49 #include <boost/core/ignore_unused.hpp> 50 #include <boost/config.hpp> 51 #include <boost/graph/adjacency_list.hpp> 52 #include <boost/graph/cuthill_mckee_ordering.hpp> 53 #include <boost/graph/properties.hpp> 54 #include <boost/graph/bandwidth.hpp> 60 namespace MultiRegions
62 AssemblyMapDG::AssemblyMapDG():
63 m_numDirichletBndPhys(0)
79 const std::string variable):
82 boost::ignore_unused(graph);
84 int i, j, k, cnt, eid, id, id1, gid;
86 int nTraceExp = trace->GetExpSize();
87 int nbnd = bndCondExp.num_elements();
94 int nel = expList.size();
96 map<int, int> meshTraceId;
101 for(i = 0; i < nTraceExp; ++i)
103 meshTraceId[trace->GetExp(i)->GetGeom()->GetGlobalID()] = i;
108 for(i = 0; i < nel; ++i)
110 cnt += expList[i]->GetNtrace();
118 for(cnt = i = 0; i < nel; ++i)
122 for(j = 0; j < expList[i]->GetNtrace(); ++j)
124 id = expList[i]->GetGeom()->GetTid(j);
126 if(meshTraceId.count(
id) > 0)
129 trace->GetExp(meshTraceId.find(
id)->second);
133 ASSERTL0(
false,
"Failed to find trace map");
137 cnt += expList[i]->GetNtrace();
142 for(i = 0; i < nbnd; ++i)
144 if (bndCond[i]->GetBoundaryConditionType() ==
149 cnt += bndCondExp[i]->GetExpSize();
157 for(i = 0; i < bndCondExp.num_elements(); ++i)
159 for(j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
161 bndExp = bndCondExp[i]->GetExp(j);
162 traceGeom = bndExp->GetGeom();
163 id = traceGeom->GetGlobalID();
165 if(bndCond[i]->GetBoundaryConditionType() ==
184 for(i = 0; i < nel; ++i)
187 nbndry += expList[eid]->NumDGBndryCoeffs();
188 m_numLocalIntCoeffsPerPatch[i] = 0;
190 (
unsigned int) expList[eid]->NumDGBndryCoeffs();
206 typedef boost::adjacency_list<
207 boost::setS, boost::vecS, boost::undirectedS> BoostGraph;
209 BoostGraph boostGraphObj;
210 int trace_id, trace_id1;
215 for(i = 0; i < nTraceExp; ++i)
217 id = trace->GetExp(i)->GetGeom()->GetGlobalID();
219 if (dirTrace.count(
id) == 0)
223 boost::add_vertex(boostGraphObj);
224 traceElmtGid[i] = cnt++;
229 traceElmtGid[i] = dirOffset;
230 dirOffset += trace->GetExp(i)->GetNcoeffs();
236 for(i = 0; i < nel; ++i)
240 for(j = 0; j < expList[eid]->GetNtrace(); ++j)
244 id = traceGeom->GetGlobalID();
245 trace_id = meshTraceId.find(
id)->second;
247 if(dirTrace.count(
id) == 0)
249 for(k = j+1; k < expList[eid]->GetNtrace(); ++k)
252 id1 = traceGeom->GetGlobalID();
253 trace_id1 = meshTraceId.find(id1)->second;
255 if(dirTrace.count(id1) == 0)
257 boost::add_edge((
size_t)traceElmtGid[trace_id],
258 (
size_t)traceElmtGid[trace_id1],
266 int nGraphVerts = nTraceExp - nDir;
272 for(i = 0; i < nGraphVerts; ++i)
274 vwgts[i] = trace->GetExp(i+nDir)->GetNcoeffs();
308 ASSERTL0(
false,
"Unrecognised solution type");
316 for(i = 0; i < nTraceExp - nDir; ++i)
318 traceElmtGid[perm[i]+nDir] = cnt;
319 cnt += trace->GetExp(perm[i]+nDir)->GetNcoeffs();
325 for(i = 0; i < nel; ++i)
330 for(j = 0; j < exp->GetNtrace(); ++j)
333 id = traceGeom->GetGlobalID();
334 gid = traceElmtGid[meshTraceId.find(
id)->second];
336 const int nDim = expList[eid]->GetNumBases();
345 order_e = expList[eid]->GetEdgeNcoeffs(j);
349 for(k = 0; k < order_e; ++k)
363 for (k = 2; k < order_e; ++k)
369 for(k = 3; k < order_e; k+=2)
371 m_localToGlobalBndSign[cnt+k] = -1.0;
378 for(k = 0; k < order_e; ++k)
387 for(k = 0; k < order_e; ++k)
395 ASSERTL0(
false,
"Boundary type not permitted");
402 order_e = expList[eid]->GetFaceNcoeffs(j);
404 std::map<int, int> orientMap;
415 expList[eid]->GetFaceToElementMap(j,fo,elmMap1,elmSign1);
416 expList[eid]->GetFaceToElementMap(
419 for (k = 0; k < elmMap1.num_elements(); ++k)
424 for (
int l = 0; l < elmMap2.num_elements(); ++l)
426 if (elmMap1[k] == elmMap2[l])
433 ASSERTL2(idx != -1,
"Problem with face to element map!");
437 for(k = 0; k < order_e; ++k)
440 m_localToGlobalBndSign[k+cnt] = elmSign2[orientMap[k]];
450 for(i = 0; i < nbnd; ++i)
452 if (bndCond[i]->GetBoundaryConditionType() ==
457 cnt += bndCondExp[i]->GetNcoeffs();
463 int nbndexp = 0, bndOffset, bndTotal = 0;
464 for(cnt = i = 0; i < nbnd; ++i)
466 if (bndCond[i]->GetBoundaryConditionType() ==
472 for(j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
474 bndExp = bndCondExp[i]->GetExp(j);
475 id = bndExp->GetGeom()->GetGlobalID();
476 gid = traceElmtGid[meshTraceId.find(
id)->second];
477 bndOffset = bndCondExp[i]->GetCoeff_Offset(j) + bndTotal;
482 for(k = 0; k < bndExp->GetNcoeffs(); ++k)
488 nbndexp += bndCondExp[i]->GetExpSize();
489 bndTotal += bndCondExp[i]->GetNcoeffs();
499 for(i = 0; i < bndCondExp.num_elements(); ++i)
501 if (bndCond[i]->GetBoundaryConditionType() ==
507 for(j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
509 bndExp = bndCondExp[i]->GetExp(j);
510 traceGeom = bndExp->GetGeom();
511 id = traceGeom->GetGlobalID();
513 meshTraceId.find(
id)->second;
532 for (
int i = 0; i < nGraphVerts; i++)
534 vwgts_perm[i] = vwgts[perm[i]];
537 bottomUpGraph->ExpandGraphWithVertexWeights(vwgts_perm);
576 for(i = 0; i < locExpVector.size(); ++i)
578 locExpansion = locExpVector[i];
579 nDim = locExpansion->GetShapeDimension();
584 maxDof = (1 > maxDof ? 1 : maxDof);
588 for (j = 0; j < locExpansion->GetNedges(); ++j)
590 dof = locExpansion->GetEdgeNcoeffs(j);
591 maxDof = (dof > maxDof ? dof : maxDof);
596 for (j = 0; j < locExpansion->GetNfaces(); ++j)
598 dof = locExpansion->GetFaceNcoeffs(j);
599 maxDof = (dof > maxDof ? dof : maxDof);
607 for(i = 0; i < locExpVector.size(); ++i)
610 locExpansion = locExpVector[eid];
611 nDim = locExpansion->GetShapeDimension();
616 int nverts = locExpansion->GetNverts();
617 for(j = 0; j < nverts; ++j)
621 id = locPointExp->
GetGeom()->GetGlobalID();
624 =
id * maxDof + j + 1;
630 for(j = 0; j < locExpansion->GetNedges(); ++j)
635 id = locSegExp->
GetGeom()->GetGlobalID();
636 order_e = locExpansion->GetEdgeNcoeffs(j);
638 map<int,int> orientMap;
643 locExpansion->GetEdgeToElementMap(j, locExpansion->GetEorient(j), map2, sign2);
645 for (k = 0; k < map1.num_elements(); ++k)
650 for (
int l = 0; l < map2.num_elements(); ++l)
652 if (map1[k] == map2[l])
659 ASSERTL2(idx != -1,
"Problem with face to element map!");
663 for(k = 0; k < order_e; ++k)
667 =
id * maxDof + orientMap[k] + 1;
674 for(j = 0; j < locExpansion->GetNfaces(); ++j)
680 id = locFaceExp->
GetGeom()->GetGlobalID();
681 order_e = locExpansion->GetFaceNcoeffs(j);
683 map<int,int> orientMap;
688 locExpansion->GetFaceToElementMap(j, locExpansion->GetForient(j), map2, sign2);
690 for (k = 0; k < map1.num_elements(); ++k)
695 for (
int l = 0; l < map2.num_elements(); ++l)
697 if (map1[k] == map2[l])
704 ASSERTL2(idx != -1,
"Problem with face to element map!");
708 for(k = 0; k < order_e; ++k)
712 =
id * maxDof + orientMap[k] + 1;
729 m_globalToUniversalBndMapUnique[i] = (tmp[i] >= 0 ? 1 : 0);
741 int maxQuad = 0, quad = 0, nDim = 0, eid = 0, offset = 0;
745 int nTracePhys = trace->GetTotPoints();
755 nDim = locExpVector[0]->GetShapeDimension();
759 maxQuad = (1 > maxQuad ? 1 : maxQuad);
763 for (i = 0; i < trace->GetExpSize(); ++i)
765 quad = trace->GetExp(i)->GetTotPoints();
776 for (
int i = 0; i < trace->GetExpSize(); ++i)
778 eid = trace->GetExp(i)->GetGeom()->GetGlobalID();
779 offset = trace->GetPhys_Offset(i);
783 auto it = perMap.find(eid);
784 if (perMap.count(eid) > 0)
789 eid = min(eid, ent.
id);
798 for (
int i = 0; i < trace->GetExpSize(); ++i)
800 eid = trace->GetExp(i)->GetGeom()->GetGlobalID();
801 offset = trace->GetPhys_Offset(i);
802 quad = trace->GetExp(i)->GetTotPoints();
808 auto it = perMap.find(eid);
809 bool realign =
false;
810 if (perMap.count(eid) > 0)
815 realign = eid == min(eid, ent.
id);
816 eid = min(eid, ent.
id);
820 for (
int j = 0; j < quad; ++j)
831 it->second[0].orient, quad);
837 it->second[0].orient,
838 trace->GetExp(i)->GetNumPoints(0),
839 trace->GetExp(i)->GetNumPoints(1));
846 for (
int i = 0; i < nTracePhys; ++i)
852 for (
int i = 0; i < nTracePhys; ++i)
854 m_traceToUniversalMapUnique[i] = tmp2[i];
866 ASSERTL1(nquad2 == 0,
"nquad2 != 0 for reorienation");
867 for (
int i = 0; i < nquad1/2; ++i)
869 swap(toAlign[i], toAlign[nquad1-1-i]);
874 ASSERTL1(nquad2 != 0,
"nquad2 == 0 for reorienation");
884 for (
int i = 0; i < nquad2; ++i)
886 for (
int j = 0; j < nquad1; ++j)
888 tmp[i*nquad1 + j] = toAlign[j*nquad2 + i];
894 for (
int i = 0; i < nquad2; ++i)
896 for (
int j = 0; j < nquad1; ++j)
898 tmp[i*nquad1 + j] = toAlign[i*nquad1 + j];
909 for (
int i = 0; i < nquad2; ++i)
911 for (
int j = 0; j < nquad1/2; ++j)
913 swap(tmp[i*nquad1 + j],
914 tmp[i*nquad1 + nquad1-j-1]);
925 for (
int j = 0; j < nquad1; ++j)
927 for (
int i = 0; i < nquad2/2; ++i)
929 swap(tmp[i*nquad1 + j],
930 tmp[(nquad2-i-1)*nquad1 + j]);
985 boost::ignore_unused(useComm);
994 boost::ignore_unused(useComm);
1062 "i is out of range");
void GlobalToLocalBnd(const NekVector< NekDouble > &global, NekVector< NekDouble > &loc, int offset) const
AssemblyMapDG()
Default constructor.
#define ASSERTL0(condition, msg)
std::size_t hash_range(Iter first, Iter last)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
bool m_signChange
Flag indicating if modes require sign reversal.
int m_numGlobalBndCoeffs
Total number of global boundary coefficients.
int id
Geometry ID of entity.
void MultiLevelBisectionReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm, BottomUpSubStructuredGraphSharedPtr &substructgraph, std::set< int > partVerts, int mdswitch)
int GetBndSystemBandWidth() const
Returns the bandwidth of the boundary system.
LibUtilities::CommSharedPtr m_comm
Communicator.
static void Gather(Nektar::Array< OneD, NekDouble > pU, gs_op pOp, gs_data *pGsh, Nektar::Array< OneD, NekDouble > pBuffer=NullNekDouble1DArray)
Performs a gather-scatter operation of the provided values.
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
Array< OneD, int > m_bndCondTraceToGlobalTraceMap
Integer map of bnd cond trace number to global trace number.
SpatialDomains::GeometrySharedPtr GetGeom() const
Principle Modified Functions .
Lagrange Polynomials using the Gauss points .
int m_numLocalCoeffs
Total number of local coefficients.
void CuthillMckeeReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm)
void UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
const std::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Array< OneD, int > m_traceToUniversalMap
Integer map of process trace space quadrature points to universal space.
std::vector< ExpansionSharedPtr > ExpansionVector
AssemblyMapSharedPtr m_nextLevelLocalToGlobalMap
Map from the patches of the previous level to the patches of the current level.
Base class for constructing local to global mapping of degrees of freedom.
static gs_data * Init(const Nektar::Array< OneD, long > pId, const LibUtilities::CommSharedPtr &pComm, bool verbose=true)
Initialise Gather-Scatter map.
size_t m_hash
Hash for map.
Base class for all multi-elemental spectral/hp expansions.
Array< OneD, Array< OneD, LocalRegions::ExpansionSharedPtr > > & GetElmtToTrace()
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique()
void SetUpUniversalTraceMap(const ExpList &locExp, const ExpListSharedPtr trace, const PeriodicMap &perMap=NullPeriodicMap)
virtual void v_Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
Array< OneD, unsigned int > m_numLocalBndCoeffsPerPatch
The number of bnd dofs per patch.
GlobalSysSolnType m_solnType
The solution type of the global system.
virtual void v_GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const
int m_numGlobalDirBndCoeffs
Number of Global Dirichlet Boundary Coefficients.
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm) const
virtual int v_GetFullSystemBandWidth() const
std::shared_ptr< Geometry > GeometrySharedPtr
virtual const Array< OneD, const int > & v_GetLocalToGlobalMap()
bool isLocal
Flag specifying if this entity is local to this partition.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static void Unique(const Nektar::Array< OneD, long > pId, const LibUtilities::CommSharedPtr &pComm)
Updates pId to negate all-but-one references to each universal ID.
Array< OneD, const NekDouble > GetLocalToGlobalBndSign() const
Retrieve the sign change for all local boundary modes.
void SetUpUniversalDGMap(const ExpList &locExp)
Array< OneD, unsigned int > m_numLocalIntCoeffsPerPatch
The number of int dofs per patch.
int GetTraceToUniversalMap(int i)
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
int m_lowestStaticCondLevel
Lowest static condensation level.
void CalculateBndSystemBandWidth()
Calculates the bandwidth of the boundary system.
Array< OneD, int > m_localToGlobalBndMap
Integer map of local boundary coeffs to global space.
virtual ~AssemblyMapDG()
Destructor.
int m_numLocalDirBndCoeffs
Number of Local Dirichlet Boundary Coefficients.
Array< OneD, int > m_traceToUniversalMapUnique
Integer map of unique process trace space quadrature points to universal space (signed).
Array< OneD, int > m_bndCondCoeffsToGlobalCoeffsMap
Integer map of bnd cond coeffs to global coefficients.
int GetTraceToUniversalMapUnique(int i)
std::shared_ptr< Expansion > ExpansionSharedPtr
int m_numLocalBndCoeffs
Number of local boundary coefficients.
std::shared_ptr< PointExp > PointExpSharedPtr
int m_staticCondLevel
The level of recursion in the case of multi-level static condensation.
Array< OneD, NekDouble > m_localToGlobalBndSign
Integer sign of local boundary coeffs to global space.
std::shared_ptr< Expansion2D > Expansion2DSharedPtr
Array< OneD, Array< OneD, LocalRegions::ExpansionSharedPtr > > m_elmtToTrace
list of edge expansions for a given element
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
virtual const Array< OneD, NekDouble > & v_GetLocalToGlobalSign() const
void AssembleBnd(const NekVector< NekDouble > &loc, NekVector< NekDouble > &global, int offset) const
std::shared_ptr< SegExp > SegExpSharedPtr
void UniversalTraceAssemble(Array< OneD, NekDouble > &pGlobal) const
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMap()
Array< OneD, int > m_globalToUniversalBndMap
Integer map of process coeffs to universal space.
Array< OneD, int > m_globalToUniversalBndMapUnique
Integer map of unique process coeffs to universal space (signed)
int m_numGlobalCoeffs
Total number of global coefficients.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
std::shared_ptr< BottomUpSubStructuredGraph > BottomUpSubStructuredGraphSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void RealignTraceElement(Array< OneD, int > &toAlign, StdRegions::Orientation orient, int nquad1, int nquad2=0)
Array< OneD, DataType > & GetPtr()
int GetNumDirichletBndPhys()
Return the number of boundary segments on which Dirichlet boundary conditions are imposed...
int m_numPatches
The number of patches (~elements) in the current level.
const SpatialDomains::PointGeomSharedPtr GetGeom() const
void NoReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm)
int m_numDirichletBndPhys
Number of physical dirichlet boundary values in trace.
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const