MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
mesh.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_MESH
13#define MFEM_MESH
14
15#include "../config/config.hpp"
18#include "attribute_sets.hpp"
19#include "triangle.hpp"
20#include "tetrahedron.hpp"
21#include "vertex.hpp"
22#include "vtk.hpp"
23#include "ncmesh.hpp"
24#include "../fem/eltrans.hpp"
26#include "../general/zstr.hpp"
27#ifdef MFEM_USE_ADIOS2
29#endif
30#include <iostream>
31#include <array>
32#include <map>
33#include <memory>
34
35namespace mfem
36{
37
38class GeometricFactors;
39class FaceGeometricFactors;
40class KnotVector;
41class NURBSExtension;
42class FiniteElementSpace;
43class GridFunction;
44struct Refinement;
45
46/** An enum type to specify if interior or boundary faces are desired. */
47enum class FaceType : bool {Interior, Boundary};
48
49#ifdef MFEM_USE_MPI
50class ParMesh;
51class ParNCMesh;
52#endif
53
54/// Mesh data type
55class Mesh
56{
57 friend class NCMesh;
58 friend class NURBSExtension;
59#ifdef MFEM_USE_MPI
60 friend class ParMesh;
61 friend class ParNCMesh;
62#endif
63#ifdef MFEM_USE_ADIOS2
64 friend class adios2stream;
65#endif
66
67protected:
68 int Dim;
70
73 /** These variables store the number of Interior and Boundary faces. Calling
74 fes->GetMesh()->GetNBE() doesn't return the expected value in 3D because
75 periodic meshes in 3D have some of their faces marked as boundary for
76 visualization purpose in GLVis. */
78
79 // see MeshGenerator(); global in parallel
81 // sum of (1 << geom) for all geom of all dimensions; local in parallel
83
84 // Counter for Mesh transformations: refinement, derefinement, rebalancing.
85 // Used for checking during Update operations on objects depending on the
86 // Mesh, such as FiniteElementSpace, GridFunction, etc.
88
89 /// Counter for geometric factor invalidation
91
93 // Vertices are only at the corners of elements, where you would expect them
94 // in the lowest-order mesh. In some cases, e.g. in a Mesh that defines the
95 // patch topology for a NURBS mesh (see LoadPatchTopo()) the vertices may be
96 // empty while NumOfVertices is positive.
100
101 /** @brief This structure stores the low level information necessary to
102 interpret the configuration of elements on a specific face. This
103 information can be accessed using methods like GetFaceElements(),
104 GetFaceInfos(), FaceIsInterior(), etc.
105
106 For accessing higher level deciphered information look at
107 Mesh::FaceInformation, and its accessor Mesh::GetFaceInformation().
108
109 Each face contains information on the indices, local reference faces,
110 orientations, and potential nonconformity for the two neighboring
111 elements on a face.
112 Each face can either be an interior, boundary, or shared interior face.
113 Each interior face is shared by two elements referred as Elem1 and Elem2.
114 For boundary faces only the information on Elem1 is relevant.
115 Shared interior faces correspond to faces where Elem1 and Elem2 are
116 distributed on different MPI ranks.
117 Regarding conformity, three cases are distinguished, conforming faces,
118 nonconforming slave faces, and nonconforming master faces. Master and
119 slave referring to the coarse and fine elements respectively on a
120 nonconforming face.
121 Nonconforming slave faces always have the slave element as Elem1 and
122 the master element as Elem2. On the other side, nonconforming master
123 faces always have the master element as Elem1, and one of the slave
124 element as Elem2. Except for ghost nonconforming slave faces, where
125 Elem1 is the master side and Elem2 is the slave side.
126
127 The indices of Elem1 and Elem2 can be indirectly extracted from
128 FaceInfo::Elem1No and FaceInfo::Elem2No, read the note below for special
129 cases on the index of Elem2.
130
131 The local face identifiers are deciphered from FaceInfo::Elem1Inf and
132 FaceInfo::Elem2Inf through the formula: LocalFaceIndex = ElemInf/64,
133 the semantic of the computed local face identifier can be found in
134 fem/geom.cpp. The local face identifier corresponds to an index
135 in the Constants<Geometry>::Edges arrays for 2D element geometries, and
136 to an index in the Constants<Geometry>::FaceVert arrays for 3D element
137 geometries.
138
139 The orientation of each element relative to a face is obtained through
140 the formula: Orientation = ElemInf%64, the semantic of the orientation
141 can also be found in fem/geom.cpp. The orientation corresponds to
142 an index in the Constants<Geometry>::Orient arrays, providing the
143 sequence of vertices identifying the orientation of an edge/face. By
144 convention the orientation of Elem1 is always set to 0, serving as the
145 reference orientation. The orientation of Elem2 relatively to Elem1 is
146 therefore determined just by using the orientation of Elem2. An important
147 special case is the one of nonconforming faces, the orientation should
148 be composed with the PointMatrix, which also contains orientation
149 information. A special treatment should be done for 2D, the orientation
150 in the PointMatrix is not included, therefore when applying the
151 PointMatrix transformation, the PointMatrix should be flipped, except for
152 shared nonconforming slave faces where the transformation can be applied
153 as is.
154
155 Another special case is the case of shared nonconforming faces. Ghost
156 faces use a different design based on so called "ghost" faces.
157 Ghost faces, as their name suggest are very well hidden, and they
158 usually have a separate interface from "standard" faces.
159 */
160 struct FaceInfo
161 {
162 // Inf = 64 * LocalFaceIndex + FaceOrientation
164 int NCFace; /* -1 if this is a regular conforming/boundary face;
165 index into 'nc_faces_info' if >= 0. */
166 };
167 // NOTE: in NC meshes, master faces have Elem2No == -1. Slave faces on the
168 // other hand have Elem2No and Elem2Inf set to the master face's element and
169 // its local face number.
170 //
171 // A local face is one generated from a local element and has index i in
172 // faces_info such that i < GetNumFaces(). Also, Elem1No always refers to the
173 // element (slave or master, in the nonconforming case) that generated the
174 // face.
175 // Classification of a local (non-ghost) face based on its FaceInfo:
176 // - Elem2No >= 0 --> local interior face; can be either:
177 // - NCFace == -1 --> conforming face, or
178 // - NCFace >= 0 --> nonconforming slave face; Elem2No is the index of
179 // the master volume element; Elem2Inf%64 is 0, see the note in
180 // Mesh::GenerateNCFaceInfo().
181 // - Elem2No < 0 --> local "boundary" face; can be one of:
182 // - NCFace == -1 --> conforming face; can be either:
183 // - Elem2Inf < 0 --> true boundary face (no element on side 2)
184 // - Elem2Inf >= 0 --> shared face where element 2 is a face-neighbor
185 // element with index -1-Elem2No. This state is initialized by
186 // ParMesh::ExchangeFaceNbrData().
187 // - NCFace >= 0 --> nonconforming face; can be one of:
188 // - Elem2Inf < 0 --> master nonconforming face, interior or shared;
189 // In this case, Elem2No is -1; see GenerateNCFaceInfo().
190 // - Elem2Inf >= 0 --> shared slave nonconforming face where element 2
191 // is the master face-neighbor element with index -1-Elem2No; see
192 // ParNCMesh::GetFaceNeighbors().
193 //
194 // A ghost face is a nonconforming face that is generated by a non-local,
195 // i.e. ghost, element. A ghost face has index i in faces_info such that
196 // i >= GetNumFaces().
197 // Classification of a ghost (non-local) face based on its FaceInfo:
198 // - Elem1No == -1 --> master ghost face? These ghost faces also have:
199 // Elem2No == -1, Elem1Inf == Elem2Inf == -1, and NCFace == -1.
200 // - Elem1No >= 0 --> slave ghost face; Elem1No is the index of the local
201 // master side element, i.e. side 1 IS NOT the side that generated the
202 // face. Elem2No is < 0 and -1-Elem2No is the index of the ghost
203 // face-neighbor element that generated this slave ghost face. In this
204 // case, Elem2Inf >= 0 and NCFace >= 0.
205 // Relevant methods: GenerateFaces(), GenerateNCFaceInfo(),
206 // ParNCMesh::GetFaceNeighbors(),
207 // ParMesh::ExchangeFaceNbrData()
208
210 {
211 bool Slave; // true if this is a slave face, false if master face
212 int MasterFace; // if Slave, this is the index of the master face
213 // If not Slave, 'MasterFace' is the local face index of this master face
214 // as a face in the unique adjacent element.
215 const DenseMatrix* PointMatrix; // if Slave, position within master face
216 // (NOTE: PointMatrix points to a matrix owned by NCMesh.)
217
218 NCFaceInfo() = default;
219
220 NCFaceInfo(bool slave, int master, const DenseMatrix* pm)
221 : Slave(slave), MasterFace(master), PointMatrix(pm) {}
222 };
223
226
230 Array<int> be_to_face; // faces = vertices (1D), edges (2D), faces (3D)
231
232 Table *bel_to_edge; // for 3D only
233
234 // Note that the following tables are owned by this class and should not be
235 // deleted by the caller. Of these three tables, only face_edge and
236 // edge_vertex are returned by access functions.
237 mutable Table *face_to_elem; // Used by FindFaceNeighbors, not returned.
238 mutable Table *face_edge; // Returned by GetFaceEdgeTable().
239 mutable Table *edge_vertex; // Returned by GetEdgeVertexTable().
240
245
246 // refinement embeddings for forward compatibility with NCMesh
248
249 // Nodes are only active for higher order meshes, and share locations with
250 // the vertices, plus all the higher- order control points within the
251 // element and along the edges and on the faces.
254
255 static const int vtk_quadratic_tet[10];
256 static const int vtk_quadratic_pyramid[13];
257 static const int vtk_quadratic_wedge[18];
258 static const int vtk_quadratic_hex[27];
259
260#ifdef MFEM_USE_MEMALLOC
261 friend class Tetrahedron;
262 MemAlloc <Tetrahedron, 1024> TetMemory;
263#endif
264
265 // used during NC mesh initialization only
267
268public:
276
278
279 /// A list of all unique element attributes used by the Mesh.
281 /// A list of all unique boundary attributes used by the Mesh.
283
284 /// Named sets of element attributes
286
287 /// Named sets of boundary element attributes
289
290 NURBSExtension *NURBSext; ///< Optional NURBS mesh extension.
291 NCMesh *ncmesh; ///< Optional nonconforming mesh extension.
292 Array<GeometricFactors*> geom_factors; ///< Optional geometric factors.
294 factors. */
295
296 // Global parameter that can be used to control the removal of unused
297 // vertices performed when reading a mesh in MFEM format. The default value
298 // (true) is set in mesh_readers.cpp.
300
301protected:
303
304 void Init();
305 void InitTables();
306 void SetEmpty(); // Init all data members with empty values
307 void DestroyTables();
309 void DestroyPointers(); // Delete data specifically allocated by class Mesh.
310 void Destroy(); // Delete all owned data.
311 void ResetLazyData();
312
313 Element *ReadElementWithoutAttr(std::istream &input);
314 static void PrintElementWithoutAttr(const Element *el, std::ostream &os);
315
316 Element *ReadElement(std::istream &input);
317 static void PrintElement(const Element *el, std::ostream &os);
318
319 // Readers for different mesh formats, used in the Load() method.
320 // The implementations of these methods are in mesh_readers.cpp.
321 void ReadMFEMMesh(std::istream &input, int version, int &curved);
322 void ReadLineMesh(std::istream &input);
323 void ReadNetgen2DMesh(std::istream &input, int &curved);
324 void ReadNetgen3DMesh(std::istream &input);
325 void ReadTrueGridMesh(std::istream &input);
326 void CreateVTKMesh(const Vector &points, const Array<int> &cell_data,
327 const Array<int> &cell_offsets,
328 const Array<int> &cell_types,
329 const Array<int> &cell_attributes,
330 int &curved, int &read_gf, bool &finalize_topo);
331 void ReadVTKMesh(std::istream &input, int &curved, int &read_gf,
332 bool &finalize_topo);
333 void ReadXML_VTKMesh(std::istream &input, int &curved, int &read_gf,
334 bool &finalize_topo, const std::string &xml_prefix="");
335 void ReadNURBSMesh(std::istream &input, int &curved, int &read_gf,
336 bool spacing=false);
337 void ReadInlineMesh(std::istream &input, bool generate_edges = false);
338 void ReadGmshMesh(std::istream &input, int &curved, int &read_gf);
339
340 /* Note NetCDF (optional library) is used for reading cubit files */
341#ifdef MFEM_USE_NETCDF
342 /// @brief Load a mesh from a Genesis file.
343 void ReadCubit(const std::string &filename, int &curved, int &read_gf);
344#endif
345
346 /// Determine the mesh generator bitmask #meshgen, see MeshGenerator().
347 /** Also, initializes #mesh_geoms. */
348 void SetMeshGen();
349
350 /// Return the length of the segment from node i to node j.
351 real_t GetLength(int i, int j) const;
352
353 void MarkForRefinement();
355 void GetEdgeOrdering(const DSTable &v_to_v, Array<int> &order);
356 virtual void MarkTetMeshForRefinement(const DSTable &v_to_v);
357
358 // Methods used to prepare and apply permutation of the mesh nodes assuming
359 // that the mesh elements may be rotated (e.g. to mark triangle or tet edges
360 // for refinement) between the two calls - PrepareNodeReorder() and
361 // DoNodeReorder(). The latter method assumes that the 'faces' have not been
362 // updated after the element rotations.
363 void PrepareNodeReorder(DSTable **old_v_to_v, Table **old_elem_vert);
364 void DoNodeReorder(DSTable *old_v_to_v, Table *old_elem_vert);
365
367 STable3D *GetElementToFaceTable(int ret_ftbl = 0);
368
369 /** Red refinement. Element with index i is refined. The default
370 red refinement for now is Uniform. */
371 void RedRefinement(int i, const DSTable &v_to_v,
372 int *edge1, int *edge2, int *middle)
373 { UniformRefinement(i, v_to_v, edge1, edge2, middle); }
374
375 /** Green refinement. Element with index i is refined. The default
376 refinement for now is Bisection. */
377 void GreenRefinement(int i, const DSTable &v_to_v,
378 int *edge1, int *edge2, int *middle)
379 { Bisection(i, v_to_v, edge1, edge2, middle); }
380
381 /// Bisect a triangle: element with index @a i is bisected.
382 void Bisection(int i, const DSTable &, int *, int *, int *);
383
384 /// Bisect a tetrahedron: element with index @a i is bisected.
385 void Bisection(int i, HashTable<Hashed2> &);
386
387 /// Bisect a boundary triangle: boundary element with index @a i is bisected.
388 void BdrBisection(int i, const HashTable<Hashed2> &);
389
390 /** Uniform Refinement. Element with index i is refined uniformly. */
391 void UniformRefinement(int i, const DSTable &, int *, int *, int *);
392
393 /** @brief Averages the vertices with given @a indexes and saves the result
394 in #vertices[result]. */
395 void AverageVertices(const int *indexes, int n, int result);
396
398 int FindCoarseElement(int i);
399
400 /** @brief Update the nodes of a curved mesh after the topological part of a
401 Mesh::Operation, such as refinement, has been performed. */
402 /** If Nodes GridFunction is defined, i.e. not NULL, this method calls
403 NodesUpdated().
404
405 @note Unlike the similarly named public method NodesUpdated() this
406 method modifies the mesh nodes (if they exist) and calls NodesUpdated().
407 */
408 void UpdateNodes();
409
410 /// Helper to set vertex coordinates given a high-order curvature function.
411 void SetVerticesFromNodes(const GridFunction *nodes);
412
413 void UniformRefinement2D_base(bool update_nodes = true);
414
415 /// Refine a mixed 2D mesh uniformly.
417
418 /* If @a f2qf is not NULL, adds all quadrilateral faces to @a f2qf which
419 represents a "face-to-quad-face" index map. When all faces are quads, the
420 array @a f2qf is kept empty since it is not needed. */
421 void UniformRefinement3D_base(Array<int> *f2qf = NULL,
422 DSTable *v_to_v_p = NULL,
423 bool update_nodes = true);
424
425 /// Refine a mixed 3D mesh uniformly.
427
428 /// This function is not public anymore. Use GeneralRefinement instead.
429 virtual void LocalRefinement(const Array<int> &marked_el, int type = 3);
430
431 /// This function is not public anymore. Use GeneralRefinement instead.
432 virtual void NonconformingRefinement(const Array<Refinement> &refinements,
433 int nc_limit = 0);
434
435 /// NC version of GeneralDerefinement.
436 virtual bool NonconformingDerefinement(Array<real_t> &elem_error,
437 real_t threshold, int nc_limit = 0,
438 int op = 1);
439 /// Derefinement helper.
440 real_t AggregateError(const Array<real_t> &elem_error,
441 const int *fine, int nfine, int op);
442
443 /// Read NURBS patch/macro-element mesh
444 void LoadPatchTopo(std::istream &input, Array<int> &edge_to_knot);
445
446 void UpdateNURBS();
447
448 /** @brief Write the beginning of a NURBS mesh to @a os, specifying the NURBS
449 patch topology. Optional file comments can be provided in @a comments.
450
451 @param[in] os Output stream to which to write.
452 @param[in] e_to_k Map from edge to signed knotvector indices.
453 @param[in] version NURBS mesh version number times 10 (e.g. 11 for v1.1).
454 @param[in] comment Optional comment string, written after version line.
455 */
456 void PrintTopo(std::ostream &os, const Array<int> &e_to_k,
457 const int version,
458 const std::string &comment = "") const;
459
460 /// Used in GetFaceElementTransformations (...)
462 int i) const;
464 int i) const;
466 int i) const;
468 int i) const;
470 int i) const;
472 int i) const;
474 int i) const;
476 int i) const;
478 int i) const;
479
480 /** Used in GetFaceElementTransformations to account for the fact that a
481 slave face occupies only a portion of its master face. */
483 const FaceInfo &fi, bool is_ghost) const;
484
485 bool IsSlaveFace(const FaceInfo &fi) const;
486
487 /// Returns the orientation of "test" relative to "base"
488 static int GetTriOrientation(const int *base, const int *test);
489
490 /// Returns the orientation of "base" relative to "test"
491 /// In other words: GetTriOrientation(test, base) should equal
492 /// InvertTriOrientation(GetTriOrientation(base, test))
493 static int InvertTriOrientation(int ori);
494
495 /// Returns the orientation of "c" relative to "a" by composing
496 /// previously computed orientations relative to an intermediate
497 /// set "b".
498 static int ComposeTriOrientations(int ori_a_b, int ori_b_c);
499
500 /// Returns the orientation of "test" relative to "base"
501 static int GetQuadOrientation(const int *base, const int *test);
502
503 /// Returns the orientation of "base" relative to "test"
504 /// In other words: GetQuadOrientation(test, base) should equal
505 /// InvertQuadOrientation(GetQuadOrientation(base, test))
506 static int InvertQuadOrientation(int ori);
507
508 /// Returns the orientation of "c" relative to "a" by composing
509 /// previously computed orientations relative to an intermediate
510 /// set "b".
511 static int ComposeQuadOrientations(int ori_a_b, int ori_b_c);
512
513 /// Returns the orientation of "test" relative to "base"
514 static int GetTetOrientation(const int *base, const int *test);
515
516 static void GetElementArrayEdgeTable(const Array<Element*> &elem_array,
517 const DSTable &v_to_v,
519
520 /** Return element to edge table and the indices for the boundary edges.
521 The entries in the table are ordered according to the order of the
522 nodes in the elements. For example, if T is the element to edge table
523 T(i, 0) gives the index of edge in element i that connects vertex 0
524 to vertex 1, etc. Returns the number of the edges. */
526
527 /// Used in GenerateFaces()
528 void AddPointFaceElement(int lf, int gf, int el);
529
530 void AddSegmentFaceElement (int lf, int gf, int el, int v0, int v1);
531
532 void AddTriangleFaceElement (int lf, int gf, int el,
533 int v0, int v1, int v2);
534
535 void AddQuadFaceElement (int lf, int gf, int el,
536 int v0, int v1, int v2, int v3);
537 /** For a serial Mesh, return true if the face is interior. For a parallel
538 ParMesh return true if the face is interior or shared. In parallel, this
539 method only works if the face neighbor data is exchanged. */
540 bool FaceIsTrueInterior(int FaceNo) const
541 {
542 return FaceIsInterior(FaceNo) || (faces_info[FaceNo].Elem2Inf >= 0);
543 }
544
545 void FreeElement(Element *E);
546
547 void GenerateFaces();
548 void GenerateNCFaceInfo();
549
550 /// Begin construction of a mesh
551 void InitMesh(int Dim_, int spaceDim_, int NVert, int NElem, int NBdrElem);
552
553 // Used in the methods FinalizeXXXMesh() and FinalizeTopology()
554 void FinalizeCheck();
555
556 void Loader(std::istream &input, int generate_edges = 0,
557 std::string parse_tag = "");
558
559 /** If NURBS mesh, write NURBS format. If NCMesh, write mfem v1.1 format.
560 If section_delimiter is empty, write mfem v1.0 format. Otherwise, write
561 mfem v1.2 format with the given section_delimiter at the end.
562 If @a comments is non-empty, it will be printed after the first line of
563 the file, and each line should begin with '#'. */
564 void Printer(std::ostream &os = mfem::out,
565 std::string section_delimiter = "",
566 const std::string &comments = "") const;
567
568 /// @brief Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz],
569 /// divided into nx*ny*nz hexahedra if @a type = HEXAHEDRON or into
570 /// 6*nx*ny*nz tetrahedrons if @a type = TETRAHEDRON.
571 ///
572 /// The parameter @a sfc_ordering controls how the elements
573 /// (when @a type = HEXAHEDRON) are ordered: true - use space-filling curve
574 /// ordering, or false - use lexicographic ordering.
575 void Make3D(int nx, int ny, int nz, Element::Type type,
576 real_t sx, real_t sy, real_t sz, bool sfc_ordering);
577
578 /// @brief Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz],
579 /// divided into nx*ny*nz*24 tetrahedrons.
580 ///
581 /// The mesh is generated by taking nx*ny*nz hexahedra and splitting each
582 /// hexahedron into 24 tetrahedrons. Each face of the hexahedron is split
583 /// into 4 triangles (face edges are connected to a face-centered point),
584 /// and the triangles are connected to a hex-centered point.
585 void Make3D24TetsFromHex(int nx, int ny, int nz,
586 real_t sx, real_t sy, real_t sz);
587
588 /// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*4
589 /// triangles.
590 ///
591 /// The mesh is generated by taking nx*ny quadrilaterals and splitting each
592 /// quadrilateral into 4 triangles by connecting the vertices to a
593 /// quad-centered point.
594 void Make2D4TrisFromQuad(int nx, int ny, real_t sx, real_t sy);
595
596 /// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*5
597 /// quadrilaterals.
598 ///
599 /// The mesh is generated by taking nx*ny quadrilaterals and splitting
600 /// each quadrilateral into 5 quadrilaterals. Each quadrilateral is projected
601 /// inwards and connected to the original quadrilateral.
602 void Make2D5QuadsFromQuad(int nx, int ny, real_t sx, real_t sy);
603
604 /// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny
605 /// quadrilaterals if @a type = QUADRILATERAL or into 2*nx*ny triangles if
606 /// @a type = TRIANGLE.
607 ///
608 /// If generate_edges = 0 (default) edges are not generated, if 1 edges are
609 /// generated. The parameter @a sfc_ordering controls how the elements (when
610 /// @a type = QUADRILATERAL) are ordered: true - use space-filling curve
611 /// ordering, or false - use lexicographic ordering.
612 void Make2D(int nx, int ny, Element::Type type, real_t sx, real_t sy,
613 bool generate_edges, bool sfc_ordering);
614
615 /// @a brief Creates a 1D mesh for the interval [0,sx] divided into n equal
616 /// intervals.
617 void Make1D(int n, real_t sx = 1.0);
618
619 /// Internal function used in Mesh::MakeRefined
620 void MakeRefined_(Mesh &orig_mesh, const Array<int> &ref_factors,
621 int ref_type);
622
623 /// Initialize vertices/elements/boundary/tables from a nonconforming mesh.
624 void InitFromNCMesh(const NCMesh &ncmesh);
625
626 /// Create from a nonconforming mesh.
627 explicit Mesh(const NCMesh &ncmesh);
628
629 // used in GetElementData() and GetBdrElementData()
630 void GetElementData(const Array<Element*> &elem_array, int geom,
631 Array<int> &elem_vtx, Array<int> &attr) const;
632
633 // Internal helper used in MakeSimplicial (and ParMesh::MakeSimplicial).
634 void MakeSimplicial_(const Mesh &orig_mesh, int *vglobal);
635
636public:
637
638 /// @anchor mfem_Mesh_ctors
639 /// @name Standard Mesh constructors and related methods
640 ///
641 /// These constructors and assignment operators accept mesh information in
642 /// a variety of common forms. For more specialized constructors see
643 /// @ref mfem_Mesh_named_ctors "Named mesh constructors".
644 /// @{
647
648 /** Copy constructor. Performs a deep copy of (almost) all data, so that the
649 source mesh can be modified (e.g. deleted, refined) without affecting the
650 new mesh. If 'copy_nodes' is false, use a shallow (pointer) copy for the
651 nodes, if present. */
652 explicit Mesh(const Mesh &mesh, bool copy_nodes = true);
653
654 /// Move constructor, useful for using a Mesh as a function return value.
655 Mesh(Mesh &&mesh);
656
657 /// Move assignment operator.
658 Mesh& operator=(Mesh &&mesh);
659
660 /// Explicitly delete the copy assignment operator.
661 Mesh& operator=(const Mesh &mesh) = delete;
662
663 /// Construct a Mesh from the given primary data.
664 /** The array @a vertices is used as external data, i.e. the Mesh does not
665 copy the data and will not delete the pointer.
666
667 The data from the other arrays is copied into the internal Mesh data
668 structures.
669
670 This method calls the method FinalizeTopology(). The method Finalize()
671 may be called after this constructor and after optionally setting the
672 Mesh nodes. */
673 Mesh(real_t *vertices, int num_vertices,
674 int *element_indices, Geometry::Type element_type,
675 int *element_attributes, int num_elements,
676 int *boundary_indices, Geometry::Type boundary_type,
677 int *boundary_attributes, int num_boundary_elements,
678 int dimension, int space_dimension = -1);
679
680 /** @anchor mfem_Mesh_init_ctor
681 @brief _Init_ constructor: begin the construction of a Mesh object.
682
683 Construct a shell of a mesh object allocating space to store pointers to
684 the vertices, elements, and boundary elements. The vertices and elements
685 themselves can later be added using methods from the
686 @ref mfem_Mesh_construction "Mesh construction" group. */
687 Mesh(int Dim_, int NVert, int NElem, int NBdrElem = 0, int spaceDim_ = -1)
689 {
690 if (spaceDim_ == -1) { spaceDim_ = Dim_; }
691 InitMesh(Dim_, spaceDim_, NVert, NElem, NBdrElem);
692 }
693
694 /** Creates mesh by reading a file in MFEM, Netgen, or VTK format. If
695 generate_edges = 0 (default) edges are not generated, if 1 edges are
696 generated. See also @a Mesh::LoadFromFile. See @a Mesh::Finalize for the
697 meaning of @a refine. */
698 explicit Mesh(const std::string &filename, int generate_edges = 0,
699 int refine = 1, bool fix_orientation = true);
700
701 /** Creates mesh by reading data stream in MFEM, Netgen, or VTK format. If
702 generate_edges = 0 (default) edges are not generated, if 1 edges are
703 generated. */
704 explicit Mesh(std::istream &input, int generate_edges = 0, int refine = 1,
705 bool fix_orientation = true);
706
707 /// Create a disjoint mesh from the given mesh array
708 ///
709 /// @note Data is copied from the meshes in @a mesh_array.
710 Mesh(Mesh *mesh_array[], int num_pieces);
711
712 /** This is similar to the mesh constructor with the same arguments, but here
713 the current mesh is destroyed and another one created based on the data
714 stream again given in MFEM, Netgen, or VTK format. If generate_edges = 0
715 (default) edges are not generated, if 1 edges are generated. */
716 /// \see mfem::ifgzstream() for on-the-fly decompression of compressed ascii
717 /// inputs.
718 virtual void Load(std::istream &input, int generate_edges = 0,
719 int refine = 1, bool fix_orientation = true)
720 {
721 Loader(input, generate_edges);
722 Finalize(refine, fix_orientation);
723 }
724
725 /// Swaps internal data with another mesh. By default, non-geometry members
726 /// like 'ncmesh' and 'NURBSExt' are only swapped when 'non_geometry' is set.
727 void Swap(Mesh& other, bool non_geometry);
728
729 /// Clear the contents of the Mesh.
730 void Clear() { Destroy(); SetEmpty(); }
731
732 /// Destroys Mesh.
733 virtual ~Mesh() { DestroyPointers(); }
734
735 /// @}
736
737 /** @anchor mfem_Mesh_named_ctors @name Named mesh constructors.
738
739 Each of these constructors uses the move constructor, and can be used as
740 the right-hand side of an assignment when creating new meshes. For more
741 general mesh constructors see
742 @ref mfem_Mesh_ctors "Standard mesh constructors".*/
743 ///@{
744
745 /** Creates mesh by reading a file in MFEM, Netgen, or VTK format. If
746 generate_edges = 0 (default) edges are not generated, if 1 edges are
747 generated.
748
749 @note @a filename is not cached by the Mesh object and can be
750 safely deleted following this function call.
751 */
752 static Mesh LoadFromFile(const std::string &filename,
753 int generate_edges = 0, int refine = 1,
754 bool fix_orientation = true);
755
756 /// Creates 1D mesh, divided into n equal intervals.
757 static Mesh MakeCartesian1D(int n, real_t sx = 1.0);
758
759 /// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny
760 /// quadrilaterals if @a type = QUADRILATERAL or into 2*nx*ny triangles if
761 /// @a type = TRIANGLE.
762 ///
763 /// If generate_edges = 0 (default) edges are not generated, if 1 edges are
764 /// generated. The parameter @a sfc_ordering controls how the elements (when
765 /// @a type = QUADRILATERAL) are ordered: true - use space-filling curve
766 /// ordering, or false - use lexicographic ordering.
767 static Mesh MakeCartesian2D(
768 int nx, int ny, Element::Type type, bool generate_edges = false,
769 real_t sx = 1.0, real_t sy = 1.0, bool sfc_ordering = true);
770
771 /// @brief Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz],
772 /// divided into nx*ny*nz hexahedra if @a type = HEXAHEDRON or into
773 /// 6*nx*ny*nz tetrahedrons if @a type = TETRAHEDRON.
774 ///
775 /// The parameter @a sfc_ordering controls how the elements
776 /// (when @a type = HEXAHEDRON) are ordered: true - use space-filling curve
777 /// ordering, or false - use lexicographic ordering.
778 static Mesh MakeCartesian3D(
779 int nx, int ny, int nz, Element::Type type,
780 real_t sx = 1.0, real_t sy = 1.0, real_t sz = 1.0,
781 bool sfc_ordering = true);
782
783 /// @brief Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz],
784 /// divided into nx*ny*nz*24 tetrahedrons.
785 ///
786 /// The mesh is generated by taking nx*ny*nz hexahedra and splitting each
787 /// hexahedron into 24 tetrahedrons. Each face of the hexahedron is split
788 /// into 4 triangles (face edges are connected to a face-centered point),
789 /// and the triangles are connected to a hex-centered point.
790 static Mesh MakeCartesian3DWith24TetsPerHex(int nx, int ny, int nz,
791 real_t sx = 1.0, real_t sy = 1.0,
792 real_t sz = 1.0);
793
794 /// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*4
795 /// triangles.
796 ///
797 /// The mesh is generated by taking nx*ny quadrilaterals and splitting each
798 /// quadrilateral into 4 triangles by connecting the vertices to a
799 /// quad-centered point.
800 static Mesh MakeCartesian2DWith4TrisPerQuad(int nx, int ny, real_t sx = 1.0,
801 real_t sy = 1.0);
802
803 /// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*5
804 /// quadrilaterals.
805 ///
806 /// The mesh is generated by taking nx*ny quadrilaterals and splitting
807 /// each quadrilateral into 5 quadrilaterals. Each quadrilateral is projected
808 /// inwards and connected to the original quadrilateral.
809 static Mesh MakeCartesian2DWith5QuadsPerQuad(int nx, int ny, real_t sx = 1.0,
810 real_t sy = 1.0);
811
812
813 /// Create a refined (by any factor) version of @a orig_mesh.
814 /** @param[in] orig_mesh The starting coarse mesh.
815 @param[in] ref_factor The refinement factor, an integer > 1.
816 @param[in] ref_type Specify the positions of the new vertices. The
817 options are BasisType::ClosedUniform or
818 BasisType::GaussLobatto.
819
820 The refinement data which can be accessed with GetRefinementTransforms()
821 is set to reflect the performed refinements.
822
823 @note The constructed Mesh is straight-sided. */
824 static Mesh MakeRefined(Mesh &orig_mesh, int ref_factor, int ref_type);
825
826 /// Create a refined mesh, where each element of the original mesh may be
827 /// refined by a different factor.
828 /** @param[in] orig_mesh The starting coarse mesh.
829 @param[in] ref_factors An array of integers whose size is the number of
830 elements of @a orig_mesh. The @a ith element of
831 @a orig_mesh is refined by refinement factor
832 @a ref_factors[i].
833 @param[in] ref_type Specify the positions of the new vertices. The
834 options are BasisType::ClosedUniform or
835 BasisType::GaussLobatto.
836
837 The refinement data which can be accessed with GetRefinementTransforms()
838 is set to reflect the performed refinements.
839
840 @note The constructed Mesh is straight-sided. */
841 /// refined @a ref_factors[i] times in each dimension.
842 static Mesh MakeRefined(Mesh &orig_mesh, const Array<int> &ref_factors,
843 int ref_type);
844
845 /** Create a mesh by splitting each element of @a orig_mesh into simplices.
846 Quadrilaterals are split into two triangles, prisms are split into
847 3 tetrahedra, and hexahedra are split into either 5 or 6 tetrahedra
848 depending on the configuration.
849 @warning The curvature of the original mesh is not carried over to the
850 new mesh. Periodic meshes are not supported. */
851 static Mesh MakeSimplicial(const Mesh &orig_mesh);
852
853 /// Create a periodic mesh by identifying vertices of @a orig_mesh.
854 /** Each vertex @a i will be mapped to vertex @a v2v[i], such that all
855 vertices that are coincident under the periodic mapping get mapped to
856 the same index. The mapping @a v2v can be generated from translation
857 vectors using Mesh::CreatePeriodicVertexMapping.
858 @note MFEM requires that each edge of the resulting mesh be uniquely
859 identifiable by a pair of distinct vertices. As a consequence, periodic
860 boundaries must be connected by at least three edges. */
861 static Mesh MakePeriodic(const Mesh &orig_mesh, const std::vector<int> &v2v);
862
863 ///@}
864
865 /** @anchor mfem_Mesh_construction
866 @name Methods for piecewise Mesh construction.
867
868 These methods are intended to be used with the @ref mfem_Mesh_init_ctor
869 "init constructor". */
870 ///@{
871
872 /// @note The returned object should be deleted by the caller.
873 Element *NewElement(int geom);
874
875 int AddVertex(real_t x, real_t y = 0.0, real_t z = 0.0);
876 int AddVertex(const real_t *coords);
877 int AddVertex(const Vector &coords);
878 /// Mark vertex @a i as nonconforming, with parent vertices @a p1 and @a p2.
879 void AddVertexParents(int i, int p1, int p2);
880 /// Adds a vertex at the mean center of the @a nverts vertex indices given
881 /// by @a vi.
882 int AddVertexAtMeanCenter(const int *vi, const int nverts, int dim = 3);
883
884 /// Adds a segment to the mesh given by 2 vertices @a v1 and @a v2.
885 int AddSegment(int v1, int v2, int attr = 1);
886 /// Adds a segment to the mesh given by 2 vertices @a vi.
887 int AddSegment(const int *vi, int attr = 1);
888
889 /// Adds a triangle to the mesh given by 3 vertices @a v1 through @a v3.
890 int AddTriangle(int v1, int v2, int v3, int attr = 1);
891 /// Adds a triangle to the mesh given by 3 vertices @a vi.
892 int AddTriangle(const int *vi, int attr = 1);
893 /// Adds a triangle to the mesh given by 3 vertices @a vi.
894 int AddTri(const int *vi, int attr = 1) { return AddTriangle(vi, attr); }
895
896 /// Adds a quadrilateral to the mesh given by 4 vertices @a v1 through @a v4.
897 int AddQuad(int v1, int v2, int v3, int v4, int attr = 1);
898 /// Adds a quadrilateral to the mesh given by 4 vertices @a vi.
899 int AddQuad(const int *vi, int attr = 1);
900
901 /// Adds a tetrahedron to the mesh given by 4 vertices @a v1 through @a v4.
902 int AddTet(int v1, int v2, int v3, int v4, int attr = 1);
903 /// Adds a tetrahedron to the mesh given by 4 vertices @a vi.
904 int AddTet(const int *vi, int attr = 1);
905
906 /// Adds a wedge to the mesh given by 6 vertices @a v1 through @a v6.
907 int AddWedge(int v1, int v2, int v3, int v4, int v5, int v6, int attr = 1);
908 /// Adds a wedge to the mesh given by 6 vertices @a vi.
909 int AddWedge(const int *vi, int attr = 1);
910
911 /// Adds a pyramid to the mesh given by 5 vertices @a v1 through @a v5.
912 int AddPyramid(int v1, int v2, int v3, int v4, int v5, int attr = 1);
913 /// Adds a pyramid to the mesh given by 5 vertices @a vi.
914 int AddPyramid(const int *vi, int attr = 1);
915
916 /// Adds a hexahedron to the mesh given by 8 vertices @a v1 through @a v8.
917 int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8,
918 int attr = 1);
919 /// Adds a hexahedron to the mesh given by 8 vertices @a vi.
920 int AddHex(const int *vi, int attr = 1);
921 /// @brief Adds 6 tetrahedrons to the mesh by splitting a hexahedron given by
922 /// 8 vertices @a vi.
923 void AddHexAsTets(const int *vi, int attr = 1);
924 /// @brief Adds 2 wedges to the mesh by splitting a hexahedron given by
925 /// 8 vertices @a vi.
926 void AddHexAsWedges(const int *vi, int attr = 1);
927 /// @brief Adds 6 pyramids to the mesh by splitting a hexahedron given by
928 /// 8 vertices @a vi.
929 void AddHexAsPyramids(const int *vi, int attr = 1);
930
931 /// @brief Adds 24 tetrahedrons to the mesh by splitting a hexahedron.
932 ///
933 /// @a vi are the 8 vertices of the hexahedron, @a hex_face_verts has the
934 /// map from the 4 vertices of each face of the hexahedron to the index
935 /// of the point created at the center of the face, and @a attr is the
936 /// attribute of the new elements. See @a Make3D24TetsFromHex for usage.
937 void AddHexAs24TetsWithPoints(int *vi,
938 std::map<std::array<int, 4>, int>
939 &hex_face_verts,
940 int attr = 1);
941
942 /// @brief Adds 4 triangles to the mesh by splitting a quadrilateral given by
943 /// 4 vertices @a vi.
944 ///
945 /// @a attr is the attribute of the new elements. See @a Make2D4TrisFromQuad
946 /// for usage.
947 void AddQuadAs4TrisWithPoints(int *vi, int attr = 1);
948
949 /// @brief Adds 5 quadrilaterals to the mesh by splitting a quadrilateral
950 /// given by 4 vertices @a vi.
951 ///
952 /// @a attr is the attribute of the new elements. See @a Make2D5QuadsFromQuad
953 /// for usage.
954 void AddQuadAs5QuadsWithPoints(int *vi, int attr = 1);
955
956 /// The parameter @a elem should be allocated using the NewElement() method
957 /// @note Ownership of @a elem will pass to the Mesh object
958 int AddElement(Element *elem);
959 /// The parameter @a elem should be allocated using the NewElement() method
960 /// @note Ownership of @a elem will pass to the Mesh object
961 int AddBdrElement(Element *elem);
962
963 int AddBdrSegment(int v1, int v2, int attr = 1);
964 int AddBdrSegment(const int *vi, int attr = 1);
965
966 int AddBdrTriangle(int v1, int v2, int v3, int attr = 1);
967 int AddBdrTriangle(const int *vi, int attr = 1);
968
969 int AddBdrQuad(int v1, int v2, int v3, int v4, int attr = 1);
970 int AddBdrQuad(const int *vi, int attr = 1);
971 void AddBdrQuadAsTriangles(const int *vi, int attr = 1);
972
973 int AddBdrPoint(int v, int attr = 1);
974
975 virtual void GenerateBoundaryElements();
976 /// Finalize the construction of a triangular Mesh.
977 void FinalizeTriMesh(int generate_edges = 0, int refine = 0,
978 bool fix_orientation = true);
979 /// Finalize the construction of a quadrilateral Mesh.
980 void FinalizeQuadMesh(int generate_edges = 0, int refine = 0,
981 bool fix_orientation = true);
982 /// Finalize the construction of a tetrahedral Mesh.
983 void FinalizeTetMesh(int generate_edges = 0, int refine = 0,
984 bool fix_orientation = true);
985 /// Finalize the construction of a wedge Mesh.
986 void FinalizeWedgeMesh(int generate_edges = 0, int refine = 0,
987 bool fix_orientation = true);
988 /// Finalize the construction of a hexahedral Mesh.
989 void FinalizeHexMesh(int generate_edges = 0, int refine = 0,
990 bool fix_orientation = true);
991 /// Finalize the construction of any type of Mesh.
992 /** This method calls FinalizeTopology() and Finalize(). */
993 void FinalizeMesh(int refine = 0, bool fix_orientation = true);
994
995 ///@}
996
997 /// @name Mesh consistency methods
998 /// @{
999
1000 /** @brief Finalize the construction of the secondary topology (connectivity)
1001 data of a Mesh. */
1002 /** This method does not require any actual coordinate data (either vertex
1003 coordinates for linear meshes or node coordinates for meshes with nodes)
1004 to be available. However, the data generated by this method is generally
1005 required by the FiniteElementSpace class.
1006
1007 After calling this method, setting the Mesh vertices or nodes, it may be
1008 appropriate to call the method Finalize(). */
1009 void FinalizeTopology(bool generate_bdr = true);
1010
1011 /// Finalize the construction of a general Mesh.
1012 /** This method will:
1013 - check and optionally fix the orientation of regular elements
1014 - check and fix the orientation of boundary elements
1015 - assume that #vertices are defined, if #Nodes == NULL
1016 - assume that #Nodes are defined, if #Nodes != NULL.
1017 @param[in] refine If true, prepare the Mesh for conforming refinement of
1018 triangular or tetrahedral meshes.
1019 @param[in] fix_orientation
1020 If true, fix the orientation of inverted mesh elements
1021 by permuting their vertices.
1022
1023 Before calling this method, call FinalizeTopology() and ensure that the
1024 Mesh vertices or nodes are set. */
1025 virtual void Finalize(bool refine = false, bool fix_orientation = false);
1026
1027 /// @brief Determine the sets of unique attribute values in domain and
1028 /// boundary elements.
1029 ///
1030 /// Separately scan the domain and boundary elements to generate unique,
1031 /// sorted sets of the element attribute values present in the mesh and
1032 /// store these in the Mesh::attributes and Mesh::bdr_attributes arrays.
1033 virtual void SetAttributes();
1034
1035 /// Check (and optionally attempt to fix) the orientation of the elements
1036 /** @param[in] fix_it If `true`, attempt to fix the orientations of some
1037 elements: triangles, quads, and tets.
1038 @return The number of elements with wrong orientation.
1039
1040 @note For meshes with nodes (e.g. high-order or periodic meshes), fixing
1041 the element orientations may require additional permutation of the nodal
1042 GridFunction of the mesh which is not performed by this method. Instead,
1043 the method Finalize() should be used with the parameter
1044 @a fix_orientation set to `true`.
1045
1046 @note This method performs a simple check if an element is inverted, e.g.
1047 for most elements types, it checks if the Jacobian of the mapping from
1048 the reference element is non-negative at the center of the element. */
1049 int CheckElementOrientation(bool fix_it = true);
1050
1051 /// Check the orientation of the boundary elements
1052 /** @return The number of boundary elements with wrong orientation. */
1053 int CheckBdrElementOrientation(bool fix_it = true);
1054
1055 /** This method modifies a tetrahedral mesh so that Nedelec spaces of order
1056 greater than 1 can be defined on the mesh. Specifically, we
1057 1) rotate all tets in the mesh so that the vertices {v0, v1, v2, v3}
1058 satisfy: v0 < v1 < min(v2, v3).
1059 2) rotate all boundary triangles so that the vertices {v0, v1, v2}
1060 satisfy: v0 < min(v1, v2).
1061
1062 @note Refinement does not work after a call to this method! */
1063 MFEM_DEPRECATED virtual void ReorientTetMesh();
1064
1065 /// Remove unused vertices and rebuild mesh connectivity.
1066 void RemoveUnusedVertices();
1067
1068 /** Remove boundary elements that lie in the interior of the mesh, i.e. that
1069 have two adjacent faces in 3D, or edges in 2D. */
1071
1072 /// @}
1073
1074 /// @name Element ordering methods
1075 /// @{
1076
1077 /** This is our integration with the Gecko library. The method finds an
1078 element ordering that will increase memory coherency by putting elements
1079 that are in physical proximity closer in memory. It can also be used to
1080 obtain a space-filling curve ordering for ParNCMesh partitioning.
1081 @param[out] ordering Output element ordering.
1082 @param iterations Total number of V cycles. The ordering may improve with
1083 more iterations. The best iteration is returned at the end.
1084 @param window Initial window size. This determines the number of
1085 permutations tested at each multigrid level and strongly influences the
1086 quality of the result, but the cost of increasing 'window' is exponential.
1087 @param period The window size is incremented every 'period' iterations.
1088 @param seed Seed for initial random ordering (0 = skip random reorder).
1089 @param verbose Print the progress of the optimization to mfem::out.
1090 @param time_limit Optional time limit for the optimization, in seconds.
1091 When reached, ordering from the best iteration so far is returned
1092 (0 = no limit).
1093 @return The final edge product cost of the ordering. The function may be
1094 called in an external loop with different seeds, and the best ordering can
1095 then be retained. */
1097 int iterations = 4, int window = 4,
1098 int period = 2, int seed = 0,
1099 bool verbose = false, real_t time_limit = 0);
1100
1101 /** Return an ordering of the elements that approximately follows the Hilbert
1102 curve. The method performs a spatial (Hilbert) sort on the centers of all
1103 elements and returns the resulting sequence, which can then be passed to
1104 ReorderElements. This is a cheap alternative to GetGeckoElementOrdering.*/
1105 void GetHilbertElementOrdering(Array<int> &ordering);
1106
1107 /** Rebuilds the mesh with a different order of elements. For each element i,
1108 the array ordering[i] contains its desired new index. Note that the method
1109 reorders vertices, edges and faces along with the elements. */
1110 void ReorderElements(const Array<int> &ordering, bool reorder_vertices = true);
1111
1112 /// @}
1113
1114 /// @anchor mfem_Mesh_deprecated_ctors @name Deprecated mesh constructors
1115 ///
1116 /// These constructors have been deprecated in favor of
1117 /// @ref mfem_Mesh_named_ctors "Named mesh constructors".
1118 /// @{
1119
1120 /// Deprecated: see @a MakeCartesian3D.
1121 MFEM_DEPRECATED
1122 Mesh(int nx, int ny, int nz, Element::Type type, bool generate_edges = false,
1123 real_t sx = 1.0, real_t sy = 1.0, real_t sz = 1.0,
1124 bool sfc_ordering = true)
1126 {
1127 Make3D(nx, ny, nz, type, sx, sy, sz, sfc_ordering);
1128 Finalize(true); // refine = true
1129 }
1130
1131 /// Deprecated: see @a MakeCartesian2D.
1132 MFEM_DEPRECATED
1133 Mesh(int nx, int ny, Element::Type type, bool generate_edges = false,
1134 real_t sx = 1.0, real_t sy = 1.0, bool sfc_ordering = true)
1136 {
1137 Make2D(nx, ny, type, sx, sy, generate_edges, sfc_ordering);
1138 Finalize(true); // refine = true
1139 }
1140
1141 /// Deprecated: see @a MakeCartesian1D.
1142 MFEM_DEPRECATED
1143 explicit Mesh(int n, real_t sx = 1.0)
1145 {
1146 Make1D(n, sx);
1147 // Finalize(); // reminder: not needed
1148 }
1149
1150 /// Deprecated: see @a MakeRefined.
1151 MFEM_DEPRECATED
1152 Mesh(Mesh *orig_mesh, int ref_factor, int ref_type);
1153
1154 /// @}
1155
1156 /// @name Information about the mesh as a whole
1157 /// @{
1158
1159 /// @brief Dimension of the reference space used within the elements
1160 int Dimension() const { return Dim; }
1161
1162 /// @brief Dimension of the physical space containing the mesh
1163 int SpaceDimension() const { return spaceDim; }
1164
1165 /// Equals 1 + num_holes - num_loops
1166 inline int EulerNumber() const
1168 /// Equals 1 - num_holes
1169 inline int EulerNumber2D() const
1170 { return NumOfVertices - NumOfEdges + NumOfElements; }
1171
1172 /** @brief Get the mesh generator/type.
1173
1174 The purpose of this is to be able to quickly tell what type of elements
1175 one has in the mesh. Examination of this bitmask along with knowledge
1176 of the mesh dimension can be used to identify which element types are
1177 present.
1178
1179 @return A bitmask:
1180 - bit 0 - simplices are present in the mesh (triangles, tets),
1181 - bit 1 - tensor product elements are present in the mesh (quads, hexes),
1182 - bit 2 - the mesh has wedge elements.
1183 - bit 3 - the mesh has pyramid elements.
1184
1185 In parallel, the result takes into account elements on all processors.
1186 */
1187 inline int MeshGenerator() const { return meshgen; }
1188
1189 /// Checks if the mesh has boundary elements
1190 virtual bool HasBoundaryElements() const { return (NumOfBdrElements > 0); }
1191
1192 /** @brief Return true iff the given @a geom is encountered in the mesh.
1193 Geometries of dimensions lower than Dimension() are counted as well. */
1195 { return mesh_geoms & (1 << geom); }
1196
1197 /** @brief Return the number of geometries of the given dimension present in
1198 the mesh. */
1199 /** For a parallel mesh only the local geometries are counted. */
1200 int GetNumGeometries(int dim) const;
1201
1202 /// Return all element geometries of the given dimension present in the mesh.
1203 /** For a parallel mesh only the local geometries are returned.
1204
1205 The returned geometries are sorted. */
1206 void GetGeometries(int dim, Array<Geometry::Type> &el_geoms) const;
1207
1208 /// Returns the minimum and maximum corners of the mesh bounding box.
1209 /** For high-order meshes, the geometry is first refined @a ref times. */
1210 void GetBoundingBox(Vector &min, Vector &max, int ref = 2);
1211
1212 void GetCharacteristics(real_t &h_min, real_t &h_max,
1213 real_t &kappa_min, real_t &kappa_max,
1214 Vector *Vh = NULL, Vector *Vk = NULL);
1215
1216 /// @}
1217
1218 /// @name Information concerning numbers of mesh entities
1219 /// @{
1220
1221 /** @brief Returns number of vertices. Vertices are only at the corners of
1222 elements, where you would expect them in the lowest-order mesh. */
1223 inline int GetNV() const { return NumOfVertices; }
1224
1225 /// Returns number of elements.
1226 inline int GetNE() const { return NumOfElements; }
1227
1228 /// Returns number of boundary elements.
1229 inline int GetNBE() const { return NumOfBdrElements; }
1230
1231 /// Return the number of edges.
1232 inline int GetNEdges() const { return NumOfEdges; }
1233
1234 /// Return the number of faces in a 3D mesh.
1235 inline int GetNFaces() const { return NumOfFaces; }
1236
1237 /// Return the number of faces (3D), edges (2D) or vertices (1D).
1238 int GetNumFaces() const;
1239
1240 /** @brief Return the number of faces (3D), edges (2D) or vertices (1D)
1241 including ghost faces. */
1242 int GetNumFacesWithGhost() const;
1243
1244 /** @brief Returns the number of faces according to the requested type, does
1245 not count master nonconforming faces.
1246
1247 If type==Boundary returns only the number of true boundary faces
1248 contrary to GetNBE() that returns all "boundary" elements which may
1249 include actual interior faces.
1250 Similarly, if type==Interior, only the true interior faces are counted
1251 excluding all master nonconforming faces. */
1252 virtual int GetNFbyType(FaceType type) const;
1253
1254 /// Return the total (global) number of elements.
1255 long long GetGlobalNE() const { return ReduceInt(NumOfElements); }
1256
1257 /// @}
1258
1259 /// @name Access to individual mesh entities
1260 /// @{
1261
1262 /// @brief Return pointer to vertex i's coordinates.
1263 /// @warning For high-order meshes (when #Nodes != NULL) vertices may not be
1264 /// updated and should not be used!
1265 const real_t *GetVertex(int i) const { return vertices[i](); }
1266
1267 /// @brief Return pointer to vertex i's coordinates.
1268 ///
1269 /// @warning For high-order meshes (when Nodes != NULL) vertices may not
1270 /// being updated and should not be used!
1271 ///
1272 /// @note The pointer returned by this function can be used to
1273 /// alter vertex locations but the pointer itself should not be
1274 /// changed by the caller.
1275 real_t *GetVertex(int i) { return vertices[i](); }
1276
1277 /// @brief Return pointer to the i'th element object
1278 ///
1279 /// The index @a i should be in the range [0, Mesh::GetNE())
1280 ///
1281 /// In parallel, @a i is the local element index which is in the
1282 /// same range mentioned above.
1283 const Element *GetElement(int i) const { return elements[i]; }
1284
1285 /// @brief Return pointer to the i'th element object
1286 ///
1287 /// @note Provides read/write access to the i'th element object so
1288 /// that element attributes or connectivity can be adjusted. However,
1289 /// the Element object itself should not be deleted by the caller.
1290 Element *GetElement(int i) { return elements[i]; }
1291
1292 /// @brief Return pointer to the i'th boundary element object
1293 ///
1294 /// The index @a i should be in the range [0, Mesh::GetNBE())
1295 ///
1296 /// In parallel, @a i is the local boundary element index which is
1297 /// in the same range mentioned above.
1298 const Element *GetBdrElement(int i) const { return boundary[i]; }
1299
1300 /// @brief Return pointer to the i'th boundary element object
1301 ///
1302 /// @note Provides read/write access to the i'th boundary element object so
1303 /// that boundary attributes or connectivity can be adjusted. However,
1304 /// the Element object itself should not be deleted by the caller.
1305 Element *GetBdrElement(int i) { return boundary[i]; }
1306
1307 /// @brief Return pointer to the i'th face element object
1308 ///
1309 /// The index @a i should be in the range [0, Mesh::GetNFaces())
1310 const Element *GetFace(int i) const { return faces[i]; }
1311
1312 /// @}
1313
1314 /// @name Access to groups of mesh entities
1315 /// @{
1316
1317 const Element* const *GetElementsArray() const
1318 { return elements.GetData(); }
1319
1320 void GetElementData(int geom, Array<int> &elem_vtx, Array<int> &attr) const
1321 { GetElementData(elements, geom, elem_vtx, attr); }
1322
1323 void GetBdrElementData(int geom, Array<int> &bdr_elem_vtx,
1324 Array<int> &bdr_attr) const
1325 { GetElementData(boundary, geom, bdr_elem_vtx, bdr_attr); }
1326
1327 /// @}
1328
1329 /// @name Access information concerning individual mesh entites
1330 /// @{
1331
1332 /// Return the attribute of element i.
1333 int GetAttribute(int i) const { return elements[i]->GetAttribute(); }
1334
1335 /// Set the attribute of element i.
1336 void SetAttribute(int i, int attr) { elements[i]->SetAttribute(attr); }
1337
1338 /// Return the attribute of boundary element i.
1339 int GetBdrAttribute(int i) const { return boundary[i]->GetAttribute(); }
1340
1341 /// Set the attribute of boundary element i.
1342 void SetBdrAttribute(int i, int attr) { boundary[i]->SetAttribute(attr); }
1343
1344 /// Return the attribute of patch i, for a NURBS mesh.
1345 int GetPatchAttribute(int i) const;
1346
1347 /// Set the attribute of patch i, for a NURBS mesh.
1348 void SetPatchAttribute(int i, int attr);
1349
1350 /// Return the attribute of patch boundary element i, for a NURBS mesh.
1351 int GetPatchBdrAttribute(int i) const;
1352
1353 /// Set the attribute of patch boundary element i, for a NURBS mesh.
1354 void SetPatchBdrAttribute(int i, int attr);
1355
1356 /// Returns the type of element i.
1357 Element::Type GetElementType(int i) const;
1358
1359 /// Returns the type of boundary element i.
1360 Element::Type GetBdrElementType(int i) const;
1361
1362 /// Deprecated in favor of Mesh::GetFaceGeometry
1363 MFEM_DEPRECATED Geometry::Type GetFaceGeometryType(int Face) const
1364 { return GetFaceGeometry(Face); }
1365
1366 Element::Type GetFaceElementType(int Face) const;
1367
1368 /// Return the Geometry::Type associated with face @a i.
1369 Geometry::Type GetFaceGeometry(int i) const;
1370
1372 {
1373 return elements[i]->GetGeometryType();
1374 }
1375
1377 {
1378 return boundary[i]->GetGeometryType();
1379 }
1380
1381 /// Deprecated in favor of Mesh::GetFaceGeometry
1382 MFEM_DEPRECATED Geometry::Type GetFaceBaseGeometry(int i) const
1383 { return GetFaceGeometry(i); }
1384
1387
1390
1391 /// Return true if the given face is interior. @sa FaceIsTrueInterior().
1392 bool FaceIsInterior(int FaceNo) const
1393 {
1394 return (faces_info[FaceNo].Elem2No >= 0);
1395 }
1396
1397 /** @brief Get the size of the i-th element relative to the perfect
1398 reference element. */
1399 real_t GetElementSize(int i, int type = 0);
1400
1401 real_t GetElementSize(int i, const Vector &dir);
1402
1403 real_t GetElementSize(ElementTransformation *T, int type = 0) const;
1404
1405 real_t GetElementVolume(int i);
1406
1407 void GetElementCenter(int i, Vector &center);
1408
1409 /** Compute the Jacobian of the transformation from the perfect
1410 reference element at the given integration point (defaults to the
1411 center of the element if no integration point is specified) */
1412 void GetElementJacobian(int i, DenseMatrix &J,
1413 const IntegrationPoint *ip = NULL);
1414
1415 /// @}
1416
1417 /// List of mesh geometries stored as Array<Geometry::Type>.
1418 class GeometryList : public Array<Geometry::Type>
1419 {
1420 protected:
1422 public:
1423 /// Construct a GeometryList of all element geometries in @a mesh.
1424 GeometryList(const Mesh &mesh)
1425 : Array<Geometry::Type>(geom_buf, Geometry::NumGeom)
1426 { mesh.GetGeometries(mesh.Dimension(), *this); }
1427 /** @brief Construct a GeometryList of all geometries of dimension @a dim
1428 in @a mesh. */
1429 GeometryList(const Mesh &mesh, int dim)
1430 : Array<Geometry::Type>(geom_buf, Geometry::NumGeom)
1431 { mesh.GetGeometries(dim, *this); }
1432 };
1433
1434 /// @name Access connectivity for individual mesh entites
1435 /// @{
1436
1437 /// Returns the indices of the vertices of element i.
1438 void GetElementVertices(int i, Array<int> &v) const
1439 { elements[i]->GetVertices(v); }
1440
1441 /// Returns the indices of the vertices of boundary element i.
1442 void GetBdrElementVertices(int i, Array<int> &v) const
1443 { boundary[i]->GetVertices(v); }
1444
1445 /// Return the indices and the orientations of all edges of element i.
1446 void GetElementEdges(int i, Array<int> &edges, Array<int> &cor) const;
1447
1448 /// Return the indices and the orientations of all edges of bdr element i.
1449 void GetBdrElementEdges(int i, Array<int> &edges, Array<int> &cor) const;
1450
1451 /** Return the indices and the orientations of all edges of face i.
1452 Works for both 2D (face=edge) and 3D faces. */
1453 void GetFaceEdges(int i, Array<int> &edges, Array<int> &o) const;
1454
1455 /// Returns the indices of the vertices of face i.
1456 void GetFaceVertices(int i, Array<int> &vert) const
1457 {
1458 if (Dim == 1)
1459 {
1460 vert.SetSize(1); vert[0] = i;
1461 }
1462 else
1463 {
1464 faces[i]->GetVertices(vert);
1465 }
1466 }
1467
1468 /// Returns the indices of the vertices of edge i.
1469 void GetEdgeVertices(int i, Array<int> &vert) const;
1470
1471 /// Return the indices and the orientations of all faces of element i.
1472 void GetElementFaces(int i, Array<int> &faces, Array<int> &ori) const;
1473
1474 /** @brief Returns the sorted, unique indices of elements sharing a face with
1475 element @a elem, including @a elem. */
1476 Array<int> FindFaceNeighbors(const int elem) const;
1477
1478 /** Return the index and the orientation of the vertex of bdr element i. (1D)
1479 Return the index and the orientation of the edge of bdr element i. (2D)
1480 Return the index and the orientation of the face of bdr element i. (3D)
1481
1482 In 2D, the returned edge orientation is 0 or 1, not +/-1 as returned by
1483 GetElementEdges/GetBdrElementEdges. */
1484 void GetBdrElementFace(int i, int *f, int *o) const;
1485
1486 /** @brief For the given boundary element, bdr_el, return its adjacent
1487 element and its info, i.e. 64*local_bdr_index+bdr_orientation.
1488
1489 The returned bdr_orientation is that of the boundary element relative to
1490 the respective face element.
1491
1492 @sa GetBdrElementAdjacentElement2() */
1493 void GetBdrElementAdjacentElement(int bdr_el, int &el, int &info) const;
1494
1495 /** @brief Deprecated.
1496
1497 For the given boundary element, bdr_el, return its adjacent element and
1498 its info, i.e. 64*local_bdr_index+inverse_bdr_orientation.
1499
1500 The returned inverse_bdr_orientation is the inverse of the orientation of
1501 the boundary element relative to the respective face element. In other
1502 words this is the orientation of the face element relative to the
1503 boundary element.
1504
1505 @warning This only differs from GetBdrElementAdjacentElement by returning
1506 the face info with inverted orientation. It does @b not return
1507 information corresponding to a second adjacent face. This function is
1508 deprecated, use Geometry::GetInverseOrientation, Mesh::EncodeFaceInfo,
1509 Mesh::DecodeFaceInfoOrientation, and Mesh::DecodeFaceInfoLocalIndex
1510 instead.
1511
1512 @sa GetBdrElementAdjacentElement() */
1513 MFEM_DEPRECATED
1514 void GetBdrElementAdjacentElement2(int bdr_el, int &el, int &info) const;
1515
1516 /// @brief Return the local face (codimension-1) index for the given boundary
1517 /// element index.
1518 int GetBdrElementFaceIndex(int be_idx) const { return be_to_face[be_idx]; }
1519
1520 /// Deprecated in favor of GetBdrElementFaceIndex().
1521 MFEM_DEPRECATED int GetBdrFace(int i) const { return GetBdrElementFaceIndex(i); }
1522
1523 /** Return the vertex index of boundary element i. (1D)
1524 Return the edge index of boundary element i. (2D)
1525 Return the face index of boundary element i. (3D)
1526
1527 Deprecated in favor of GetBdrElementFaceIndex(). */
1528 MFEM_DEPRECATED int GetBdrElementEdgeIndex(int i) const { return GetBdrElementFaceIndex(i); }
1529
1530 /// @}
1531
1532 /// @name Access connectivity data
1533 /// @{
1534
1535 /// @note The returned Table should be deleted by the caller
1537
1538 /// Return the "face"-element Table. Here "face" refers to face (3D),
1539 /// edge (2D), or vertex (1D).
1540 ///
1541 /// @note The returned Table should be deleted by the caller.
1543
1544 /// Returns the face-to-edge Table (3D)
1545 ///
1546 /// @note The returned object should NOT be deleted by the caller.
1547 Table *GetFaceEdgeTable() const;
1548
1549 /// Returns the edge-to-vertex Table (3D)
1550 ///
1551 /// @note The returned object should NOT be deleted by the caller.
1552 Table *GetEdgeVertexTable() const;
1553
1554 /** Return vertex to vertex table. The connections stored in the table
1555 are from smaller to bigger vertex index, i.e. if i<j and (i, j) is
1556 in the table, then (j, i) is not stored.
1557
1558 @note This data is not stored internally as a Table. The Table passed as
1559 an argument is populated using the EdgeVertex Table (see GetEdgeVertexTable)
1560 if available or the element connectivity.
1561 */
1562 void GetVertexToVertexTable(DSTable &) const;
1563
1565
1566 const Table &ElementToFaceTable() const;
1567
1568 const Table &ElementToEdgeTable() const;
1569
1571
1572 ///@}
1573
1574 /// @brief Return FiniteElement for reference element of the specified type
1575 ///
1576 /// @note The returned object is a pointer to a global object and should not
1577 /// be deleted by the caller.
1579
1580 /** @brief For the vertex (1D), edge (2D), or face (3D) of a boundary element
1581 with the orientation @a o, return the transformation of the boundary
1582 element integration point @ ip to the face element. In 2D, the
1583 the orientation is 0 or 1 as returned by GetBdrElementFace, not +/-1.
1584 Supports both internal and external boundaries. */
1586 const IntegrationPoint &ip);
1587
1588 /// @anchor mfem_Mesh_elem_trans
1589 /// @name Access the coordinate transformation for individual elements
1590 ///
1591 /// See also the methods related to
1592 /// @ref mfem_Mesh_geom_factors "Geometric Factors" for accessing
1593 /// information cached at quadrature points.
1594 /// @{
1595
1596 /// @brief Builds the transformation defining the i-th element in @a ElTr.
1597 /// @a ElTr must be allocated in advance and will be owned by the caller.
1598 ///
1599 /// @note The provided pointer must not be NULL. In the future this should be
1600 /// changed to a reference parameter consistent with
1601 /// GetFaceElementTransformations.
1602 void GetElementTransformation(int i,
1603 IsoparametricTransformation *ElTr) const;
1604
1605 /// @brief Returns a pointer to the transformation defining the i-th element.
1606 ///
1607 /// @note The returned object is owned by the class and is shared, i.e.,
1608 /// calling this function resets pointers obtained from previous calls.
1609 /// Also, this pointer should NOT be deleted by the caller.
1611
1612 /// @brief Builds the transformation defining the i-th element in @a ElTr
1613 /// assuming position of the vertices/nodes are given by @a nodes.
1614 /// @a ElTr must be allocated in advance and will be owned by the caller.
1615 ///
1616 /// @note The provided pointer must not be NULL. In the future this should be
1617 /// changed to a reference parameter consistent with
1618 /// GetFaceElementTransformations.
1619 void GetElementTransformation(int i, const Vector &nodes,
1620 IsoparametricTransformation *ElTr) const;
1621
1622 /// @brief Returns a pointer to the transformation defining the i-th boundary
1623 /// element.
1624 ///
1625 /// @note The returned object is owned by the class and is shared, i.e.,
1626 /// calling this function resets pointers obtained from previous calls.
1627 /// Also, the returned object should NOT be deleted by the caller.
1629
1630 /// @brief Builds the transformation defining the i-th boundary element in
1631 /// @a ElTr. @a ElTr must be allocated in advance and will be owned by the
1632 /// caller.
1633 ///
1634 /// @note The provided pointer must not be NULL. In the future this should be
1635 /// changed to a reference parameter consistent with
1636 /// GetFaceElementTransformations.
1637 void GetBdrElementTransformation(int i,
1638 IsoparametricTransformation *ElTr) const;
1639
1640 /// @brief Returns a pointer to the transformation defining the given face
1641 /// element.
1642 ///
1643 /// @note The returned object is owned by the class and is shared, i.e.,
1644 /// calling this function resets pointers obtained from previous calls. Also,
1645 /// the returned object should NOT be deleted by the caller.
1647
1648 /// @brief Builds the transformation defining the i-th face element in
1649 /// @a FTr. @a FTr must be allocated in advance and will be owned by the
1650 /// caller.
1651 ///
1652 /// @note The provided pointer must not be NULL. In the future this should be
1653 /// changed to a reference parameter consistent with
1654 /// GetFaceElementTransformations.
1655 void GetFaceTransformation(int i, IsoparametricTransformation *FTr) const;
1656
1657 /** @brief A helper method that constructs a transformation from the
1658 reference space of a face to the reference space of an element. */
1659 /** The local index of the face as a face in the element and its orientation
1660 are given by the input parameter @a info, as @a info = 64*loc_face_idx +
1661 loc_face_orientation. */
1662 void GetLocalFaceTransformation(int face_type, int elem_type,
1664 int info) const;
1665
1666 /// @brief Builds the transformation defining the i-th edge element in
1667 /// @a EdTr. @a EdTr must be allocated in advance and will be owned by the
1668 /// caller.
1669 ///
1670 /// @note The provided pointer must not be NULL. In the future this should be
1671 /// changed to a reference parameter consistent with
1672 /// GetFaceElementTransformations.
1673 void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr) const;
1674
1675 /// @brief Returns a pointer to the transformation defining the given edge
1676 /// element.
1677 ///
1678 /// @note The returned object is owned by the class and is shared, i.e.,
1679 /// calling this function resets pointers obtained from previous calls.
1680 /// Also, the returned object should NOT be deleted by the caller.
1682
1683 /// Returns (a pointer to an object containing) the following data:
1684 ///
1685 /// 1) Elem1No - the index of the first element that contains this face this
1686 /// is the element that has the same outward unit normal vector as the
1687 /// face;
1688 ///
1689 /// 2) Elem2No - the index of the second element that contains this face this
1690 /// element has outward unit normal vector as the face multiplied with -1;
1691 ///
1692 /// 3) Elem1, Elem2 - pointers to the ElementTransformation's of the first
1693 /// and the second element respectively;
1694 ///
1695 /// 4) Face - pointer to the ElementTransformation of the face;
1696 ///
1697 /// 5) Loc1, Loc2 - IntegrationPointTransformation's mapping the face
1698 /// coordinate system to the element coordinate system (both in their
1699 /// reference elements). Used to transform IntegrationPoints from face to
1700 /// element. More formally, let:
1701 /// TL1, TL2 be the transformations represented by Loc1, Loc2,
1702 /// TE1, TE2 - the transformations represented by Elem1, Elem2,
1703 /// TF - the transformation represented by Face, then
1704 /// TF(x) = TE1(TL1(x)) = TE2(TL2(x)) for all x in the reference face.
1705 ///
1706 /// 6) FaceGeom - the base geometry for the face.
1707 ///
1708 /// The mask specifies which fields in the structure to return:
1709 /// mask & 1 - Elem1, mask & 2 - Elem2
1710 /// mask & 4 - Loc1, mask & 8 - Loc2, mask & 16 - Face.
1711 /// These mask values are defined in the ConfigMasks enum type as part of the
1712 /// FaceElementTransformations class in fem/eltrans.hpp.
1713 ///
1714 /// @note The returned object is owned by the class and is shared, i.e.,
1715 /// calling this function resets pointers obtained from previous calls.
1716 /// Also, this pointer should NOT be deleted by the caller.
1718 GetFaceElementTransformations(int FaceNo, int mask = 31);
1719
1720 /// @brief Variant of GetFaceElementTransformations using a user allocated
1721 /// FaceElementTransformations object.
1722 virtual void GetFaceElementTransformations(int FaceNo,
1726 int mask = 31) const;
1727
1728 /// @brief See GetFaceElementTransformations().
1729 ///
1730 /// @note The returned object is owned by the class and is shared, i.e.,
1731 /// calling this function resets pointers obtained from previous calls.
1732 /// Also, this pointer should NOT be deleted by the caller.
1734
1735 /// @brief Variant of GetInteriorFaceTransformations using a user allocated
1736 /// FaceElementTransformations object.
1737 void GetInteriorFaceTransformations(int FaceNo,
1740 IsoparametricTransformation &ElTr2) const;
1741
1742 /// @brief Builds the transformation defining the given boundary face.
1743 ///
1744 /// @note The returned object is owned by the class and is shared, i.e.,
1745 /// calling this function resets pointers obtained from previous calls.
1746 /// Also, this pointer should NOT be deleted by the caller.
1748
1749 /// @brief Variant of GetBdrFaceTransformations using a user allocated
1750 /// FaceElementTransformations object.
1751 void GetBdrFaceTransformations(int BdrElemNo,
1754 IsoparametricTransformation &ElTr2) const;
1755
1756 /// @}
1757
1758 /// @anchor mfem_Mesh_geom_factors
1759 /// @name Access the coordinate transformation at quadrature points
1760 ///
1761 /// See also methods related to
1762 /// @ref mfem_Mesh_elem_trans "Element-wise coordinate transformation".
1763 /// @{
1764
1765 /** @brief Return the mesh geometric factors corresponding to the given
1766 integration rule.
1767
1768 The IntegrationRule used with GetGeometricFactors needs to remain valid
1769 until the internally stored GeometricFactors objects are destroyed (by
1770 calling Mesh::DeleteGeometricFactors(), Mesh::NodesUpdated(), or the Mesh
1771 destructor).
1772
1773 If the device MemoryType parameter @a d_mt is specified, then the
1774 returned object will use that type unless it was previously allocated
1775 with a different type.
1776
1777 The returned pointer points to an internal object that may be invalidated
1778 by mesh operations such as refinement, vertex/node movement, etc. Since
1779 not all such modifications can be tracked by the Mesh class (e.g. when
1780 using the pointer returned by GetNodes() to change the nodes) one needs
1781 to account for such changes by calling the method NodesUpdated() which,
1782 in particular, will call DeleteGeometricFactors(). */
1784 const IntegrationRule& ir,
1785 const int flags,
1787
1788 /** @brief Return the mesh geometric factors for the faces corresponding
1789 to the given integration rule.
1790
1791 The IntegrationRule used with GetFaceGeometricFactors needs to remain
1792 valid until the internally stored FaceGeometricFactors objects are
1793 destroyed (by either calling Mesh::DeleteGeometricFactors(),
1794 Mesh::NodesUpdated(), or the Mesh destructor).
1795
1796 If the device MemoryType parameter @a d_mt is specified, then the
1797 returned object will use that type unless it was previously allocated
1798 with a different type.
1799
1800 The returned pointer points to an internal object that may be invalidated
1801 by mesh operations such as refinement, vertex/node movement, etc. Since
1802 not all such modifications can be tracked by the Mesh class (e.g. when
1803 using the pointer returned by GetNodes() to change the nodes) one needs
1804 to account for such changes by calling the method NodesUpdated() which,
1805 in particular, will call DeleteGeometricFactors(). */
1807 const IntegrationRule& ir,
1808 const int flags,
1809 FaceType type,
1811
1812 /// Destroy all GeometricFactors stored by the Mesh.
1813 /** This method can be used to force recomputation of the GeometricFactors,
1814 for example, after the mesh nodes are modified externally.
1815
1816 @note In general, the preferred method for resetting the GeometricFactors
1817 should be to call NodesUpdated(). */
1819
1820 /// @}
1821
1822 /** This enumerated type describes the three main face topologies:
1823 - Boundary, for faces on the boundary of the computational domain,
1824 - Conforming, for conforming faces interior to the computational domain,
1825 - Nonconforming, for nonconforming faces interior to the computational
1826 domain. */
1828 Conforming,
1830 NA
1831 };
1832
1833 /** This enumerated type describes the location of the two elements sharing a
1834 face, Local meaning that the element is local to the MPI rank, FaceNbr
1835 meaning that the element is distributed on a different MPI rank, this
1836 typically means that methods with FaceNbr should be used to access the
1837 relevant information, e.g., ParFiniteElementSpace::GetFaceNbrElementVDofs.
1838 */
1840
1841 /** This enumerated type describes the topological relation of an element to
1842 a face:
1843 - Coincident meaning that the element's face is topologically equal to
1844 the mesh face.
1845 - Superset meaning that the element's face is topologically coarser than
1846 the mesh face, i.e., the element's face contains the mesh face.
1847 - Subset meaning that the element's face is topologically finer than the
1848 mesh face, i.e., the element's face is contained in the mesh face.
1849 Superset and Subset are only relevant for nonconforming faces.
1850 Master nonconforming faces have a conforming element on one side, and a
1851 fine element on the other side. Slave nonconforming faces have a
1852 conforming element on one side, and a coarse element on the other side.
1853 */
1855
1856 /** This enumerated type describes the corresponding FaceInfo internal
1857 representation (encoded cases), c.f. FaceInfo's documentation:
1858 Classification of a local (non-ghost) face based on its FaceInfo:
1859 - Elem2No >= 0 --> local interior face; can be either:
1860 - NCFace == -1 --> LocalConforming,
1861 - NCFace >= 0 --> LocalSlaveNonconforming,
1862 - Elem2No < 0 --> local "boundary" face; can be one of:
1863 - NCFace == -1 --> conforming face; can be either:
1864 - Elem2Inf < 0 --> Boundary,
1865 - Elem2Inf >= 0 --> SharedConforming,
1866 - NCFace >= 0 --> nonconforming face; can be one of:
1867 - Elem2Inf < 0 --> MasterNonconforming (shared or not shared),
1868 - Elem2Inf >= 0 --> SharedSlaveNonconforming.
1869 Classification of a ghost (non-local) face based on its FaceInfo:
1870 - Elem1No == -1 --> GhostMaster (includes other unused ghost faces),
1871 - Elem1No >= 0 --> GhostSlave.
1872 */
1882
1883 /** @brief This structure is used as a human readable output format that
1884 deciphers the information contained in Mesh::FaceInfo when using the
1885 Mesh::GetFaceInformation() method.
1886
1887 The element indices in this structure don't need further processing,
1888 contrary to the ones obtained through Mesh::GetFacesElements and can
1889 directly be used, e.g., Elem1 and Elem2 indices.
1890 Likewise the orientations for Elem1 and Elem2 already take into account
1891 special cases and can be used as is.
1892 */
1894 {
1896
1897 struct
1898 {
1905
1909
1910 /** @brief Return true if the face is a local interior face which is NOT
1911 a master nonconforming face. */
1912 bool IsLocal() const
1913 {
1914 return element[1].location == Mesh::ElementLocation::Local;
1915 }
1916
1917 /** @brief Return true if the face is a shared interior face which is NOT
1918 a master nonconforming face. */
1919 bool IsShared() const
1920 {
1921 return element[1].location == Mesh::ElementLocation::FaceNbr;
1922 }
1923
1924 /** @brief return true if the face is an interior face to the computation
1925 domain, either a local or shared interior face (not a boundary face)
1926 which is NOT a master nonconforming face.
1927 */
1928 bool IsInterior() const
1929 {
1932 }
1933
1934 /** @brief Return true if the face is a boundary face. */
1935 bool IsBoundary() const
1936 {
1938 }
1939
1940 /// @brief Return true if the face is of the same type as @a type.
1941 bool IsOfFaceType(FaceType type) const
1942 {
1943 switch (type)
1944 {
1945 case FaceType::Interior:
1946 return IsInterior();
1947 case FaceType::Boundary:
1948 return IsBoundary();
1949 default:
1950 return false;
1951 }
1952 }
1953
1954 /// @brief Return true if the face is a conforming face.
1955 bool IsConforming() const
1956 {
1958 }
1959
1960 /// @brief Return true if the face is a nonconforming fine face.
1962 {
1964 (element[0].conformity == ElementConformity::Superset ||
1965 element[1].conformity == ElementConformity::Superset);
1966 }
1967
1968 /// @brief Return true if the face is a nonconforming coarse face.
1969 /** Note that ghost nonconforming master faces cannot be clearly
1970 identified as such with the currently available information, so this
1971 method will return false for such faces. */
1973 {
1975 element[1].conformity == ElementConformity::Subset;
1976 }
1977
1978 /// @brief cast operator from FaceInformation to FaceInfo.
1979 operator Mesh::FaceInfo() const;
1980 };
1981
1982 /// Given a "face info int", return the face orientation. @sa FaceInfo.
1983 static int DecodeFaceInfoOrientation(int info) { return info%64; }
1984
1985 /// Given a "face info int", return the local face index. @sa FaceInfo.
1986 static int DecodeFaceInfoLocalIndex(int info) { return info/64; }
1987
1988 /// @brief Given @a local_face_index and @a orientation, return the
1989 /// corresponding encoded "face info int". @sa FaceInfo.
1990 static int EncodeFaceInfo(int local_face_index, int orientation)
1991 { return orientation + local_face_index*64; }
1992
1993 /// @name More advanced entity information access methods
1994 /// @{
1995
1996 /* Return point matrix of element i of dimension Dim X #v, where for every
1997 vertex we give its coordinates in space of dimension Dim. */
1998 void GetPointMatrix(int i, DenseMatrix &pointmat) const;
1999
2000 /* Return point matrix of boundary element i of dimension Dim X #v, where for
2001 every vertex we give its coordinates in space of dimension Dim. */
2002 void GetBdrPointMatrix(int i, DenseMatrix &pointmat) const;
2003
2004 /** This method aims to provide face information in a deciphered format, i.e.
2005 Mesh::FaceInformation, compared to the raw encoded information returned
2006 by Mesh::GetFaceElements() and Mesh::GetFaceInfos(). */
2007 FaceInformation GetFaceInformation(int f) const;
2008
2009 void GetFaceElements (int Face, int *Elem1, int *Elem2) const;
2010 void GetFaceInfos (int Face, int *Inf1, int *Inf2) const;
2011 void GetFaceInfos (int Face, int *Inf1, int *Inf2, int *NCFace) const;
2012
2013 /// @}
2014
2015 /// @name Methods related to mesh partitioning
2016 /// @{
2017
2018 /// @note The returned array should be deleted by the caller.
2019 int *CartesianPartitioning(int nxyz[]);
2020 /// @note The returned array should be deleted by the caller.
2021 int *GeneratePartitioning(int nparts, int part_method = 1);
2022 /// @todo This method needs a proper description
2023 void CheckPartitioning(int *partitioning_);
2024
2025 /// @}
2026
2027 /// @anchor mfem_Mesh_trans
2028 /// @name Methods related to accessing/altering mesh coordinates
2029 ///
2030 /// See also @ref mfem_Mesh_gf_nodes "Coordinates as a GridFunction".
2031 /// @{
2032
2033 // Vertices are only at the corners of elements, where you would expect them
2034 // in the lowest-order mesh.
2035 void MoveVertices(const Vector &displacements);
2036 void GetVertices(Vector &vert_coord) const;
2037 void SetVertices(const Vector &vert_coord);
2038
2039 /** @brief Set the internal Vertex array to point to the given @a vertices
2040 array without assuming ownership of the pointer. */
2041 /** If @a zerocopy is `true`, the vertices must be given as an array of 3
2042 doubles per vertex. If @a zerocopy is `false` then the current Vertex
2043 data is first copied to the @a vertices array. */
2044 void ChangeVertexDataOwnership(real_t *vertices, int len_vertices,
2045 bool zerocopy = false);
2046
2047 // Nodes are only active for higher order meshes, and share locations with
2048 // the vertices, plus all the higher- order control points within the element
2049 // and along the edges and on the faces.
2050 void GetNode(int i, real_t *coord) const;
2051 void SetNode(int i, const real_t *coord);
2052
2053 // Node operations for curved mesh.
2054 // They call the corresponding '...Vertices' method if the
2055 // mesh is not curved (i.e. Nodes == NULL).
2056 void MoveNodes(const Vector &displacements);
2057 void GetNodes(Vector &node_coord) const;
2058 /// Updates the vertex/node locations. Invokes NodesUpdated().
2059 void SetNodes(const Vector &node_coord);
2060
2061 void ScaleSubdomains (real_t sf);
2062 void ScaleElements (real_t sf);
2063
2064 void Transform(void (*f)(const Vector&, Vector&));
2065 void Transform(VectorCoefficient &deformation);
2066
2067 /** @brief This function should be called after the mesh node coordinates
2068 have been updated externally, e.g. by modifying the internal nodal
2069 GridFunction returned by GetNodes(). */
2070 /** It deletes internal quantities derived from the node coordinates,
2071 such as the (Face)GeometricFactors.
2072
2073 @note Unlike the similarly named protected method UpdateNodes() this
2074 method does not modify the nodes. */
2076
2077 /// @}
2078
2079 /// @anchor mfem_Mesh_gf_nodes
2080 /// @name Methods related to nodal coordinates stored as a GridFunction
2081 ///
2082 /// See also @ref mfem_Mesh_trans "Mesh Transformations".
2083 /// @{
2084
2085 /// @brief Return a pointer to the internal node GridFunction (may be NULL).
2086 ///
2087 /// If the mesh is straight-sided (low-order), it may not have a GridFunction
2088 /// for the nodes, in which case this function returns NULL. To ensure that
2089 /// the nodal GridFunction exists, first call EnsureNodes().
2090 /// @sa SetCurvature().
2091 ///
2092 /// @note The returned object should NOT be deleted by the caller.
2094 const GridFunction *GetNodes() const { return Nodes; }
2095 /// Return the mesh nodes ownership flag.
2096 bool OwnsNodes() const { return own_nodes; }
2097 /// Set the mesh nodes ownership flag.
2098 void SetNodesOwner(bool nodes_owner) { own_nodes = nodes_owner; }
2099 /// Replace the internal node GridFunction with the given GridFunction.
2100 /** Invokes NodesUpdated(). */
2101 void NewNodes(GridFunction &nodes, bool make_owner = false);
2102 /** @brief Swap the internal node GridFunction pointer and ownership flag
2103 members with the given ones. */
2104 /** Invokes NodesUpdated(). */
2105 void SwapNodes(GridFunction *&nodes, int &own_nodes_);
2106
2107 /// Return the mesh nodes/vertices projected on the given GridFunction.
2108 void GetNodes(GridFunction &nodes) const;
2109 /** Replace the internal node GridFunction with a new GridFunction defined
2110 on the given FiniteElementSpace. The new node coordinates are projected
2111 (derived) from the current nodes/vertices. */
2112 virtual void SetNodalFESpace(FiniteElementSpace *nfes);
2113 /** Replace the internal node GridFunction with the given GridFunction. The
2114 given GridFunction is updated with node coordinates projected (derived)
2115 from the current nodes/vertices. */
2116 void SetNodalGridFunction(GridFunction *nodes, bool make_owner = false);
2117 /** Return the FiniteElementSpace on which the current mesh nodes are
2118 defined or NULL if the mesh does not have nodes. */
2119 const FiniteElementSpace *GetNodalFESpace() const;
2120 /** @brief Make sure that the mesh has valid nodes, i.e. its geometry is
2121 described by a vector finite element grid function (even if it is a
2122 low-order mesh with straight edges).
2123
2124 @sa GetNodes(). */
2125 void EnsureNodes();
2126
2127 /// Set the curvature of the mesh nodes using the given polynomial degree.
2128 /** Creates a nodal GridFunction if one doesn't already exist.
2129
2130 @param[in] order Polynomial degree of the nodal FE space. If this
2131 value is <= 0 then the method will remove the
2132 nodal GridFunction and the Mesh will use the
2133 vertices array instead; the other arguments are
2134 ignored in this case.
2135 @param[in] discont Whether to use a discontinuous or continuous
2136 finite element space (continuous is default).
2137 @param[in] space_dim The space dimension (optional).
2138 @param[in] ordering The Ordering of the finite element space
2139 (Ordering::byVDIM is the default). */
2140 virtual void SetCurvature(int order, bool discont = false, int space_dim = -1,
2141 int ordering = 1);
2142
2143 /// @}
2144
2145 /// @name Methods related to mesh refinement
2146 /// @{
2147
2148 /// Refine all mesh elements.
2149 /** @param[in] ref_algo %Refinement algorithm. Currently used only for pure
2150 tetrahedral meshes. If set to zero (default), a tet mesh will be refined
2151 using algorithm A, that produces elements with better quality compared to
2152 algorithm B used when the parameter is non-zero.
2153
2154 For tetrahedral meshes, after using algorithm A, the mesh cannot be
2155 refined locally using methods like GeneralRefinement() unless it is
2156 re-finalized using Finalize() with the parameter @a refine set to true.
2157 Note that calling Finalize() in this way will generally invalidate any
2158 FiniteElementSpace%s and GridFunction%s defined on the mesh. */
2159 void UniformRefinement(int ref_algo = 0);
2160
2161 /** @brief Refine NURBS mesh, with an optional refinement factor, generally
2162 anisotropic.
2163
2164 @param[in] rf Optional refinement factor. If scalar, the factor is used
2165 for all dimensions. If an array, factors can be specified
2166 for each dimension. The factor multiplies the number of
2167 elements in each dimension. Some factors can be 1.
2168 @param[in] tol NURBS geometry deviation tolerance, cf. Algorithm A5.8 of
2169 "The NURBS Book", 2nd ed, Piegl and Tiller. */
2170 virtual void NURBSUniformRefinement(int rf = 2, real_t tol = 1.0e-12);
2171 virtual void NURBSUniformRefinement(const Array<int> &rf, real_t tol=1.e-12);
2172
2173 /// Coarsening for a NURBS mesh, with an optional coarsening factor @a cf > 1
2174 /// which divides the number of elements in each dimension.
2175 void NURBSCoarsening(int cf = 2, real_t tol = 1.0e-12);
2176
2177 /** Refine selected mesh elements. Refinement type can be specified for each
2178 element. The function can do conforming refinement of triangles and
2179 tetrahedra and nonconforming refinement (i.e., with hanging-nodes) of
2180 triangles, quadrilaterals and hexahedra. If 'nonconforming' = -1,
2181 suitable refinement method is selected automatically (namely, conforming
2182 refinement for triangles). Use nonconforming = 0/1 to force the method.
2183 For nonconforming refinements, nc_limit optionally specifies the maximum
2184 level of hanging nodes (unlimited by default). */
2185 void GeneralRefinement(const Array<Refinement> &refinements,
2186 int nonconforming = -1, int nc_limit = 0);
2187
2188 /** Simplified version of GeneralRefinement taking a simple list of elements
2189 to refine, without refinement types. */
2190 void GeneralRefinement(const Array<int> &el_to_refine,
2191 int nonconforming = -1, int nc_limit = 0);
2192
2193 /// Refine each element with given probability. Uses GeneralRefinement.
2194 void RandomRefinement(real_t prob, bool aniso = false,
2195 int nonconforming = -1, int nc_limit = 0);
2196
2197 /// Refine elements sharing the specified vertex. Uses GeneralRefinement.
2198 void RefineAtVertex(const Vertex& vert,
2199 real_t eps = 0.0, int nonconforming = -1);
2200
2201 /** Refine element i if elem_error[i] > threshold, for all i.
2202 Returns true if at least one element was refined, false otherwise. */
2203 bool RefineByError(const Array<real_t> &elem_error, real_t threshold,
2204 int nonconforming = -1, int nc_limit = 0);
2205
2206 /** Refine element i if elem_error(i) > threshold, for all i.
2207 Returns true if at least one element was refined, false otherwise. */
2208 bool RefineByError(const Vector &elem_error, real_t threshold,
2209 int nonconforming = -1, int nc_limit = 0);
2210
2211 /** Derefine the mesh based on an error measure associated with each
2212 element. A derefinement is performed if the sum of errors of its fine
2213 elements is smaller than 'threshold'. If 'nc_limit' > 0, derefinements
2214 that would increase the maximum level of hanging nodes of the mesh are
2215 skipped. Returns true if the mesh changed, false otherwise. */
2216 bool DerefineByError(Array<real_t> &elem_error, real_t threshold,
2217 int nc_limit = 0, int op = 1);
2218
2219 /// Same as DerefineByError for an error vector.
2220 bool DerefineByError(const Vector &elem_error, real_t threshold,
2221 int nc_limit = 0, int op = 1);
2222
2223 /** Make sure that a quad/hex mesh is considered to be nonconforming (i.e.,
2224 has an associated NCMesh object). Simplex meshes can be both conforming
2225 (default) or nonconforming. */
2226 void EnsureNCMesh(bool simplices_nonconforming = false);
2227
2228 bool Conforming() const { return ncmesh == NULL; }
2229 bool Nonconforming() const { return ncmesh != NULL; }
2230
2231 /** Return fine element transformations following a mesh refinement.
2232 Space uses this to construct a global interpolation matrix. */
2234
2235 /// Return type of last modification of the mesh.
2237
2238 /** Return update counter. The counter starts at zero and is incremented
2239 each time refinement, derefinement, or rebalancing method is called.
2240 It is used for checking proper sequence of Space:: and GridFunction::
2241 Update() calls. */
2242 long GetSequence() const { return sequence; }
2243
2244 /// @brief Return the nodes update counter.
2245 ///
2246 /// This counter starts at zero, and is incremented every time the geometric
2247 /// factors must be recomputed (e.g. on calls to Mesh::Transform,
2248 /// Mesh::NodesUpdated, etc.)
2249 long GetNodesSequence() const { return nodes_sequence; }
2250
2251 /// @}
2252
2253 ///@{ @name NURBS mesh refinement methods
2254 /** Refine a NURBS mesh with the knots specified in the file named @a ref_file.
2255 The file has the number of knot vectors on the first line. It is the same
2256 number of knot vectors specified in the NURBS mesh in the section edges. Then
2257 for each knot vector specified in the section edges (with the same ordering),
2258 a line describes (in this order): 1) an integer giving the number of knots
2259 inserted, 2) the knots inserted as a double. The advantage of this method
2260 is that it is possible to specifically refine a coarse NURBS mesh without
2261 changing the mesh file itself. Examples in miniapps/nurbs/meshes. */
2262 void RefineNURBSFromFile(std::string ref_file);
2263
2264 /// For NURBS meshes, insert the new knots in @a kv, for each direction.
2266
2267 /// For NURBS meshes, insert the knots in @a kv, for each direction.
2268 void KnotInsert(Array<Vector*> &kv);
2269
2270 /// For NURBS meshes, remove the knots in @a kv, for each direction.
2271 void KnotRemove(Array<Vector*> &kv);
2272
2273 /* For each knot vector:
2274 new_degree = max(old_degree, min(old_degree + rel_degree, degree)). */
2275 void DegreeElevate(int rel_degree, int degree = 16);
2276 ///@}
2277
2278 /// @name Print/Save/Export methods
2279 /// @{
2280
2281 /// Print the mesh to the given stream using Netgen/Truegrid format.
2282 virtual void PrintXG(std::ostream &os = mfem::out) const;
2283
2284 /// Print the mesh to the given stream using the default MFEM mesh format.
2285 /// \see mfem::ofgzstream() for on-the-fly compression of ascii outputs. If
2286 /// @a comments is non-empty, it will be printed after the first line of the
2287 /// file, and each line should begin with '#'.
2288 virtual void Print(std::ostream &os = mfem::out,
2289 const std::string &comments = "") const
2290 { Printer(os, "", comments); }
2291
2292 /// Save the mesh to a file using Mesh::Print. The given @a precision will be
2293 /// used for ASCII output.
2294 virtual void Save(const std::string &fname, int precision=16) const;
2295
2296 /// Print the mesh to the given stream using the adios2 bp format
2297#ifdef MFEM_USE_ADIOS2
2298 virtual void Print(adios2stream &os) const;
2299#endif
2300 /// Print the mesh in VTK format (linear and quadratic meshes only).
2301 /// \see mfem::ofgzstream() for on-the-fly compression of ascii outputs
2302 void PrintVTK(std::ostream &os);
2303 /** Print the mesh in VTK format. The parameter ref > 0 specifies an element
2304 subdivision number (useful for high order fields and curved meshes).
2305 If the optional field_data is set, we also add a FIELD section in the
2306 beginning of the file with additional dataset information. */
2307 /// \see mfem::ofgzstream() for on-the-fly compression of ascii outputs
2308 void PrintVTK(std::ostream &os, int ref, int field_data=0);
2309 /** Print the mesh in VTU format. The parameter ref > 0 specifies an element
2310 subdivision number (useful for high order fields and curved meshes).
2311 If @a bdr_elements is true, then output (only) the boundary elements,
2312 otherwise output only the non-boundary elements. */
2313 void PrintVTU(std::ostream &os,
2314 int ref=1,
2316 bool high_order_output=false,
2317 int compression_level=0,
2318 bool bdr_elements=false);
2319 /** Print the mesh in VTU format with file name fname. */
2320 virtual void PrintVTU(std::string fname,
2322 bool high_order_output=false,
2323 int compression_level=0,
2324 bool bdr=false);
2325 /** Print the boundary elements of the mesh in VTU format, and output the
2326 boundary attributes as a data array (useful for boundary conditions). */
2327 void PrintBdrVTU(std::string fname,
2329 bool high_order_output=false,
2330 int compression_level=0);
2331
2332 /** @brief Prints the mesh with boundary elements given by the boundary of
2333 the subdomains, so that the boundary of subdomain i has boundary
2334 attribute i+1. */
2335 /// \see mfem::ofgzstream() for on-the-fly compression of ascii outputs
2336 void PrintWithPartitioning (int *partitioning,
2337 std::ostream &os, int elem_attr = 0) const;
2338
2339 void PrintElementsWithPartitioning (int *partitioning,
2340 std::ostream &os,
2341 int interior_faces = 0);
2342
2343 /// Print set of disjoint surfaces:
2344 /*!
2345 * If Aface_face(i,j) != 0, print face j as a boundary
2346 * element with attribute i+1.
2347 */
2348 void PrintSurfaces(const Table &Aface_face, std::ostream &os) const;
2349
2350 /// Auxiliary method used by PrintCharacteristics().
2351 /** It is also used in the `mesh-explorer` miniapp. */
2352 static void PrintElementsByGeometry(int dim,
2353 const Array<int> &num_elems_by_geom,
2354 std::ostream &os);
2355
2356 /** @brief Compute and print mesh characteristics such as number of vertices,
2357 number of elements, number of boundary elements, minimal and maximal
2358 element sizes, minimal and maximal element aspect ratios, etc. */
2359 /** If @a Vh or @a Vk are not NULL, return the element sizes and aspect
2360 ratios for all elements in the given Vector%s. */
2361 void PrintCharacteristics(Vector *Vh = NULL, Vector *Vk = NULL,
2362 std::ostream &os = mfem::out);
2363
2364 /** @brief In serial, this method calls PrintCharacteristics(). In parallel,
2365 additional information about the parallel decomposition is also printed.
2366 */
2367 virtual void PrintInfo(std::ostream &os = mfem::out)
2368 {
2369 PrintCharacteristics(NULL, NULL, os);
2370 }
2371
2372#ifdef MFEM_DEBUG
2373 /// Output an NCMesh-compatible debug dump.
2374 void DebugDump(std::ostream &os) const;
2375#endif
2376
2377 /// @}
2378
2379 /// @name Miscellaneous or undocumented methods
2380 /// @{
2381
2382 /// @brief Creates a mapping @a v2v from the vertex indices of the mesh such
2383 /// that coincident vertices under the given @a translations are identified.
2384 /** Each Vector in @a translations should be of size @a sdim (the spatial
2385 dimension of the mesh). Two vertices are considered coincident if the
2386 translated coordinates of one vertex are within the given tolerance (@a
2387 tol, relative to the mesh diameter) of the coordinates of the other
2388 vertex.
2389 @warning This algorithm does not scale well with the number of boundary
2390 vertices in the mesh, and may run slowly on very large meshes. */
2391 std::vector<int> CreatePeriodicVertexMapping(
2392 const std::vector<Vector> &translations, real_t tol = 1e-8) const;
2393
2394 /** @brief Find the ids of the elements that contain the given points, and
2395 their corresponding reference coordinates.
2396
2397 The DenseMatrix @a point_mat describes the given points - one point for
2398 each column; it should have SpaceDimension() rows.
2399
2400 The InverseElementTransformation object, @a inv_trans, is used to attempt
2401 the element transformation inversion. If NULL pointer is given, the
2402 method will use a default constructed InverseElementTransformation. Note
2403 that the algorithms in the base class InverseElementTransformation can be
2404 completely overwritten by deriving custom classes that override the
2405 Transform() method.
2406
2407 If no element is found for the i-th point, elem_ids[i] is set to -1.
2408
2409 In the ParMesh implementation, the @a point_mat is expected to be the
2410 same on all ranks. If the i-th point is found by multiple ranks, only one
2411 of them will mark that point as found, i.e. set its elem_ids[i] to a
2412 non-negative number; the other ranks will set their elem_ids[i] to -2 to
2413 indicate that the point was found but assigned to another rank.
2414
2415 @returns The total number of points that were found.
2416
2417 @note This method is not 100 percent reliable, i.e. it is not guaranteed
2418 to find a point, even if it lies inside a mesh element. */
2419 virtual int FindPoints(DenseMatrix& point_mat, Array<int>& elem_ids,
2420 Array<IntegrationPoint>& ips, bool warn = true,
2421 InverseElementTransformation *inv_trans = NULL);
2422
2423 /** @brief Computes geometric parameters associated with a Jacobian matrix
2424 in 2D/3D. These parameters are
2425 (1) Area/Volume,
2426 (2) Aspect-ratio (1 in 2D, and 2 non-dimensional and 2 dimensional
2427 parameters in 3D. Dimensional parameters are used
2428 for target construction in TMOP),
2429 (3) skewness (1 in 2D and 3 in 3D), and finally
2430 (4) orientation (1 in 2D and 3 in 3D).
2431 */
2433 real_t &volume,
2434 Vector &aspr,
2435 Vector &skew,
2436 Vector &ori) const;
2437
2438 /// Utility function: sum integers from all processors (Allreduce).
2439 virtual long long ReduceInt(int value) const { return value; }
2440
2441 /// @todo This method needs a proper description
2442 void GetElementColoring(Array<int> &colors, int el0 = 0);
2443
2444 /// @todo This method needs a proper description
2445 void MesquiteSmooth(const int mesquite_option = 0);
2446
2447 /// @todo This method needs a proper description
2448 void CheckDisplacements(const Vector &displacements, real_t &tmax);
2449
2450 /// @}
2451};
2452
2453/** Overload operator<< for std::ostream and Mesh; valid also for the derived
2454 class ParMesh */
2455std::ostream &operator<<(std::ostream &os, const Mesh &mesh);
2456
2457/// @brief Print function for Mesh::FaceInformation.
2458std::ostream& operator<<(std::ostream &os, const Mesh::FaceInformation& info);
2459
2460
2461/** @brief Class containing a minimal description of a part (a subset of the
2462 elements) of a Mesh and its connectivity to other parts.
2463
2464 The main purpose of this class is to facilitate the partitioning of serial
2465 meshes (in serial, i.e. on one processor) and save the parts in parallel
2466 MFEM mesh format.
2467
2468 Another potential futrure purpose of this class could be to facilitate
2469 exchange of MeshParts between MPI ranks for repartitioning purposes. It can
2470 also potentially be used to implement parallel mesh I/O functions with
2471 partitionings that have number of parts different from the number of MPI
2472 tasks.
2473
2474 @note Parts of NURBS or non-conforming meshes cannot be fully described by
2475 this class alone with its current data members. Such extensions may be added
2476 in the future.
2477*/
2479{
2480protected:
2481 struct Entity { int geom; int num_verts; const int *verts; };
2483 {
2488
2489 EntityHelper(int dim_,
2490 const Array<int> (&entity_to_vertex_)[Geometry::NumGeom]);
2491 Entity FindEntity(int bytype_entity_id);
2492 };
2493
2494public:
2495 /// Reference space dimension of the elements
2497
2498 /// Dimension of the physical space into which the MeshPart is embedded.
2500
2501 /// Number of vertices
2503
2504 /// Number of elements with reference space dimension equal to 'dimension'.
2506
2507 /** @brief Number of boundary elements with reference space dimension equal
2508 to 'dimension'-1. */
2510
2511 /**
2512 Each 'entity_to_vertex[geom]' describes the entities of Geometry::Type
2513 'geom' in terms of their vertices. The number of entities of type 'geom'
2514 is:
2515
2516 num_entities[geom] = size('entity_to_vertex[geom]')/num_vertices[geom]
2517
2518 The number of all elements, 'num_elements', is:
2519
2520 'num_elements' = sum_{dim[geom]=='dimension'} num_entities[geom]
2521
2522 and the number of all boundary elements, 'num_bdr_elements' is:
2523
2524 'num_bdr_elements' = sum_{dim[geom]=='dimension'-1} num_entities[geom]
2525
2526 Note that 'entity_to_vertex' does NOT describe all "faces" in the mesh
2527 part (i.e. all 'dimension'-1 entities) but only the boundary elements.
2528 Also, note that lower dimesional entities ('dimension'-2 and lower) are
2529 NOT described by the respective array, i.e. the array will be empty.
2530 */
2532
2533 /** @brief Store the refinement flags for tetraheral elements. If all tets
2534 have zero refinement flags then this array is empty, i.e. has size 0. */
2536
2537 /**
2538 Terminology: "by-type" element/boundary ordering: ordered by
2539 Geometry::Type and within each Geometry::Type 'geom' ordered as in
2540 'entity_to_vertex[geom]'.
2541
2542 Optional re-ordering of the elements that will be used by (Par)Mesh
2543 objects constructed from this MeshPart. This array maps "natural" element
2544 ids (used by the Mesh/ParMesh objects) to "by-type" element ids (see
2545 above):
2546
2547 "by-type" element id = element_map["natural" element id]
2548
2549 The size of the array is either 'num_elements' or 0 when no re-ordering is
2550 needed (then "by-type" id == "natural" id).
2551 */
2553
2554 /// Optional re-ordering for the boundary elements, similar to 'element_map'.
2556
2557 /**
2558 Element attributes. Ordered using the "natural" element ordering defined
2559 by the array 'element_map'. The size of this array is 'num_elements'.
2560 */
2562
2563 /**
2564 Boundary element attributes. Ordered using the "natural" boundary element
2565 ordering defined by the array 'boundary_map'. The size of this array is
2566 'num_bdr_elements'.
2567 */
2569
2570 /**
2571 Optional vertex coordinates. The size of the array is either
2572
2573 size = 'space_dimension' * 'num_vertices'
2574
2575 or 0 when the vertex coordinates are not used, i.e. when the MeshPart uses
2576 a nodal GridFunction to describe its location in physical space. This
2577 array uses Ordering::byVDIM: "X0,Y0,Z0, X1,Y1,Z1, ...".
2578 */
2580
2581 /**
2582 Optional serial Mesh object constructed on demand using the method
2583 GetMesh(). One use case for it is when one wants to construct FE spaces
2584 and GridFunction%s on the MeshPart for saving or MPI communication.
2585 */
2586 std::unique_ptr<Mesh> mesh;
2587
2588 /**
2589 Nodal FE space defined on 'mesh' used by the GridFunction 'nodes'. Uses
2590 the FE collection from the global nodal FE space.
2591 */
2592 std::unique_ptr<FiniteElementSpace> nodal_fes;
2593
2594 /**
2595 'nodes': pointer to a GridFunction describing the physical location of the
2596 MeshPart. Used for describing high-order and periodic meshes. This
2597 GridFunction is defined on the FE space 'nodal_fes' which, in turn, is
2598 defined on the Mesh 'mesh'.
2599 */
2600 std::unique_ptr<GridFunction> nodes;
2601
2602 /** @name Connectivity to other MeshPart objects */
2603 ///@{
2604
2605 /// Total number of MeshParts
2607
2608 /** @brief Index of the part described by this MeshPart:
2609 0 <= 'my_part_id' < 'num_parts' */
2611
2612 /**
2613 A group G is a subset of the set { 0, 1, ..., 'num_parts'-1 } for which
2614 there is a mesh entity E (of any dimension) in the global mesh such that
2615 G is the set of the parts assigned (by the partitioning array) to the
2616 elements adjacent to E. The MeshPart describes only the "neighbor" groups,
2617 i.e. the groups that contain 'my_part_id'. The Table 'my_groups' defines
2618 the "neighbor" groups in terms of their part ids. In other words, it maps
2619 "neighbor" group ids to a (sorted) list of part ids. In particular, the
2620 number of "neighbor" groups is given by 'my_groups.Size()'. The "local"
2621 group { 'my_part_id' } has index 0 in 'my_groups'.
2622 */
2624
2625 /**
2626 Shared entities for this MeshPart are mesh entities of all dimensions less
2627 than 'dimension' that are generated by the elements of this MeshPart and
2628 at least one other MeshPart.
2629
2630 The Table 'group_shared_entity_to_vertex[geom]' defines, for each group,
2631 the shared entities of Geometry::Type 'geom'. Each row (corresponding to a
2632 "neighbor" group, as defined by 'my_groups') in the Table defines the
2633 shared entities in a way similar to the arrays 'entity_to_vertex[geom]'.
2634 The "local" group (with index 0) does not have any shared entities, so the
2635 0-th row in the Table is always empty.
2636
2637 IMPORTANT: the descriptions of the groups in this MeshPart must match
2638 their descriptions in all neighboring MeshParts. This includes the
2639 ordering of the shared entities within the group, as well as the vertex
2640 ordering of each shared entity.
2641 */
2643
2644 ///@}
2645
2646 /** @brief Write the MeshPart to a stream using the parallel format
2647 "MFEM mesh v1.2". */
2648 void Print(std::ostream &os) const;
2649
2650 /** @brief Construct a serial Mesh object from the MeshPart.
2651
2652 The nodes of 'mesh' are NOT initialized by this method, however, the
2653 nodal FE space and nodal GridFunction can be created and then attached to
2654 the 'mesh'. The Mesh is constructed only if 'mesh' is empty, otherwise
2655 the method simply returns the object held by 'mesh'.
2656 */
2657 Mesh &GetMesh();
2658};
2659
2660
2661/** @brief Class that allows serial meshes to be partitioned into MeshPart
2662 objects, typically one MeshPart at a time, which can then be used to write
2663 the local mesh in parallel MFEM mesh format.
2664
2665 Sample usage of this class: partition a serial mesh and save it in parallel
2666 MFEM format:
2667 \code
2668 // The array 'partitioning' can be obtained e.g. from
2669 // mesh->GeneratePartitioning():
2670 void usage1(Mesh *mesh, int num_parts, int *partitioning)
2671 {
2672 MeshPartitioner partitioner(*mesh, num_parts, partitioning);
2673 MeshPart mesh_part;
2674 for (int i = 0; i < num_parts; i++)
2675 {
2676 partitioner.ExtractPart(i, mesh_part);
2677 ofstream omesh(MakeParFilename("my-mesh.", i));
2678 mesh_part.Print(omesh);
2679 }
2680 }
2681 \endcode
2682
2683 This class can also be used to partition a mesh and GridFunction(s) and save
2684 them in parallel:
2685 \code
2686 // The array 'partitioning' can be obtained e.g. from
2687 // mesh->GeneratePartitioning():
2688 void usage2(Mesh *mesh, int num_parts, int *partitioning,
2689 GridFunction *gf)
2690 {
2691 MeshPartitioner partitioner(*mesh, num_parts, partitioning);
2692 MeshPart mesh_part;
2693 for (int i = 0; i < num_parts; i++)
2694 {
2695 partitioner.ExtractPart(i, mesh_part);
2696 ofstream omesh(MakeParFilename("my-mesh.", i));
2697 mesh_part.Print(omesh);
2698 auto lfes = partitioner.ExtractFESpace(mesh_part, *gf->FESpace());
2699 auto lgf = partitioner.ExtractGridFunction(mesh_part, *gf, *lfes);
2700 ofstream ofield(MakeParFilename("my-field.", i));
2701 lgf->Save(ofield);
2702 }
2703 }
2704 \endcode
2705*/
2707{
2708protected:
2715
2716public:
2717 /** @brief Construct a MeshPartitioner.
2718
2719 @param[in] mesh_ Mesh to be partitioned into MeshPart%s.
2720 @param[in] num_parts_ Number of parts to partition the mesh into.
2721 @param[in] partitioning_ Partitioning array: for every element in the
2722 mesh gives the partition it belongs to; if NULL,
2723 partitioning will be generated internally by
2724 calling Mesh::GeneratePartitioning().
2725 @param[in] part_method Partitioning method to be used in the call to
2726 Mesh::GeneratePartitioning() when the provided
2727 input partitioning is NULL.
2728 */
2729 MeshPartitioner(Mesh &mesh_, int num_parts_, int *partitioning_ = NULL,
2730 int part_method = 1);
2731
2732 /** @brief Construct a MeshPart corresponding to the given @a part_id.
2733
2734 @param[in] part_id Partition index to extract; valid values are in
2735 the range [0, num_parts).
2736 @param[out] mesh_part Output MeshPart object; its contents is
2737 overwritten, while potentially reusing existing
2738 dynamic memory allocations.
2739 */
2740 void ExtractPart(int part_id, MeshPart &mesh_part) const;
2741
2742 /** @brief Construct a local version of the given FiniteElementSpace
2743 @a global_fespace corresponding to the given @a mesh_part.
2744
2745 @param[in,out] mesh_part MeshPart on which to construct the local
2746 FiniteElementSpace; this object is
2747 generally modified by this call since it
2748 calls mesh_part.GetMesh() to ensure the
2749 local mesh is constructed.
2750 @param[in] global_fespace The global FiniteElementSpace that should
2751 be restricted to the @a mesh_part.
2752
2753 @returns A FiniteElementSpace pointer stored in a unique_ptr. The
2754 returned local FiniteElementSpace is built on the Mesh object
2755 contained in @a mesh_part (MeshPart::mesh) and it reuses the
2756 FiniteElementCollection of the @a global_fespace.
2757 */
2758 std::unique_ptr<FiniteElementSpace>
2759 ExtractFESpace(MeshPart &mesh_part,
2760 const FiniteElementSpace &global_fespace) const;
2761
2762 /** @brief Construct a local version of the given GridFunction, @a global_gf,
2763 corresponding to the given @a mesh_part. The respective data is copied
2764 from @a global_gf to the returned local GridFunction.
2765
2766 @param[in] mesh_part MeshPart on which to construct the local
2767 GridFunction.
2768 @param[in] global_gf The global GridFunction that should be
2769 restricted to the @a mesh_part.
2770 @param[in,out] local_fespace The local FiniteElementSpace corresponding
2771 to @a mesh_part, e.g. constructed by the
2772 method ExtractFESpace().
2773
2774 @returns A GridFunction pointer stored in a unique_ptr. The returned
2775 local GridFunction is initialized with data appropriately copied
2776 from @a global_gf.
2777 */
2778 std::unique_ptr<GridFunction>
2779 ExtractGridFunction(const MeshPart &mesh_part,
2780 const GridFunction &global_gf,
2781 FiniteElementSpace &local_fespace) const;
2782};
2783
2784
2785/** @brief Structure for storing mesh geometric factors: coordinates, Jacobians,
2786 and determinants of the Jacobians. */
2787/** Typically objects of this type are constructed and owned by objects of class
2788 Mesh. See Mesh::GetGeometricFactors(). */
2790{
2791private:
2792 void Compute(const GridFunction &nodes,
2794
2795public:
2796 const Mesh *mesh;
2799
2801 {
2802 COORDINATES = 1 << 0,
2803 JACOBIANS = 1 << 1,
2805 };
2806
2807 GeometricFactors(const Mesh *mesh, const IntegrationRule &ir, int flags,
2809
2810 GeometricFactors(const GridFunction &nodes, const IntegrationRule &ir,
2811 int flags,
2813
2814 /// Mapped (physical) coordinates of all quadrature points.
2815 /** This array uses a column-major layout with dimensions (NQ x SDIM x NE)
2816 where
2817 - NQ = number of quadrature points per element,
2818 - SDIM = space dimension of the mesh = mesh.SpaceDimension(), and
2819 - NE = number of elements in the mesh. */
2821
2822 /// Jacobians of the element transformations at all quadrature points.
2823 /** This array uses a column-major layout with dimensions (NQ x SDIM x DIM x
2824 NE) where
2825 - NQ = number of quadrature points per element,
2826 - SDIM = space dimension of the mesh = mesh.SpaceDimension(),
2827 - DIM = dimension of the mesh = mesh.Dimension(), and
2828 - NE = number of elements in the mesh. */
2830
2831 /// Determinants of the Jacobians at all quadrature points.
2832 /** This array uses a column-major layout with dimensions (NQ x NE) where
2833 - NQ = number of quadrature points per element, and
2834 - NE = number of elements in the mesh. */
2836};
2837
2838
2839/** @brief Structure for storing face geometric factors: coordinates, Jacobians,
2840 determinants of the Jacobians, and normal vectors. */
2841/** Typically objects of this type are constructed and owned by objects of class
2842 Mesh. See Mesh::GetFaceGeometricFactors(). */
2844{
2845public:
2846 const Mesh *mesh;
2850
2852 {
2853 COORDINATES = 1 << 0,
2854 JACOBIANS = 1 << 1,
2856 NORMALS = 1 << 3,
2857 };
2858
2859 FaceGeometricFactors(const Mesh *mesh, const IntegrationRule &ir, int flags,
2861
2862 /// Mapped (physical) coordinates of all quadrature points.
2863 /** This array uses a column-major layout with dimensions (NQ x SDIM x NF)
2864 where
2865 - NQ = number of quadrature points per face,
2866 - SDIM = space dimension of the mesh = mesh.SpaceDimension(), and
2867 - NF = number of faces in the mesh. */
2869
2870 /// Jacobians of the element transformations at all quadrature points.
2871 /** This array uses a column-major layout with dimensions (NQ x SDIM x DIM x
2872 NF) where
2873 - NQ = number of quadrature points per face,
2874 - SDIM = space dimension of the mesh = mesh.SpaceDimension(),
2875 - DIM = dimension of the mesh = mesh.Dimension(), and
2876 - NF = number of faces in the mesh. */
2878
2879 /// Determinants of the Jacobians at all quadrature points.
2880 /** This array uses a column-major layout with dimensions (NQ x NF) where
2881 - NQ = number of quadrature points per face, and
2882 - NF = number of faces in the mesh. */
2884
2885 /// Normals at all quadrature points.
2886 /** This array uses a column-major layout with dimensions (NQ x DIM x NF) where
2887 - NQ = number of quadrature points per face,
2888 - SDIM = space dimension of the mesh = mesh.SpaceDimension(), and
2889 - NF = number of faces in the mesh. */
2891};
2892
2893
2894/// Class used to extrude the nodes of a mesh
2896{
2897private:
2898 int n, layer;
2899 real_t p[2], s;
2900 Vector tip;
2901public:
2902 NodeExtrudeCoefficient(const int dim, const int n_, const real_t s_);
2903 void SetLayer(const int l) { layer = l; }
2905 virtual void Eval(Vector &V, ElementTransformation &T,
2906 const IntegrationPoint &ip);
2908};
2909
2910
2911/// Extrude a 1D mesh
2912Mesh *Extrude1D(Mesh *mesh, const int ny, const real_t sy,
2913 const bool closed = false);
2914
2915/// Extrude a 2D mesh
2916Mesh *Extrude2D(Mesh *mesh, const int nz, const real_t sz);
2917
2918// shift cyclically 3 integers left-to-right
2919inline void ShiftRight(int &a, int &b, int &c)
2920{
2921 int t = a;
2922 a = c; c = b; b = t;
2923}
2924
2925}
2926
2927#endif
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition array.hpp:697
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Abstract data type element.
Definition element.hpp:29
Type
Constants for the classes derived from Element.
Definition element.hpp:41
A specialized ElementTransformation class representing a face and its two neighboring elements.
Definition eltrans.hpp:484
Structure for storing face geometric factors: coordinates, Jacobians, determinants of the Jacobians,...
Definition mesh.hpp:2844
Vector normal
Normals at all quadrature points.
Definition mesh.hpp:2890
Vector J
Jacobians of the element transformations at all quadrature points.
Definition mesh.hpp:2877
const IntegrationRule * IntRule
Definition mesh.hpp:2847
Vector X
Mapped (physical) coordinates of all quadrature points.
Definition mesh.hpp:2868
FaceGeometricFactors(const Mesh *mesh, const IntegrationRule &ir, int flags, FaceType type, MemoryType d_mt=MemoryType::DEFAULT)
Definition mesh.cpp:14263
Vector detJ
Determinants of the Jacobians at all quadrature points.
Definition mesh.hpp:2883
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:220
Abstract class for all finite elements.
Definition fe_base.hpp:239
Structure for storing mesh geometric factors: coordinates, Jacobians, and determinants of the Jacobia...
Definition mesh.hpp:2790
Vector X
Mapped (physical) coordinates of all quadrature points.
Definition mesh.hpp:2820
const Mesh * mesh
Definition mesh.hpp:2796
const IntegrationRule * IntRule
Definition mesh.hpp:2797
Vector detJ
Determinants of the Jacobians at all quadrature points.
Definition mesh.hpp:2835
Vector J
Jacobians of the element transformations at all quadrature points.
Definition mesh.hpp:2829
GeometricFactors(const Mesh *mesh, const IntegrationRule &ir, int flags, MemoryType d_mt=MemoryType::DEFAULT)
Definition mesh.cpp:14183
static const int NumGeom
Definition geom.hpp:42
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
Class for integration point with weight.
Definition intrules.hpp:35
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:100
The inverse transformation of a given ElementTransformation.
Definition eltrans.hpp:187
A standard isoparametric element transformation.
Definition eltrans.hpp:363
Class containing a minimal description of a part (a subset of the elements) of a Mesh and its connect...
Definition mesh.hpp:2479
Array< real_t > vertex_coordinates
Definition mesh.hpp:2579
int dimension
Reference space dimension of the elements.
Definition mesh.hpp:2496
int num_vertices
Number of vertices.
Definition mesh.hpp:2502
Table group_shared_entity_to_vertex[Geometry::NumGeom]
Definition mesh.hpp:2642
Array< int > entity_to_vertex[Geometry::NumGeom]
Definition mesh.hpp:2531
std::unique_ptr< Mesh > mesh
Definition mesh.hpp:2586
Array< int > boundary_map
Optional re-ordering for the boundary elements, similar to 'element_map'.
Definition mesh.hpp:2555
std::unique_ptr< FiniteElementSpace > nodal_fes
Definition mesh.hpp:2592
int num_parts
Total number of MeshParts.
Definition mesh.hpp:2606
Array< int > tet_refine_flags
Store the refinement flags for tetraheral elements. If all tets have zero refinement flags then this ...
Definition mesh.hpp:2535
int space_dimension
Dimension of the physical space into which the MeshPart is embedded.
Definition mesh.hpp:2499
int num_bdr_elements
Number of boundary elements with reference space dimension equal to 'dimension'-1.
Definition mesh.hpp:2509
int num_elements
Number of elements with reference space dimension equal to 'dimension'.
Definition mesh.hpp:2505
Mesh & GetMesh()
Construct a serial Mesh object from the MeshPart.
Definition mesh.cpp:13518
int my_part_id
Index of the part described by this MeshPart: 0 <= 'my_part_id' < 'num_parts'.
Definition mesh.hpp:2610
Array< int > element_map
Definition mesh.hpp:2552
Array< int > attributes
Definition mesh.hpp:2561
Table my_groups
Definition mesh.hpp:2623
std::unique_ptr< GridFunction > nodes
Definition mesh.hpp:2600
void Print(std::ostream &os) const
Write the MeshPart to a stream using the parallel format "MFEM mesh v1.2".
Definition mesh.cpp:13338
Array< int > bdr_attributes
Definition mesh.hpp:2568
Class that allows serial meshes to be partitioned into MeshPart objects, typically one MeshPart at a ...
Definition mesh.hpp:2707
Array< int > partitioning
Definition mesh.hpp:2710
std::unique_ptr< FiniteElementSpace > ExtractFESpace(MeshPart &mesh_part, const FiniteElementSpace &global_fespace) const
Construct a local version of the given FiniteElementSpace global_fespace corresponding to the given m...
Definition mesh.cpp:14142
MeshPartitioner(Mesh &mesh_, int num_parts_, int *partitioning_=NULL, int part_method=1)
Construct a MeshPartitioner.
Definition mesh.cpp:13601
std::unique_ptr< GridFunction > ExtractGridFunction(const MeshPart &mesh_part, const GridFunction &global_gf, FiniteElementSpace &local_fespace) const
Construct a local version of the given GridFunction, global_gf, corresponding to the given mesh_part....
Definition mesh.cpp:14157
void ExtractPart(int part_id, MeshPart &mesh_part) const
Construct a MeshPart corresponding to the given part_id.
Definition mesh.cpp:13672
List of mesh geometries stored as Array<Geometry::Type>.
Definition mesh.hpp:1419
Geometry::Type geom_buf[Geometry::NumGeom]
Definition mesh.hpp:1421
GeometryList(const Mesh &mesh)
Construct a GeometryList of all element geometries in mesh.
Definition mesh.hpp:1424
GeometryList(const Mesh &mesh, int dim)
Construct a GeometryList of all geometries of dimension dim in mesh.
Definition mesh.hpp:1429
Mesh data type.
Definition mesh.hpp:56
int CheckElementOrientation(bool fix_it=true)
Check (and optionally attempt to fix) the orientation of the elements.
Definition mesh.cpp:6294
Array< Vertex > vertices
Definition mesh.hpp:97
void GetFaceEdges(int i, Array< int > &edges, Array< int > &o) const
Definition mesh.cpp:7039
void GetEdgeOrdering(const DSTable &v_to_v, Array< int > &order)
Definition mesh.cpp:2642
Geometry::Constants< Geometry::TETRAHEDRON > tet_t
Definition mesh.hpp:272
void GetLocalFaceTransformation(int face_type, int elem_type, IsoparametricTransformation &Transf, int info) const
A helper method that constructs a transformation from the reference space of a face to the reference ...
Definition mesh.cpp:914
void NURBSCoarsening(int cf=2, real_t tol=1.0e-12)
Definition mesh.cpp:10502
void SetVerticesFromNodes(const GridFunction *nodes)
Helper to set vertex coordinates given a high-order curvature function.
Definition mesh.cpp:6236
void ReadGmshMesh(std::istream &input, int &curved, int &read_gf)
int GetPatchBdrAttribute(int i) const
Return the attribute of patch boundary element i, for a NURBS mesh.
Definition mesh.cpp:3016
int GetElementToEdgeTable(Table &)
Definition mesh.cpp:7422
int meshgen
Definition mesh.hpp:80
void GetGeometries(int dim, Array< Geometry::Type > &el_geoms) const
Return all element geometries of the given dimension present in the mesh.
Definition mesh.cpp:6972
void SetVertices(const Vector &vert_coord)
Definition mesh.cpp:8913
Element * NewElement(int geom)
Definition mesh.cpp:4401
Operation GetLastOperation() const
Return type of last modification of the mesh.
Definition mesh.hpp:2236
IsoparametricTransformation Transformation2
Definition mesh.hpp:241
int GetNEdges() const
Return the number of edges.
Definition mesh.hpp:1232
void MarkForRefinement()
Definition mesh.cpp:2610
void GetBdrElementFace(int i, int *f, int *o) const
Definition mesh.cpp:7252
void InitMesh(int Dim_, int spaceDim_, int NVert, int NElem, int NBdrElem)
Begin construction of a mesh.
Definition mesh.cpp:1635
static void PrintElement(const Element *el, std::ostream &os)
Definition mesh.cpp:4467
Array< FaceInfo > faces_info
Definition mesh.hpp:224
int EulerNumber() const
Equals 1 + num_holes - num_loops.
Definition mesh.hpp:1166
CoarseFineTransformations CoarseFineTr
Definition mesh.hpp:247
void GetElementJacobian(int i, DenseMatrix &J, const IntegrationPoint *ip=NULL)
Definition mesh.cpp:62
int AddSegment(int v1, int v2, int attr=1)
Adds a segment to the mesh given by 2 vertices v1 and v2.
Definition mesh.cpp:1715
int AddBdrElement(Element *elem)
Definition mesh.cpp:2028
void GetElementColoring(Array< int > &colors, int el0=0)
Definition mesh.cpp:12047
virtual FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
Definition mesh.cpp:980
void FinalizeMesh(int refine=0, bool fix_orientation=true)
Finalize the construction of any type of Mesh.
Definition mesh.cpp:3128
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Definition mesh.hpp:282
static void PrintElementWithoutAttr(const Element *el, std::ostream &os)
Definition mesh.cpp:4443
Element * GetElement(int i)
Return pointer to the i'th element object.
Definition mesh.hpp:1290
MemAlloc< Tetrahedron, 1024 > TetMemory
Definition mesh.hpp:262
void RedRefinement(int i, const DSTable &v_to_v, int *edge1, int *edge2, int *middle)
Definition mesh.hpp:371
NURBSExtension * NURBSext
Optional NURBS mesh extension.
Definition mesh.hpp:290
void ReadTrueGridMesh(std::istream &input)
static const int vtk_quadratic_tet[10]
Definition mesh.hpp:255
void GetFaceInfos(int Face, int *Inf1, int *Inf2) const
Definition mesh.cpp:1439
const GridFunction * GetNodes() const
Definition mesh.hpp:2094
IsoparametricTransformation EdgeTransformation
Definition mesh.hpp:243
static FiniteElement * GetTransformationFEforElementType(Element::Type)
Return FiniteElement for reference element of the specified type.
Definition mesh.cpp:336
int AddBdrQuad(int v1, int v2, int v3, int v4, int attr=1)
Definition mesh.cpp:2063
int * CartesianPartitioning(int nxyz[])
Definition mesh.cpp:8054
Array< int > FindFaceNeighbors(const int elem) const
Returns the sorted, unique indices of elements sharing a face with element elem, including elem.
Definition mesh.cpp:7224
static int GetQuadOrientation(const int *base, const int *test)
Returns the orientation of "test" relative to "base".
Definition mesh.cpp:6533
Element::Type GetElementType(int i) const
Returns the type of element i.
Definition mesh.cpp:7316
void GetLocalSegToQuadTransformation(IsoparametricTransformation &loc, int i) const
Definition mesh.cpp:692
virtual long long ReduceInt(int value) const
Utility function: sum integers from all processors (Allreduce).
Definition mesh.hpp:2439
int NumOfBdrElements
Definition mesh.hpp:71
void BdrBisection(int i, const HashTable< Hashed2 > &)
Bisect a boundary triangle: boundary element with index i is bisected.
Definition mesh.cpp:10933
Element::Type GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition mesh.cpp:7321
const Table & ElementToEdgeTable() const
Definition mesh.cpp:7506
bool Conforming() const
Definition mesh.hpp:2228
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
Definition mesh.cpp:6250
void ReadNetgen3DMesh(std::istream &input)
void GetBdrElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of boundary element i.
Definition mesh.hpp:1442
Geometry::Type GetFaceGeometry(int i) const
Return the Geometry::Type associated with face i.
Definition mesh.cpp:1452
void GeneralRefinement(const Array< Refinement > &refinements, int nonconforming=-1, int nc_limit=0)
Definition mesh.cpp:10558
Geometry::Type GetElementGeometry(int i) const
Definition mesh.hpp:1371
Geometry::Type GetBdrElementGeometry(int i) const
Definition mesh.hpp:1376
int AddTri(const int *vi, int attr=1)
Adds a triangle to the mesh given by 3 vertices vi.
Definition mesh.hpp:894
static Mesh MakeCartesian1D(int n, real_t sx=1.0)
Creates 1D mesh, divided into n equal intervals.
Definition mesh.cpp:4235
int GetAttribute(int i) const
Return the attribute of element i.
Definition mesh.hpp:1333
void NodesUpdated()
This function should be called after the mesh node coordinates have been updated externally,...
Definition mesh.hpp:2075
void EnsureNodes()
Make sure that the mesh has valid nodes, i.e. its geometry is described by a vector finite element gr...
Definition mesh.cpp:6159
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
Definition mesh.hpp:1438
void UniformRefinement3D_base(Array< int > *f2qf=NULL, DSTable *v_to_v_p=NULL, bool update_nodes=true)
Definition mesh.cpp:9238
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.
Definition mesh.cpp:1743
long nodes_sequence
Counter for geometric factor invalidation.
Definition mesh.hpp:90
virtual void Load(std::istream &input, int generate_edges=0, int refine=1, bool fix_orientation=true)
Definition mesh.hpp:718
IsoparametricTransformation FaceTransformation
Definition mesh.hpp:243
Array< NCFaceInfo > nc_faces_info
Definition mesh.hpp:225
@ REBALANCE
Definition mesh.hpp:277
void MakeRefined_(Mesh &orig_mesh, const Array< int > &ref_factors, int ref_type)
Internal function used in Mesh::MakeRefined.
Definition mesh.cpp:4900
int AddWedge(int v1, int v2, int v3, int v4, int v5, int v6, int attr=1)
Adds a wedge to the mesh given by 6 vertices v1 through v6.
Definition mesh.cpp:1778
Array< int > GetFaceToBdrElMap() const
Definition mesh.cpp:1477
static Mesh MakeCartesian2DWith4TrisPerQuad(int nx, int ny, real_t sx=1.0, real_t sy=1.0)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*4 triangles.
Definition mesh.cpp:4272
void ReadInlineMesh(std::istream &input, bool generate_edges=false)
void SetPatchAttribute(int i, int attr)
Set the attribute of patch i, for a NURBS mesh.
Definition mesh.cpp:2987
void FinalizeTetMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a tetrahedral Mesh.
Definition mesh.cpp:3022
real_t GetLength(int i, int j) const
Return the length of the segment from node i to node j.
Definition mesh.cpp:7360
const FiniteElementSpace * GetNodalFESpace() const
Definition mesh.cpp:6206
void AddBdrQuadAsTriangles(const int *vi, int attr=1)
Definition mesh.cpp:2077
int AddPyramid(int v1, int v2, int v3, int v4, int v5, int attr=1)
Adds a pyramid to the mesh given by 5 vertices v1 through v5.
Definition mesh.cpp:1792
void Loader(std::istream &input, int generate_edges=0, std::string parse_tag="")
Definition mesh.cpp:4526
const Table & ElementToElementTable()
Definition mesh.cpp:7461
void ScaleElements(real_t sf)
Definition mesh.cpp:12751
void GenerateNCFaceInfo()
Definition mesh.cpp:7741
void ReadLineMesh(std::istream &input)
void ApplyLocalSlaveTransformation(FaceElementTransformations &FT, const FaceInfo &fi, bool is_ghost) const
Definition mesh.cpp:1130
Array< Element * > faces
Definition mesh.hpp:99
int Dim
Definition mesh.hpp:68
real_t AggregateError(const Array< real_t > &elem_error, const int *fine, int nfine, int op)
Derefinement helper.
Definition mesh.cpp:10233
void CheckPartitioning(int *partitioning_)
Definition mesh.cpp:8498
void DoNodeReorder(DSTable *old_v_to_v, Table *old_elem_vert)
Definition mesh.cpp:2756
void GetLocalPtToSegTransformation(IsoparametricTransformation &, int i) const
Used in GetFaceElementTransformations (...)
Definition mesh.cpp:657
const Element *const * GetElementsArray() const
Definition mesh.hpp:1317
bool Nonconforming() const
Definition mesh.hpp:2229
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
Definition mesh.hpp:1339
void PrintCharacteristics(Vector *Vh=NULL, Vector *Vk=NULL, std::ostream &os=mfem::out)
Compute and print mesh characteristics such as number of vertices, number of elements,...
Definition mesh.cpp:251
void UpdateNURBS()
Definition mesh.cpp:5796
static int ComposeQuadOrientations(int ori_a_b, int ori_b_c)
Definition mesh.cpp:6581
int AddTriangle(int v1, int v2, int v3, int attr=1)
Adds a triangle to the mesh given by 3 vertices v1 through v3.
Definition mesh.cpp:1729
void GenerateFaces()
Definition mesh.cpp:7639
static const int vtk_quadratic_wedge[18]
Definition mesh.hpp:257
int EulerNumber2D() const
Equals 1 - num_holes.
Definition mesh.hpp:1169
AttributeSets bdr_attribute_sets
Named sets of boundary element attributes.
Definition mesh.hpp:288
void Destroy()
Definition mesh.cpp:1565
int GetBdrElementFaceIndex(int be_idx) const
Return the local face (codimension-1) index for the given boundary element index.
Definition mesh.hpp:1518
void GetVertices(Vector &vert_coord) const
Definition mesh.cpp:8902
void InitFromNCMesh(const NCMesh &ncmesh)
Initialize vertices/elements/boundary/tables from a nonconforming mesh.
Definition mesh.cpp:10333
virtual int GetNFbyType(FaceType type) const
Returns the number of faces according to the requested type, does not count master nonconforming face...
Definition mesh.cpp:6266
void Make1D(int n, real_t sx=1.0)
Definition mesh.cpp:4038
void DeleteTables()
Definition mesh.hpp:308
void RefineNURBSFromFile(std::string ref_file)
Definition mesh.cpp:5627
const Element * GetElement(int i) const
Return pointer to the i'th element object.
Definition mesh.hpp:1283
int AddBdrPoint(int v, int attr=1)
Definition mesh.cpp:2092
void FinalizeWedgeMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a wedge Mesh.
Definition mesh.cpp:3063
static int GetTriOrientation(const int *base, const int *test)
Returns the orientation of "test" relative to "base".
Definition mesh.cpp:6444
void PrintTopo(std::ostream &os, const Array< int > &e_to_k, const int version, const std::string &comment="") const
Write the beginning of a NURBS mesh to os, specifying the NURBS patch topology. Optional file comment...
Definition mesh.cpp:11434
Geometry::Constants< Geometry::SEGMENT > seg_t
Definition mesh.hpp:269
void GetElementData(int geom, Array< int > &elem_vtx, Array< int > &attr) const
Definition mesh.hpp:1320
static Mesh MakeSimplicial(const Mesh &orig_mesh)
Definition mesh.cpp:5128
void SetPatchBdrAttribute(int i, int attr)
Set the attribute of patch boundary element i, for a NURBS mesh.
Definition mesh.cpp:3004
int GetNFaces() const
Return the number of faces in a 3D mesh.
Definition mesh.hpp:1235
int AddVertexAtMeanCenter(const int *vi, const int nverts, int dim=3)
Definition mesh.cpp:1698
static int GetTetOrientation(const int *base, const int *test)
Returns the orientation of "test" relative to "base".
Definition mesh.cpp:6612
Geometry::Constants< Geometry::PRISM > pri_t
Definition mesh.hpp:274
real_t GetGeckoElementOrdering(Array< int > &ordering, int iterations=4, int window=4, int period=2, int seed=0, bool verbose=false, real_t time_limit=0)
Definition mesh.cpp:2239
static int EncodeFaceInfo(int local_face_index, int orientation)
Given local_face_index and orientation, return the corresponding encoded "face info int".
Definition mesh.hpp:1990
bool FaceIsTrueInterior(int FaceNo) const
Definition mesh.hpp:540
long GetSequence() const
Definition mesh.hpp:2242
const CoarseFineTransformations & GetRefinementTransforms() const
Definition mesh.cpp:11082
void Make2D5QuadsFromQuad(int nx, int ny, real_t sx, real_t sy)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*5 quadrilaterals.
Definition mesh.cpp:3671
Geometry::Constants< Geometry::SQUARE > quad_t
Definition mesh.hpp:271
void GetLocalQuadToWdgTransformation(IsoparametricTransformation &loc, int i) const
Definition mesh.cpp:809
ElementTransformation * GetFaceTransformation(int FaceNo)
Returns a pointer to the transformation defining the given face element.
Definition mesh.cpp:583
void SetAttribute(int i, int attr)
Set the attribute of element i.
Definition mesh.hpp:1336
Element * GetBdrElement(int i)
Return pointer to the i'th boundary element object.
Definition mesh.hpp:1305
void FinalizeTopology(bool generate_bdr=true)
Finalize the construction of the secondary topology (connectivity) data of a Mesh.
Definition mesh.cpp:3135
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Definition mesh.hpp:2288
void DestroyTables()
Definition mesh.cpp:1520
static Mesh MakeCartesian2DWith5QuadsPerQuad(int nx, int ny, real_t sx=1.0, real_t sy=1.0)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*5 quadrilaterals.
Definition mesh.cpp:4281
const FaceGeometricFactors * GetFaceGeometricFactors(const IntegrationRule &ir, const int flags, FaceType type, MemoryType d_mt=MemoryType::DEFAULT)
Return the mesh geometric factors for the faces corresponding to the given integration rule.
Definition mesh.cpp:876
void PrintWithPartitioning(int *partitioning, std::ostream &os, int elem_attr=0) const
Prints the mesh with boundary elements given by the boundary of the subdomains, so that the boundary ...
Definition mesh.cpp:12122
void Clear()
Clear the contents of the Mesh.
Definition mesh.hpp:730
void PrepareNodeReorder(DSTable **old_v_to_v, Table **old_elem_vert)
Definition mesh.cpp:2690
void ReadXML_VTKMesh(std::istream &input, int &curved, int &read_gf, bool &finalize_topo, const std::string &xml_prefix="")
int AddVertex(real_t x, real_t y=0.0, real_t z=0.0)
Definition mesh.cpp:1658
virtual void LocalRefinement(const Array< int > &marked_el, int type=3)
This function is not public anymore. Use GeneralRefinement instead.
Definition mesh.cpp:9945
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1226
const Element * GetFace(int i) const
Return pointer to the i'th face element object.
Definition mesh.hpp:1310
void Make3D(int nx, int ny, int nz, Element::Type type, real_t sx, real_t sy, real_t sz, bool sfc_ordering)
Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into nx*ny*nz hexahedra if type =...
Definition mesh.cpp:3316
virtual void Save(const std::string &fname, int precision=16) const
Definition mesh.cpp:11481
Mesh(int Dim_, int NVert, int NElem, int NBdrElem=0, int spaceDim_=-1)
Init constructor: begin the construction of a Mesh object.
Definition mesh.hpp:687
int AddTet(int v1, int v2, int v3, int v4, int attr=1)
Adds a tetrahedron to the mesh given by 4 vertices v1 through v4.
Definition mesh.cpp:1757
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
Definition mesh.cpp:138
void GetBdrPointMatrix(int i, DenseMatrix &pointmat) const
Definition mesh.cpp:7344
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1160
Table * el_to_face
Definition mesh.hpp:228
void RandomRefinement(real_t prob, bool aniso=false, int nonconforming=-1, int nc_limit=0)
Refine each element with given probability. Uses GeneralRefinement.
Definition mesh.cpp:10650
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
Definition mesh.hpp:1298
void CheckDisplacements(const Vector &displacements, real_t &tmax)
Definition mesh.cpp:8816
void AddTriangleFaceElement(int lf, int gf, int el, int v0, int v1, int v2)
Definition mesh.cpp:7584
void AddHexAs24TetsWithPoints(int *vi, std::map< std::array< int, 4 >, int > &hex_face_verts, int attr=1)
Adds 24 tetrahedrons to the mesh by splitting a hexahedron.
Definition mesh.cpp:1960
void GetNode(int i, real_t *coord) const
Definition mesh.cpp:8922
bool OwnsNodes() const
Return the mesh nodes ownership flag.
Definition mesh.hpp:2096
void ReorderElements(const Array< int > &ordering, bool reorder_vertices=true)
Definition mesh.cpp:2458
void GreenRefinement(int i, const DSTable &v_to_v, int *edge1, int *edge2, int *middle)
Definition mesh.hpp:377
void UpdateNodes()
Update the nodes of a curved mesh after the topological part of a Mesh::Operation,...
Definition mesh.cpp:9064
void PrintElementsWithPartitioning(int *partitioning, std::ostream &os, int interior_faces=0)
Definition mesh.cpp:12241
Mesh & operator=(Mesh &&mesh)
Move assignment operator.
Definition mesh.cpp:4219
Geometry::Constants< Geometry::CUBE > hex_t
Definition mesh.hpp:273
long sequence
Definition mesh.hpp:87
static int InvertQuadOrientation(int ori)
Definition mesh.cpp:6606
Array< FaceGeometricFactors * > face_geom_factors
Definition mesh.hpp:293
void GetLocalTriToPyrTransformation(IsoparametricTransformation &loc, int i) const
Definition mesh.cpp:762
ElementConformity
Definition mesh.hpp:1854
Table * bel_to_edge
Definition mesh.hpp:232
Geometry::Constants< Geometry::TRIANGLE > tri_t
Definition mesh.hpp:270
static Mesh MakeRefined(Mesh &orig_mesh, int ref_factor, int ref_type)
Create a refined (by any factor) version of orig_mesh.
Definition mesh.cpp:4290
real_t GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
Definition mesh.cpp:107
Element * ReadElementWithoutAttr(std::istream &input)
Definition mesh.cpp:4425
void SetNodesOwner(bool nodes_owner)
Set the mesh nodes ownership flag.
Definition mesh.hpp:2098
int AddBdrSegment(int v1, int v2, int attr=1)
Definition mesh.cpp:2035
bool DerefineByError(Array< real_t > &elem_error, real_t threshold, int nc_limit=0, int op=1)
Definition mesh.cpp:10304
void FinalizeHexMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a hexahedral Mesh.
Definition mesh.cpp:3098
int AddElement(Element *elem)
Definition mesh.cpp:2021
static int DecodeFaceInfoLocalIndex(int info)
Given a "face info int", return the local face index.
Definition mesh.hpp:1986
Table * el_to_edge
Definition mesh.hpp:227
FaceInformation GetFaceInformation(int f) const
Definition mesh.cpp:1169
int GetNumFacesWithGhost() const
Return the number of faces (3D), edges (2D) or vertices (1D) including ghost faces.
Definition mesh.cpp:6261
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...
Definition mesh.cpp:357
void RefineAtVertex(const Vertex &vert, real_t eps=0.0, int nonconforming=-1)
Refine elements sharing the specified vertex. Uses GeneralRefinement.
Definition mesh.cpp:10669
void GetBdrElementEdges(int i, Array< int > &edges, Array< int > &cor) const
Return the indices and the orientations of all edges of bdr element i.
Definition mesh.cpp:7007
static int InvertTriOrientation(int ori)
Definition mesh.cpp:6527
STable3D * GetElementToFaceTable(int ret_ftbl=0)
Definition mesh.cpp:7862
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a quadrilateral Mesh.
Definition mesh.cpp:2177
void Make3D24TetsFromHex(int nx, int ny, int nz, real_t sx, real_t sy, real_t sz)
Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into nx*ny*nz*24 tetrahedrons.
Definition mesh.cpp:3745
virtual bool NonconformingDerefinement(Array< real_t > &elem_error, real_t threshold, int nc_limit=0, int op=1)
NC version of GeneralDerefinement.
Definition mesh.cpp:10256
void AddVertexParents(int i, int p1, int p2)
Mark vertex i as nonconforming, with parent vertices p1 and p2.
Definition mesh.cpp:1682
MFEM_DEPRECATED void GetBdrElementAdjacentElement2(int bdr_el, int &el, int &info) const
Deprecated.
Definition mesh.cpp:7293
int GetPatchAttribute(int i) const
Return the attribute of patch i, for a NURBS mesh.
Definition mesh.cpp:2998
void GetFaceElements(int Face, int *Elem1, int *Elem2) const
Definition mesh.cpp:1433
void Printer(std::ostream &os=mfem::out, std::string section_delimiter="", const std::string &comments="") const
Definition mesh.cpp:11309
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
Definition mesh.hpp:1392
ElementTransformation * GetBdrElementTransformation(int i)
Returns a pointer to the transformation defining the i-th boundary element.
Definition mesh.cpp:506
static bool remove_unused_vertices
Definition mesh.hpp:299
IsoparametricTransformation Transformation
Definition mesh.hpp:241
void Init()
Definition mesh.cpp:1488
void Make2D4TrisFromQuad(int nx, int ny, real_t sx, real_t sy)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*4 triangles.
Definition mesh.cpp:3598
MFEM_DEPRECATED Geometry::Type GetFaceGeometryType(int Face) const
Deprecated in favor of Mesh::GetFaceGeometry.
Definition mesh.hpp:1363
void GetLocalTriToWdgTransformation(IsoparametricTransformation &loc, int i) const
Definition mesh.cpp:736
void GetElementFaces(int i, Array< int > &faces, Array< int > &ori) const
Return the indices and the orientations of all faces of element i.
Definition mesh.cpp:7201
int SpaceDimension() const
Dimension of the physical space containing the mesh.
Definition mesh.hpp:1163
void ReadNURBSMesh(std::istream &input, int &curved, int &read_gf, bool spacing=false)
const GeometricFactors * GetGeometricFactors(const IntegrationRule &ir, const int flags, MemoryType d_mt=MemoryType::DEFAULT)
Return the mesh geometric factors corresponding to the given integration rule.
Definition mesh.cpp:856
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 =...
Definition mesh.cpp:4253
Table * edge_vertex
Definition mesh.hpp:239
void LoadPatchTopo(std::istream &input, Array< int > &edge_to_knot)
Read NURBS patch/macro-element mesh.
Definition mesh.cpp:5858
void GetCharacteristics(real_t &h_min, real_t &h_max, real_t &kappa_min, real_t &kappa_max, Vector *Vh=NULL, Vector *Vk=NULL)
Definition mesh.cpp:202
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
Definition mesh.cpp:6200
void ReadCubit(const std::string &filename, int &curved, int &read_gf)
Load a mesh from a Genesis file.
static const int vtk_quadratic_pyramid[13]
Definition mesh.hpp:256
void SetNode(int i, const real_t *coord)
Definition mesh.cpp:8941
int NumOfVertices
Definition mesh.hpp:71
AttributeSets attribute_sets
Named sets of element attributes.
Definition mesh.hpp:285
virtual void UniformRefinement3D()
Refine a mixed 3D mesh uniformly.
Definition mesh.hpp:426
static int ComposeTriOrientations(int ori_a_b, int ori_b_c)
Definition mesh.cpp:6504
Array< int > be_to_face
Definition mesh.hpp:230
Mesh & operator=(const Mesh &mesh)=delete
Explicitly delete the copy assignment operator.
void PrintBdrVTU(std::string fname, VTKFormat format=VTKFormat::ASCII, bool high_order_output=false, int compression_level=0)
Definition mesh.cpp:11687
void AddSegmentFaceElement(int lf, int gf, int el, int v0, int v1)
Definition mesh.cpp:7547
FaceElementTransformations * GetBdrFaceTransformations(int BdrElemNo)
Builds the transformation defining the given boundary face.
Definition mesh.cpp:1099
int AddBdrTriangle(int v1, int v2, int v3, int attr=1)
Definition mesh.cpp:2049
void GetGeometricParametersFromJacobian(const DenseMatrix &J, real_t &volume, Vector &aspr, Vector &skew, Vector &ori) const
Computes geometric parameters associated with a Jacobian matrix in 2D/3D. These parameters are (1) Ar...
Definition mesh.cpp:13195
int MeshGenerator() const
Get the mesh generator/type.
Definition mesh.hpp:1187
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
Definition mesh.hpp:1223
static int DecodeFaceInfoOrientation(int info)
Given a "face info int", return the face orientation.
Definition mesh.hpp:1983
void GetHilbertElementOrdering(Array< int > &ordering)
Definition mesh.cpp:2406
void GetEdgeVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of edge i.
Definition mesh.cpp:7069
void AddQuadAs5QuadsWithPoints(int *vi, int attr=1)
Adds 5 quadrilaterals to the mesh by splitting a quadrilateral given by 4 vertices vi.
Definition mesh.cpp:1900
void ReadVTKMesh(std::istream &input, int &curved, int &read_gf, bool &finalize_topo)
void PrintVTU(std::ostream &os, int ref=1, VTKFormat format=VTKFormat::ASCII, bool high_order_output=false, int compression_level=0, bool bdr_elements=false)
Definition mesh.cpp:11695
virtual void UniformRefinement2D()
Refine a mixed 2D mesh uniformly.
Definition mesh.hpp:416
GridFunction * Nodes
Definition mesh.hpp:252
static Mesh MakePeriodic(const Mesh &orig_mesh, const std::vector< int > &v2v)
Create a periodic mesh by identifying vertices of orig_mesh.
Definition mesh.cpp:5457
Element::Type GetFaceElementType(int Face) const
Definition mesh.cpp:1472
int CheckBdrElementOrientation(bool fix_it=true)
Check the orientation of the boundary elements.
Definition mesh.cpp:6745
void GetBdrElementAdjacentElement(int bdr_el, int &el, int &info) const
For the given boundary element, bdr_el, return its adjacent element and its info, i....
Definition mesh.cpp:7271
Table * el_to_el
Definition mesh.hpp:229
void AverageVertices(const int *indexes, int n, int result)
Averages the vertices with given indexes and saves the result in vertices[result].
Definition mesh.cpp:9043
Table * face_edge
Definition mesh.hpp:238
real_t GetElementVolume(int i)
Definition mesh.cpp:121
static Mesh LoadFromFile(const std::string &filename, int generate_edges=0, int refine=1, bool fix_orientation=true)
Definition mesh.cpp:4225
int NumOfElements
Definition mesh.hpp:71
static const int vtk_quadratic_hex[27]
Definition mesh.hpp:258
void Swap(Mesh &other, bool non_geometry)
Definition mesh.cpp:10378
Array< Triple< int, int, int > > tmp_vertex_parents
Definition mesh.hpp:266
virtual void GenerateBoundaryElements()
Definition mesh.cpp:2099
static void GetElementArrayEdgeTable(const Array< Element * > &elem_array, const DSTable &v_to_v, Table &el_to_edge)
Definition mesh.cpp:7375
std::vector< int > CreatePeriodicVertexMapping(const std::vector< Vector > &translations, real_t tol=1e-8) const
Creates a mapping v2v from the vertex indices of the mesh such that coincident vertices under the giv...
Definition mesh.cpp:5491
void Bisection(int i, const DSTable &, int *, int *, int *)
Bisect a triangle: element with index i is bisected.
Definition mesh.cpp:10724
void GetFaceVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of face i.
Definition mesh.hpp:1456
void ResetLazyData()
Definition mesh.cpp:1593
void UniformRefinement2D_base(bool update_nodes=true)
Definition mesh.cpp:9079
IsoparametricTransformation BdrTransformation
Definition mesh.hpp:242
void GetLocalSegToTriTransformation(IsoparametricTransformation &loc, int i) const
Definition mesh.cpp:672
void DestroyPointers()
Definition mesh.cpp:1539
void InitTables()
Definition mesh.cpp:1507
void DegreeElevate(int rel_degree, int degree=16)
Definition mesh.cpp:5779
Table * face_to_elem
Definition mesh.hpp:237
int NumOfFaces
Definition mesh.hpp:72
void GetBdrElementData(int geom, Array< int > &bdr_elem_vtx, Array< int > &bdr_attr) const
Definition mesh.hpp:1323
int spaceDim
Definition mesh.hpp:69
int FindCoarseElement(int i)
Definition mesh.cpp:11072
void FinalizeTriMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a triangular Mesh.
Definition mesh.cpp:2148
void GetElementCenter(int i, Vector &center)
Definition mesh.cpp:77
void AddHexAsPyramids(const int *vi, int attr=1)
Adds 6 pyramids to the mesh by splitting a hexahedron given by 8 vertices vi.
Definition mesh.cpp:1859
static void PrintElementsByGeometry(int dim, const Array< int > &num_elems_by_geom, std::ostream &os)
Auxiliary method used by PrintCharacteristics().
Definition mesh.cpp:237
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.
Definition mesh.cpp:1806
static IntegrationPoint TransformBdrElementToFace(Geometry::Type geom, int o, const IntegrationPoint &ip)
For the vertex (1D), edge (2D), or face (3D) of a boundary element with the orientation o,...
Definition mesh.cpp:6856
MFEM_DEPRECATED int GetBdrFace(int i) const
Deprecated in favor of GetBdrElementFaceIndex().
Definition mesh.hpp:1521
void SetEmpty()
Definition mesh.cpp:1514
virtual void SetNodalFESpace(FiniteElementSpace *nfes)
Definition mesh.cpp:6153
int GetNBE() const
Returns number of boundary elements.
Definition mesh.hpp:1229
long long GetGlobalNE() const
Return the total (global) number of elements.
Definition mesh.hpp:1255
virtual void Finalize(bool refine=false, bool fix_orientation=false)
Finalize the construction of a general Mesh.
Definition mesh.cpp:3241
MFEM_DEPRECATED Mesh(int n, real_t sx=1.0)
Deprecated: see MakeCartesian1D.
Definition mesh.hpp:1143
void AddQuadFaceElement(int lf, int gf, int el, int v0, int v1, int v2, int v3)
Definition mesh.cpp:7612
void ReadMFEMMesh(std::istream &input, int version, int &curved)
Geometry::Constants< Geometry::PYRAMID > pyr_t
Definition mesh.hpp:275
void KnotRemove(Array< Vector * > &kv)
For NURBS meshes, remove the knots in kv, for each direction.
Definition mesh.cpp:5708
virtual int FindPoints(DenseMatrix &point_mat, Array< int > &elem_ids, Array< IntegrationPoint > &ips, bool warn=true, InverseElementTransformation *inv_trans=NULL)
Find the ids of the elements that contain the given points, and their corresponding reference coordin...
Definition mesh.cpp:13081
void CreateVTKMesh(const Vector &points, const Array< int > &cell_data, const Array< int > &cell_offsets, const Array< int > &cell_types, const Array< int > &cell_attributes, int &curved, int &read_gf, bool &finalize_topo)
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr) const
Builds the transformation defining the i-th edge element in EdTr. EdTr must be allocated in advance a...
Definition mesh.cpp:589
int own_nodes
Definition mesh.hpp:253
void GetElementData(const Array< Element * > &elem_array, int geom, Array< int > &elem_vtx, Array< int > &attr) const
Definition mesh.cpp:10438
void PrintSurfaces(const Table &Aface_face, std::ostream &os) const
Print set of disjoint surfaces:
Definition mesh.cpp:12614
bool IsSlaveFace(const FaceInfo &fi) const
Definition mesh.cpp:1125
void FreeElement(Element *E)
Definition mesh.cpp:13056
Array< Element * > boundary
Definition mesh.hpp:98
virtual void MarkTetMeshForRefinement(const DSTable &v_to_v)
Definition mesh.cpp:2667
void GetPointMatrix(int i, DenseMatrix &pointmat) const
Definition mesh.cpp:7326
FaceElementTransformations * GetInteriorFaceTransformations(int FaceNo)
See GetFaceElementTransformations().
Definition mesh.cpp:1079
void GetLocalTriToTetTransformation(IsoparametricTransformation &loc, int i) const
Definition mesh.cpp:712
virtual void PrintInfo(std::ostream &os=mfem::out)
In serial, this method calls PrintCharacteristics(). In parallel, additional information about the pa...
Definition mesh.hpp:2367
virtual void PrintXG(std::ostream &os=mfem::out) const
Print the mesh to the given stream using Netgen/Truegrid format.
Definition mesh.cpp:11145
MFEM_DEPRECATED Geometry::Type GetFaceBaseGeometry(int i) const
Deprecated in favor of Mesh::GetFaceGeometry.
Definition mesh.hpp:1382
NCMesh * ncmesh
Optional nonconforming mesh extension.
Definition mesh.hpp:291
void NewNodes(GridFunction &nodes, bool make_owner=false)
Replace the internal node GridFunction with the given GridFunction.
Definition mesh.cpp:9000
virtual void NURBSUniformRefinement(int rf=2, real_t tol=1.0e-12)
Refine NURBS mesh, with an optional refinement factor, generally anisotropic.
Definition mesh.cpp:5730
MFEM_DEPRECATED Mesh(int nx, int ny, int nz, Element::Type type, bool generate_edges=false, real_t sx=1.0, real_t sy=1.0, real_t sz=1.0, bool sfc_ordering=true)
Deprecated: see MakeCartesian3D.
Definition mesh.hpp:1122
int mesh_geoms
Definition mesh.hpp:82
void DebugDump(std::ostream &os) const
Output an NCMesh-compatible debug dump.
Definition mesh.cpp:14735
real_t * GetVertex(int i)
Return pointer to vertex i's coordinates.
Definition mesh.hpp:1275
MFEM_DEPRECATED int GetBdrElementEdgeIndex(int i) const
Definition mesh.hpp:1528
GridFunction * GetNodes()
Return a pointer to the internal node GridFunction (may be NULL).
Definition mesh.hpp:2093
bool RefineByError(const Array< real_t > &elem_error, real_t threshold, int nonconforming=-1, int nc_limit=0)
Definition mesh.cpp:10695
static Mesh MakeCartesian3DWith24TetsPerHex(int nx, int ny, int nz, real_t sx=1.0, real_t sy=1.0, real_t sz=1.0)
Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into nx*ny*nz*24 tetrahedrons.
Definition mesh.cpp:4263
virtual ~Mesh()
Destroys Mesh.
Definition mesh.hpp:733
STable3D * GetFacesTable()
Definition mesh.cpp:7799
Table * GetFaceEdgeTable() const
Definition mesh.cpp:7078
void EnsureNCMesh(bool simplices_nonconforming=false)
Definition mesh.cpp:10626
bool HasGeometry(Geometry::Type geom) const
Return true iff the given geom is encountered in the mesh. Geometries of dimensions lower than Dimens...
Definition mesh.hpp:1194
virtual MFEM_DEPRECATED void ReorientTetMesh()
Definition mesh.cpp:7992
void PrintVTK(std::ostream &os)
Definition mesh.cpp:11495
void MoveNodes(const Vector &displacements)
Definition mesh.cpp:8961
Array< GeometricFactors * > geom_factors
Optional geometric factors.
Definition mesh.hpp:292
void SetMeshGen()
Determine the mesh generator bitmask meshgen, see MeshGenerator().
Definition mesh.cpp:4473
int nbBoundaryFaces
Definition mesh.hpp:77
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...
Definition mesh.cpp:4243
void GetElementEdges(int i, Array< int > &edges, Array< int > &cor) const
Return the indices and the orientations of all edges of element i.
Definition mesh.cpp:6985
void Make2D(int nx, int ny, Element::Type type, real_t sx, real_t sy, bool generate_edges, bool sfc_ordering)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny quadrilaterals if type = QUADRILATER...
Definition mesh.cpp:3860
void AddHexAsTets(const int *vi, int attr=1)
Adds 6 tetrahedrons to the mesh by splitting a hexahedron given by 8 vertices vi.
Definition mesh.cpp:1822
FaceElementTransformations FaceElemTr
Definition mesh.hpp:244
void MesquiteSmooth(const int mesquite_option=0)
void SetNodes(const Vector &node_coord)
Updates the vertex/node locations. Invokes NodesUpdated().
Definition mesh.cpp:8985
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
Definition mesh.cpp:6961
void FinalizeCheck()
Definition mesh.cpp:2134
void GetLocalQuadToPyrTransformation(IsoparametricTransformation &loc, int i) const
Definition mesh.cpp:833
void AddHexAsWedges(const int *vi, int attr=1)
Adds 2 wedges to the mesh by splitting a hexahedron given by 8 vertices vi.
Definition mesh.cpp:1841
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Set the curvature of the mesh nodes using the given polynomial degree.
Definition mesh.cpp:6211
Element * ReadElement(std::istream &input)
Definition mesh.cpp:4455
virtual bool HasBoundaryElements() const
Checks if the mesh has boundary elements.
Definition mesh.hpp:1190
void ScaleSubdomains(real_t sf)
Definition mesh.cpp:12681
void GetVertexToVertexTable(DSTable &) const
Definition mesh.cpp:7397
void GetLocalQuadToHexTransformation(IsoparametricTransformation &loc, int i) const
Definition mesh.cpp:787
int NumOfEdges
Definition mesh.hpp:72
void Transform(void(*f)(const Vector &, Vector &))
Definition mesh.cpp:12821
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:10970
Geometry::Type GetElementBaseGeometry(int i) const
Definition mesh.hpp:1385
Operation last_operation
Definition mesh.hpp:302
void SwapNodes(GridFunction *&nodes, int &own_nodes_)
Swap the internal node GridFunction pointer and ownership flag members with the given ones.
Definition mesh.cpp:9022
void SetBdrAttribute(int i, int attr)
Set the attribute of boundary element i.
Definition mesh.hpp:1342
void ChangeVertexDataOwnership(real_t *vertices, int len_vertices, bool zerocopy=false)
Set the internal Vertex array to point to the given vertices array without assuming ownership of the ...
Definition mesh.cpp:4334
MFEM_DEPRECATED Mesh(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)
Deprecated: see MakeCartesian2D.
Definition mesh.hpp:1133
int nbInteriorFaces
Definition mesh.hpp:77
Table * GetVertexToElementTable()
Definition mesh.cpp:7132
void InitRefinementTransforms()
Definition mesh.cpp:11060
Geometry::Type GetBdrElementBaseGeometry(int i) const
Definition mesh.hpp:1388
Table * GetEdgeVertexTable() const
Definition mesh.cpp:7106
int * GeneratePartitioning(int nparts, int part_method=1)
Definition mesh.cpp:8098
Table * GetFaceToElementTable() const
Definition mesh.cpp:7167
void MarkTriMeshForRefinement()
Definition mesh.cpp:2627
void ReadNetgen2DMesh(std::istream &input, int &curved)
Array< Element * > elements
Definition mesh.hpp:92
Array< int > attributes
A list of all unique element attributes used by the Mesh.
Definition mesh.hpp:280
void AddPointFaceElement(int lf, int gf, int el)
Used in GenerateFaces()
Definition mesh.cpp:7515
void RemoveInternalBoundaries()
Definition mesh.cpp:12979
virtual void NonconformingRefinement(const Array< Refinement > &refinements, int nc_limit=0)
This function is not public anymore. Use GeneralRefinement instead.
Definition mesh.cpp:10187
void MakeSimplicial_(const Mesh &orig_mesh, int *vglobal)
Definition mesh.cpp:5135
void MoveVertices(const Vector &displacements)
Definition mesh.cpp:8893
virtual void SetAttributes()
Determine the sets of unique attribute values in domain and boundary elements.
Definition mesh.cpp:1604
const real_t * GetVertex(int i) const
Return pointer to vertex i's coordinates.
Definition mesh.hpp:1265
void DeleteGeometricFactors()
Destroy all GeometricFactors stored by the Mesh.
Definition mesh.cpp:898
const Table & ElementToFaceTable() const
Definition mesh.cpp:7497
long GetNodesSequence() const
Return the nodes update counter.
Definition mesh.hpp:2249
void AddQuadAs4TrisWithPoints(int *vi, int attr=1)
Adds 4 triangles to the mesh by splitting a quadrilateral given by 4 vertices vi.
Definition mesh.cpp:1878
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
Definition mesh.cpp:12872
void KnotInsert(Array< KnotVector * > &kv)
For NURBS meshes, insert the new knots in kv, for each direction.
Definition mesh.cpp:5664
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
Definition ncmesh.hpp:123
Class used to extrude the nodes of a mesh.
Definition mesh.hpp:2896
void SetLayer(const int l)
Definition mesh.hpp:2903
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
Definition mesh.cpp:14330
NodeExtrudeCoefficient(const int dim, const int n_, const real_t s_)
Definition mesh.cpp:14324
virtual ~NodeExtrudeCoefficient()
Definition mesh.hpp:2907
Class for parallel meshes.
Definition pmesh.hpp:34
A parallel extension of the NCMesh class.
Definition pncmesh.hpp:65
Symmetric 3D Table stored as an array of rows each of which has a stack of column,...
Definition stable3d.hpp:35
Data type tetrahedron element.
Base class for vector Coefficients that optionally depend on time and space.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
Vector data type.
Definition vector.hpp:80
Data type for vertex.
Definition vertex.hpp:23
int dim
Definition ex24.cpp:53
prob_type prob
Definition ex25.cpp:156
constexpr int dimension
This example only works in 3D. Kernels for 2D are not implemented.
Definition hooke.cpp:45
real_t b
Definition lissajous.cpp:42
real_t a
Definition lissajous.cpp:41
std::ostream & operator<<(std::ostream &os, SparseMatrix const &mat)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition globals.hpp:66
void ShiftRight(int &a, int &b, int &c)
Definition mesh.hpp:2919
Mesh * Extrude1D(Mesh *mesh, const int ny, const real_t sy, const bool closed)
Extrude a 1D mesh.
Definition mesh.cpp:14348
Mesh * Extrude2D(Mesh *mesh, const int nz, const real_t sz)
Extrude a 2D mesh.
Definition mesh.cpp:14508
VTKFormat
Data array format for VTK and VTU files.
Definition vtk.hpp:99
@ ASCII
Data arrays will be written in ASCII format.
float real_t
Definition config.hpp:43
MemoryType
Memory types supported by MFEM.
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30
FaceType
Definition mesh.hpp:47
RefCoord t[3]
Defines the coarse-fine transformations of all fine elements.
Definition ncmesh.hpp:72
EntityHelper(int dim_, const Array< int >(&entity_to_vertex_)[Geometry::NumGeom])
Definition mesh.cpp:13310
Entity FindEntity(int bytype_entity_id)
Definition mesh.cpp:13325
entity_to_vertex_type & entity_to_vertex
Definition mesh.hpp:2487
const Array< int > entity_to_vertex_type[Geometry::NumGeom]
Definition mesh.hpp:2486
int geom_offsets[Geometry::NumGeom+1]
Definition mesh.hpp:2485
const int * verts
Definition mesh.hpp:2481
This structure stores the low level information necessary to interpret the configuration of elements ...
Definition mesh.hpp:161
This structure is used as a human readable output format that deciphers the information contained in ...
Definition mesh.hpp:1894
ElementLocation location
Definition mesh.hpp:1899
bool IsNonconformingFine() const
Return true if the face is a nonconforming fine face.
Definition mesh.hpp:1961
bool IsBoundary() const
Return true if the face is a boundary face.
Definition mesh.hpp:1935
bool IsNonconformingCoarse() const
Return true if the face is a nonconforming coarse face.
Definition mesh.hpp:1972
bool IsOfFaceType(FaceType type) const
Return true if the face is of the same type as type.
Definition mesh.hpp:1941
bool IsInterior() const
return true if the face is an interior face to the computation domain, either a local or shared inter...
Definition mesh.hpp:1928
struct mfem::Mesh::FaceInformation::@13 element[2]
bool IsLocal() const
Return true if the face is a local interior face which is NOT a master nonconforming face.
Definition mesh.hpp:1912
bool IsConforming() const
Return true if the face is a conforming face.
Definition mesh.hpp:1955
ElementConformity conformity
Definition mesh.hpp:1900
bool IsShared() const
Return true if the face is a shared interior face which is NOT a master nonconforming face.
Definition mesh.hpp:1919
const DenseMatrix * point_matrix
Definition mesh.hpp:1908
const DenseMatrix * PointMatrix
Definition mesh.hpp:215
NCFaceInfo(bool slave, int master, const DenseMatrix *pm)
Definition mesh.hpp:220