1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 void Foam::nearWallFields::createFields
35 PtrList<GeometricField<Type, fvPatchField, volMesh> >& sflds
38 typedef GeometricField<Type, fvPatchField, volMesh> vfType;
40 HashTable<const vfType*> flds(obr_.lookupClass<vfType>());
42 forAllConstIter(typename HashTable<const vfType*>, flds, iter)
44 const vfType& fld = *iter();
46 if (fieldMap_.found(fld.name()))
48 const word& sampleFldName = fieldMap_[fld.name()];
50 if (obr_.found(sampleFldName))
52 Info<< " a field " << sampleFldName
53 << " already exists on the mesh."
58 label sz = sflds.size();
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)
71 label patchI = iter.key();
73 sampleFld.boundaryField().set
76 new selfContainedDirectMappedFixedValueFvPatchField
79 sampleFld.mesh().boundary()[patchI],
80 sampleFld.dimensionedInternalField(),
82 sampleFld.mesh().name(),
83 directMappedPatchBase::NEARESTCELL,
84 word::null, // samplePatch
87 sampleFld.name(), // fieldName
89 pTraits<Type>::zero, // average
90 interpolationCellPoint<Type>::typeName
95 Info<< " created " << sampleFld.name() << " to sample "
96 << fld.name() << endl;
104 void Foam::nearWallFields::sampleFields
106 PtrList<GeometricField<Type, fvPatchField, volMesh> >& sflds
109 typedef GeometricField<Type, fvPatchField, volMesh> vfType;
113 const word& fldName = reverseFieldMap_[sflds[i].name()];
114 const vfType& fld = obr_.lookupObject<vfType>(fldName);
116 // Take over internal and boundary values
118 // Evaluate to update the directMapped
119 sflds[i].correctBoundaryConditions();
124 // ************************************************************************* //