37 #include <boost/core/ignore_unused.hpp>
51 namespace MultiRegions
78 ExpList1D::ExpList1D():
89 ExpList(In,DeclareCoeffPhysArrays)
98 const std::vector<unsigned int> &eIDs,
99 const bool DeclareCoeffPhysArrays,
101 ExpList(In, eIDs, DeclareCoeffPhysArrays)
146 = graph1D->GetExpansions();
150 for (
auto &expIt : expansions)
152 if ((SegmentGeom = std::dynamic_pointer_cast<
154 expIt.second->m_geomShPtr)))
158 seg->SetElmtId(
id++);
159 (*m_exp).push_back(seg);
163 ASSERTL0(
false,
"dynamic cast to a SegGeom failed");
205 const bool DeclareCoeffPhysArrays,
217 = graph1D->GetExpansions();
220 for (
auto &expIt : expansions)
225 if ((SegmentGeom = std::dynamic_pointer_cast<
227 expIt.second->m_geomShPtr)))
233 seg->SetElmtId(
id++);
236 (*m_exp).push_back(seg);
240 ASSERTL0(
false,
"dynamic cast to a SegGeom failed");
252 if(DeclareCoeffPhysArrays)
289 const bool DeclareCoeffPhysArrays,
290 const std::string var,
291 bool SetToOneSpaceDimension,
302 = graph1D->GetExpansions(var);
305 for(
auto &compIt : domain)
308 for(j = 0; j < compIt.second->m_geomVec.size(); ++j)
310 if((SegmentGeom = std::dynamic_pointer_cast<
312 compIt.second->m_geomVec[j])))
315 auto expIt = expansions.find(SegmentGeom->GetGlobalID());
316 if(expIt != expansions.end())
320 if(SetToOneSpaceDimension)
323 SegmentGeom->GenerateOneSpaceDimGeom();
336 ASSERTL0(
false,
"Failed to find basis key");
341 ASSERTL0(
false,
"Failed to dynamic cast geometry to SegGeom");
345 seg->SetElmtId(
id++);
348 (*m_exp).push_back(seg);
360 if(DeclareCoeffPhysArrays)
388 const bool DeclareCoeffPhysArrays,
389 const std::string variable,
409 for(
auto &compIt : domain)
412 for(j = 0; j < compIt.second->m_geomVec.size(); ++j)
414 if((SegmentGeom = std::dynamic_pointer_cast<
416 compIt.second->m_geomVec[j])))
420 SegmentGeom, variable);
426 seg->SetElmtId(
id++);
427 (*m_exp).push_back(seg);
431 ASSERTL0(
false,
"dynamic cast to a SegGeom failed");
446 if(DeclareCoeffPhysArrays)
478 const bool DeclareCoeffPhysArrays,
479 const std::string variable,
483 boost::ignore_unused(periodicEdges, variable);
485 int i, j, id, elmtid = 0;
497 map<int,int> EdgeDone;
498 map<int,int> NormalSet;
504 for(i = 0; i < bndCond.num_elements(); ++i)
506 if(bndCond[i]->GetBoundaryConditionType()
509 for(j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
512 ->GetExp(j)->GetBasis(0)->GetBasisKey();
513 exp1D = bndConstraint[i]->GetExp(j)->
514 as<LocalRegions::Expansion1D>();
515 segGeom = exp1D->GetGeom1D();
519 edgesDone.insert(segGeom->GetGlobalID());
521 seg->SetElmtId(elmtid++);
522 (*m_exp).push_back(seg);
528 LibUtilities::BasisKey> > edgeOrders;
530 for(i = 0; i < locexp.size(); ++i)
532 exp2D = locexp[i]->as<LocalRegions::Expansion2D>();
534 for(j = 0; j < locexp[i]->GetNedges(); ++j)
536 segGeom = exp2D->GetGeom2D()->GetEdge(j);
537 id = segGeom->GetGlobalID();
539 if (edgesDone.count(
id) != 0)
544 auto it = edgeOrders.find(
id);
546 if (it == edgeOrders.end())
548 edgeOrders.insert(std::make_pair(
id, std::make_pair(
549 segGeom, locexp[i]->DetEdgeBasisKey(j))));
553 LibUtilities::BasisKey edge
554 = locexp[i]->DetEdgeBasisKey(j);
555 LibUtilities::BasisKey existing
558 int np1 = edge .GetNumPoints();
559 int np2 = existing.GetNumPoints();
560 int nm1 = edge .GetNumModes ();
561 int nm2 = existing.GetNumModes ();
563 if (np2 >= np1 && nm2 >= nm1)
567 else if (np2 < np1 && nm2 < nm1)
569 it->second.second = edge;
574 "inappropriate number of points/modes (max "
575 "num of points is not set with max order)");
582 pSession->GetComm()->GetRowComm();
583 int nproc = vComm->GetSize();
584 int edgepr = vComm->GetRank();
591 for(i = 0; i < locexp.size(); ++i)
593 eCnt += locexp[i]->GetNedges();
598 Array<OneD, int> edgesCnt(nproc, 0);
599 edgesCnt[edgepr] = eCnt;
604 Array<OneD, int> eTotOffsets(nproc,0);
605 for (i = 1; i < nproc; ++i)
607 eTotOffsets[i] = eTotOffsets[i-1] + edgesCnt[i-1];
611 Array<OneD, int> EdgesTotID(totEdgeCnt, 0);
612 Array<OneD, int> EdgesTotNm(totEdgeCnt, 0);
613 Array<OneD, int> EdgesTotPnts(totEdgeCnt, 0);
615 int cntr = eTotOffsets[edgepr];
617 for(i = 0; i < locexp.size(); ++i)
619 exp2D = locexp[i]->as<LocalRegions::Expansion2D>();
621 int nedges = locexp[i]->GetNedges();
623 for(j = 0; j < nedges; ++j, ++cntr)
625 LibUtilities::BasisKey bkeyEdge =
626 locexp[i]->DetEdgeBasisKey(j);
627 EdgesTotID [cntr] = exp2D->GetGeom2D()->GetEid(j);
628 EdgesTotNm [cntr] = bkeyEdge.GetNumModes();
629 EdgesTotPnts[cntr] = bkeyEdge.GetNumPoints();
637 for (i = 0; i < totEdgeCnt; ++i)
639 auto it = edgeOrders.find(EdgesTotID[i]);
641 if (it == edgeOrders.end())
646 LibUtilities::BasisKey existing
648 LibUtilities::BasisKey edge(
649 existing.GetBasisType(), EdgesTotNm[i],
650 LibUtilities::PointsKey(EdgesTotPnts[i],
651 existing.GetPointsType()));
654 int np1 = edge .GetNumPoints();
655 int np2 = existing.GetNumPoints();
656 int nm1 = edge .GetNumModes ();
657 int nm2 = existing.GetNumModes ();
659 if (np2 >= np1 && nm2 >= nm1)
663 else if (np2 < np1 && nm2 < nm1)
665 it->second.second = edge;
670 "inappropriate number of points/modes (max "
671 "num of points is not set with max order)");
676 for (
auto &it : edgeOrders)
680 seg->SetElmtId(elmtid++);
681 (*m_exp).push_back(seg);
693 if(DeclareCoeffPhysArrays)
732 int quad_npoints = elmExp->GetTotPoints();
734 elmExp->GetPointsType(0));
741 int kernel_width = kernel->GetKernelWidth();
748 for(i = 0; i < inarray.num_elements(); i++)
751 kernel->MoveKernelCenter(inarray[i],local_kernel_breaks);
755 kernel->FindMeshUnderKernel(local_kernel_breaks,h,mesh_breaks);
758 int total_nbreaks = local_kernel_breaks.num_elements() +
759 mesh_breaks.num_elements();
762 kernel->Sort(local_kernel_breaks,mesh_breaks,total_breaks);
767 for(j = 0; j < total_breaks.num_elements()-1; j++)
773 for(r = 0; r < quad_points.num_elements(); r++)
775 mapped_quad_points[r]
776 = (quad_points[r] + 1.0) * 0.5 * (b - a) + a;
785 elmExp->GetBasisNumModes(0),u_value);
789 kernel->EvaluateKernel(mapped_quad_points,h,k_value);
792 for(r = 0; r < quad_npoints; r++)
794 integral_value += (b - a) * 0.5 * k_value[r]
795 * u_value[r] * quad_weights[r];
798 outarray[i] = integral_value/h;
829 for(i = 0; i < outarray.num_elements(); i++)
835 int x_size = inarray2.num_elements();
840 for(i = 0; i < x_size; i++ )
842 x_elm[i] = (int)floor(inarray2[i]/h);
846 for(i = 0; i < x_size; i++)
852 while(x_elm[i] >= num_elm)
854 x_elm[i] -= num_elm ;
859 for(i = 0; i < x_size; i++)
861 x_values_cp[i] = (inarray2[i]/h - floor(inarray2[i]/h))*2 - 1.0;
868 for(i = 0; i < nmodes; i++)
871 jacobi_poly.get()+i*x_size,NULL,i,0.0,0.0);
875 for(r = 0; r < nmodes; r++)
877 for(j = 0; j < x_size; j++)
879 int index = ((x_elm[j])*nmodes)+r;
880 outarray[j] += inarray1[index]*jacobi_poly[r][j];
924 for (i = 0; i <
m_exp->size(); ++i)
926 for (j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
928 (*m_exp)[i]->ComputeVertexNormal(j);
949 int i,j,k,e_npoints,offset;
956 ASSERTL1(Vec.num_elements() >= coordim,
957 "Input vector does not have sufficient dimensions to "
961 for(i = 0; i <
m_exp->size(); ++i)
964 e_npoints = (*m_exp)[i]->GetNumPoints(0);
965 normals = (*m_exp)[i]->GetPhysNormals();
971 for(j = 0; j < e_npoints; ++j)
975 for(k = 0; k < coordim; ++k)
977 Vn += Vec[k][offset+j]*normals[k*e_npoints + j];
983 Upwind[offset + j] = Fwd[offset + j];
987 Upwind[offset + j] = Bwd[offset + j];
1012 int i,j,e_npoints,offset;
1016 for(i = 0; i <
m_exp->size(); ++i)
1019 e_npoints = (*m_exp)[i]->GetNumPoints(0);
1023 for(j = 0; j < e_npoints; ++j)
1026 if(Vn[offset + j] > 0.0)
1028 Upwind[offset + j] = Fwd[offset + j];
1032 Upwind[offset + j] = Bwd[offset + j];
1049 int i,j,k,e_npoints,offset;
1057 ASSERTL1(normals.num_elements() >= coordim,
1058 "Output vector does not have sufficient dimensions to "
1061 for (i = 0; i <
m_exp->size(); ++i)
1068 int edgeNumber = loc_exp->GetLeftAdjacentElementEdge();
1071 e_npoints = (*m_exp)[i]->GetNumPoints(0);
1073 locnormals = loc_elmt->GetEdgeNormal(edgeNumber);
1074 int e_nmodes = loc_exp->GetBasis(0)->GetNumModes();
1075 int loc_nmodes = loc_elmt->GetBasis(0)->GetNumModes();
1077 if (e_nmodes != loc_nmodes)
1079 if (loc_exp->GetRightAdjacentElementEdge() >= 0)
1082 loc_exp->GetRightAdjacentElementExp();
1084 int EdgeNumber = loc_exp->GetRightAdjacentElementEdge();
1087 locnormals = loc_elmt->GetEdgeNormal(EdgeNumber);
1092 for (j = 0; j < e_npoints; ++j)
1096 for (k = 0; k < coordim; ++k)
1098 normals[k][offset + j] = -locnormals[k][j];
1107 for (
int p = 0;
p < coordim; ++
p)
1111 loc_exp->GetBasis(0)->GetPointsKey();
1113 loc_elmt->GetBasis(0)->GetPointsKey();
1123 for (j = 0; j < e_npoints; ++j)
1127 for (k = 0; k < coordim; ++k)
1129 normals[k][offset + j] = normal[k][j];
1140 for (j = 0; j < e_npoints; ++j)
1144 for (k = 0; k < coordim; ++k)
1146 normals[k][offset + j] = locnormals[k][j];
1178 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
1180 int ntotminus = (nquad0-1);
1186 (*m_exp)[expansion]->GetCoords(coords[0],coords[1],coords[2]);
1188 outfile <<
" <Piece NumberOfPoints=\""
1189 << ntot <<
"\" NumberOfCells=\""
1190 << ntotminus <<
"\">" << endl;
1191 outfile <<
" <Points>" << endl;
1192 outfile <<
" <DataArray type=\"Float64\" "
1193 <<
"NumberOfComponents=\"3\" format=\"ascii\">" << endl;
1195 for (i = 0; i < ntot; ++i)
1197 for (j = 0; j < 3; ++j)
1199 outfile << setprecision(8) << scientific
1200 << (float)coords[j][i] <<
" ";
1205 outfile <<
" </DataArray>" << endl;
1206 outfile <<
" </Points>" << endl;
1207 outfile <<
" <Cells>" << endl;
1208 outfile <<
" <DataArray type=\"Int32\" "
1209 <<
"Name=\"connectivity\" format=\"ascii\">" << endl;
1210 for (i = 0; i < nquad0-1; ++i)
1212 outfile << i <<
" " << i+1 << endl;
1215 outfile <<
" </DataArray>" << endl;
1216 outfile <<
" <DataArray type=\"Int32\" "
1217 <<
"Name=\"offsets\" format=\"ascii\">" << endl;
1218 for (i = 0; i < ntotminus; ++i)
1220 outfile << i*2+2 <<
" ";
1223 outfile <<
" </DataArray>" << endl;
1224 outfile <<
" <DataArray type=\"UInt8\" "
1225 <<
"Name=\"types\" format=\"ascii\">" << endl;
1226 for (i = 0; i < ntotminus; ++i)
1231 outfile <<
" </DataArray>" << endl;
1232 outfile <<
" </Cells>" << endl;
1233 outfile <<
" <PointData>" << endl;
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Describes the specification for a Basis.
Defines a specification for a set of points.
Expansion2DSharedPtr GetLeftAdjacentElementExp() const
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
This class is the abstraction of a one-dimensional multi-elemental expansions which is merely a colle...
virtual void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip)
const StdRegions::StdExpansionVector &locexp);
void v_Upwind(const Array< OneD, const Array< OneD, NekDouble > > &Vec, 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 velocity field given by Vec.
ExpList1D()
The default constructor.
virtual ~ExpList1D()
Destructor.
void PostProcess(LibUtilities::KernelSharedPtr kernel, Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray, NekDouble h, int elmId=0)
Performs the post-processing on a specified element.
void PeriodicEval(Array< OneD, NekDouble > &inarray1, Array< OneD, NekDouble > &inarray2, NekDouble h, int nmodes, Array< OneD, NekDouble > &outarray)
Evaluates the global spectral/hp expansion at some arbitray set of points.
void v_GetNormals(Array< OneD, Array< OneD, NekDouble > > &normals)
Populate normals with the normals of all expansions.
virtual void v_ReadGlobalOptimizationParameters()
virtual void v_SetUpPhysNormals()
Set up the normals on each expansion.
Base class for all multi-elemental spectral/hp expansions.
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
void CreateCollections(Collections::ImplementationType ImpType=Collections::eNoImpType)
Construct collections of elements containing a single element type and polynomial order from the list...
void Upwind(const Array< OneD, const Array< OneD, NekDouble > > &Vec, const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &Upwind)
const Array< OneD, const NekDouble > & GetCoeffs() const
This function returns (a reference to) the array (implemented as m_coeffs) containing all local expa...
int GetExpSize(void)
This function returns the number of elements in the expansion.
void ReadGlobalOptimizationParameters()
LibUtilities::CommSharedPtr m_comm
Communicator.
std::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
void SetCoeffPhysOffsets()
Definition of the total number of degrees of freedom and quadrature points and offsets to access data...
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
const std::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
SpatialDomains::MeshGraphSharedPtr m_graph
Mesh associated with this expansion list.
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
void SetExpType(ExpansionType Type)
Returns the type of the expansion.
int GetCoordim(int eid)
This function returns the dimension of the coordinates of the element eid.
void Interp1D(const BasisKey &fbasis0, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, Array< OneD, NekDouble > &to)
this function interpolates a 1D function evaluated at the quadrature points of the basis fbasis0 to ...
PointsManagerT & PointsManager(void)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Kernel > KernelSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
std::shared_ptr< SegExp > SegExpSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< Expansion2D > Expansion2DSharedPtr
std::vector< ExpansionSharedPtr > ExpansionVector
std::shared_ptr< Expansion1D > Expansion1DSharedPtr
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
std::map< int, ExpansionShPtr > ExpansionMap
std::map< int, CompositeSharedPtr > CompositeMap
std::shared_ptr< SegGeom > SegGeomSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< Geometry2D > Geometry2DSharedPtr
std::shared_ptr< Geometry1D > Geometry1DSharedPtr
void jacobfd(const int np, const double *z, double *poly_in, double *polyd, const int n, const double alpha, const double beta)
Routine to calculate Jacobi polynomials, , and their first derivative, .
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)