49 namespace MultiRegions
88 const bool DeclareCoeffPhysArrays):
89 ExpList(In,DeclareCoeffPhysArrays)
100 const std::vector<unsigned int> &eIDs,
101 const bool DeclareCoeffPhysArrays):
102 ExpList(In,eIDs,DeclareCoeffPhysArrays)
134 const bool DeclareCoeffPhysArrays,
135 const std::string &var):
148 = graph2D->GetExpansions(var);
150 SpatialDomains::ExpansionMap::const_iterator expIt;
151 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
156 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
157 ::TriGeom>(expIt->second->m_geomShPtr)))
160 = expIt->second->m_basisKeyVector[0];
162 = expIt->second->m_basisKeyVector[1];
175 Ntri->SetElmtId(elmtid++);
176 (*m_exp).push_back(Ntri);
183 tri->SetElmtId(elmtid++);
184 (*m_exp).push_back(tri);
191 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
195 = expIt->second->m_basisKeyVector[0];
197 = expIt->second->m_basisKeyVector[1];
202 quad->SetElmtId(elmtid++);
203 (*m_exp).push_back(quad);
210 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
217 for(
int i = 0; i < (*m_exp).size(); ++i)
219 (*m_exp)[i]->SetElmtId(i);
231 if (DeclareCoeffPhysArrays)
260 const bool DeclareCoeffPhysArrays):
ExpList(pSession)
272 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
277 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
278 ::TriGeom>(expIt->second->m_geomShPtr)))
281 = expIt->second->m_basisKeyVector[0];
283 = expIt->second->m_basisKeyVector[1];
296 Ntri->SetElmtId(elmtid++);
297 (*m_exp).push_back(Ntri);
304 tri->SetElmtId(elmtid++);
305 (*m_exp).push_back(tri);
312 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
316 = expIt->second->m_basisKeyVector[0];
318 = expIt->second->m_basisKeyVector[1];
323 quad->SetElmtId(elmtid++);
324 (*m_exp).push_back(quad);
331 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
346 if (DeclareCoeffPhysArrays)
401 graph2D->GetExpansions();
407 SpatialDomains::ExpansionMap::const_iterator expIt;
408 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
413 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains::
414 TriGeom>(expIt->second->m_geomShPtr)))
421 Ntri->SetElmtId(elmtid++);
422 (*m_exp).push_back(Ntri);
428 tri->SetElmtId(elmtid++);
429 (*m_exp).push_back(tri);
437 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
442 quad->SetElmtId(elmtid++);
443 (*m_exp).push_back(quad);
451 "dynamic cast to a proper Geometry2D failed");
493 const bool DeclareCoeffPhysArrays,
494 const std::string variable):
499 int i, j, id, elmtid=0;
512 for (i = 0; i < bndCond.num_elements(); ++i)
514 if (bndCond[i]->GetBoundaryConditionType()
517 for (j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
520 ->GetExp(j)->GetBasis(0)->GetBasisKey();
522 ->GetExp(j)->GetBasis(1)->GetBasisKey();
523 exp2D = bndConstraint[i]->GetExp(j)
528 if((FaceQuadGeom = boost::dynamic_pointer_cast<
533 facesDone.insert(FaceQuadGeom->GetFid());
534 FaceQuadExp->SetElmtId(elmtid++);
535 (*m_exp).push_back(FaceQuadExp);
538 else if((FaceTriGeom = boost::dynamic_pointer_cast<
543 facesDone.insert(FaceTriGeom->GetFid());
544 FaceTriExp->SetElmtId(elmtid++);
545 (*m_exp).push_back(FaceTriExp);
549 ASSERTL0(
false,
"dynamic cast to a proper face geometry failed");
557 LibUtilities::BasisKey> > > faceOrders;
559 pair<LibUtilities::BasisKey,
562 for(i = 0; i < locexp.size(); ++i)
565 for (j = 0; j < exp3D->GetNfaces(); ++j)
567 FaceGeom = exp3D->
GetGeom3D()->GetFace(j);
568 id = FaceGeom->GetFid();
570 if(facesDone.count(
id) != 0)
574 it = faceOrders.find(
id);
576 if (it == faceOrders.end())
578 LibUtilities::BasisKey face_dir0
579 = locexp[i]->DetFaceBasisKey(j,0);
580 LibUtilities::BasisKey face_dir1
581 = locexp[i]->DetFaceBasisKey(j,1);
587 std::make_pair(face_dir0, face_dir1))));
591 LibUtilities::BasisKey face0 =
592 locexp[i]->DetFaceBasisKey(j,0);
593 LibUtilities::BasisKey face1 =
594 locexp[i]->DetFaceBasisKey(j,1);
595 LibUtilities::BasisKey existing0 =
596 it->second.second.first;
597 LibUtilities::BasisKey existing1 =
598 it->second.second.second;
609 if ((np22 >= np12 || np21 >= np11) &&
610 (nm22 >= nm12 || nm21 >= nm11))
614 else if((np22 < np12 || np21 < np11) &&
615 (nm22 < nm12 || nm21 < nm11))
617 it->second.second.first = face0;
618 it->second.second.second = face1;
623 "inappropriate number of points/modes (max "
624 "num of points is not set with max order)");
631 int nproc = vComm->GetSize();
632 int facepr = vComm->GetRank();
639 for(i = 0; i < locexp.size(); ++i)
641 fCnt += locexp[i]->GetNfaces();
647 faceCnt[facepr] = fCnt;
653 for (i = 1; i < nproc; ++i)
655 fTotOffsets[i] = fTotOffsets[i-1] + faceCnt[i-1];
666 int cntr = fTotOffsets[facepr];
668 for(i = 0; i < locexp.size(); ++i)
674 for(j = 0; j < nfaces; ++j, ++cntr)
676 LibUtilities::BasisKey face_dir0
677 = locexp[i]->DetFaceBasisKey(j,0);
678 LibUtilities::BasisKey face_dir1
679 = locexp[i]->DetFaceBasisKey(j,1);
681 FacesTotID[cntr] = exp3D->GetGeom3D()->GetFid(j);
695 for (i = 0; i < totFaceCnt; ++i)
697 it = faceOrders.find(FacesTotID[i]);
699 if (it == faceOrders.end())
704 LibUtilities::BasisKey existing0 =
705 it->second.second.first;
706 LibUtilities::BasisKey existing1 =
707 it->second.second.second;
708 LibUtilities::BasisKey face0(
712 LibUtilities::BasisKey face1(
726 if ((np22 >= np12 || np21 >= np11) &&
727 (nm22 >= nm12 || nm21 >= nm11))
731 else if((np22 < np12 || np21 < np11) &&
732 (nm22 < nm12 || nm21 < nm11))
734 it->second.second.first = face0;
735 it->second.second.second = face1;
740 "inappropriate number of points/modes (max "
741 "num of points is not set with max order)");
746 for (it = faceOrders.begin(); it != faceOrders.end(); ++it)
748 FaceGeom = it->second.first;
750 if ((FaceQuadGeom = boost::dynamic_pointer_cast<
755 it->second.second.second,
757 FaceQuadExp->SetElmtId(elmtid++);
758 (*m_exp).push_back(FaceQuadExp);
760 else if ((FaceTriGeom = boost::dynamic_pointer_cast<
765 it->second.second.second,
767 FaceTriExp->SetElmtId(elmtid++);
768 (*m_exp).push_back(FaceTriExp);
782 if(DeclareCoeffPhysArrays)
806 const std::string variable):
ExpList(pSession, graph3D)
811 ASSERTL0(boost::dynamic_pointer_cast<
813 "Expected a MeshGraph3D object.");
827 SpatialDomains::CompositeMap::const_iterator compIt;
828 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
830 nel += (compIt->second)->size();
833 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
835 for (j = 0; j < compIt->second->size(); ++j)
837 if ((TriangleGeom = boost::dynamic_pointer_cast<
841 = boost::dynamic_pointer_cast<
843 GetFaceBasisKey(TriangleGeom, 0, variable);
845 = boost::dynamic_pointer_cast<
846 SpatialDomains::MeshGraph3D>(graph3D)->
847 GetFaceBasisKey(TriangleGeom,1,variable);
849 if (graph3D->GetExpansions().begin()->second->
850 m_basisKeyVector[0].GetBasisType() ==
853 ASSERTL0(
false,
"This method needs sorting");
859 Ntri->SetElmtId(elmtid++);
860 (*m_exp).push_back(Ntri);
867 tri->SetElmtId(elmtid++);
868 (*m_exp).push_back(tri);
877 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
881 = boost::dynamic_pointer_cast<
883 GetFaceBasisKey(QuadrilateralGeom, 0,
886 = boost::dynamic_pointer_cast<
887 SpatialDomains::MeshGraph3D>(graph3D)->
888 GetFaceBasisKey(QuadrilateralGeom, 1,
894 quad->SetElmtId(elmtid++);
895 (*m_exp).push_back(quad);
904 "dynamic cast to a proper Geometry2D failed");
937 int i,j,f_npoints,offset;
940 for(i = 0; i <
m_exp->size(); ++i)
943 f_npoints = (*m_exp)[i]->GetNumPoints(0)*
944 (*m_exp)[i]->GetNumPoints(1);
948 for(j = 0; j < f_npoints; ++j)
951 if(Vn[offset + j] > 0.0)
953 Upwind[offset + j] = Fwd[offset + j];
957 Upwind[offset + j] = Bwd[offset + j];
978 for (
int i = 0; i < nquad2; ++i)
980 for (
int j = 0; j < nquad1; ++j)
982 out[i*nquad1 + j] = in[j*nquad2 + i];
988 for (
int i = 0; i < nquad2; ++i)
990 for (
int j = 0; j < nquad1; ++j)
992 out[i*nquad1 + j] = in[i*nquad1 + j];
1003 for (
int i = 0; i < nquad2; ++i)
1005 for (
int j = 0; j < nquad1/2; ++j)
1007 swap(out[i*nquad1 + j],
1008 out[i*nquad1 + nquad1-j-1]);
1019 for (
int j = 0; j < nquad1; ++j)
1021 for (
int i = 0; i < nquad2/2; ++i)
1023 swap(out[i*nquad1 + j],
1024 out[(nquad2-i-1)*nquad1 + j]);
1045 ASSERTL1(normals.num_elements() >= coordim,
1046 "Output vector does not have sufficient dimensions to "
1050 for (i = 0; i <
m_exp->size(); ++i)
1058 int faceNum = traceExp->GetLeftAdjacentElementFace();
1062 = exp3D->GetFaceNormal(faceNum);
1069 int fromid0,fromid1;
1083 = exp3D->DetFaceBasisKey(faceNum, fromid0);
1085 = exp3D->DetFaceBasisKey(faceNum, fromid1);
1087 = traceExp->GetBasis(0)->GetBasisKey();
1089 = traceExp->GetBasis(1)->GetBasisKey();
1094 for (j = 0; j < coordim; ++j)
1098 locNormals[j], traceNormals);
1105 tmp = normals[j]+offset);
1132 for(i = 0; i <
m_exp->size(); ++i)
1138 m_offset_elmt_id[cnt++] = i;
1139 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
1140 m_npoints += (*m_exp)[i]->GetTotPoints();
1144 for(i = 0; i <
m_exp->size(); ++i)
1150 m_offset_elmt_id[cnt++] = i;
1151 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
1152 m_npoints += (*m_exp)[i]->GetTotPoints();
1164 for (i = 0; i <
m_exp->size(); ++i)
1166 for (j = 0; j < (*m_exp)[i]->GetNedges(); ++j)
1168 (*m_exp)[i]->ComputeEdgeNormal(j);
1195 std::ostream &outfile,
1200 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
1201 int nquad1 = (*m_exp)[expansion]->GetNumPoints(1);
1202 int ntot = nquad0*nquad1;
1203 int ntotminus = (nquad0-1)*(nquad1-1);
1209 (*m_exp)[expansion]->GetCoords(coords[0],coords[1],coords[2]);
1211 outfile <<
" <Piece NumberOfPoints=\""
1212 << ntot <<
"\" NumberOfCells=\""
1213 << ntotminus <<
"\">" << endl;
1214 outfile <<
" <Points>" << endl;
1215 outfile <<
" <DataArray type=\"Float64\" "
1216 <<
"NumberOfComponents=\"3\" format=\"ascii\">" << endl;
1218 for (i = 0; i < ntot; ++i)
1220 for (j = 0; j < 3; ++j)
1222 outfile << setprecision(8) << scientific
1223 << (float)coords[j][i] <<
" ";
1228 outfile <<
" </DataArray>" << endl;
1229 outfile <<
" </Points>" << endl;
1230 outfile <<
" <Cells>" << endl;
1231 outfile <<
" <DataArray type=\"Int32\" "
1232 <<
"Name=\"connectivity\" format=\"ascii\">" << endl;
1233 for (i = 0; i < nquad0-1; ++i)
1235 for (j = 0; j < nquad1-1; ++j)
1237 outfile << j*nquad0 + i <<
" "
1238 << j*nquad0 + i + 1 <<
" "
1239 << (j+1)*nquad0 + i + 1 <<
" "
1240 << (j+1)*nquad0 + i << endl;
1244 outfile <<
" </DataArray>" << endl;
1245 outfile <<
" <DataArray type=\"Int32\" "
1246 <<
"Name=\"offsets\" format=\"ascii\">" << endl;
1247 for (i = 0; i < ntotminus; ++i)
1249 outfile << i*4+4 <<
" ";
1252 outfile <<
" </DataArray>" << endl;
1253 outfile <<
" <DataArray type=\"UInt8\" "
1254 <<
"Name=\"types\" format=\"ascii\">" << endl;
1255 for (i = 0; i < ntotminus; ++i)
1260 outfile <<
" </DataArray>" << endl;
1261 outfile <<
" </Cells>" << endl;
1262 outfile <<
" <PointData>" << endl;
1277 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1278 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1279 int npt0 = (int) pt0*scale;
1280 int npt1 = (int) pt1*scale;
1283 (*
m_exp)[i]->GetPointsType(0));
1285 (*
m_exp)[i]->GetPointsType(1));
1289 (*
m_exp)[i]->GetBasis(1)->GetPointsKey(),
1290 &inarray[cnt],newPointsKey0,
1291 newPointsKey1,&outarray[cnt1]);
1309 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1310 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1311 int npt0 = (int) pt0*scale;
1312 int npt1 = (int) pt1*scale;
1315 (*
m_exp)[i]->GetPointsType(0));
1317 (*
m_exp)[i]->GetPointsType(1));
1324 (*
m_exp)[i]->GetBasis(0)->GetPointsKey(),
1325 (*
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