Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
mesh.hpp
Go to the documentation of this file.
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
13 #pragma once
14 
15 #include <memory>
16 #include <string>
17 #include <functional>
18 #include <map>
19 #include <vector>
20 
21 #include "mpi.h"
22 
23 #include "mfem.hpp"
26 
27 namespace serac {
28 
29 // Forward declare
30 struct Domain;
31 class FiniteElementState;
32 class FiniteElementDual;
33 
37 class Mesh {
38  public:
45  Mesh(mfem::Mesh&& mesh, const std::string& meshtag, int serial_refine = 0, int parallel_refine = 0,
46  MPI_Comm comm = MPI_COMM_WORLD);
47 
51  Mesh(mfem::ParMesh&& mesh, const std::string& meshtag);
52 
59  Mesh(const std::string& meshfile, const std::string& meshtag, int serial_refine = 0, int parallel_refine = 0,
60  MPI_Comm comm = MPI_COMM_WORLD);
61 
63  const std::string& tag() const { return mesh_tag_; }
64 
66  const mfem::ParMesh& mfemParMesh() const { return *mfem_mesh_; }
67 
69  mfem::ParMesh& mfemParMesh() { return *mfem_mesh_; }
70 
72  MPI_Comm getComm() const;
73 
75  static std::string entireBodyName() { return "entire_body"; }
76 
78  serac::Domain& entireBody() const;
79 
81  static std::string entireBoundaryName() { return "entire_boundary"; }
82 
85 
87  static std::string internalBoundaryName() { return "internal_boundary"; }
88 
91 
93  serac::Domain& domain(const std::string& domain_name) const;
94 
98  serac::Domain& addDomainOfBoundaryElements(const std::string& domain_name,
99  std::function<bool(std::vector<vec3>, int)> func);
100 
104  serac::Domain& addDomainOfBoundaryElements(const std::string& domain_name,
105  std::function<bool(std::vector<vec2>, int)> func);
106 
110  serac::Domain& addDomainOfBodyElements(const std::string& domain_name,
111  std::function<bool(std::vector<vec3>, int)> func);
112 
116  serac::Domain& addDomainOfBodyElements(const std::string& domain_name,
117  std::function<bool(std::vector<vec2>, int)> func);
118 
120  const mfem::ParFiniteElementSpace& shapeDisplacementSpace();
121 
124 
127 
128  private:
131  void createDomains();
132 
134  std::string mesh_tag_;
135 
137  mfem::ParMesh* mfem_mesh_;
138 
140  mutable std::map<std::string, serac::Domain> domains_;
141 };
142 
143 } // namespace serac
Class for encapsulating the dual vector space of a finite element space (i.e. the space of linear for...
Class for encapsulating the critical MFEM components of a primal finite element field.
Helper class for constructing a mesh consistent with serac.
Definition: mesh.hpp:37
mfem::ParMesh & mfemParMesh()
Returns parallel mfem mesh.
Definition: mesh.hpp:69
serac::Domain & entireBody() const
Returns domain corresponding to the entire mesh.
Definition: mesh.cpp:56
Mesh(mfem::Mesh &&mesh, const std::string &meshtag, int serial_refine=0, int parallel_refine=0, MPI_Comm comm=MPI_COMM_WORLD)
Construct from existing serial mfem mesh.
Definition: mesh.cpp:30
serac::Domain & addDomainOfBodyElements(const std::string &domain_name, std::function< bool(std::vector< vec3 >, int)> func)
create domain of 3D elements with specified name The second argument is a function taking a std::vect...
Definition: mesh.cpp:96
static std::string internalBoundaryName()
Returns string, name used to access the internal boundary elements.
Definition: mesh.hpp:87
const mfem::ParFiniteElementSpace & shapeDisplacementSpace()
get space associated with shape displacement
Definition: mesh.cpp:105
serac::Domain & internalBoundary() const
Returns domain boundary corresponding to the internal boundary elements.
Definition: mesh.cpp:60
serac::Domain & addDomainOfBoundaryElements(const std::string &domain_name, std::function< bool(std::vector< vec3 >, int)> func)
create domain of 3D boundary elements with specified name The second argument is a function taking a ...
Definition: mesh.cpp:78
serac::FiniteElementState newShapeDisplacement()
create new shape displacement
Definition: mesh.cpp:110
const mfem::ParMesh & mfemParMesh() const
Returns const parallel mfem mesh.
Definition: mesh.hpp:66
static std::string entireBoundaryName()
Returns string, name used to access the entire boundary.
Definition: mesh.hpp:81
serac::Domain & entireBoundary() const
Returns domain boundary corresponding to the entire mesh.
Definition: mesh.cpp:58
serac::FiniteElementDual newShapeDisplacementDual()
create new shape displacement sensitivity
Definition: mesh.cpp:112
static std::string entireBodyName()
Returns string, name used to access the entire domain body.
Definition: mesh.hpp:75
const std::string & tag() const
Returns string tag for mesh.
Definition: mesh.hpp:63
MPI_Comm getComm() const
Returns parallel communicator.
Definition: mesh.cpp:47
serac::Domain & domain(const std::string &domain_name) const
Returns registered domain with specified name.
Definition: mesh.cpp:62
many of the functions in this file amount to extracting element indices from an mesh_t like
Accelerator functionality.
Definition: serac.cpp:36
a class for representing a geometric region that can be used for integration
Definition: domain.hpp:33
Implementation of the tensor class used by Functional.