refinementHistoryConstraint.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) 2015 OpenFOAM Foundation
6  \\/ M anipulation |
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 
28 #include "syncTools.H"
29 #include "refinementHistory.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 defineTypeName(refinementHistoryConstraint);
37 (
38  decompositionConstraint,
39  refinementHistoryConstraint,
40  dictionary
41 );
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
48 (
49  const dictionary& constraintsDict,
50  const word& modelType
51 )
52 :
53  decompositionConstraint(constraintsDict, typeName)
54 {
55  if (decompositionConstraint::debug)
56  {
57  Info<< type() << " : setting constraints to preserve refinement history"
58  << endl;
59  }
60 }
61 
62 
64 :
66 {
67  if (decompositionConstraint::debug)
68  {
69  Info<< type() << " : setting constraints to refinement history"
70  << endl;
71  }
72 }
73 
74 
75 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
76 
78 (
79  const polyMesh& mesh,
80  boolList& blockedFace,
81  PtrList<labelList>& specifiedProcessorFaces,
82  labelList& specifiedProcessor,
83  List<labelPair>& explicitConnections
84 ) const
85 {
87  refinementHistory const* refPtr = NULL;
88 
89  if (mesh.foundObject<refinementHistory>("refinementHistory"))
90  {
91  if (decompositionConstraint::debug)
92  {
93  Info<< type() << " : found refinementHistory" << endl;
94  }
95  refPtr = &mesh.lookupObject<refinementHistory>("refinementHistory");
96  }
97  else
98  {
99  if (decompositionConstraint::debug)
100  {
101  Info<< type() << " : reading refinementHistory from time "
102  << mesh.facesInstance() << endl;
103  }
104  storagePtr.reset
105  (
107  (
108  IOobject
109  (
110  "refinementHistory",
113  mesh,
116  ),
117  mesh.nCells()
118  )
119  );
120  }
121 
122  const refinementHistory& history =
123  (
124  storagePtr.valid()
125  ? storagePtr()
126  : *refPtr
127  );
128 
129  if (history.active())
130  {
131  // refinementHistory itself implements decompositionConstraint
132  history.add
133  (
134  blockedFace,
135  specifiedProcessorFaces,
136  specifiedProcessor,
137  explicitConnections
138  );
139  }
140 }
141 
142 
144 (
145  const polyMesh& mesh,
146  const boolList& blockedFace,
147  const PtrList<labelList>& specifiedProcessorFaces,
148  const labelList& specifiedProcessor,
149  const List<labelPair>& explicitConnections,
150  labelList& decomposition
151 ) const
152 {
154  refinementHistory const* refPtr = NULL;
155 
156  if (mesh.foundObject<refinementHistory>("refinementHistory"))
157  {
158  //if (decompositionConstraint::debug)
159  //{
160  // Info<< type() << " : found refinementHistory" << endl;
161  //}
162  refPtr = &mesh.lookupObject<refinementHistory>("refinementHistory");
163  }
164  else
165  {
166  //if (decompositionConstraint::debug)
167  //{
168  // Info<< type() << " : reading refinementHistory from time "
169  // << mesh.facesInstance() << endl;
170  //}
171  storagePtr.reset
172  (
174  (
175  IOobject
176  (
177  "refinementHistory",
180  mesh,
183  ),
184  mesh.nCells()
185  )
186  );
187  }
188 
189  const refinementHistory& history =
190  (
191  storagePtr.valid()
192  ? storagePtr()
193  : *refPtr
194  );
195 
196  if (history.active())
197  {
198  // refinementHistory itself implements decompositionConstraint
199  history.apply
200  (
201  blockedFace,
202  specifiedProcessorFaces,
203  specifiedProcessor,
204  explicitConnections,
205  decomposition
206  );
207  }
208 }
209 
210 
211 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::decompositionConstraint
Definition: decompositionConstraint.H:54
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::refinementHistory::apply
void apply(const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &decomposition) const
Apply any additional post-decomposition constraints.
Definition: refinementHistory.C:497
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
refinementHistoryConstraint.H
Foam::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:309
Foam::refinementHistory::active
bool active() const
Is there unrefinement history?
Definition: refinementHistory.H:279
Foam::polyMesh::facesInstance
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:778
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::defineTypeName
defineTypeName(refinementHistoryConstraint)
Foam::refinementHistoryConstraint::apply
virtual void apply(const polyMesh &mesh, const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &decomposition) const
Apply any additional post-decomposition constraints.
Definition: refinementHistoryConstraint.C:144
Foam::refinementHistoryConstraint::refinementHistoryConstraint
refinementHistoryConstraint()
Construct from components.
Definition: refinementHistoryConstraint.C:63
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::primitiveMesh::nCells
label nCells() const
Definition: primitiveMeshI.H:64
Foam::refinementHistory
All refinement history. Used in unrefinement.
Definition: refinementHistory.H:95
Foam::refinementHistoryConstraint::add
virtual void add(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my constraints to list of constraints.
Definition: refinementHistoryConstraint.C:78
Foam::Info
messageStream Info
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
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
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
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::objectRegistry::foundObject
bool foundObject(const word &name) const
Is the named Type found?
Definition: objectRegistryTemplates.C:142
Foam::refinementHistory::add
void add(boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my decomposition constraints.
Definition: refinementHistory.C:451
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::autoPtr::valid
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
Definition: autoPtrI.H:83
Foam::autoPtr::reset
void reset(T *=0)
If object pointer already set, delete object and set to given.
Definition: autoPtrI.H:114
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Definition: objectRegistryTemplates.C:165
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::IOobject::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: IOobject.H:110