44 #include <boost/core/ignore_unused.hpp>
45 #include <boost/config.hpp>
46 #include <boost/graph/adjacency_list.hpp>
52 namespace MultiRegions
54 AssemblyMapDG::AssemblyMapDG():
55 m_numDirichletBndPhys(0)
71 const std::string variable):
74 boost::ignore_unused(graph);
76 int i, j, k, cnt, id, id1, gid;
78 int nTraceExp = trace->GetExpSize();
79 int nbnd = bndCondExp.size();
86 int nel = expList.size();
88 map<int, int> meshTraceId;
93 for(i = 0; i < nTraceExp; ++i)
95 meshTraceId[trace->GetExp(i)->GetGeom()->GetGlobalID()] = i;
100 for(i = 0; i < nel; ++i)
102 cnt += expList[i]->GetNtraces();
110 for(cnt = i = 0; i < nel; ++i)
115 for(j = 0; j < exp->GetNtraces(); ++j)
117 id = exp->GetGeom()->GetTid(j);
119 if(meshTraceId.count(
id) > 0)
122 trace->GetExp(meshTraceId.find(
id)->second);
126 ASSERTL0(
false,
"Failed to find trace map");
130 cnt += exp->GetNtraces();
135 for(i = 0; i < nbnd; ++i)
137 if (bndCond[i]->GetBoundaryConditionType() ==
142 cnt += bndCondExp[i]->GetExpSize();
150 for(i = 0; i < bndCondExp.size(); ++i)
152 for(j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
154 bndExp = bndCondExp[i]->GetExp(j);
155 traceGeom = bndExp->GetGeom();
156 id = traceGeom->GetGlobalID();
158 if(bndCond[i]->GetBoundaryConditionType() ==
177 for(i = 0; i < nel; ++i)
179 int BndCoeffs = expList[i]->NumDGBndryCoeffs();
198 typedef boost::adjacency_list<
199 boost::setS, boost::vecS, boost::undirectedS> BoostGraph;
201 BoostGraph boostGraphObj;
202 int trace_id, trace_id1;
207 for(i = 0; i < nTraceExp; ++i)
209 id = trace->GetExp(i)->GetGeom()->GetGlobalID();
211 if (dirTrace.count(
id) == 0)
215 boost::add_vertex(boostGraphObj);
216 traceElmtGid[i] = cnt++;
221 traceElmtGid[i] = dirOffset;
222 dirOffset += trace->GetExp(i)->GetNcoeffs();
228 for(i = 0; i < nel; ++i)
232 for(j = 0; j < exp->GetNtraces(); ++j)
236 id = traceGeom->GetGlobalID();
237 trace_id = meshTraceId.find(
id)->second;
239 if(dirTrace.count(
id) == 0)
241 for(k = j+1; k < exp->GetNtraces(); ++k)
244 id1 = traceGeom->GetGlobalID();
245 trace_id1 = meshTraceId.find(id1)->second;
247 if(dirTrace.count(id1) == 0)
249 boost::add_edge((
size_t)traceElmtGid[trace_id],
250 (
size_t)traceElmtGid[trace_id1],
258 int nGraphVerts = nTraceExp - nDir;
264 for(i = 0; i < nGraphVerts; ++i)
266 vwgts[i] = trace->GetExp(i+nDir)->GetNcoeffs();
300 ASSERTL0(
false,
"Unrecognised solution type");
308 for(i = 0; i < nTraceExp - nDir; ++i)
310 traceElmtGid[perm[i]+nDir] = cnt;
311 cnt += trace->GetExp(perm[i]+nDir)->GetNcoeffs();
316 for(i = 0; i < nel; ++i)
320 for(j = 0; j < exp->GetNtraces(); ++j)
323 id = traceGeom->GetGlobalID();
324 gid = traceElmtGid[meshTraceId.find(
id)->second];
326 const int nDim = exp->GetNumBases();
335 order_e = exp->GetTraceNcoeffs(j);
339 for(k = 0; k < order_e; ++k)
353 for (k = 2; k < order_e; ++k)
359 for(k = 3; k < order_e; k+=2)
368 for(k = 0; k < order_e; ++k)
377 for(k = 0; k < order_e; ++k)
385 ASSERTL0(
false,
"Boundary type not permitted");
392 order_e = exp->GetTraceNcoeffs(j);
394 std::map<int, int> orientMap;
405 exp->GetTraceToElementMap(j,elmMap1,elmSign1,fo);
406 exp->GetTraceToElementMap(j,elmMap2,elmSign2,
409 for (k = 0; k < elmMap1.size(); ++k)
414 for (
int l = 0; l < elmMap2.size(); ++l)
416 if (elmMap1[k] == elmMap2[l])
423 ASSERTL2(idx != -1,
"Problem with face to element map!");
427 for(k = 0; k < order_e; ++k)
461 for(i = 0; i < nbnd; ++i)
463 if (bndCond[i]->GetBoundaryConditionType() ==
468 cnt += bndCondExp[i]->GetNcoeffs();
469 nbndexp += bndCondExp[i]->GetExpSize();
476 for(i = 0; i < bndCondExp.size(); ++i)
478 if (bndCond[i]->GetBoundaryConditionType() ==
484 for(j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
486 bndExp = bndCondExp[i]->GetExp(j);
487 id = bndExp->GetGeom()->GetGlobalID();
489 int meshId = meshTraceId.find(
id)->second;
495 traceOffset = traceElmtGid[meshId];
496 bndOffset = bndCondExp[i]->GetCoeff_Offset(j) + bndTotal;
499 for(k = 0; k < bndExp->GetNcoeffs(); ++k)
505 bndTotal += bndCondExp[i]->GetNcoeffs();
509 map<int,int> invLocToGloMap;
510 for(i = 0; i < nbndry; ++i)
529 locExp, tr,
m_elmtToTrace, bndCondExp, bndCond, periodicTrace));
541 for (
int i = 0; i < nGraphVerts; i++)
543 vwgts_perm[i] = vwgts[perm[i]];
546 bottomUpGraph->ExpandGraphWithVertexWeights(vwgts_perm);
584 for(i = 0; i < locExpVector.size(); ++i)
586 locExpansion = locExpVector[i];
587 nDim = locExpansion->GetShapeDimension();
592 maxDof = (1 > maxDof ? 1 : maxDof);
596 for (j = 0; j < locExpansion->GetNtraces(); ++j)
598 dof = locExpansion->GetTraceNcoeffs(j);
599 maxDof = (dof > maxDof ? dof : maxDof);
607 for(i = 0; i < locExpVector.size(); ++i)
609 locExpansion = locExpVector[i];
610 nDim = locExpansion->GetShapeDimension();
615 int nverts = locExpansion->GetNverts();
616 for(j = 0; j < nverts; ++j)
620 id = locPointExp->
GetGeom()->GetGlobalID();
623 =
id * maxDof + j + 1;
629 for(j = 0; j < locExpansion->GetNtraces(); ++j)
634 id = locSegExp->
GetGeom()->GetGlobalID();
635 order_e = locExpansion->GetTraceNcoeffs(j);
637 map<int,int> orientMap;
641 locExpansion->GetTraceToElementMap(j, map1, sign1,
643 locExpansion->GetTraceToElementMap(j, map2, sign2,
644 locExpansion->GetTraceOrient(j));
646 for (k = 0; k < map1.size(); ++k)
651 for (
int l = 0; l < map2.size(); ++l)
653 if (map1[k] == map2[l])
660 ASSERTL2(idx != -1,
"Problem with face to"
665 for(k = 0; k < order_e; ++k)
669 =
id * maxDof + orientMap[k] + 1;
676 for(j = 0; j < locExpansion->GetNtraces(); ++j)
682 id = locFaceExp->
GetGeom()->GetGlobalID();
683 order_e = locExpansion->GetTraceNcoeffs(j);
685 map<int,int> orientMap;
689 locExpansion->GetTraceToElementMap(j, map1, sign1,
691 locExpansion->GetTraceToElementMap(j, map2, sign2,
692 locExpansion->GetTraceOrient(j));
694 for (k = 0; k < map1.size(); ++k)
699 for (
int l = 0; l < map2.size(); ++l)
701 if (map1[k] == map2[l])
708 ASSERTL2(idx != -1,
"Problem with face to "
713 for(k = 0; k < order_e; ++k)
717 =
id * maxDof + orientMap[k] + 1;
746 ASSERTL1(nquad2 == 0,
"nquad2 != 0 for reorienation");
747 for (
int i = 0; i < nquad1/2; ++i)
749 swap(toAlign[i], toAlign[nquad1-1-i]);
754 ASSERTL1(nquad2 != 0,
"nquad2 == 0 for reorienation");
764 for (
int i = 0; i < nquad2; ++i)
766 for (
int j = 0; j < nquad1; ++j)
768 tmp[i*nquad1 + j] = toAlign[j*nquad2 + i];
774 for (
int i = 0; i < nquad2; ++i)
776 for (
int j = 0; j < nquad1; ++j)
778 tmp[i*nquad1 + j] = toAlign[i*nquad1 + j];
789 for (
int i = 0; i < nquad2; ++i)
791 for (
int j = 0; j < nquad1/2; ++j)
793 swap(tmp[i*nquad1 + j],
794 tmp[i*nquad1 + nquad1-j-1]);
805 for (
int j = 0; j < nquad1; ++j)
807 for (
int i = 0; i < nquad2/2; ++i)
809 swap(tmp[i*nquad1 + j],
810 tmp[(nquad2-i-1)*nquad1 + j]);
916 "i is out of range");
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
SpatialDomains::GeometrySharedPtr GetGeom() const
const SpatialDomains::PointGeomSharedPtr GetGeom() const
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Array< OneD, Array< OneD, LocalRegions::ExpansionSharedPtr > > m_elmtToTrace
list of edge expansions for a given element
virtual void v_GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique()
static void RealignTraceElement(Array< OneD, int > &toAlign, StdRegions::Orientation orient, int nquad1, int nquad2=0)
AssemblyCommDGSharedPtr m_assemblyComm
Array< OneD, Array< OneD, LocalRegions::ExpansionSharedPtr > > & GetElmtToTrace()
virtual int v_GetFullSystemBandWidth() const
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMap()
AssemblyCommDGSharedPtr GetAssemblyCommDG()
virtual ~AssemblyMapDG()
Destructor.
int GetNumDirichletBndPhys()
Return the number of boundary segments on which Dirichlet boundary conditions are imposed.
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm=false) const
virtual void v_Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
void SetUpUniversalDGMap(const ExpList &locExp)
int m_numDirichletBndPhys
Number of physical dirichlet boundary values in trace.
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
AssemblyMapDG()
Default constructor.
virtual const Array< OneD, const int > & v_GetLocalToGlobalMap()
Base class for constructing local to global mapping of degrees of freedom.
int m_lowestStaticCondLevel
Lowest static condensation level.
GlobalSysSolnType m_solnType
The solution type of the global system.
int m_numLocalCoeffs
Total number of local coefficients.
Array< OneD, int > m_globalToUniversalBndMap
Integer map of process coeffs to universal space.
bool m_signChange
Flag indicating if modes require sign reversal.
void AssembleBnd(const NekVector< NekDouble > &loc, NekVector< NekDouble > &global, int offset) const
int m_numGlobalCoeffs
Total number of global coefficients.
Array< OneD, int > m_localToGlobalBndMap
Integer map of local coeffs to global Boundary Dofs.
void CalculateBndSystemBandWidth()
Calculates the bandwidth of the boundary system.
Array< OneD, unsigned int > m_numLocalBndCoeffsPerPatch
The number of bnd dofs per patch.
virtual const Array< OneD, NekDouble > & v_GetLocalToGlobalSign() const
int m_numLocalBndCoeffs
Number of local boundary coefficients.
AssemblyMapSharedPtr m_nextLevelLocalToGlobalMap
Map from the patches of the previous level to the patches of the current level.
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.
int m_numLocalDirBndCoeffs
Number of Local Dirichlet Boundary Coefficients.
int m_numGlobalDirBndCoeffs
Number of Global Dirichlet Boundary Coefficients.
Array< OneD, unsigned int > m_numLocalIntCoeffsPerPatch
The number of int dofs per patch.
int GetBndSystemBandWidth() const
Returns the bandwidth of the boundary system.
size_t m_hash
Hash for map.
Array< OneD, const NekDouble > GetLocalToGlobalBndSign() const
Retrieve the sign change for all local boundary modes.
LibUtilities::CommSharedPtr m_comm
Communicator.
Array< OneD, int > m_localToLocalBndMap
Integer map of local boundary coeffs to local boundary system numbering.
Array< OneD, int > m_globalToUniversalBndMapUnique
Integer map of unique process coeffs to universal space (signed)
void LocalBndToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, int offset, bool UseComm=true) const
void UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
int m_numPatches
The number of patches (~elements) in the current level.
Array< OneD, int > m_bndCondIDToGlobalTraceID
Integer map of bnd cond trace number to global trace number.
Array< OneD, int > m_bndCondCoeffsToLocalTraceMap
Integer map of bnd cond coeff to local trace coeff.
void GlobalToLocalBnd(const NekVector< NekDouble > &global, NekVector< NekDouble > &loc, int offset) const
int m_numGlobalBndCoeffs
Total number of global boundary coefficients.
Base class for all multi-elemental spectral/hp expansions.
const std::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Array< OneD, DataType > & GetPtr()
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.
static gs_data * Init(const Nektar::Array< OneD, long > pId, const LibUtilities::CommSharedPtr &pComm, bool verbose=true)
Initialise Gather-Scatter map.
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.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ eGauss_Lagrange
Lagrange Polynomials using the Gauss points .
@ eGLL_Lagrange
Lagrange for SEM basis .
@ eModified_A
Principle Modified Functions .
std::shared_ptr< SegExp > SegExpSharedPtr
std::shared_ptr< PointExp > PointExpSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< Expansion2D > Expansion2DSharedPtr
std::vector< ExpansionSharedPtr > ExpansionVector
void NoReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm)
@ eIterativeMultiLevelStaticCond
@ eDirectMultiLevelStaticCond
@ eXxtMultiLevelStaticCond
@ ePETScMultiLevelStaticCond
std::shared_ptr< AssemblyCommDG > AssemblyCommDGSharedPtr
void CuthillMckeeReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm)
void MultiLevelBisectionReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm, BottomUpSubStructuredGraphSharedPtr &substructgraph, std::set< int > partVerts, int mdswitch)
std::shared_ptr< BottomUpSubStructuredGraph > BottomUpSubStructuredGraphSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< Geometry > GeometrySharedPtr
@ eDir1BwdDir2_Dir2BwdDir1
@ eDir1FwdDir1_Dir2FwdDir2
@ eDir1BwdDir1_Dir2BwdDir2
@ eDir1BwdDir2_Dir2FwdDir1
@ eDir1FwdDir1_Dir2BwdDir2
@ eDir1BwdDir1_Dir2FwdDir2
@ eDir1FwdDir2_Dir2FwdDir1
@ eDir1FwdDir2_Dir2BwdDir1
The above copyright notice and this permission notice shall be included.
std::size_t hash_range(Iter first, Iter last)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)