wallDistData.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) 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 "wallDistData.H"
30 #include "patchDataWave.H"
31 #include "wallPolyPatch.H"
32 #include "emptyFvPatchFields.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class TransferType>
38 (
39  const Foam::fvMesh& mesh,
41  const bool correctWalls
42 )
43 :
45  (
46  IOobject
47  (
48  "y",
49  mesh.time().timeName(),
50  mesh
51  ),
52  mesh,
53  dimensionedScalar("y", dimLength, GREAT)
54  ),
56  field_(field),
57  correctWalls_(correctWalls),
58  nUnset_(0)
59 {
60  correct();
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
65 
66 template<class TransferType>
68 {}
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
73 template<class TransferType>
75 {
77 
78  //
79  // Fill data on wall patches with initial values
80  //
81 
82  // Get patchids of walls
83  labelHashSet wallPatchIDs(getPatchIDs<wallPolyPatch>());
84 
85  // Collect pointers to data on patches
86  UPtrList<Field<Type>> patchData(mesh.boundaryMesh().size());
87 
89  Boundary& fieldBf = field_.boundaryFieldRef();
90 
91  forAll(fieldBf, patchi)
92  {
93  patchData.set(patchi, &fieldBf[patchi]);
94  }
95 
96  // Do mesh wave
98  (
99  mesh,
100  wallPatchIDs,
101  patchData,
102  correctWalls_
103  );
104 
105  // Transfer cell values from wave into *this and field_
106  transfer(wave.distance());
107 
108  field_.transfer(wave.cellData());
109 
110  volScalarField::Boundary& bf = boundaryFieldRef();
111 
112  // Transfer values on patches into boundaryField of *this and field_
113  forAll(bf, patchi)
114  {
115  scalarField& waveFld = wave.patchDistance()[patchi];
116 
117  if (!isA<emptyFvPatchScalarField>(bf[patchi]))
118  {
119  bf[patchi].transfer(waveFld);
120  Field<Type>& wavePatchData = wave.patchData()[patchi];
121  fieldBf[patchi].transfer(wavePatchData);
122  }
123  }
124 
125  // Transfer number of unset values
126  nUnset_ = wave.nUnset();
127 }
128 
129 
130 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
wallDistData.H
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::patchDataWave
Takes a set of patches to start MeshWave from.
Definition: patchDataWave.H:66
wallPolyPatch.H
Foam::HashSet< label, Hash< label > >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::UPtrList::transfer
void transfer(UPtrList< T > &list)
Transfer contents into this list and annul the argument.
Definition: UPtrListI.H:148
Foam::wallDistData
Wall distance calculation. Like wallDist but also transports extra data (template argument).
Definition: wallDistData.H:59
Foam::Field< scalar >
Foam::wallDistData::correct
virtual void correct()
Correct for mesh geom/topo changes.
Definition: wallDistData.C:74
correct
fvOptions correct(rho)
Foam::patchDataWave::distance
const scalarField & distance() const
Definition: patchDataWave.H:160
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:62
patchDataWave.H
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
field
rDeltaTY field()
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
emptyFvPatchFields.H
Foam::patchDataWave::cellData
const Field< Type > & cellData() const
Definition: patchDataWave.H:181
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::patchDataWave::patchData
const FieldField< Field, Type > & patchData() const
Definition: patchDataWave.H:191
Foam::cellDistFuncs
Collection of functions used in wall distance calculation.
Definition: cellDistFuncs.H:63
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::patchDataWave::nUnset
label nUnset() const
Definition: patchDataWave.H:201
Foam::wallDistData::~wallDistData
virtual ~wallDistData()
Destructor.
Definition: wallDistData.C:67
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::patchDataWave::patchDistance
const FieldField< Field, scalar > & patchDistance() const
Definition: patchDataWave.H:171