Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mesh::Partition Class Reference

#include <PMesh.H>

Collaboration diagram for Mesh::Partition:

Public Member Functions

 Partition ()
 
int Read (const std::string &meshname, int id)
 
int Read (const std::string &MeshName, IRAD::Comm::CommunicatorObject &comm, bool allow_n2m, std::ostream &ErrOut)
 
MeshUtilityObjectMesh ()
 
const MeshUtilityObjectMesh () const
 
PartInfoInfo ()
 
const PartInfoInfo () const
 
std::vector< Border > & Borders ()
 
const std::vector< Border > & Borders () const
 
IRAD::Comm::CommunicatorObject * CommunicatorPtr ()
 
int GetBorderElements (std::vector< Mesh::IndexType > &be) const
 

Public Attributes

MeshUtilityObject _mesh
 
PartInfo _info
 
std::vector< Border_borders
 

Private Attributes

IRAD::Comm::CommunicatorObject * _communicator
 

Detailed Description

Definition at line 95 of file PMesh.H.

Constructor & Destructor Documentation

Partition ( )
inline

Definition at line 99 of file PMesh.H.

99 : _communicator(NULL), _mesh(),_info(),_borders() {};
std::vector< Border > _borders
Definition: PMesh.H:104
IRAD::Comm::CommunicatorObject * _communicator
Definition: PMesh.H:97
MeshUtilityObject _mesh
Definition: PMesh.H:99
PartInfo _info
Definition: PMesh.H:103

Member Function Documentation

std::vector<Border>& Borders ( )
inline

Definition at line 114 of file PMesh.H.

References _borders.

114 { return(_borders); };
std::vector< Border > _borders
Definition: PMesh.H:104
const std::vector<Border>& Borders ( ) const
inline

Definition at line 115 of file PMesh.H.

References _borders.

115 { return(_borders); };
std::vector< Border > _borders
Definition: PMesh.H:104
IRAD::Comm::CommunicatorObject* CommunicatorPtr ( )
inline

Definition at line 116 of file PMesh.H.

References _communicator.

116 { return(_communicator); };
IRAD::Comm::CommunicatorObject * _communicator
Definition: PMesh.H:97
int GetBorderElements ( std::vector< Mesh::IndexType > &  be) const

Definition at line 13 of file PMesh.C.

References _info, _mesh, Mesh::MeshUtilityObject::ENDUAL, Mesh::MeshUtilityObject::GetCon(), Mesh::PartInfo::nshared, Mesh::MeshUtilityObject::NumberOfElements(), and Mesh::MeshUtilityObject::NumberOfNodes().

14  {
15  std::list<Mesh::IndexType> belist;
16  Mesh::IndexType number_of_nodes = _mesh.NumberOfNodes();
17  Mesh::IndexType number_of_elements = _mesh.NumberOfElements();
18  std::vector<bool> element_processed(number_of_elements,false);
19  Mesh::IndexType nvolume_nodes = number_of_nodes - _info.nshared;
21  for(Mesh::IndexType nn = nvolume_nodes;nn < number_of_nodes;nn++){
22  std::vector<Mesh::IndexType>::const_iterator ei =
23  dc[nn].begin();
24  while(ei != dc[nn].end()){
25  if(!element_processed[*ei-1]){
26  element_processed[*ei-1] = true; // cheap uniquity
27  belist.push_back(*ei);
28  }
29  ei++;
30  }
31  }
32  belist.sort();
33  std::list<Mesh::IndexType>::iterator beli = belist.begin();
34  be.resize(belist.size());
35  std::vector<Mesh::IndexType>::iterator bei = be.begin();
36  while(bei != be.end())
37  *bei++ = *beli++;
38  return(0);
39  };
General connectivity object.
Definition: Mesh.H:334
Connectivity & GetCon(const MeshConType type)
Definition: Mesh.H:500
int NumberOfElements() const
Definition: Mesh.H:470
MeshUtilityObject _mesh
Definition: PMesh.H:99
int NumberOfNodes() const
Definition: Mesh.H:469
PartInfo _info
Definition: PMesh.H:103
IRAD::Primitive::IndexType IndexType
Definition: Mesh.H:57
Mesh::IndexType nshared
number of borders
Definition: PMesh.H:89

Here is the call graph for this function:

PartInfo& Info ( )
inline

Definition at line 112 of file PMesh.H.

References _info.

112 { return (_info); };
PartInfo _info
Definition: PMesh.H:103
const PartInfo& Info ( ) const
inline

Definition at line 113 of file PMesh.H.

References _info.

113 { return(_info); };
PartInfo _info
Definition: PMesh.H:103
MeshUtilityObject& Mesh ( )
inline

Definition at line 110 of file PMesh.H.

References _mesh.

110 { return (_mesh); };
MeshUtilityObject _mesh
Definition: PMesh.H:99
const MeshUtilityObject& Mesh ( ) const
inline

Definition at line 111 of file PMesh.H.

References _mesh.

