nearWallFieldsTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "nearWallFields.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
34 ) const
35 {
37 
38  HashTable<const vfType*> flds(obr_.lookupClass<vfType>());
39 
40  forAllConstIter(typename HashTable<const vfType*>, flds, iter)
41  {
42  const vfType& fld = *iter();
43 
44  if (fieldMap_.found(fld.name()))
45  {
46  const word& sampleFldName = fieldMap_[fld.name()];
47 
48  if (obr_.found(sampleFldName))
49  {
50  Info<< " a field " << sampleFldName
51  << " already exists on the mesh."
52  << endl;
53  }
54  else
55  {
56  label sz = sflds.size();
57  sflds.setSize(sz+1);
58 
59  IOobject io(fld);
60  io.readOpt() = IOobject::NO_READ;
61  io.writeOpt() = IOobject::NO_WRITE;
62  io.rename(sampleFldName);
63 
64  sflds.set(sz, new vfType(io, fld));
65 
66  Info<< " created " << sflds[sz].name() << " to sample "
67  << fld.name() << endl;
68  }
69  }
70  }
71 }
72 
73 
74 template<class Type>
76 (
77  const interpolationCellPoint<Type>& interpolator,
79 ) const
80 {
81  // Construct flat fields for all patch faces to be sampled
82  Field<Type> sampledValues(getPatchDataMapPtr_().constructSize());
83 
84  forAll(cellToWalls_, cellI)
85  {
86  const labelList& cData = cellToWalls_[cellI];
87 
88  forAll(cData, i)
89  {
90  const point& samplePt = cellToSamples_[cellI][i];
91  sampledValues[cData[i]] = interpolator.interpolate(samplePt, cellI);
92  }
93  }
94 
95  // Send back sampled values to patch faces
96  getPatchDataMapPtr_().reverseDistribute
97  (
98  getPatchDataMapPtr_().constructSize(),
99  sampledValues
100  );
101 
102  // Pick up data
103  label nPatchFaces = 0;
104  forAllConstIter(labelHashSet, patchSet_, iter)
105  {
106  label patchI = iter.key();
107 
108  fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
109 
110  Field<Type> newFld(pfld.size());
111  forAll(pfld, i)
112  {
113  newFld[i] = sampledValues[nPatchFaces++];
114  }
115 
116  pfld == newFld;
117  }
118 }
119 
120 
121 template<class Type>
123 (
125 ) const
126 {
128 
129  forAll(sflds, i)
130  {
131  const word& fldName = reverseFieldMap_[sflds[i].name()];
132  const vfType& fld = obr_.lookupObject<vfType>(fldName);
133 
134  // Take over internal and boundary values
135  sflds[i] == fld;
136 
137  // Construct interpolation method
138  interpolationCellPoint<Type> interpolator(fld);
139 
140  // Override sampled values
141  sampleBoundaryField(interpolator, sflds[i]);
142  }
143 }
144 
145 
146 // ************************************************************************* //
readOption readOpt() const
Definition: IOobject.H:304
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
virtual void rename(const word &newName)
Rename.
Definition: IOobject.H:284
An STL-conforming hash table.
Definition: HashTable.H:61
A class for handling words, derived from string.
Definition: word.H:59
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void sampleBoundaryField(const interpolationCellPoint< Type > &interpolator, GeometricField< Type, fvPatchField, volMesh > &fld) const
Override boundary fields with sampled values.
void size(const label)
Override size to be inconsistent with allocated storage.
messageStream Info
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define forAll(list, i)
Definition: UList.H:421
writeOption writeOpt() const
Definition: IOobject.H:314
Type interpolate(const cellPointWeight &cpw) const
Interpolate field for the given cellPointWeight.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
void sampleFields(PtrList< GeometricField< Type, fvPatchField, volMesh > > &) const
Pre-declare SubField and related Field type.
Definition: Field.H:57
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject( name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE ))
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
Generic GeometricField class.
void createFields(PtrList< GeometricField< Type, fvPatchField, volMesh > > &) const