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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "nearWallFields.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
37 ) const
38 {
40 
41  HashTable<const VolFieldType*> flds(obr_.lookupClass<VolFieldType>());
42 
43  forAllConstIters(flds, iter)
44  {
45  const VolFieldType& fld = *(iter.val());
46 
47  if (fieldMap_.found(fld.name()))
48  {
49  const word& sampleFldName = fieldMap_[fld.name()];
50 
51  if (obr_.found(sampleFldName))
52  {
54  << " a field named " << sampleFldName
55  << " already exists on the mesh"
56  << endl;
57  }
58  else
59  {
60  label sz = sflds.size();
61  sflds.setSize(sz+1);
62 
63  IOobject io(fld);
64  io.readOpt() = IOobject::NO_READ;
65  io.writeOpt() = IOobject::NO_WRITE;
66 
67  // Override bc to be calculated
68  wordList fldTypes(fld.boundaryField().types());
69  for (const label patchi : patchSet_)
70  {
71  fldTypes[patchi] = calculatedFvPatchField<Type>::typeName;
72  }
73 
74  io.rename(sampleFldName);
75 
76  sflds.set(sz, new VolFieldType(io, fld, fldTypes));
77 
78  Log << " created " << sflds[sz].name()
79  << " to sample " << fld.name() << endl;
80  }
81  }
82  }
83 }
84 
85 
86 template<class Type>
88 (
89  const interpolationCellPoint<Type>& interpolator,
91 ) const
92 {
93  // Construct flat fields for all patch faces to be sampled
94  Field<Type> sampledValues(getPatchDataMapPtr_().constructSize());
95 
96  forAll(cellToWalls_, celli)
97  {
98  const labelList& cData = cellToWalls_[celli];
99 
100  forAll(cData, i)
101  {
102  const point& samplePt = cellToSamples_[celli][i];
103  sampledValues[cData[i]] = interpolator.interpolate(samplePt, celli);
104  }
105  }
106 
107  // Send back sampled values to patch faces
108  getPatchDataMapPtr_().reverseDistribute
109  (
110  getPatchDataMapPtr_().constructSize(),
111  sampledValues
112  );
113 
115  Boundary& fldBf = fld.boundaryFieldRef();
116 
117  // Pick up data
118  label nPatchFaces = 0;
119  for (const label patchi : patchSet_)
120  {
121  fvPatchField<Type>& pfld = fldBf[patchi];
122 
123  Field<Type> newFld(pfld.size());
124  forAll(pfld, i)
125  {
126  newFld[i] = sampledValues[nPatchFaces++];
127  }
128 
129  pfld == newFld;
130  }
131 }
132 
133 
134 template<class Type>
136 (
138 ) const
139 {
140  typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
141 
142  forAll(sflds, i)
143  {
144  const word& fldName = reverseFieldMap_[sflds[i].name()];
145  const VolFieldType& fld = obr_.lookupObject<VolFieldType>(fldName);
146 
147  // Take over internal and boundary values
148  sflds[i] == fld;
149 
150  // Construct interpolation method
151  interpolationCellPoint<Type> interpolator(fld);
152 
153  // Override sampled values
154  sampleBoundaryField(interpolator, sflds[i]);
155  }
156 }
157 
158 
159 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
nearWallFields.H
Foam::label
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:62
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::IOobject::writeOpt
writeOption writeOpt() const
The write option.
Definition: IOobjectI.H:153
Foam::interpolationCellPoint
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
Definition: interpolationCellPoint.H:50
Foam::functionObjects::nearWallFields::sampleBoundaryField
void sampleBoundaryField(const interpolationCellPoint< Type > &interpolator, GeometricField< Type, fvPatchField, volMesh > &fld) const
Override boundary fields with sampled values.
Definition: nearWallFieldsTemplates.C:88
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:65
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::interpolationCellPoint::interpolate
Type interpolate(const cellPointWeight &cpw) const
Interpolate field for the given cellPointWeight.
Definition: interpolationCellPointI.H:32
Foam::calculatedFvPatchField
This boundary condition is not designed to be evaluated; it is assmued that the value is assigned via...
Definition: calculatedFvPatchField.H:66
Foam::IOobject::rename
virtual void rename(const word &newName)
Rename.
Definition: IOobject.H:368
Foam::functionObjects::nearWallFields::sampleFields
void sampleFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
Definition: nearWallFieldsTemplates.C:136
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::functionObjects::nearWallFields::createFields
void createFields(PtrList< GeometricField< Type, fvPatchField, volMesh >> &) const
Definition: nearWallFieldsTemplates.C:35
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::Vector< scalar >
Foam::List< word >
Foam::IOobject::readOpt
readOption readOpt() const
The read option.
Definition: IOobjectI.H:141
Foam::GeometricField< Type, fvPatchField, volMesh >
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
Log
#define Log
Report write to Foam::Info if the local log switch is true.
Definition: messageStream.H:332