Nektar++
NekNonlinSys.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File NekNonlinSys.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: NekNonlinSys header
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_NONLINSYS_H
37 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_NONLINSYS_H
38 
41 
42 namespace Nektar
43 {
44 namespace LibUtilities
45 {
46 class NekNonlinSys;
47 
48 typedef std::shared_ptr<NekNonlinSys> NekNonlinSysSharedPtr;
49 
50 typedef LibUtilities::NekFactory<std::string, NekNonlinSys,
52  const LibUtilities::CommSharedPtr &, const int,
53  const NekSysKey &>
56 
57 class NekNonlinSys : public NekSys
58 {
59 public:
60  friend class MemoryManager<NekNonlinSys>;
63  const LibUtilities::CommSharedPtr &vComm, const int nDimen,
64  const NekSysKey &pKey)
65  {
68  nDimen, pKey);
69  return p;
70  }
73  const LibUtilities::CommSharedPtr &vComm, const int nDimen,
74  const NekSysKey &pKey);
76 
78  const int nGlobal, const Array<OneD, const NekDouble> &pInput,
79  const Array<OneD, const NekDouble> &pSource,
80  const int nDir);
81 
83  const
84  {
85  return m_Solution;
86  }
87 
89  const
90  {
91  return m_Residual;
92  }
93 
95  const
96  {
97  return m_SourceVec;
98  }
99 
102  {
103  ASSERTL0(in.size() == m_SysDimen,
104  "SetRefResidual dimension not correct");
105  Vmath::Vcopy(m_SysDimen, in, 1, m_Residual, 1);
106 
107  m_ResidualUpdated = true;
108  }
109 
111  {
112  m_tolerance = in;
113  }
114 
116  const unsigned int in)
117  {
118  m_maxiter = in;
119  }
120 
123  {
124  return m_linsol;
125  }
126 
128  {
130  }
131 
133  {
135  }
136 
138  {
139  return m_NtotLinSysIts;
140  }
141 
142 protected:
144 
147 
149 
152 
153 
158 
159  bool m_ResidualUpdated = false;
160 
161  virtual void v_InitObject();
162 
163 private:
164 };
165 } // namespace LibUtilities
166 } // namespace Nektar
167 #endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
#define LIB_UTILITIES_EXPORT
Provides a generic Factory class.
Definition: NekFactory.hpp:105
NekNonlinSys(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vComm, const int nDimen, const NekSysKey &pKey)
void SetLinSysRelativeTolInNonlin(const NekDouble in)
Definition: NekNonlinSys.h:132
void SetNekNonlinSysTolerance(const NekDouble in)
Definition: NekNonlinSys.h:110
Array< OneD, NekDouble > m_Residual
Definition: NekNonlinSys.h:155
const Array< OneD, const NekDouble > & GetRefSourceVec() const
Definition: NekNonlinSys.h:94
const NekLinSysIterSharedPtr & GetLinSys()
Definition: NekNonlinSys.h:122
static NekNonlinSysSharedPtr CreateInstance(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vComm, const int nDimen, const NekSysKey &pKey)
Definition: NekNonlinSys.h:61
void SetRefResidual(const Array< OneD, const NekDouble > &in)
Definition: NekNonlinSys.h:100
Array< OneD, NekDouble > m_DeltSltn
Definition: NekNonlinSys.h:156
void SetNonlinIterTolRelativeL2(const NekDouble in)
Definition: NekNonlinSys.h:127
virtual void v_SetupNekNonlinSystem(const int nGlobal, const Array< OneD, const NekDouble > &pInput, const Array< OneD, const NekDouble > &pSource, const int nDir)
Array< OneD, NekDouble > m_SourceVec
Definition: NekNonlinSys.h:157
NekLinSysIterSharedPtr m_linsol
Definition: NekNonlinSys.h:143
const Array< OneD, const NekDouble > & GetRefSolution() const
Definition: NekNonlinSys.h:82
const Array< OneD, const NekDouble > & GetRefResidual() const
Definition: NekNonlinSys.h:88
void SetNekNonlinSysMaxIterations(const unsigned int in)
Definition: NekNonlinSys.h:115
Array< OneD, NekDouble > m_Solution
Definition: NekNonlinSys.h:154
NekDouble m_tolerance
Tolerance of iterative solver.
Definition: NekSys.h:283
int m_SysDimen
The dimension of the system.
Definition: NekSys.h:296
int m_maxiter
Maximum iterations.
Definition: NekSys.h:281
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.
LibUtilities::NekFactory< std::string, NekNonlinSys, const LibUtilities::SessionReaderSharedPtr &, const LibUtilities::CommSharedPtr &, const int, const NekSysKey & > NekNonlinSysFactory
Definition: NekNonlinSys.h:54
std::shared_ptr< NekLinSysIter > NekLinSysIterSharedPtr
Definition: NekLinSysIter.h:46
NekNonlinSysFactory & GetNekNonlinSysFactory()
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< NekNonlinSys > NekNonlinSysSharedPtr
Definition: NekNonlinSys.h:46
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:54
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199