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.writeOpt() = IOobject::NO_WRITE;
64 io.rename(sampleFldName);
66 sflds.set(sz, new vfType(io, fld));
67 vfType& sampleFld = sflds[sz];
69 // Reset the bcs to be directMapped
70 forAllConstIter(labelHashSet, patchSet_, iter)
72 label patchI = iter.key();
74 sampleFld.boundaryField().set
77 new selfContainedDirectMappedFixedValueFvPatchField
80 sampleFld.mesh().boundary()[patchI],
81 sampleFld.dimensionedInternalField(),
83 sampleFld.mesh().name(),
84 directMappedPatchBase::NEARESTCELL,
85 word::null, // samplePatch
88 sampleFld.name(), // fieldName
90 pTraits<Type>::zero, // average
91 interpolationCellPoint<Type>::typeName
96 Info<< " created " << sampleFld.name() << " to sample "
97 << fld.name() << endl;
105 void Foam::nearWallFields::sampleFields
107 PtrList<GeometricField<Type, fvPatchField, volMesh> >& sflds
110 typedef GeometricField<Type, fvPatchField, volMesh> vfType;
114 const word& fldName = reverseFieldMap_[sflds[i].name()];
115 const vfType& fld = obr_.lookupObject<vfType>(fldName);
117 // Take over internal and boundary values
119 // Evaluate to update the directMapped
120 sflds[i].correctBoundaryConditions();
125 // ************************************************************************* //