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 
52  const LibUtilities::CommSharedPtr &, const int, const NekSysKey &>
55 
56 class NekNonlinSys : public NekSys
57 {
58 public:
59  friend class MemoryManager<NekNonlinSys>;
62  const LibUtilities::CommSharedPtr &vComm, const int nDimen,
63  const NekSysKey &pKey)
64  {
67  nDimen, pKey);
68  return p;
69  }
72  const LibUtilities::CommSharedPtr &vComm, const int nDimen,
73  const NekSysKey &pKey);
75 
77  const int nGlobal, const Array<OneD, const NekDouble> &pInput,
78  const Array<OneD, const NekDouble> &pSource, const int nDir);
79 
81  const
82  {
83  return m_Solution;
84  }
85 
87  const
88  {
89  return m_Residual;
90  }
91 
93  const
94  {
95  return m_SourceVec;
96  }
97 
100  {
101  ASSERTL0(in.size() == m_SysDimen,
102  "SetRefResidual dimension not correct");
103  Vmath::Vcopy(m_SysDimen, in, 1, m_Residual, 1);
104 
105  m_ResidualUpdated = true;
106  }
107 
109  {
110  m_tolerance = in;
111  }
112 
114  const unsigned int in)
115  {
116  m_maxiter = in;
117  }
118 
120  {
121  return m_linsol;
122  }
123 
125  {
127  }
128 
130  {
132  }
133 
135  {
136  return m_NtotLinSysIts;
137  }
138 
139 protected:
141 
144 
146 
149 
154 
155  bool m_ResidualUpdated = false;
156 
157  virtual void v_InitObject();
158 
159 private:
160 };
161 } // namespace LibUtilities
162 } // namespace Nektar
163 #endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
#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:129
void SetNekNonlinSysTolerance(const NekDouble in)
Definition: NekNonlinSys.h:108
Array< OneD, NekDouble > m_Residual
Definition: NekNonlinSys.h:151
const Array< OneD, const NekDouble > & GetRefSourceVec() const
Definition: NekNonlinSys.h:92
const NekLinSysIterSharedPtr & GetLinSys()
Definition: NekNonlinSys.h:119
static NekNonlinSysSharedPtr CreateInstance(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vComm, const int nDimen, const NekSysKey &pKey)
Definition: NekNonlinSys.h:60
void SetRefResidual(const Array< OneD, const NekDouble > &in)
Definition: NekNonlinSys.h:98
Array< OneD, NekDouble > m_DeltSltn
Definition: NekNonlinSys.h:152
void SetNonlinIterTolRelativeL2(const NekDouble in)
Definition: NekNonlinSys.h:124
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:153
NekLinSysIterSharedPtr m_linsol
Definition: NekNonlinSys.h:140
const Array< OneD, const NekDouble > & GetRefSolution() const
Definition: NekNonlinSys.h:80
const Array< OneD, const NekDouble > & GetRefResidual() const
Definition: NekNonlinSys.h:86
void SetNekNonlinSysMaxIterations(const unsigned int in)
Definition: NekNonlinSys.h:113
Array< OneD, NekDouble > m_Solution
Definition: NekNonlinSys.h:150
NekDouble m_tolerance
Tolerance of iterative solver.
Definition: NekSys.h:282
int m_SysDimen
The dimension of the system.
Definition: NekSys.h:295
int m_maxiter
Maximum iterations.
Definition: NekSys.h:280
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.
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
LibUtilities::NekFactory< std::string, NekNonlinSys, const LibUtilities::SessionReaderSharedPtr &, const LibUtilities::CommSharedPtr &, const int, const NekSysKey & > NekNonlinSysFactory
Definition: NekNonlinSys.h:53
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:1255