NuTo
Numerics Tool
MeshGmsh.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "nuto/base/Group.h"
5 #include <string>
6 #include <map>
7 #include <unordered_map>
8 
9 struct GmshFileContent;
10 
11 namespace NuTo
12 {
13 
16 class MeshGmsh
17 {
18 public:
21  MeshGmsh() = delete;
22 
25  MeshGmsh(const MeshGmsh&) = delete;
26 
28  MeshGmsh(MeshGmsh&&) = default;
29 
32  MeshGmsh& operator=(const MeshGmsh&) = delete;
33 
35  MeshGmsh& operator=(MeshGmsh&&) = default;
36 
38  ~MeshGmsh() = default;
39 
42  explicit MeshGmsh(const std::string& fileName);
43 
47  const NuTo::Group<ElementCollectionFem>& GetPhysicalGroup(std::string physicalName) const;
48 
49 
53  const NuTo::Group<ElementCollectionFem>& GetPhysicalGroup(int physicalGroupId) const;
54 
57  {
58  return mMesh;
59  }
60 
61 private:
67  void AddElementToPhysicalGroup(const GmshFileContent& fileContent, ElementCollectionFem& rElement,
68  int physicalGroupId);
69 
77  std::unordered_map<int, NodeSimple*> CreateNodes(const GmshFileContent& fileContent);
78 
82  void CreateElements(const GmshFileContent& fileContent, const std::unordered_map<int, NodeSimple*>& nodePtrs);
83 
86  void CreateMesh(const GmshFileContent& fileContent);
87 
90  void ReadGmshFile(const std::string& fileName);
91 
93  MeshFem mMesh;
94 
96  std::map<int, Group<ElementCollectionFem>> mPhysicalGroups;
97 
99  std::map<std::string, Group<ElementCollectionFem>*> mNamedPhysicalGroups;
100 };
101 }
Definition: MeshGmsh.cpp:58
MeshGmsh & operator=(const MeshGmsh &)=delete
copy assignment operator
~MeshGmsh()=default
dtor
const NuTo::Group< ElementCollectionFem > & GetPhysicalGroup(std::string physicalName) const
Gets an element collection group associated to the physical name defined in gmsh. ...
Definition: MeshGmsh.cpp:446
MeshFem & GetMeshFEM()
Gets the MeshFem.
Definition: MeshGmsh.h:56
contains the nodes, elements and interpolations for a classic finite element mesh ...
Definition: MeshFem.h:16
Definition: Exception.h:6
Reads a gmsh msh-file and converts it to a MeshFEM.
Definition: MeshGmsh.h:16
MeshGmsh()=delete
ctor
Ordered container class for elements, nodes and the like.
Definition: Group.h:15
implementation of the interface ElementCollection for arbitrary element types that are derived from E...
Definition: ElementCollection.h:31