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 | Copyright (C) 2013-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "mapPolyMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(externalDisplacementMeshMover, 0);
35  defineRunTimeSelectionTable(externalDisplacementMeshMover, dictionary);
36 }
37 
38 
39 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
40 
42 (
43  const pointVectorField& field
44 )
45 {
46  DynamicList<label> adaptPatchIDs;
47 
48  forAll(field.boundaryField(), patchI)
49  {
50  const pointPatchField<vector>& patchField =
51  field.boundaryField()[patchI];
52 
53  if (isA<valuePointPatchField<vector> >(patchField))
54  {
56  {
57  // Special condition of fixed boundary condition. Does not
58  // get adapted
59  }
60  else
61  {
62  adaptPatchIDs.append(patchI);
63  }
64  }
65  }
66 
67  return adaptPatchIDs;
68 }
69 
70 
73 (
74  const polyMesh& mesh,
75  const labelList& patchIDs
76 )
77 {
78  const polyBoundaryMesh& patches = mesh.boundaryMesh();
79 
80  // Count faces.
81  label nFaces = 0;
82 
83  forAll(patchIDs, i)
84  {
85  const polyPatch& pp = patches[patchIDs[i]];
86 
87  nFaces += pp.size();
88  }
89 
90  // Collect faces.
91  labelList addressing(nFaces);
92  nFaces = 0;
93 
94  forAll(patchIDs, i)
95  {
96  const polyPatch& pp = patches[patchIDs[i]];
97 
98  label meshFaceI = pp.start();
99 
100  forAll(pp, i)
101  {
102  addressing[nFaces++] = meshFaceI++;
103  }
104  }
105 
107  (
109  (
110  IndirectList<face>(mesh.faces(), addressing),
111  mesh.points()
112  )
113  );
114 }
115 
116 
117 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
118 
120 (
121  const dictionary& dict,
122  const List<labelPair>& baffles,
123  pointVectorField& pointDisplacement
124 )
125 :
126  baffles_(baffles),
127  pointDisplacement_(pointDisplacement)
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
132 
135 (
136  const word& type,
137  const dictionary& dict,
138  const List<labelPair>& baffles,
139  pointVectorField& pointDisplacement
140 )
141 {
142  Info<< "Selecting externalDisplacementMeshMover " << type << endl;
143 
144  dictionaryConstructorTable::iterator cstrIter =
145  dictionaryConstructorTablePtr_->find(type);
146 
147  if (cstrIter == dictionaryConstructorTablePtr_->end())
148  {
150  << "Unknown externalDisplacementMeshMover type "
151  << type << nl << nl
152  << "Valid externalDisplacementMeshMover types:" << endl
153  << dictionaryConstructorTablePtr_->sortedToc()
154  << exit(FatalError);
155  }
156 
158  (
159  cstrIter()(dict, baffles, pointDisplacement)
160  );
161 }
162 
163 
164 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
165 
167 {}
168 
169 
170 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
171 
173 {
174  // No local data to update
175 }
176 
177 
179 {
180  // Renumber baffles
181  DynamicList<labelPair> newBaffles(baffles_.size());
182  forAll(baffles_, i)
183  {
184  label f0 = mpm.reverseFaceMap()[baffles_[i].first()];
185  label f1 = mpm.reverseFaceMap()[baffles_[i].second()];
186 
187  if (f0 >= 0 && f1 >= 0)
188  {
189  newBaffles.append(labelPair(f0, f1));
190  }
191  }
192  newBaffles.shrink();
193  baffles_.transfer(newBaffles);
194 }
195 
196 
197 // ************************************************************************* //
Foam::externalDisplacementMeshMover::getFixedValueBCs
static labelList getFixedValueBCs(const pointVectorField &)
Extract fixed-value patchfields.
Definition: externalDisplacementMeshMover.C:42
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::DynamicList< label >
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
mapPolyMesh.H
zeroFixedValuePointPatchFields.H
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::pointPatchField< vector >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::externalDisplacementMeshMover::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
Definition: externalDisplacementMeshMover.C:178
Foam::externalDisplacementMeshMover::externalDisplacementMeshMover
externalDisplacementMeshMover(const externalDisplacementMeshMover &)
Disallow default bitwise copy construct.
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:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
externalDisplacementMeshMover.H
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::externalDisplacementMeshMover::New
static autoPtr< externalDisplacementMeshMover > New(const word &type, const dictionary &dict, const List< labelPair > &baffles, pointVectorField &pointDisplacement)
Return a reference to the selected meshMover model.
Definition: externalDisplacementMeshMover.C:135
Foam::externalDisplacementMeshMover::movePoints
virtual void movePoints(const pointField &)
Update local data for geometry changes.
Definition: externalDisplacementMeshMover.C:172
Foam::IndirectList
A List with indirect addressing.
Definition: IndirectList.H:102
f1
scalar f1
Definition: createFields.H:28
Foam::DynamicList::shrink
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Definition: DynamicListI.H:258
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::zeroFixedValuePointPatchField
Enables the specification of a zero fixed value boundary condition.
Definition: zeroFixedValuePointPatchField.H:57
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::externalDisplacementMeshMover::~externalDisplacementMeshMover
virtual ~externalDisplacementMeshMover()
Destructor.
Definition: externalDisplacementMeshMover.C:166
Foam::DynamicList::append
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::mapPolyMesh::reverseFaceMap
const labelList & reverseFaceMap() const
Reverse face map.
Definition: mapPolyMesh.H:497
Foam::externalDisplacementMeshMover::getPatch
static autoPtr< indirectPrimitivePatch > getPatch(const polyMesh &, const labelList &)
Construct patch on selected patches.
Definition: externalDisplacementMeshMover.C:73
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::valuePointPatchField< vector >
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::isA
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:134
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::labelPair
Pair< label > labelPair
Label pair.
Definition: labelPair.H:48
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88