FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/IOField.H>
00027 
00028 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00029 
00030 template<class Type>
00031 Foam::IOField<Type>::IOField(const IOobject& io)
00032 :
00033     regIOobject(io)
00034 {
00035     if
00036     (
00037         io.readOpt() == IOobject::MUST_READ
00038      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00039     )
00040     {
00041         readStream(typeName) >> *this;
00042         close();
00043     }
00044 }
00045 
00046 
00047 template<class Type>
00048 Foam::IOField<Type>::IOField(const IOobject& io, const label size)
00049 :
00050     regIOobject(io)
00051 {
00052     if
00053     (
00054         io.readOpt() == IOobject::MUST_READ
00055      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00056     )
00057     {
00058         readStream(typeName) >> *this;
00059         close();
00060     }
00061     else
00062     {
00063         Field<Type>::setSize(size);
00064     }
00065 }
00066 
00067 
00068 template<class Type>
00069 Foam::IOField<Type>::IOField(const IOobject& io, const Field<Type>& f)
00070 :
00071     regIOobject(io)
00072 {
00073     if
00074     (
00075         io.readOpt() == IOobject::MUST_READ
00076      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00077     )
00078     {
00079         readStream(typeName) >> *this;
00080         close();
00081     }
00082     else
00083     {
00084         Field<Type>::operator=(f);
00085     }
00086 }
00087 
00088 
00089 template<class Type>
00090 Foam::IOField<Type>::IOField(const IOobject& io, const Xfer<Field<Type> >& f)
00091 :
00092     regIOobject(io)
00093 {
00094     Field<Type>::transfer(f());
00095 
00096     if
00097     (
00098         io.readOpt() == IOobject::MUST_READ
00099      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00100     )
00101     {
00102         readStream(typeName) >> *this;
00103         close();
00104     }
00105 }
00106 
00107 
00108 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
00109 
00110 template<class Type>
00111 Foam::IOField<Type>::~IOField()
00112 {}
00113 
00114 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00115 
00116 template<class Type>
00117 bool Foam::IOField<Type>::writeData(Ostream& os) const
00118 {
00119     return (os << static_cast<const Field<Type>&>(*this)).good();
00120 }
00121 
00122 
00123 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00124 
00125 template<class Type>
00126 void Foam::IOField<Type>::operator=(const IOField<Type>& rhs)
00127 {
00128     Field<Type>::operator=(rhs);
00129 }
00130 
00131 
00132 template<class Type>
00133 void Foam::IOField<Type>::operator=(const Field<Type>& rhs)
00134 {
00135     Field<Type>::operator=(rhs);
00136 }
00137 
00138 
00139 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines