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