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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2016 OpenFOAM Foundation
9  Copyright (C) 2018 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 
31 #include "syncTools.H"
32 #include "refinementHistory.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace decompositionConstraints
39 {
40  defineTypeName(refinementHistory);
41 
43  (
44  decompositionConstraint,
45  refinementHistory,
46  dictionary
47  );
48 }
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 (
56  const dictionary& dict
57 )
58 :
59  decompositionConstraint(dict, typeName)
60 {
62  {
63  Info<< type()
64  << " : setting constraints to refinement history" << endl;
65  }
66 }
67 
68 
70 :
72 {
74  {
75  Info<< type()
76  << " : setting constraints to refinement history" << endl;
77  }
78 }
79 
80 
81 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
82 
84 (
85  const polyMesh& mesh,
86  boolList& blockedFace,
87  PtrList<labelList>& specifiedProcessorFaces,
88  labelList& specifiedProcessor,
89  List<labelPair>& explicitConnections
90 ) const
91 {
92  // The refinement history type
93  typedef ::Foam::refinementHistory HistoryType;
94 
95  // Local storage if read from file
96  autoPtr<const HistoryType> readFromFile;
97 
98  const HistoryType* historyPtr =
99  mesh.findObject<HistoryType>("refinementHistory");
100 
101  if (historyPtr)
102  {
104  {
105  Info<< type() << " : found refinementHistory" << endl;
106  }
107  }
108  else
109  {
111  {
112  Info<< type() << " : reading refinementHistory from time "
113  << mesh.facesInstance() << endl;
114  }
115 
116  readFromFile.reset
117  (
118  new HistoryType
119  (
120  IOobject
121  (
122  "refinementHistory",
123  mesh.facesInstance(),
125  mesh,
128  ),
129  mesh.nCells()
130  )
131  );
132 
133  historyPtr = readFromFile.get(); // get(), not release()
134  }
135 
136  const auto& history = *historyPtr;
137 
138  if (history.active())
139  {
140  // refinementHistory itself implements decompositionConstraint
141  history.add
142  (
143  blockedFace,
144  specifiedProcessorFaces,
145  specifiedProcessor,
146  explicitConnections
147  );
148  }
149 }
150 
151 
153 (
154  const polyMesh& mesh,
155  const boolList& blockedFace,
156  const PtrList<labelList>& specifiedProcessorFaces,
157  const labelList& specifiedProcessor,
158  const List<labelPair>& explicitConnections,
159  labelList& decomposition
160 ) const
161 {
162  // The refinement history type
163  typedef ::Foam::refinementHistory HistoryType;
164 
165  // Local storage if read from file
166  autoPtr<const HistoryType> readFromFile;
167 
168  const HistoryType* historyPtr =
169  mesh.findObject<HistoryType>("refinementHistory");
170 
171  if (!historyPtr)
172  {
173  readFromFile.reset
174  (
175  new HistoryType
176  (
177  IOobject
178  (
179  "refinementHistory",
180  mesh.facesInstance(),
182  mesh,
185  ),
186  mesh.nCells()
187  )
188  );
189 
190  historyPtr = readFromFile.get(); // get(), not release()
191  }
192 
193  const auto& history = *historyPtr;
194 
195  if (history.active())
196  {
197  // refinementHistory itself implements decompositionConstraint
198  history.apply
199  (
200  blockedFace,
201  specifiedProcessorFaces,
202  specifiedProcessor,
203  explicitConnections,
204  decomposition
205  );
206  }
207 }
208 
209 
210 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::decompositionConstraint
Abstract class for handling decomposition constraints.
Definition: decompositionConstraint.H:58
Foam::decompositionConstraints::defineTypeName
defineTypeName(geometric)
refinementHistoryConstraint.H
Foam::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:321
Foam::decompositionConstraints::refinementHistory::add
virtual void add(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add this constraint to list of constraints.
Definition: refinementHistoryConstraint.C:84
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::autoPtr::get
T * get() noexcept
Return pointer to managed object without nullptr checking.
Definition: autoPtr.H:152
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:187
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr::reset
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:117
Foam::decompositionConstraints::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionConstraint, geometric, dictionary)
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::List< bool >
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::decompositionConstraints::refinementHistory::refinementHistory
refinementHistory()
Construct from components.
Definition: refinementHistoryConstraint.C:69
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
refinementHistory.H
Foam::decompositionConstraints::refinementHistory::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 this constraint post-decomposition.
Definition: refinementHistoryConstraint.C:153