Loading [MathJax]/extensions/tex2jax.js
Plugins
Toggle main menu visibility
ug4
Modules
ugBase
libAlgebra
libDiscretization
libGrid
Plugins
Registry
Scripts
Apps
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Variables
Typedefs
Enumerations
Enumerator
c
k
m
r
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
v
w
x
y
Typedefs
a
b
c
d
e
f
g
i
l
m
n
p
r
s
t
u
v
w
Enumerations
Enumerator
Files
File List
File Members
All
_
a
b
c
d
e
f
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Functions
a
b
c
d
e
f
h
i
l
m
n
p
r
s
t
v
w
Variables
b
c
e
f
n
p
q
r
s
u
Macros
_
b
h
l
n
o
p
s
t
u
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
domain_util.h
Go to the documentation of this file.
1
# ifndef __util__domain_util__h__
2
# define __util__domain_util__h__
3
4
// UG4 base libs.
5
#include "
common/common.h
"
6
#include "
common/log.h
"
7
#include "
common/util/smart_pointer.h
"
8
9
10
#include "
lib_grid/refinement/refiner_factory.hpp
"
11
#include "
lib_grid/algorithms/problem_detection_util.h
"
// CheckForUnconnectedSides
12
13
14
#include "
lib_disc/domain.h
"
15
#include "
lib_disc/domain_util.h
"
16
17
// C++ libs.
18
#include <vector>
19
#include <string>
20
21
namespace
ug
{
22
namespace
Util {
23
24
namespace
aux {
25
template
<
typename
TObject>
26
void
write
(TObject &text) {
UG_LOG
(text); }
27
}
24
namespace
aux {
…
}
28
29
using
aux::write
;
30
31
// util.CheckSubsets
32
// checks if all required subsets are contained in the SubsetHandler
33
// @param dom Domain
34
// @param neededSubsets List of subsets the SubsetHandler must contain
35
// @return true if all subsets are contained, false else
36
37
template
<
typename
TDomain>
38
bool
CheckSubsets
(
const
TDomain &dom,
const
std::vector<std::string> &neededSubsets)
39
{
40
auto
sh = dom.subset_handler();
41
42
for
(
auto
&subset : neededSubsets) {
43
if
(sh->get_subset_index(subset.c_str()) == -1) {
44
UG_LOG
(
"Domain does not contain subset '"
<< subset.c_str() <<
"'."
);
45
return
false
;
46
}
47
}
48
49
return
true
;
50
}
38
bool
CheckSubsets
(
const
TDomain &dom,
const
std::vector<std::string> &neededSubsets) {
…
}
51
52
53
// Creates a new domain and loads the specified grid.
54
// The method then performs numRefs global refinements.
55
// A list of subset-names can be specified which have to be present in the loaded grid.
56
// The method returns the created domain.
57
// @note Some paramters are optional. nil is a valid value for each optional parameter.
58
// @return (Domain) the created domain
59
// @param gridName (string) The filename of the grid which shall be loaded.
60
// The grid is searched in a path relative to the current path
61
// first. If it isn't found there, the path is interpreted as
62
// an absolute path. If the grid still can't be found, the method
63
// tries to load it from UG_BASE/data/grids.
64
// @param numRefs (int) The total number of global refinements
65
// @param neededSubsets (optional, list of strings) The subsets that are required
66
// by the simulation. If not all those subsets are present,
67
// the method aborts. Default is an empty list.
68
// @param noIntegrityCheck (optional, bool) Disables integrity check if 'true'.
69
70
71
template
<
typename
TDomain>
72
SmartPtr<TDomain>
CreateDomain
(
const
std::string &gridName,
int
numRefs
,
73
const
std::vector<std::string> &neededSubsets,
bool
noIntegrityCheck=
false
) {
74
75
// Create domain instance.
76
auto
dom = make_sp<TDomain>(
new
TDomain());
77
78
// load domain
79
UG_LOG
(
"Loading Domain "
<< gridName <<
" ... "
)
80
LoadDomain
(*dom, gridName.c_str());
// from lib_disc/domain_util.cpp
81
UG_LOG
(
"done."
<< std::endl)
82
83
84
if
(noIntegrityCheck ==
false
) {
85
UG_LOG
(
"Performing integrity check on domain ... "
);
86
if
(
CheckForUnconnectedSides
(*dom->grid()))
87
{
88
UG_LOG
(
"WARNING: unconnected sides found (see above).\n"
);
89
std::string note(
"NOTE: You may disable this check by passing 'true' to 'noIntegrityCheck' in 'util.CreateDomain'.\n"
);
90
UG_LOG
(note);
91
UG_ERR_LOG
(note);
92
}
93
UG_LOG
(
"done.\n"
);
94
}
95
96
// Create a refiner instance. This is a factory method
97
// which automatically creates a parallel refiner if required.
98
// if numRefs == nil then numRefs = 0 end
99
if
(
numRefs
> 0) {
100
UG_LOG
(
"Refining("
<<
numRefs
<<
"): "
);
101
auto
refiner =
GlobalDomainRefiner
(*dom);
102
for
(
int
i=0; i<
numRefs
; ++i){
103
// TerminateAbortedRun();
104
refiner->refine();
105
UG_LOG
(i <<
" "
);
106
}
107
UG_LOG
(
"done.\n"
);
108
// delete(refiner)
109
}
110
111
// check whether required subsets are present
112
if
(!neededSubsets.empty())
113
{
114
115
UG_ASSERT
(
CheckSubsets
(*dom, neededSubsets) ==
true
,
116
"Something wrong with required subsets. Aborting."
);
117
}
118
119
// return the created domain
120
return
dom;
121
}
72
SmartPtr<TDomain>
CreateDomain
(
const
std::string &gridName,
int
numRefs
, {
…
}
122
123
124
template
<
typename
TDomain>
125
SmartPtr<TDomain>
CreateDomain
(
const
std::string &gridName,
int
numRefs
,
const
std::vector<std::string> &neededSubsets)
126
{
127
return
CreateDomain<TDomain>(gridName,
numRefs
, neededSubsets,
false
);
128
}
125
SmartPtr<TDomain>
CreateDomain
(
const
std::string &gridName,
int
numRefs
,
const
std::vector<std::string> &neededSubsets) {
…
}
129
130
template
<
typename
TDomain>
131
SmartPtr<TDomain>
CreateDomain
(
const
std::string &gridName,
int
numRefs
)
132
{
133
return
CreateDomain<TDomain>(gridName,
numRefs
, std::vector<std::string>(),
false
);
134
}
131
SmartPtr<TDomain>
CreateDomain
(
const
std::string &gridName,
int
numRefs
) {
…
}
135
136
template
<
typename
TDomain>
137
SmartPtr<TDomain>
CreateDomain
(
const
std::string &gridName)
138
{
139
140
return
CreateDomain<TDomain>(gridName, 0, std::vector<std::string>(),
false
);
141
}
137
SmartPtr<TDomain>
CreateDomain
(
const
std::string &gridName) {
…
}
142
143
144
// Creates a new domain and loads the specified grid. The method then performs
145
// numPreRefs refinements before it distributes the domain onto the available
146
// processes. The partitioning method can be chosen through distributionMethod.
147
// After distribution the domain is refined until a total of numRefs refinement
148
// steps has been performed (including numPreRefs).
149
// A list of subset-names can be specified. After distribution the methods checks
150
// Whether all processes received the required subsets.
151
// The method returns the created domain.
152
// @note Some paramters are optional. nil is a valid value for each optional parameter.
153
// @return (Domain) the created domain
154
// @param gridName (string) The filename of the grid which shall be loaded.
155
// The grid is searched in a path relative to the current path
156
// first. If it isn't found there, the path is interpreted as
157
// an absolute path. If the grid still can't be found, the method
158
// tries to load it from UG_BASE/data/grids.
159
// @param numRefs (int) The total number of global refinements
160
// @param numPreRefs (int) The number of refinements that are performed before
161
// distribution.
162
// @param neededSubsets (optional, list of strings) The subsets that are required
163
// by the simulation. If not all those subsets are present,
164
// the method aborts. Default is an empty list.
165
// @param distributionMethod (optional, string) The distribution method.
166
// Either "bisection" or "metis". Default is "bisection".
167
// See util.DistributeDomain for more information
168
// (in UG_BASE/scripts/util/domain_distribution.lua)
169
// @param verticalInterfaces (optional, bool) Vertical interfaces are required
170
// by multi-grid solvers. Default is true.
171
// See util.DistributeDomain for more information
172
// (in UG_BASE/scripts/util/domain_distribution.lua)
173
// @param numTargetProcs (optional, int) The number of target processes to which
174
// the domain shall be distributed. Make sure that the
175
// number of target processes is not higher than the
176
// number of elements in the distributionLevel.
177
// Default is NumProcs()
178
// See util.DistributeDomain for more information
179
// (in UG_BASE/scripts/util/domain_distribution.lua)
180
// @param distributionLevel (optional, int) The level on which the distribution
181
// is performed. Default is the domains top-level
182
// after pre-refinement.
183
// See util.DistributeDomain for more information
184
// (in UG_BASE/scripts/util/domain_distribution.lua)
185
// @param wFct (optional SmartPtr<EdgeWeighting>) Sets the weighting function for the
186
// 'metisReweigh' partitioning method.
187
// @param noIntegrityCheck (optional, bool) Disables integrity check if 'true'.
188
189
/*function util.CreateAndDistributeDomain(gridName, numRefs, numPreRefs,
190
neededSubsets, distributionMethod,
191
verticalInterfaces, numTargetProcs,
192
distributionLevel, wFct, noIntegrityCheck)
193
194
// create Instance of a Domain
195
local dom = Domain()
196
197
// load domain
198
write("Loading Domain "..gridName.." ... ")
199
LoadDomain(dom, gridName)
200
write("done.\n")
201
202
if noIntegrityCheck ~= true then
203
write("Performing integrity check on domain ... ")
204
if CheckForUnconnectedSides(dom:grid()) == true then
205
write("WARNING: unconnected sides found (see above).\n")
206
local note = "NOTE: You may disable this check by passing 'true' "..
207
"to 'noIntegrityCheck' in 'util.CreateAndDistributeDomain'.\n"
208
write(note)
209
errlog(note)
210
end
211
write("done.\n")
212
end
213
214
// create Refiner
215
ug_assert(numPreRefs <= numRefs, "numPreRefs must be smaller than numRefs. Aborting.");
216
217
if numPreRefs > numRefs then
218
numPreRefs = numRefs
219
end
220
221
// Create a refiner instance. This is a factory method
222
// which automatically creates a parallel refiner if required.
223
local refiner = nil
224
if numRefs > 0 then
225
refiner = GlobalDomainRefiner(dom)
226
end
227
228
write("Pre-Refining("..numPreRefs.."): ")
229
// Performing pre-refines
230
for i=1,numPreRefs do
231
TerminateAbortedRun()
232
write(i .. " ")
233
refiner:refine()
234
end
235
write("done.\nDistributing...")
236
// Distribute the domain to all involved processes
237
if util.DistributeDomain(dom, distributionMethod, verticalInterfaces, numTargetProcs, distributionLevel, wFct) == false then
238
ug_error("Error while Distributing Grid. Aborting.")
239
end
240
write(" done.\nPost-Refining("..(numRefs-numPreRefs).."): ")
241
242
if numRefs > 0 then
243
// Perform post-refine
244
for i=numPreRefs+1,numRefs do
245
TerminateAbortedRun()
246
refiner:refine()
247
write(i-numPreRefs .. " ")
248
end
249
end
250
write("done.\n")
251
252
// Now we loop all subsets an search for it in the SubsetHandler of the domain
253
if neededSubsets ~= nil then
254
if util.CheckSubsets(dom, neededSubsets) == false then
255
ug_error("Something wrong with required subsets. Aborting.");
256
end
257
end
258
259
260
//clean up
261
if refiner ~= nil then
262
delete(refiner)
263
end
264
265
// return the created domain
266
return dom
267
end
268
*/
269
}
// namespace util
22
namespace
Util {
…
}
270
}
// namespace ug
271
272
# endif
//__util__domain_util__h__
numRefs
parameterNumber numRefs
Definition
evaluate.lua:2
SmartPtr
common.h
domain.h
domain_util.h
ug::LoadDomain
void LoadDomain(TDomain &domain, const char *filename)
UG_ASSERT
#define UG_ASSERT(expr, msg)
UG_ERR_LOG
#define UG_ERR_LOG(msg)
UG_LOG
#define UG_LOG(msg)
log.h
ug::Util::aux::write
void write(TObject &text)
Definition
domain_util.h:26
ug::Util::CreateDomain
SmartPtr< TDomain > CreateDomain(const std::string &gridName, int numRefs, const std::vector< std::string > &neededSubsets, bool noIntegrityCheck=false)
Definition
domain_util.h:72
ug::Util::CheckSubsets
bool CheckSubsets(const TDomain &dom, const std::vector< std::string > &neededSubsets)
Definition
domain_util.h:38
ug
ug::CheckForUnconnectedSides
bool CheckForUnconnectedSides(Grid &grid)
ug::GlobalDomainRefiner
static SmartPtr< IRefiner > GlobalDomainRefiner(TDomain &dom)
problem_detection_util.h
refiner_factory.hpp
smart_pointer.h
plugins
Util
domain_util.h
Generated on Mon Feb 24 2025 01:12:51 for Plugins by
1.9.8