44#include <boost/algorithm/string.hpp>
45#include <boost/config.hpp>
46#include <boost/graph/adjacency_list.hpp>
66 const PeriodicMap &periodicTrace,
const std::string variable)
69 int i, j, k, cnt, id, id1, gid;
71 int nTraceExp = trace->GetExpSize();
72 int nbnd = bndCondExp.size();
79 int nel = expList.size();
81 map<int, int> meshTraceId;
86 for (i = 0; i < nTraceExp; ++i)
88 meshTraceId[trace->GetExp(i)->GetGeom()->GetGlobalID()] = i;
93 for (i = 0; i < nel; ++i)
95 cnt += expList[i]->GetNtraces();
103 for (cnt = i = 0; i < nel; ++i)
108 for (j = 0; j < exp->GetNtraces(); ++j)
110 id = exp->GetGeom()->GetTid(j);
112 if (meshTraceId.count(
id) > 0)
115 trace->GetExp(meshTraceId.find(
id)->second);
119 ASSERTL0(
false,
"Failed to find trace map");
123 cnt += exp->GetNtraces();
128 for (i = 0; i < nbnd; ++i)
134 cnt += bndCondExp[i]->GetExpSize();
142 for (i = 0; i < bndCondExp.size(); ++i)
144 for (j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
146 bndExp = bndCondExp[i]->GetExp(j);
147 traceGeom = bndExp->GetGeom();
150 if (bndCond[i]->GetBoundaryConditionType() ==
169 for (i = 0; i < nel; ++i)
171 int BndCoeffs = expList[i]->NumDGBndryCoeffs();
190 typedef boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS>
193 BoostGraph boostGraphObj;
194 int trace_id, trace_id1;
199 for (i = 0; i < nTraceExp; ++i)
201 id = trace->GetExp(i)->GetGeom()->GetGlobalID();
203 if (dirTrace.count(
id) == 0)
207 boost::add_vertex(boostGraphObj);
208 traceElmtGid[i] = cnt++;
213 traceElmtGid[i] = dirOffset;
214 dirOffset += trace->GetExp(i)->GetNcoeffs();
220 for (i = 0; i < nel; ++i)
224 for (j = 0; j < exp->GetNtraces(); ++j)
229 trace_id = meshTraceId.find(
id)->second;
231 if (dirTrace.count(
id) == 0)
233 for (k = j + 1; k < exp->GetNtraces(); ++k)
237 trace_id1 = meshTraceId.find(id1)->second;
239 if (dirTrace.count(id1) == 0)
241 boost::add_edge((
size_t)traceElmtGid[trace_id],
242 (
size_t)traceElmtGid[trace_id1],
250 int nGraphVerts = nTraceExp - nDir;
256 for (i = 0; i < nGraphVerts; ++i)
258 vwgts[i] = trace->GetExp(i + nDir)->GetNcoeffs();
292 ASSERTL0(
false,
"Unrecognised solution type");
300 for (i = 0; i < nTraceExp - nDir; ++i)
302 traceElmtGid[perm[i] + nDir] = cnt;
303 cnt += trace->GetExp(perm[i] + nDir)->GetNcoeffs();
308 for (i = 0; i < nel; ++i)
312 for (j = 0; j < exp->GetNtraces(); ++j)
316 gid = traceElmtGid[meshTraceId.find(
id)->second];
318 const int nDim = exp->GetNumBases();
327 order_e = exp->GetTraceNcoeffs(j);
331 for (k = 0; k < order_e; ++k)
345 for (k = 2; k < order_e; ++k)
351 for (k = 3; k < order_e; k += 2)
360 for (k = 0; k < order_e; ++k)
370 for (k = 0; k < order_e; ++k)
379 ASSERTL0(
false,
"Boundary type not permitted");
386 order_e = exp->GetTraceNcoeffs(j);
388 std::map<int, int> orientMap;
399 exp->GetTraceToElementMap(j, elmMap1, elmSign1, fo);
400 exp->GetTraceToElementMap(j, elmMap2, elmSign2,
403 for (k = 0; k < elmMap1.size(); ++k)
408 for (
int l = 0; l < elmMap2.size(); ++l)
410 if (elmMap1[k] == elmMap2[l])
417 ASSERTL2(idx != -1,
"Problem with face to element map!");
421 for (k = 0; k < order_e; ++k)
449 int nrotperbndexp = 0;
455 for (i = 0; i < nbnd; ++i)
459 if (boost::icontains(bndCond[i]->GetUserDefined(),
"Rotated"))
461 nrotperbndexp += bndCondExp[i]->GetExpSize();
466 cnt += bndCondExp[i]->GetNcoeffs();
467 nbndexp += bndCondExp[i]->GetExpSize();
476 for (i = 0; i < bndCondExp.size(); ++i)
480 if (boost::icontains(bndCond[i]->GetUserDefined(),
"Rotated"))
483 for (j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
485 bndExp = bndCondExp[i]->GetExp(j);
486 id = bndExp->GetGeom()->GetGlobalID();
488 int meshId = meshTraceId.find(
id)->second;
495 for (j = 0; j < bndCondExp[i]->GetExpSize(); ++j)
497 bndExp = bndCondExp[i]->GetExp(j);
498 id = bndExp->GetGeom()->GetGlobalID();
500 int meshId = meshTraceId.find(
id)->second;
506 traceOffset = traceElmtGid[meshId];
507 bndOffset = bndCondExp[i]->GetCoeff_Offset(j) + bndTotal;
509 for (k = 0; k < bndExp->GetNcoeffs(); ++k)
514 bndTotal += bndCondExp[i]->GetNcoeffs();
518 map<int, int> invLocToGloMap;
519 for (i = 0; i < nbndry; ++i)
538 locExp, tr,
m_elmtToTrace, bndCondExp, bndCond, periodicTrace));
550 for (
int i = 0; i < nGraphVerts; i++)
552 vwgts_perm[i] = vwgts[perm[i]];
555 bottomUpGraph->ExpandGraphWithVertexWeights(vwgts_perm);
596 for (i = 0; i < locExpVector.size(); ++i)
598 locExpansion = locExpVector[i];
599 nDim = locExpansion->GetShapeDimension();
604 maxDof = (1 > maxDof ? 1 : maxDof);
608 for (j = 0; j < locExpansion->GetNtraces(); ++j)
610 dof = locExpansion->GetTraceNcoeffs(j);
611 maxDof = (dof > maxDof ? dof : maxDof);
619 for (i = 0; i < locExpVector.size(); ++i)
621 locExpansion = locExpVector[i];
622 nDim = locExpansion->GetShapeDimension();
627 int nverts = locExpansion->GetNverts();
628 for (j = 0; j < nverts; ++j)
640 for (j = 0; j < locExpansion->GetNtraces(); ++j)
646 order_e = locExpansion->GetTraceNcoeffs(j);
648 map<int, int> orientMap;
652 locExpansion->GetTraceToElementMap(j, map1, sign1,
654 locExpansion->GetTraceToElementMap(
655 j, map2, sign2, locExpansion->GetTraceOrient(j));
657 for (k = 0; k < map1.size(); ++k)
662 for (
int l = 0; l < map2.size(); ++l)
664 if (map1[k] == map2[l])
671 ASSERTL2(idx != -1,
"Problem with face to"
676 for (k = 0; k < order_e; ++k)
680 id * maxDof + orientMap[k] + 1;
687 for (j = 0; j < locExpansion->GetNtraces(); ++j)
693 order_e = locExpansion->GetTraceNcoeffs(j);
695 map<int, int> orientMap;
699 locExpansion->GetTraceToElementMap(
701 locExpansion->GetTraceToElementMap(
702 j, map2, sign2, locExpansion->GetTraceOrient(j));
704 for (k = 0; k < map1.size(); ++k)
709 for (
int l = 0; l < map2.size(); ++l)
711 if (map1[k] == map2[l])
718 ASSERTL2(idx != -1,
"Problem with face to "
723 for (k = 0; k < order_e; ++k)
727 id * maxDof + orientMap[k] + 1;
741 bool verbose =
m_comm->IsParallelInTime()
742 ?
m_comm->GetTimeComm()->GetRank() == 0
755 int nquad1,
int nquad2)
759 ASSERTL1(nquad2 == 0,
"nquad2 != 0 for reorienation");
760 for (
int i = 0; i < nquad1 / 2; ++i)
762 swap(toAlign[i], toAlign[nquad1 - 1 - i]);
767 ASSERTL1(nquad2 != 0,
"nquad2 == 0 for reorienation");
777 for (
int i = 0; i < nquad2; ++i)
779 for (
int j = 0; j < nquad1; ++j)
781 tmp[i * nquad1 + j] = toAlign[j * nquad2 + i];
787 for (
int i = 0; i < nquad2; ++i)
789 for (
int j = 0; j < nquad1; ++j)
791 tmp[i * nquad1 + j] = toAlign[i * nquad1 + j];
802 for (
int i = 0; i < nquad2; ++i)
804 for (
int j = 0; j < nquad1 / 2; ++j)
806 swap(tmp[i * nquad1 + j], tmp[i * nquad1 + nquad1 - j - 1]);
817 for (
int j = 0; j < nquad1; ++j)
819 for (
int i = 0; i < nquad2 / 2; ++i)
821 swap(tmp[i * nquad1 + j],
822 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.
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)