omega_h
Reliable mesh adaptation
Omega_h_quality.hpp
1 #ifndef OMEGA_H_QUALITY_HPP
2 #define OMEGA_H_QUALITY_HPP
3 
4 #include <Omega_h_shape.hpp>
5 
6 namespace Omega_h {
7 
8 template <Int dim>
9 OMEGA_H_INLINE Real mean_ratio(Real size, Real mean_squared_length) {
10  return power<2, dim>(size / equilateral_simplex_size(dim)) /
11  mean_squared_length;
12 }
13 
14 /* note that we will always use a constant metric tensor over the whole
15  * element to compute its quality, because that way we are computing
16  * the quality of the element after a single linear transformation which
17  * is guaranteed not to turn it inside out.
18  * this is why edge lengths are recomputed using the metric interpolated
19  * to the element centroid.
20  * other authors will try to use the highly accurate metric length
21  * formula together with the very approximate metric volume formula to
22  * compute quality. that can, for example, compute qualities greater
23  * than 1.0, and other strange results.
24  */
25 
26 template <Int dim, typename Metric>
27 OMEGA_H_INLINE Real metric_element_quality(
28  Few<Vector<dim>, dim + 1> p, Metric metric) {
29  auto b = simplex_basis<dim, dim>(p);
30  auto rs = simplex_size_from_basis(b);
31  auto s = metric_size<dim>(rs, metric);
32  if (s < 0) return s;
33  auto ev = element_edge_vectors(p, b);
34  auto msl = mean_squared_metric_length(ev, metric);
35  return mean_ratio<dim>(s, msl);
36 }
37 
38 template <Int space_dim, Int metric_dim>
40  Reals coords;
41  Reals metrics;
42  MetricElementQualities(Mesh const* mesh, Reals metrics_in)
43  : coords(mesh->coords()), metrics(metrics_in) {}
44  MetricElementQualities(Mesh const* mesh)
45  : MetricElementQualities(mesh, mesh->get_array<Real>(VERT, "metric")) {}
46  OMEGA_H_DEVICE Real measure(Few<LO, space_dim + 1> v) const {
47  auto p = gather_vectors<space_dim + 1, space_dim>(coords, v);
48  auto ms = gather_symms<space_dim + 1, metric_dim>(metrics, v);
49  auto m = maxdet_metric(ms);
50  return metric_element_quality(p, m);
51  }
52 };
53 
54 Reals measure_qualities(Mesh* mesh, LOs a2e, Reals metrics);
55 Reals measure_qualities(Mesh* mesh, LOs a2e);
56 Reals measure_qualities(Mesh* mesh);
57 Reals measure_qualities(Mesh* mesh, Reals metrics);
58 Reals get_1d_cavity_qualities(Mesh* mesh, Int key_dim, LOs keys2kds);
59 
60 } // end namespace Omega_h
61 
62 #endif
Definition: Omega_h_few.hpp:61
Definition: Omega_h_mesh.hpp:35
Definition: amr_mpi_test.cpp:6
Definition: Omega_h_quality.hpp:39