111 { return (_mesh); };
MeshUtilityObject _mesh
Definition: PMesh.H:99
int Read ( const std::string &  meshname,
int  id 
)

Definition at line 127 of file PMesh.C.

References _borders, _info, _mesh, Mesh::MeshUtilityObject::ECon(), Mesh::PartInfo::nborder, Mesh::MeshUtilityObject::NC(), Mesh::PartInfo::nelem, Mesh::PartInfo::nlocal, Mesh::PartInfo::nnodes, Mesh::PartInfo::nown, Mesh::PartInfo::npart, Mesh::PartInfo::nshared, Mesh::PartInfo::part, Mesh::Connectivity::ShrinkWrap(), and Mesh::Connectivity::Sync().

128  {
129  // rank = id - 1
130  std::ifstream Inf;
131  std::ostringstream FNOstr;
132  if(id > 0){
133  FNOstr << MeshName << "." << id << ".info";
134  Inf.open(FNOstr.str().c_str());
135  if(!Inf)
136  return(2);
138  Inf.close();
140  FNOstr.str("");
141  }
142  _info.nborder = 0;
143  _info.nshared = 0;
144  _info.nown = 0;
145  if(id > 0)
146  FNOstr << MeshName << "." << id << ".pmesh";
147  else
148  FNOstr << MeshName;
149  Inf.open(FNOstr.str().c_str());
150  if(!Inf)
151  return(3);
152  // Inf >> _nc;
153  // Inf >> _ec;
154  // _ec.ShrinkWrap();
155  // _ec.Sync();
156  Inf >> _mesh.NC();
157  Inf >> _mesh.ECon();
158  _mesh.ECon().ShrinkWrap();
159  _mesh.ECon().Sync();
160  if(id > 0){
161  Inf >> _info.nborder;
162  _borders.resize(_info.nborder);
163  for(Mesh::IndexType nn = 0;nn < _info.nborder;nn++){
164  Mesh::IndexType nrecv = 0;
165  Mesh::IndexType nsend = 0;
166  Inf >> _borders[nn].rpart >> nrecv >> nsend;
167  for(Mesh::IndexType ii = 0;ii < nrecv;ii++){
168  Mesh::IndexType nodeid = 0;
169  Inf >> nodeid;
170  _borders[nn].nrecv.push_back(nodeid);
171  Inf >> nodeid;
172  }
173  for(Mesh::IndexType ii = 0;ii < nsend;ii++){
174  Mesh::IndexType nodeid = 0;
175  Inf >> nodeid;
176  _borders[nn].nsend.push_back(nodeid);
177  Inf >> nodeid;
178  }
179  }
180  }
181  Inf.close();
182  return(0);
183  };
void Sync()
Definition: Mesh.C:246
std::vector< Border > _borders
Definition: PMesh.H:104
void ShrinkWrap()
Definition: Mesh.C:247
Connectivity & ECon()
Definition: Mesh.H:479
Mesh::IndexType npart
Definition: PMesh.H:84
Mesh::IndexType part
total number of partitions
Definition: PMesh.H:85
Mesh::IndexType nnodes
total number of elems
Definition: PMesh.H:87
Mesh::IndexType nborder
total number of nodes
Definition: PMesh.H:88
MeshUtilityObject _mesh
Definition: PMesh.H:99
Mesh::IndexType nlocal
number of shared nodes owned
Definition: PMesh.H:91
Mesh::IndexType nelem
partition id
Definition: PMesh.H:86
PartInfo _info
Definition: PMesh.H:103
IRAD::Primitive::IndexType IndexType
Definition: Mesh.H:57
Mesh::IndexType nown
number of shared nodes
Definition: PMesh.H:90
Mesh::IndexType nshared
number of borders
Definition: PMesh.H:89
NodalCoordinates & NC()
Definition: Mesh.H:471

Here is the call graph for this function:

int Read ( const std::string &  MeshName,
IRAD::Comm::CommunicatorObject &  comm,
bool  allow_n2m,
std::ostream &  ErrOut 
)

Definition at line 41 of file PMesh.C.

References _borders, _communicator, _info, _mesh, Mesh::MeshUtilityObject::ECon(), Mesh::PartInfo::nborder, Mesh::MeshUtilityObject::NC(), Mesh::PartInfo::nelem, Mesh::PartInfo::nlocal, Mesh::PartInfo::nnodes, Mesh::PartInfo::nown, Mesh::PartInfo::npart, Mesh::PartInfo::nshared, Mesh::MeshUtilityObject::NumberOfElements(), Mesh::MeshUtilityObject::NumberOfNodes(), Mesh::PartInfo::part, rank, and Mesh::Connectivity::ShrinkWrap().

