40 #include "primitive_utilities.H"
53 const double TOL = 1e-9;
62 typedef IRAD::Primitive::MultiContainer<IndexType>::VecVec
MultiVec;
63 typedef IRAD::Primitive::MultiContainer<IndexType,IndexType>::VecMap
VecMap;
67 template<
typename OuterCont,
typename OutCont,
typename InnerCont,
typename MapType>
70 trg.resize(src.size());
71 typename OuterCont::iterator sci = src.begin();
72 typename OutCont::iterator oci = trg.begin();
73 while(sci != src.end()){
74 typename InnerCont::iterator ici = sci->begin();
75 while(ici != sci->end())
76 oci->push_back(m[*ici++]);
83 template<
typename ListContainerType,
typename ListType>
87 typename ListContainerType::const_iterator lci = fc.begin();
88 while(lci != fc.end()){
89 typename ListType::const_iterator li = lci->begin();
90 while(li != lci->end()){
100 template<
typename OuterCont,
typename InnerCont,
typename OutCont>
102 typename OuterCont::iterator cci = con.begin();
104 while(cci != con.end()){
105 typename InnerCont::iterator ccni = cci->begin();
106 while(ccni != cci->end())
107 ocon.push_back(*ccni++);
113 template<
typename OuterContType>
117 typename OuterContType::iterator ci = con.begin();
118 while(ci != con.end()){
119 total_size += ci->size();
126 template<
typename OuterContType,
typename InnerContType,
typename RetCont,
typename idxtype>
128 OuterContType &source)
130 IndexType number_of_elements = source.size();
131 xadj.resize(number_of_elements+1);
132 IndexType number_entries = GetTotalSize<OuterContType>(source);
133 adj.reserve(number_entries);
134 typename OuterContType::iterator si = source.begin();
137 while(si != source.end()){
138 typename InnerContType::iterator ei = si->begin();
139 xadj[elm] =
static_cast<idxtype
>(si->size() + xadj[elm-1]);
141 while(ei != si->end())
142 adj.push_back(static_cast<idxtype>(*ei++-1));
152 template<
typename ListContainerType,
typename ListType>
154 ListContainerType &fc,
IndexType nnodes=0)
157 nnodes = MaxNodeId<ListContainerType,ListType>(fc);
158 anodelist.resize(nnodes);
159 typename ListContainerType::iterator lci = fc.begin();
160 while(lci != fc.end())
162 typename ListType::iterator li = lci->begin();
163 while(li != lci->end()){
167 next_node = *(lci->begin());
170 anodelist[this_node].push_back(next_node);
171 anodelist[next_node-1].push_back(this_node+1);
177 anodelist[
node].sort();
178 anodelist[
node].unique();
188 template<
typename ListContainerType,
typename ListType>
189 void AdjEList(std::vector<std::list<IndexType> > &aelist,
190 ListContainerType &dual_con,
unsigned long nel=0)
193 nel = MaxNodeId<ListContainerType,ListType>(dual_con);
195 typename ListContainerType::iterator lci = dual_con.begin();
196 while(lci != dual_con.end())
198 typename ListType::iterator li = lci->begin();
199 while(li != lci->end()){
201 typename ListType::iterator li2 = li;
202 while(li2 != lci->end()){
204 aelist[this_node].push_back(nexnode+1);
205 aelist[nexnode].push_back(this_node+1);
213 aelist[
node].unique();
217 template<
typename ConType,
typename IConType>
220 typename ConType::iterator ci = con.begin();
223 while(ci != con.end())
226 typename IConType::iterator eni = ci->begin();
227 while(eni != ci->end())
238 template<
typename ContainerType,
typename Icont>
251 friend std::ostream &
operator<<(std::ostream &oSt,
253 friend std::istream &
operator>>(std::istream &iSt,
312 assert(!(n >
nnodes || n == 0));
317 assert(!(n >
nnodes || n == 0));
344 void Resize(
unsigned int N = 0);
347 assert(n > 0 && n <=
_nelem);
348 return((*
this)[n-1]);
351 assert(n > 0 && n <=
_nelem);
352 return((*
this)[n-1]);
355 assert(e > 0 && e <= _nelem && n > 0);
356 assert(n <= (*
this)[e-1].size());
357 return((*
this)[e-1][n-1]);
360 assert(e > 0 && e <= _nelem && n > 0);
361 assert(n <= (*
this)[e-1].size());
362 return((*
this)[e-1][n-1]);
367 assert(n > 0 && n <=
_nelem);
368 return (
_sizes.empty() ? (*this)[n-1].size() :
_sizes[n-1]);
370 void AddElement(
const std::vector<IndexType> &elem);
383 bool exclude_self=
true,
392 std::vector<Mesh::SymbolicFace> &sf,
Connectivity &dc)
const;
397 std::vector<std::vector<IndexType> >::const_iterator eci = this->begin();
398 while(eci != this->end()){
399 std::vector<IndexType>::const_iterator eni = eci->begin();
400 while(eni != eci->end())
401 outcon.push_back(*eni++);
406 void ElementsOn(std::vector<Mesh::IndexType> &nodes,
408 std::vector<Mesh::IndexType> &subset);
435 friend std::ostream &
operator<<(std::ostream &oSt,
437 friend std::istream &
operator>>(std::istream &iSt,
457 enum MeshConType {
EN=0,
ENDUAL,
ED,
EDDUAL,
EF,
EFDUAL,
DN,
DNDUAL,
DF,
DFDUAL,
FN,
FNDUAL ,
NCONS};
526 bool connectivity_known_type =
false;
527 assert(connectivity_known_type);
566 void ReOrient(std::vector<IndexType> &ec);
668 void ReOrient(std::vector<IndexType> &ec);
681 const std::vector<IndexType> &)
const;
731 std::vector<double> ¢roids);
736 std::vector<Mesh::IndexType> &candidates,
737 std::vector<Mesh::IndexType> &cells);
741 std::vector<Mesh::IndexType> &cells);
746 const GenericElement &el,
748 const NodalCoordinates &nc,
754 const GenericCell_2 &el,
756 const NodalCoordinates &nc,
778 const NodalCoordinates &nc,
780 std::list<IndexType> &elements);
783 const NodalCoordinates &nc,
785 const std::vector<Mesh::IndexType> &elements,
790 const NodalCoordinates &nc,
797 const NodalCoordinates &nc,
805 const NodalCoordinates &nc,
/brief Cartesian 3 Vector
IndexType MaxNodeId(const ListContainerType &fc)
Return the maximum of all elements of a multicontainer.
int GetMeshCentroids(Mesh::NodalCoordinates &nc, Mesh::Connectivity &conn, std::vector< double > ¢roids)
Geometric Primitives interface.
Mesh::IndexType closest_node(const GeoPrim::CPoint &p, double *dist_ptr=NULL) const
double * operator[](IndexType n)
friend std::istream & operator>>(std::istream &iSt, Mesh::GeometricEntity &ge)
void GetAdjacent(Connectivity &rl, Connectivity &dc, IndexType n=0, bool sortit=false)
void init_copy(IndexType n, double *data)
General connectivity object.
std::vector< IndexType > & Element(IndexType n)
std::vector< IndexType > _sizes
GenericCell_2(IndexType s=3)
void shape_func(const GeoPrim::CVector &, double[]) const
bool operator<(const TestFace &f)
Mesh::Connectivity _collections
IndexType NumberOfEdges(ConType &con)
const Connectivity & GetCon(const MeshConType type) const
void dshape_func(const GeoPrim::CVector &, double[][2]) const
void jacobian(const GeoPrim::CPoint p[], const GeoPrim::CVector &, GeoPrim::CVector J[]) const
Mesh::IndexType GlobalFindPointInMesh(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const Connectivity &dc, const GeoPrim::CBox &box, GeoPrim::CVector &natc)
int ReadMesh(const std::string &path, Mesh::UnstructuredMesh &mesh)
int DestroyConnectivity(const MeshConType type)
const Connectivity & ECon() const
boolean empty(T_VertexSet s)
GeoPrim::C3Point Centroid()
Class Mesh is the main class that holds all information to describe the current state of the mesh...
void dshape_func(const GeoPrim::CVector &, double[][3]) const
void GetNeighborhood(NeighborHood &, const Connectivity &dc, IndexType size=0)
bool LUDcmp(GeoPrim::CVector a[], int indx[])
real *8 function offset(vNorm, x2, y2, z2)
void GetPointSet(GeoPrim::CPoint ps[], IndexType elnum, const Connectivity &ec, const NodalCoordinates &nc)
Connectivity & GetCon(const MeshConType type)
void ReOrient(std::vector< IndexType > &ec)
int FormConnectivity(const MeshConType type)
void ElementsOn(std::vector< Mesh::IndexType > &nodes, Connectivity &dc, std::vector< Mesh::IndexType > &subset)
void Resize(unsigned int N=0)
friend std::istream & operator>>(std::istream &iSt, Mesh::NodalCoordinates &nc)
void CreateAdjacentNodeList(std::vector< std::list< IndexType > > &anodelist, ListContainerType &fc, IndexType nnodes=0)
Given an array of adjacent node lists (like an array of face connectivities), this function will loop...
void GetMeshBoxes(const NodalCoordinates &nc, const Connectivity &ec, GeoPrim::CBox &mesh_box, GeoPrim::CBox &small_box, GeoPrim::CBox &large_box)
Bounding boxes for a mesh.
Mesh::IndexType FindPointInMesh_2(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const Connectivity &dc, const GeoPrim::CBox &box, GeoPrim::CVector &natc)
Locate element containing given physical point.
bool ShapeOK(std::vector< IndexType > &ec, NodalCoordinates &nc) const
void MapElements(OuterCont &src, OutCont &trg, MapType &m)
void get_face_connectivities(Connectivity &, const std::vector< IndexType > &) const
Face conn for given element.
IRAD::Primitive::MultiContainer< IndexType, IndexType >::VecMap VecMap
GenericElement(IndexType s=4)
std::vector< IndexType > IndexVec
IndexType GetTotalSize(OuterContType &con)
Return the total number of entries in a multicontainer.
double & z(IndexType n=1)
const double & x(IndexType n=1) const
std::pair< IndexType, CellEntityIDType > SubEntityId
void ReOrient(std::vector< IndexType > &ec)
void matrix_mode(IndexType offset=0)
void Container2CSR(RetCont &xadj, RetCont &adj, OuterContType &source)
void Inverse(Connectivity &, IndexType nnodes=0) const
IndexType & Node(IndexType e, IndexType n)
bool Inverted(std::vector< IndexType > &ec, NodalCoordinates &nc) const
void GetNormalSet(GeoPrim::CVector ns[], IndexType elnum, const Connectivity &ec, const NodalCoordinates &nc)
IndexType Esize(IndexType n) const
friend std::ostream & operator<<(std::ostream &oSt, const Mesh::NodalCoordinates &nc)
const NodalCoordinates & NC() const
void interpolate(const GeoPrim::CVector f[], const GeoPrim::CVector &nc, GeoPrim::CVector &) const
int NumberOfElements() const
int CollideCellsWithBox(Mesh::NodalCoordinates &nc, Mesh::Connectivity &conn, GeoPrim::CBox &box, std::vector< Mesh::IndexType > &candidates, std::vector< Mesh::IndexType > &cells)
Connects continuous to discrete.
friend std::ostream & operator<<(std::ostream &oSt, const Connectivity &ec)
Mesh::IndexType FindPointInMesh(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const Connectivity &dc, const GeoPrim::CBox &box, GeoPrim::CVector &natc)
Locate element containing given physical point.
void FormGraph(const ContainerType &adjlist)
friend std::istream & operator>>(std::istream &iSt, Connectivity &ec)
void BreadthFirstRenumber(std::vector< Mesh::IndexType > &remap)
Mesh::IndexType FindPointInCells(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const std::vector< Mesh::IndexType > &elements, GeoPrim::CVector &natc)
Locate element containing given physical point.
IndexType Node(IndexType e, IndexType n) const
double & x(IndexType n=1)
void BuildFaceConnectivity(Connectivity &fcon, Connectivity &ef, std::vector< Mesh::SymbolicFace > &sf, Connectivity &dc) const
const GeoPrim::CPoint closest_point(const GeoPrim::CPoint &p) const
void graph_mode(IndexType offset=0)
IRAD::Primitive::ubyte CellEntityIDType
void Flatten(std::vector< T > &outcon) const
void InverseDegenerate(Connectivity &, IndexType nnodes=0) const
const double & y(IndexType n=1) const
Connectivity & Con(const MeshConType type)
const double & z(IndexType n=1) const
int NumberOfNodes() const
void LUBksb(GeoPrim::CVector a[], int indx[], GeoPrim::CVector &b)
void shapef_jacobian_at(const GeoPrim::CPoint &p, GeoPrim::CVector &natc, IndexType elnum, const Connectivity &ec, const NodalCoordinates &nc, GeoPrim::CVector &fvec, GeoPrim::CVector fjac[]) const
int CollideMeshWithBox(Mesh::NodalCoordinates &nc, Mesh::Connectivity &conn, GeoPrim::CBox &box, std::vector< Mesh::IndexType > &cells)
void Flatten(OuterCont &con, OutCont &ocon)
Populate OutCont with a flat list of entries from a multicontainer.
bool NewtonRaphson(GeoPrim::CVector &natc, IndexType elnum, const GenericElement &el, const Connectivity &ec, const NodalCoordinates &nc, const GeoPrim::CPoint &point)
Newton-Raphson method, customized for using the GeoPrimitives and computational mesh constructs...
std::vector< IndexType > Element(IndexType n) const
void shapef_jacobian_at(const GeoPrim::CPoint &p, GeoPrim::CVector &natc, IndexType elnum, const Connectivity &ec, const NodalCoordinates &nc, GeoPrim::CVector &fvec, GeoPrim::CVector jac[]) const
void GetCoordinateBounds(NodalCoordinates &nc, std::vector< double > &)
IRAD::Primitive::IndexType IndexType
void jacobian(const GeoPrim::CPoint p[], const GeoPrim::CVector &nc, GeoPrim::CVector J[]) const
void AdjEList(std::vector< std::list< IndexType > > &aelist, ListContainerType &dual_con, unsigned long nel=0)
Given an array of adjacent node lists (like an array of face connectivities), this function will loop...
void interpolate(const GeoPrim::CVector f[], const GeoPrim::CVector &nc, GeoPrim::CVector &) const
NodalCoordinates _nodal_coordinates
friend std::ostream & operator<<(std::ostream &oSt, const Mesh::GeometricEntity &ge)
GeoPrim::C3Point Centroid()
IRAD::Primitive::ubyte GeoDimType
bool NewtonRaphson_2(GeoPrim::CVector &natc, IndexType elnum, const GenericCell_2 &el, const Connectivity &ec, const NodalCoordinates &nc, const GeoPrim::CPoint &point)
Newton-Raphson method, customized for using the GeoPrimitives and computational mesh constructs...
void init_node(IndexType n, const GeoPrim::CPoint &)
const Connectivity & Con(const MeshConType type) const
IRAD::Primitive::MultiContainer< IndexType >::VecVec MultiVec
void shape_func(const GeoPrim::CVector &, double[]) const
Encapsulates an element-connectivity of a mesh.
const double * operator[](IndexType n) const
std::pair< SubEntityId, SubEntityId > SymbolicFace
std::vector< Connectivity > _connectivities
double & y(IndexType n=1)
void FindElementsInBox(const GeoPrim::CBox &box, const NodalCoordinates &nc, const Connectivity &dc, std::list< IndexType > &elements)
Get elements in box.