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 "
201 if (DeclareCoeffPhysArrays)
229 const bool DeclareCoeffPhysArrays):
ExpList(pSession)
241 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
246 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains
247 ::TriGeom>(expIt->second->m_geomShPtr)))
250 = expIt->second->m_basisKeyVector[0];
252 = expIt->second->m_basisKeyVector[1];
265 Ntri->SetElmtId(elmtid++);
266 (*m_exp).push_back(Ntri);
273 tri->SetElmtId(elmtid++);
274 (*m_exp).push_back(tri);
281 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
285 = expIt->second->m_basisKeyVector[0];
287 = expIt->second->m_basisKeyVector[1];
292 quad->SetElmtId(elmtid++);
293 (*m_exp).push_back(quad);
300 ASSERTL0(
false,
"dynamic cast to a proper Geometry2D "
315 if (DeclareCoeffPhysArrays)
369 graph2D->GetExpansions();
375 SpatialDomains::ExpansionMap::const_iterator expIt;
376 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
381 if ((TriangleGeom = boost::dynamic_pointer_cast<SpatialDomains::
382 TriGeom>(expIt->second->m_geomShPtr)))
389 Ntri->SetElmtId(elmtid++);
390 (*m_exp).push_back(Ntri);
396 tri->SetElmtId(elmtid++);
397 (*m_exp).push_back(tri);
405 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
410 quad->SetElmtId(elmtid++);
411 (*m_exp).push_back(quad);
419 "dynamic cast to a proper Geometry2D failed");
455 const Array<OneD,const ExpListSharedPtr> &bndConstraint,
456 const Array<OneD,const SpatialDomains::BoundaryConditionShPtr> &bndCond,
460 const bool DeclareCoeffPhysArrays,
461 const std::string variable):
466 int i, j, id, elmtid=0;
479 for (i = 0; i < bndCond.num_elements(); ++i)
481 if (bndCond[i]->GetBoundaryConditionType()
484 for (j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
487 ->GetExp(j)->GetBasis(0)->GetBasisKey();
489 ->GetExp(j)->GetBasis(1)->GetBasisKey();
490 exp2D = bndConstraint[i]->GetExp(j)
495 if((FaceQuadGeom = boost::dynamic_pointer_cast<
500 facesDone.insert(FaceQuadGeom->GetFid());
501 FaceQuadExp->SetElmtId(elmtid++);
502 (*m_exp).push_back(FaceQuadExp);
505 else if((FaceTriGeom = boost::dynamic_pointer_cast<
510 facesDone.insert(FaceTriGeom->GetFid());
511 FaceTriExp->SetElmtId(elmtid++);
512 (*m_exp).push_back(FaceTriExp);
516 ASSERTL0(
false,
"dynamic cast to a proper face geometry failed");
524 LibUtilities::BasisKey> > > faceOrders;
526 pair<LibUtilities::BasisKey,
529 for(i = 0; i < locexp.size(); ++i)
532 for (j = 0; j < exp3D->GetNfaces(); ++j)
534 FaceGeom = exp3D->
GetGeom3D()->GetFace(j);
535 id = FaceGeom->GetFid();
537 if(facesDone.count(
id) != 0)
541 it = faceOrders.find(
id);
543 if (it == faceOrders.end())
545 LibUtilities::BasisKey face_dir0
546 = locexp[i]->DetFaceBasisKey(j,0);
547 LibUtilities::BasisKey face_dir1
548 = locexp[i]->DetFaceBasisKey(j,1);
554 std::make_pair(face_dir0, face_dir1))));
558 LibUtilities::BasisKey face0 =
559 locexp[i]->DetFaceBasisKey(j,0);
560 LibUtilities::BasisKey face1 =
561 locexp[i]->DetFaceBasisKey(j,1);
562 LibUtilities::BasisKey existing0 =
563 it->second.second.first;
564 LibUtilities::BasisKey existing1 =
565 it->second.second.second;
576 if ((np22 >= np12 || np21 >= np11) &&
577 (nm22 >= nm12 || nm21 >= nm11))
581 else if((np22 < np12 || np21 < np11) &&
582 (nm22 < nm12 || nm21 < nm11))
584 it->second.second.first = face0;
585 it->second.second.second = face1;
590 "inappropriate number of points/modes (max "
591 "num of points is not set with max order)");
598 int nproc = vComm->GetSize();
599 int facepr = vComm->GetRank();
606 for(i = 0; i < locexp.size(); ++i)
608 fCnt += locexp[i]->GetNfaces();
613 Array<OneD, int> faceCnt(nproc,0);
614 faceCnt[facepr] = fCnt;
618 Array<OneD, int> fTotOffsets(nproc,0);
620 for (i = 1; i < nproc; ++i)
622 fTotOffsets[i] = fTotOffsets[i-1] + faceCnt[i-1];
627 Array<OneD, int> FacesTotID (totFaceCnt, 0);
628 Array<OneD, int> FacesTotNm0 (totFaceCnt, 0);
629 Array<OneD, int> FacesTotNm1 (totFaceCnt, 0);
630 Array<OneD, int> FacesTotPnts0(totFaceCnt, 0);
631 Array<OneD, int> FacesTotPnts1(totFaceCnt, 0);
633 int cntr = fTotOffsets[facepr];
635 for(i = 0; i < locexp.size(); ++i)
641 for(j = 0; j < nfaces; ++j, ++cntr)
643 LibUtilities::BasisKey face_dir0
644 = locexp[i]->DetFaceBasisKey(j,0);
645 LibUtilities::BasisKey face_dir1
646 = locexp[i]->DetFaceBasisKey(j,1);
648 FacesTotID[cntr] = exp3D->GetGeom3D()->GetFid(j);
662 for (i = 0; i < totFaceCnt; ++i)
664 it = faceOrders.find(FacesTotID[i]);
666 if (it == faceOrders.end())
671 LibUtilities::BasisKey existing0 =
672 it->second.second.first;
673 LibUtilities::BasisKey existing1 =
674 it->second.second.second;
675 LibUtilities::BasisKey face0(
679 LibUtilities::BasisKey face1(
693 if ((np22 >= np12 || np21 >= np11) &&
694 (nm22 >= nm12 || nm21 >= nm11))
698 else if((np22 < np12 || np21 < np11) &&
699 (nm22 < nm12 || nm21 < nm11))
701 it->second.second.first = face0;
702 it->second.second.second = face1;
707 "inappropriate number of points/modes (max "
708 "num of points is not set with max order)");
713 for (it = faceOrders.begin(); it != faceOrders.end(); ++it)
715 FaceGeom = it->second.first;
717 if ((FaceQuadGeom = boost::dynamic_pointer_cast<
722 it->second.second.second,
724 FaceQuadExp->SetElmtId(elmtid++);
725 (*m_exp).push_back(FaceQuadExp);
727 else if ((FaceTriGeom = boost::dynamic_pointer_cast<
732 it->second.second.second,
734 FaceTriExp->SetElmtId(elmtid++);
735 (*m_exp).push_back(FaceTriExp);
749 if(DeclareCoeffPhysArrays)
771 const std::string variable):
ExpList(pSession, graph3D)
776 ASSERTL0(boost::dynamic_pointer_cast<
778 "Expected a MeshGraph3D object.");
792 SpatialDomains::CompositeMap::const_iterator compIt;
793 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
795 nel += (compIt->second)->size();
798 for (compIt = domain.begin(); compIt != domain.end(); ++compIt)
800 for (j = 0; j < compIt->second->size(); ++j)
802 if ((TriangleGeom = boost::dynamic_pointer_cast<
806 = boost::dynamic_pointer_cast<
808 GetFaceBasisKey(TriangleGeom, 0, variable);
810 = boost::dynamic_pointer_cast<
811 SpatialDomains::MeshGraph3D>(graph3D)->
812 GetFaceBasisKey(TriangleGeom,1,variable);
814 if (graph3D->GetExpansions().begin()->second->
815 m_basisKeyVector[0].GetBasisType() ==
818 ASSERTL0(
false,
"This method needs sorting");
824 Ntri->SetElmtId(elmtid++);
825 (*m_exp).push_back(Ntri);
832 tri->SetElmtId(elmtid++);
833 (*m_exp).push_back(tri);
842 else if ((QuadrilateralGeom = boost::dynamic_pointer_cast<
846 = boost::dynamic_pointer_cast<
848 GetFaceBasisKey(QuadrilateralGeom, 0,
851 = boost::dynamic_pointer_cast<
852 SpatialDomains::MeshGraph3D>(graph3D)->
853 GetFaceBasisKey(QuadrilateralGeom, 1,
859 quad->SetElmtId(elmtid++);
860 (*m_exp).push_back(quad);
869 "dynamic cast to a proper Geometry2D failed");
896 const Array<OneD, const NekDouble> &Vn,
897 const Array<OneD, const NekDouble> &Fwd,
898 const Array<OneD, const NekDouble> &Bwd,
899 Array<OneD, NekDouble> &Upwind)
901 int i,j,f_npoints,offset;
904 for(i = 0; i <
m_exp->size(); ++i)
907 f_npoints = (*m_exp)[i]->GetNumPoints(0)*
908 (*m_exp)[i]->GetNumPoints(1);
912 for(j = 0; j < f_npoints; ++j)
915 if(Vn[offset + j] > 0.0)
917 Upwind[offset + j] = Fwd[offset + j];
921 Upwind[offset + j] = Bwd[offset + j];
935 Array<
OneD, Array<OneD, NekDouble> > &normals)
938 Array<OneD,Array<OneD,NekDouble> > locnormals;
939 Array<OneD, NekDouble> tmp;
943 ASSERTL1(normals.num_elements() >= coordim,
944 "Output vector does not have sufficient dimensions to "
948 for(i = 0; i <
m_exp->size(); ++i)
950 int e_npoints = (*m_exp)[i]->GetTotPoints();
955 int faceNumber = loc_exp->GetLeftAdjacentElementFace();
958 locnormals = loc_elmt->GetFaceNormal(faceNumber);
959 int e_nmodes = loc_exp->GetBasis(0)->GetNumModes();
960 int loc_nmodes = loc_elmt->GetBasis(0)->GetNumModes();
962 if (e_nmodes != loc_nmodes)
964 if (loc_exp->GetRightAdjacentElementFace() >= 0)
967 loc_exp->GetRightAdjacentElementExp();
969 int faceNumber = loc_exp->GetRightAdjacentElementFace();
972 locnormals = loc_elmt->GetFaceNormal(faceNumber);
976 for(
int j = 0; j < e_npoints; ++j)
978 for(k = 0; k < coordim; ++k)
980 normals[k][offset+j] = -locnormals[k][j];
986 Array<OneD, Array<OneD, NekDouble> > normal(coordim);
988 for (
int p = 0; p < coordim; ++p)
990 normal[p] = Array<OneD, NekDouble>(e_npoints,0.0);
993 loc_exp->GetBasis(0)->GetPointsKey();
995 loc_exp->GetBasis(1)->GetPointsKey();
997 loc_elmt->GetBasis(0)->GetPointsKey();
999 loc_elmt->GetBasis(1)->GetPointsKey();
1012 for (j = 0; j < e_npoints; ++j)
1016 for (k = 0; k < coordim; ++k)
1018 normals[k][offset + j] = normal[k][j];
1028 for (k = 0; k < coordim; ++k)
1031 loc_elmt->GetFacePointsKey(faceNumber, 0),
1032 loc_elmt->GetFacePointsKey(faceNumber, 1),
1034 (*m_exp)[i]->GetBasis(0)->GetPointsKey(),
1035 (*m_exp)[i]->GetBasis(1)->GetPointsKey(),
1036 tmp = normals[k]+offset);
1064 for(i = 0; i <
m_exp->size(); ++i)
1070 m_offset_elmt_id[cnt++] = i;
1071 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
1072 m_npoints += (*m_exp)[i]->GetTotPoints();
1076 for(i = 0; i <
m_exp->size(); ++i)
1082 m_offset_elmt_id[cnt++] = i;
1083 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
1084 m_npoints += (*m_exp)[i]->GetTotPoints();
1096 for (i = 0; i <
m_exp->size(); ++i)
1098 for (j = 0; j < (*m_exp)[i]->GetNedges(); ++j)
1100 (*m_exp)[i]->ComputeEdgeNormal(j);
1108 Array<OneD, int> NumShape(2,0);
1127 std::ofstream &outfile,
1131 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
1132 int nquad1 = (*m_exp)[expansion]->GetNumPoints(1);
1133 int ntot = nquad0*nquad1;
1134 int ntotminus = (nquad0-1)*(nquad1-1);
1136 Array<OneD,NekDouble> coords[3];
1137 coords[0] = Array<OneD,NekDouble>(ntot,0.0);
1138 coords[1] = Array<OneD,NekDouble>(ntot,0.0);
1139 coords[2] = Array<OneD,NekDouble>(ntot,0.0);
1140 (*m_exp)[expansion]->GetCoords(coords[0],coords[1],coords[2]);
1142 outfile <<
" <Piece NumberOfPoints=\""
1143 << ntot <<
"\" NumberOfCells=\""
1144 << ntotminus <<
"\">" << endl;
1145 outfile <<
" <Points>" << endl;
1146 outfile <<
" <DataArray type=\"Float64\" "
1147 <<
"NumberOfComponents=\"3\" format=\"ascii\">" << endl;
1149 for (i = 0; i < ntot; ++i)
1151 for (j = 0; j < 3; ++j)
1153 outfile << setprecision(8) << scientific
1154 << (float)coords[j][i] <<
" ";
1159 outfile <<
" </DataArray>" << endl;
1160 outfile <<
" </Points>" << endl;
1161 outfile <<
" <Cells>" << endl;
1162 outfile <<
" <DataArray type=\"Int32\" "
1163 <<
"Name=\"connectivity\" format=\"ascii\">" << endl;
1164 for (i = 0; i < nquad0-1; ++i)
1166 for (j = 0; j < nquad1-1; ++j)
1168 outfile << j*nquad0 + i <<
" "
1169 << j*nquad0 + i + 1 <<
" "
1170 << (j+1)*nquad0 + i + 1 <<
" "
1171 << (j+1)*nquad0 + i << endl;
1175 outfile <<
" </DataArray>" << endl;
1176 outfile <<
" <DataArray type=\"Int32\" "
1177 <<
"Name=\"offsets\" format=\"ascii\">" << endl;
1178 for (i = 0; i < ntotminus; ++i)
1180 outfile << i*4+4 <<
" ";
1183 outfile <<
" </DataArray>" << endl;
1184 outfile <<
" <DataArray type=\"UInt8\" "
1185 <<
"Name=\"types\" format=\"ascii\">" << endl;
1186 for (i = 0; i < ntotminus; ++i)
1191 outfile <<
" </DataArray>" << endl;
1192 outfile <<
" </Cells>" << endl;
1193 outfile <<
" <PointData>" << endl;
1199 const Array<OneD, NekDouble> &inarray,
1200 Array<OneD, NekDouble> &outarray)
1208 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1209 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1210 int npt0 = (int) pt0*scale;
1211 int npt1 = (int) pt1*scale;
1214 (*
m_exp)[i]->GetPointsType(0));
1216 (*
m_exp)[i]->GetPointsType(1));
1220 (*
m_exp)[i]->GetBasis(1)->GetPointsKey(),
1221 &inarray[cnt],newPointsKey0,
1222 newPointsKey1,&outarray[cnt1]);
1231 const Array<OneD, NekDouble> &inarray,
1232 Array<OneD, NekDouble> &outarray)
1240 int pt0 = (*m_exp)[i]->GetNumPoints(0);
1241 int pt1 = (*m_exp)[i]->GetNumPoints(1);
1242 int npt0 = (int) pt0*scale;
1243 int npt1 = (int) pt1*scale;
1246 (*
m_exp)[i]->GetPointsType(0));
1248 (*
m_exp)[i]->GetPointsType(1));
1255 (*
m_exp)[i]->GetBasis(0)->GetPointsKey(),
1256 (*
m_exp)[i]->GetBasis(1)->GetPointsKey(),