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-------------------------------------------------------------------------------
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
31#include "syncTools.H"
32#include "refinementHistory.H"
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace decompositionConstraints
39{
41
43 (
47 );
48}
49}
50
51
52// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53
55(
56 const dictionary& dict
57)
58:
60{
61 if (decompositionConstraint::debug)
62 {
63 Info<< type()
64 << " : setting constraints to refinement history" << endl;
65 }
66}
67
68
70:
72{
73 if (decompositionConstraint::debug)
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 {
103 if (decompositionConstraint::debug)
104 {
105 Info<< type() << " : found refinementHistory" << endl;
106 }
107 }
108 else
109 {
110 if (decompositionConstraint::debug)
111 {
112 Info<< type() << " : reading refinementHistory from time "
113 << mesh.facesInstance() << endl;
114 }
115
116 readFromFile.reset
117 (
118 new HistoryType
119 (
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 (
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
T * get() noexcept
Return pointer to managed object without nullptr checking.
Definition: autoPtr.H:152
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:117
virtual void apply()=0
Apply bins.
Abstract class for handling decomposition constraints.
Constraint to keep all cells originating from refining the same cell onto the same processor....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Sums a given list of (at least two or more) fields and outputs the result into a new field,...
Definition: add.H:161
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:324
All refinement history. Used in unrefinement.
#define defineTypeName(Type)
Define the typeName.
Definition: className.H:96
dynamicFvMesh & mesh
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dictionary dict