36int main(
int argc,
char *argv[])
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;
148 const real_t volume = 1.0 * perturb_v;
151 const real_t 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 real_t 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 real_t 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));
180 const real_t volume = 1.0 * perturb_v;
183 const real_t ar_1 = 1.0 * perturb_ar,
188 const real_t 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 real_t 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);
Data type dense matrix using column-major storage.
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Class for grid function - Vector with associated FE space.
Arbitrary order H1-conforming (continuous) finite elements.
static Mesh MakeCartesian3D(int nx, int ny, int nz, Element::Type type, real_t sx=1.0, real_t sy=1.0, real_t sz=1.0, bool sfc_ordering=true)
Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into nx*ny*nz hexahedra if type =...
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
virtual void SetNodalFESpace(FiniteElementSpace *nfes)
static Mesh MakeCartesian2D(int nx, int ny, Element::Type type, bool generate_edges=false, real_t sx=1.0, real_t sy=1.0, bool sfc_ordering=true)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny quadrilaterals if type = QUADRILATER...
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
2D barrier Shape+Orientation (OS) metric (polyconvex).
2D non-barrier metric without a type.
2D barrier Shape+Size (VS) metric (not polyconvex).
2D barrier Shape+Size (VS) metric (not polyconvex).
2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).
2D barrier shape (S) metric (not polyconvex).
2D barrier Shape+Orientation (OS) metric (polyconvex).
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
3D barrier Shape+Size (VS) metric, well-posed (invex).
3D barrier Shape+Size (VS) metric, well-posed (invex).
3D barrier Shape+Size (VS) metric, well-posed (invex).
3D non-barrier Shape (S) metric.
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P....
virtual real_t EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
int Size() const
Returns the size of the vector.
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)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void Form3DJac(real_t perturb_v, real_t perturb_ar, real_t perturb_s, DenseMatrix &J)
void Form2DJac(real_t perturb_v, real_t perturb_ar, real_t perturb_s, DenseMatrix &J)