NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
meshPartition Class Reference

Detailed Description

Definition at line 60 of file meshPartitioner.H.

Public Member Functions

 meshPartition (int pidx, const std::vector< int > &glbElmPartedIdx, const std::vector< int > &glbElmConn, MeshType_t inMshType)
 
 ~meshPartition ()=default
 
std::vector< double > getCrds (const std::vector< double > &crds) const
 
std::vector< int > getConns () const
 
std::vector< double > getElmSlns (const std::vector< double > &slns) const
 
std::vector< double > getElmSlnsVec (const std::vector< double > &slns, int nComp) const
 
std::map< int, int > getPartToGlobNodeMap () const
 
std::map< int, int > getPartToGlobElmMap () const
 

Public Attributes

int nNde
 
int nElm
 

Private Attributes

int pIdx
 
int nNdeElm
 
std::vector< int > globNdeIdx
 
std::vector< int > globElmIdx
 
std::vector< int > partElmConn
 
std::map< int, int > ndeIdxGlobToPart
 
std::map< int, int > ndeIdxPartToGlob
 
std::map< int, int > elmIdxGlobToPart
 
std::map< int, int > elmIdxPartToGlob
 
MeshType_t mshType
 

Constructor & Destructor Documentation

◆ meshPartition()

meshPartition::meshPartition ( int  pidx,
const std::vector< int > &  glbElmPartedIdx,
const std::vector< int > &  glbElmConn,
MeshType_t  inMshType 
)

Definition at line 42 of file meshPartitioner.C.

References elmIdxGlobToPart, elmIdxPartToGlob, globElmIdx, globNdeIdx, MESH_TETRA_4, MESH_TRI_3, mshType, ndeIdxGlobToPart, ndeIdxPartToGlob, nElm, nNde, nNdeElm, partElmConn, and pIdx.

Referenced by meshPartitioner::buildPartitions().

46 {
47  mshType = inMshType;
48  pIdx = pidx;
49  nNde = 0;
50  nElm = 0;
52  nNdeElm = 4;
53  else if (mshType == MeshType_t::MESH_TRI_3)
54  nNdeElm = 3;
55  // finding partition elements
56  int glbElmIdx = 1;
57  for (int ie : glbElmPartedIdx)
58  {
59  if (ie == pIdx)
60  {
61  nElm++;
62  elmIdxGlobToPart[glbElmIdx] = nElm;
63  elmIdxPartToGlob[nElm] = glbElmIdx;
64  globElmIdx.push_back(glbElmIdx);
65  //std::cout << "My element = " << glbElmIdx << std::endl;
66  // attaching nodes of this element to the current partition
67  for (int iNde = 0; iNde < nNdeElm; iNde++)
68  {
69  int glbNdeIdx = glbElmConn[(glbElmIdx - 1) * nNdeElm + iNde];
70  auto it = ndeIdxGlobToPart.find(glbNdeIdx);
71  int partNdeIdx;
72  if (it == ndeIdxGlobToPart.end())
73  {
74  nNde++;
75  partNdeIdx = nNde;
76  ndeIdxGlobToPart[glbNdeIdx] = nNde;
77  ndeIdxPartToGlob[nNde] = glbNdeIdx;
78  globNdeIdx.push_back(glbNdeIdx);
79  //std::cout << "partition " << pIdx
80  // << " global node id " << glbNdeIdx
81  // << " is local " << nNde
82  // << std::endl;
83  }
84  else
85  {
86  partNdeIdx = it->second;
87  }
88  partElmConn.push_back(partNdeIdx);
89  }
90  }
91  glbElmIdx++;
92  }
93  //std::cout << "Min connectivity passed to partitioner = "
94  // << *std::min_element(glbElmConn.begin(), glbElmConn.end())
95  // << std::endl;
96 
97  // Debug information
98  //std::cout << "I am partition " << pidx << std::endl
99  // << " cycled on " << glbElmIdx - 1 << " global elements "
100  // << std::endl
101  // << " my min global element idx is "
102  // << *std::min_element(globElmIdx.begin(), globElmIdx.end())
103  // << std::endl
104  // << " my max global element idx is "
105  // << *std::max_element(globElmIdx.begin(), globElmIdx.end())
106  // << std::endl
107  // << " my nNde = " << nNde << " my nElm = " << nElm << std::endl;
108 }
std::vector< int > globNdeIdx
std::map< int, int > ndeIdxPartToGlob
MeshType_t mshType
std::map< int, int > ndeIdxGlobToPart
std::vector< int > globElmIdx
std::map< int, int > elmIdxGlobToPart
std::vector< int > partElmConn
std::map< int, int > elmIdxPartToGlob

