44 #include <boost/config.hpp>
45 #include <boost/core/ignore_unused.hpp>
46 #include <boost/graph/adjacency_list.hpp>
52 namespace MultiRegions
54 AssemblyMapDG::AssemblyMapDG() : m_numDirichletBndPhys(0)
68 const PeriodicMap &periodicTrace,
const std::string variable)
71 boost::ignore_unused(graph);
73 int i, j, k, cnt, id, id1, gid;
75 int nTraceExp = trace->GetExpSize();
76 int nbnd = bndCondExp.size();
83 int nel = expList.size();
85 map<int, int> meshTraceId;
90 for (i = 0; i < nTraceExp; ++i)
92 meshTraceId[trace->GetExp(i)->GetGeom()->GetGlobalID()] = i;
97 for (i = 0; i < nel; ++i)
99 cnt += expList[i]->GetNtraces();
107 for (cnt = i = 0; i < nel; ++i)
112 for (j = 0; j < exp->GetNtraces(); ++j)
114 id = exp->GetGeom()->GetTid(j);
116 if (meshTraceId.count(
id) > 0)
119 trace->GetExp(meshTraceId.find(
id)->second);
123 ASSERTL0(
false,
"Failed to find trace map");
127 cnt += exp->GetNtraces();
132 for (i = 0; i < nbnd; ++i)
138 cnt += bndCondExp[i]->GetExpSize();
146 for (i = 0; i < bndCondExp.size(); ++i)
148 for (j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
150 bndExp = bndCondExp[i]->GetExp(j);
151 traceGeom = bndExp->GetGeom();
152 id = traceGeom->GetGlobalID();
154 if (bndCond[i]->GetBoundaryConditionType() ==
173 for (i = 0; i < nel; ++i)
175 int BndCoeffs = expList[i]->NumDGBndryCoeffs();
194 typedef boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS>
197 BoostGraph boostGraphObj;
198 int trace_id, trace_id1;
203 for (i = 0; i < nTraceExp; ++i)
205 id = trace->GetExp(i)->GetGeom()->GetGlobalID();
207 if (dirTrace.count(
id) == 0)
211 boost::add_vertex(boostGraphObj);
212 traceElmtGid[i] = cnt++;
217 traceElmtGid[i] = dirOffset;
218 dirOffset += trace->GetExp(i)->GetNcoeffs();
224 for (i = 0; i < nel; ++i)
228 for (j = 0; j < exp->GetNtraces(); ++j)
232 id = traceGeom->GetGlobalID();
233 trace_id = meshTraceId.find(
id)->second;
235 if (dirTrace.count(
id) == 0)
237 for (k = j + 1; k < exp->GetNtraces(); ++k)
240 id1 = traceGeom->GetGlobalID();
241 trace_id1 = meshTraceId.find(id1)->second;
243 if (dirTrace.count(id1) == 0)
245 boost::add_edge((
size_t)traceElmtGid[trace_id],
246 (
size_t)traceElmtGid[trace_id1],
254 int nGraphVerts = nTraceExp - nDir;
260 for (i = 0; i < nGraphVerts; ++i)
262 vwgts[i] = trace->GetExp(i + nDir)->GetNcoeffs();
296 ASSERTL0(
false,
"Unrecognised solution type");
304 for (i = 0; i < nTraceExp - nDir; ++i)
306 traceElmtGid[perm[i] + nDir] = cnt;
307 cnt += trace->GetExp(perm[i] + nDir)->GetNcoeffs();
312 for (i = 0; i < nel; ++i)
316 for (j = 0; j < exp->GetNtraces(); ++j)
319 id = traceGeom->GetGlobalID();
320 gid = traceElmtGid[meshTraceId.find(
id)->second];
322 const int nDim = exp->GetNumBases();
331 order_e = exp->GetTraceNcoeffs(j);
335 for (k = 0; k < order_e; ++k)
349 for (k = 2; k < order_e; ++k)
355 for (k = 3; k < order_e; k += 2)
364 for (k = 0; k < order_e; ++k)
374 for (k = 0; k < order_e; ++k)
383 ASSERTL0(
false,
"Boundary type not permitted");
390 order_e = exp->GetTraceNcoeffs(j);
392 std::map<int, int> orientMap;
403 exp->GetTraceToElementMap(j, elmMap1, elmSign1, fo);
404 exp->GetTraceToElementMap(j, elmMap2, elmSign2,
407 for (k = 0; k < elmMap1.size(); ++k)
412 for (
int l = 0; l < elmMap2.size(); ++l)
414 if (elmMap1[k] == elmMap2[l])
421 ASSERTL2(idx != -1,
"Problem with face to element map!");
425 for (k = 0; k < order_e; ++k)
458 for (i = 0; i < nbnd; ++i)
464 cnt += bndCondExp[i]->GetNcoeffs();
465 nbndexp += bndCondExp[i]->GetExpSize();
472 for (i = 0; i < bndCondExp.size(); ++i)
479 for (j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
481 bndExp = bndCondExp[i]->GetExp(j);
482 id = bndExp->GetGeom()->GetGlobalID();
484 int meshId = meshTraceId.find(
id)->second;
490 traceOffset = traceElmtGid[meshId];
491 bndOffset = bndCondExp[i]->GetCoeff_Offset(j) + bndTotal;
493 for (k = 0; k < bndExp->GetNcoeffs(); ++k)
498 bndTotal += bndCondExp[i]->GetNcoeffs();
502 map<int, int> invLocToGloMap;
503 for (i = 0; i < nbndry; ++i)
522 locExp, tr,
m_elmtToTrace, bndCondExp, bndCond, periodicTrace));
534 for (
int i = 0; i < nGraphVerts; i++)
536 vwgts_perm[i] = vwgts[perm[i]];
539 bottomUpGraph->ExpandGraphWithVertexWeights(vwgts_perm);
580 for (i = 0; i < locExpVector.size(); ++i)
582 locExpansion = locExpVector[i];
583 nDim = locExpansion->GetShapeDimension();
588 maxDof = (1 > maxDof ? 1 : maxDof);
592 for (j = 0; j < locExpansion->GetNtraces(); ++j)
594 dof = locExpansion->GetTraceNcoeffs(j);
595 maxDof = (dof > maxDof ? dof : maxDof);
603 for (i = 0; i < locExpVector.size(); ++i)
605 locExpansion = locExpVector[i];
606 nDim = locExpansion->GetShapeDimension();
611 int nverts = locExpansion->GetNverts();
612 for (j = 0; j < nverts; ++j)
616 id = locPointExp->
GetGeom()->GetGlobalID();
624 for (j = 0; j < locExpansion->GetNtraces(); ++j)
629 id = locSegExp->
GetGeom()->GetGlobalID();
630 order_e = locExpansion->GetTraceNcoeffs(j);
632 map<int, int> orientMap;
636 locExpansion->GetTraceToElementMap(j, map1, sign1,
638 locExpansion->GetTraceToElementMap(
639 j, map2, sign2, locExpansion->GetTraceOrient(j));
641 for (k = 0; k < map1.size(); ++k)
646 for (
int l = 0; l < map2.size(); ++l)
648 if (map1[k] == map2[l])
655 ASSERTL2(idx != -1,
"Problem with face to"
660 for (k = 0; k < order_e; ++k)
664 id * maxDof + orientMap[k] + 1;
671 for (j = 0; j < locExpansion->GetNtraces(); ++j)
676 id = locFaceExp->
GetGeom()->GetGlobalID();
677 order_e = locExpansion->GetTraceNcoeffs(j);
679 map<int, int> orientMap;
683 locExpansion->GetTraceToElementMap(
685 locExpansion->GetTraceToElementMap(
686 j, map2, sign2, locExpansion->GetTraceOrient(j));
688 for (k = 0; k < map1.size(); ++k)
693 for (
int l = 0; l < map2.size(); ++l)
695 if (map1[k] == map2[l])
702 ASSERTL2(idx != -1,
"Problem with face to "
707 for (k = 0; k < order_e; ++k)
711 id * maxDof + orientMap[k] + 1;
734 int nquad1,
int nquad2)
738 ASSERTL1(nquad2 == 0,
"nquad2 != 0 for reorienation");
739 for (
int i = 0; i < nquad1 / 2; ++i)
741 swap(toAlign[i], toAlign[nquad1 - 1 - i]);
746 ASSERTL1(nquad2 != 0,
"nquad2 == 0 for reorienation");
756 for (
int i = 0; i < nquad2; ++i)
758 for (
int j = 0; j < nquad1; ++j)
760 tmp[i * nquad1 + j] = toAlign[j * nquad2 + i];
766 for (
int i = 0; i < nquad2; ++i)
768 for (
int j = 0; j < nquad1; ++j)
770 tmp[i * nquad1 + j] = toAlign[i * nquad1 + j];
781 for (
int i = 0; i < nquad2; ++i)
783 for (
int j = 0; j < nquad1 / 2; ++j)
785 swap(tmp[i * nquad1 + j], tmp[i * nquad1 + nquad1 - j - 1]);
796 for (
int j = 0; j < nquad1; ++j)
798 for (
int i = 0; i < nquad2 / 2; ++i)
800 swap(tmp[i * nquad1 + j],
801 tmp[(nquad2 - i - 1) * nquad1 + j]);
#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 const Array< OneD, const int > & v_GetGlobalToUniversalMap() override
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm=false) const override
virtual void v_GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const override
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 const Array< OneD, const int > & v_GetLocalToGlobalMap() override
AssemblyCommDGSharedPtr GetAssemblyCommDG()
virtual ~AssemblyMapDG()
Destructor.
int GetNumDirichletBndPhys()
Return the number of boundary segments on which Dirichlet boundary conditions are imposed.
virtual void v_Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const override
void SetUpUniversalDGMap(const ExpList &locExp)
int m_numDirichletBndPhys
Number of physical dirichlet boundary values in trace.
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique() override
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const override
virtual int v_GetFullSystemBandWidth() const override
AssemblyMapDG()
Default constructor.
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_bndCondCoeffsToLocalTraceMap
Integer map of bnd cond coeff to local trace coeff.
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_globalToUniversalBndMap
Integer map of process coeffs to universal space.
void CalculateBndSystemBandWidth()
Calculates the bandwidth of the boundary system.
Array< OneD, NekDouble > m_localToGlobalBndSign
Integer sign of local boundary coeffs to global space.
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.
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.
Array< OneD, int > m_localToGlobalBndMap
Integer map of local coeffs to global Boundary Dofs.
size_t m_hash
Hash for map.
Array< OneD, const NekDouble > GetLocalToGlobalBndSign() const
Retrieve the sign change for all local boundary modes.
Array< OneD, int > m_globalToUniversalBndMapUnique
Integer map of unique process coeffs to universal space (signed)
LibUtilities::CommSharedPtr m_comm
Communicator.
Array< OneD, int > m_localToLocalBndMap
Integer map of local boundary coeffs to local boundary system numbering.
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.
void GlobalToLocalBnd(const NekVector< NekDouble > &global, NekVector< NekDouble > &loc, int offset) const
int m_numGlobalBndCoeffs
Total number of global boundary coefficients.
Array< OneD, int > m_bndCondIDToGlobalTraceID
Integer map of bnd cond trace number to global trace number.
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)