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,
150 pSession->GetGlobalSysSolnInfo(variable,
151 "MaxIterations").c_str());
155 pSession->LoadParameter(
"MaxIterations",
161 if(pSession->DefinesGlobalSysSolnInfo(variable,
"SuccessiveRHS"))
164 pSession->GetGlobalSysSolnInfo(variable,
165 "SuccessiveRHS").c_str());
169 pSession->LoadParameter(
"SuccessiveRHS",
182 m_session(oldLevelMap->m_session),
183 m_comm(oldLevelMap->GetComm()),
185 m_solnType(oldLevelMap->m_solnType),
186 m_preconType(oldLevelMap->m_preconType),
187 m_maxIterations(oldLevelMap->m_maxIterations),
188 m_iterativeTolerance(oldLevelMap->m_iterativeTolerance),
189 m_successiveRHS(oldLevelMap->m_successiveRHS),
190 m_gsh(oldLevelMap->m_gsh),
191 m_bndGsh(oldLevelMap->m_bndGsh),
192 m_lowestStaticCondLevel(oldLevelMap->m_lowestStaticCondLevel)
213 int newLevel = staticCondLevelOld+1;
234 multiLevelGraph->MaskPatches(newLevel,globHomPatchMask);
253 int numPatchesWithIntNew = multiLevelGraph->GetNpatchesWithInterior(newLevel);
254 int numPatchesNew = numPatchesWithIntNew;
258 map<int, int> numLocalBndCoeffsPerPatchNew;
259 for(
int i = 0; i < numPatchesNew; i++)
261 numLocalBndCoeffsPerPatchNew[i] = 0;
267 for(i = cnt = 0; i < numPatchesOld; i++)
280 minval = *min_element(&locPatchMask[cnt],
281 &locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
282 maxval = *max_element(&locPatchMask[cnt],
283 &locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
284 ASSERTL0((minval==maxval)||(minval==-1),
"These values should never be the same");
288 curPatch = numPatchesNew;
289 numLocalBndCoeffsPerPatchNew[curPatch] = 0;
297 for(j = 0; j < numLocalBndCoeffsPerPatchOld[i]; j++ )
299 ASSERTL0((locPatchMask[cnt]==maxval)||(locPatchMask[cnt]==minval),
300 "These values should never be the same");
301 if(locPatchMask[cnt] == -1)
303 ++numLocalBndCoeffsPerPatchNew[curPatch];
320 multiLevelGraph->GetNintDofsPerPatch(newLevel,m_numLocalIntCoeffsPerPatch);
328 "This method should only be called for in "
329 "case of multi-level static condensation.");
354 for(
int i = 1; i < m_numPatches+1; i++)
356 numLocalBndCoeffsPerPatchOffset[i] += numLocalBndCoeffsPerPatchOffset[i-1] + numLocalBndCoeffsPerPatchNew[i-1];
359 int additionalPatchCnt = numPatchesWithIntNew;
365 for(i = cnt = 0; i < numPatchesOld; i++)
367 minval = *min_element(&locPatchMask[cnt],&locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
368 maxval = *max_element(&locPatchMask[cnt],&locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
369 ASSERTL0((minval==maxval)||(minval==-1),
"These values should never be the same");
373 curPatch = additionalPatchCnt;
374 additionalPatchCnt++;
381 for(j = 0; j < numLocalBndCoeffsPerPatchOld[i]; j++ )
383 ASSERTL0((locPatchMask[cnt]==maxval)||(locPatchMask[cnt]==minval),
384 "These values should never be the same");
388 if(locPatchMask[cnt] == -1)
390 newid = numLocalBndCoeffsPerPatchOffset[curPatch];
398 blockid = bndDofPerPatchCnt[curPatch];
402 numLocalBndCoeffsPerPatchOffset[curPatch]++;
403 bndDofPerPatchCnt[curPatch]++;
415 sign = isBndDof?1.0:
sign;
467 for(j = 0; j < locSize; j++)
482 bwidth = (bwidth>(maxId-minId))?bwidth:(maxId-minId);
493 ASSERTL0(
false,
"Not defined for this type of mapping.");
499 ASSERTL0(
false,
"Not defined for this type of mapping.");
505 ASSERTL0(
false,
"Not defined for this type of mapping.");
511 ASSERTL0(
false,
"Not defined for this type of mapping.");
518 ASSERTL0(
false,
"Not defined for this type of mapping.");
525 ASSERTL0(
false,
"Not defined for this type of mapping.");
532 ASSERTL0(
false,
"Not defined for this type of mapping.");
538 ASSERTL0(
false,
"Not defined for this type of mapping.");
547 ASSERTL0(
false,
"Not defined for this type of mapping.");
554 ASSERTL0(
false,
"Not defined for this type of mapping.");
561 ASSERTL0(
false,
"Not defined for this type of mapping.");
568 ASSERTL0(
false,
"Not defined for this type of mapping.");
575 ASSERTL0(
false,
"Not defined for this type of mapping.");
582 ASSERTL0(
false,
"Not defined for this type of mapping.");
609 ASSERTL0(
false,
"Not defined for this type of mapping.");
615 ASSERTL0(
false,
"Not defined for this type of mapping.");
621 ASSERTL0(
false,
"Not defined for this type of mapping.");
627 ASSERTL0(
false,
"Not defined for this type of mapping.");
633 ASSERTL0(
false,
"Not defined for this type of mapping.");
639 ASSERTL0(
false,
"Not defined for this type of mapping.");
645 ASSERTL0(
false,
"Not defined for this type of mapping.");
651 ASSERTL0(
false,
"Not defined for this type of mapping.");
657 ASSERTL0(
false,
"Not defined for this type of mapping.");
665 ASSERTL0(
false,
"Not defined for this sub class");
666 static boost::shared_ptr<AssemblyMap> result;
888 "Index out of range.");
895 return m_bndCondTraceToGlobalTraceMap;
1145 if (offset > 0)
Vmath::Vcopy(offset, pGlobal, 1, tmp, 1);
1147 if (offset > 0)
Vmath::Vcopy(offset, tmp, 1, pGlobal, 1);
1233 std::ostream &out, std::string variable)
const
1237 bool isRoot = vRowComm->GetRank() == 0;
1238 int n = vRowComm->GetSize();
1242 int globBndCnt = 0, globDirCnt = 0;
1266 int totGlobDof = globCnt;
1267 int totGlobBndDof = globBndCnt;
1268 int totGlobDirDof = globDirCnt;
1273 int meanValence = 0;
1275 int minValence = 10000000;
1283 if (tmpGlob[i] > maxValence)
1285 maxValence = tmpGlob[i];
1287 if (tmpGlob[i] < minValence)
1289 minValence = tmpGlob[i];
1291 meanValence += tmpGlob[i];
1304 meanValence /= totGlobBndDof;
1308 out <<
"Assembly map statistics for field " << variable <<
":"
1310 out <<
" - Number of local/global dof : "
1311 << totLocalDof <<
" " << totGlobDof << endl;
1312 out <<
" - Number of local/global boundary dof : "
1313 << totLocalBndDof <<
" " << totGlobBndDof << endl;
1314 out <<
" - Number of local/global Dirichlet dof : "
1315 << totLocalDirDof <<
" " << totGlobDirDof << endl;
1316 out <<
" - dof valency (min/max/mean) : "
1317 << minValence <<
" " << maxValence <<
" " << meanValence
1326 for (i = 1; i < n; ++i)
1328 vRowComm->Recv(i, tmp);
1330 mean2 += tmp[0]*tmp[0];
1332 if (tmp[0] > maxval)
1336 if (tmp[0] < minval)
1342 out <<
" - Local dof dist. (min/max/mean/dev) : "
1343 << minval <<
" " << maxval <<
" " << (mean / n) <<
" "
1344 << sqrt(mean2/n - mean*mean/n/n) << endl;
1349 mean2 = mean * mean;
1351 for (i = 1; i < n; ++i)
1353 vRowComm->Recv(i, tmp);
1355 mean2 += tmp[0]*tmp[0];
1357 if (tmp[0] > maxval)
1361 if (tmp[0] < minval)
1367 out <<
" - Local bnd dof dist. (min/max/mean/dev) : "
1368 << minval <<
" " << maxval <<
" " << (mean / n) <<
" "
1369 << sqrt(mean2/n - mean*mean/n/n) << endl;
1376 vRowComm->Send(0, tmp);
1379 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.
int m_maxIterations
Maximum iterations for iterative solver.
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()
int GetMaxIterations() const
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