46 char *title,
int pos_x,
int pos_y);
48int main (
int argc,
char *argv[])
55 const char *mesh_file =
"../../data/klein-bottle.mesh";
56 int mesh_poly_deg = 2;
57 bool visualization =
true;
63 args.
AddOption(&mesh_file,
"-m",
"--mesh",
65 args.
AddOption(&mesh_poly_deg,
"-o",
"--order",
66 "Polynomial degree of mesh finite element space.");
67 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
69 "Enable or disable GLVis visualization.");
70 args.
AddOption(&visit,
"-visit",
"--visit",
"-no-visit",
72 "Enable or disable VisIt output.");
73 args.
AddOption(&jacobian,
"-jac",
"--jacobian",
"-no-jac",
75 "Compute bounds on determinant of mesh Jacobian");
79 Mesh mesh(mesh_file, 1, 1,
false);
83 ParMesh pmesh(MPI_COMM_WORLD, mesh);
85 else { mesh_poly_deg = pmesh.
GetNodes()->FESpace()->GetMaxElementOrder(); }
96 int nelem = pmesh.
GetNE();
100 nodes->GetElementBounds(lower, upper, 2, -1);
101 for (
int e = 0; e < nelem; e++)
105 for (
int d = 0; d < sdim; d++)
107 lower_upper(d) = lower(e + d*nelem);
108 lower_upper(d+sdim) = upper(e + d*nelem);
121 char title1[] =
"Input mesh";
123 char title2[] =
"Bounding box mesh";
139 nodes->GetBounds(lower, upper, ref_factor);
142 out <<
"Nodal position minimum bounds:" << endl;
144 out <<
"Nodal position maximum bounds:" << endl;
148 if (!jacobian) {
return 0; }
161 detgf->GetElementBounds(bounds_detgf_lower, bounds_detgf_upper, ref_factor);
166 char title1[] =
"Determinant of Jacobian (det J)";
168 char title2[] =
"Element-wise lower bound on det J";
170 char title3[] =
"Element-wise upper bound on det J";
179 visit_dc.
RegisterField(
"det-lower-bound", &bounds_detgf_lower);
180 visit_dc.
RegisterField(
"det-upper-bound", &bounds_detgf_upper);
185 detgf->GetBounds(lower, upper, ref_factor);
188 out <<
"Jacobian determinant minimum bound: " << lower(0) << endl;
189 out <<
"Jacobian determinant maximum bound: " << upper(0) << endl;
197 int nelem = mesh.
GetNE();
199 int nverts = pow(2,sdim)*nelem;
200 Mesh meshbb(sdim, nverts, nelem, 0, sdim);
203 for (
int e = 0; e < nelem; e++)
210 xyz(0) = xyzminmax_el(0);
211 xyz(1) = xyzminmax_el(1);
214 xyz(0) = xyzminmax_el(2);
215 xyz(1) = xyzminmax_el(1);
218 xyz(0) = xyzminmax_el(2);
219 xyz(1) = xyzminmax_el(3);
222 xyz(0) = xyzminmax_el(0);
223 xyz(1) = xyzminmax_el(3);
226 const int inds[4] = {vidx++, vidx++, vidx++, vidx++};
234 xyz(0) = xyzminmax_el(0);
235 xyz(1) = xyzminmax_el(1);
236 xyz(2) = xyzminmax_el(2);
239 xyz(0) = xyzminmax_el(3);
240 xyz(1) = xyzminmax_el(1);
241 xyz(2) = xyzminmax_el(2);
244 xyz(0) = xyzminmax_el(3);
245 xyz(1) = xyzminmax_el(4);
246 xyz(2) = xyzminmax_el(2);
249 xyz(0) = xyzminmax_el(0);
250 xyz(1) = xyzminmax_el(4);
251 xyz(2) = xyzminmax_el(2);
254 xyz(0) = xyzminmax_el(0);
255 xyz(1) = xyzminmax_el(1);
256 xyz(2) = xyzminmax_el(5);
259 xyz(0) = xyzminmax_el(3);
260 xyz(1) = xyzminmax_el(1);
261 xyz(2) = xyzminmax_el(5);
264 xyz(0) = xyzminmax_el(3);
265 xyz(1) = xyzminmax_el(4);
266 xyz(2) = xyzminmax_el(5);
269 xyz(0) = xyzminmax_el(0);
270 xyz(1) = xyzminmax_el(4);
271 xyz(2) = xyzminmax_el(5);
274 const int inds[8] = {vidx++, vidx++, vidx++, vidx++,
275 vidx++, vidx++, vidx++, vidx++
277 meshbb.
AddHex(inds, (eidx++)+1);
294 sock.
open(
"localhost", 19916);
297 std::string keystrokes = mesh.
SpaceDimension() == 2 ?
"keys em" :
"keys )";
298 sock <<
"window_title '"<< title <<
"'\n"
299 <<
"window_geometry "
300 << pos_x <<
" " << pos_y <<
" " << 400 <<
" " << 400 <<
"\n"
302 << keystrokes << endl;
306 char *title,
int pos_x,
int pos_y)
311 sock.
open(
"localhost", 19916);
312 sock <<
"solution\n";
318 sock <<
"window_title '"<< title <<
"'\n"
319 <<
"window_geometry "
320 << pos_x <<
" " << pos_y <<
" " << 400 <<
" " << 400 <<
"\n"
321 <<
"keys jRmclApppppppppppp//]]]]]]]]" << endl;
int Size() const
Return the logical size of the array.
virtual void SetFormat(int fmt)
Set the desired output mesh and data format.
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 ...
Class for grid function - Vector with associated FE space.
virtual void GetElementDofValues(int el, Vector &dof_vals) const
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
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 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).
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 ...
Class for parallel meshes.
Mesh GetSerialMesh(int save_rank) const
void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1, int pyrtype=1) override
Set the curvature of the mesh nodes using the given polynomial degree.
std::unique_ptr< ParGridFunction > GetJacobianDeterminantGF() const
Create a ParGridFunction representing the Jacobian determinant. Parallel counterpart of Mesh::GetJaco...
void PrintAsOne(std::ostream &out=mfem::out, const std::string &comments="") const
Write the mesh to the stream 'out' on Process 0 in a form suitable for visualization.
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)
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