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");
179 const bool DeclareCoeffPhysArrays):
190 = graph1D->GetExpansions();
193 SpatialDomains::ExpansionMap::const_iterator expIt;
194 for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
199 if ((SegmentGeom = boost::dynamic_pointer_cast<
201 expIt->second->m_geomShPtr)))
207 seg->SetElmtId(
id++);
210 (*m_exp).push_back(seg);
214 ASSERTL0(
false,
"dynamic cast to a SegGeom failed");
226 if(DeclareCoeffPhysArrays)
263 const bool DeclareCoeffPhysArrays,
264 const std::string var,
265 bool SetToOneSpaceDimension):
272 SpatialDomains::CompositeMap::const_iterator compIt;
276 = graph1D->GetExpansions(var);
279 for(compIt = domain.begin(); compIt != domain.end(); ++compIt)
281 comp = compIt->second;
284 for(j = 0; j < compIt->second->size(); ++j)
286 SpatialDomains::ExpansionMap::const_iterator expIt;
288 if((SegmentGeom = boost::dynamic_pointer_cast<
290 (*compIt->second)[j])))
293 if((expIt = expansions.find(SegmentGeom->GetGlobalID())) != expansions.end())
297 if(SetToOneSpaceDimension)
300 SegmentGeom->GenerateOneSpaceDimGeom();
313 ASSERTL0(
false,
"Failed to find basis key");
319 ASSERTL0(
false,
"Failed to dynamic cast geometry to SegGeom");
324 seg->SetElmtId(
id++);
327 (*m_exp).push_back(seg);
339 if(DeclareCoeffPhysArrays)
367 const bool DeclareCoeffPhysArrays,
368 const std::string variable):
377 SpatialDomains::CompositeMap::const_iterator compIt;
382 for(compIt = domain.begin(); compIt != domain.end(); ++compIt)
384 comp = compIt->second;
386 for(j = 0; j < compIt->second->size(); ++j)
388 if((SegmentGeom = boost::dynamic_pointer_cast<
390 (*compIt->second)[j])))
400 seg->SetElmtId(
id++);
401 (*m_exp).push_back(seg);
405 ASSERTL0(
false,
"dynamic cast to a SegGeom failed");
420 if(DeclareCoeffPhysArrays)
452 const bool DeclareCoeffPhysArrays,
453 const std::string variable):
456 int i, j, id, elmtid = 0;
468 map<int,int> EdgeDone;
469 map<int,int> NormalSet;
475 for(i = 0; i < bndCond.num_elements(); ++i)
477 if(bndCond[i]->GetBoundaryConditionType()
480 for(j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
483 ->GetExp(j)->GetBasis(0)->GetBasisKey();
484 exp1D = bndConstraint[i]->GetExp(j)->
485 as<LocalRegions::Expansion1D>();
486 segGeom = exp1D->GetGeom1D();
490 edgesDone.insert(segGeom->GetEid());
492 seg->SetElmtId(elmtid++);
493 (*m_exp).push_back(seg);
503 for(i = 0; i < locexp.size(); ++i)
507 for(j = 0; j < locexp[i]->GetNedges(); ++j)
509 segGeom = exp2D->
GetGeom2D()->GetEdge(j);
510 id = segGeom->GetEid();
512 if (edgesDone.count(
id) != 0)
517 it = edgeOrders.find(
id);
519 if (it == edgeOrders.end())
521 edgeOrders.insert(std::make_pair(
id, std::make_pair(
522 segGeom, locexp[i]->DetEdgeBasisKey(j))));
527 = locexp[i]->DetEdgeBasisKey(j);
536 if (np2 >= np1 && nm2 >= nm1)
540 else if (np2 < np1 && nm2 < nm1)
542 it->second.second = edge;
547 "inappropriate number of points/modes (max "
548 "num of points is not set with max order)");
555 pSession->GetComm()->GetRowComm();
556 int nproc = vComm->GetSize();
557 int edgepr = vComm->GetRank();
564 for(i = 0; i < locexp.size(); ++i)
566 eCnt += locexp[i]->GetNedges();
572 edgesCnt[edgepr] = eCnt;
578 for (i = 1; i < nproc; ++i)
580 eTotOffsets[i] = eTotOffsets[i-1] + edgesCnt[i-1];
588 int cntr = eTotOffsets[edgepr];
590 for(i = 0; i < locexp.size(); ++i)
596 for(j = 0; j < nedges; ++j, ++cntr)
599 locexp[i]->DetEdgeBasisKey(j);
600 EdgesTotID [cntr] = exp2D->GetGeom2D()->GetEid(j);
610 for (i = 0; i < totEdgeCnt; ++i)
612 it = edgeOrders.find(EdgesTotID[i]);
614 if (it == edgeOrders.end())
632 if (np2 >= np1 && nm2 >= nm1)
636 else if (np2 < np1 && nm2 < nm1)
638 it->second.second = edge;
643 "inappropriate number of points/modes (max "
644 "num of points is not set with max order)");
649 for (it = edgeOrders.begin(); it != edgeOrders.end(); ++it)
653 seg->SetElmtId(elmtid++);
654 (*m_exp).push_back(seg);
666 if(DeclareCoeffPhysArrays)
696 for(i = 0; i <
m_exp->size(); ++i)
700 m_offset_elmt_id[i] = i;
701 m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
702 m_npoints += (*m_exp)[i]->GetTotPoints();
736 int quad_npoints = elmExp->GetTotPoints();
738 elmExp->GetPointsType(0));
745 int kernel_width = kernel->GetKernelWidth();
752 for(i = 0; i < inarray.num_elements(); i++)
755 kernel->MoveKernelCenter(inarray[i],local_kernel_breaks);
759 kernel->FindMeshUnderKernel(local_kernel_breaks,h,mesh_breaks);
762 int total_nbreaks = local_kernel_breaks.num_elements() +
763 mesh_breaks.num_elements();
766 kernel->Sort(local_kernel_breaks,mesh_breaks,total_breaks);
771 for(j = 0; j < total_breaks.num_elements()-1; j++)
777 for(r = 0; r < quad_points.num_elements(); r++)
779 mapped_quad_points[r]
780 = (quad_points[r] + 1.0) * 0.5 * (b - a) + a;
789 elmExp->GetBasisNumModes(0),u_value);
793 kernel->EvaluateKernel(mapped_quad_points,h,k_value);
796 for(r = 0; r < quad_npoints; r++)
798 integral_value += (b - a) * 0.5 * k_value[r]
799 * u_value[r] * quad_weights[r];
802 outarray[i] = integral_value/h;
833 for(i = 0; i < outarray.num_elements(); i++)
839 int x_size = inarray2.num_elements();
844 for(i = 0; i < x_size; i++ )
846 x_elm[i] = (int)floor(inarray2[i]/h);
850 for(i = 0; i < x_size; i++)
856 while(x_elm[i] >= num_elm)
858 x_elm[i] -= num_elm ;
863 for(i = 0; i < x_size; i++)
865 x_values_cp[i] = (inarray2[i]/h - floor(inarray2[i]/h))*2 - 1.0;
872 for(i = 0; i < nmodes; i++)
875 jacobi_poly.get()+i*x_size,NULL,i,0.0,0.0);
879 for(r = 0; r < nmodes; r++)
881 for(j = 0; j < x_size; j++)
883 int index = ((x_elm[j])*nmodes)+r;
884 outarray[j] += inarray1[index]*jacobi_poly[r][j];
928 for (i = 0; i <
m_exp->size(); ++i)
930 for (j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
932 (*m_exp)[i]->ComputeVertexNormal(j);
953 int i,j,k,e_npoints,offset;
960 ASSERTL1(Vec.num_elements() >= coordim,
961 "Input vector does not have sufficient dimensions to "
965 for(i = 0; i <
m_exp->size(); ++i)
968 e_npoints = (*m_exp)[i]->GetNumPoints(0);
969 normals = (*m_exp)[i]->GetPhysNormals();
975 for(j = 0; j < e_npoints; ++j)
979 for(k = 0; k < coordim; ++k)
981 Vn += Vec[k][offset+j]*normals[k*e_npoints + j];
987 Upwind[offset + j] = Fwd[offset + j];
991 Upwind[offset + j] = Bwd[offset + j];
1016 int i,j,e_npoints,offset;
1020 for(i = 0; i <
m_exp->size(); ++i)
1023 e_npoints = (*m_exp)[i]->GetNumPoints(0);
1027 for(j = 0; j < e_npoints; ++j)
1030 if(Vn[offset + j] > 0.0)
1032 Upwind[offset + j] = Fwd[offset + j];
1036 Upwind[offset + j] = Bwd[offset + j];
1053 int i,j,k,e_npoints,offset;
1061 ASSERTL1(normals.num_elements() >= coordim,
1062 "Output vector does not have sufficient dimensions to "
1065 for (i = 0; i <
m_exp->size(); ++i)
1072 int edgeNumber = loc_exp->GetLeftAdjacentElementEdge();
1075 e_npoints = (*m_exp)[i]->GetNumPoints(0);
1077 locnormals = loc_elmt->GetEdgeNormal(edgeNumber);
1078 int e_nmodes = loc_exp->GetBasis(0)->GetNumModes();
1079 int loc_nmodes = loc_elmt->GetBasis(0)->GetNumModes();
1081 if (e_nmodes != loc_nmodes)
1083 if (loc_exp->GetRightAdjacentElementEdge() >= 0)
1086 loc_exp->GetRightAdjacentElementExp();
1088 int EdgeNumber = loc_exp->GetRightAdjacentElementEdge();
1091 locnormals = loc_elmt->GetEdgeNormal(EdgeNumber);
1096 for (j = 0; j < e_npoints; ++j)
1100 for (k = 0; k < coordim; ++k)
1102 normals[k][offset + j] = -locnormals[k][j];
1111 for (
int p = 0; p < coordim; ++p)
1115 loc_exp->GetBasis(0)->GetPointsKey();
1117 loc_elmt->GetBasis(0)->GetPointsKey();
1127 for (j = 0; j < e_npoints; ++j)
1131 for (k = 0; k < coordim; ++k)
1133 normals[k][offset + j] = normal[k][j];
1144 for (j = 0; j < e_npoints; ++j)
1148 for (k = 0; k < coordim; ++k)
1150 normals[k][offset + j] = locnormals[k][j];
1182 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
1184 int ntotminus = (nquad0-1);
1190 (*m_exp)[expansion]->GetCoords(coords[0],coords[1],coords[2]);
1192 outfile <<
" <Piece NumberOfPoints=\""
1193 << ntot <<
"\" NumberOfCells=\""
1194 << ntotminus <<
"\">" << endl;
1195 outfile <<
" <Points>" << endl;
1196 outfile <<
" <DataArray type=\"Float32\" "
1197 <<
"NumberOfComponents=\"3\" format=\"ascii\">" << endl;
1199 for (i = 0; i < ntot; ++i)
1201 for (j = 0; j < 3; ++j)
1203 outfile << setprecision(8) << scientific
1204 << (float)coords[j][i] <<
" ";
1209 outfile <<
" </DataArray>" << endl;
1210 outfile <<
" </Points>" << endl;
1211 outfile <<
" <Cells>" << endl;
1212 outfile <<
" <DataArray type=\"Int32\" "
1213 <<
"Name=\"connectivity\" format=\"ascii\">" << endl;
1214 for (i = 0; i < nquad0-1; ++i)
1216 outfile << i <<
" " << i+1 << endl;
1219 outfile <<
" </DataArray>" << endl;
1220 outfile <<
" <DataArray type=\"Int32\" "
1221 <<
"Name=\"offsets\" format=\"ascii\">" << endl;
1222 for (i = 0; i < ntotminus; ++i)
1224 outfile << i*2+2 <<
" ";
1227 outfile <<
" </DataArray>" << endl;
1228 outfile <<
" <DataArray type=\"UInt8\" "
1229 <<
"Name=\"types\" format=\"ascii\">" << endl;
1230 for (i = 0; i < ntotminus; ++i)
1235 outfile <<
" </DataArray>" << endl;
1236 outfile <<
" </Cells>" << endl;
1237 outfile <<
" <PointData>" << endl;
const Array< OneD, const NekDouble > & GetCoeffs() const
This function returns (a reference to) the array (implemented as m_coeffs) containing all local expa...
ExpList1D()
The default constructor.
#define ASSERTL0(condition, msg)
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.
const boost::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
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_SetUpPhysNormals()
Set up the normals on each expansion.
std::vector< ExpansionSharedPtr > ExpansionVector
Expansion2DSharedPtr GetLeftAdjacentElementExp() const
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.
Array< OneD, int > m_coeff_offset
Offset of elemental data into the array m_coeffs.
boost::shared_ptr< SegExp > SegExpSharedPtr
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.
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
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.
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.
boost::shared_ptr< Kernel > KernelSharedPtr
PointsManagerT & PointsManager(void)
SpatialDomains::MeshGraphSharedPtr m_graph
Mesh associated with this expansion list.
Defines a specification for a set of points.
boost::shared_ptr< GeometryVector > Composite
std::map< int, Composite > CompositeMap
void SetCoeffPhysOffsets(void)
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
boost::shared_ptr< Geometry2D > Geometry2DSharedPtr
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void v_GetNormals(Array< OneD, Array< OneD, NekDouble > > &normals)
Populate normals with the normals of all expansions.
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 ...
This class is the abstraction of a one-dimensional multi-elemental expansions which is merely a colle...
boost::shared_ptr< Geometry1D > Geometry1DSharedPtr
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.
virtual void v_ReadGlobalOptimizationParameters()
void ReadGlobalOptimizationParameters()
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.
virtual void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip)
const StdRegions::StdExpansionVector &locexp);
void SetExpType(ExpansionType Type)
Returns the type of the expansion.
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
boost::shared_ptr< Expansion1D > Expansion1DSharedPtr
int GetNedges() const
This function returns the number of edges of the expansion domain.
virtual ~ExpList1D()
Destructor.
Describes the specification for a Basis.
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, .
std::map< int, ExpansionShPtr > ExpansionMap
boost::shared_ptr< Expansion2D > Expansion2DSharedPtr