ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / nearWallFields / nearWallFieldsTemplates.C
blob0436d2ddbbb84c45a101e735de6ba758d6c40702
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.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)
71                 {
72                     label patchI = iter.key();
74                     sampleFld.boundaryField().set
75                     (
76                         patchI,
77                         new selfContainedDirectMappedFixedValueFvPatchField
78                             <Type>
79                         (
80                             sampleFld.mesh().boundary()[patchI],
81                             sampleFld.dimensionedInternalField(),
83                             sampleFld.mesh().name(),
84                             directMappedPatchBase::NEARESTCELL,
85                             word::null,     // samplePatch
86                             -distance_,
88                             sampleFld.name(),       // fieldName
89                             false,                  // setAverage
90                             pTraits<Type>::zero,    // average
91                             interpolationCellPoint<Type>::typeName
92                         )
93                     );
94                 }
96                 Info<< "    created " << sampleFld.name() << " to sample "
97                     << fld.name() << endl;
98             }
99         }
100     }
104 template<class Type>
105 void Foam::nearWallFields::sampleFields
107     PtrList<GeometricField<Type, fvPatchField, volMesh> >& sflds
108 ) const
110     typedef GeometricField<Type, fvPatchField, volMesh> vfType;
112     forAll(sflds, i)
113     {
114         const word& fldName = reverseFieldMap_[sflds[i].name()];
115         const vfType& fld = obr_.lookupObject<vfType>(fldName);
117         // Take over internal and boundary values
118         sflds[i] == fld;
119         // Evaluate to update the directMapped
120         sflds[i].correctBoundaryConditions();
121     }
125 // ************************************************************************* //