refinementHistoryConstraint.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2015-2018 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);
36 
38  (
39  decompositionConstraint,
40  refinementHistoryConstraint,
41  dictionary
42  );
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const dictionary& constraintsDict,
51  const word& modelType
52 )
53 :
54  decompositionConstraint(constraintsDict, typeName)
55 {
56  if (decompositionConstraint::debug)
57  {
58  Info<< type() << " : setting constraints to preserve refinement history"
59  << endl;
60  }
61 }
62 
63 
65 :
67 {
68  if (decompositionConstraint::debug)
69  {
70  Info<< type() << " : setting constraints to refinement history"
71  << endl;
72  }
73 }
74 
75 
76 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
77 
79 (
80  const polyMesh& mesh,
81  boolList& blockedFace,
82  PtrList<labelList>& specifiedProcessorFaces,
83  labelList& specifiedProcessor,
84  List<labelPair>& explicitConnections
85 ) const
86 {
88  refinementHistory const* refPtr = nullptr;
89 
90  if (mesh.foundObject<refinementHistory>("refinementHistory"))
91  {
92  if (decompositionConstraint::debug)
93  {
94  Info<< type() << " : found refinementHistory" << endl;
95  }
96  refPtr = &mesh.lookupObject<refinementHistory>("refinementHistory");
97  }
98  else
99  {
100  if (decompositionConstraint::debug)
101  {
102  Info<< type() << " : reading refinementHistory from time "
103  << mesh.facesInstance() << endl;
104  }
105  storagePtr.reset
106  (
108  (
109  IOobject
110  (
111  "refinementHistory",
112  mesh.facesInstance(),
114  mesh,
117  ),
118  mesh.nCells()
119  )
120  );
121  }
122 
123  const refinementHistory& history =
124  (
125  storagePtr.valid()
126  ? storagePtr()
127  : *refPtr
128  );
129 
130  if (history.active())
131  {
132  // refinementHistory itself implements decompositionConstraint
133  history.add
134  (
135  blockedFace,
136  specifiedProcessorFaces,
137  specifiedProcessor,
138  explicitConnections
139  );
140  }
141 }
142 
143 
145 (
146  const polyMesh& mesh,
147  const boolList& blockedFace,
148  const PtrList<labelList>& specifiedProcessorFaces,
149  const labelList& specifiedProcessor,
150  const List<labelPair>& explicitConnections,
151  labelList& decomposition
152 ) const
153 {
155  refinementHistory const* refPtr = nullptr;
156 
157  if (mesh.foundObject<refinementHistory>("refinementHistory"))
158  {
159  // if (decompositionConstraint::debug)
160  //{
161  // Info<< type() << " : found refinementHistory" << endl;
162  //}
163  refPtr = &mesh.lookupObject<refinementHistory>("refinementHistory");
164  }
165  else
166  {
167  // if (decompositionConstraint::debug)
168  //{
169  // Info<< type() << " : reading refinementHistory from time "
170  // << mesh.facesInstance() << endl;
171  //}
172  storagePtr.reset
173  (
175  (
176  IOobject
177  (
178  "refinementHistory",
179  mesh.facesInstance(),
181  mesh,
184  ),
185  mesh.nCells()
186  )
187  );
188  }
189 
190  const refinementHistory& history =
191  (
192  storagePtr.valid()
193  ? storagePtr()
194  : *refPtr
195  );
196 
197  if (history.active())
198  {
199  // refinementHistory itself implements decompositionConstraint
200  history.apply
201  (
202  blockedFace,
203  specifiedProcessorFaces,
204  specifiedProcessor,
205  explicitConnections,
206  decomposition
207  );
208  }
209 }
210 
211 
212 // ************************************************************************* //
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:801
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
Definition: autoPtrI.H:114
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
bool active() const
Is there unrefinement history?
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:312
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
bool foundObject(const word &name) const
Is the named Type found?
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Macros for easy insertion into run-time selection tables.
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.
dynamicFvMesh & mesh
refinementHistoryConstraint()
Construct from components.
A class for handling words, derived from string.
Definition: word.H:59
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
virtual void add(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my constraints to list of constraints.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeName(refinementHistoryConstraint)
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:481
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.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
messageStream Info
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
All refinement history. Used in unrefinement.
void add(boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my decomposition constraints.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.