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):
103 ExpList(In,eIDs,DeclareCoeffPhysArrays)
135 const bool DeclareCoeffPhysArrays,
136 const std::string &var):
149 = graph2D->GetExpansions(var);
151 SpatialDomains::ExpansionMap::const_iterator expIt;
152 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
157 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
158 ::TriGeom>(expIt->second->m_geomShPtr)))
161 = expIt->second->m_basisKeyVector[0];
163 = expIt->second->m_basisKeyVector[1];
176 Ntri->SetElmtId(elmtid++);
177 (*m_exp).push_back(Ntri);
184 tri->SetElmtId(elmtid++);
185 (*m_exp).push_back(tri);
192 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
196 = expIt->second->m_basisKeyVector[0];
198 = expIt->second->m_basisKeyVector[1];
203 quad->SetElmtId(elmtid++);
204 (*m_exp).push_back(quad);
211 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
218 for(
int i = 0; i < (*m_exp).size(); ++i)
220 (*m_exp)[i]->SetElmtId(i);
232 if (DeclareCoeffPhysArrays)
261 const bool DeclareCoeffPhysArrays):
ExpList(pSession)
273 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
278 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
279 ::TriGeom>(expIt->second->m_geomShPtr)))
282 = expIt->second->m_basisKeyVector[0];
284 = expIt->second->m_basisKeyVector[1];
297 Ntri->SetElmtId(elmtid++);
298 (*m_exp).push_back(Ntri);
305 tri->SetElmtId(elmtid++);
306 (*m_exp).push_back(tri);
313 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
317 = expIt->second->m_basisKeyVector[0];
319 = expIt->second->m_basisKeyVector[1];
324 quad->SetElmtId(elmtid++);
325 (*m_exp).push_back(quad);
332 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
347 if (DeclareCoeffPhysArrays)
402 graph2D->GetExpansions();
408 SpatialDomains::ExpansionMap::const_iterator expIt;
409 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
414 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains::
415 TriGeom>(expIt->second->m_geomShPtr)))
422 Ntri->SetElmtId(elmtid++);
423 (*m_exp).push_back(Ntri);
429 tri->SetElmtId(elmtid++);
430 (*m_exp).push_back(tri);
438 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
443 quad->SetElmtId(elmtid++);
444 (*m_exp).push_back(quad);
452 "dynamic cast to a proper Geometry2D failed");
494 const bool DeclareCoeffPhysArrays,
495 const std::string variable):
500 int i, j, id, elmtid=0;
513 for (i = 0; i < bndCond.num_elements(); ++i)
515 if (bndCond[i]->GetBoundaryConditionType()
518 for (j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
521 ->GetExp(j)->GetBasis(0)->GetBasisKey();
523 ->GetExp(j)->GetBasis(1)->GetBasisKey();
524 exp2D = bndConstraint[i]->GetExp(j)
529 if((FaceQuadGeom = boost::dynamic_pointer_cast<
534 facesDone.insert(FaceQuadGeom->GetFid());
535 FaceQuadExp->SetElmtId(elmtid++);
536 (*m_exp).push_back(FaceQuadExp);
539 else if((FaceTriGeom = boost::dynamic_pointer_cast<
544 facesDone.insert(FaceTriGeom->GetFid());
545 FaceTriExp->SetElmtId(elmtid++);
546 (*m_exp).push_back(FaceTriExp);
550 ASSERTL0(
false,
"dynamic cast to a proper face geometry failed");
558 LibUtilities::BasisKey> > > faceOrders;
560 pair<LibUtilities::BasisKey,
563 for(i = 0; i < locexp.size(); ++i)
566 for (j = 0; j < exp3D->GetNfaces(); ++j)
568 FaceGeom = exp3D->
GetGeom3D()->GetFace(j);
569 id = FaceGeom->GetFid();
571 if(facesDone.count(
id) != 0)
575 it = faceOrders.find(
id);
577 if (it == faceOrders.end())
579 LibUtilities::BasisKey face_dir0
580 = locexp[i]->DetFaceBasisKey(j,0);
581 LibUtilities::BasisKey face_dir1
582 = locexp[i]->DetFaceBasisKey(j,1);
588 std::make_pair(face_dir0, face_dir1))));
592 LibUtilities::BasisKey face0 =
593 locexp[i]->DetFaceBasisKey(j,0);
594 LibUtilities::BasisKey face1 =
595 locexp[i]->DetFaceBasisKey(j,1);
596 LibUtilities::BasisKey existing0 =
597 it->second.second.first;
598 LibUtilities::BasisKey existing1 =
599 it->second.second.second;
610 if ((np22 >= np12 || np21 >= np11) &&
611 (nm22 >= nm12 || nm21 >= nm11))
615 else if((np22 < np12 || np21 < np11) &&
616 (nm22 < nm12 || nm21 < nm11))
618 it->second.second.first = face0;
619 it->second.second.second = face1;
624 "inappropriate number of points/modes (max "
625 "num of points is not set with max order)");
632 int nproc = vComm->GetSize();
633 int facepr = vComm->GetRank();
640 for(i = 0; i < locexp.size(); ++i)
642 fCnt += locexp[i]->GetNfaces();
648 faceCnt[facepr] = fCnt;
654 for (i = 1; i < nproc; ++i)
656 fTotOffsets[i] = fTotOffsets[i-1] + faceCnt[i-1];
667 int cntr = fTotOffsets[facepr];
669 for(i = 0; i < locexp.size(); ++i)
675 for(j = 0; j < nfaces; ++j, ++cntr)
677 LibUtilities::BasisKey face_dir0
678 = locexp[i]->DetFaceBasisKey(j,0);
679 LibUtilities::BasisKey face_dir1
680 = locexp[i]->DetFaceBasisKey(j,1);
682 FacesTotID[cntr] = exp3D->GetGeom3D()->GetFid(j);
696 for (i = 0; i < totFaceCnt; ++i)
698 it = faceOrders.find(FacesTotID[i]);
700 if (it == faceOrders.end())
705 LibUtilities::BasisKey existing0 =
706 it->second.second.first;
707 LibUtilities::BasisKey existing1 =
708 it->second.second.second;
709 LibUtilities::BasisKey face0(
713 LibUtilities::BasisKey face1(
727 if ((np22 >= np12 || np21 >= np11) &&
728 (nm22 >= nm12 || nm21 >= nm11))
732 else if((np22 < np12 || np21 < np11) &&
733 (nm22 < nm12 || nm21 < nm11))
735 it->second.second.first = face0;
736 it->second.second.second = face1;
741 "inappropriate number of points/modes (max "
742 "num of points is not set with max order)");
747 for (it = faceOrders.begin(); it != faceOrders.end(); ++it)
749 FaceGeom = it->second.first;
751 if ((FaceQuadGeom = boost::dynamic_pointer_cast<
756 it->second.second.second,
758 FaceQuadExp->SetElmtId(elmtid++);
759 (*m_exp).push_back(FaceQuadExp);
761 else if ((FaceTriGeom = boost::dynamic_pointer_cast<
766 it->second.second.second,
768 FaceTriExp->SetElmtId(elmtid++);
769 (*m_exp).push_back(FaceTriExp);
783 if(DeclareCoeffPhysArrays)
807 const std::string variable):
ExpList(pSession, graph3D)
812 ASSERTL0(boost::dynamic_pointer_cast<
814 "Expected a MeshGraph3D object.");
828 SpatialDomains::CompositeMap::const_iterator compIt;
829 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
831 nel += (compIt->second)->size();
834 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
836 for (j = 0; j < compIt->second->size(); ++j)
838 if ((TriangleGeom = boost::dynamic_pointer_cast<
842 = boost::dynamic_pointer_cast<
844 GetFaceBasisKey(TriangleGeom, 0, variable);
846 = boost::dynamic_pointer_cast<
847 SpatialDomains::MeshGraph3D>(graph3D)->
848 GetFaceBasisKey(TriangleGeom,1,variable);
850 if (graph3D->GetExpansions().begin()->second->
851 m_basisKeyVector[0].GetBasisType() ==
854 ASSERTL0(
false,
"This method needs sorting");
860 Ntri->SetElmtId(elmtid++);
861 (*m_exp).push_back(Ntri);
868 tri->SetElmtId(elmtid++);
869 (*m_exp).push_back(tri);
878 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
882 = boost::dynamic_pointer_cast<
884 GetFaceBasisKey(QuadrilateralGeom, 0,
887 = boost::dynamic_pointer_cast<
888 SpatialDomains::MeshGraph3D>(graph3D)->
889 GetFaceBasisKey(QuadrilateralGeom, 1,
895 quad->SetElmtId(elmtid++);
896 (*m_exp).push_back(quad);
905 "dynamic cast to a proper Geometry2D failed");
938 int i,j,f_npoints,offset;
941 for(i = 0; i <
m_exp->size(); ++i)
944 f_npoints = (*m_exp)[i]->GetNumPoints(0)*
945 (*m_exp)[i]->GetNumPoints(1);
949 for(j = 0; j < f_npoints; ++j)
952 if(Vn[offset + j] > 0.0)
954 Upwind[offset + j] = Fwd[offset + j];
958 Upwind[offset + j] = Bwd[offset + j];
979 for (
int i = 0; i < nquad2; ++i)
981 for (
int j = 0; j < nquad1; ++j)
983 out[i*nquad1 + j] = in[j*nquad2 + i];
989 for (
int i = 0; i < nquad2; ++i)
991 for (
int j = 0; j < nquad1; ++j)
993 out[i*nquad1 + j] = in[i*nquad1 + j];
1004 for (
int i = 0; i < nquad2; ++i)
1006 for (
int j = 0; j < nquad1/2; ++j)
1008 swap(out[i*nquad1 + j],
1009 out[i*nquad1 + nquad1-j-1]);
1020 for (
int j = 0; j < nquad1; ++j)
1022 for (
int i = 0; i < nquad2/2; ++i)
1024 swap(out[i*nquad1 + j],
1025 out[(nquad2-i-1)*nquad1 + j]);
1046 ASSERTL1(normals.num_elements() >= coordim,
1047 "Output vector does not have sufficient dimensions to "
1051 for (i = 0; i <
m_exp->size(); ++i)
1059 int faceNum = traceExp->GetLeftAdjacentElementFace();
1063 = exp3D->GetFaceNormal(faceNum);
1070 int fromid0,fromid1;
1084 = exp3D->DetFaceBasisKey(faceNum, fromid0);
1086 = exp3D->DetFaceBasisKey(faceNum, fromid1);
1088 = traceExp->GetBasis(0)->GetBasisKey();
1090 = traceExp->GetBasis(1)->GetBasisKey();
1095 for (j = 0; j < coordim; ++j)
1099 locNormals[j], traceNormals);
1106 tmp = normals[j]+offset);
1133 for(i = 0; i <
m_exp->size(); ++i)
1139 m_offset_elmt_id[cnt++] = i;
1140 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
1141 m_npoints += (*m_exp)[i]->GetTotPoints();
1145 for(i = 0; i <
m_exp->size(); ++i)
1151 m_offset_elmt_id[cnt++] = i;
1152 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
1153 m_npoints += (*m_exp)[i]->GetTotPoints();
1165 for (i = 0; i <
m_exp->size(); ++i)
1167 for (j = 0; j < (*m_exp)[i]->GetNedges(); ++j)
1169 (*m_exp)[i]->ComputeEdgeNormal(j);
1196 std::ostream &outfile,
1201 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
1202 int nquad1 = (*m_exp)[expansion]->GetNumPoints(1);
1203 int ntot = nquad0*nquad1;
1204 int ntotminus = (nquad0-1)*(nquad1-1);
1210 (*m_exp)[expansion]->GetCoords(coords[0],coords[1],coords[2]);
1212 outfile <<
" <Piece NumberOfPoints=\""
1213 << ntot <<
"\" NumberOfCells=\""
1214 << ntotminus <<
"\">" << endl;
1215 outfile <<
" <Points>" << endl;
1216 outfile <<
" <DataArray type=\"Float64\" "
1217 <<
"NumberOfComponents=\"3\" format=\"ascii\">" << endl;
1219 for (i = 0; i < ntot; ++i)
1221 for (j = 0; j < 3; ++j)
1223 outfile << setprecision(8) << scientific
1224 << (float)coords[j][i] <<
" ";
1229 outfile <<
" </DataArray>" << endl;
1230 outfile <<
" </Points>" << endl;
1231 outfile <<
" <Cells>" << endl;
1232 outfile <<
" <DataArray type=\"Int32\" "
1233 <<
"Name=\"connectivity\" format=\"ascii\">" << endl;
1234 for (i = 0; i < nquad0-1; ++i)
1236 for (j = 0; j < nquad1-1; ++j)
1238 outfile << j*nquad0 + i <<
" "
1239 << j*nquad0 + i + 1 <<
" "
1240 << (j+1)*nquad0 + i + 1 <<
" "
1241 << (j+1)*nquad0 + i << endl;
1245 outfile <<
" </DataArray>" << endl;
1246 outfile <<
" <DataArray type=\"Int32\" "
1247 <<
"Name=\"offsets\" format=\"ascii\">" << endl;
1248 for (i = 0; i < ntotminus; ++i)
1250 outfile << i*4+4 <<
" ";
1253 outfile <<
" </DataArray>" << endl;
1254 outfile <<
" <DataArray type=\"UInt8\" "
1255 <<
"Name=\"types\" format=\"ascii\">" << endl;
1256 for (i = 0; i < ntotminus; ++i)
1261 outfile <<
" </DataArray>" << endl;
1262 outfile <<
" </Cells>" << endl;
1263 outfile <<
" <PointData>" << endl;
1278 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1279 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1280 int npt0 = (int) pt0*scale;
1281 int npt1 = (int) pt1*scale;
1284 (*
m_exp)[i]->GetPointsType(0));
1286 (*
m_exp)[i]->GetPointsType(1));
1290 (*
m_exp)[i]->GetBasis(1)->GetPointsKey(),
1291 &inarray[cnt],newPointsKey0,
1292 newPointsKey1,&outarray[cnt1]);
1310 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1311 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1312 int npt0 = (int) pt0*scale;
1313 int npt1 = (int) pt1*scale;
1316 (*
m_exp)[i]->GetPointsType(0));
1318 (*
m_exp)[i]->GetPointsType(1));
1325 (*
m_exp)[i]->GetBasis(0)->GetPointsKey(),
1326 (*
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.
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, 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