47 char *title,
int pos_x,
int pos_y);
49int main (
int argc,
char *argv[])
56 const char *mesh_file =
"../../data/klein-bottle.mesh";
57 int mesh_poly_deg = 2;
58 bool visualization =
true;
64 args.
AddOption(&mesh_file,
"-m",
"--mesh",
66 args.
AddOption(&mesh_poly_deg,
"-o",
"--order",
67 "Polynomial degree of mesh finite element space.");
68 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
70 "Enable or disable GLVis visualization.");
71 args.
AddOption(&visit,
"-visit",
"--visit",
"-no-visit",
73 "Enable or disable VisIt output.");
74 args.
AddOption(&jacobian,
"-jac",
"--jacobian",
"-no-jac",
76 "Compute bounds on determinant of mesh Jacobian");
80 Mesh mesh(mesh_file, 1, 1,
false);
84 ParMesh pmesh(MPI_COMM_WORLD, mesh);
86 else { mesh_poly_deg = pmesh.
GetNodes()->FESpace()->GetMaxElementOrder(); }
97 int nelem = pmesh.
GetNE();
101 nodes->GetElementBounds(lower, upper, 2, -1);
102 for (
int e = 0; e < nelem; e++)
106 for (
int d = 0; d < sdim; d++)
108 lower_upper(d) = lower(e + d*nelem);
109 lower_upper(d+sdim) = upper(e + d*nelem);
122 char title1[] =
"Input mesh";
124 char title2[] =
"Bounding box mesh";
140 nodes->GetBounds(lower, upper, ref_factor);
143 out <<
"Nodal position minimum bounds:" << endl;
145 out <<
"Nodal position maximum bounds:" << endl;
149 if (!jacobian) {
return 0; }
153 int det_order = rdim*mesh_poly_deg-1;
172 char title1[] =
"Determinant of Jacobian (det J)";
174 char title2[] =
"Element-wise lower bound on det J";
176 char title3[] =
"Element-wise upper bound on det J";
185 visit_dc.
RegisterField(
"det-lower-bound", &bounds_detgf_lower);
186 visit_dc.
RegisterField(
"det-upper-bound", &bounds_detgf_upper);
191 detgf.
GetBounds(lower, upper, ref_factor);
194 out <<
"Jacobian determinant minimum bound: " << lower(0) << endl;
195 out <<
"Jacobian determinant maximum bound: " << upper(0) << endl;
203 int nelem = mesh.
GetNE();
205 int nverts = pow(2,sdim)*nelem;
206 Mesh meshbb(sdim, nverts, nelem, 0, sdim);
209 for (
int e = 0; e < nelem; e++)
216 xyz(0) = xyzminmax_el(0);
217 xyz(1) = xyzminmax_el(1);
220 xyz(0) = xyzminmax_el(2);
221 xyz(1) = xyzminmax_el(1);
224 xyz(0) = xyzminmax_el(2);
225 xyz(1) = xyzminmax_el(3);
228 xyz(0) = xyzminmax_el(0);
229 xyz(1) = xyzminmax_el(3);
232 const int inds[4] = {vidx++, vidx++, vidx++, vidx++};
240 xyz(0) = xyzminmax_el(0);
241 xyz(1) = xyzminmax_el(1);
242 xyz(2) = xyzminmax_el(2);
245 xyz(0) = xyzminmax_el(3);
246 xyz(1) = xyzminmax_el(1);
247 xyz(2) = xyzminmax_el(2);
250 xyz(0) = xyzminmax_el(3);
251 xyz(1) = xyzminmax_el(4);
252 xyz(2) = xyzminmax_el(2);
255 xyz(0) = xyzminmax_el(0);
256 xyz(1) = xyzminmax_el(4);
257 xyz(2) = xyzminmax_el(2);
260 xyz(0) = xyzminmax_el(0);
261 xyz(1) = xyzminmax_el(1);
262 xyz(2) = xyzminmax_el(5);
265 xyz(0) = xyzminmax_el(3);
266 xyz(1) = xyzminmax_el(1);
267 xyz(2) = xyzminmax_el(5);
270 xyz(0) = xyzminmax_el(3);
271 xyz(1) = xyzminmax_el(4);
272 xyz(2) = xyzminmax_el(5);
275 xyz(0) = xyzminmax_el(0);
276 xyz(1) = xyzminmax_el(4);
277 xyz(2) = xyzminmax_el(5);
280 const int inds[8] = {vidx++, vidx++, vidx++, vidx++,
281 vidx++, vidx++, vidx++, vidx++
283 meshbb.
AddHex(inds, (eidx++)+1);
301 MFEM_VERIFY(np == ordering.
Size(),
"Invalid permutation size");
305 for (
int i = 0; i < np; i++)
309 ip_new.
Set(ip_old.
x, ip_old.
y, ip_old.
z, ip_old.
weight);
321 for (
int e = 0; e < mesh->
GetNE(); e++)
342 detvals(q) = Jac.
Weight();
346 if (irordering.
Size())
348 for (
int i = 0; i < dofs.
Size(); i++)
350 (*detgf)(dofs[i]) = detvals(irordering[i]);
363 sock.
open(
"localhost", 19916);
366 std::string keystrokes = mesh.
SpaceDimension() == 2 ?
"keys em" :
"keys )";
367 sock <<
"window_title '"<< title <<
"'\n"
368 <<
"window_geometry "
369 << pos_x <<
" " << pos_y <<
" " << 400 <<
" " << 400 <<
"\n"
371 << keystrokes << endl;
375 char *title,
int pos_x,
int pos_y)
380 sock.
open(
"localhost", 19916);
381 sock <<
"solution\n";
387 sock <<
"window_title '"<< title <<
"'\n"
388 <<
"window_geometry "
389 << pos_x <<
" " << pos_y <<
" " << 400 <<
" " << 400 <<
"\n"
390 <<
"keys jRmclApppppppppppp//]]]]]]]]" << endl;
int Size() const
Return the logical size of the array.
@ GaussLobatto
Closed type.
virtual void SetFormat(int fmt)
Set the desired output mesh and data format.
Data type dense matrix using column-major storage.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'. The returned indices are offsets into an ldo...
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for the i'th element. The returned indices are offsets into an ...
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
Abstract class for all finite elements.
int GetDim() const
Returns the reference space dimension for the finite element.
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
Class for grid function - Vector with associated FE space.
PLBound GetElementBounds(Vector &lower, Vector &upper, const int ref_factor=1, const int vdim=-1) const
virtual void GetElementDofValues(int el, Vector &dof_vals) const
FiniteElementSpace * FESpace()
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Class for integration point with weight.
void Set(const real_t *p, const int dim)
Class for an integration rule - an Array of IntegrationPoint.
int GetOrder() const
Returns the order of the integration rule.
int GetNPoints() const
Returns the number of the points in the integration rule.
void SetOrder(const int order)
Sets the order of the integration rule. This is only for keeping order information,...
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Arbitrary order "L2-conforming" discontinuous finite elements.
int AddQuad(int v1, int v2, int v3, int v4, int attr=1)
Adds a quadrilateral to the mesh given by 4 vertices v1 through v4.
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Print the mesh to the given stream using the default MFEM mesh format.
void Clear()
Clear the contents of the Mesh.
int AddVertex(real_t x, real_t y=0.0, real_t z=0.0)
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void FinalizeHexMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a hexahedral Mesh.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr) const
Builds the transformation defining the i-th element in ElTr. ElTr must be allocated in advance and wi...
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a quadrilateral Mesh.
int SpaceDimension() const
Dimension of the physical space containing the mesh.
void GetNodes(Vector &node_coord) const
int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8, int attr=1)
Adds a hexahedron to the mesh given by 8 vertices v1 through v8.
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
Class for standard nodal finite elements.
const Array< int > & GetLexicographicOrdering() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
void ParseCheck(std::ostream &out=mfem::out)
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...
Abstract parallel finite element space.
Class for parallel grid function.
void SaveAsOne(const char *fname, int precision=16) const
GridFunction GetSerialGridFunction(int save_rank, Mesh &serial_mesh) const
Returns a GridFunction on MPI rank save_rank that does not have any duplication of vertices/nodes at ...
PLBound GetBounds(Vector &lower, Vector &upper, const int ref_factor=1, const int vdim=-1) const override
Class for parallel meshes.
Mesh GetSerialMesh(int save_rank) const
void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1) override
Set the curvature of the mesh nodes using the given polynomial degree.
void PrintAsOne(std::ostream &out=mfem::out, const std::string &comments="") const
void Print(std::ostream &out=mfem::out, int width=8) const
Prints vector to stream out.
void SetSubVector(const Array< int > &dofs, const real_t value)
Set the entries listed in dofs to the given value.
Data collection with VisIt I/O routines.
void Save() override
Save the collection and a VisIt root file.
void RegisterField(const std::string &field_name, GridFunction *gf) override
Add a grid function to the collection and update the root file.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void VisualizeBB(Mesh &mesh, char *title, int pos_x, int pos_y)
IntegrationRule PermuteIR(const IntegrationRule &irule, const Array< int > ordering)
void GetDeterminantJacobianGF(ParMesh *mesh, ParGridFunction *detgf)
Mesh MakeBoundingBoxMesh(Mesh &mesh, GridFunction &nodal_bb_gf)
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, const char *keys, bool vec)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
std::array< int, NCMesh::MaxFaceNodes > nodes