40 namespace MultiRegions
57 return int(x > 0.0 ? x + 0.5 : x - 0.5);
63 int size = inarray.num_elements();
64 ASSERTL1(outarray.num_elements()>=size,
"Array sizes not compatible");
67 for(
int i = 0; i < size; i++)
70 outarray[i] = int(x > 0.0 ? x + 0.5 : x - 0.5);
81 m_numLocalBndCoeffs(0),
82 m_numGlobalBndCoeffs(0),
83 m_numLocalDirBndCoeffs(0),
84 m_numGlobalDirBndCoeffs(0),
86 m_bndSystemBandWidth(0),
95 const std::string variable):
97 m_comm(pSession->GetComm()),
99 m_numLocalBndCoeffs(0),
100 m_numGlobalBndCoeffs(0),
101 m_numLocalDirBndCoeffs(0),
102 m_numGlobalDirBndCoeffs(0),
103 m_bndSystemBandWidth(0),
115 if(pSession->DefinesGlobalSysSolnInfo(variable,
"GlobalSysSoln"))
117 std::string sysSoln = pSession->GetGlobalSysSolnInfo(variable,
120 "GlobalSysSoln", sysSoln);
123 if(pSession->DefinesGlobalSysSolnInfo(variable,
"Preconditioner"))
125 std::string precon = pSession->GetGlobalSysSolnInfo(variable,
128 "Preconditioner", precon);
131 if(pSession->DefinesGlobalSysSolnInfo(variable,
132 "IterativeSolverTolerance"))
135 pSession->GetGlobalSysSolnInfo(variable,
136 "IterativeSolverTolerance").c_str());
140 pSession->LoadParameter(
"IterativeSolverTolerance",
146 if(pSession->DefinesGlobalSysSolnInfo(variable,
"SuccessiveRHS"))
149 pSession->GetGlobalSysSolnInfo(variable,
150 "SuccessiveRHS").c_str());
154 pSession->LoadParameter(
"SuccessiveRHS",
167 m_session(oldLevelMap->m_session),
168 m_comm(oldLevelMap->GetComm()),
170 m_solnType(oldLevelMap->m_solnType),
171 m_preconType(oldLevelMap->m_preconType),
172 m_iterativeTolerance(oldLevelMap->m_iterativeTolerance),
173 m_successiveRHS(oldLevelMap->m_successiveRHS),
174 m_gsh(oldLevelMap->m_gsh),
175 m_bndGsh(oldLevelMap->m_bndGsh),
176 m_lowestStaticCondLevel(oldLevelMap->m_lowestStaticCondLevel)
197 int newLevel = staticCondLevelOld+1;
218 multiLevelGraph->MaskPatches(newLevel,globHomPatchMask);
237 int numPatchesWithIntNew = multiLevelGraph->GetNpatchesWithInterior(newLevel);
238 int numPatchesNew = numPatchesWithIntNew;
242 map<int, int> numLocalBndCoeffsPerPatchNew;
243 for(
int i = 0; i < numPatchesNew; i++)
245 numLocalBndCoeffsPerPatchNew[i] = 0;
251 for(i = cnt = 0; i < numPatchesOld; i++)
264 minval = *min_element(&locPatchMask[cnt],
265 &locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
266 maxval = *max_element(&locPatchMask[cnt],
267 &locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
268 ASSERTL0((minval==maxval)||(minval==-1),
"These values should never be the same");
272 curPatch = numPatchesNew;
273 numLocalBndCoeffsPerPatchNew[curPatch] = 0;
281 for(j = 0; j < numLocalBndCoeffsPerPatchOld[i]; j++ )
283 ASSERTL0((locPatchMask[cnt]==maxval)||(locPatchMask[cnt]==minval),
284 "These values should never be the same");
285 if(locPatchMask[cnt] == -1)
287 ++numLocalBndCoeffsPerPatchNew[curPatch];
304 multiLevelGraph->GetNintDofsPerPatch(newLevel,m_numLocalIntCoeffsPerPatch);
312 "This method should only be called for in "
313 "case of multi-level static condensation.");
338 for(
int i = 1; i < m_numPatches+1; i++)
340 numLocalBndCoeffsPerPatchOffset[i] += numLocalBndCoeffsPerPatchOffset[i-1] + numLocalBndCoeffsPerPatchNew[i-1];
343 int additionalPatchCnt = numPatchesWithIntNew;
349 for(i = cnt = 0; i < numPatchesOld; i++)
351 minval = *min_element(&locPatchMask[cnt],&locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
352 maxval = *max_element(&locPatchMask[cnt],&locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
353 ASSERTL0((minval==maxval)||(minval==-1),
"These values should never be the same");
357 curPatch = additionalPatchCnt;
358 additionalPatchCnt++;
365 for(j = 0; j < numLocalBndCoeffsPerPatchOld[i]; j++ )
367 ASSERTL0((locPatchMask[cnt]==maxval)||(locPatchMask[cnt]==minval),
368 "These values should never be the same");
372 if(locPatchMask[cnt] == -1)
374 newid = numLocalBndCoeffsPerPatchOffset[curPatch];
382 blockid = bndDofPerPatchCnt[curPatch];
386 numLocalBndCoeffsPerPatchOffset[curPatch]++;
387 bndDofPerPatchCnt[curPatch]++;
399 sign = isBndDof?1.0:
sign;
451 for(j = 0; j < locSize; j++)
466 bwidth = (bwidth>(maxId-minId))?bwidth:(maxId-minId);
477 ASSERTL0(
false,
"Not defined for this type of mapping.");
483 ASSERTL0(
false,
"Not defined for this type of mapping.");
489 ASSERTL0(
false,
"Not defined for this type of mapping.");
495 ASSERTL0(
false,
"Not defined for this type of mapping.");
502 ASSERTL0(
false,
"Not defined for this type of mapping.");
509 ASSERTL0(
false,
"Not defined for this type of mapping.");
516 ASSERTL0(
false,
"Not defined for this type of mapping.");
522 ASSERTL0(
false,
"Not defined for this type of mapping.");
531 ASSERTL0(
false,
"Not defined for this type of mapping.");
538 ASSERTL0(
false,
"Not defined for this type of mapping.");
545 ASSERTL0(
false,
"Not defined for this type of mapping.");
552 ASSERTL0(
false,
"Not defined for this type of mapping.");
559 ASSERTL0(
false,
"Not defined for this type of mapping.");
566 ASSERTL0(
false,
"Not defined for this type of mapping.");
593 ASSERTL0(
false,
"Not defined for this type of mapping.");
599 ASSERTL0(
false,
"Not defined for this type of mapping.");
605 ASSERTL0(
false,
"Not defined for this type of mapping.");
611 ASSERTL0(
false,
"Not defined for this type of mapping.");
617 ASSERTL0(
false,
"Not defined for this type of mapping.");
623 ASSERTL0(
false,
"Not defined for this type of mapping.");
629 ASSERTL0(
false,
"Not defined for this type of mapping.");
635 ASSERTL0(
false,
"Not defined for this type of mapping.");
641 ASSERTL0(
false,
"Not defined for this type of mapping.");
649 ASSERTL0(
false,
"Not defined for this sub class");
650 static boost::shared_ptr<AssemblyMap> result;
872 "Index out of range.");
879 return m_bndCondTraceToGlobalTraceMap;
1129 if (offset > 0)
Vmath::Vcopy(offset, pGlobal, 1, tmp, 1);
1131 if (offset > 0)
Vmath::Vcopy(offset, tmp, 1, pGlobal, 1);
1212 std::ostream &out, std::string variable)
const
1216 bool isRoot = vRowComm->GetRank() == 0;
1217 int n = vRowComm->GetSize();
1221 int globBndCnt = 0, globDirCnt = 0;
1245 int totGlobDof = globCnt;
1246 int totGlobBndDof = globBndCnt;
1247 int totGlobDirDof = globDirCnt;
1252 int meanValence = 0;
1254 int minValence = 10000000;
1262 if (tmpGlob[i] > maxValence)
1264 maxValence = tmpGlob[i];
1266 if (tmpGlob[i] < minValence)
1268 minValence = tmpGlob[i];
1270 meanValence += tmpGlob[i];
1283 meanValence /= totGlobBndDof;
1287 out <<
"Assembly map statistics for field " << variable <<
":"
1289 out <<
" - Number of local/global dof : "
1290 << totLocalDof <<
" " << totGlobDof << endl;
1291 out <<
" - Number of local/global boundary dof : "
1292 << totLocalBndDof <<
" " << totGlobBndDof << endl;
1293 out <<
" - Number of local/global Dirichlet dof : "
1294 << totLocalDirDof <<
" " << totGlobDirDof << endl;
1295 out <<
" - dof valency (min/max/mean) : "
1296 << minValence <<
" " << maxValence <<
" " << meanValence
1305 for (i = 1; i < n; ++i)
1307 vRowComm->Recv(i, tmp);
1309 mean2 += tmp[0]*tmp[0];
1311 if (tmp[0] > maxval)
1315 if (tmp[0] < minval)
1321 out <<
" - Local dof dist. (min/max/mean/dev) : "
1322 << minval <<
" " << maxval <<
" " << (mean / n) <<
" "
1323 << sqrt(mean2/n - mean*mean/n/n) << endl;
1328 mean2 = mean * mean;
1330 for (i = 1; i < n; ++i)
1332 vRowComm->Recv(i, tmp);
1334 mean2 += tmp[0]*tmp[0];
1336 if (tmp[0] > maxval)
1340 if (tmp[0] < minval)
1346 out <<
" - Local bnd dof dist. (min/max/mean/dev) : "
1347 << minval <<
" " << maxval <<
" " << (mean / n) <<
" "
1348 << sqrt(mean2/n - mean*mean/n/n) << endl;
1355 vRowComm->Send(0, tmp);
1358 vRowComm->Send(0, tmp);
const Array< OneD, const int > & GetBndCondTraceToGlobalTraceMap()
PreconditionerType GetPreconType() const
#define ASSERTL0(condition, msg)
bool m_systemSingular
Flag indicating if the system is singular or not.
const Array< OneD, const int > & GetGlobalToUniversalMap()
bool m_signChange
Flag indicating if modes require sign reversal.
void PrintStats(std::ostream &out, std::string variable) const
int GetLocalToGlobalBndMap(const int i) const
Retrieve the global index of a given local boundary mode.
virtual int v_GetNumNonDirFaceModes() const
const Array< OneD, NekDouble > & GetLocalToGlobalSign() const
PreconditionerType m_preconType
Type type of preconditioner to use in iterative solver.
int m_numGlobalBndCoeffs
Total number of global boundary coefficients.
LibUtilities::CommSharedPtr GetComm()
Retrieves the communicator.
LibUtilities::CommSharedPtr m_comm
Communicator.
virtual ~AssemblyMap()
Destructor.
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.
void Gathr(int n, const T *x, const int *y, T *z)
Gather vector z[i] = x[y[i]].
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
#define sign(a, b)
return the sign(b)*a
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
int GetNumLocalCoeffs() const
Returns the total number of local coefficients.
virtual int v_GetNumNonDirVertexModes() const
static const NekDouble kNekIterativeTol
Array< OneD, int > m_bndCondTraceToGlobalTraceMap
Integer map of bnd cond trace number to global trace number.
int GetBndSystemBandWidth() const
Returns the bandwidth of the boundary system.
virtual int v_GetNumNonDirFaces() const
size_t GetHash() const
Retrieves the hash of this map.
boost::shared_ptr< BottomUpSubStructuredGraph > BottomUpSubStructuredGraphSharedPtr
int GetNumNonDirVertexModes() const
int GetFullSystemBandWidth() const
bool AtLastLevel() const
Returns true if this is the last level in the multi-level static condensation.
int GetNumPatches() const
Returns the number of patches in this static condensation level.
Array< OneD, const NekDouble > GetLocalToGlobalBndSign() const
Retrieve the sign change for all local boundary modes.
NekDouble GetIterativeTolerance() const
int m_numLocalCoeffs
Total number of local coefficients.
int GetNumNonDirFaceModes() const
const Array< OneD, const int > & GetExtraDirEdges()
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
PatchMapSharedPtr m_patchMapFromPrevLevel
Mapping information for previous level in MultiLevel Solver.
virtual void v_GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const
boost::shared_ptr< PatchMap > PatchMapSharedPtr
const Array< OneD, const int > & GetGlobalToUniversalBndMapUnique()
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
const Array< OneD, const int > & GetLocalToGlobalBndMap()
Retrieve the global indices of the local boundary modes.
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.
int m_successiveRHS
sucessive RHS for iterative solver
size_t m_hash
Hash for map.
void UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
Base class for all multi-elemental spectral/hp expansions.
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
int GetNumGlobalDirBndCoeffs() const
Returns the number of global Dirichlet boundary coefficients.
virtual boost::shared_ptr< AssemblyMap > v_LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType)
Generate a linear space mapping from existing mapping.
GlobalSysSolnType GetGlobalSysSolnType() const
Returns the method of solving global systems.
int m_bndSystemBandWidth
The bandwith of the global bnd system.
NekDouble m_iterativeTolerance
Tolerance for iterative solver.
Array< OneD, unsigned int > m_numLocalBndCoeffsPerPatch
The number of bnd dofs per patch.
boost::shared_ptr< AssemblyMap > LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType)
GlobalSysSolnType m_solnType
The solution type of the global system.
Array< OneD, NekDouble > m_bndCondCoeffsToGlobalCoeffsSign
Integer map of bnd cond coeffs to global coefficients.
int m_numGlobalDirBndCoeffs
Number of Global Dirichlet Boundary Coefficients.
NekDouble GetBndCondCoeffsToGlobalCoeffsSign(const int i)
Returns the modal sign associated with a given boundary expansion mode.
int GetStaticCondLevel() const
Returns the level of static condensation for this map.
void GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const
int GetNumNonDirEdges() const
virtual int v_GetNumDirFaces() const
virtual int v_GetFullSystemBandWidth() const
void Scatr(int n, const T *x, const int *y, T *z)
Scatter vector z[y[i]] = x[i].
const PatchMapSharedPtr & GetPatchMapFromPrevLevel(void) const
Returns the patch map from the previous level of the multi-level static condensation.
int GetNumDirEdges() const
void Assmb(int n, const T *x, const int *y, T *z)
Assemble z[y[i]] += x[i]; z should be zero'd first.
void LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
Array< OneD, unsigned int > m_numLocalIntCoeffsPerPatch
The number of int dofs per patch.
void CalculateBndSystemBandWidth()
Calculates the bandwidth of the boundary system.
Array< OneD, int > m_localToGlobalBndMap
Integer map of local boundary coeffs to global space.
int GetNumDirFaces() const
const Array< OneD, const int > & GetBndCondCoeffsToGlobalCoeffsMap()
Retrieves the global indices corresponding to the boundary expansion modes.
int m_numLocalDirBndCoeffs
Number of Local Dirichlet Boundary Coefficients.
bool GetSignChange()
Returns true if using a modal expansion requiring a change of sign of some modes. ...
const Array< OneD, const int > & GetLocalToGlobalMap()
virtual void v_Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
const Array< OneD, const int > & GetGlobalToUniversalBndMap()
virtual int v_GetNumNonDirEdgeModes() const
Array< OneD, int > m_bndCondCoeffsToGlobalCoeffsMap
Integer map of bnd cond coeffs to global coefficients.
int m_numLocalBndCoeffs
Number of local boundary coefficients.
int GetNumNonDirFaces() const
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 GetNumNonDirEdgeModes() const
int GetNumGlobalBndCoeffs() const
Returns the total number of global boundary coefficients.
AssemblyMap()
Default constructor.
const Array< OneD, const unsigned int > & GetNumLocalBndCoeffsPerPatch()
Returns the number of local boundary coefficients in each patch.
void GlobalToLocalBndWithoutSign(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc)
int RoundNekDoubleToInt(NekDouble x)
Rounds a double precision number to an integer.
const Array< OneD, const int > & GetGlobalToUniversalMapUnique()
NekDouble GetLocalToGlobalBndSign(const int i) const
Retrieve the sign change of a given local boundary mode.
int GetNumLocalDirBndCoeffs() const
Returns the number of local Dirichlet boundary coefficients.
LibUtilities::SessionReaderSharedPtr m_session
Session object.
void LocalBndToGlobal(const NekVector< NekDouble > &loc, NekVector< NekDouble > &global, int offset) const
void AssembleBnd(const NekVector< NekDouble > &loc, NekVector< NekDouble > &global, int offset) const
virtual const Array< OneD, NekDouble > & v_GetLocalToGlobalSign() const
virtual const Array< OneD, const int > & v_GetExtraDirEdges()
int GetNumGlobalCoeffs() const
Returns the total number of global coefficients.
int GetNumLocalBndCoeffs() const
Returns the total number of local boundary coefficients.
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)
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique()
No Solution type specified.
void UniversalAssembleBnd(Array< OneD, NekDouble > &pGlobal) const
int m_numGlobalCoeffs
Total number of global coefficients.
void GlobalToLocalBnd(const NekVector< NekDouble > &global, NekVector< NekDouble > &loc, int offset) const
const Array< OneD, const unsigned int > & GetNumLocalIntCoeffsPerPatch()
Returns the number of local interior coefficients in each patch.
virtual int v_GetNumNonDirEdges() const
void Zero(int n, T *x, const int incx)
Zero vector.
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMap()
#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)
const AssemblyMapSharedPtr GetNextLevelLocalToGlobalMap() const
Returns the local to global mapping for the next level in the multi-level static condensation.
void Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
Array< OneD, DataType > & GetPtr()
virtual const Array< OneD, const int > & v_GetLocalToGlobalMap()
virtual int v_GetNumDirEdges() const
int m_numPatches
The number of patches (~elements) in the current level.
bool GetSingularSystem() const
Retrieves if the system is singular (true) or not (false)
int GetSuccessiveRHS() const