OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

IOField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "IOField.H"
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 template<class Type>
00032 Foam::IOField<Type>::IOField(const IOobject& io)
00033 :
00034     regIOobject(io)
00035 {
00036     if
00037     (
00038         io.readOpt() == IOobject::MUST_READ
00039      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00040     )
00041     {
00042         readStream(typeName) >> *this;
00043         close();
00044     }
00045 }
00046 
00047 
00048 template<class Type>
00049 Foam::IOField<Type>::IOField(const IOobject& io, const label size)
00050 :
00051     regIOobject(io)
00052 {
00053     if
00054     (
00055         io.readOpt() == IOobject::MUST_READ
00056      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00057     )
00058     {
00059         readStream(typeName) >> *this;
00060         close();
00061     }
00062     else
00063     {
00064         Field<Type>::setSize(size);
00065     }
00066 }
00067 
00068 
00069 template<class Type>
00070 Foam::IOField<Type>::IOField(const IOobject& io, const Field<Type>& f)
00071 :
00072     regIOobject(io)
00073 {
00074     if
00075     (
00076         io.readOpt() == IOobject::MUST_READ
00077      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00078     )
00079     {
00080         readStream(typeName) >> *this;
00081         close();
00082     }
00083     else
00084     {
00085         Field<Type>::operator=(f);
00086     }
00087 }
00088 
00089 
00090 template<class Type>
00091 Foam::IOField<Type>::IOField(const IOobject& io, const Xfer<Field<Type> >& f)
00092 :
00093     regIOobject(io)
00094 {
00095     Field<Type>::transfer(f());
00096 
00097     if
00098     (
00099         io.readOpt() == IOobject::MUST_READ
00100      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00101     )
00102     {
00103         readStream(typeName) >> *this;
00104         close();
00105     }
00106 }
00107 
00108 
00109 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
00110 
00111 template<class Type>
00112 Foam::IOField<Type>::~IOField()
00113 {}
00114 
00115 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00116 
00117 template<class Type>
00118 bool Foam::IOField<Type>::writeData(Ostream& os) const
00119 {
00120     return (os << static_cast<const Field<Type>&>(*this)).good();
00121 }
00122 
00123 
00124 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00125 
00126 template<class Type>
00127 void Foam::IOField<Type>::operator=(const IOField<Type>& rhs)
00128 {
00129     Field<Type>::operator=(rhs);
00130 }
00131 
00132 
00133 template<class Type>
00134 void Foam::IOField<Type>::operator=(const Field<Type>& rhs)
00135 {
00136     Field<Type>::operator=(rhs);
00137 }
00138 
00139 
00140 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd