2 #ifndef MESH_OPTIMIZER_HH_
3 #define MESH_OPTIMIZER_HH_
36 static_assert(DIM == 2 || DIM == 3,
"DIM must be either 2 or 3.");
51 double elm_norm_size = elm.bounding_box().longest_size() / mesh_longest_size;
53 for (
uint i = 0; i < elm.dim() + 1; ++i) {
80 for (
uint j = 0; j < elm->dim() + 1; ++j) {
132 return (2 +
hilbert_value(2 * x - 1, 2 * y - 1, 4 * eps)) / 4;
134 return (3 +
hilbert_value(1 - 2 * y, 2 - 2 * x, 4 * eps)) / 4;
140 inline double hilbert_value(
double x,
double y,
double z,
double eps)
const {
149 return (1 +
hilbert_value(2 * y - 1, 2 * z, 2 * x, 8 * eps)) / 8;
153 return (2 +
hilbert_value(2 * y - 1, 2 * z, 2 * x - 1, 8 * eps)) / 8;
155 return (3 +
hilbert_value(2 - 2 * x, 1 - 2 * y, 2 * z, 8 * eps)) / 8;
161 return (4 +
hilbert_value(2 - 2 * x, 1 - 2 * y, 2 * z - 1, 8 * eps)) / 8;
163 return (5 +
hilbert_value(2 * y - 1, 2 - 2 * z, 2 - 2 * x, 8 * eps)) / 8;
167 return (6 +
hilbert_value(2 * y - 1, 2 - 2 * z, 1 - 2 * x, 8 * eps)) / 8;
169 return (7 +
hilbert_value(2 - 2 * z, 2 * x, 1 - 2 * y, 8 * eps)) / 8;
184 return (1 +
zcurve_value(2 * x - 1, 2 * y, 4 * eps)) / 4;
188 return (2 +
zcurve_value(2 * x, 2 * y - 1, 4 * eps)) / 4;
190 return (3 +
zcurve_value(2 * x - 1, 2 * y - 1, 4 * eps)) / 4;
196 inline double zcurve_value(
double x,
double y,
double z,
double eps)
const {
205 return (1 +
zcurve_value(2 * x - 1, 2 * y, 2 * z, 8 * eps)) / 8;
209 return (2 +
zcurve_value(2 * x, 2 * y - 1, 2 * z, 8 * eps)) / 8;
211 return (3 +
zcurve_value(2 * x - 1, 2 * y - 1, 2 * z, 8 * eps)) / 8;
217 return (4 +
zcurve_value(2 * x, 2 * y, 2 * z - 1, 8 * eps)) / 8;
219 return (5 +
zcurve_value(2 * x - 1, 2 * y, 2 * z - 1, 8 * eps)) / 8;
223 return (6 +
zcurve_value(2 * x, 2 * y - 1, 2 * z - 1, 8 * eps)) / 8;
225 return (7 +
zcurve_value(2 * x - 1, 2 * y - 1, 2 * z - 1, 8 * eps)) / 8;
242 std::sort(refs.begin(), refs.end());
244 mesh_ids.reserve(refs.size());
245 for (
uint i = 0; i < refs.size(); ++i) {
246 mesh_perm[ refs[i].original_index_ ] = i;
247 mesh_ids.push_back( refs[i].original_index_ );
256 return hilbert_value(
vec[0],
vec[1], size * size);
261 return zcurve_value(
vec[0],
vec[1], size * size);