Mesh Oriented datABase
(version 5.5.1)
An array-based unstructured mesh library
LloydSmoother.hpp
Go to the documentation of this file.
1
/** @class LloydSmoother.cpp \n
2
* \brief Perform Lloyd relaxation on a mesh and its dual \n
3
*
4
* Briefly, Lloyd relaxation is a technique to smooth out a mesh. The centroid of each cell is
5
* computed from its vertex positions, then vertices are placed at the average of their connected
6
* cells' centroids, and the process iterates until convergence.
7
*
8
* In the parallel algorithm, an extra ghost layer of cells is exchanged. This allows us to compute
9
* the centroids for boundary cells on each processor where they appear; this eliminates the need
10
* for one round of data exchange (for those centroids) between processors. New vertex positions
11
* must be sent from owning processors to processors sharing those vertices. Convergence is
12
* measured as the maximum distance moved by any vertex.
13
*
14
*/
15
16
#ifndef LLOYDSMOOTHER_HPP
17
#define LLOYDSMOOTHER_HPP
18
19
#include "
moab/Interface.hpp
"
20
21
namespace
moab
22
{
23
24
class
ParallelComm;
25
26
class
LloydSmoother
27
{
28
public
:
29
/* \brief Constructor
30
* Bare constructor, data input to this class through methods.
31
* \param impl The MOAB instance for this smoother
32
*/
33
LloydSmoother
(
Interface
* impl );
34
35
/* \brief Constructor
36
* Convenience constructor, data input directly
37
* \param impl The MOAB instance for this smoother
38
* \param pc The ParallelComm instance by which this mesh is parallel
39
* \param elems The mesh to be smoothed
40
* \param cds_tag If specified, this tag is used to get/set coordinates, rather than
41
* true vertex coordinates
42
* \param fixed_tag The tag marking which vertices are fixed
43
* \param abs_tol Absolute tolerance measuring convergence
44
* \param rel_tol Relative tolerance measuring convergence
45
*/
46
LloydSmoother
(
Interface
* impl,
47
ParallelComm
* pc,
48
Range
&
elems
,
49
Tag
cds_tag = 0,
50
Tag
fixed_tag
= 0,
51
double
abs_tol
= -1.0,
52
double
rel_tol
= 1.0e-6 );
53
54
/* \brief Destructor
55
*/
56
~LloydSmoother
();
57
58
/* \brief perform smoothing operation
59
*/
60
ErrorCode
perform_smooth
();
61
62
/* \brief get instance
63
*/
64
Interface
*
mb_impl
()
65
{
66
return
mbImpl
;
67
}
68
69
/* \brief get/set ParallelComm
70
*/
71
ParallelComm
*
pcomm
()
72
{
73
return
myPcomm
;
74
}
75
76
/* \brief get/set ParallelComm
77
*/
78
void
pcomm
(
ParallelComm
* pc )
79
{
80
myPcomm
= pc;
81
}
82
83
/* \brief get/set elements
84
*/
85
Range
&
elems
()
86
{
87
return
myElems
;
88
}
89
90
/* \brief get/set elements
91
*/
92
const
Range
&
elems
()
const
93
{
94
return
myElems
;
95
}
96
97
/* \brief get/set fixed tag
98
*/
99
Tag
fixed_tag
()
100
{
101
return
fixedTag
;
102
}
103
104
/* \brief get/set fixed tag
105
*/
106
void
fixed_tag
(
Tag
fixed )
107
{
108
fixedTag
= fixed;
109
}
110
111
/* \brief get/set coords tag
112
*/
113
Tag
coords_tag
()
114
{
115
return
coordsTag
;
116
}
117
118
/* \brief get/set coords tag
119
*/
120
void
coords_tag
(
Tag
coords )
121
{
122
coordsTag
= coords;
123
}
124
125
/* \brief get/set tolerance
126
*/
127
double
abs_tol
()
128
{
129
return
absTol
;
130
}
131
132
/* \brief get/set tolerance
133
*/
134
void
abs_tol
(
double
tol )
135
{
136
absTol
= tol;
137
}
138
139
/* \brief get/set tolerance
140
*/
141
double
rel_tol
()
142
{
143
return
relTol
;
144
}
145
146
/* \brief get/set tolerance
147
*/
148
void
rel_tol
(
double
tol )
149
{
150
relTol
= tol;
151
}
152
153
/* \brief get/set numIts
154
*/
155
int
num_its
()
156
{
157
return
numIts
;
158
}
159
void
num_its
(
int
num )
160
{
161
numIts
= num;
162
}
163
164
/* \brief get/set reportIts
165
*/
166
int
report_its
()
167
{
168
return
reportIts
;
169
}
170
void
report_its
(
int
num )
171
{
172
reportIts
= num;
173
}
174
175
private
:
176
//- initialize some things in certain cases
177
ErrorCode
initialize
();
178
179
//- MOAB instance
180
Interface
*
mbImpl
;
181
182
//- ParallelComm
183
ParallelComm
*
myPcomm
;
184
185
//- elements to smooth
186
Range
myElems
;
187
188
//- tag for coordinates; if zero, true vertex coords are used
189
Tag
coordsTag
;
190
191
//- tag marking which vertices are fixed, 0 = not fixed, otherwise fixed
192
Tag
fixedTag
;
193
194
//- tolerances
195
double
absTol
,
relTol
;
196
197
//- number of iterations between reporting
198
int
reportIts
;
199
200
//- number of iterations taken during smooth
201
int
numIts
;
202
203
//- keep track of whether I created the fixed tag
204
bool
iCreatedTag
;
205
};
206
207
}
// namespace moab
208
209
#endif
src
moab
LloydSmoother.hpp
Generated on Tue Jul 30 2024 02:18:02 for Mesh Oriented datABase by
1.9.1.