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

readFields.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) 2010-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 "readFields.H"
00027 #include <OpenFOAM/dictionary.H>
00028 
00029 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033     defineTypeNameAndDebug(readFields, 0);
00034 }
00035 
00036 
00037 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00038 
00039 Foam::readFields::readFields
00040 (
00041     const word& name,
00042     const objectRegistry& obr,
00043     const dictionary& dict,
00044     const bool loadFromFiles
00045 )
00046 :
00047     name_(name),
00048     obr_(obr),
00049     active_(true),
00050     fieldSet_()
00051 {
00052     // Check if the available mesh is an fvMesh otherise deactivate
00053     if (!isA<fvMesh>(obr_))
00054     {
00055         active_ = false;
00056         WarningIn
00057         (
00058             "readFields::readFields"
00059             "("
00060                 "const word&, "
00061                 "const objectRegistry&, "
00062                 "const dictionary&, "
00063                 "const bool"
00064             ")"
00065         )   << "No fvMesh available, deactivating."
00066             << endl;
00067     }
00068 
00069     read(dict);
00070 }
00071 
00072 
00073 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00074 
00075 Foam::readFields::~readFields()
00076 {}
00077 
00078 
00079 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00080 
00081 void Foam::readFields::read(const dictionary& dict)
00082 {
00083     if (active_)
00084     {
00085         dict.lookup("fields") >> fieldSet_;
00086     }
00087 }
00088 
00089 
00090 void Foam::readFields::execute()
00091 {
00092     //Info<< type() << " " << name_ << ":" << nl;
00093 
00094     // Clear out any previously loaded fields 
00095     vsf_.clear();
00096     vvf_.clear();
00097     vSpheretf_.clear();
00098     vSymmtf_.clear();
00099     vtf_.clear();
00100 
00101     ssf_.clear();
00102     svf_.clear();
00103     sSpheretf_.clear();
00104     sSymmtf_.clear();
00105     stf_.clear();
00106 
00107     forAll(fieldSet_, fieldI)
00108     {
00109         // If necessary load field
00110         loadField<scalar>(fieldSet_[fieldI], vsf_, ssf_);
00111         loadField<vector>(fieldSet_[fieldI], vvf_, svf_);
00112         loadField<sphericalTensor>(fieldSet_[fieldI], vSpheretf_, sSpheretf_);
00113         loadField<symmTensor>(fieldSet_[fieldI], vSymmtf_, sSymmtf_);
00114         loadField<tensor>(fieldSet_[fieldI], vtf_, stf_);
00115     }
00116 }
00117 
00118 
00119 void Foam::readFields::end()
00120 {
00121     // Do nothing
00122 }
00123 
00124 
00125 void Foam::readFields::write()
00126 {
00127     // Do nothing
00128 }
00129 
00130 
00131 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines