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-2016 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 VolFieldType*> flds(obr_.lookupClass<VolFieldType>());
39 
41  {
42  const VolFieldType& 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  Log << " 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 VolFieldType(io, fld));
65 
66  Log << " created " << sflds[sz].name()
67  << " to sample " << 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 
103  Boundary& fldBf = fld.boundaryFieldRef();
104 
105  // Pick up data
106  label nPatchFaces = 0;
107  forAllConstIter(labelHashSet, patchSet_, iter)
108  {
109  label patchi = iter.key();
110 
111  fvPatchField<Type>& pfld = fldBf[patchi];
112 
113  Field<Type> newFld(pfld.size());
114  forAll(pfld, i)
115  {
116  newFld[i] = sampledValues[nPatchFaces++];
117  }
118 
119  pfld == newFld;
120  }
121 }
122 
123 
124 template<class Type>
126 (
128 ) const
129 {
130  typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
131 
132  forAll(sflds, i)
133  {
134  const word& fldName = reverseFieldMap_[sflds[i].name()];
135  const VolFieldType& fld = obr_.lookupObject<VolFieldType>(fldName);
136 
137  // Take over internal and boundary values
138  sflds[i] == fld;
139 
140  // Construct interpolation method
141  interpolationCellPoint<Type> interpolator(fld);
142 
143  // Override sampled values
144  sampleBoundaryField(interpolator, sflds[i]);
145  }
146 }
147 
148 
149 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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 size(const label)
Override size to be inconsistent with allocated storage.
virtual void rename(const word &newName)
Rename.
Definition: IOobject.H:284
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Generic GeometricField class.
writeOption writeOpt() const
Definition: IOobject.H:314
void createFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
void sampleFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
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))
Pre-declare SubField and related Field type.
Definition: Field.H:57
A class for handling words, derived from string.
Definition: word.H:59
An STL-conforming hash table.
Definition: HashTable.H:61
void sampleBoundaryField(const interpolationCellPoint< Type > &interpolator, GeometricField< Type, fvPatchField, volMesh > &fld) const
Override boundary fields with sampled values.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
Type interpolate(const cellPointWeight &cpw) const
Interpolate field for the given cellPointWeight.
label patchi
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:62
readOption readOpt() const
Definition: IOobject.H:304
#define Log
Report write to Foam::Info if the local log switch is true.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91