50 namespace MultiRegions
69 ExpList2D::ExpList2D():
89 const bool DeclareCoeffPhysArrays):
90 ExpList(In,DeclareCoeffPhysArrays)
101 const std::vector<unsigned int> &eIDs,
102 const bool DeclareCoeffPhysArrays,
104 ExpList(In,eIDs,DeclareCoeffPhysArrays)
136 const bool DeclareCoeffPhysArrays,
137 const std::string &var,
151 = graph2D->GetExpansions(var);
153 SpatialDomains::ExpansionMap::const_iterator expIt;
154 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
159 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
160 ::TriGeom>(expIt->second->m_geomShPtr)))
163 = expIt->second->m_basisKeyVector[0];
165 = expIt->second->m_basisKeyVector[1];
178 Ntri->SetElmtId(elmtid++);
179 (*m_exp).push_back(Ntri);
186 tri->SetElmtId(elmtid++);
187 (*m_exp).push_back(tri);
194 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
198 = expIt->second->m_basisKeyVector[0];
200 = expIt->second->m_basisKeyVector[1];
205 quad->SetElmtId(elmtid++);
206 (*m_exp).push_back(quad);
213 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
220 for(
int i = 0; i < (*m_exp).size(); ++i)
222 (*m_exp)[i]->SetElmtId(i);
234 if (DeclareCoeffPhysArrays)
263 const bool DeclareCoeffPhysArrays,
277 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
282 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
283 ::TriGeom>(expIt->second->m_geomShPtr)))
286 = expIt->second->m_basisKeyVector[0];
288 = expIt->second->m_basisKeyVector[1];
301 Ntri->SetElmtId(elmtid++);
302 (*m_exp).push_back(Ntri);
309 tri->SetElmtId(elmtid++);
310 (*m_exp).push_back(tri);
317 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
321 = expIt->second->m_basisKeyVector[0];
323 = expIt->second->m_basisKeyVector[1];
328 quad->SetElmtId(elmtid++);
329 (*m_exp).push_back(quad);
336 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
351 if (DeclareCoeffPhysArrays)
408 graph2D->GetExpansions();
414 SpatialDomains::ExpansionMap::const_iterator expIt;
415 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
420 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains::
421 TriGeom>(expIt->second->m_geomShPtr)))
428 Ntri->SetElmtId(elmtid++);
429 (*m_exp).push_back(Ntri);
435 tri->SetElmtId(elmtid++);
436 (*m_exp).push_back(tri);
444 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
449 quad->SetElmtId(elmtid++);
450 (*m_exp).push_back(quad);
458 "dynamic cast to a proper Geometry2D failed");
500 const bool DeclareCoeffPhysArrays,
501 const std::string variable,
507 int i, j, id, elmtid=0;
520 for (i = 0; i < bndCond.num_elements(); ++i)
522 if (bndCond[i]->GetBoundaryConditionType()
525 for (j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
528 ->GetExp(j)->GetBasis(0)->GetBasisKey();
530 ->GetExp(j)->GetBasis(1)->GetBasisKey();
531 exp2D = bndConstraint[i]->GetExp(j)
536 if((FaceQuadGeom = boost::dynamic_pointer_cast<
541 facesDone.insert(FaceQuadGeom->GetFid());
542 FaceQuadExp->SetElmtId(elmtid++);
543 (*m_exp).push_back(FaceQuadExp);
546 else if((FaceTriGeom = boost::dynamic_pointer_cast<
551 facesDone.insert(FaceTriGeom->GetFid());
552 FaceTriExp->SetElmtId(elmtid++);
553 (*m_exp).push_back(FaceTriExp);
557 ASSERTL0(
false,
"dynamic cast to a proper face geometry failed");
565 LibUtilities::BasisKey> > > faceOrders;
567 pair<LibUtilities::BasisKey,
570 for(i = 0; i < locexp.size(); ++i)
573 for (j = 0; j < exp3D->GetNfaces(); ++j)
575 FaceGeom = exp3D->
GetGeom3D()->GetFace(j);
576 id = FaceGeom->GetFid();
578 if(facesDone.count(
id) != 0)
582 it = faceOrders.find(
id);
584 if (it == faceOrders.end())
586 LibUtilities::BasisKey face_dir0
587 = locexp[i]->DetFaceBasisKey(j,0);
588 LibUtilities::BasisKey face_dir1
589 = locexp[i]->DetFaceBasisKey(j,1);
595 std::make_pair(face_dir0, face_dir1))));
599 LibUtilities::BasisKey face0 =
600 locexp[i]->DetFaceBasisKey(j,0);
601 LibUtilities::BasisKey face1 =
602 locexp[i]->DetFaceBasisKey(j,1);
603 LibUtilities::BasisKey existing0 =
604 it->second.second.first;
605 LibUtilities::BasisKey existing1 =
606 it->second.second.second;
617 if ((np22 >= np12 || np21 >= np11) &&
618 (nm22 >= nm12 || nm21 >= nm11))
622 else if((np22 < np12 || np21 < np11) &&
623 (nm22 < nm12 || nm21 < nm11))
625 it->second.second.first = face0;
626 it->second.second.second = face1;
631 "inappropriate number of points/modes (max "
632 "num of points is not set with max order)");
639 int nproc = vComm->GetSize();
640 int facepr = vComm->GetRank();
647 for(i = 0; i < locexp.size(); ++i)
649 fCnt += locexp[i]->GetNfaces();
655 faceCnt[facepr] = fCnt;
661 for (i = 1; i < nproc; ++i)
663 fTotOffsets[i] = fTotOffsets[i-1] + faceCnt[i-1];
674 int cntr = fTotOffsets[facepr];
676 for(i = 0; i < locexp.size(); ++i)
682 for(j = 0; j < nfaces; ++j, ++cntr)
684 LibUtilities::BasisKey face_dir0
685 = locexp[i]->DetFaceBasisKey(j,0);
686 LibUtilities::BasisKey face_dir1
687 = locexp[i]->DetFaceBasisKey(j,1);
689 FacesTotID[cntr] = exp3D->GetGeom3D()->GetFid(j);
703 for (i = 0; i < totFaceCnt; ++i)
705 it = faceOrders.find(FacesTotID[i]);
707 if (it == faceOrders.end())
712 LibUtilities::BasisKey existing0 =
713 it->second.second.first;
714 LibUtilities::BasisKey existing1 =
715 it->second.second.second;
716 LibUtilities::BasisKey face0(
720 LibUtilities::BasisKey face1(
734 if ((np22 >= np12 || np21 >= np11) &&
735 (nm22 >= nm12 || nm21 >= nm11))
739 else if((np22 < np12 || np21 < np11) &&
740 (nm22 < nm12 || nm21 < nm11))
742 it->second.second.first = face0;
743 it->second.second.second = face1;
748 "inappropriate number of points/modes (max "
749 "num of points is not set with max order)");
754 for (it = faceOrders.begin(); it != faceOrders.end(); ++it)
756 FaceGeom = it->second.first;
758 if ((FaceQuadGeom = boost::dynamic_pointer_cast<
763 it->second.second.second,
765 FaceQuadExp->SetElmtId(elmtid++);
766 (*m_exp).push_back(FaceQuadExp);
768 else if ((FaceTriGeom = boost::dynamic_pointer_cast<
773 it->second.second.second,
775 FaceTriExp->SetElmtId(elmtid++);
776 (*m_exp).push_back(FaceTriExp);
790 if(DeclareCoeffPhysArrays)
814 const std::string variable,
821 ASSERTL0(boost::dynamic_pointer_cast<
823 "Expected a MeshGraph3D object.");
837 SpatialDomains::CompositeMap::const_iterator compIt;
838 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
840 nel += (compIt->second)->size();
843 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
845 for (j = 0; j < compIt->second->size(); ++j)
847 if ((TriangleGeom = boost::dynamic_pointer_cast<
851 = boost::dynamic_pointer_cast<
853 GetFaceBasisKey(TriangleGeom, 0, variable);
855 = boost::dynamic_pointer_cast<
856 SpatialDomains::MeshGraph3D>(graph3D)->
857 GetFaceBasisKey(TriangleGeom,1,variable);
859 if (graph3D->GetExpansions().begin()->second->
860 m_basisKeyVector[0].GetBasisType() ==
863 ASSERTL0(
false,
"This method needs sorting");
869 Ntri->SetElmtId(elmtid++);
870 (*m_exp).push_back(Ntri);
877 tri->SetElmtId(elmtid++);
878 (*m_exp).push_back(tri);
887 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
891 = boost::dynamic_pointer_cast<
893 GetFaceBasisKey(QuadrilateralGeom, 0,
896 = boost::dynamic_pointer_cast<
897 SpatialDomains::MeshGraph3D>(graph3D)->
898 GetFaceBasisKey(QuadrilateralGeom, 1,
904 quad->SetElmtId(elmtid++);
905 (*m_exp).push_back(quad);
914 "dynamic cast to a proper Geometry2D failed");
947 int i,j,f_npoints,offset;
950 for(i = 0; i <
m_exp->size(); ++i)
953 f_npoints = (*m_exp)[i]->GetNumPoints(0)*
954 (*m_exp)[i]->GetNumPoints(1);
958 for(j = 0; j < f_npoints; ++j)
961 if(Vn[offset + j] > 0.0)
963 Upwind[offset + j] = Fwd[offset + j];
967 Upwind[offset + j] = Bwd[offset + j];
988 for (
int i = 0; i < nquad2; ++i)
990 for (
int j = 0; j < nquad1; ++j)
992 out[i*nquad1 + j] = in[j*nquad2 + i];
998 for (
int i = 0; i < nquad2; ++i)
1000 for (
int j = 0; j < nquad1; ++j)
1002 out[i*nquad1 + j] = in[i*nquad1 + j];
1013 for (
int i = 0; i < nquad2; ++i)
1015 for (
int j = 0; j < nquad1/2; ++j)
1017 swap(out[i*nquad1 + j],
1018 out[i*nquad1 + nquad1-j-1]);
1029 for (
int j = 0; j < nquad1; ++j)
1031 for (
int i = 0; i < nquad2/2; ++i)
1033 swap(out[i*nquad1 + j],
1034 out[(nquad2-i-1)*nquad1 + j]);
1055 ASSERTL1(normals.num_elements() >= coordim,
1056 "Output vector does not have sufficient dimensions to "
1060 for (i = 0; i <
m_exp->size(); ++i)
1068 int faceNum = traceExp->GetLeftAdjacentElementFace();
1072 = exp3D->GetFaceNormal(faceNum);
1079 int fromid0,fromid1;
1093 = exp3D->DetFaceBasisKey(faceNum, fromid0);
1095 = exp3D->DetFaceBasisKey(faceNum, fromid1);
1097 = traceExp->GetBasis(0)->GetBasisKey();
1099 = traceExp->GetBasis(1)->GetBasisKey();
1104 for (j = 0; j < coordim; ++j)
1108 locNormals[j], traceNormals);
1115 tmp = normals[j]+offset);
1126 for (i = 0; i <
m_exp->size(); ++i)
1128 for (j = 0; j < (*m_exp)[i]->GetNedges(); ++j)
1130 (*m_exp)[i]->ComputeEdgeNormal(j);
1157 std::ostream &outfile,
1162 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
1163 int nquad1 = (*m_exp)[expansion]->GetNumPoints(1);
1164 int ntot = nquad0*nquad1;
1165 int ntotminus = (nquad0-1)*(nquad1-1);
1171 (*m_exp)[expansion]->GetCoords(coords[0],coords[1],coords[2]);
1173 outfile <<
" <Piece NumberOfPoints=\""
1174 << ntot <<
"\" NumberOfCells=\""
1175 << ntotminus <<
"\">" << endl;
1176 outfile <<
" <Points>" << endl;
1177 outfile <<
" <DataArray type=\"Float64\" "
1178 <<
"NumberOfComponents=\"3\" format=\"ascii\">" << endl;
1180 for (i = 0; i < ntot; ++i)
1182 for (j = 0; j < 3; ++j)
1184 outfile << setprecision(8) << scientific
1185 << (float)coords[j][i] <<
" ";
1190 outfile <<
" </DataArray>" << endl;
1191 outfile <<
" </Points>" << endl;
1192 outfile <<
" <Cells>" << endl;
1193 outfile <<
" <DataArray type=\"Int32\" "
1194 <<
"Name=\"connectivity\" format=\"ascii\">" << endl;
1195 for (i = 0; i < nquad0-1; ++i)
1197 for (j = 0; j < nquad1-1; ++j)
1199 outfile << j*nquad0 + i <<
" "
1200 << j*nquad0 + i + 1 <<
" "
1201 << (j+1)*nquad0 + i + 1 <<
" "
1202 << (j+1)*nquad0 + i << endl;
1206 outfile <<
" </DataArray>" << endl;
1207 outfile <<
" <DataArray type=\"Int32\" "
1208 <<
"Name=\"offsets\" format=\"ascii\">" << endl;
1209 for (i = 0; i < ntotminus; ++i)
1211 outfile << i*4+4 <<
" ";
1214 outfile <<
" </DataArray>" << endl;
1215 outfile <<
" <DataArray type=\"UInt8\" "
1216 <<
"Name=\"types\" format=\"ascii\">" << endl;
1217 for (i = 0; i < ntotminus; ++i)
1222 outfile <<
" </DataArray>" << endl;
1223 outfile <<
" </Cells>" << endl;
1224 outfile <<
" <PointData>" << endl;
1239 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1240 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1241 int npt0 = (int) pt0*scale;
1242 int npt1 = (int) pt1*scale;
1245 (*
m_exp)[i]->GetPointsType(0));
1247 (*
m_exp)[i]->GetPointsType(1));
1251 (*
m_exp)[i]->GetBasis(1)->GetPointsKey(),
1252 &inarray[cnt],newPointsKey0,
1253 newPointsKey1,&outarray[cnt1]);
1271 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1272 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1273 int npt0 = (int) pt0*scale;
1274 int npt1 = (int) pt1*scale;
1277 (*
m_exp)[i]->GetPointsType(0));
1279 (*
m_exp)[i]->GetPointsType(1));
1286 (*
m_exp)[i]->GetBasis(0)->GetPointsKey(),
1287 (*
m_exp)[i]->GetBasis(1)->GetPointsKey(),
#define ASSERTL0(condition, msg)
std::map< int, ExpansionShPtr >::const_iterator ExpansionMapConstIter
int GetNfaces() const
This function returns the number of faces of the expansion domain.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
BasisType GetBasisType() const
Return type of expansion basis.
boost::shared_ptr< QuadGeom > QuadGeomSharedPtr
SpatialDomains::Geometry3DSharedPtr GetGeom3D() const
PointsType GetPointsType() const
Return type of quadrature.
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
int GetExpSize(void)
This function returns the number of elements in the expansion.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual void v_PhysInterp1DScaled(const NekDouble scale, const Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
virtual ~ExpList2D()
Destructor.
std::vector< ExpansionSharedPtr > ExpansionVector
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis...
virtual void v_SetUpPhysNormals()
Set up the normals on each expansion.
Base class for all multi-elemental spectral/hp expansions.
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
SpatialDomains::Geometry2DSharedPtr GetGeom2D() const
boost::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
boost::shared_ptr< Expansion3D > Expansion3DSharedPtr
bool m_physState
The state of the array m_phys.
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
int GetNumPoints() const
Return points order at which basis is defined.
void SetCoeffPhysOffsets()
Definition of the total number of degrees of freedom and quadrature points and offsets to access data...
Principle Orthogonal Functions .
LibUtilities::SessionReaderSharedPtr m_session
Session.
Defines a specification for a set of points.
boost::shared_ptr< QuadExp > QuadExpSharedPtr
Expansion3DSharedPtr GetLeftAdjacentElementExp() const
boost::shared_ptr< GeometryVector > Composite
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
std::map< int, Composite > CompositeMap
boost::shared_ptr< Geometry2D > Geometry2DSharedPtr
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
virtual void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip)
PointsKey GetPointsKey() const
Return distribution of points.
void v_GetNormals(Array< OneD, Array< OneD, NekDouble > > &normals)
For each local element, copy the normals stored in the element list into the array normals...
virtual void v_ReadGlobalOptimizationParameters()
ExpList2D()
Default constructor.
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
void ReadGlobalOptimizationParameters()
void v_Upwind(const Array< OneD, const NekDouble > &Vn, const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &Upwind)
Upwind the Fwd and Bwd states based on the one- dimensional normal velocity field given by Vn...
boost::shared_ptr< TriGeom > TriGeomSharedPtr
void CreateCollections(Collections::ImplementationType ImpType=Collections::eNoImpType)
Construct collections of elements containing a single element type and polynomial order from the list...
int GetCoordim(int eid)
This function returns the dimension of the coordinates of the element eid.
int GetNumModes() const
Returns the order of the basis.
void SetExpType(ExpansionType Type)
Returns the type of the expansion.
virtual void v_PhysGalerkinProjection1DScaled(const NekDouble scale, const Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Describes the specification for a Basis.
void PhysGalerkinProject2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
2D Nodal Electrostatic Points on a Triangle
std::map< int, ExpansionShPtr > ExpansionMap
boost::shared_ptr< Expansion2D > Expansion2DSharedPtr
boost::shared_ptr< TriExp > TriExpSharedPtr
void AlignFace(const StdRegions::Orientation orient, const int nquad1, const int nquad2, const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out)
Helper function to re-align face to a given orientation.
boost::shared_ptr< NodalTriExp > NodalTriExpSharedPtr