25 #include "../common/mfem-common.hpp" 31 void Form2DJac(
double perturb_v,
double perturb_ar,
double perturb_s,
33 void Form3DJac(
double perturb_v,
double perturb_ar,
double perturb_s,
36 int main(
int argc,
char *argv[])
39 double perturb_v = 1.0;
40 double perturb_ar = 1.0;
41 double perturb_s = 1.0;
44 args.
AddOption(&metric_id,
"-mid",
"--metric-id",
"Metric id");
45 args.
AddOption(&perturb_v,
"-pv",
"--perturb-factor-volume",
46 "Volume perturbation factor w.r.t. the ideal element.");
47 args.
AddOption(&perturb_ar,
"-par",
"--perturb-factor-aspect-ratio",
48 "Aspect ratio perturbation factor w.r.t. the ideal element.");
49 args.
AddOption(&perturb_s,
"-ps",
"--perturb-factor-skew",
50 "Skew perturbation factor w.r.t. the ideal element.");
55 MFEM_VERIFY(perturb_v > 0.0 && perturb_ar > 0.0 && perturb_s >= 1.0,
93 default: cout <<
"Unknown metric_id: " << metric_id << endl;
return 3;
96 const int dim = (metric_id < 300) ? 2 : 3;
117 (
dim == 2) ?
Form2DJac(perturb_v, perturb_ar, perturb_s, J)
118 :
Form3DJac(perturb_v, perturb_ar, perturb_s, J);
120 const int nodes_cnt = x.
Size() /
dim;
121 for (
int i = 0; i < nodes_cnt; i++)
124 for (
int d = 0; d <
dim; d++) { X(d) = x(i + d * nodes_cnt); }
127 for (
int d = 0; d <
dim; d++) { x(i + d * nodes_cnt) = Jx(d); }
134 cout <<
"Magnitude of metric " << metric_id <<
": " << metric->
EvalW(J)
135 <<
"\n volume perturbation factor: " << perturb_v
136 <<
"\n aspect ratio pert factor: " << perturb_ar
137 <<
"\n skew perturbation factor: " << perturb_s << endl;
144 void Form2DJac(
double perturb_v,
double perturb_ar,
double perturb_s,
148 const double volume = 1.0 * perturb_v;
151 const double a_r = 1.0 * perturb_ar;
153 M_ar(0, 0) = 1.0 / sqrt(a_r);
154 M_ar(1, 1) = sqrt(a_r);
157 const double skew_angle = M_PI / 2.0 / perturb_s;
159 M_skew(0, 0) = 1.0; M_skew(0, 1) = cos(skew_angle);
160 M_skew(1, 0) = 0.0; M_skew(1, 1) = sin(skew_angle);
163 const double rot_angle = 0.0;
165 M_rot(0, 0) = cos(rot_angle); M_rot(0, 1) = -sin(rot_angle);
166 M_rot(1, 0) = sin(rot_angle); M_rot(1, 1) = cos(rot_angle);
171 Mult(M_rot, M_skew, TMP);
173 J *= sqrt(volume / sin(skew_angle));
176 void Form3DJac(
double perturb_v,
double perturb_ar,
double perturb_s,
180 const double volume = 1.0 * perturb_v;
183 const double ar_1 = 1.0 * perturb_ar,
188 const double skew_angle_12 = M_PI / 2.0 / perturb_s,
189 skew_angle_13 = M_PI / 2.0,
190 skew_angle_23 = M_PI / 2.0;
196 J(0, 0) = pow(ar_1, 1.0/3.0);
197 J(0, 1) = pow(ar_2, 1.0/3.0) * cos(skew_angle_12);
198 J(0, 2) = pow(ar_3, 1.0/3.0) * cos(skew_angle_13);
201 J(1, 1) = pow(ar_2, 1.0/3.0) * sin(skew_angle_12);
202 J(1, 2) = pow(ar_3, 1.0/3.0) * sin(skew_angle_13) * cos(skew_angle_23);
206 J(2, 2) = pow(ar_3, 1.0/3.0) * sin(skew_angle_13) * sin(skew_angle_23);
209 double sin3 = sin(skew_angle_12)*sin(skew_angle_13)*sin(skew_angle_23),
210 ar3 = pow(ar_1, 1.0/3.0) * pow(ar_2, 1.0/3.0) * pow(ar_3, 1.0/3.0);
211 J *= pow(volume / (sin3 * ar3), 1.0/3.0);
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 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 ...
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).