49 namespace MultiRegions
88 const bool DeclareCoeffPhysArrays):
89 ExpList(In,DeclareCoeffPhysArrays)
110 const bool DeclareCoeffPhysArrays,
111 const std::string &var):
124 = graph2D->GetExpansions(var);
126 SpatialDomains::ExpansionMap::const_iterator expIt;
127 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
132 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
133 ::TriGeom>(expIt->second->m_geomShPtr)))
136 = expIt->second->m_basisKeyVector[0];
138 = expIt->second->m_basisKeyVector[1];
151 Ntri->SetElmtId(elmtid++);
152 (*m_exp).push_back(Ntri);
159 tri->SetElmtId(elmtid++);
160 (*m_exp).push_back(tri);
167 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
171 = expIt->second->m_basisKeyVector[0];
173 = expIt->second->m_basisKeyVector[1];
178 quad->SetElmtId(elmtid++);
179 (*m_exp).push_back(quad);
186 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
193 for(
int i = 0; i < (*m_exp).size(); ++i)
195 (*m_exp)[i]->SetElmtId(i);
207 if (DeclareCoeffPhysArrays)
236 const bool DeclareCoeffPhysArrays):
ExpList(pSession)
248 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
253 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
254 ::TriGeom>(expIt->second->m_geomShPtr)))
257 = expIt->second->m_basisKeyVector[0];
259 = expIt->second->m_basisKeyVector[1];
272 Ntri->SetElmtId(elmtid++);
273 (*m_exp).push_back(Ntri);
280 tri->SetElmtId(elmtid++);
281 (*m_exp).push_back(tri);
288 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
292 = expIt->second->m_basisKeyVector[0];
294 = expIt->second->m_basisKeyVector[1];
299 quad->SetElmtId(elmtid++);
300 (*m_exp).push_back(quad);
307 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
322 if (DeclareCoeffPhysArrays)
377 graph2D->GetExpansions();
383 SpatialDomains::ExpansionMap::const_iterator expIt;
384 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
389 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains::
390 TriGeom>(expIt->second->m_geomShPtr)))
397 Ntri->SetElmtId(elmtid++);
398 (*m_exp).push_back(Ntri);
404 tri->SetElmtId(elmtid++);
405 (*m_exp).push_back(tri);
413 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
418 quad->SetElmtId(elmtid++);
419 (*m_exp).push_back(quad);
427 "dynamic cast to a proper Geometry2D failed");
469 const bool DeclareCoeffPhysArrays,
470 const std::string variable):
475 int i, j, id, elmtid=0;
488 for (i = 0; i < bndCond.num_elements(); ++i)
490 if (bndCond[i]->GetBoundaryConditionType()
493 for (j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
496 ->GetExp(j)->GetBasis(0)->GetBasisKey();
498 ->GetExp(j)->GetBasis(1)->GetBasisKey();
499 exp2D = bndConstraint[i]->GetExp(j)
504 if((FaceQuadGeom = boost::dynamic_pointer_cast<
509 facesDone.insert(FaceQuadGeom->GetFid());
510 FaceQuadExp->SetElmtId(elmtid++);
511 (*m_exp).push_back(FaceQuadExp);
514 else if((FaceTriGeom = boost::dynamic_pointer_cast<
519 facesDone.insert(FaceTriGeom->GetFid());
520 FaceTriExp->SetElmtId(elmtid++);
521 (*m_exp).push_back(FaceTriExp);
525 ASSERTL0(
false,
"dynamic cast to a proper face geometry failed");
533 LibUtilities::BasisKey> > > faceOrders;
535 pair<LibUtilities::BasisKey,
538 for(i = 0; i < locexp.size(); ++i)
541 for (j = 0; j < exp3D->GetNfaces(); ++j)
543 FaceGeom = exp3D->
GetGeom3D()->GetFace(j);
544 id = FaceGeom->GetFid();
546 if(facesDone.count(
id) != 0)
550 it = faceOrders.find(
id);
552 if (it == faceOrders.end())
554 LibUtilities::BasisKey face_dir0
555 = locexp[i]->DetFaceBasisKey(j,0);
556 LibUtilities::BasisKey face_dir1
557 = locexp[i]->DetFaceBasisKey(j,1);
563 std::make_pair(face_dir0, face_dir1))));
567 LibUtilities::BasisKey face0 =
568 locexp[i]->DetFaceBasisKey(j,0);
569 LibUtilities::BasisKey face1 =
570 locexp[i]->DetFaceBasisKey(j,1);
571 LibUtilities::BasisKey existing0 =
572 it->second.second.first;
573 LibUtilities::BasisKey existing1 =
574 it->second.second.second;
585 if ((np22 >= np12 || np21 >= np11) &&
586 (nm22 >= nm12 || nm21 >= nm11))
590 else if((np22 < np12 || np21 < np11) &&
591 (nm22 < nm12 || nm21 < nm11))
593 it->second.second.first = face0;
594 it->second.second.second = face1;
599 "inappropriate number of points/modes (max "
600 "num of points is not set with max order)");
607 int nproc = vComm->GetSize();
608 int facepr = vComm->GetRank();
615 for(i = 0; i < locexp.size(); ++i)
617 fCnt += locexp[i]->GetNfaces();
623 faceCnt[facepr] = fCnt;
629 for (i = 1; i < nproc; ++i)
631 fTotOffsets[i] = fTotOffsets[i-1] + faceCnt[i-1];
642 int cntr = fTotOffsets[facepr];
644 for(i = 0; i < locexp.size(); ++i)
650 for(j = 0; j < nfaces; ++j, ++cntr)
652 LibUtilities::BasisKey face_dir0
653 = locexp[i]->DetFaceBasisKey(j,0);
654 LibUtilities::BasisKey face_dir1
655 = locexp[i]->DetFaceBasisKey(j,1);
657 FacesTotID[cntr] = exp3D->GetGeom3D()->GetFid(j);
671 for (i = 0; i < totFaceCnt; ++i)
673 it = faceOrders.find(FacesTotID[i]);
675 if (it == faceOrders.end())
680 LibUtilities::BasisKey existing0 =
681 it->second.second.first;
682 LibUtilities::BasisKey existing1 =
683 it->second.second.second;
684 LibUtilities::BasisKey face0(
688 LibUtilities::BasisKey face1(
702 if ((np22 >= np12 || np21 >= np11) &&
703 (nm22 >= nm12 || nm21 >= nm11))
707 else if((np22 < np12 || np21 < np11) &&
708 (nm22 < nm12 || nm21 < nm11))
710 it->second.second.first = face0;
711 it->second.second.second = face1;
716 "inappropriate number of points/modes (max "
717 "num of points is not set with max order)");
722 for (it = faceOrders.begin(); it != faceOrders.end(); ++it)
724 FaceGeom = it->second.first;
726 if ((FaceQuadGeom = boost::dynamic_pointer_cast<
731 it->second.second.second,
733 FaceQuadExp->SetElmtId(elmtid++);
734 (*m_exp).push_back(FaceQuadExp);
736 else if ((FaceTriGeom = boost::dynamic_pointer_cast<
741 it->second.second.second,
743 FaceTriExp->SetElmtId(elmtid++);
744 (*m_exp).push_back(FaceTriExp);
758 if(DeclareCoeffPhysArrays)
782 const std::string variable):
ExpList(pSession, graph3D)
787 ASSERTL0(boost::dynamic_pointer_cast<
789 "Expected a MeshGraph3D object.");
803 SpatialDomains::CompositeMap::const_iterator compIt;
804 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
806 nel += (compIt->second)->size();
809 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
811 for (j = 0; j < compIt->second->size(); ++j)
813 if ((TriangleGeom = boost::dynamic_pointer_cast<
817 = boost::dynamic_pointer_cast<
819 GetFaceBasisKey(TriangleGeom, 0, variable);
821 = boost::dynamic_pointer_cast<
822 SpatialDomains::MeshGraph3D>(graph3D)->
823 GetFaceBasisKey(TriangleGeom,1,variable);
825 if (graph3D->GetExpansions().begin()->second->
826 m_basisKeyVector[0].GetBasisType() ==
829 ASSERTL0(
false,
"This method needs sorting");
835 Ntri->SetElmtId(elmtid++);
836 (*m_exp).push_back(Ntri);
843 tri->SetElmtId(elmtid++);
844 (*m_exp).push_back(tri);
853 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
857 = boost::dynamic_pointer_cast<
859 GetFaceBasisKey(QuadrilateralGeom, 0,
862 = boost::dynamic_pointer_cast<
863 SpatialDomains::MeshGraph3D>(graph3D)->
864 GetFaceBasisKey(QuadrilateralGeom, 1,
870 quad->SetElmtId(elmtid++);
871 (*m_exp).push_back(quad);
880 "dynamic cast to a proper Geometry2D failed");
913 int i,j,f_npoints,offset;
916 for(i = 0; i <
m_exp->size(); ++i)
919 f_npoints = (*m_exp)[i]->GetNumPoints(0)*
920 (*m_exp)[i]->GetNumPoints(1);
924 for(j = 0; j < f_npoints; ++j)
927 if(Vn[offset + j] > 0.0)
929 Upwind[offset + j] = Fwd[offset + j];
933 Upwind[offset + j] = Bwd[offset + j];
954 for (
int i = 0; i < nquad2; ++i)
956 for (
int j = 0; j < nquad1; ++j)
958 out[i*nquad1 + j] = in[j*nquad2 + i];
964 for (
int i = 0; i < nquad2; ++i)
966 for (
int j = 0; j < nquad1; ++j)
968 out[i*nquad1 + j] = in[i*nquad1 + j];
979 for (
int i = 0; i < nquad2; ++i)
981 for (
int j = 0; j < nquad1/2; ++j)
983 swap(out[i*nquad1 + j],
984 out[i*nquad1 + nquad1-j-1]);
995 for (
int j = 0; j < nquad1; ++j)
997 for (
int i = 0; i < nquad2/2; ++i)
999 swap(out[i*nquad1 + j],
1000 out[(nquad2-i-1)*nquad1 + j]);
1021 ASSERTL1(normals.num_elements() >= coordim,
1022 "Output vector does not have sufficient dimensions to "
1026 for (i = 0; i <
m_exp->size(); ++i)
1034 int faceNum = traceExp->GetLeftAdjacentElementFace();
1038 = exp3D->GetFaceNormal(faceNum);
1045 int fromid0,fromid1;
1059 = exp3D->DetFaceBasisKey(faceNum, fromid0);
1061 = exp3D->DetFaceBasisKey(faceNum, fromid1);
1063 = traceExp->GetBasis(0)->GetBasisKey();
1065 = traceExp->GetBasis(1)->GetBasisKey();
1070 for (j = 0; j < coordim; ++j)
1074 locNormals[j], traceNormals);
1081 tmp = normals[j]+offset);
1108 for(i = 0; i <
m_exp->size(); ++i)
1114 m_offset_elmt_id[cnt++] = i;
1115 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
1116 m_npoints += (*m_exp)[i]->GetTotPoints();
1120 for(i = 0; i <
m_exp->size(); ++i)
1126 m_offset_elmt_id[cnt++] = i;
1127 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
1128 m_npoints += (*m_exp)[i]->GetTotPoints();
1140 for (i = 0; i <
m_exp->size(); ++i)
1142 for (j = 0; j < (*m_exp)[i]->GetNedges(); ++j)
1144 (*m_exp)[i]->ComputeEdgeNormal(j);
1171 std::ostream &outfile,
1176 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
1177 int nquad1 = (*m_exp)[expansion]->GetNumPoints(1);
1178 int ntot = nquad0*nquad1;
1179 int ntotminus = (nquad0-1)*(nquad1-1);
1185 (*m_exp)[expansion]->GetCoords(coords[0],coords[1],coords[2]);
1187 outfile <<
" <Piece NumberOfPoints=\""
1188 << ntot <<
"\" NumberOfCells=\""
1189 << ntotminus <<
"\">" << endl;
1190 outfile <<
" <Points>" << endl;
1191 outfile <<
" <DataArray type=\"Float64\" "
1192 <<
"NumberOfComponents=\"3\" format=\"ascii\">" << endl;
1194 for (i = 0; i < ntot; ++i)
1196 for (j = 0; j < 3; ++j)
1198 outfile << setprecision(8) << scientific
1199 << (float)coords[j][i] <<
" ";
1204 outfile <<
" </DataArray>" << endl;
1205 outfile <<
" </Points>" << endl;
1206 outfile <<
" <Cells>" << endl;
1207 outfile <<
" <DataArray type=\"Int32\" "
1208 <<
"Name=\"connectivity\" format=\"ascii\">" << endl;
1209 for (i = 0; i < nquad0-1; ++i)
1211 for (j = 0; j < nquad1-1; ++j)
1213 outfile << j*nquad0 + i <<
" "
1214 << j*nquad0 + i + 1 <<
" "
1215 << (j+1)*nquad0 + i + 1 <<
" "
1216 << (j+1)*nquad0 + i << endl;
1220 outfile <<
" </DataArray>" << endl;
1221 outfile <<
" <DataArray type=\"Int32\" "
1222 <<
"Name=\"offsets\" format=\"ascii\">" << endl;
1223 for (i = 0; i < ntotminus; ++i)
1225 outfile << i*4+4 <<
" ";
1228 outfile <<
" </DataArray>" << endl;
1229 outfile <<
" <DataArray type=\"UInt8\" "
1230 <<
"Name=\"types\" format=\"ascii\">" << endl;
1231 for (i = 0; i < ntotminus; ++i)
1236 outfile <<
" </DataArray>" << endl;
1237 outfile <<
" </Cells>" << endl;
1238 outfile <<
" <PointData>" << endl;
1253 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1254 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1255 int npt0 = (int) pt0*scale;
1256 int npt1 = (int) pt1*scale;
1259 (*
m_exp)[i]->GetPointsType(0));
1261 (*
m_exp)[i]->GetPointsType(1));
1265 (*
m_exp)[i]->GetBasis(1)->GetPointsKey(),
1266 &inarray[cnt],newPointsKey0,
1267 newPointsKey1,&outarray[cnt1]);
1285 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1286 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1287 int npt0 = (int) pt0*scale;
1288 int npt1 = (int) pt1*scale;
1291 (*
m_exp)[i]->GetPointsType(0));
1293 (*
m_exp)[i]->GetPointsType(1));
1300 (*
m_exp)[i]->GetBasis(0)->GetPointsKey(),
1301 (*
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.
std::map< int, vector< PeriodicEntity > > PeriodicMap
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.
Array< OneD, int > m_coeff_offset
Offset of elemental data into the array m_coeffs.
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 .
Array< OneD, int > m_offset_elmt_id
Array containing the element id m_offset_elmt_id[n] that the n^th consecutive block of data in m_coef...
int GetNumPoints() const
Return points order at which basis is defined.
Principle Orthogonal Functions .
LibUtilities::SessionReaderSharedPtr m_session
Session.
Defines a specification for a set of points.
boost::shared_ptr< QuadExp > QuadExpSharedPtr
void SetCoeffPhysOffsets(void)
Definition of the total number of degrees of freedom and quadrature points and offsets to access data...
Expansion3DSharedPtr GetLeftAdjacentElementExp() const
boost::shared_ptr< GeometryVector > Composite
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