57 "Iterative solver for full matrix system.");
68 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
71 m_locToGloMap(pLocToGloMap)
74 "This routine should only be used when using an Iterative "
75 "conjugate gradient matrix solve.");
104 bool dirForcCalculated = (bool)pDirForcing.size();
105 int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
106 int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
107 int nLocDofs = pLocToGloMap->GetNumLocalCoeffs();
109 int nDirTotal = nDirDofs;
110 std::shared_ptr<MultiRegions::ExpList> expList =
m_expList.lock();
111 expList->GetComm()->GetRowComm()->AllReduce(nDirTotal,
119 if (dirForcCalculated)
123 pDirForcing.size() >= nLocDofs,
124 "DirForcing is not of sufficient size. Is it in local space?");
125 Vmath::Vsub(nLocDofs, pLocInput, 1, pDirForcing, 1, rhs, 1);
131 expList->GeneralMatrixOp(
m_linSysKey, pLocOutput, rhs);
141 int offset = expList->GetCoeff_Offset(n);
145 for (rBC = r.second; rBC; rBC = rBC->next)
147 vExp->AddRobinTraceContribution(
148 rBC->m_robinID, rBC->m_robinPrimitiveCoeffs,
149 pLocOutput + offset, rhsloc = rhs + offset);
152 Vmath::Vsub(nLocDofs, pLocInput, 1, rhs, 1, rhs, 1);
155 if (std::dynamic_pointer_cast<AssemblyMapCG>(pLocToGloMap))
163 Vmath::Vadd(nLocDofs, diff, 1, pLocOutput, 1, pLocOutput, 1);
167 ASSERTL0(
false,
"Need DG solve if using Dir BCs");
185 std::shared_ptr<MultiRegions::ExpList> expList =
m_expList.lock();
189 int ncoeffs = expList->GetNcoeffs();
198 expList->GeneralMatrixOp(
m_linSysKey, InputLoc, OutputLoc);
202 ASSERTL1(pInput.size() >= asmMap->GetNumGlobalCoeffs(),
203 "Input array is not of suffiicent length "
204 "to support GlobalToLocal Call");
208 asmMap->GlobalToLocal(pInput, InputLoc);
210 expList->GeneralMatrixOp(
m_linSysKey, InputLoc, OutputLoc);
221 int offset = expList->GetCoeff_Offset(n);
225 for (rBC = r.second; rBC; rBC = rBC->next)
227 vExp->AddRobinTraceContribution(
228 rBC->m_robinID, rBC->m_robinPrimitiveCoeffs, InputLoc + offset,
229 tmp = OutputLoc + offset);
234 if (isLocal ==
false)
236 asmMap->Assemble(OutputLoc, pOutput);
254 m_expList.lock()->GetComm()->GetRowComm();
262 "' is not defined.\n");
266 string variable = plocToGloMap->GetVariable();
270 if (pSession->DefinesGlobalSysSolnInfo(variable,
271 "IterativeSolverTolerance"))
273 sysKey.m_NekLinSysTolerance = boost::lexical_cast<double>(
275 ->GetGlobalSysSolnInfo(variable,
"IterativeSolverTolerance")
280 pSession->LoadParameter(
"IterativeSolverTolerance",
281 sysKey.m_NekLinSysTolerance,
285 if (pSession->DefinesGlobalSysSolnInfo(variable,
286 "NekLinSysMaxIterations"))
288 sysKey.m_NekLinSysMaxIterations = std::stoi(
290 ->GetGlobalSysSolnInfo(variable,
"NekLinSysMaxIterations")
295 pSession->LoadParameter(
"NekLinSysMaxIterations",
296 sysKey.m_NekLinSysMaxIterations, 5000);
299 if (pSession->DefinesGlobalSysSolnInfo(variable,
"LinSysMaxStorage"))
301 sysKey.m_LinSysMaxStorage = std::stoi(
302 pSession->GetGlobalSysSolnInfo(variable,
"LinSysMaxStorage")
307 pSession->LoadParameter(
"LinSysMaxStorage",
308 sysKey.m_LinSysMaxStorage, 100);
311 if (pSession->DefinesGlobalSysSolnInfo(variable,
"GMRESMaxHessMatBand"))
313 sysKey.m_KrylovMaxHessMatBand = std::stoi(
314 pSession->GetGlobalSysSolnInfo(variable,
"GMRESMaxHessMatBand")
319 pSession->LoadParameter(
"GMRESMaxHessMatBand",
320 sysKey.m_KrylovMaxHessMatBand,
321 sysKey.m_LinSysMaxStorage + 1);
326 pSession->MatchSolverInfo(
"GMRESLeftPrecon",
"True",
327 sysKey.m_NekLinSysLeftPrecon,
false);
328 pSession->MatchSolverInfo(
"GMRESRightPrecon",
"True",
329 sysKey.m_NekLinSysRightPrecon,
true);
362 plocToGloMap->Assemble(pInput, gloIn);
364 plocToGloMap->GlobalToLocal(gloOut, pOutput);
370 int nLocDofs = plocToGloMap->GetNumLocalCoeffs();
372 m_linsol->SolveSystem(nLocDofs, pInput, pOutput, nDir);
379 plocToGloMap->Assemble(pInput, gloIn);
380 m_linsol->SolveSystem(nGlobal, gloIn, gloOut, nDir);
381 plocToGloMap->GlobalToLocal(gloOut, pOutput);
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
const std::map< int, RobinBCInfoSharedPtr > m_robinBCInfo
Robin boundary info.
void SolveLinearSystem(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir=0)
Solve the linear system for given input and output vectors.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
PreconditionerSharedPtr CreatePrecon(AssemblyMapSharedPtr asmMap)
Create a preconditioner object from the parameters defined in the supplied assembly map.
void v_UniqueMap() override
static GlobalLinSysSharedPtr create(const GlobalLinSysKey &pLinSysKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
GlobalLinSysIterativeFull(const GlobalLinSysKey &pLinSysKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
static std::string className
Name of class.
void Initialise(const int nGlobal, const AssemblyMapSharedPtr &plocToGloMap, const int nDir)
void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
std::weak_ptr< AssemblyMap > m_locToGloMap
void v_Solve(const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray) override
Solve the linear system for given input and output vectors using a specified local to global map.
void v_SolveLinearSystem(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir) override
Solve the matrix system.
LibUtilities::NekLinSysIterSharedPtr m_linsol
bool m_isAbsoluteTolerance
PreconditionerSharedPtr m_precon
void DoProjection(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int pNumDir, const bool isAconjugate)
projection technique
bool m_useProjection
Whether to apply projection technique.
Array< OneD, int > m_map
Global to universal unique map.
NekDouble m_rhs_magnitude
dot product of rhs to normalise stopping criterion
LibUtilities::NekSysOperators m_NekSysOp
std::string m_linSysIterSolver
Iterative solver: Conjugate Gradient, GMRES.
Describe a linear system.
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
NekLinSysIterFactory & GetNekLinSysIterFactory()
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< RobinBCInfo > RobinBCInfoSharedPtr
GlobalLinSysFactory & GetGlobalLinSysFactory()
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
static const NekDouble kNekIterativeTol
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Zero(int n, T *x, const int incx)
Zero vector.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.