42  {
43  unsigned int nproc = comm.Size();
44  unsigned int rank = comm.Rank();
45  unsigned int id = rank + 1;
46  // Read the partitioning info
47  if(nproc > 1){
48  std::ifstream InfoInf;
49  std::ostringstream FNOstr;
50  FNOstr << MeshName << "." << id << ".info";
51  InfoInf.open(FNOstr.str().c_str());
52  if(!InfoInf){
53  comm.SetErr(1);
54  }
55  if(comm.Check()){
56  ErrOut << "Partition::Read Could not find partition info for " << MeshName;
57  return(1);
58  }
59  InfoInf >> _info.npart >> _info.part >> _info.nelem >> _info.nnodes >> _info.nborder
60  >> _info.nshared >> _info.nown;
61  if(_info.npart != nproc && !allow_n2m){
62  comm.SetErr(1);
63  }
64  if(comm.Check()){
65  ErrOut << "Partition::Read " << MeshName << " has partition/processor mismatch: ("
66  << _info.npart << "/" << nproc << ").\n";
67  return(1);
68  }
70  InfoInf.close();
71  }
72  else{
73  _info.nborder = 0;
74  _info.nshared = 0;
75  }
76  // done reading partition info
77  std::ifstream Inf;
78  std::ostringstream Ostr;
79  Ostr << MeshName;
80  if(nproc > 1)
81  Ostr << "." << id << ".pmesh";
82  else
83  Ostr << ".mesh";
84  Inf.open(Ostr.str().c_str());
85  // Don't blink or you'll miss the mesh actually being loaded here.
86  Inf >> _mesh.NC() >> _mesh.ECon();
87  _mesh.ECon().ShrinkWrap();
88  // Inf >> _nc >> _ec;
89  // _ec.ShrinkWrap();
90  // done loading actual mesh
91  // Mesh::IndexType number_of_nodes = _nc.Size();
92  // Mesh::IndexType number_of_elements = _ec.Nelem();
93  Mesh::IndexType number_of_nodes = _mesh.NumberOfNodes();
94  Mesh::IndexType number_of_elements = _mesh.NumberOfElements();
95  if(nproc == 1){
96  _info.nnodes = number_of_nodes;
97  _info.nown = 0;
98  _info.nlocal = number_of_nodes;
99  _info.nelem = number_of_elements;
100  }
101  else{
102  Inf >> _info.nborder;
103  _borders.resize(_info.nborder);
104  for(Mesh::IndexType nn = 0;nn < _info.nborder;nn++){
105  Mesh::IndexType nrecv = 0;
106  Mesh::IndexType nsend = 0;
107  Inf >> _borders[nn].rpart >> nrecv >> nsend;
108  _borders[nn].nrecv.resize(nrecv);
109  for(Mesh::IndexType ii = 0;ii < nrecv;ii++){
110  Mesh::IndexType nodeid = 0;
111  Inf >> _borders[nn].nrecv[ii] >> nodeid;
112  }
113  _borders[nn].nsend.resize(nsend);
114  for(Mesh::IndexType ii = 0;ii < nsend;ii++){
115  Mesh::IndexType nodeid = 0;
116  Inf >> _borders[nn].nsend[ii] >> nodeid;
117  }
118  }
119  }
120  Inf.close();
121  _communicator = &comm;
122  return(0);
123  }
std::vector< Border > _borders
Definition: PMesh.H:104
void ShrinkWrap()
Definition: Mesh.C:247
IRAD::Comm::CommunicatorObject * _communicator
Definition: PMesh.H:97
Connectivity & ECon()
Definition: Mesh.H:479
Mesh::IndexType npart
Definition: PMesh.H:84
Mesh::IndexType part
total number of partitions
Definition: PMesh.H:85
int NumberOfElements() const
Definition: Mesh.H:470
Mesh::IndexType nnodes
total number of elems
Definition: PMesh.H:87
Mesh::IndexType nborder
total number of nodes
Definition: PMesh.H:88
MeshUtilityObject _mesh
Definition: PMesh.H:99
Mesh::IndexType nlocal
number of shared nodes owned
Definition: PMesh.H:91
Mesh::IndexType nelem
partition id
Definition: PMesh.H:86
int NumberOfNodes() const
Definition: Mesh.H:469
static int rank
Definition: advectest.C:66
PartInfo _info
Definition: PMesh.H:103
IRAD::Primitive::IndexType IndexType
Definition: Mesh.H:57
Mesh::IndexType nown
number of shared nodes
Definition: PMesh.H:90
Mesh::IndexType nshared
number of borders
Definition: PMesh.H:89
NodalCoordinates & NC()
Definition: Mesh.H:471

Here is the call graph for this function:

Member Data Documentation

std::vector<Border> _borders

Definition at line 104 of file PMesh.H.

Referenced by Borders(), and Read().

IRAD::Comm::CommunicatorObject* _communicator
private

Definition at line 97 of file PMesh.H.

Referenced by CommunicatorPtr(), and Read().

PartInfo _info

Definition at line 103 of file PMesh.H.

Referenced by GetBorderElements(), Info(), and Read().

Definition at line 99 of file PMesh.H.

Referenced by GetBorderElements(), Mesh(), and Read().


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