MFEM  v4.2.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
tmesh.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_TEMPLATE_MESH
13 #define MFEM_TEMPLATE_MESH
14 
15 #include "../config/tconfig.hpp"
16 #include "../linalg/tlayout.hpp"
17 
18 #include "mesh.hpp"
19 
20 namespace mfem
21 {
22 
23 template <typename FESpace,
24  typename nodeLayout =
25  VectorLayout<Ordering::byNODES,FESpace::FE_type::dim> >
26 class TMesh
27 {
28 public:
29  typedef FESpace FESpace_type;
30  typedef typename FESpace::FE_type FE_type;
31  typedef nodeLayout nodeLayout_type;
32 
33  static const int dim = FE_type::dim;
34  static const int space_dim = nodeLayout::vec_dim;
35 
36  const Mesh &m_mesh;
39 
41  FESpace t_fes;
42 
43  nodeLayout node_layout;
44 
45 public:
46  TMesh(const Mesh &mesh)
47  : m_mesh(mesh), fes(*mesh.GetNodalFESpace()), Nodes(*mesh.GetNodes()),
48  fe(*fes.FEColl()), t_fes(fe, fes), node_layout(fes)
49  {
50  MFEM_STATIC_ASSERT(space_dim != 0, "dynamic space dim is not allowed");
51  }
52 
53  int GetNE() const { return m_mesh.GetNE(); }
54 
55  static bool MatchesGeometry(const Mesh &mesh)
56  {
57  if (mesh.Dimension() != dim) { return false; }
58  if (mesh.SpaceDimension() != space_dim) { return false; }
59  for (int i = 0; i < mesh.GetNE(); i++)
60  {
61  if (mesh.GetElementBaseGeometry(i) != FE_type::geom) { return false; }
62  }
63  return true;
64  }
65 
66  static bool MatchesNodes(const Mesh &mesh)
67  {
68  if (!mesh.GetNodes()) { return false; }
69  return FESpace::template VectorMatches<nodeLayout>(
70  *mesh.GetNodalFESpace());
71  }
72 
73  static bool Matches(const Mesh &mesh)
74  {
75  return MatchesGeometry(mesh) && MatchesNodes(mesh);
76  }
77 };
78 
79 } // namespace mfem
80 
81 #endif // MFEM_TEMPLATE_MESH
int GetNE() const
Definition: tmesh.hpp:53
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:30
FESpace::FE_type FE_type
Definition: tmesh.hpp:30
const Mesh & m_mesh
Definition: tmesh.hpp:36
const Geometry::Type geom
Definition: ex1.cpp:40
int GetNE() const
Returns number of elements.
Definition: mesh.hpp:737
FESpace FESpace_type
Definition: tmesh.hpp:29
FE_type fe
Definition: tmesh.hpp:40
nodeLayout node_layout
Definition: tmesh.hpp:43
Geometry::Type GetElementBaseGeometry(int i) const
Definition: mesh.hpp:834
static const int space_dim
Definition: tmesh.hpp:34
const FiniteElementSpace & fes
Definition: tmesh.hpp:37
TMesh(const Mesh &mesh)
Definition: tmesh.hpp:46
nodeLayout nodeLayout_type
Definition: tmesh.hpp:31
const GridFunction & Nodes
Definition: tmesh.hpp:38
int Dimension() const
Definition: mesh.hpp:788
static bool Matches(const Mesh &mesh)
Definition: tmesh.hpp:73
int SpaceDimension() const
Definition: mesh.hpp:789
static const int dim
Definition: tmesh.hpp:33
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:87
const FiniteElementSpace * GetNodalFESpace() const
Definition: mesh.cpp:4160
int dim
Definition: ex24.cpp:53
static bool MatchesGeometry(const Mesh &mesh)
Definition: tmesh.hpp:55
void GetNodes(Vector &node_coord) const
Definition: mesh.cpp:6603
FESpace t_fes
Definition: tmesh.hpp:41
static bool MatchesNodes(const Mesh &mesh)
Definition: tmesh.hpp:66