MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
tmesh.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_TEMPLATE_MESH
13#define MFEM_TEMPLATE_MESH
14
15#include "../config/tconfig.hpp"
16#include "../linalg/tlayout.hpp"
17
18#include "mesh.hpp"
19
20namespace mfem
21{
22
23template <typename FESpace,
24 typename nodeLayout =
25 VectorLayout<Ordering::byNODES,FESpace::FE_type::dim> >
26class TMesh
27{
28public:
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
45public:
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
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:220
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
Mesh data type.
Definition mesh.hpp:56
const FiniteElementSpace * GetNodalFESpace() const
Definition mesh.cpp:6206
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1226
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1160
int SpaceDimension() const
Dimension of the physical space containing the mesh.
Definition mesh.hpp:1163
void GetNodes(Vector &node_coord) const
Definition mesh.cpp:8973
Geometry::Type GetElementBaseGeometry(int i) const
Definition mesh.hpp:1385
nodeLayout nodeLayout_type
Definition tmesh.hpp:31
static bool Matches(const Mesh &mesh)
Definition tmesh.hpp:73
FESpace FESpace_type
Definition tmesh.hpp:29
const FiniteElementSpace & fes
Definition tmesh.hpp:37
static bool MatchesNodes(const Mesh &mesh)
Definition tmesh.hpp:66
FE_type fe
Definition tmesh.hpp:40
nodeLayout node_layout
Definition tmesh.hpp:43
FESpace t_fes
Definition tmesh.hpp:41
static const int dim
Definition tmesh.hpp:33
FESpace::FE_type FE_type
Definition tmesh.hpp:30
int GetNE() const
Definition tmesh.hpp:53
const Mesh & m_mesh
Definition tmesh.hpp:36
TMesh(const Mesh &mesh)
Definition tmesh.hpp:46
static const int space_dim
Definition tmesh.hpp:34
const GridFunction & Nodes
Definition tmesh.hpp:38
static bool MatchesGeometry(const Mesh &mesh)
Definition tmesh.hpp:55