ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / nearWallFields / nearWallFields.C
blob36a5c2cfb0aba08c5d7fe200e6a988da08f29fb5
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 "nearWallFields.H"
27 #include "wordReList.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 defineTypeNameAndDebug(Foam::nearWallFields, 0);
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 Foam::nearWallFields::nearWallFields
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             "nearWallFields::nearWallFields"
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::nearWallFields::~nearWallFields()
76 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
78 void Foam::nearWallFields::read(const dictionary& dict)
80     if (active_)
81     {
82         const fvMesh& mesh = refCast<const fvMesh>(obr_);
84         dict.lookup("fields") >> fieldSet_;
85         patchSet_ = mesh.boundaryMesh().patchSet
86         (
87             wordReList(dict.lookup("patches"))
88         );
89         distance_ = readScalar(dict.lookup("distance"));
92         // Clear out any previously loaded fields 
93         vsf_.clear();
94         vvf_.clear();
95         vSpheretf_.clear();
96         vSymmtf_.clear();
97         vtf_.clear();
98         fieldMap_.clear();
99         reverseFieldMap_.clear();
102         // Generate fields with selfContainedDirectMapped bc.
104         // Convert field to map
105         fieldMap_.resize(2*fieldSet_.size());
106         reverseFieldMap_.resize(2*fieldSet_.size());
107         forAll(fieldSet_, setI)
108         {
109             const word& fldName = fieldSet_[setI].first();
110             const word& sampleFldName = fieldSet_[setI].second();
112             fieldMap_.insert(fldName, sampleFldName);
113             reverseFieldMap_.insert(sampleFldName, fldName);
114         }
116         createFields(vsf_);
117         createFields(vvf_);
118         createFields(vSpheretf_);
119         createFields(vSymmtf_);
120         createFields(vtf_);
121     }
125 void Foam::nearWallFields::execute()
127     if (active_)
128     {
129         sampleFields(vsf_);
130         sampleFields(vvf_);
131         sampleFields(vSpheretf_);
132         sampleFields(vSymmtf_);
133         sampleFields(vtf_);
134     }
138 void Foam::nearWallFields::end()
140     // Do nothing
144 void Foam::nearWallFields::write()
146     // Do nothing
147     if (active_)
148     {
149         Info<< "Writing sampled fields to " << obr_.time().timeName()
150             << endl;
152         // Write fields
153         forAll(vsf_, i)
154         {
155             vsf_[i].write();
156         }
157         forAll(vvf_, i)
158         {
159             vvf_[i].write();
160         }
161         forAll(vSpheretf_, i)
162         {
163             vSpheretf_[i].write();
164         }
165         forAll(vSymmtf_, i)
166         {
167             vSymmtf_[i].write();
168         }
169         forAll(vtf_, i)
170         {
171             vtf_[i].write();
172         }
173     }
177 // ************************************************************************* //