gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
CGNSZone.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 //
6 // Contributor(s):
7 // Thomas Toulorge
8 
9 #ifndef CGNS_ZONE_H
10 #define CGNS_ZONE_H
11 
12 #include <string>
13 #include <vector>
14 #include <map>
15 #include "GmshConfig.h"
16 #include "CGNSCommon.h"
17 #include "CGNSRead.h"
18 
19 #if defined(HAVE_LIBCGNS)
20 
21 class MVertex;
22 class MElement;
23 
24 class CGNSZone {
25 public:
26  CGNSZone() {}
27  CGNSZone(int fileIndex, int baseIndex, int zoneIndex,
28  CGNS_ENUMT(ZoneType_t) type, int meshDim, cgsize_t startNode,
29  const Family2EltNodeTransfo &allEltNodeTransfo, int &err);
30  virtual ~CGNSZone() {}
31 
32  int index() const { return zoneIndex_; }
33  std::string name() const { return name_; }
34  CGNS_ENUMT(ZoneType_t) type() const { return type_; }
35  cgsize_t startNode() const { return startNode_; }
36  cgsize_t nbNode() const { return nbNode_; }
37  cgsize_t nbElt() const { return nbElt_; }
38  const cgsize_t *size() const { return size_; }
39 
40  virtual cgsize_t indexDataSize(cgsize_t nbVal) = 0;
41  virtual void eltFromRange(const cgsize_t *range,
42  std::vector<cgsize_t> &elt) const = 0;
43  void eltFromRange(const std::vector<cgsize_t> &range,
44  std::vector<cgsize_t> &elt) const
45  {
46  eltFromRange(range.data(), elt);
47  }
48  virtual void eltFromList(const std::vector<cgsize_t> &list,
49  std::vector<cgsize_t> &elt) const = 0;
50  virtual void nodeFromRange(const cgsize_t *range,
51  std::vector<cgsize_t> &node) const = 0;
52  void nodeFromRange(const std::vector<cgsize_t> &range,
53  std::vector<cgsize_t> &node) const
54  {
55  nodeFromRange(range.data(), node);
56  }
57  virtual void nodeFromList(const std::vector<cgsize_t> &range,
58  std::vector<cgsize_t> &node) const = 0;
59 
60  std::map<cgsize_t, int> &elt2Geom() { return elt2Geom_; }
61  const ZoneEltNodeTransfo *eltNodeTransfo() const { return eltNodeTransfo_; }
62  const std::vector<bool> &interfaceNode() const { return interfaceNode_; }
63  int nbPerConnect() const { return nbPerConnect_; }
64  int masterZone(int iPer) const { return masterZone_[iPer]; }
65  const std::vector<double> &perTransfo(int iPer) const
66  {
67  return perTransfo_[iPer];
68  }
69  const std::vector<cgsize_t> &masterNode(int iPer) const
70  {
71  return masterNode_[iPer];
72  }
73  const std::vector<cgsize_t> &slaveNode(int iPer) const
74  {
75  return slaveNode_[iPer];
76  }
77  std::vector<MVertex *> &masterVert(int iPer) { return masterVert_[iPer]; }
78  std::vector<MVertex *> &slaveVert(int iPer) { return slaveVert_[iPer]; }
79 
80  int readBoundaryCondition(int iZoneBC,
81  const std::vector<CGNSZone *> &allZones,
82  std::vector<std::string> &allGeomName);
83 
84  int readVertices(int dim, double scale, std::vector<CGNSZone *> &allZones,
85  std::vector<MVertex *> &zoneVert);
86 
87  virtual int readElements(std::vector<MVertex *> &allVert,
88  std::map<int, std::vector<MElement *> > *allElt,
89  std::vector<MElement *> &zoneElt,
90  std::vector<std::string> &allGeomName) = 0;
91 
92  virtual int readConnectivities(const std::map<std::string, int> &name2Zone,
93  std::vector<CGNSZone *> &allZones);
94 
95  int readMesh(int dim, double scale, std::vector<CGNSZone *> &allZones,
96  std::vector<MVertex *> &allVert,
97  std::map<int, std::vector<MElement *> > *allElt,
98  std::vector<MVertex *> &zoneVert,
99  std::vector<MElement *> &zoneElt,
100  std::vector<std::string> &allGeomName);
101 
102  void setPeriodicVertices(const std::vector<CGNSZone *> &allZones,
103  const std::vector<MVertex *> &allVert);
104 
105 protected:
106  // basic zone information
107  int fileIndex_, baseIndex_, meshDim_, zoneIndex_;
108  std::string name_;
109  cgsize_t size_[9];
110  CGNS_ENUMT(ZoneType_t) type_;
111  cgsize_t startNode_, nbNode_, nbElt_;
112 
113  // BC information
114  std::map<cgsize_t, int> elt2Geom_;
115 
116  // transformations of high-order points per element (CPEX0045)
117  const ZoneEltNodeTransfo *eltNodeTransfo_;
118 
119  // internal interface information
120  std::vector<bool> interfaceNode_;
121 
122  // periodic information
123  int nbPerConnect_;
124  std::vector<int> masterZone_;
125  std::vector<std::vector<double> > perTransfo_;
126  std::vector<std::vector<cgsize_t> > masterNode_, slaveNode_;
127  std::vector<std::vector<MVertex *> > masterVert_, slaveVert_;
128 
129  int fileIndex() const { return fileIndex_; }
130  int baseIndex() const { return baseIndex_; }
131  int meshDim() const { return meshDim_; }
132 
133  int readBoundaryConditionList(int indBC, cgsize_t nbVal,
134  std::vector<cgsize_t> &bcElt);
135  int readBoundaryConditionRange(int indBC, std::vector<cgsize_t> &bcElt);
136 };
137 
138 #endif // HAVE_LIBCGNS
139 
140 #endif // CGNS_ZONE_H
CGNSRead.h
MVertex
Definition: MVertex.h:24
MElement
Definition: MElement.h:30
CGNSCommon.h
scale
static void scale(std::vector< double > &x, double s)
Definition: ConjugateGradients.cpp:21