44#include <boost/algorithm/string.hpp>
45#include <boost/config.hpp>
46#include <boost/graph/adjacency_list.hpp>
67 const PeriodicMap &periodicTrace,
const std::string variable)
70 int i, j, k, cnt, id, id1, gid;
72 int nTraceExp = trace->GetExpSize();
73 int nbnd = bndCondExp.size();
80 int nel = expList.size();
82 map<int, int> meshTraceId;
87 for (i = 0; i < nTraceExp; ++i)
89 meshTraceId[trace->GetExp(i)->GetGeom()->GetGlobalID()] = i;
94 for (i = 0; i < nel; ++i)
96 cnt += expList[i]->GetNtraces();
104 for (cnt = i = 0; i < nel; ++i)
109 for (j = 0; j < exp->GetNtraces(); ++j)
111 id = exp->GetGeom()->GetTid(j);
113 if (meshTraceId.count(
id) > 0)
116 trace->GetExp(meshTraceId.find(
id)->second);
120 ASSERTL0(
false,
"Failed to find trace map");
124 cnt += exp->GetNtraces();
129 for (i = 0; i < nbnd; ++i)
135 cnt += bndCondExp[i]->GetExpSize();
143 for (i = 0; i < bndCondExp.size(); ++i)
145 for (j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
147 bndExp = bndCondExp[i]->GetExp(j);
148 traceGeom = bndExp->GetGeom();
151 if (bndCond[i]->GetBoundaryConditionType() ==
170 for (i = 0; i < nel; ++i)
172 int BndCoeffs = expList[i]->NumDGBndryCoeffs();
191 typedef boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS>
194 BoostGraph boostGraphObj;
195 int trace_id, trace_id1;
200 for (i = 0; i < nTraceExp; ++i)
202 id = trace->GetExp(i)->GetGeom()->GetGlobalID();
204 if (dirTrace.count(
id) == 0)
208 boost::add_vertex(boostGraphObj);
209 traceElmtGid[i] = cnt++;
214 traceElmtGid[i] = dirOffset;
215 dirOffset += trace->GetExp(i)->GetNcoeffs();
221 for (i = 0; i < nel; ++i)
225 for (j = 0; j < exp->GetNtraces(); ++j)
230 trace_id = meshTraceId.find(
id)->second;
232 if (dirTrace.count(
id) == 0)
234 for (k = j + 1; k < exp->GetNtraces(); ++k)
238 trace_id1 = meshTraceId.find(id1)->second;
240 if (dirTrace.count(id1) == 0)
242 boost::add_edge((
size_t)traceElmtGid[trace_id],
243 (
size_t)traceElmtGid[trace_id1],
251 int nGraphVerts = nTraceExp - nDir;
257 for (i = 0; i < nGraphVerts; ++i)
259 vwgts[i] = trace->GetExp(i + nDir)->GetNcoeffs();
293 ASSERTL0(
false,
"Unrecognised solution type");
301 for (i = 0; i < nTraceExp - nDir; ++i)
303 traceElmtGid[perm[i] + nDir] = cnt;
304 cnt += trace->GetExp(perm[i] + nDir)->GetNcoeffs();
309 for (i = 0; i < nel; ++i)
313 for (j = 0; j < exp->GetNtraces(); ++j)
317 gid = traceElmtGid[meshTraceId.find(
id)->second];
319 const int nDim = exp->GetNumBases();
328 order_e = exp->GetTraceNcoeffs(j);
332 for (k = 0; k < order_e; ++k)
346 for (k = 2; k < order_e; ++k)
352 for (k = 3; k < order_e; k += 2)
361 for (k = 0; k < order_e; ++k)
371 for (k = 0; k < order_e; ++k)
380 ASSERTL0(
false,
"Boundary type not permitted");
387 order_e = exp->GetTraceNcoeffs(j);
389 std::map<int, int> orientMap;
400 exp->GetTraceToElementMap(j, elmMap1, elmSign1, fo);
401 exp->GetTraceToElementMap(j, elmMap2, elmSign2,
404 for (k = 0; k < elmMap1.size(); ++k)
409 for (
int l = 0; l < elmMap2.size(); ++l)
411 if (elmMap1[k] == elmMap2[l])
418 ASSERTL2(idx != -1,
"Problem with face to element map!");
422 for (k = 0; k < order_e; ++k)
450 int nrotperbndexp = 0;
456 for (i = 0; i < nbnd; ++i)
460 if (boost::icontains(bndCond[i]->GetUserDefined(),
"Rotated"))
462 nrotperbndexp += bndCondExp[i]->GetExpSize();
467 cnt += bndCondExp[i]->GetNcoeffs();
468 nbndexp += bndCondExp[i]->GetExpSize();
477 for (i = 0; i < bndCondExp.size(); ++i)
481 if (boost::icontains(bndCond[i]->GetUserDefined(),
"Rotated"))
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;
496 for (j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
498 bndExp = bndCondExp[i]->GetExp(j);
499 id = bndExp->GetGeom()->GetGlobalID();
501 int meshId = meshTraceId.find(
id)->second;
507 traceOffset = traceElmtGid[meshId];
508 bndOffset = bndCondExp[i]->GetCoeff_Offset(j) + bndTotal;
510 for (k = 0; k < bndExp->GetNcoeffs(); ++k)
515 bndTotal += bndCondExp[i]->GetNcoeffs();
519 map<int, int> invLocToGloMap;
520 for (i = 0; i < nbndry; ++i)
539 locExp, tr,
m_elmtToTrace, bndCondExp, bndCond, periodicTrace));
551 for (
int i = 0; i < nGraphVerts; i++)
553 vwgts_perm[i] = vwgts[perm[i]];
556 bottomUpGraph->ExpandGraphWithVertexWeights(vwgts_perm);
597 for (i = 0; i < locExpVector.size(); ++i)
599 locExpansion = locExpVector[i];
600 nDim = locExpansion->GetShapeDimension();
605 maxDof = (1 > maxDof ? 1 : maxDof);
609 for (j = 0; j < locExpansion->GetNtraces(); ++j)
611 dof = locExpansion->GetTraceNcoeffs(j);
612 maxDof = (dof > maxDof ? dof : maxDof);
620 for (i = 0; i < locExpVector.size(); ++i)
622 locExpansion = locExpVector[i];
623 nDim = locExpansion->GetShapeDimension();
628 int nverts = locExpansion->GetNverts();
629 for (j = 0; j < nverts; ++j)
641 for (j = 0; j < locExpansion->GetNtraces(); ++j)
647 order_e = locExpansion->GetTraceNcoeffs(j);
649 map<int, int> orientMap;
653 locExpansion->GetTraceToElementMap(j, map1, sign1,
655 locExpansion->GetTraceToElementMap(
656 j, map2, sign2, locExpansion->GetTraceOrient(j));
658 for (k = 0; k < map1.size(); ++k)
663 for (
int l = 0; l < map2.size(); ++l)
665 if (map1[k] == map2[l])
672 ASSERTL2(idx != -1,
"Problem with face to"
677 for (k = 0; k < order_e; ++k)
681 id * maxDof + orientMap[k] + 1;
688 for (j = 0; j < locExpansion->GetNtraces(); ++j)
694 order_e = locExpansion->GetTraceNcoeffs(j);
696 map<int, int> orientMap;
700 locExpansion->GetTraceToElementMap(
702 locExpansion->GetTraceToElementMap(
703 j, map2, sign2, locExpansion->GetTraceOrient(j));
705 for (k = 0; k < map1.size(); ++k)
710 for (
int l = 0; l < map2.size(); ++l)
712 if (map1[k] == map2[l])
719 ASSERTL2(idx != -1,
"Problem with face to "
724 for (k = 0; k < order_e; ++k)
728 id * maxDof + orientMap[k] + 1;
742 bool verbose =
m_comm->IsParallelInTime()
743 ?
m_comm->GetTimeComm()->GetRank() == 0
756 int nquad1,
int nquad2)
760 ASSERTL1(nquad2 == 0,
"nquad2 != 0 for reorienation");
761 for (
int i = 0; i < nquad1 / 2; ++i)
763 swap(toAlign[i], toAlign[nquad1 - 1 - i]);
768 ASSERTL1(nquad2 != 0,
"nquad2 == 0 for reorienation");
778 for (
int i = 0; i < nquad2; ++i)
780 for (
int j = 0; j < nquad1; ++j)
782 tmp[i * nquad1 + j] = toAlign[j * nquad2 + i];
788 for (
int i = 0; i < nquad2; ++i)
790 for (
int j = 0; j < nquad1; ++j)
792 tmp[i * nquad1 + j] = toAlign[i * nquad1 + j];
803 for (
int i = 0; i < nquad2; ++i)
805 for (
int j = 0; j < nquad1 / 2; ++j)
807 swap(tmp[i * nquad1 + j], tmp[i * nquad1 + nquad1 - j - 1]);
818 for (
int j = 0; j < nquad1; ++j)
820 for (
int i = 0; i < nquad2 / 2; ++i)
822 swap(tmp[i * nquad1 + j],
823 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::Geometry * GetGeom() const
const SpatialDomains::PointGeom * 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
const Array< OneD, const int > & v_GetGlobalToUniversalMap() override
void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm=false) const override
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()
const Array< OneD, const int > & v_GetLocalToGlobalMap() override
AssemblyCommDGSharedPtr GetAssemblyCommDG()
const Array< OneD, NekDouble > & v_GetLocalToGlobalSign() const override
int GetNumDirichletBndPhys()
Return the number of boundary segments on which Dirichlet boundary conditions are imposed.
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.
const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique() override
void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const override
int v_GetFullSystemBandWidth() const override
~AssemblyMapDG() override
Destructor.
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.
Array< OneD, int > m_perbndCondIDToGlobalTraceID
Integer map of rotational periodic bnd cond trace number to global trace number.
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.
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
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
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.
Base class for shape geometry information.
int GetGlobalID(void) const
Get the ID of this object.
static gs_data * Init(const Nektar::Array< OneD, long > &pId, const LibUtilities::CommSharedPtr &pComm, bool verbose=true)
Initialise Gather-Scatter map.
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 void Unique(const Nektar::Array< OneD, long > &pId, const LibUtilities::CommSharedPtr &pComm)
Updates pId to negate all-but-one references to each universal ID.
static void Finalise(gs_data *pGsh)
Deallocates the GSLib mapping data.
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
@ eDir1BwdDir2_Dir2BwdDir1
@ eDir1FwdDir1_Dir2FwdDir2
@ eDir1BwdDir1_Dir2BwdDir2
@ eDir1BwdDir2_Dir2FwdDir1
@ eDir1FwdDir1_Dir2BwdDir2
@ eDir1BwdDir1_Dir2FwdDir2
@ eDir1FwdDir2_Dir2FwdDir1
@ eDir1FwdDir2_Dir2BwdDir1
std::size_t hash_range(Iter first, Iter last)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)