MFEM  v4.2.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
mesh.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2020, 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"
16 #include "../general/stable3d.hpp"
17 #include "../general/globals.hpp"
18 #include "triangle.hpp"
19 #include "tetrahedron.hpp"
20 #include "vertex.hpp"
21 #include "vtk.hpp"
22 #include "ncmesh.hpp"
23 #include "../fem/eltrans.hpp"
24 #include "../fem/coefficient.hpp"
25 #include "../general/zstr.hpp"
26 #ifdef MFEM_USE_ADIOS2
27 #include "../general/adios2stream.hpp"
28 #endif
29 #include <iostream>
30 
31 namespace mfem
32 {
33 
34 // Data type mesh
35 
36 class GeometricFactors;
37 class FaceGeometricFactors;
38 class KnotVector;
39 class NURBSExtension;
40 class FiniteElementSpace;
41 class GridFunction;
42 struct Refinement;
43 
44 /** An enum type to specify if interior or boundary faces are desired. */
45 enum class FaceType : bool {Interior, Boundary};
46 
47 #ifdef MFEM_USE_MPI
48 class ParMesh;
49 class ParNCMesh;
50 #endif
51 
52 class Mesh
53 {
54 #ifdef MFEM_USE_MPI
55  friend class ParMesh;
56  friend class ParNCMesh;
57 #endif
58  friend class NCMesh;
59  friend class NURBSExtension;
60 
61 #ifdef MFEM_USE_ADIOS2
62  friend class adios2stream;
63 #endif
64 
65 protected:
66  int Dim;
67  int spaceDim;
68 
71  /** These variables store the number of Interior and Boundary faces. Calling
72  fes->GetMesh()->GetNBE() doesn't return the expected value in 3D because
73  periodic meshes in 3D have some of their faces marked as boundary for
74  visualization purpose in GLVis. */
76 
77  int meshgen; // see MeshGenerator()
78  int mesh_geoms; // sum of (1 << geom) for all geom of all dimensions
79 
80  // Counter for Mesh transformations: refinement, derefinement, rebalancing.
81  // Used for checking during Update operations on objects depending on the
82  // Mesh, such as FiniteElementSpace, GridFunction, etc.
83  long sequence;
84 
86  // Vertices are only at the corners of elements, where you would expect them
87  // in the lowest-order mesh. In some cases, e.g. in a Mesh that defines the
88  // patch topology for a NURBS mesh (see LoadPatchTopo()) the vertices may be
89  // empty while NumOfVertices is positive.
93 
94  struct FaceInfo
95  {
96  // Inf = 64 * LocalFaceIndex + FaceOrientation
98  int NCFace; /* -1 if this is a regular conforming/boundary face;
99  index into 'nc_faces_info' if >= 0. */
100  };
101  // NOTE: in NC meshes, master faces have Elem2No == -1. Slave faces on the
102  // other hand have Elem2No and Elem2Inf set to the master face's element and
103  // its local face number.
104  //
105  // A local face is one generated from a local element and has index i in
106  // faces_info such that i < GetNumFaces(). Also, Elem1No always refers to the
107  // element (slave or master, in the non-conforming case) that generated the
108  // face.
109  // Classification of a local (non-ghost) face based on its FaceInfo:
110  // - Elem2No >= 0 --> local internal face; can be either:
111  // - NCFace == -1 --> conforming face, or
112  // - NCFace >= 0 --> non-conforming slave face.
113  // - Elem2No < 0 --> local "boundary" face; can be one of:
114  // - NCFace == -1 --> conforming face; can be either:
115  // - Elem2Inf < 0 --> true boundary face (no element on side 2)
116  // - Elem2Inf >= 0 --> shared face where element 2 is a face-neighbor
117  // element with index -1-Elem2No. This state is initialized by
118  // ParMesh::ExchangeFaceNbrData().
119  // - NCFace >= 0 --> non-conforming master face. Elem2No is -1 or, in the
120  // case of a shared face, -1-Elem2No is the index of one of the adjacent
121  // (the last one?) slave ghost elements. Elem2Inf is -1.
122  //
123  // A ghost face is a non-conforming face that is generated by a non-local,
124  // i.e. ghost, element. A ghost face has index i in faces_info such that
125  // i >= GetNumFaces().
126  // Classification of a ghost (non-local) face based on its FaceInfo:
127  // - Elem1No == -1 --> master ghost face? These ghost faces also have:
128  // Elem2No == -1, Elem1Inf == Elem2Inf == -1, and NCFace == -1.
129  // - Elem1No >= 0 --> slave ghost face; Elem1No is the index of the local
130  // master side element, i.e. side 1 IS NOT the side that generated the
131  // face. Elem2No is < 0 and -1-Elem2No is the index of the ghost
132  // face-neighbor element that generated this slave ghost face. In this
133  // case, Elem2Inf >= 0.
134  // Relevant methods: GenerateFaces(), GenerateNCFaceInfo(),
135  // ParNCMesh::GetFaceNeighbors(),
136  // ParMesh::ExchangeFaceNbrData()
137 
138  struct NCFaceInfo
139  {
140  bool Slave; // true if this is a slave face, false if master face
141  int MasterFace; // if Slave, this is the index of the master face
142  // If not Slave, 'MasterFace' is the local face index of this master face
143  // as a face in the unique adjacent element.
144  const DenseMatrix* PointMatrix; // if Slave, position within master face
145  // (NOTE: PointMatrix points to a matrix owned by NCMesh.)
146 
147  NCFaceInfo() = default;
148 
149  NCFaceInfo(bool slave, int master, const DenseMatrix* pm)
150  : Slave(slave), MasterFace(master), PointMatrix(pm) {}
151  };
152 
155 
160  Table *bel_to_edge; // for 3D
162  mutable Table *face_edge;
163  mutable Table *edge_vertex;
164 
169 
170  // refinement embeddings for forward compatibility with NCMesh
172 
173  // Nodes are only active for higher order meshes, and share locations with
174  // the vertices, plus all the higher- order control points within the
175  // element and along the edges and on the faces.
178 
179  static const int vtk_quadratic_tet[10];
180  static const int vtk_quadratic_wedge[18];
181  static const int vtk_quadratic_hex[27];
182 
183 #ifdef MFEM_USE_MEMALLOC
184  friend class Tetrahedron;
186 #endif
187 
188 public:
195 
197 
198  /// A list of all unique element attributes used by the Mesh.
200  /// A list of all unique boundary attributes used by the Mesh.
202 
203  NURBSExtension *NURBSext; ///< Optional NURBS mesh extension.
204  NCMesh *ncmesh; ///< Optional non-conforming mesh extension.
205  Array<GeometricFactors*> geom_factors; ///< Optional geometric factors.
207  face_geom_factors; ///< Optional face geometric factors.
208 
209  /// Used during initialization only.
211 
212  // Global parameter that can be used to control the removal of unused
213  // vertices performed when reading a mesh in MFEM format. The default value
214  // (true) is set in mesh_readers.cpp.
216 
217 protected:
219 
220  void Init();
221  void InitTables();
222  void SetEmpty(); // Init all data members with empty values
223  void DestroyTables();
225  void DestroyPointers(); // Delete data specifically allocated by class Mesh.
226  void Destroy(); // Delete all owned data.
227  void ResetLazyData();
228 
229  Element *ReadElementWithoutAttr(std::istream &);
230  static void PrintElementWithoutAttr(const Element *, std::ostream &);
231 
232  Element *ReadElement(std::istream &);
233  static void PrintElement(const Element *, std::ostream &);
234 
235  // Readers for different mesh formats, used in the Load() method.
236  // The implementations of these methods are in mesh_readers.cpp.
237  void ReadMFEMMesh(std::istream &input, bool mfem_v11, int &curved);
238  void ReadLineMesh(std::istream &input);
239  void ReadNetgen2DMesh(std::istream &input, int &curved);
240  void ReadNetgen3DMesh(std::istream &input);
241  void ReadTrueGridMesh(std::istream &input);
242  void ReadVTKMesh(std::istream &input, int &curved, int &read_gf,
243  bool &finalize_topo);
244  void ReadNURBSMesh(std::istream &input, int &curved, int &read_gf);
245  void ReadInlineMesh(std::istream &input, bool generate_edges = false);
246  void ReadGmshMesh(std::istream &input, int &curved, int &read_gf);
247  /* Note NetCDF (optional library) is used for reading cubit files */
248 #ifdef MFEM_USE_NETCDF
249  void ReadCubit(const char *filename, int &curved, int &read_gf);
250 #endif
251 
252  /// Determine the mesh generator bitmask #meshgen, see MeshGenerator().
253  /** Also, initializes #mesh_geoms. */
254  void SetMeshGen();
255 
256  /// Return the length of the segment from node i to node j.
257  double GetLength(int i, int j) const;
258 
259  /** Compute the Jacobian of the transformation from the perfect
260  reference element at the center of the element. */
261  void GetElementJacobian(int i, DenseMatrix &J);
262 
263  void MarkForRefinement();
265  void GetEdgeOrdering(DSTable &v_to_v, Array<int> &order);
266  virtual void MarkTetMeshForRefinement(DSTable &v_to_v);
267 
268  // Methods used to prepare and apply permutation of the mesh nodes assuming
269  // that the mesh elements may be rotated (e.g. to mark triangle or tet edges
270  // for refinement) between the two calls - PrepareNodeReorder() and
271  // DoNodeReorder(). The latter method assumes that the 'faces' have not been
272  // updated after the element rotations.
273  void PrepareNodeReorder(DSTable **old_v_to_v, Table **old_elem_vert);
274  void DoNodeReorder(DSTable *old_v_to_v, Table *old_elem_vert);
275 
277  STable3D *GetElementToFaceTable(int ret_ftbl = 0);
278 
279  /** Red refinement. Element with index i is refined. The default
280  red refinement for now is Uniform. */
281  void RedRefinement(int i, const DSTable &v_to_v,
282  int *edge1, int *edge2, int *middle)
283  { UniformRefinement(i, v_to_v, edge1, edge2, middle); }
284 
285  /** Green refinement. Element with index i is refined. The default
286  refinement for now is Bisection. */
287  void GreenRefinement(int i, const DSTable &v_to_v,
288  int *edge1, int *edge2, int *middle)
289  { Bisection(i, v_to_v, edge1, edge2, middle); }
290 
291  /// Bisect a triangle: element with index @a i is bisected.
292  void Bisection(int i, const DSTable &, int *, int *, int *);
293 
294  /// Bisect a tetrahedron: element with index @a i is bisected.
295  void Bisection(int i, HashTable<Hashed2> &);
296 
297  /// Bisect a boundary triangle: boundary element with index @a i is bisected.
298  void BdrBisection(int i, const HashTable<Hashed2> &);
299 
300  /** Uniform Refinement. Element with index i is refined uniformly. */
301  void UniformRefinement(int i, const DSTable &, int *, int *, int *);
302 
303  /** @brief Averages the vertices with given @a indexes and saves the result
304  in #vertices[result]. */
305  void AverageVertices(const int *indexes, int n, int result);
306 
308  int FindCoarseElement(int i);
309 
310  /// Update the nodes of a curved mesh after refinement
311  void UpdateNodes();
312 
313  void UniformRefinement2D_base(bool update_nodes = true);
314 
315  /// Refine a mixed 2D mesh uniformly.
317 
318  /* If @a f2qf is not NULL, adds all quadrilateral faces to @a f2qf which
319  represents a "face-to-quad-face" index map. When all faces are quads, the
320  array @a f2qf is kept empty since it is not needed. */
321  void UniformRefinement3D_base(Array<int> *f2qf = NULL,
322  DSTable *v_to_v_p = NULL,
323  bool update_nodes = true);
324 
325  /// Refine a mixed 3D mesh uniformly.
327 
328  /// Refine NURBS mesh.
329  virtual void NURBSUniformRefinement();
330 
331  /// This function is not public anymore. Use GeneralRefinement instead.
332  virtual void LocalRefinement(const Array<int> &marked_el, int type = 3);
333 
334  /// This function is not public anymore. Use GeneralRefinement instead.
335  virtual void NonconformingRefinement(const Array<Refinement> &refinements,
336  int nc_limit = 0);
337 
338  /// NC version of GeneralDerefinement.
339  virtual bool NonconformingDerefinement(Array<double> &elem_error,
340  double threshold, int nc_limit = 0,
341  int op = 1);
342  /// Derefinement helper.
343  double AggregateError(const Array<double> &elem_error,
344  const int *fine, int nfine, int op);
345 
346  /// Read NURBS patch/macro-element mesh
347  void LoadPatchTopo(std::istream &input, Array<int> &edge_to_knot);
348 
349  void UpdateNURBS();
350 
351  void PrintTopo(std::ostream &out, const Array<int> &e_to_k) const;
352 
353  /// Used in GetFaceElementTransformations (...)
356  int i);
358  int i);
359  /// Used in GetFaceElementTransformations (...)
361  int i);
362  /// Used in GetFaceElementTransformations (...)
364  int i);
365  /// Used in GetFaceElementTransformations (...)
367  int i);
368  /// Used in GetFaceElementTransformations (...)
370  int i);
371 
372  /** Used in GetFaceElementTransformations to account for the fact that a
373  slave face occupies only a portion of its master face. */
375  const FaceInfo &fi, bool is_ghost);
376 
377  bool IsSlaveFace(const FaceInfo &fi) const;
378 
379  /// Returns the orientation of "test" relative to "base"
380  static int GetTriOrientation (const int * base, const int * test);
381  /// Returns the orientation of "test" relative to "base"
382  static int GetQuadOrientation (const int * base, const int * test);
383  /// Returns the orientation of "test" relative to "base"
384  static int GetTetOrientation (const int * base, const int * test);
385 
386  static void GetElementArrayEdgeTable(const Array<Element*> &elem_array,
387  const DSTable &v_to_v,
388  Table &el_to_edge);
389 
390  /** Return vertex to vertex table. The connections stored in the table
391  are from smaller to bigger vertex index, i.e. if i<j and (i, j) is
392  in the table, then (j, i) is not stored. */
393  void GetVertexToVertexTable(DSTable &) const;
394 
395  /** Return element to edge table and the indices for the boundary edges.
396  The entries in the table are ordered according to the order of the
397  nodes in the elements. For example, if T is the element to edge table
398  T(i, 0) gives the index of edge in element i that connects vertex 0
399  to vertex 1, etc. Returns the number of the edges. */
401 
402  /// Used in GenerateFaces()
403  void AddPointFaceElement(int lf, int gf, int el);
404 
405  void AddSegmentFaceElement (int lf, int gf, int el, int v0, int v1);
406 
407  void AddTriangleFaceElement (int lf, int gf, int el,
408  int v0, int v1, int v2);
409 
410  void AddQuadFaceElement (int lf, int gf, int el,
411  int v0, int v1, int v2, int v3);
412  /** For a serial Mesh, return true if the face is interior. For a parallel
413  ParMesh return true if the face is interior or shared. In parallel, this
414  method only works if the face neighbor data is exchanged. */
415  bool FaceIsTrueInterior(int FaceNo) const
416  {
417  return FaceIsInterior(FaceNo) || (faces_info[FaceNo].Elem2Inf >= 0);
418  }
419 
420  void FreeElement(Element *E);
421 
422  void GenerateFaces();
423  void GenerateNCFaceInfo();
424 
425  /// Begin construction of a mesh
426  void InitMesh(int _Dim, int _spaceDim, int NVert, int NElem, int NBdrElem);
427 
428  // Used in the methods FinalizeXXXMesh() and FinalizeTopology()
429  void FinalizeCheck();
430 
431  void Loader(std::istream &input, int generate_edges = 0,
432  std::string parse_tag = "");
433 
434  // If NURBS mesh, write NURBS format. If NCMesh, write mfem v1.1 format.
435  // If section_delimiter is empty, write mfem v1.0 format. Otherwise, write
436  // mfem v1.2 format with the given section_delimiter at the end.
437  void Printer(std::ostream &out = mfem::out,
438  std::string section_delimiter = "") const;
439 
440  /** Creates mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into
441  nx*ny*nz hexahedra if type=HEXAHEDRON or into 6*nx*ny*nz tetrahedrons if
442  type=TETRAHEDRON. The parameter @a sfc_ordering controls how the elements
443  (when type=HEXAHEDRON) are ordered: true - use space-filling curve
444  ordering, or false - use lexicographic ordering. */
445  void Make3D(int nx, int ny, int nz, Element::Type type,
446  double sx, double sy, double sz, bool sfc_ordering);
447 
448  /** Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny
449  quadrilaterals if type = QUADRILATERAL or into 2*nx*ny triangles if
450  type = TRIANGLE. If generate_edges = 0 (default) edges are not generated,
451  if 1 edges are generated. The parameter @a sfc_ordering controls how the
452  elements (when type=QUADRILATERAL) are ordered: true - use space-filling
453  curve ordering, or false - use lexicographic ordering. */
454  void Make2D(int nx, int ny, Element::Type type, double sx, double sy,
455  bool generate_edges, bool sfc_ordering);
456 
457  /// Creates a 1D mesh for the interval [0,sx] divided into n equal intervals.
458  void Make1D(int n, double sx = 1.0);
459 
460  /// Initialize vertices/elements/boundary/tables from a nonconforming mesh.
461  void InitFromNCMesh(const NCMesh &ncmesh);
462 
463  /// Create from a nonconforming mesh.
464  explicit Mesh(const NCMesh &ncmesh);
465 
466  /// Swaps internal data with another mesh. By default, non-geometry members
467  /// like 'ncmesh' and 'NURBSExt' are only swapped when 'non_geometry' is set.
468  void Swap(Mesh& other, bool non_geometry);
469 
470  // used in GetElementData() and GetBdrElementData()
471  void GetElementData(const Array<Element*> &elem_array, int geom,
472  Array<int> &elem_vtx, Array<int> &attr) const;
473 
474 public:
475 
476  Mesh() { SetEmpty(); }
477 
478  /** Copy constructor. Performs a deep copy of (almost) all data, so that the
479  source mesh can be modified (e.g. deleted, refined) without affecting the
480  new mesh. If 'copy_nodes' is false, use a shallow (pointer) copy for the
481  nodes, if present. */
482  explicit Mesh(const Mesh &mesh, bool copy_nodes = true);
483 
484  /// Construct a Mesh from the given primary data.
485  /** The array @a vertices is used as external data, i.e. the Mesh does not
486  copy the data and will not delete the pointer.
487 
488  The data from the other arrays is copied into the internal Mesh data
489  structures.
490 
491  This method calls the method FinalizeTopology(). The method Finalize()
492  may be called after this constructor and after optionally setting the
493  Mesh nodes. */
494  Mesh(double *vertices, int num_vertices,
495  int *element_indices, Geometry::Type element_type,
496  int *element_attributes, int num_elements,
497  int *boundary_indices, Geometry::Type boundary_type,
498  int *boundary_attributes, int num_boundary_elements,
499  int dimension, int space_dimension= -1);
500 
501  /** @anchor mfem_Mesh_init_ctor
502  @brief _Init_ constructor: begin the construction of a Mesh object. */
503  Mesh(int _Dim, int NVert, int NElem, int NBdrElem = 0, int _spaceDim = -1)
504  {
505  if (_spaceDim == -1) { _spaceDim = _Dim; }
506  InitMesh(_Dim, _spaceDim, NVert, NElem, NBdrElem);
507  }
508 
509  /** @name Methods for Mesh construction.
510 
511  These methods are intended to be used with the @ref mfem_Mesh_init_ctor
512  "init constructor". */
513  ///@{
514 
515  Element *NewElement(int geom);
516 
517  int AddVertex(double x, double y = 0.0, double z = 0.0);
518  int AddVertex(const double *coords);
519  /// Mark vertex @a i as non-conforming, with parent vertices @a p1 and @a p2.
520  void AddVertexParents(int i, int p1, int p2);
521 
522  int AddSegment(int v1, int v2, int attr = 1);
523  int AddSegment(const int *vi, int attr = 1);
524 
525  int AddTriangle(int v1, int v2, int v3, int attr = 1);
526  int AddTriangle(const int *vi, int attr = 1);
527  int AddTri(const int *vi, int attr = 1) { return AddTriangle(vi, attr); }
528 
529  int AddQuad(int v1, int v2, int v3, int v4, int attr = 1);
530  int AddQuad(const int *vi, int attr = 1);
531 
532  int AddTet(int v1, int v2, int v3, int v4, int attr = 1);
533  int AddTet(const int *vi, int attr = 1);
534 
535  int AddWedge(int v1, int v2, int v3, int v4, int v5, int v6, int attr = 1);
536  int AddWedge(const int *vi, int attr = 1);
537 
538  int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8,
539  int attr = 1);
540  int AddHex(const int *vi, int attr = 1);
541  void AddHexAsTets(const int *vi, int attr = 1);
542  void AddHexAsWedges(const int *vi, int attr = 1);
543 
544  /// The parameter @a elem should be allocated using the NewElement() method
545  int AddElement(Element *elem);
546  int AddBdrElement(Element *elem);
547 
548  int AddBdrSegment(int v1, int v2, int attr = 1);
549  int AddBdrSegment(const int *vi, int attr = 1);
550 
551  int AddBdrTriangle(int v1, int v2, int v3, int attr = 1);
552  int AddBdrTriangle(const int *vi, int attr = 1);
553 
554  int AddBdrQuad(int v1, int v2, int v3, int v4, int attr = 1);
555  int AddBdrQuad(const int *vi, int attr = 1);
556  void AddBdrQuadAsTriangles(const int *vi, int attr = 1);
557 
559  /// Finalize the construction of a triangular Mesh.
560  void FinalizeTriMesh(int generate_edges = 0, int refine = 0,
561  bool fix_orientation = true);
562  /// Finalize the construction of a quadrilateral Mesh.
563  void FinalizeQuadMesh(int generate_edges = 0, int refine = 0,
564  bool fix_orientation = true);
565  /// Finalize the construction of a tetrahedral Mesh.
566  void FinalizeTetMesh(int generate_edges = 0, int refine = 0,
567  bool fix_orientation = true);
568  /// Finalize the construction of a wedge Mesh.
569  void FinalizeWedgeMesh(int generate_edges = 0, int refine = 0,
570  bool fix_orientation = true);
571  /// Finalize the construction of a hexahedral Mesh.
572  void FinalizeHexMesh(int generate_edges = 0, int refine = 0,
573  bool fix_orientation = true);
574  /// Finalize the construction of any type of Mesh.
575  /** This method calls FinalizeTopology() and Finalize(). */
576  void FinalizeMesh(int refine = 0, bool fix_orientation = true);
577 
578  ///@}
579 
580  /** @brief Finalize the construction of the secondary topology (connectivity)
581  data of a Mesh. */
582  /** This method does not require any actual coordinate data (either vertex
583  coordinates for linear meshes or node coordinates for meshes with nodes)
584  to be available. However, the data generated by this method is generally
585  required by the FiniteElementSpace class.
586 
587  After calling this method, setting the Mesh vertices or nodes, it may be
588  appropriate to call the method Finalize(). */
589  void FinalizeTopology(bool generate_bdr = true);
590 
591  /// Finalize the construction of a general Mesh.
592  /** This method will:
593  - check and optionally fix the orientation of regular elements
594  - check and fix the orientation of boundary elements
595  - assume that #vertices are defined, if #Nodes == NULL
596  - assume that #Nodes are defined, if #Nodes != NULL.
597  @param[in] refine If true, prepare the Mesh for conforming refinement of
598  triangular or tetrahedral meshes.
599  @param[in] fix_orientation
600  If true, fix the orientation of inverted mesh elements
601  by permuting their vertices.
602 
603  Before calling this method, call FinalizeTopology() and ensure that the
604  Mesh vertices or nodes are set. */
605  virtual void Finalize(bool refine = false, bool fix_orientation = false);
606 
607  virtual void SetAttributes();
608 
609  /** This is our integration with the Gecko library. The method finds an
610  element ordering that will increase memory coherency by putting elements
611  that are in physical proximity closer in memory. It can also be used to
612  obtain a space-filling curve ordering for ParNCMesh partitioning.
613  @param[out] ordering Output element ordering.
614  @param iterations Total number of V cycles. The ordering may improve with
615  more iterations. The best iteration is returned at the end.
616  @param window Initial window size. This determines the number of
617  permutations tested at each multigrid level and strongly influences the
618  quality of the result, but the cost of increasing 'window' is exponential.
619  @param period The window size is incremented every 'period' iterations.
620  @param seed Seed for initial random ordering (0 = skip random reorder).
621  @param verbose Print the progress of the optimization to mfem::out.
622  @param time_limit Optional time limit for the optimization, in seconds.
623  When reached, ordering from the best iteration so far is returned
624  (0 = no limit).
625  @return The final edge product cost of the ordering. The function may be
626  called in an external loop with different seeds, and the best ordering can
627  then be retained. */
628  double GetGeckoElementOrdering(Array<int> &ordering,
629  int iterations = 4, int window = 4,
630  int period = 2, int seed = 0,
631  bool verbose = false, double time_limit = 0);
632 
633  /** Return an ordering of the elements that approximately follows the Hilbert
634  curve. The method performs a spatial (Hilbert) sort on the centers of all
635  elements and returns the resulting sequence, which can then be passed to
636  ReorderElements. This is a cheap alternative to GetGeckoElementOrdering.*/
637  void GetHilbertElementOrdering(Array<int> &ordering);
638 
639  /** Rebuilds the mesh with a different order of elements. For each element i,
640  the array ordering[i] contains its desired new index. Note that the method
641  reorders vertices, edges and faces along with the elements. */
642  void ReorderElements(const Array<int> &ordering, bool reorder_vertices = true);
643 
644  /** Creates mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into
645  nx*ny*nz hexahedra if type=HEXAHEDRON or into 6*nx*ny*nz tetrahedrons if
646  type=TETRAHEDRON. If sfc_ordering = true (default), elements are ordered
647  along a space-filling curve, instead of row by row and layer by layer.
648  The parameter @a generate_edges is ignored (for now, it is kept for
649  backward compatibility). */
650  Mesh(int nx, int ny, int nz, Element::Type type, bool generate_edges = false,
651  double sx = 1.0, double sy = 1.0, double sz = 1.0,
652  bool sfc_ordering = true)
653  {
654  Make3D(nx, ny, nz, type, sx, sy, sz, sfc_ordering);
655  Finalize(true); // refine = true
656  }
657 
658  /** Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny
659  quadrilaterals if type = QUADRILATERAL or into 2*nx*ny triangles if
660  type = TRIANGLE. If generate_edges = 0 (default) edges are not generated,
661  if 1 edges are generated. If scf_ordering = true (default), elements are
662  ordered along a space-filling curve, instead of row by row. */
663  Mesh(int nx, int ny, Element::Type type, bool generate_edges = false,
664  double sx = 1.0, double sy = 1.0, bool sfc_ordering = true)
665  {
666  Make2D(nx, ny, type, sx, sy, generate_edges, sfc_ordering);
667  Finalize(true); // refine = true
668  }
669 
670  /** Creates 1D mesh , divided into n equal intervals. */
671  explicit Mesh(int n, double sx = 1.0)
672  {
673  Make1D(n, sx);
674  // Finalize(); // reminder: not needed
675  }
676 
677  /** Creates mesh by reading a file in MFEM, Netgen, or VTK format. If
678  generate_edges = 0 (default) edges are not generated, if 1 edges are
679  generated. */
680  explicit Mesh(const char *filename, int generate_edges = 0, int refine = 1,
681  bool fix_orientation = true);
682 
683  /** Creates mesh by reading data stream in MFEM, Netgen, or VTK format. If
684  generate_edges = 0 (default) edges are not generated, if 1 edges are
685  generated. */
686  explicit Mesh(std::istream &input, int generate_edges = 0, int refine = 1,
687  bool fix_orientation = true);
688 
689  /// Create a disjoint mesh from the given mesh array
690  Mesh(Mesh *mesh_array[], int num_pieces);
691 
692  /// Create a uniformly refined (by any factor) version of @a orig_mesh.
693  /** @param[in] orig_mesh The starting coarse mesh.
694  @param[in] ref_factor The refinement factor, an integer > 1.
695  @param[in] ref_type Specify the positions of the new vertices. The
696  options are BasisType::ClosedUniform or
697  BasisType::GaussLobatto.
698 
699  The refinement data which can be accessed with GetRefinementTransforms()
700  is set to reflect the performed refinements.
701 
702  @note The constructed Mesh is linear, i.e. it does not have nodes. */
703  Mesh(Mesh *orig_mesh, int ref_factor, int ref_type);
704 
705  /** This is similar to the mesh constructor with the same arguments, but here
706  the current mesh is destroyed and another one created based on the data
707  stream again given in MFEM, Netgen, or VTK format. If generate_edges = 0
708  (default) edges are not generated, if 1 edges are generated. */
709  /// \see mfem::ifgzstream() for on-the-fly decompression of compressed ascii
710  /// inputs.
711  virtual void Load(std::istream &input, int generate_edges = 0,
712  int refine = 1, bool fix_orientation = true)
713  {
714  Loader(input, generate_edges);
715  Finalize(refine, fix_orientation);
716  }
717 
718  /// Clear the contents of the Mesh.
719  void Clear() { Destroy(); SetEmpty(); }
720 
721  /** @brief Get the mesh generator/type.
722 
723  @return A bitmask:
724  - bit 0 - simplices are present in the mesh (triangles, tets),
725  - bit 1 - tensor product elements are present in the mesh (quads, hexes),
726  - bit 2 - the mesh has wedge elements.
727 
728  In parallel, the result takes into account elements on all processors.
729  */
730  inline int MeshGenerator() { return meshgen; }
731 
732  /** @brief Returns number of vertices. Vertices are only at the corners of
733  elements, where you would expect them in the lowest-order mesh. */
734  inline int GetNV() const { return NumOfVertices; }
735 
736  /// Returns number of elements.
737  inline int GetNE() const { return NumOfElements; }
738 
739  /// Returns number of boundary elements.
740  inline int GetNBE() const { return NumOfBdrElements; }
741 
742  /// Return the number of edges.
743  inline int GetNEdges() const { return NumOfEdges; }
744 
745  /// Return the number of faces in a 3D mesh.
746  inline int GetNFaces() const { return NumOfFaces; }
747 
748  /// Return the number of faces (3D), edges (2D) or vertices (1D).
749  int GetNumFaces() const;
750 
751  /// Returns the number of faces according to the requested type.
752  /** If type==Boundary returns only the "true" number of boundary faces
753  contrary to GetNBE() that returns "fake" boundary faces associated to
754  visualization for GLVis.
755  Similarly, if type==Interior, the "fake" boundary faces associated to
756  visualization are counted as interior faces. */
757  int GetNFbyType(FaceType type) const;
758 
759  /// Utility function: sum integers from all processors (Allreduce).
760  virtual long ReduceInt(int value) const { return value; }
761 
762  /// Return the total (global) number of elements.
763  long GetGlobalNE() const { return ReduceInt(NumOfElements); }
764 
765  /** @brief Return the mesh geometric factors corresponding to the given
766  integration rule. */
768  const int flags);
769 
770  /** @brief Return the mesh geometric factors for the faces corresponding
771  to the given integration rule. */
773  const int flags,
774  FaceType type);
775 
776  /// Destroy all GeometricFactors stored by the Mesh.
777  /** This method can be used to force recomputation of the GeometricFactors,
778  for example, after the mesh nodes are modified externally. */
779  void DeleteGeometricFactors();
780 
781  /// Equals 1 + num_holes - num_loops
782  inline int EulerNumber() const
784  /// Equals 1 - num_holes
785  inline int EulerNumber2D() const
786  { return NumOfVertices - NumOfEdges + NumOfElements; }
787 
788  int Dimension() const { return Dim; }
789  int SpaceDimension() const { return spaceDim; }
790 
791  /// @brief Return pointer to vertex i's coordinates.
792  /// @warning For high-order meshes (when #Nodes != NULL) vertices may not be
793  /// updated and should not be used!
794  const double *GetVertex(int i) const { return vertices[i](); }
795 
796  /// @brief Return pointer to vertex i's coordinates.
797  /// @warning For high-order meshes (when Nodes != NULL) vertices may not
798  /// being updated and should not be used!
799  double *GetVertex(int i) { return vertices[i](); }
800 
801  void GetElementData(int geom, Array<int> &elem_vtx, Array<int> &attr) const
802  { GetElementData(elements, geom, elem_vtx, attr); }
803 
804  void GetBdrElementData(int geom, Array<int> &bdr_elem_vtx,
805  Array<int> &bdr_attr) const
806  { GetElementData(boundary, geom, bdr_elem_vtx, bdr_attr); }
807 
808  /** @brief Set the internal Vertex array to point to the given @a vertices
809  array without assuming ownership of the pointer. */
810  /** If @a zerocopy is `true`, the vertices must be given as an array of 3
811  doubles per vertex. If @a zerocopy is `false` then the current Vertex
812  data is first copied to the @a vertices array. */
813  void ChangeVertexDataOwnership(double *vertices, int len_vertices,
814  bool zerocopy = false);
815 
816  const Element* const *GetElementsArray() const
817  { return elements.GetData(); }
818 
819  const Element *GetElement(int i) const { return elements[i]; }
820 
821  Element *GetElement(int i) { return elements[i]; }
822 
823  const Element *GetBdrElement(int i) const { return boundary[i]; }
824 
825  Element *GetBdrElement(int i) { return boundary[i]; }
826 
827  const Element *GetFace(int i) const { return faces[i]; }
828 
830  {
831  return faces[i]->GetGeometryType();
832  }
833 
835  {
836  return elements[i]->GetGeometryType();
837  }
838 
840  {
841  return boundary[i]->GetGeometryType();
842  }
843 
844  /** @brief Return true iff the given @a geom is encountered in the mesh.
845  Geometries of dimensions lower than Dimension() are counted as well. */
847  { return mesh_geoms & (1 << geom); }
848 
849  /** @brief Return the number of geometries of the given dimension present in
850  the mesh. */
851  /** For a parallel mesh only the local geometries are counted. */
852  int GetNumGeometries(int dim) const;
853 
854  /// Return all element geometries of the given dimension present in the mesh.
855  /** For a parallel mesh only the local geometries are returned.
856 
857  The returned geometries are sorted. */
858  void GetGeometries(int dim, Array<Geometry::Type> &el_geoms) const;
859 
860  /// List of mesh geometries stored as Array<Geometry::Type>.
861  class GeometryList : public Array<Geometry::Type>
862  {
863  protected:
865  public:
866  /// Construct a GeometryList of all element geometries in @a mesh.
868  : Array<Geometry::Type>(geom_buf, Geometry::NumGeom)
869  { mesh.GetGeometries(mesh.Dimension(), *this); }
870  /** @brief Construct a GeometryList of all geometries of dimension @a dim
871  in @a mesh. */
872  GeometryList(Mesh &mesh, int dim)
873  : Array<Geometry::Type>(geom_buf, Geometry::NumGeom)
874  { mesh.GetGeometries(dim, *this); }
875  };
876 
877  /// Returns the indices of the vertices of element i.
878  void GetElementVertices(int i, Array<int> &v) const
879  { elements[i]->GetVertices(v); }
880 
881  /// Returns the indices of the vertices of boundary element i.
882  void GetBdrElementVertices(int i, Array<int> &v) const
883  { boundary[i]->GetVertices(v); }
884 
885  /// Return the indices and the orientations of all edges of element i.
886  void GetElementEdges(int i, Array<int> &edges, Array<int> &cor) const;
887 
888  /// Return the indices and the orientations of all edges of bdr element i.
889  void GetBdrElementEdges(int i, Array<int> &edges, Array<int> &cor) const;
890 
891  /** Return the indices and the orientations of all edges of face i.
892  Works for both 2D (face=edge) and 3D faces. */
893  void GetFaceEdges(int i, Array<int> &, Array<int> &) const;
894 
895  /// Returns the indices of the vertices of face i.
896  void GetFaceVertices(int i, Array<int> &vert) const
897  {
898  if (Dim == 1)
899  {
900  vert.SetSize(1); vert[0] = i;
901  }
902  else
903  {
904  faces[i]->GetVertices(vert);
905  }
906  }
907 
908  /// Returns the indices of the vertices of edge i.
909  void GetEdgeVertices(int i, Array<int> &vert) const;
910 
911  /// Returns the face-to-edge Table (3D)
912  Table *GetFaceEdgeTable() const;
913 
914  /// Returns the edge-to-vertex Table (3D)
915  Table *GetEdgeVertexTable() const;
916 
917  /// Return the indices and the orientations of all faces of element i.
918  void GetElementFaces(int i, Array<int> &, Array<int> &) const;
919 
920  /// Return the index and the orientation of the face of bdr element i. (3D)
921  void GetBdrElementFace(int i, int *, int *) const;
922 
923  /** Return the vertex index of boundary element i. (1D)
924  Return the edge index of boundary element i. (2D)
925  Return the face index of boundary element i. (3D) */
926  int GetBdrElementEdgeIndex(int i) const;
927 
928  /** @brief For the given boundary element, bdr_el, return its adjacent
929  element and its info, i.e. 64*local_bdr_index+bdr_orientation. */
930  void GetBdrElementAdjacentElement(int bdr_el, int &el, int &info) const;
931 
932  /// Returns the type of element i.
933  Element::Type GetElementType(int i) const;
934 
935  /// Returns the type of boundary element i.
936  Element::Type GetBdrElementType(int i) const;
937 
938  /* Return point matrix of element i of dimension Dim X #v, where for every
939  vertex we give its coordinates in space of dimension Dim. */
940  void GetPointMatrix(int i, DenseMatrix &pointmat) const;
941 
942  /* Return point matrix of boundary element i of dimension Dim X #v, where for
943  every vertex we give its coordinates in space of dimension Dim. */
944  void GetBdrPointMatrix(int i, DenseMatrix &pointmat) const;
945 
947 
948  /** Builds the transformation defining the i-th element in the user-defined
949  variable. */
951 
952  /// Returns the transformation defining the i-th element
954 
955  /** Return the transformation defining the i-th element assuming
956  the position of the vertices/nodes are given by 'nodes'. */
957  void GetElementTransformation(int i, const Vector &nodes,
959 
960  /// Returns the transformation defining the i-th boundary element
963 
964  /** @brief Returns the transformation defining the given face element in a
965  user-defined variable. */
967 
968  /** @brief A helper method that constructs a transformation from the
969  reference space of a face to the reference space of an element. */
970  /** The local index of the face as a face in the element and its orientation
971  are given by the input parameter @a info, as @a info = 64*loc_face_idx +
972  loc_face_orientation. */
973  void GetLocalFaceTransformation(int face_type, int elem_type,
975  int info);
976 
977  /// Returns the transformation defining the given face element
979 
980  /** Returns the transformation defining the given edge element.
981  The transformation is stored in a user-defined variable. */
983 
984  /// Returns the transformation defining the given face element
986 
987  /// Returns (a pointer to an object containing) the following data:
988  ///
989  /// 1) Elem1No - the index of the first element that contains this face this
990  /// is the element that has the same outward unit normal vector as the
991  /// face;
992  ///
993  /// 2) Elem2No - the index of the second element that contains this face this
994  /// element has outward unit normal vector as the face multiplied with -1;
995  ///
996  /// 3) Elem1, Elem2 - pointers to the ElementTransformation's of the first
997  /// and the second element respectively;
998  ///
999  /// 4) Face - pointer to the ElementTransformation of the face;
1000  ///
1001  /// 5) Loc1, Loc2 - IntegrationPointTransformation's mapping the face
1002  /// coordinate system to the element coordinate system (both in their
1003  /// reference elements). Used to transform IntegrationPoints from face to
1004  /// element. More formally, let:
1005  /// TL1, TL2 be the transformations represented by Loc1, Loc2,
1006  /// TE1, TE2 - the transformations represented by Elem1, Elem2,
1007  /// TF - the transformation represented by Face, then
1008  /// TF(x) = TE1(TL1(x)) = TE2(TL2(x)) for all x in the reference face.
1009  ///
1010  /// 6) FaceGeom - the base geometry for the face.
1011  ///
1012  /// The mask specifies which fields in the structure to return:
1013  /// mask & 1 - Elem1, mask & 2 - Elem2
1014  /// mask & 4 - Loc1, mask & 8 - Loc2, mask & 16 - Face.
1015  /// These mask values are defined in the ConfigMasks enum type as part of the
1016  /// FaceElementTransformations class in fem/eltrans.hpp.
1018  int mask = 31);
1019 
1021  {
1022  if (faces_info[FaceNo].Elem2No < 0) { return NULL; }
1023  return GetFaceElementTransformations (FaceNo);
1024  }
1025 
1027 
1028  /// Return true if the given face is interior. @sa FaceIsTrueInterior().
1029  bool FaceIsInterior(int FaceNo) const
1030  {
1031  return (faces_info[FaceNo].Elem2No >= 0);
1032  }
1033  void GetFaceElements (int Face, int *Elem1, int *Elem2) const;
1034  void GetFaceInfos (int Face, int *Inf1, int *Inf2) const;
1035 
1036  Geometry::Type GetFaceGeometryType(int Face) const;
1037  Element::Type GetFaceElementType(int Face) const;
1038 
1039  /// Check the orientation of the elements
1040  /** @return The number of elements with wrong orientation. */
1041  int CheckElementOrientation(bool fix_it = true);
1042  /// Check the orientation of the boundary elements
1043  /** @return The number of boundary elements with wrong orientation. */
1044  int CheckBdrElementOrientation(bool fix_it = true);
1045 
1046  /// Return the attribute of element i.
1047  int GetAttribute(int i) const { return elements[i]->GetAttribute(); }
1048 
1049  /// Set the attribute of element i.
1050  void SetAttribute(int i, int attr) { elements[i]->SetAttribute(attr); }
1051 
1052  /// Return the attribute of boundary element i.
1053  int GetBdrAttribute(int i) const { return boundary[i]->GetAttribute(); }
1054 
1055  const Table &ElementToElementTable();
1056 
1057  const Table &ElementToFaceTable() const;
1058 
1059  const Table &ElementToEdgeTable() const;
1060 
1061  /// The returned Table must be destroyed by the caller
1063 
1064  /** Return the "face"-element Table. Here "face" refers to face (3D),
1065  edge (2D), or vertex (1D).
1066  The returned Table must be destroyed by the caller. */
1067  Table *GetFaceToElementTable() const;
1068 
1069  /** This method modifies a tetrahedral mesh so that Nedelec spaces of order
1070  greater than 1 can be defined on the mesh. Specifically, we
1071  1) rotate all tets in the mesh so that the vertices {v0, v1, v2, v3}
1072  satisfy: v0 < v1 < min(v2, v3).
1073  2) rotate all boundary triangles so that the vertices {v0, v1, v2}
1074  satisfy: v0 < min(v1, v2).
1075 
1076  @note Refinement does not work after a call to this method! */
1077  virtual void ReorientTetMesh();
1078 
1079  int *CartesianPartitioning(int nxyz[]);
1080  int *GeneratePartitioning(int nparts, int part_method = 1);
1081  void CheckPartitioning(int *partitioning);
1082 
1083  void CheckDisplacements(const Vector &displacements, double &tmax);
1084 
1085  // Vertices are only at the corners of elements, where you would expect them
1086  // in the lowest-order mesh.
1087  void MoveVertices(const Vector &displacements);
1088  void GetVertices(Vector &vert_coord) const;
1089  void SetVertices(const Vector &vert_coord);
1090 
1091  // Nodes are only active for higher order meshes, and share locations with
1092  // the vertices, plus all the higher- order control points within the element
1093  // and along the edges and on the faces.
1094  void GetNode(int i, double *coord) const;
1095  void SetNode(int i, const double *coord);
1096 
1097  // Node operations for curved mesh.
1098  // They call the corresponding '...Vertices' method if the
1099  // mesh is not curved (i.e. Nodes == NULL).
1100  void MoveNodes(const Vector &displacements);
1101  void GetNodes(Vector &node_coord) const;
1102  void SetNodes(const Vector &node_coord);
1103 
1104  /// Return a pointer to the internal node GridFunction (may be NULL).
1105  GridFunction *GetNodes() { return Nodes; }
1106  const GridFunction *GetNodes() const { return Nodes; }
1107  /// Return the mesh nodes ownership flag.
1108  bool OwnsNodes() const { return own_nodes; }
1109  /// Set the mesh nodes ownership flag.
1110  void SetNodesOwner(bool nodes_owner) { own_nodes = nodes_owner; }
1111  /// Replace the internal node GridFunction with the given GridFunction.
1112  void NewNodes(GridFunction &nodes, bool make_owner = false);
1113  /** Swap the internal node GridFunction pointer and ownership flag members
1114  with the given ones. */
1115  void SwapNodes(GridFunction *&nodes, int &own_nodes_);
1116 
1117  /// Return the mesh nodes/vertices projected on the given GridFunction.
1118  void GetNodes(GridFunction &nodes) const;
1119  /** Replace the internal node GridFunction with a new GridFunction defined
1120  on the given FiniteElementSpace. The new node coordinates are projected
1121  (derived) from the current nodes/vertices. */
1122  void SetNodalFESpace(FiniteElementSpace *nfes);
1123  /** Replace the internal node GridFunction with the given GridFunction. The
1124  given GridFunction is updated with node coordinates projected (derived)
1125  from the current nodes/vertices. */
1126  void SetNodalGridFunction(GridFunction *nodes, bool make_owner = false);
1127  /** Return the FiniteElementSpace on which the current mesh nodes are
1128  defined or NULL if the mesh does not have nodes. */
1129  const FiniteElementSpace *GetNodalFESpace() const;
1130  /** Make sure that the mesh has valid nodes, i.e. its geometry is described
1131  by a vector finite element grid function (even if it is a low-order mesh
1132  with straight edges). */
1133  void EnsureNodes();
1134 
1135  /** Set the curvature of the mesh nodes using the given polynomial degree,
1136  'order', and optionally: discontinuous or continuous FE space, 'discont',
1137  new space dimension, 'space_dim' (if != -1), and 'ordering'. */
1138  virtual void SetCurvature(int order, bool discont = false, int space_dim = -1,
1139  int ordering = 1);
1140 
1141  /// Refine all mesh elements.
1142  /** @param[in] ref_algo %Refinement algorithm. Currently used only for pure
1143  tetrahedral meshes. If set to zero (default), a tet mesh will be refined
1144  using algorithm A, that produces elements with better quality compared to
1145  algorithm B used when the parameter is non-zero.
1146 
1147  For tetrahedral meshes, after using algorithm A, the mesh cannot be
1148  refined locally using methods like GeneralRefinement() unless it is
1149  re-finalized using Finalize() with the parameter @a refine set to true.
1150  Note that calling Finalize() in this way will generally invalidate any
1151  FiniteElementSpace%s and GridFunction%s defined on the mesh. */
1152  void UniformRefinement(int ref_algo = 0);
1153 
1154  /** Refine selected mesh elements. Refinement type can be specified for each
1155  element. The function can do conforming refinement of triangles and
1156  tetrahedra and non-conforming refinement (i.e., with hanging-nodes) of
1157  triangles, quadrilaterals and hexahedra. If 'nonconforming' = -1,
1158  suitable refinement method is selected automatically (namely, conforming
1159  refinement for triangles). Use nonconforming = 0/1 to force the method.
1160  For nonconforming refinements, nc_limit optionally specifies the maximum
1161  level of hanging nodes (unlimited by default). */
1162  void GeneralRefinement(const Array<Refinement> &refinements,
1163  int nonconforming = -1, int nc_limit = 0);
1164 
1165  /** Simplified version of GeneralRefinement taking a simple list of elements
1166  to refine, without refinement types. */
1167  void GeneralRefinement(const Array<int> &el_to_refine,
1168  int nonconforming = -1, int nc_limit = 0);
1169 
1170  /// Refine each element with given probability. Uses GeneralRefinement.
1171  void RandomRefinement(double prob, bool aniso = false,
1172  int nonconforming = -1, int nc_limit = 0);
1173 
1174  /// Refine elements sharing the specified vertex. Uses GeneralRefinement.
1175  void RefineAtVertex(const Vertex& vert,
1176  double eps = 0.0, int nonconforming = -1);
1177 
1178  /** Refine element i if elem_error[i] > threshold, for all i.
1179  Returns true if at least one element was refined, false otherwise. */
1180  bool RefineByError(const Array<double> &elem_error, double threshold,
1181  int nonconforming = -1, int nc_limit = 0);
1182 
1183  /** Refine element i if elem_error(i) > threshold, for all i.
1184  Returns true if at least one element was refined, false otherwise. */
1185  bool RefineByError(const Vector &elem_error, double threshold,
1186  int nonconforming = -1, int nc_limit = 0);
1187 
1188  /** Derefine the mesh based on an error measure associated with each
1189  element. A derefinement is performed if the sum of errors of its fine
1190  elements is smaller than 'threshold'. If 'nc_limit' > 0, derefinements
1191  that would increase the maximum level of hanging nodes of the mesh are
1192  skipped. Returns true if the mesh changed, false otherwise. */
1193  bool DerefineByError(Array<double> &elem_error, double threshold,
1194  int nc_limit = 0, int op = 1);
1195 
1196  /// Same as DerefineByError for an error vector.
1197  bool DerefineByError(const Vector &elem_error, double threshold,
1198  int nc_limit = 0, int op = 1);
1199 
1200  ///@{ @name NURBS mesh refinement methods
1201  void KnotInsert(Array<KnotVector *> &kv);
1202  void KnotInsert(Array<Vector *> &kv);
1203  /* For each knot vector:
1204  new_degree = max(old_degree, min(old_degree + rel_degree, degree)). */
1205  void DegreeElevate(int rel_degree, int degree = 16);
1206  ///@}
1207 
1208  /** Make sure that a quad/hex mesh is considered to be non-conforming (i.e.,
1209  has an associated NCMesh object). Simplex meshes can be both conforming
1210  (default) or non-conforming. */
1211  void EnsureNCMesh(bool simplices_nonconforming = false);
1212 
1213  bool Conforming() const { return ncmesh == NULL; }
1214  bool Nonconforming() const { return ncmesh != NULL; }
1215 
1216  /** Return fine element transformations following a mesh refinement.
1217  Space uses this to construct a global interpolation matrix. */
1219 
1220  /// Return type of last modification of the mesh.
1222 
1223  /** Return update counter. The counter starts at zero and is incremented
1224  each time refinement, derefinement, or rebalancing method is called.
1225  It is used for checking proper sequence of Space:: and GridFunction::
1226  Update() calls. */
1227  long GetSequence() const { return sequence; }
1228 
1229  /// Print the mesh to the given stream using Netgen/Truegrid format.
1230  virtual void PrintXG(std::ostream &out = mfem::out) const;
1231 
1232  /// Print the mesh to the given stream using the default MFEM mesh format.
1233  /// \see mfem::ofgzstream() for on-the-fly compression of ascii outputs
1234  virtual void Print(std::ostream &out = mfem::out) const { Printer(out); }
1235 
1236  /// Print the mesh to the given stream using the adios2 bp format
1237 #ifdef MFEM_USE_ADIOS2
1238  virtual void Print(adios2stream &out) const;
1239 #endif
1240  /// Print the mesh in VTK format (linear and quadratic meshes only).
1241  /// \see mfem::ofgzstream() for on-the-fly compression of ascii outputs
1242  void PrintVTK(std::ostream &out);
1243  /** Print the mesh in VTK format. The parameter ref > 0 specifies an element
1244  subdivision number (useful for high order fields and curved meshes).
1245  If the optional field_data is set, we also add a FIELD section in the
1246  beginning of the file with additional dataset information. */
1247  /// \see mfem::ofgzstream() for on-the-fly compression of ascii outputs
1248  void PrintVTK(std::ostream &out, int ref, int field_data=0);
1249  /** Print the mesh in VTU format. The parameter ref > 0 specifies an element
1250  subdivision number (useful for high order fields and curved meshes).
1251  If @a bdr_elements is true, then output (only) the boundary elements,
1252  otherwise output only the non-boundary elements. */
1253  void PrintVTU(std::ostream &out,
1254  int ref=1,
1255  VTKFormat format=VTKFormat::ASCII,
1256  bool high_order_output=false,
1257  int compression_level=0,
1258  bool bdr_elements=false);
1259  /** Print the mesh in VTU format with file name fname. */
1260  virtual void PrintVTU(std::string fname,
1261  VTKFormat format=VTKFormat::ASCII,
1262  bool high_order_output=false,
1263  int compression_level=0,
1264  bool bdr=false);
1265  /** Print the boundary elements of the mesh in VTU format, and output the
1266  boundary attributes as a data array (useful for boundary conditions). */
1267  void PrintBdrVTU(std::string fname,
1268  VTKFormat format=VTKFormat::ASCII,
1269  bool high_order_output=false,
1270  int compression_level=0);
1271 
1272  void GetElementColoring(Array<int> &colors, int el0 = 0);
1273 
1274  /** @brief Prints the mesh with boundary elements given by the boundary of
1275  the subdomains, so that the boundary of subdomain i has boundary
1276  attribute i+1. */
1277  /// \see mfem::ofgzstream() for on-the-fly compression of ascii outputs
1278  void PrintWithPartitioning (int *partitioning,
1279  std::ostream &out, int elem_attr = 0) const;
1280 
1281  void PrintElementsWithPartitioning (int *partitioning,
1282  std::ostream &out,
1283  int interior_faces = 0);
1284 
1285  /// Print set of disjoint surfaces:
1286  /*!
1287  * If Aface_face(i,j) != 0, print face j as a boundary
1288  * element with attribute i+1.
1289  */
1290  void PrintSurfaces(const Table &Aface_face, std::ostream &out) const;
1291 
1292  void ScaleSubdomains (double sf);
1293  void ScaleElements (double sf);
1294 
1295  void Transform(void (*f)(const Vector&, Vector&));
1296  void Transform(VectorCoefficient &deformation);
1297 
1298  /// Remove unused vertices and rebuild mesh connectivity.
1299  void RemoveUnusedVertices();
1300 
1301  /** Remove boundary elements that lie in the interior of the mesh, i.e. that
1302  have two adjacent faces in 3D, or edges in 2D. */
1303  void RemoveInternalBoundaries();
1304 
1305  /** @brief Get the size of the i-th element relative to the perfect
1306  reference element. */
1307  double GetElementSize(int i, int type = 0);
1308 
1309  double GetElementSize(int i, const Vector &dir);
1310 
1311  double GetElementVolume(int i);
1312 
1313  void GetElementCenter(int i, Vector &center);
1314 
1315  /// Returns the minimum and maximum corners of the mesh bounding box.
1316  /** For high-order meshes, the geometry is first refined @a ref times. */
1317  void GetBoundingBox(Vector &min, Vector &max, int ref = 2);
1318 
1319  void GetCharacteristics(double &h_min, double &h_max,
1320  double &kappa_min, double &kappa_max,
1321  Vector *Vh = NULL, Vector *Vk = NULL);
1322 
1323  /// Auxiliary method used by PrintCharacteristics().
1324  /** It is also used in the `mesh-explorer` miniapp. */
1325  static void PrintElementsByGeometry(int dim,
1326  const Array<int> &num_elems_by_geom,
1327  std::ostream &out);
1328 
1329  /** @brief Compute and print mesh characteristics such as number of vertices,
1330  number of elements, number of boundary elements, minimal and maximal
1331  element sizes, minimal and maximal element aspect ratios, etc. */
1332  /** If @a Vh or @a Vk are not NULL, return the element sizes and aspect
1333  ratios for all elements in the given Vector%s. */
1334  void PrintCharacteristics(Vector *Vh = NULL, Vector *Vk = NULL,
1335  std::ostream &out = mfem::out);
1336 
1337  /** @brief In serial, this method calls PrintCharacteristics(). In parallel,
1338  additional information about the parallel decomposition is also printed.
1339  */
1340  virtual void PrintInfo(std::ostream &out = mfem::out)
1341  {
1342  PrintCharacteristics(NULL, NULL, out);
1343  }
1344 
1345  void MesquiteSmooth(const int mesquite_option = 0);
1346 
1347  /** @brief Find the ids of the elements that contain the given points, and
1348  their corresponding reference coordinates.
1349 
1350  The DenseMatrix @a point_mat describes the given points - one point for
1351  each column; it should have SpaceDimension() rows.
1352 
1353  The InverseElementTransformation object, @a inv_trans, is used to attempt
1354  the element transformation inversion. If NULL pointer is given, the
1355  method will use a default constructed InverseElementTransformation. Note
1356  that the algorithms in the base class InverseElementTransformation can be
1357  completely overwritten by deriving custom classes that override the
1358  Transform() method.
1359 
1360  If no element is found for the i-th point, elem_ids[i] is set to -1.
1361 
1362  In the ParMesh implementation, the @a point_mat is expected to be the
1363  same on all ranks. If the i-th point is found by multiple ranks, only one
1364  of them will mark that point as found, i.e. set its elem_ids[i] to a
1365  non-negative number; the other ranks will set their elem_ids[i] to -2 to
1366  indicate that the point was found but assigned to another rank.
1367 
1368  @returns The total number of points that were found.
1369 
1370  @note This method is not 100 percent reliable, i.e. it is not guaranteed
1371  to find a point, even if it lies inside a mesh element. */
1372  virtual int FindPoints(DenseMatrix& point_mat, Array<int>& elem_ids,
1373  Array<IntegrationPoint>& ips, bool warn = true,
1374  InverseElementTransformation *inv_trans = NULL);
1375 
1376  /// Destroys Mesh.
1377  virtual ~Mesh() { DestroyPointers(); }
1378 
1379 #ifdef MFEM_DEBUG
1380  /// Output an NCMesh-compatible debug dump.
1381  void DebugDump(std::ostream &out) const;
1382 #endif
1383 };
1384 
1385 /** Overload operator<< for std::ostream and Mesh; valid also for the derived
1386  class ParMesh */
1387 std::ostream &operator<<(std::ostream &out, const Mesh &mesh);
1388 
1389 
1390 /** @brief Structure for storing mesh geometric factors: coordinates, Jacobians,
1391  and determinants of the Jacobians. */
1392 /** Typically objects of this type are constructed and owned by objects of class
1393  Mesh. See Mesh::GetGeometricFactors(). */
1395 {
1396 public:
1397  const Mesh *mesh;
1400 
1402  {
1403  COORDINATES = 1 << 0,
1404  JACOBIANS = 1 << 1,
1405  DETERMINANTS = 1 << 2,
1406  };
1407 
1408  GeometricFactors(const Mesh *mesh, const IntegrationRule &ir, int flags);
1409 
1410  /// Mapped (physical) coordinates of all quadrature points.
1411  /** This array uses a column-major layout with dimensions (NQ x SDIM x NE)
1412  where
1413  - NQ = number of quadrature points per element,
1414  - SDIM = space dimension of the mesh = mesh.SpaceDimension(), and
1415  - NE = number of elements in the mesh. */
1417 
1418  /// Jacobians of the element transformations at all quadrature points.
1419  /** This array uses a column-major layout with dimensions (NQ x SDIM x DIM x
1420  NE) where
1421  - NQ = number of quadrature points per element,
1422  - SDIM = space dimension of the mesh = mesh.SpaceDimension(),
1423  - DIM = dimension of the mesh = mesh.Dimension(), and
1424  - NE = number of elements in the mesh. */
1426 
1427  /// Determinants of the Jacobians at all quadrature points.
1428  /** This array uses a column-major layout with dimensions (NQ x NE) where
1429  - NQ = number of quadrature points per element, and
1430  - NE = number of elements in the mesh. */
1432 };
1433 
1434 /** @brief Structure for storing face geometric factors: coordinates, Jacobians,
1435  determinants of the Jacobians, and normal vectors. */
1436 /** Typically objects of this type are constructed and owned by objects of class
1437  Mesh. See Mesh::GetFaceGeometricFactors(). */
1439 {
1440 public:
1441  const Mesh *mesh;
1445 
1447  {
1448  COORDINATES = 1 << 0,
1449  JACOBIANS = 1 << 1,
1450  DETERMINANTS = 1 << 2,
1451  NORMALS = 1 << 3,
1452  };
1453 
1454  FaceGeometricFactors(const Mesh *mesh, const IntegrationRule &ir, int flags,
1455  FaceType type);
1456 
1457  /// Mapped (physical) coordinates of all quadrature points.
1458  /** This array uses a column-major layout with dimensions (NQ x SDIM x NF)
1459  where
1460  - NQ = number of quadrature points per face,
1461  - SDIM = space dimension of the mesh = mesh.SpaceDimension(), and
1462  - NF = number of faces in the mesh. */
1464 
1465  /// Jacobians of the element transformations at all quadrature points.
1466  /** This array uses a column-major layout with dimensions (NQ x SDIM x DIM x
1467  NF) where
1468  - NQ = number of quadrature points per face,
1469  - SDIM = space dimension of the mesh = mesh.SpaceDimension(),
1470  - DIM = dimension of the mesh = mesh.Dimension(), and
1471  - NF = number of faces in the mesh. */
1473 
1474  /// Determinants of the Jacobians at all quadrature points.
1475  /** This array uses a column-major layout with dimensions (NQ x NF) where
1476  - NQ = number of quadrature points per face, and
1477  - NF = number of faces in the mesh. */
1479 
1480  /// Normals at all quadrature points.
1481  /** This array uses a column-major layout with dimensions (NQ x DIM x NF) where
1482  - NQ = number of quadrature points per face,
1483  - SDIM = space dimension of the mesh = mesh.SpaceDimension(), and
1484  - NF = number of faces in the mesh. */
1486 };
1487 
1488 /// Class used to extrude the nodes of a mesh
1490 {
1491 private:
1492  int n, layer;
1493  double p[2], s;
1494  Vector tip;
1495 public:
1496  NodeExtrudeCoefficient(const int dim, const int _n, const double _s);
1497  void SetLayer(const int l) { layer = l; }
1499  virtual void Eval(Vector &V, ElementTransformation &T,
1500  const IntegrationPoint &ip);
1502 };
1503 
1504 
1505 /// Extrude a 1D mesh
1506 Mesh *Extrude1D(Mesh *mesh, const int ny, const double sy,
1507  const bool closed = false);
1508 
1509 /// Extrude a 2D mesh
1510 Mesh *Extrude2D(Mesh *mesh, const int nz, const double sz);
1511 
1512 // shift cyclically 3 integers left-to-right
1513 inline void ShiftRight(int &a, int &b, int &c)
1514 {
1515  int t = a;
1516  a = c; c = b; b = t;
1517 }
1518 
1519 }
1520 
1521 #endif
Abstract class for all finite elements.
Definition: fe.hpp:235
const IntegrationRule * IntRule
Definition: mesh.hpp:1442
void Loader(std::istream &input, int generate_edges=0, std::string parse_tag="")
Definition: mesh.cpp:3415
double GetGeckoElementOrdering(Array< int > &ordering, int iterations=4, int window=4, int period=2, int seed=0, bool verbose=false, double time_limit=0)
Definition: mesh.cpp:1609
void GetFaceEdges(int i, Array< int > &, Array< int > &) const
Definition: mesh.cpp:4775
void PrintSurfaces(const Table &Aface_face, std::ostream &out) const
Print set of disjoint surfaces:
Definition: mesh.cpp:10085
void GetPointMatrix(int i, DenseMatrix &pointmat) const
Definition: mesh.cpp:5040
static const int vtk_quadratic_hex[27]
Definition: mesh.hpp:181
virtual void Print(std::ostream &out=mfem::out) const
Definition: mesh.hpp:1234
int * CartesianPartitioning(int nxyz[])
Definition: mesh.cpp:5693
Class for an integration rule - an Array of IntegrationPoint.
Definition: intrules.hpp:90
const DenseMatrix * PointMatrix
Definition: mesh.hpp:144
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
Definition: mesh.hpp:1053
const double * GetVertex(int i) const
Return pointer to vertex i&#39;s coordinates.
Definition: mesh.hpp:794
void ScaleElements(double sf)
Definition: mesh.cpp:10222
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:30
Table * GetEdgeVertexTable() const
Returns the edge-to-vertex Table (3D)
Definition: mesh.cpp:4842
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:4743
void ReadVTKMesh(std::istream &input, int &curved, int &read_gf, bool &finalize_topo)
void FreeElement(Element *E)
Definition: mesh.cpp:10536
int AddQuad(int v1, int v2, int v3, int v4, int attr=1)
Definition: mesh.cpp:1293
int CheckElementOrientation(bool fix_it=true)
Check the orientation of the elements.
Definition: mesh.cpp:4222
static bool remove_unused_vertices
Definition: mesh.hpp:215
void SetVertices(const Vector &vert_coord)
Definition: mesh.cpp:6543
static const int vtk_quadratic_tet[10]
Definition: mesh.hpp:179
void GetEdgeVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of edge i.
Definition: mesh.cpp:4805
void Make2D(int nx, int ny, Element::Type type, double sx, double sy, bool generate_edges, bool sfc_ordering)
Definition: mesh.cpp:2864
bool FaceIsTrueInterior(int FaceNo) const
Definition: mesh.hpp:415
Vector J
Jacobians of the element transformations at all quadrature points.
Definition: mesh.hpp:1472
Vector X
Mapped (physical) coordinates of all quadrature points.
Definition: mesh.hpp:1416
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
Definition: mesh.cpp:10784
Base class for vector Coefficients that optionally depend on time and space.
void UniformRefinement3D_base(Array< int > *f2qf=NULL, DSTable *v_to_v_p=NULL, bool update_nodes=true)
Definition: mesh.cpp:6840
long GetGlobalNE() const
Return the total (global) number of elements.
Definition: mesh.hpp:763
static void PrintElementsByGeometry(int dim, const Array< int > &num_elems_by_geom, std::ostream &out)
Auxiliary method used by PrintCharacteristics().
Definition: mesh.cpp:217
void AddHexAsTets(const int *vi, int attr=1)
Definition: mesh.cpp:1358
static const int NumGeom
Definition: geom.hpp:41
void AddHexAsWedges(const int *vi, int attr=1)
Definition: mesh.cpp:1377
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 ...
Array< Element * > boundary
Definition: mesh.hpp:91
Geometry::Constants< Geometry::SQUARE > quad_t
Definition: mesh.hpp:191
int * GeneratePartitioning(int nparts, int part_method=1)
Definition: mesh.cpp:5732
CoarseFineTransformations CoarseFineTr
Definition: mesh.hpp:171
int own_nodes
Definition: mesh.hpp:177
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
Definition: mesh.cpp:4697
bool Conforming() const
Definition: mesh.hpp:1213
void MoveVertices(const Vector &displacements)
Definition: mesh.cpp:6523
int GetNBE() const
Returns number of boundary elements.
Definition: mesh.hpp:740
IsoparametricTransformation Transformation
Definition: mesh.hpp:165
void GetLocalPtToSegTransformation(IsoparametricTransformation &, int)
Used in GetFaceElementTransformations (...)
Definition: mesh.cpp:617
void GetCharacteristics(double &h_min, double &h_max, double &kappa_min, double &kappa_max, Vector *Vh=NULL, Vector *Vk=NULL)
Definition: mesh.cpp:182
void PrintWithPartitioning(int *partitioning, std::ostream &out, 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:9594
const Geometry::Type geom
Definition: ex1.cpp:40
static FiniteElement * GetTransformationFEforElementType(Element::Type)
Definition: mesh.cpp:316
void NewNodes(GridFunction &nodes, bool make_owner=false)
Replace the internal node GridFunction with the given GridFunction.
Definition: mesh.cpp:6627
int NumOfEdges
Definition: mesh.hpp:70
virtual void UniformRefinement2D()
Refine a mixed 2D mesh uniformly.
Definition: mesh.hpp:316
void SwapNodes(GridFunction *&nodes, int &own_nodes_)
Definition: mesh.cpp:6641
void GetElementFaces(int i, Array< int > &, Array< int > &) const
Return the indices and the orientations of all faces of element i.
Definition: mesh.cpp:4937
Element::Type GetElementType(int i) const
Returns the type of element i.
Definition: mesh.cpp:5030
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
Definition: mesh.cpp:118
void ReadNetgen2DMesh(std::istream &input, int &curved)
void ShiftRight(int &a, int &b, int &c)
Definition: mesh.hpp:1513
Element::Type GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition: mesh.cpp:5035
int EulerNumber2D() const
Equals 1 - num_holes.
Definition: mesh.hpp:785
A specialized ElementTransformation class representing a face and its two neighboring elements...
Definition: eltrans.hpp:467
int AddTriangle(int v1, int v2, int v3, int attr=1)
Definition: mesh.cpp:1279
Vector detJ
Determinants of the Jacobians at all quadrature points.
Definition: mesh.hpp:1478
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:4708
void DeleteTables()
Definition: mesh.hpp:224
void GetFaceVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of face i.
Definition: mesh.hpp:896
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
const FaceGeometricFactors * GetFaceGeometricFactors(const IntegrationRule &ir, const int flags, FaceType type)
Return the mesh geometric factors for the faces corresponding to the given integration rule...
Definition: mesh.cpp:787
GridFunction * Nodes
Definition: mesh.hpp:176
int NumOfElements
Definition: mesh.hpp:69
Mesh * Extrude1D(Mesh *mesh, const int ny, const double sy, const bool closed)
Extrude a 1D mesh.
Definition: mesh.cpp:10802
void Transform(void(*f)(const Vector &, Vector &))
Definition: mesh.cpp:10292
void FinalizeCheck()
Definition: mesh.cpp:1504
void ApplyLocalSlaveTransformation(FaceElementTransformations &FT, const FaceInfo &fi, bool is_ghost)
Definition: mesh.cpp:964
int GetBdrElementEdgeIndex(int i) const
Definition: mesh.cpp:4998
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:6651
int GetNE() const
Returns number of elements.
Definition: mesh.hpp:737
const Element * GetFace(int i) const
Definition: mesh.hpp:827
void FinalizeWedgeMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a wedge Mesh.
Definition: mesh.cpp:2397
Element * GetElement(int i)
Definition: mesh.hpp:821
void GenerateBoundaryElements()
Definition: mesh.cpp:1466
Mesh(int nx, int ny, int nz, Element::Type type, bool generate_edges=false, double sx=1.0, double sy=1.0, double sz=1.0, bool sfc_ordering=true)
Definition: mesh.hpp:650
Geometry::Type GetFaceBaseGeometry(int i) const
Definition: mesh.hpp:829
void PrintVTU(std::ostream &out, int ref=1, VTKFormat format=VTKFormat::ASCII, bool high_order_output=false, int compression_level=0, bool bdr_elements=false)
Definition: mesh.cpp:9130
Structure for storing mesh geometric factors: coordinates, Jacobians, and determinants of the Jacobia...
Definition: mesh.hpp:1394
Data type for vertex.
Definition: vertex.hpp:22
void SetMeshGen()
Determine the mesh generator bitmask meshgen, see MeshGenerator().
Definition: mesh.cpp:3371
static int GetQuadOrientation(const int *base, const int *test)
Returns the orientation of &quot;test&quot; relative to &quot;base&quot;.
Definition: mesh.cpp:4405
void GetVertices(Vector &vert_coord) const
Definition: mesh.cpp:6532
void ReadNetgen3DMesh(std::istream &input)
The inverse transformation of a given ElementTransformation.
Definition: eltrans.hpp:172
void ReadInlineMesh(std::istream &input, bool generate_edges=false)
FaceElementTransformations * GetInteriorFaceTransformations(int FaceNo)
Definition: mesh.hpp:1020
void RemoveInternalBoundaries()
Definition: mesh.cpp:10448
void DebugDump(std::ostream &out) const
Output an NCMesh-compatible debug dump.
Definition: mesh.cpp:11189
Mesh * Extrude2D(Mesh *mesh, const int nz, const double sz)
Extrude a 2D mesh.
Definition: mesh.cpp:10962
FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
Definition: mesh.cpp:869
Geometry::Type GetElementBaseGeometry(int i) const
Definition: mesh.hpp:834
void SetEmpty()
Definition: mesh.cpp:1091
Array< Element * > faces
Definition: mesh.hpp:92
virtual long ReduceInt(int value) const
Utility function: sum integers from all processors (Allreduce).
Definition: mesh.hpp:760
void FinalizeHexMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a hexahedral Mesh.
Definition: mesh.cpp:2432
void GetVertexToVertexTable(DSTable &) const
Definition: mesh.cpp:5111
void RedRefinement(int i, const DSTable &v_to_v, int *edge1, int *edge2, int *middle)
Definition: mesh.hpp:281
Operation last_operation
Definition: mesh.hpp:218
void MarkTriMeshForRefinement()
Definition: mesh.cpp:1997
void ReadCubit(const char *filename, int &curved, int &read_gf)
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:846
void InitRefinementTransforms()
Definition: mesh.cpp:8472
IsoparametricTransformation FaceTransformation
Definition: mesh.hpp:167
void UniformRefinement2D_base(bool update_nodes=true)
Definition: mesh.cpp:6681
Array< FaceGeometricFactors * > face_geom_factors
Optional face geometric factors.
Definition: mesh.hpp:207
Array< NCFaceInfo > nc_faces_info
Definition: mesh.hpp:154
Element * ReadElement(std::istream &)
Definition: mesh.cpp:3353
void KnotInsert(Array< KnotVector * > &kv)
Definition: mesh.cpp:3891
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:64
Element * NewElement(int geom)
Definition: mesh.cpp:3300
FaceElementTransformations FaceElemTr
Definition: mesh.hpp:168
Table * el_to_face
Definition: mesh.hpp:157
void GetEdgeTransformation(int i, IsoparametricTransformation *EdTr)
Definition: mesh.cpp:553
const GridFunction * GetNodes() const
Definition: mesh.hpp:1106
void MarkForRefinement()
Definition: mesh.cpp:1980
Element::Type GetFaceElementType(int Face) const
Definition: mesh.cpp:1062
Structure for storing face geometric factors: coordinates, Jacobians, determinants of the Jacobians...
Definition: mesh.hpp:1438
ElementTransformation * GetBdrElementTransformation(int i)
Returns the transformation defining the i-th boundary element.
Definition: mesh.cpp:417
int AddBdrTriangle(int v1, int v2, int v3, int attr=1)
Definition: mesh.cpp:1423
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:503
void PrintTopo(std::ostream &out, const Array< int > &e_to_k) const
Definition: mesh.cpp:8804
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
Definition: mesh.cpp:4184
Geometry::Constants< Geometry::SEGMENT > seg_t
Definition: mesh.hpp:189
void GetElementJacobian(int i, DenseMatrix &J)
Definition: mesh.cpp:58
void MesquiteSmooth(const int mesquite_option=0)
Definition: mesquite.cpp:1144
static int GetTetOrientation(const int *base, const int *test)
Returns the orientation of &quot;test&quot; relative to &quot;base&quot;.
Definition: mesh.cpp:4453
long GetSequence() const
Definition: mesh.hpp:1227
int AddTri(const int *vi, int attr=1)
Definition: mesh.hpp:527
int AddVertex(double x, double y=0.0, double z=0.0)
Definition: mesh.cpp:1232
bool Nonconforming() const
Definition: mesh.hpp:1214
Vector J
Jacobians of the element transformations at all quadrature points.
Definition: mesh.hpp:1425
FaceType
Definition: mesh.hpp:45
const GeometricFactors * GetGeometricFactors(const IntegrationRule &ir, const int flags)
Return the mesh geometric factors corresponding to the given integration rule.
Definition: mesh.cpp:768
void MoveNodes(const Vector &displacements)
Definition: mesh.cpp:6591
void GetEdgeOrdering(DSTable &v_to_v, Array< int > &order)
Definition: mesh.cpp:2012
void GetElementData(int geom, Array< int > &elem_vtx, Array< int > &attr) const
Definition: mesh.hpp:801
NCFaceInfo(bool slave, int master, const DenseMatrix *pm)
Definition: mesh.hpp:149
void FinalizeTriMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a triangular Mesh.
Definition: mesh.cpp:1518
void UpdateNURBS()
Definition: mesh.cpp:3965
Symmetric 3D Table stored as an array of rows each of which has a stack of column, floor, number nodes. The number of the node is assigned by counting the nodes from zero as they are pushed into the table. Diagonals of any kind are not allowed so the row, column and floor must all be different for each node. Only one node is stored for all 6 symmetric entries that are indexable by unique triplets of row, column, and floor.
Definition: stable3d.hpp:34
void FinalizeTetMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a tetrahedral Mesh.
Definition: mesh.cpp:2356
void AddBdrQuadAsTriangles(const int *vi, int attr=1)
Definition: mesh.cpp:1451
void Make3D(int nx, int ny, int nz, Element::Type type, double sx, double sy, double sz, bool sfc_ordering)
Definition: mesh.cpp:2626
void AddSegmentFaceElement(int lf, int gf, int el, int v0, int v1)
Definition: mesh.cpp:5246
virtual void SetAttributes()
Definition: mesh.cpp:1178
void EnsureNCMesh(bool simplices_nonconforming=false)
Definition: mesh.cpp:8045
GeometryList(Mesh &mesh, int dim)
Construct a GeometryList of all geometries of dimension dim in mesh.
Definition: mesh.hpp:872
Vector detJ
Determinants of the Jacobians at all quadrature points.
Definition: mesh.hpp:1431
int FindCoarseElement(int i)
Definition: mesh.cpp:8484
GeometryList(Mesh &mesh)
Construct a GeometryList of all element geometries in mesh.
Definition: mesh.hpp:867
double b
Definition: lissajous.cpp:42
int AddTet(int v1, int v2, int v3, int v4, int attr=1)
Definition: mesh.cpp:1307
void GetFaceTransformation(int i, IsoparametricTransformation *FTr)
Returns the transformation defining the given face element in a user-defined variable.
Definition: mesh.cpp:480
void GetLocalSegToTriTransformation(IsoparametricTransformation &loc, int i)
Definition: mesh.cpp:632
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition: mesh.cpp:8382
void AddQuadFaceElement(int lf, int gf, int el, int v0, int v1, int v2, int v3)
Definition: mesh.cpp:5303
void LoadPatchTopo(std::istream &input, Array< int > &edge_to_knot)
Read NURBS patch/macro-element mesh.
Definition: mesh.cpp:4030
void ReadGmshMesh(std::istream &input, int &curved, int &read_gf)
STable3D * GetElementToFaceTable(int ret_ftbl=0)
Definition: mesh.cpp:5518
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Definition: mesh.cpp:4165
int MeshGenerator()
Get the mesh generator/type.
Definition: mesh.hpp:730
virtual void PrintInfo(std::ostream &out=mfem::out)
In serial, this method calls PrintCharacteristics(). In parallel, additional information about the pa...
Definition: mesh.hpp:1340
Type
Constants for the classes derived from Element.
Definition: element.hpp:41
void GetBdrPointMatrix(int i, DenseMatrix &pointmat) const
Definition: mesh.cpp:5058
void InitTables()
Definition: mesh.cpp:1085
void CheckDisplacements(const Vector &displacements, double &tmax)
Definition: mesh.cpp:6446
VTKFormat
Definition: vtk.hpp:22
int mesh_geoms
Definition: mesh.hpp:78
int AddBdrSegment(int v1, int v2, int attr=1)
Definition: mesh.cpp:1409
Geometry::Constants< Geometry::TETRAHEDRON > tet_t
Definition: mesh.hpp:192
int AddElement(Element *elem)
The parameter elem should be allocated using the NewElement() method.
Definition: mesh.cpp:1395
void ReadLineMesh(std::istream &input)
virtual void Load(std::istream &input, int generate_edges=0, int refine=1, bool fix_orientation=true)
Definition: mesh.hpp:711
void SetNodesOwner(bool nodes_owner)
Set the mesh nodes ownership flag.
Definition: mesh.hpp:1110
void SetLayer(const int l)
Definition: mesh.hpp:1497
int GetElementToEdgeTable(Table &, Array< int > &)
Definition: mesh.cpp:5136
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:5010
void GetHilbertElementOrdering(Array< int > &ordering)
Definition: mesh.cpp:1776
int nbBoundaryFaces
Definition: mesh.hpp:75
void RandomRefinement(double prob, bool aniso=false, int nonconforming=-1, int nc_limit=0)
Refine each element with given probability. Uses GeneralRefinement.
Definition: mesh.cpp:8063
const Element * GetElement(int i) const
Definition: mesh.hpp:819
Mesh(int n, double sx=1.0)
Definition: mesh.hpp:671
void GetLocalQuadToHexTransformation(IsoparametricTransformation &loc, int i)
Used in GetFaceElementTransformations (...)
Definition: mesh.cpp:722
void ResetLazyData()
Definition: mesh.cpp:1168
void GetElementCenter(int i, Vector &center)
Definition: mesh.cpp:66
IsoparametricTransformation BdrTransformation
Definition: mesh.hpp:166
void GetLocalFaceTransformation(int face_type, int elem_type, IsoparametricTransformation &Transf, int info)
A helper method that constructs a transformation from the reference space of a face to the reference ...
Definition: mesh.cpp:822
IsoparametricTransformation Transformation2
Definition: mesh.hpp:165
void Init()
Definition: mesh.cpp:1067
void SetNodalFESpace(FiniteElementSpace *nfes)
Definition: mesh.cpp:4126
Element * GetBdrElement(int i)
Definition: mesh.hpp:825
Vector normal
Normals at all quadrature points.
Definition: mesh.hpp:1485
A class for non-conforming AMR on higher-order hexahedral, prismatic, quadrilateral or triangular mes...
Definition: ncmesh.hpp:102
FaceElementTransformations * GetBdrFaceTransformations(int BdrElemNo)
Definition: mesh.cpp:1003
Geometry::Constants< Geometry::PRISM > pri_t
Definition: mesh.hpp:194
int Dimension() const
Definition: mesh.hpp:788
virtual void ReorientTetMesh()
Definition: mesh.cpp:5631
prob_type prob
Definition: ex25.cpp:149
int NumOfBdrElements
Definition: mesh.hpp:69
Table * el_to_edge
Definition: mesh.hpp:156
virtual void LocalRefinement(const Array< int > &marked_el, int type=3)
This function is not public anymore. Use GeneralRefinement instead.
Definition: mesh.cpp:7432
Data type tetrahedron element.
Definition: tetrahedron.hpp:22
virtual void MarkTetMeshForRefinement(DSTable &v_to_v)
Definition: mesh.cpp:2037
Array< Triple< int, int, int > > tmp_vertex_parents
Used during initialization only.
Definition: mesh.hpp:210
List of mesh geometries stored as Array&lt;Geometry::Type&gt;.
Definition: mesh.hpp:861
void Destroy()
Definition: mesh.cpp:1139
double GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
Definition: mesh.cpp:74
int CheckBdrElementOrientation(bool fix_it=true)
Check the orientation of the boundary elements.
Definition: mesh.cpp:4586
int SpaceDimension() const
Definition: mesh.hpp:789
void GetBdrElementFace(int i, int *, int *) const
Return the index and the orientation of the face of bdr element i. (3D)
Definition: mesh.cpp:4975
void CheckPartitioning(int *partitioning)
Definition: mesh.cpp:6128
void PrintElementsWithPartitioning(int *partitioning, std::ostream &out, int interior_faces=0)
Definition: mesh.cpp:9713
bool FaceIsInterior(int FaceNo) const
Return true if the given face is interior.
Definition: mesh.hpp:1029
void ReadMFEMMesh(std::istream &input, bool mfem_v11, int &curved)
void GetLocalQuadToWdgTransformation(IsoparametricTransformation &loc, int i)
Used in GetFaceElementTransformations (...)
Definition: mesh.cpp:744
void AddPointFaceElement(int lf, int gf, int el)
Used in GenerateFaces()
Definition: mesh.cpp:5229
GeometricFactors(const Mesh *mesh, const IntegrationRule &ir, int flags)
Definition: mesh.cpp:10676
void GetFaceElements(int Face, int *Elem1, int *Elem2) const
Definition: mesh.cpp:1031
void Make1D(int n, double sx=1.0)
Creates a 1D mesh for the interval [0,sx] divided into n equal intervals.
Definition: mesh.cpp:3042
const Element *const * GetElementsArray() const
Definition: mesh.hpp:816
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Definition: mesh.hpp:201
virtual void NonconformingRefinement(const Array< Refinement > &refinements, int nc_limit=0)
This function is not public anymore. Use GeneralRefinement instead.
Definition: mesh.cpp:7674
void PrintVTK(std::ostream &out)
Definition: mesh.cpp:8853
virtual ~Mesh()
Destroys Mesh.
Definition: mesh.hpp:1377
void FinalizeMesh(int refine=0, bool fix_orientation=true)
Finalize the construction of any type of Mesh.
Definition: mesh.cpp:2462
Mesh(int nx, int ny, Element::Type type, bool generate_edges=false, double sx=1.0, double sy=1.0, bool sfc_ordering=true)
Definition: mesh.hpp:663
Table * el_to_el
Definition: mesh.hpp:158
void GetFaceInfos(int Face, int *Inf1, int *Inf2) const
Definition: mesh.cpp:1037
int AddSegment(int v1, int v2, int attr=1)
Definition: mesh.cpp:1265
Geometry::Constants< Geometry::CUBE > hex_t
Definition: mesh.hpp:193
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:87
Geometry::Type geom_buf[Geometry::NumGeom]
Definition: mesh.hpp:864
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
Definition: mesh.cpp:10341
static void PrintElement(const Element *, std::ostream &)
Definition: mesh.cpp:3365
virtual void NURBSUniformRefinement()
Refine NURBS mesh.
Definition: mesh.cpp:3935
int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8, int attr=1)
Definition: mesh.cpp:1342
const IntegrationRule * IntRule
Definition: mesh.hpp:1398
Vector X
Mapped (physical) coordinates of all quadrature points.
Definition: mesh.hpp:1463
void FinalizeTopology(bool generate_bdr=true)
Finalize the construction of the secondary topology (connectivity) data of a Mesh.
Definition: mesh.cpp:2469
static void GetElementArrayEdgeTable(const Array< Element * > &elem_array, const DSTable &v_to_v, Table &el_to_edge)
Definition: mesh.cpp:5089
GridFunction * GetNodes()
Return a pointer to the internal node GridFunction (may be NULL).
Definition: mesh.hpp:1105
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition: array.hpp:654
void PrepareNodeReorder(DSTable **old_v_to_v, Table **old_elem_vert)
Definition: mesh.cpp:2060
int AddBdrQuad(int v1, int v2, int v3, int v4, int attr=1)
Definition: mesh.cpp:1437
bool IsSlaveFace(const FaceInfo &fi) const
Definition: mesh.cpp:959
Array< Vertex > vertices
Definition: mesh.hpp:90
virtual void PrintXG(std::ostream &out=mfem::out) const
Print the mesh to the given stream using Netgen/Truegrid format.
Definition: mesh.cpp:8557
void RefineAtVertex(const Vertex &vert, double eps=0.0, int nonconforming=-1)
Refine elements sharing the specified vertex. Uses GeneralRefinement.
Definition: mesh.cpp:8082
Array< Element * > elements
Definition: mesh.hpp:85
const Table & ElementToElementTable()
Definition: mesh.cpp:5175
double GetLength(int i, int j) const
Return the length of the segment from node i to node j.
Definition: mesh.cpp:5074
int meshgen
Definition: mesh.hpp:77
const CoarseFineTransformations & GetRefinementTransforms()
Definition: mesh.cpp:8494
bool RefineByError(const Array< double > &elem_error, double threshold, int nonconforming=-1, int nc_limit=0)
Definition: mesh.cpp:8108
Table * bel_to_edge
Definition: mesh.hpp:160
Operation GetLastOperation() const
Return type of last modification of the mesh.
Definition: mesh.hpp:1221
Table * GetFaceToElementTable() const
Definition: mesh.cpp:4903
void GetLocalTriToTetTransformation(IsoparametricTransformation &loc, int i)
Used in GetFaceElementTransformations (...)
Definition: mesh.cpp:672
double a
Definition: lissajous.cpp:41
int EulerNumber() const
Equals 1 + num_holes - num_loops.
Definition: mesh.hpp:782
NURBSExtension * NURBSext
Optional NURBS mesh extension.
Definition: mesh.hpp:203
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
Definition: mesh.hpp:734
int nbInteriorFaces
Definition: mesh.hpp:75
void PrintBdrVTU(std::string fname, VTKFormat format=VTKFormat::ASCII, bool high_order_output=false, int compression_level=0)
Definition: mesh.cpp:9067
void GetNode(int i, double *coord) const
Definition: mesh.cpp:6552
Array< int > be_to_edge
Definition: mesh.hpp:159
const Table & ElementToFaceTable() const
Definition: mesh.cpp:5211
Class for integration point with weight.
Definition: intrules.hpp:25
void Swap(Mesh &other, bool non_geometry)
Definition: mesh.cpp:7864
Element * ReadElementWithoutAttr(std::istream &)
Definition: mesh.cpp:3323
FaceGeometricFactors(const Mesh *mesh, const IntegrationRule &ir, int flags, FaceType type)
Definition: mesh.cpp:10729
A standard isoparametric element transformation.
Definition: eltrans.hpp:348
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:4721
static const int vtk_quadratic_wedge[18]
Definition: mesh.hpp:180
bool OwnsNodes() const
Return the mesh nodes ownership flag.
Definition: mesh.hpp:1108
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Definition: mesh.cpp:336
void GetLocalSegToQuadTransformation(IsoparametricTransformation &loc, int i)
Definition: mesh.cpp:652
const FiniteElementSpace * GetNodalFESpace() const
Definition: mesh.cpp:4160
Table * face_edge
Definition: mesh.hpp:162
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a quadrilateral Mesh.
Definition: mesh.cpp:1547
void GetBdrElementData(int geom, Array< int > &bdr_elem_vtx, Array< int > &bdr_attr) const
Definition: mesh.hpp:804
virtual void Finalize(bool refine=false, bool fix_orientation=false)
Finalize the construction of a general Mesh.
Definition: mesh.cpp:2552
bool DerefineByError(Array< double > &elem_error, double threshold, int nc_limit=0, int op=1)
Definition: mesh.cpp:7791
NodeExtrudeCoefficient(const int dim, const int _n, const double _s)
Definition: mesh.cpp:10778
void ReorderElements(const Array< int > &ordering, bool reorder_vertices=true)
Definition: mesh.cpp:1828
void DegreeElevate(int rel_degree, int degree=16)
Definition: mesh.cpp:3948
int dim
Definition: ex24.cpp:53
Table * edge_vertex
Definition: mesh.hpp:163
long sequence
Definition: mesh.hpp:83
virtual ~NodeExtrudeCoefficient()
Definition: mesh.hpp:1501
const Mesh * mesh
Definition: mesh.hpp:1397
void DestroyPointers()
Definition: mesh.cpp:1113
Array< FaceInfo > faces_info
Definition: mesh.hpp:153
STable3D * GetFacesTable()
Definition: mesh.cpp:5469
std::ostream & operator<<(std::ostream &os, SparseMatrix const &mat)
Definition: sparsemat.hpp:630
NCMesh * ncmesh
Optional non-conforming mesh extension.
Definition: mesh.hpp:204
Geometry::Type GetBdrElementBaseGeometry(int i) const
Definition: mesh.hpp:839
virtual void UniformRefinement3D()
Refine a mixed 3D mesh uniformly.
Definition: mesh.hpp:326
int AddBdrElement(Element *elem)
Definition: mesh.cpp:1402
static void PrintElementWithoutAttr(const Element *, std::ostream &)
Definition: mesh.cpp:3341
int AddWedge(int v1, int v2, int v3, int v4, int v5, int v6, int attr=1)
Definition: mesh.cpp:1328
virtual bool NonconformingDerefinement(Array< double > &elem_error, double threshold, int nc_limit=0, int op=1)
NC version of GeneralDerefinement.
Definition: mesh.cpp:7743
int Dim
Definition: mesh.hpp:66
Geometry::Type GetFaceGeometryType(int Face) const
Definition: mesh.cpp:1043
void Clear()
Clear the contents of the Mesh.
Definition: mesh.hpp:719
int GetNEdges() const
Return the number of edges.
Definition: mesh.hpp:743
Geometry::Constants< Geometry::TRIANGLE > tri_t
Definition: mesh.hpp:190
double AggregateError(const Array< double > &elem_error, const int *fine, int nfine, int op)
Derefinement helper.
Definition: mesh.cpp:7724
double * GetVertex(int i)
Return pointer to vertex i&#39;s coordinates.
Definition: mesh.hpp:799
int GetNFaces() const
Return the number of faces in a 3D mesh.
Definition: mesh.hpp:746
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:10561
void SetAttribute(int i, int attr)
Set the attribute of element i.
Definition: mesh.hpp:1050
Vector data type.
Definition: vector.hpp:51
void ReadTrueGridMesh(std::istream &input)
int GetNFbyType(FaceType type) const
Returns the number of faces according to the requested type.
Definition: mesh.cpp:4210
static int GetTriOrientation(const int *base, const int *test)
Returns the orientation of &quot;test&quot; relative to &quot;base&quot;.
Definition: mesh.cpp:4357
void SetNode(int i, const double *coord)
Definition: mesh.cpp:6571
void DestroyTables()
Definition: mesh.cpp:1097
void GetLocalTriToWdgTransformation(IsoparametricTransformation &loc, int i)
Used in GetFaceElementTransformations (...)
Definition: mesh.cpp:696
void GenerateFaces()
Definition: mesh.cpp:5326
void GetElementColoring(Array< int > &colors, int el0=0)
Definition: mesh.cpp:9519
void ChangeVertexDataOwnership(double *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:3234
void DeleteGeometricFactors()
Destroy all GeometricFactors stored by the Mesh.
Definition: mesh.cpp:808
int spaceDim
Definition: mesh.hpp:67
IsoparametricTransformation EdgeTransformation
Definition: mesh.hpp:167
Defines the coarse-fine transformations of all fine elements.
Definition: ncmesh.hpp:60
MemAlloc< Tetrahedron, 1024 > TetMemory
Definition: mesh.hpp:185
Table * GetFaceEdgeTable() const
Returns the face-to-edge Table (3D)
Definition: mesh.cpp:4814
void DoNodeReorder(DSTable *old_v_to_v, Table *old_elem_vert)
Definition: mesh.cpp:2126
void SetNodes(const Vector &node_coord)
Definition: mesh.cpp:6615
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
Definition: mesh.cpp:4154
void ReadNURBSMesh(std::istream &input, int &curved, int &read_gf)
int NumOfVertices
Definition: mesh.hpp:69
void ScaleSubdomains(double sf)
Definition: mesh.cpp:10152
Array< int > be_to_face
Definition: mesh.hpp:161
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 InitFromNCMesh(const NCMesh &ncmesh)
Initialize vertices/elements/boundary/tables from a nonconforming mesh.
Definition: mesh.cpp:7820
void Bisection(int i, const DSTable &, int *, int *, int *)
Bisect a triangle: element with index i is bisected.
Definition: mesh.cpp:8137
void GeneralRefinement(const Array< Refinement > &refinements, int nonconforming=-1, int nc_limit=0)
Definition: mesh.cpp:7977
Class for parallel meshes.
Definition: pmesh.hpp:32
Abstract data type element.
Definition: element.hpp:28
int GetAttribute(int i) const
Return the attribute of element i.
Definition: mesh.hpp:1047
void AddTriangleFaceElement(int lf, int gf, int el, int v0, int v1, int v2)
Definition: mesh.cpp:5279
const Table & ElementToEdgeTable() const
Definition: mesh.cpp:5220
Array< GeometricFactors * > geom_factors
Optional geometric factors.
Definition: mesh.hpp:205
void BdrBisection(int i, const HashTable< Hashed2 > &)
Bisect a boundary triangle: boundary element with index i is bisected.
Definition: mesh.cpp:8345
void GetBdrElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of boundary element i.
Definition: mesh.hpp:882
void GenerateNCFaceInfo()
Definition: mesh.cpp:5411
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
Definition: mesh.hpp:878
double GetElementVolume(int i)
Definition: mesh.cpp:101
Array< int > attributes
A list of all unique element attributes used by the Mesh.
Definition: mesh.hpp:199
void InitMesh(int _Dim, int _spaceDim, int NVert, int NElem, int NBdrElem)
Begin construction of a mesh.
Definition: mesh.cpp:1209
Table * GetVertexToElementTable()
The returned Table must be destroyed by the caller.
Definition: mesh.cpp:4868
const Element * GetBdrElement(int i) const
Definition: mesh.hpp:823
void EnsureNodes()
Definition: mesh.cpp:4132
void GetElementData(const Array< Element * > &elem_array, int geom, Array< int > &elem_vtx, Array< int > &attr) const
Definition: mesh.cpp:7913
void UpdateNodes()
Update the nodes of a curved mesh after refinement.
Definition: mesh.cpp:6672
void PrintCharacteristics(Vector *Vh=NULL, Vector *Vk=NULL, std::ostream &out=mfem::out)
Compute and print mesh characteristics such as number of vertices, number of elements, number of boundary elements, minimal and maximal element sizes, minimal and maximal element aspect ratios, etc.
Definition: mesh.cpp:231
void GreenRefinement(int i, const DSTable &v_to_v, int *edge1, int *edge2, int *middle)
Definition: mesh.hpp:287
double f(const Vector &p)
void Printer(std::ostream &out=mfem::out, std::string section_delimiter="") const
Definition: mesh.cpp:8721
Class used to extrude the nodes of a mesh.
Definition: mesh.hpp:1489
void AddVertexParents(int i, int p1, int p2)
Mark vertex i as non-conforming, with parent vertices p1 and p2.
Definition: mesh.cpp:1249
int NumOfFaces
Definition: mesh.hpp:70