nearWallFieldsTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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  sflds.set
60  (
61  sz,
62  new VolFieldType
63  (
64  IOobject
65  (
66  sampleFldName,
67  time_.timeName(),
68  mesh_
69  ),
70  fld,
71  calculatedFvPatchScalarField::typeName
72  )
73  );
74 
75  Log << " created " << sflds[sz].name()
76  << " to sample " << fld.name() << endl;
77  }
78  }
79  }
80 }
81 
82 
83 template<class Type>
85 (
86  const interpolationCellPoint<Type>& interpolator,
88 ) const
89 {
90  // Construct flat fields for all patch faces to be sampled
91  Field<Type> sampledValues(getPatchDataMapPtr_().constructSize());
92 
93  forAll(cellToWalls_, celli)
94  {
95  const labelList& cData = cellToWalls_[celli];
96 
97  forAll(cData, i)
98  {
99  const point& samplePt = cellToSamples_[celli][i];
100  sampledValues[cData[i]] = interpolator.interpolate(samplePt, celli);
101  }
102  }
103 
104  // Send back sampled values to patch faces
105  getPatchDataMapPtr_().reverseDistribute
106  (
107  getPatchDataMapPtr_().constructSize(),
108  sampledValues
109  );
110 
112  Boundary& fldBf = fld.boundaryFieldRef();
113 
114  // Pick up data
115  label nPatchFaces = 0;
116  forAllConstIter(labelHashSet, patchSet_, iter)
117  {
118  label patchi = iter.key();
119 
120  fvPatchField<Type>& pfld = fldBf[patchi];
121 
122  Field<Type> newFld(pfld.size());
123  forAll(pfld, i)
124  {
125  newFld[i] = sampledValues[nPatchFaces++];
126  }
127 
128  pfld == newFld;
129  }
130 }
131 
132 
133 template<class Type>
135 (
137 ) const
138 {
139  typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
140 
141  forAll(sflds, i)
142  {
143  const word& fldName = reverseFieldMap_[sflds[i].name()];
144  const VolFieldType& fld = obr_.lookupObject<VolFieldType>(fldName);
145 
146  // Take over internal and boundary values
147  sflds[i] == fld;
148 
149  // Construct interpolation method
150  interpolationCellPoint<Type> interpolator(fld);
151 
152  // Override sampled values
153  sampleBoundaryField(interpolator, sflds[i]);
154  }
155 }
156 
157 
158 // ************************************************************************* //
#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.
Definition: ListI.H:163
void sampleBoundaryField(const interpolationCellPoint< Type > &interpolator, GeometricField< Type, fvPatchField, volMesh > &fld) const
Override boundary fields with sampled values.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
Generic GeometricField class.
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
Type interpolate(const cellPointWeight &cpw) const
Interpolate field for the given cellPointWeight.
An STL-conforming hash table.
Definition: HashTable.H:62
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
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:63
#define Log
Report write to Foam::Info if the local log switch is true.
void createFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
void sampleFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92