Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / readFields / readFields.C
blob84ac43d24338907ac7f08df2875c4994a591be17
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "readFields.H"
27 #include "dictionary.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 defineTypeNameAndDebug(Foam::readFields, 0);
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 Foam::readFields::readFields
38     const word& name,
39     const objectRegistry& obr,
40     const dictionary& dict,
41     const bool loadFromFiles
44     name_(name),
45     obr_(obr),
46     active_(true),
47     fieldSet_()
49     // Check if the available mesh is an fvMesh otherise deactivate
50     if (!isA<fvMesh>(obr_))
51     {
52         active_ = false;
53         WarningIn
54         (
55             "readFields::readFields"
56             "("
57                 "const word&, "
58                 "const objectRegistry&, "
59                 "const dictionary&, "
60                 "const bool"
61             ")"
62         )   << "No fvMesh available, deactivating."
63             << endl;
64     }
66     read(dict);
70 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
72 Foam::readFields::~readFields()
76 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
78 void Foam::readFields::read(const dictionary& dict)
80     if (active_)
81     {
82         dict.lookup("fields") >> fieldSet_;
83     }
87 void Foam::readFields::execute()
89     //Info<< type() << " " << name_ << ":" << nl;
91     // Clear out any previously loaded fields 
92     vsf_.clear();
93     vvf_.clear();
94     vSpheretf_.clear();
95     vSymmtf_.clear();
96     vtf_.clear();
98     ssf_.clear();
99     svf_.clear();
100     sSpheretf_.clear();
101     sSymmtf_.clear();
102     stf_.clear();
104     forAll(fieldSet_, fieldI)
105     {
106         // If necessary load field
107         loadField<scalar>(fieldSet_[fieldI], vsf_, ssf_);
108         loadField<vector>(fieldSet_[fieldI], vvf_, svf_);
109         loadField<sphericalTensor>(fieldSet_[fieldI], vSpheretf_, sSpheretf_);
110         loadField<symmTensor>(fieldSet_[fieldI], vSymmtf_, sSymmtf_);
111         loadField<tensor>(fieldSet_[fieldI], vtf_, stf_);
112     }
116 void Foam::readFields::end()
118     // Do nothing
122 void Foam::readFields::write()
124     // Do nothing
128 // ************************************************************************* //