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;
241 ASSERT(refs.size() <= mesh_perm.size());
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);
Bounding box in 3d ambient space.
const Point & min() const
double longest_size() const
void expand(const Point &point)
unsigned int n_nodes() const
NodeAccessor< 3 > node(unsigned int idx) const
Create and return NodeAccessor to node of given idx.
unsigned int n_elements() const
Range< ElementAccessor< 3 > > elements_range() const
Returns range of mesh elements.
Range< NodeAccessor< 3 > > node_range() const
Returns range of nodes.
ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
MeshOptimizer(Mesh *mesh)
void calculate_element_curve_values_as_zcurve_of_center()
std::vector< double > node_sizes_
std::vector< int > sort_elements(std::vector< unsigned int > &elem_permutation)
void calculate_node_curve_values_as_zcurve()
std::vector< double > element_sizes_
void calculate_element_curve_values_as_hilbert_of_centers()
std::vector< int > sort_nodes(std::vector< unsigned int > &node_permutation)
double hilbert_value(double x, double y, double z, double eps) const
void calculate_node_curve_values_as_obtained_from_elements()
double hilbert_value(arma::vec3 vec, double size) const
double zcurve_value(double x, double y, double z, double eps) const
void calculate_node_curve_values_as_hilbert()
std::vector< Permutee > element_refs_
double zcurve_value(double x, double y, double eps) const
std::vector< Permutee > node_refs_
std::vector< int > sort(std::vector< Permutee > &refs, std::vector< unsigned int > &mesh_perm)
double zcurve_value(arma::vec3 vec, double size) const
double hilbert_value(double x, double y, double eps) const
bool operator<(const Permutee &first, const Permutee &second)
Implementation of range helper class.
arma::vec3 normalize(const arma::vec3 vec)
Normalizer(arma::vec3 shift, double scalar)
Permutee(uint original_index, double curve_value)