29 #include "../common/mfem-common.hpp" 34 int main(
int argc,
char *argv[])
37 const char *mesh_file =
"../../data/inline-quad.mesh";
40 bool visualization =
true;
43 bool aspect_ratio =
true;
47 args.
AddOption(&mesh_file,
"-m",
"--mesh",
50 "Finite element order for visualization" 51 "(defaults to order of the mesh).");
52 args.
AddOption(&ref_levels,
"-r",
"--ref-levels",
53 "Number of initial uniform refinement levels.");
54 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
56 "Enable or disable GLVis visualization.");
57 args.
AddOption(&visit,
"-visit",
"--visit",
"-no-visit",
59 "Enable or disable VisIt.");
60 args.
AddOption(&size,
"-size",
"--size",
"-no-size",
62 "Visualize size parameter.");
63 args.
AddOption(&aspect_ratio,
"-aspr",
"--aspect-ratio",
"-no-aspr",
65 "Visualize aspect-ratio parameter.");
66 args.
AddOption(&skewness,
"-skew",
"--skew",
"-no-skew",
68 "Visualize skewness parameter.");
77 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
78 for (
int lev = 0; lev < ref_levels; lev++)
84 int nSize = 1, nAspr = 1, nSkew = 1;
92 const int nTotalParams = nSize + nAspr + nSkew;
95 order = mesh->
GetNodes() == NULL ? 1 :
96 mesh->
GetNodes()->FESpace()->GetFE(0)->GetOrder();
106 Vector geomParams(nTotalParams);
110 for (
int e = 0; e < mesh->
GetNE(); e++)
114 fespace.GetElementVDofs(e, vdofs);
121 Vector asprVals, skewVals, oriVals;
123 asprVals, skewVals, oriVals);
124 allVals(q + 0) = sizeVal;
125 for (
int n = 0; n < nAspr; n++)
127 allVals(q + (n+1)*ir.
GetNPoints()) = asprVals(n);
129 for (
int n = 0; n < nSkew; n++)
131 allVals(q + (n+1+nAspr)*ir.
GetNPoints()) = skewVals(n);
159 "Size", cx, cy, visw, vish,
"Rjmc");
161 double min_size = size_gf.
Min(),
162 max_size = size_gf.
Max();
163 cout <<
"Min size: " << min_size << endl;
164 cout <<
"Max size: " << max_size << endl;
170 if (visit) { visit_dc.
RegisterField(
"Aspect-Ratio", &aspr_gf); }
175 "Aspect-Ratio", cx, cy, visw, vish,
"Rjmc");
177 double min_aspr = aspr_gf.
Min(),
178 max_aspr = aspr_gf.
Max();
179 max_aspr = max(1.0/min_aspr, max_aspr);
180 cout <<
"Worst aspect-ratio: " << max_aspr << endl;
181 cout <<
"(in any direction)" << endl;
192 "Skewness (radians)", cx, cy, visw, vish,
195 double min_skew = skew_gf.
Min(),
196 max_skew = skew_gf.
Max();
197 cout <<
"Min skew (in deg): " << min_skew*180/M_PI << endl;
198 cout <<
"Max skew (in deg): " << max_skew*180/M_PI << endl;
202 visit_dc.
SetFormat(DataCollection::SERIAL_FORMAT);
210 skew_gf1, skew_gf2, skew_gf3;
220 "Size", cx, cy, visw, vish,
"Rjmc");
222 double min_size = size_gf.
Min(),
223 max_size = size_gf.
Max();
224 cout <<
"Min size: " << min_size << endl;
225 cout <<
"Max size: " << max_size << endl;
242 "Aspect-Ratio", cx, cy, visw, vish,
"Rjmc");
245 "Aspect-Ratio2", cx, cy, visw, vish,
"Rjmc");
247 double min_aspr1 = aspr_gf1.
Min(),
248 max_aspr1 = aspr_gf1.
Max();
249 max_aspr1 = max(1.0/min_aspr1, max_aspr1);
251 double min_aspr2 = aspr_gf2.
Min(),
252 max_aspr2 = aspr_gf2.
Max();
253 max_aspr2 = max(1.0/min_aspr2, max_aspr2);
254 double max_aspr = max(max_aspr1, max_aspr2);
257 for (
int i = 0; i < aspr_gf1.
Size(); i++)
259 aspr_gf3(i) = 1.0/(aspr_gf1(i)*aspr_gf2(i));
261 double min_aspr3 = aspr_gf3.
Min(),
262 max_aspr3 = aspr_gf3.Max();
263 max_aspr3 = max(1.0/min_aspr3, max_aspr3);
264 max_aspr = max(max_aspr, max_aspr3);
266 cout <<
"Worst aspect-ratio: " << max_aspr << endl;
267 cout <<
"(in any direction)" << endl;
287 "Skewness", cx, cy, visw, vish,
"Rjmc");
290 "Skewness2", cx, cy, visw, vish,
"Rjmc");
293 "Dihedral", cx, cy, visw, vish,
"Rjmc");
295 double min_skew1 = skew_gf1.
Min(),
296 max_skew1 = skew_gf1.
Max();
297 double min_skew2 = skew_gf2.
Min(),
298 max_skew2 = skew_gf2.
Max();
299 double min_skew3 = skew_gf3.
Min(),
300 max_skew3 = skew_gf3.
Max();
301 cout <<
"Min skew 1 (in deg): " << min_skew1*180/M_PI << endl;
302 cout <<
"Max skew 1 (in deg): " << max_skew1*180/M_PI << endl;
304 cout <<
"Min skew 2 (in deg): " << min_skew2*180/M_PI << endl;
305 cout <<
"Max skew 2 (in deg): " << max_skew2*180/M_PI << endl;
307 cout <<
"Min skew 3 (in deg): " << min_skew3*180/M_PI << endl;
308 cout <<
"Max skew 3 (in deg): " << max_skew3*180/M_PI << endl;
314 visit_dc.
SetFormat(DataCollection::SERIAL_FORMAT);
Abstract class for all finite elements.
void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
int GetNPoints() const
Returns the number of the points in the integration rule.
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
void PrintOptions(std::ostream &out) const
Print the options.
int Dimension() const
Dimension of the reference space used within the elements.
void SetSize(int s)
Resize the vector to size s.
void PrintUsage(std::ostream &out) const
Print the usage message.
int Size() const
Returns the size of the vector.
Data type dense matrix using column-major storage.
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
void GetElementJacobian(int i, DenseMatrix &J, const IntegrationPoint *ip=NULL)
bool Good() const
Return true if the command line options were parsed successfully.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
int main(int argc, char *argv[])
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Data collection with VisIt I/O routines.
virtual void SetFormat(int fmt)
Set the desired output mesh and data format.
void GetGeometricParametersFromJacobian(const DenseMatrix &J, double &volume, Vector &aspr, Vector &skew, Vector &ori) const
Computes geometric parameters associated with a Jacobian matrix in 2D/3D. These parameters are (1) Ar...
virtual void MakeRef(FiniteElementSpace *f, double *v)
Make the GridFunction reference external data on a new FiniteElementSpace.
void VisualizeField(socketstream &sock, const char *vishost, int visport, ParGridFunction &gf, const char *title, int x=0, int y=0, int w=400, int h=400, bool vec=false)
double * GetData() const
Return a pointer to the beginning of the Vector data.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual void Save() override
Save the collection and a VisIt root file.
double Min() const
Returns the minimal element of the vector.
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...
double Max() const
Returns the maximal element of the vector.
int GetNE() const
Returns number of elements.
Class for integration point with weight.
int Size() const
Return the logical size of the array.
void GetNodes(Vector &node_coord) const
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
Arbitrary order "L2-conforming" discontinuous finite elements.
virtual void RegisterField(const std::string &field_name, GridFunction *gf) override
Add a grid function to the collection and update the root file.