◆ ~meshPartition()

meshPartition::~meshPartition ( )
default

Member Function Documentation

◆ getConns()

std::vector<int> meshPartition::getConns ( ) const
inline

Definition at line 71 of file meshPartitioner.H.

71 { return partElmConn; }
std::vector< int > partElmConn

◆ getCrds()

std::vector< double > meshPartition::getCrds ( const std::vector< double > &  crds) const

Definition at line 111 of file meshPartitioner.C.

References globNdeIdx.

112 {
113  std::vector<double> x;
114  for (int in : globNdeIdx)
115  x.push_back(crds[in - 1]);
116  return x;
117 }
std::vector< int > globNdeIdx

◆ getElmSlns()

std::vector< double > meshPartition::getElmSlns ( const std::vector< double > &  slns) const

Definition at line 120 of file meshPartitioner.C.

References globElmIdx.

121 {
122  std::vector<double> x;
123  for (int ie : globElmIdx)
124  x.push_back(slns[ie - 1]);
125  return x;
126 }
std::vector< int > globElmIdx

◆ getElmSlnsVec()

std::vector< double > meshPartition::getElmSlnsVec ( const std::vector< double > &  slns,
int  nComp 
) const

Definition at line 130 of file meshPartitioner.C.

References globElmIdx.

131 {
132  std::vector<double> x;
133  for (int ie : globElmIdx)
134  for (int iComp = 0; iComp < nComp; iComp++)
135  x.push_back(slns[(ie - 1) * nComp + iComp]);
136  return x;
137 }
std::vector< int > globElmIdx

◆ getPartToGlobElmMap()

std::map<int, int> meshPartition::getPartToGlobElmMap ( ) const
inline

Definition at line 76 of file meshPartitioner.H.

76 { return elmIdxPartToGlob; }
std::map< int, int > elmIdxPartToGlob

◆ getPartToGlobNodeMap()

std::map<int, int> meshPartition::getPartToGlobNodeMap ( ) const
inline

Definition at line 75 of file meshPartitioner.H.

75 { return ndeIdxPartToGlob; }
std::map< int, int > ndeIdxPartToGlob

Member Data Documentation

◆ elmIdxGlobToPart

std::map<int, int> meshPartition::elmIdxGlobToPart
private

Definition at line 90 of file meshPartitioner.H.

Referenced by meshPartition().

◆ elmIdxPartToGlob

std::map<int, int> meshPartition::elmIdxPartToGlob
private

Definition at line 91 of file meshPartitioner.H.

Referenced by meshPartition().

◆ globElmIdx

std::vector<int> meshPartition::globElmIdx
private

Definition at line 86 of file meshPartitioner.H.

Referenced by getElmSlns(), getElmSlnsVec(), and meshPartition().

◆ globNdeIdx

std::vector<int> meshPartition::globNdeIdx
private

Definition at line 85 of file meshPartitioner.H.

Referenced by getCrds(), and meshPartition().

◆ mshType

MeshType_t meshPartition::mshType
private

Definition at line 92 of file meshPartitioner.H.

Referenced by meshPartition().

◆ ndeIdxGlobToPart

std::map<int, int> meshPartition::ndeIdxGlobToPart
private

Definition at line 88 of file meshPartitioner.H.

Referenced by meshPartition().

◆ ndeIdxPartToGlob

std::map<int, int> meshPartition::ndeIdxPartToGlob
private

Definition at line 89 of file meshPartitioner.H.

Referenced by meshPartition().

◆ nElm

int meshPartition::nElm

◆ nNde

int meshPartition::nNde

◆ nNdeElm

int meshPartition::nNdeElm
private

Definition at line 84 of file meshPartitioner.H.

Referenced by meshPartition().

◆ partElmConn

std::vector<int> meshPartition::partElmConn
private

Definition at line 87 of file meshPartitioner.H.

Referenced by meshPartition().

◆ pIdx

int meshPartition::pIdx
private

Definition at line 83 of file meshPartitioner.H.

Referenced by meshPartition().


The documentation for this class was generated from the following files: