Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / nearWallFields / nearWallFieldsTemplates.C
blob8f237edc12ef9d90ea763de5353de69886235937
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 "selfContainedDirectMappedFixedValueFvPatchFields.H"
28 #include "interpolationCellPoint.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 template<class Type>
33 void Foam::nearWallFields::createFields
35     PtrList<GeometricField<Type, fvPatchField, volMesh> >& sflds
36 ) const
38     typedef GeometricField<Type, fvPatchField, volMesh> vfType;
40     HashTable<const vfType*> flds(obr_.lookupClass<vfType>());
42     forAllConstIter(typename HashTable<const vfType*>, flds, iter)
43     {
44         const vfType& fld = *iter();
46         if (fieldMap_.found(fld.name()))
47         {
48             const word& sampleFldName = fieldMap_[fld.name()];
50             if (obr_.found(sampleFldName))
51             {
52                 Info<< "    a field " << sampleFldName
53                     << " already exists on the mesh."
54                     << endl;
55             }
56             else
57             {
58                 label sz = sflds.size();
59                 sflds.setSize(sz+1);
61                 IOobject io(fld);
62                 io.readOpt() = IOobject::NO_READ;
63                 io.rename(sampleFldName);
65                 sflds.set(sz, new vfType(io, fld));
66                 vfType& sampleFld = sflds[sz];
68                 // Reset the bcs to be directMapped
69                 forAllConstIter(labelHashSet, patchSet_, iter)
70                 {
71                     label patchI = iter.key();
73                     sampleFld.boundaryField().set
74                     (
75                         patchI,
76                         new selfContainedDirectMappedFixedValueFvPatchField
77                             <Type>
78                         (
79                             sampleFld.mesh().boundary()[patchI],
80                             sampleFld.dimensionedInternalField(),
82                             sampleFld.mesh().name(),
83                             directMappedPatchBase::NEARESTCELL,
84                             word::null,     // samplePatch
85                             -distance_,
87                             sampleFld.name(),       // fieldName
88                             false,                  // setAverage
89                             pTraits<Type>::zero,    // average
90                             interpolationCellPoint<Type>::typeName
91                         )
92                     );
93                 }
95                 Info<< "    created " << sampleFld.name() << " to sample "
96                     << fld.name() << endl;
97             }
98         }
99     }
103 template<class Type>
104 void Foam::nearWallFields::sampleFields
106     PtrList<GeometricField<Type, fvPatchField, volMesh> >& sflds
107 ) const
109     typedef GeometricField<Type, fvPatchField, volMesh> vfType;
111     forAll(sflds, i)
112     {
113         const word& fldName = reverseFieldMap_[sflds[i].name()];
114         const vfType& fld = obr_.lookupObject<vfType>(fldName);
116         // Take over internal and boundary values
117         sflds[i] == fld;
118         // Evaluate to update the directMapped
119         sflds[i].correctBoundaryConditions();
120     }
124 // ************************************************************************* //