externalDisplacementMeshMover.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) 2013-2015 OpenFOAM Foundation
9  Copyright (C) 2015-2021 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 
30 #include "mapPolyMesh.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(externalDisplacementMeshMover, 0);
39 }
40 
41 
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43 
45 (
46  const pointVectorField& field
47 )
48 {
49  DynamicList<label> adaptPatchIDs;
50 
51  forAll(field.boundaryField(), patchI)
52  {
53  const auto& patchField = field.boundaryField()[patchI];
54 
55  if (isA<zeroValuePointPatchField<vector>>(patchField))
56  {
57  // Special condition of fixed boundary condition. Does not
58  // get adapted
59  }
60  else if (isA<valuePointPatchField<vector>>(patchField))
61  {
62  adaptPatchIDs.append(patchI);
63  }
64  }
65 
66  return adaptPatchIDs;
67 }
68 
69 
72 (
73  const polyMesh& mesh,
74  const labelList& patchIDs
75 )
76 {
78 
79  // Count faces.
80  label nFaces = 0;
81 
82  forAll(patchIDs, i)
83  {
84  const polyPatch& pp = patches[patchIDs[i]];
85 
86  nFaces += pp.size();
87  }
88 
89  // Collect faces.
90  labelList addressing(nFaces);
91  nFaces = 0;
92 
93  forAll(patchIDs, i)
94  {
95  const polyPatch& pp = patches[patchIDs[i]];
96 
97  label meshFaceI = pp.start();
98 
99  forAll(pp, i)
100  {
101  addressing[nFaces++] = meshFaceI++;
102  }
103  }
104 
106  (
107  IndirectList<face>(mesh.faces(), std::move(addressing)),
108  mesh.points()
109  );
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
114 
115 Foam::externalDisplacementMeshMover::externalDisplacementMeshMover
116 (
117  const dictionary& dict,
118  const List<labelPair>& baffles,
119  pointVectorField& pointDisplacement,
120  const bool dryRun
121 )
122 :
123  baffles_(baffles),
124  pointDisplacement_(pointDisplacement),
125  dryRun_(dryRun)
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
130 
133 (
134  const word& type,
135  const dictionary& dict,
136  const List<labelPair>& baffles,
137  pointVectorField& pointDisplacement,
138  const bool dryRun
139 )
140 {
141  Info<< "Selecting externalDisplacementMeshMover " << type << endl;
142 
143  auto* ctorPtr = dictionaryConstructorTable(type);
144 
145  if (!ctorPtr)
146  {
148  (
149  dict,
150  "externalDisplacementMeshMover",
151  type,
152  *dictionaryConstructorTablePtr_
153  ) << exit(FatalIOError);
154  }
155 
156  return autoPtr<externalDisplacementMeshMover>
157  (
158  ctorPtr(dict, baffles, pointDisplacement, dryRun)
159  );
160 }
161 
162 
163 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
166 {}
167 
168 
169 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
172 {
173  // No local data to update
174 }
175 
176 
178 {
179  // Renumber baffles
180  DynamicList<labelPair> newBaffles(baffles_.size());
181  forAll(baffles_, i)
182  {
183  label f0 = mpm.reverseFaceMap()[baffles_[i].first()];
184  label f1 = mpm.reverseFaceMap()[baffles_[i].second()];
185 
186  if (f0 >= 0 && f1 >= 0)
187  {
188  newBaffles.append(labelPair(f0, f1));
189  }
190  }
191  newBaffles.shrink();
192  baffles_.transfer(newBaffles);
193 }
194 
195 
196 // ************************************************************************* //
dictionary dict
rDeltaTY field()
virtual void movePoints(const pointField &)
Update local data for geometry changes.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
void append(const T &val)
Append an element at the end of the list.
Definition: List.H:496
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:518
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1063
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:400
const labelList & reverseFaceMap() const noexcept
Reverse face map.
Definition: mapPolyMesh.H:620
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:805
dynamicFvMesh & mesh
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:611
A class for handling words, derived from Foam::string.
Definition: word.H:63
void append(const T &val)
Copy append an element to the end of this list.
Definition: DynamicList.H:576
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1088
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh...
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Pair< label > labelPair
A pair of labels.
Definition: Pair.H:54
defineTypeNameAndDebug(combustionModel, 0)
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
Virtual base class for mesh movers with externally provided displacement field giving the boundary co...
labelList patchIDs
const polyBoundaryMesh & patches
static autoPtr< externalDisplacementMeshMover > New(const word &type, const dictionary &dict, const List< labelPair > &baffles, pointVectorField &pointDisplacement, const bool dryRun=false)
Return a reference to the selected meshMover model.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition: typeInfo.H:87
List< label > labelList
A List of labels.
Definition: List.H:61
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
static autoPtr< indirectPrimitivePatch > getPatch(const polyMesh &, const labelList &)
Construct patch on selected patches.
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:689
static labelList getFixedValueBCs(const pointVectorField &)
Extract fixed-value patchfields.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
Specifies a zero fixed value boundary condition.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...