42 namespace MultiRegions
59 return int(x > 0.0 ? x + 0.5 : x - 0.5);
65 int size = inarray.num_elements();
66 ASSERTL1(outarray.num_elements()>=size,
"Array sizes not compatible");
69 for(
int i = 0; i < size; i++)
72 outarray[i] = int(x > 0.0 ? x + 0.5 : x - 0.5);
79 AssemblyMap::AssemblyMap():
83 m_numLocalBndCoeffs(0),
84 m_numGlobalBndCoeffs(0),
85 m_numLocalDirBndCoeffs(0),
86 m_numGlobalDirBndCoeffs(0),
88 m_bndSystemBandWidth(0),
97 const std::string variable):
99 m_comm(pSession->GetComm()),
101 m_numLocalBndCoeffs(0),
102 m_numGlobalBndCoeffs(0),
103 m_numLocalDirBndCoeffs(0),
104 m_numGlobalDirBndCoeffs(0),
105 m_bndSystemBandWidth(0),
117 if(pSession->DefinesGlobalSysSolnInfo(variable,
"GlobalSysSoln"))
119 std::string sysSoln = pSession->GetGlobalSysSolnInfo(variable,
122 "GlobalSysSoln", sysSoln);
125 if(pSession->DefinesGlobalSysSolnInfo(variable,
"Preconditioner"))
127 std::string precon = pSession->GetGlobalSysSolnInfo(variable,
130 "Preconditioner", precon);
133 if(pSession->DefinesGlobalSysSolnInfo(variable,
134 "IterativeSolverTolerance"))
137 pSession->GetGlobalSysSolnInfo(variable,
138 "IterativeSolverTolerance").c_str());
142 pSession->LoadParameter(
"IterativeSolverTolerance",
148 if(pSession->DefinesGlobalSysSolnInfo(variable,
152 pSession->GetGlobalSysSolnInfo(variable,
153 "MaxIterations").c_str());
157 pSession->LoadParameter(
"MaxIterations",
163 if(pSession->DefinesGlobalSysSolnInfo(variable,
"SuccessiveRHS"))
166 pSession->GetGlobalSysSolnInfo(variable,
167 "SuccessiveRHS").c_str());
171 pSession->LoadParameter(
"SuccessiveRHS",
184 m_session(oldLevelMap->m_session),
185 m_comm(oldLevelMap->GetComm()),
187 m_solnType(oldLevelMap->m_solnType),
188 m_preconType(oldLevelMap->m_preconType),
189 m_maxIterations(oldLevelMap->m_maxIterations),
190 m_iterativeTolerance(oldLevelMap->m_iterativeTolerance),
191 m_successiveRHS(oldLevelMap->m_successiveRHS),
192 m_gsh(oldLevelMap->m_gsh),
193 m_bndGsh(oldLevelMap->m_bndGsh),
194 m_lowestStaticCondLevel(oldLevelMap->m_lowestStaticCondLevel)
215 int newLevel = staticCondLevelOld+1;
236 multiLevelGraph->MaskPatches(newLevel,globHomPatchMask);
255 int numPatchesWithIntNew = multiLevelGraph->GetNpatchesWithInterior(newLevel);
256 int numPatchesNew = numPatchesWithIntNew;
260 std::map<int, int> numLocalBndCoeffsPerPatchNew;
261 for(
int i = 0; i < numPatchesNew; i++)
263 numLocalBndCoeffsPerPatchNew[i] = 0;
269 for(i = cnt = 0; i < numPatchesOld; i++)
282 minval = *min_element(&locPatchMask[cnt],
283 &locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
284 maxval = *max_element(&locPatchMask[cnt],
285 &locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
286 ASSERTL0((minval==maxval)||(minval==-1),
"These values should never be the same");
290 curPatch = numPatchesNew;
291 numLocalBndCoeffsPerPatchNew[curPatch] = 0;
299 for(j = 0; j < numLocalBndCoeffsPerPatchOld[i]; j++ )
301 ASSERTL0((locPatchMask[cnt]==maxval)||(locPatchMask[cnt]==minval),
302 "These values should never be the same");
303 if(locPatchMask[cnt] == -1)
305 ++numLocalBndCoeffsPerPatchNew[curPatch];
322 multiLevelGraph->GetNintDofsPerPatch(newLevel,m_numLocalIntCoeffsPerPatch);
330 "This method should only be called for in "
331 "case of multi-level static condensation.");
356 for(
int i = 1; i < m_numPatches+1; i++)
358 numLocalBndCoeffsPerPatchOffset[i] += numLocalBndCoeffsPerPatchOffset[i-1] + numLocalBndCoeffsPerPatchNew[i-1];
361 int additionalPatchCnt = numPatchesWithIntNew;
367 for(i = cnt = 0; i < numPatchesOld; i++)
369 minval = *min_element(&locPatchMask[cnt],&locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
370 maxval = *max_element(&locPatchMask[cnt],&locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
371 ASSERTL0((minval==maxval)||(minval==-1),
"These values should never be the same");
375 curPatch = additionalPatchCnt;
376 additionalPatchCnt++;
383 for(j = 0; j < numLocalBndCoeffsPerPatchOld[i]; j++ )
385 ASSERTL0((locPatchMask[cnt]==maxval)||(locPatchMask[cnt]==minval),
386 "These values should never be the same");
390 if(locPatchMask[cnt] == -1)
392 newid = numLocalBndCoeffsPerPatchOffset[curPatch];
400 blockid = bndDofPerPatchCnt[curPatch];
404 numLocalBndCoeffsPerPatchOffset[curPatch]++;
405 bndDofPerPatchCnt[curPatch]++;
417 sign = isBndDof?1.0:
sign;
469 for(j = 0; j < locSize; j++)
484 bwidth = (bwidth>(maxId-minId))?bwidth:(maxId-minId);
495 ASSERTL0(
false,
"Not defined for this type of mapping.");
501 ASSERTL0(
false,
"Not defined for this type of mapping.");
507 ASSERTL0(
false,
"Not defined for this type of mapping.");
513 ASSERTL0(
false,
"Not defined for this type of mapping.");
520 ASSERTL0(
false,
"Not defined for this type of mapping.");
527 ASSERTL0(
false,
"Not defined for this type of mapping.");
534 ASSERTL0(
false,
"Not defined for this type of mapping.");
540 ASSERTL0(
false,
"Not defined for this type of mapping.");
549 ASSERTL0(
false,
"Not defined for this type of mapping.");
556 ASSERTL0(
false,
"Not defined for this type of mapping.");
563 ASSERTL0(
false,
"Not defined for this type of mapping.");
570 ASSERTL0(
false,
"Not defined for this type of mapping.");
577 ASSERTL0(
false,
"Not defined for this type of mapping.");
584 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.");
647 ASSERTL0(
false,
"Not defined for this type of mapping.");
653 ASSERTL0(
false,
"Not defined for this type of mapping.");
659 ASSERTL0(
false,
"Not defined for this type of mapping.");
667 ASSERTL0(
false,
"Not defined for this sub class");
668 static boost::shared_ptr<AssemblyMap> result;
890 "Index out of range.");
897 return m_bndCondTraceToGlobalTraceMap;
1147 if (offset > 0)
Vmath::Vcopy(offset, pGlobal, 1, tmp, 1);
1149 if (offset > 0)
Vmath::Vcopy(offset, tmp, 1, pGlobal, 1);
1235 std::ostream &out, std::string variable)
const
1239 bool isRoot = vRowComm->GetRank() == 0;
1240 int n = vRowComm->GetSize();
1244 int globBndCnt = 0, globDirCnt = 0;
1268 int totGlobDof = globCnt;
1269 int totGlobBndDof = globBndCnt;
1270 int totGlobDirDof = globDirCnt;
1275 int meanValence = 0;
1277 int minValence = 10000000;
1285 if (tmpGlob[i] > maxValence)
1287 maxValence = tmpGlob[i];
1289 if (tmpGlob[i] < minValence)
1291 minValence = tmpGlob[i];
1293 meanValence += tmpGlob[i];
1306 meanValence /= totGlobBndDof;
1310 out <<
"Assembly map statistics for field " << variable <<
":"
1312 out <<
" - Number of local/global dof : "
1313 << totLocalDof <<
" " << totGlobDof << endl;
1314 out <<
" - Number of local/global boundary dof : "
1315 << totLocalBndDof <<
" " << totGlobBndDof << endl;
1316 out <<
" - Number of local/global Dirichlet dof : "
1317 << totLocalDirDof <<
" " << totGlobDirDof << endl;
1318 out <<
" - dof valency (min/max/mean) : "
1319 << minValence <<
" " << maxValence <<
" " << meanValence
1328 for (i = 1; i < n; ++i)
1330 vRowComm->Recv(i, tmp);
1332 mean2 += tmp[0]*tmp[0];
1334 if (tmp[0] > maxval)
1338 if (tmp[0] < minval)
1344 out <<
" - Local dof dist. (min/max/mean/dev) : "
1345 << minval <<
" " << maxval <<
" " << (mean / n) <<
" "
1346 << sqrt(mean2/n - mean*mean/n/n) << endl;
1351 mean2 = mean * mean;
1353 for (i = 1; i < n; ++i)
1355 vRowComm->Recv(i, tmp);
1357 mean2 += tmp[0]*tmp[0];
1359 if (tmp[0] > maxval)
1363 if (tmp[0] < minval)
1369 out <<
" - Local bnd dof dist. (min/max/mean/dev) : "
1370 << minval <<
" " << maxval <<
" " << (mean / n) <<
" "
1371 << sqrt(mean2/n - mean*mean/n/n) << endl;
1378 vRowComm->Send(0, tmp);
1381 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.
void RoundNekDoubleToInt(const Array< OneD, const NekDouble > inarray, Array< OneD, int > outarray)
Rounds an array of double precision numbers to integers.
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