17 #include "../common/mfem-common.hpp" 23 void Form2DJac(
double perturb_v,
double perturb_ar,
double perturb_s,
25 void Form3DJac(
double perturb_v,
double perturb_ar,
double perturb_s,
28 int main(
int argc,
char *argv[])
31 double perturb_v = 1.0;
32 double perturb_ar = 1.0;
33 double perturb_s = 1.0;
36 args.
AddOption(&metric_id,
"-mid",
"--metric-id",
"Metric id");
37 args.
AddOption(&perturb_v,
"-pv",
"--perturb-factor-volume",
38 "Volume perturbation factor w.r.t. the ideal element.");
39 args.
AddOption(&perturb_ar,
"-par",
"--perturb-factor-aspect-ratio",
40 "Aspect ratio perturbation factor w.r.t. the ideal element.");
41 args.
AddOption(&perturb_s,
"-ps",
"--perturb-factor-skew",
42 "Skew perturbation factor w.r.t. the ideal element.");
82 default: cout <<
"Unknown metric_id: " << metric_id << endl;
return 3;
85 const int dim = (metric_id < 300) ? 2 : 3;
106 (
dim == 2) ?
Form2DJac(perturb_v, perturb_ar, perturb_s, J)
107 :
Form3DJac(perturb_v, perturb_ar, perturb_s, J);
109 const int nodes_cnt = x.
Size() /
dim;
110 for (
int i = 0; i < nodes_cnt; i++)
113 for (
int d = 0; d <
dim; d++) { X(d) = x(i + d * nodes_cnt); }
116 for (
int d = 0; d <
dim; d++) { x(i + d * nodes_cnt) = Jx(d); }
123 cout <<
"Magnitude of metric " << metric_id <<
": " << metric->
EvalW(J)
124 <<
"\n volume perturbation factor: " << perturb_v
125 <<
"\n aspect ratio pert factor: " << perturb_ar
126 <<
"\n skew perturbation factor: " << perturb_s << endl;
133 void Form2DJac(
double perturb_v,
double perturb_ar,
double perturb_s,
137 const double volume = 1.0 * perturb_v;
140 const double a_r = 1.0 * perturb_ar;
142 M_ar(0, 0) = 1.0 / sqrt(a_r);
143 M_ar(1, 1) = sqrt(a_r);
146 const double skew_angle = M_PI / 2.0 / perturb_s;
148 M_skew(0, 0) = 1.0; M_skew(0, 1) = cos(skew_angle);
149 M_skew(1, 0) = 0.0; M_skew(1, 1) = sin(skew_angle);
152 const double rot_angle = 0.0;
154 M_rot(0, 0) = cos(rot_angle); M_rot(0, 1) = -sin(rot_angle);
155 M_rot(1, 0) = sin(rot_angle); M_rot(1, 1) = cos(rot_angle);
160 Mult(M_rot, M_skew, TMP);
162 J *= sqrt(volume / sin(skew_angle));
165 void Form3DJac(
double perturb_v,
double perturb_ar,
double perturb_s,
168 MFEM_ABORT(
"The 3D case is still not complete.");
171 const double volume = 1.0 * perturb_v;
174 const double ar_1 = 1.0 * perturb_ar,
175 ar_2 = 1.0 * perturb_ar;
178 const double skew_angle_12 = M_PI / 2.0 / perturb_s,
179 skew_angle_13 = M_PI / 2.0 / perturb_s,
180 skew_angle_23 = M_PI / 2.0 / perturb_s;
181 const double sin3 = sin(skew_angle_12)*sin(skew_angle_13)*sin(skew_angle_23);
188 J(0, 1) = ar_2 * cos(skew_angle_12);
189 J(0, 2) = cos(skew_angle_13) / (ar_1 * ar_2) *
193 J(1, 1) = ar_2 * sin(skew_angle_12);
194 J(1, 2) = sin(skew_angle_13) * cos(skew_angle_23) / (ar_1 * ar_2) *
199 J(2, 2) = sin(skew_angle_13) * sin(skew_angle_23) / (ar_1 * ar_2) *
202 J *= sqrt(volume / sin3);
3D non-barrier Shape (S) metric.
Class for grid function - Vector with associated FE space.
3D barrier Shape+Size (VS) metric, well-posed (invex).
void PrintOptions(std::ostream &out) const
Print the options.
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
void PrintUsage(std::ostream &out) const
Print the usage message.
virtual double EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
static Mesh MakeCartesian3D(int nx, int ny, int nz, Element::Type type, double sx=1.0, double sy=1.0, double sz=1.0, bool sfc_ordering=true)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
int Size() const
Returns the size of the vector.
Data type dense matrix using column-major storage.
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
3D non-barrier metric without a type.
3D barrier Shape+Size (VS) metric, well-posed (invex).
bool Good() const
Return true if the command line options were parsed successfully.
2D barrier Shape+Size (VS) metric (not polyconvex).
3D barrier Shape+Size (VS) metric, well-posed (invex).
void Form3DJac(double perturb_v, double perturb_ar, double perturb_s, DenseMatrix &J)
2D barrier shape (S) metric (not polyconvex).
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P...
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
3D barrier metric without a type.
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
virtual void SetNodalFESpace(FiniteElementSpace *nfes)
void Mult(const double *x, double *y) const
Matrix vector multiplication.
2D barrier Shape+Orientation (OS) metric (polyconvex).
int main(int argc, char *argv[])
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
static Mesh MakeCartesian2D(int nx, int ny, Element::Type type, bool generate_edges=false, double sx=1.0, double sy=1.0, bool sfc_ordering=true)
void Form2DJac(double perturb_v, double perturb_ar, double perturb_s, DenseMatrix &J)
2D barrier Shape+Size (VS) metric (not polyconvex).
void VisualizeMesh(socketstream &sock, const char *vishost, int visport, Mesh &mesh, const char *title, int x, int y, int w, int h, const char *keys)
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Arbitrary order H1-conforming (continuous) finite elements.
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
2D barrier Shape+Orientation (OS) metric (polyconvex).
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
2D non-barrier metric without a type.
2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).