directionalMeshWavePatchDistMethod.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) 2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "patchDataWave.H"
30 #include "fvMesh.H"
31 #include "volFields.H"
33 #include "emptyFvPatchFields.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 namespace patchDistMethods
41 {
42  defineTypeNameAndDebug(directionalMeshWave, 0);
44  (
45  patchDistMethod,
46  directionalMeshWave,
47  dictionary
48  );
49 }
50 }
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 Foam::patchDistMethods::directionalMeshWave::directionalMeshWave
55 (
56  const dictionary& dict,
57  const fvMesh& mesh,
58  const labelHashSet& patchIDs
59 )
60 :
62  n_(dict.get<vector>("normal"))
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
69 {
70  y = dimensionedScalar(dimLength, GREAT);
71 
73  (
74  IOobject
75  (
76  "nWall",
77  y.time().timeName(),
78  mesh_,
81  false
82  ),
83  mesh_,
85  patchDistMethod::patchTypes<scalar>(mesh_, patchIDs_)
86  );
87 
88  const fvPatchList& patches = mesh_.boundary();
89 
90  volVectorField::Boundary& nbf = n.boundaryFieldRef();
91 
92  for (const label patchi : patchIDs_)
93  {
94  nbf[patchi] == patches[patchi].nf();
95  }
96 
97  return correct(y, n);
98 }
99 
100 
102 (
103  volScalarField& y,
105 )
106 {
107  y = dimensionedScalar(dimLength, GREAT);
108 
109  // Collect pointers to data on patches
110  UPtrList<vectorField> patchData(mesh_.boundaryMesh().size());
111 
112  volVectorField::Boundary& nbf = n.boundaryFieldRef();
113 
114  forAll(nbf, patchi)
115  {
116  patchData.set(patchi, &nbf[patchi]);
117  }
118 
119  // Do mesh wave
120  vector testDirection(n_);
121 
123  (
124  mesh_,
125  patchIDs_,
126  patchData,
127  correctWalls_,
128  testDirection
129  );
130 
131  // Transfer cell values from wave into y and n
132  y.transfer(wave.distance());
133 
134  n.transfer(wave.cellData());
135 
136  // Transfer values on patches into boundaryField of y and n
137  volScalarField::Boundary& ybf = y.boundaryFieldRef();
138 
139  forAll(ybf, patchi)
140  {
141  scalarField& waveFld = wave.patchDistance()[patchi];
142 
143  if (!isA<emptyFvPatchScalarField>(ybf[patchi]))
144  {
145  ybf[patchi].transfer(waveFld);
146 
147  vectorField& wavePatchData = wave.patchData()[patchi];
148 
149  nbf[patchi].transfer(wavePatchData);
150  }
151  }
152 
153  // Transfer number of unset values
154  this->nUnset_ = wave.nUnset();
155 
156  return this->nUnset_ > 0;
157 }
158 
159 
160 // ************************************************************************* //
directionalWallPointData.H
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
volFields.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::patchDataWave
Takes a set of patches to start MeshWave from.
Definition: patchDataWave.H:66
Foam::HashSet< label, Hash< label > >
Foam::patchDistMethods::defineTypeNameAndDebug
defineTypeNameAndDebug(advectionDiffusion, 0)
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::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:50
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::Field< scalar >
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
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
emptyFvPatchFields.H
Foam::patchDataWave::cellData
const Field< Type > & cellData() const
Definition: patchDataWave.H:181
directionalMeshWavePatchDistMethod.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::patchDistMethod::mesh_
const fvMesh & mesh_
Reference to the mesh.
Definition: patchDistMethod.H:66
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchDistMethod::patchIDs_
const labelHashSet patchIDs_
Set of patch IDs.
Definition: patchDistMethod.H:69
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:685
Foam::patchDistMethods::addToRunTimeSelectionTable
addToRunTimeSelectionTable(patchDistMethod, advectionDiffusion, dictionary)
Foam::patchDataWave::patchData
const FieldField< Field, Type > & patchData() const
Definition: patchDataWave.H:191
Foam::Vector< scalar >
Foam::patchDistMethods::directionalMeshWave::correct
virtual bool correct(volScalarField &y)
Correct the given distance-to-patch field.
Definition: directionalMeshWavePatchDistMethod.C:68
Foam::patchDataWave::nUnset
label nUnset() const
Definition: patchDataWave.H:201
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::patchDistMethods::meshWave
Fast topological mesh-wave method for calculating the distance to nearest patch for all cells and bou...
Definition: meshWavePatchDistMethod.H:76
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::patchDataWave::patchDistance
const FieldField< Field, scalar > & patchDistance() const
Definition: patchDataWave.H:171
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189
y
scalar y
Definition: LISASMDCalcMethod1.H:14