48 namespace MultiRegions
86 ExpList(In,DeclareCoeffPhysArrays)
119 = graph1D->GetExpansions();
123 SpatialDomains::ExpansionMap::const_iterator expIt;
124 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
126 if ((SegmentGeom = boost::dynamic_pointer_cast<
128 expIt->second->m_geomShPtr)))
132 seg->SetElmtId(
id++);
133 (*m_exp).push_back(seg);
137 ASSERTL0(
false,
"dynamic cast to a SegGeom failed");
178 const bool DeclareCoeffPhysArrays):
189 = graph1D->GetExpansions();
192 SpatialDomains::ExpansionMap::const_iterator expIt;
193 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
198 if ((SegmentGeom = boost::dynamic_pointer_cast<
200 expIt->second->m_geomShPtr)))
206 seg->SetElmtId(
id++);
209 (*m_exp).push_back(seg);
213 ASSERTL0(
false,
"dynamic cast to a SegGeom failed");
225 if(DeclareCoeffPhysArrays)
261 const bool DeclareCoeffPhysArrays,
262 const std::string var,
263 bool SetToOneSpaceDimension):
270 SpatialDomains::CompositeMap::const_iterator compIt;
274 = graph1D->GetExpansions(var);
277 for(compIt = domain.begin(); compIt != domain.end(); ++compIt)
279 comp = compIt->second;
282 for(j = 0; j < compIt->second->size(); ++j)
284 SpatialDomains::ExpansionMap::const_iterator expIt;
286 if((SegmentGeom = boost::dynamic_pointer_cast<
288 (*compIt->second)[j])))
291 if((expIt = expansions.find(SegmentGeom->GetGlobalID())) != expansions.end())
295 if(SetToOneSpaceDimension)
298 SegmentGeom->GenerateOneSpaceDimGeom();
311 ASSERTL0(
false,
"Failed to find basis key");
317 ASSERTL0(
false,
"Failed to dynamic cast geometry to SegGeom");
322 seg->SetElmtId(
id++);
325 (*m_exp).push_back(seg);
337 if(DeclareCoeffPhysArrays)
363 const bool DeclareCoeffPhysArrays,
364 const std::string variable):
371 SpatialDomains::CompositeMap::const_iterator compIt;
376 for(compIt = domain.begin(); compIt != domain.end(); ++compIt)
378 comp = compIt->second;
380 for(j = 0; j < compIt->second->size(); ++j)
382 if((SegmentGeom = boost::dynamic_pointer_cast<
384 (*compIt->second)[j])))
394 seg->SetElmtId(
id++);
395 (*m_exp).push_back(seg);
399 ASSERTL0(
false,
"dynamic cast to a SegGeom failed");
414 if(DeclareCoeffPhysArrays)
439 const Array<OneD,const ExpListSharedPtr> &bndConstraint,
440 const Array<OneD, const SpatialDomains::BoundaryConditionShPtr> &bndCond,
444 const bool DeclareCoeffPhysArrays,
445 const std::string variable):
448 int i, j, id, elmtid = 0;
460 map<int,int> EdgeDone;
461 map<int,int> NormalSet;
467 for(i = 0; i < bndCond.num_elements(); ++i)
469 if(bndCond[i]->GetBoundaryConditionType()
472 for(j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
475 ->GetExp(j)->GetBasis(0)->GetBasisKey();
476 exp1D = bndConstraint[i]->GetExp(j)->
477 as<LocalRegions::Expansion1D>();
478 segGeom = exp1D->GetGeom1D();
482 edgesDone.insert(segGeom->GetEid());
484 seg->SetElmtId(elmtid++);
485 (*m_exp).push_back(seg);
495 for(i = 0; i < locexp.size(); ++i)
499 for(j = 0; j < locexp[i]->GetNedges(); ++j)
501 segGeom = exp2D->
GetGeom2D()->GetEdge(j);
502 id = segGeom->GetEid();
504 if (edgesDone.count(
id) != 0)
509 it = edgeOrders.find(
id);
511 if (it == edgeOrders.end())
513 edgeOrders.insert(std::make_pair(
id, std::make_pair(
514 segGeom, locexp[i]->DetEdgeBasisKey(j))));
519 = locexp[i]->DetEdgeBasisKey(j);
528 if (np2 >= np1 && nm2 >= nm1)
532 else if (np2 < np1 && nm2 < nm1)
534 it->second.second = edge;
539 "inappropriate number of points/modes (max "
540 "num of points is not set with max order)");
547 pSession->GetComm()->GetRowComm();
548 int nproc = vComm->GetSize();
549 int edgepr = vComm->GetRank();
556 for(i = 0; i < locexp.size(); ++i)
558 eCnt += locexp[i]->GetNedges();
563 Array<OneD, int> edgesCnt(nproc, 0);
564 edgesCnt[edgepr] = eCnt;
569 Array<OneD, int> eTotOffsets(nproc,0);
570 for (i = 1; i < nproc; ++i)
572 eTotOffsets[i] = eTotOffsets[i-1] + edgesCnt[i-1];
576 Array<OneD, int> EdgesTotID(totEdgeCnt, 0);
577 Array<OneD, int> EdgesTotNm(totEdgeCnt, 0);
578 Array<OneD, int> EdgesTotPnts(totEdgeCnt, 0);
580 int cntr = eTotOffsets[edgepr];
582 for(i = 0; i < locexp.size(); ++i)
588 for(j = 0; j < nedges; ++j, ++cntr)
591 locexp[i]->DetEdgeBasisKey(j);
592 EdgesTotID [cntr] = exp2D->GetGeom2D()->GetEid(j);
602 for (i = 0; i < totEdgeCnt; ++i)
604 it = edgeOrders.find(EdgesTotID[i]);
606 if (it == edgeOrders.end())
624 if (np2 >= np1 && nm2 >= nm1)
628 else if (np2 < np1 && nm2 < nm1)
630 it->second.second = edge;
635 "inappropriate number of points/modes (max "
636 "num of points is not set with max order)");
641 for (it = edgeOrders.begin(); it != edgeOrders.end(); ++it)
645 seg->SetElmtId(elmtid++);
646 (*m_exp).push_back(seg);
658 if(DeclareCoeffPhysArrays)
686 for(i = 0; i <
m_exp->size(); ++i)
690 m_offset_elmt_id[i] = i;
691 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
692 m_npoints += (*m_exp)[i]->GetTotPoints();
714 Array<OneD,NekDouble> &inarray,
715 Array<OneD,NekDouble> &outarray,
726 int quad_npoints = elmExp->GetTotPoints();
728 elmExp->GetPointsType(0));
729 Array<OneD,NekDouble> quad_points
731 Array<OneD,NekDouble> quad_weights
735 int kernel_width = kernel->GetKernelWidth();
736 Array<OneD,NekDouble> local_kernel_breaks(kernel_width+1);
739 Array<OneD,NekDouble> mapped_quad_points(quad_npoints);
742 for(i = 0; i < inarray.num_elements(); i++)
745 kernel->MoveKernelCenter(inarray[i],local_kernel_breaks);
748 Array<OneD,NekDouble> mesh_breaks;
749 kernel->FindMeshUnderKernel(local_kernel_breaks,h,mesh_breaks);
752 int total_nbreaks = local_kernel_breaks.num_elements() +
753 mesh_breaks.num_elements();
755 Array<OneD,NekDouble> total_breaks(total_nbreaks);
756 kernel->Sort(local_kernel_breaks,mesh_breaks,total_breaks);
761 for(j = 0; j < total_breaks.num_elements()-1; j++)
767 for(r = 0; r < quad_points.num_elements(); r++)
769 mapped_quad_points[r]
770 = (quad_points[r] + 1.0) * 0.5 * (b - a) + a;
775 Array<OneD,NekDouble> u_value(quad_npoints);
776 Array<OneD,NekDouble> coeffs =
GetCoeffs();
779 elmExp->GetBasisNumModes(0),u_value);
782 Array<OneD,NekDouble> k_value(quad_npoints);
783 kernel->EvaluateKernel(mapped_quad_points,h,k_value);
786 for(r = 0; r < quad_npoints; r++)
788 integral_value += (b - a) * 0.5 * k_value[r]
789 * u_value[r] * quad_weights[r];
792 outarray[i] = integral_value/h;
813 Array<OneD,NekDouble> &inarray2,
815 Array<OneD,NekDouble> &outarray)
823 for(i = 0; i < outarray.num_elements(); i++)
829 int x_size = inarray2.num_elements();
830 Array<OneD,NekDouble> x_values_cp(x_size);
833 Array<OneD,int> x_elm(x_size);
834 for(i = 0; i < x_size; i++ )
836 x_elm[i] = (int)floor(inarray2[i]/h);
840 for(i = 0; i < x_size; i++)
846 while(x_elm[i] >= num_elm)
848 x_elm[i] -= num_elm ;
853 for(i = 0; i < x_size; i++)
855 x_values_cp[i] = (inarray2[i]/h - floor(inarray2[i]/h))*2 - 1.0;
861 Array<TwoD,NekDouble> jacobi_poly(nmodes,x_size);
862 for(i = 0; i < nmodes; i++)
865 jacobi_poly.get()+i*x_size,NULL,i,0.0,0.0);
869 for(r = 0; r < nmodes; r++)
871 for(j = 0; j < x_size; j++)
873 int index = ((x_elm[j])*nmodes)+r;
874 outarray[j] += inarray1[index]*jacobi_poly[r][j];
918 for (i = 0; i <
m_exp->size(); ++i)
920 for (j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
922 (*m_exp)[i]->ComputeVertexNormal(j);
938 const Array<
OneD,
const Array<OneD, NekDouble> > &Vec,
939 const Array<OneD, const NekDouble> &Fwd,
940 const Array<OneD, const NekDouble> &Bwd,
941 Array<OneD, NekDouble> &Upwind)
943 int i,j,k,e_npoints,offset;
944 Array<OneD,NekDouble> normals;
950 ASSERTL1(Vec.num_elements() >= coordim,
951 "Input vector does not have sufficient dimensions to "
955 for(i = 0; i <
m_exp->size(); ++i)
958 e_npoints = (*m_exp)[i]->GetNumPoints(0);
959 normals = (*m_exp)[i]->GetPhysNormals();
965 for(j = 0; j < e_npoints; ++j)
969 for(k = 0; k < coordim; ++k)
971 Vn += Vec[k][offset+j]*normals[k*e_npoints + j];
977 Upwind[offset + j] = Fwd[offset + j];
981 Upwind[offset + j] = Bwd[offset + j];
1001 const Array<OneD, const NekDouble> &Vn,
1002 const Array<OneD, const NekDouble> &Fwd,
1003 const Array<OneD, const NekDouble> &Bwd,
1004 Array<OneD, NekDouble> &Upwind)
1006 int i,j,e_npoints,offset;
1007 Array<OneD,NekDouble> normals;
1010 for(i = 0; i <
m_exp->size(); ++i)
1013 e_npoints = (*m_exp)[i]->GetNumPoints(0);
1017 for(j = 0; j < e_npoints; ++j)
1020 if(Vn[offset + j] > 0.0)
1022 Upwind[offset + j] = Fwd[offset + j];
1026 Upwind[offset + j] = Bwd[offset + j];
1041 Array<
OneD, Array<OneD, NekDouble> > &normals)
1043 int i,j,k,e_npoints,offset;
1045 Array<OneD,Array<OneD,NekDouble> > locnormals;
1046 Array<OneD,Array<OneD,NekDouble> > locnormals2;
1047 Array<OneD,Array<OneD,NekDouble> > Norms;
1051 ASSERTL1(normals.num_elements() >= coordim,
1052 "Output vector does not have sufficient dimensions to "
1055 for (i = 0; i <
m_exp->size(); ++i)
1062 int edgeNumber = loc_exp->GetLeftAdjacentElementEdge();
1065 e_npoints = (*m_exp)[i]->GetNumPoints(0);
1067 locnormals = loc_elmt->GetEdgeNormal(edgeNumber);
1068 int e_nmodes = loc_exp->GetBasis(0)->GetNumModes();
1069 int loc_nmodes = loc_elmt->GetBasis(0)->GetNumModes();
1071 if (e_nmodes != loc_nmodes)
1073 if (loc_exp->GetRightAdjacentElementEdge() >= 0)
1076 loc_exp->GetRightAdjacentElementExp();
1078 int EdgeNumber = loc_exp->GetRightAdjacentElementEdge();
1081 locnormals = loc_elmt->GetEdgeNormal(EdgeNumber);
1086 for (j = 0; j < e_npoints; ++j)
1090 for (k = 0; k < coordim; ++k)
1092 normals[k][offset + j] = -locnormals[k][j];
1099 Array<OneD, Array<OneD, NekDouble> > normal(coordim);
1101 for (
int p = 0; p < coordim; ++p)
1103 normal[p] = Array<OneD, NekDouble>(e_npoints,0.0);
1105 loc_exp->GetBasis(0)->GetPointsKey();
1107 loc_elmt->GetBasis(0)->GetPointsKey();
1117 for (j = 0; j < e_npoints; ++j)
1121 for (k = 0; k < coordim; ++k)
1123 normals[k][offset + j] = normal[k][j];
1134 for (j = 0; j < e_npoints; ++j)
1138 for (k = 0; k < coordim; ++k)
1140 normals[k][offset + j] = locnormals[k][j];
1172 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
1174 int ntotminus = (nquad0-1);
1176 Array<OneD,NekDouble> coords[3];
1177 coords[0] = Array<OneD,NekDouble>(ntot);
1178 coords[1] = Array<OneD,NekDouble>(ntot);
1179 coords[2] = Array<OneD,NekDouble>(ntot);
1180 (*m_exp)[expansion]->GetCoords(coords[0],coords[1],coords[2]);
1182 outfile <<
" <Piece NumberOfPoints=\""
1183 << ntot <<
"\" NumberOfCells=\""
1184 << ntotminus <<
"\">" << endl;
1185 outfile <<
" <Points>" << endl;
1186 outfile <<
" <DataArray type=\"Float32\" "
1187 <<
"NumberOfComponents=\"3\" format=\"ascii\">" << endl;
1189 for (i = 0; i < ntot; ++i)
1191 for (j = 0; j < 3; ++j)
1193 outfile << setprecision(8) << scientific
1194 << (float)coords[j][i] <<
" ";
1199 outfile <<
" </DataArray>" << endl;
1200 outfile <<
" </Points>" << endl;
1201 outfile <<
" <Cells>" << endl;
1202 outfile <<
" <DataArray type=\"Int32\" "
1203 <<
"Name=\"connectivity\" format=\"ascii\">" << endl;
1204 for (i = 0; i < nquad0-1; ++i)
1206 outfile << i <<
" " << i+1 << endl;
1209 outfile <<
" </DataArray>" << endl;
1210 outfile <<
" <DataArray type=\"Int32\" "
1211 <<
"Name=\"offsets\" format=\"ascii\">" << endl;
1212 for (i = 0; i < ntotminus; ++i)
1214 outfile << i*2+2 <<
" ";
1217 outfile <<
" </DataArray>" << endl;
1218 outfile <<
" <DataArray type=\"UInt8\" "
1219 <<
"Name=\"types\" format=\"ascii\">" << endl;
1220 for (i = 0; i < ntotminus; ++i)
1225 outfile <<
" </DataArray>" << endl;
1226 outfile <<
" </Cells>" << endl;
1227 outfile <<
" <PointData>" << endl;