Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
35namespace Foam
36{
37 defineTypeNameAndDebug(externalDisplacementMeshMover, 0);
38 defineRunTimeSelectionTable(externalDisplacementMeshMover, dictionary);
39}
40
41
42// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43
45(
47)
48{
49 DynamicList<label> adaptPatchIDs;
50
51 forAll(field.boundaryField(), patchI)
52 {
53 const auto& patchField = field.boundaryField()[patchI];
54
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{
77 const polyBoundaryMesh& patches = mesh.boundaryMesh();
78
79 // Count faces.
80 label nFaces = 0;
81
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
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(), addressing),
108 mesh.points()
109 );
110}
111
112
113// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
114
115Foam::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 * * * * * * * * * * * * * * * //
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// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
labelList patchIDs
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
void append(const T &val)
Copy append an element to the end of this list.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
A List with indirect addressing.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition List.C:347
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Virtual base class for mesh movers with externally provided displacement field giving the boundary co...
static labelList getFixedValueBCs(const pointVectorField &)
Extract fixed-value patchfields.
static autoPtr< indirectPrimitivePatch > getPatch(const polyMesh &, const labelList &)
Construct patch on selected 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.
List< labelPair > baffles_
Baffles in the mesh.
virtual void movePoints(const pointField &)
Update local data for geometry changes.
pointVectorField & pointDisplacement()
Return reference to the point motion displacement field.
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
pointVectorField & pointDisplacement_
Reference to point motion field.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
virtual const faceList & faces() const
Return raw faces.
Definition polyMesh.C:1088
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
Foam::valuePointPatchField.
A class for handling words, derived from Foam::string.
Definition word.H:66
Specifies a zero fixed value boundary condition.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
rDeltaTY field()
const polyBoundaryMesh & patches
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
Namespace for OpenFOAM.
Pair< label > labelPair
A pair of labels.
Definition Pair.H:54
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299