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:
61  const LibUtilities::CommSharedPtr &vComm, const int nDimen,
62  const NekSysKey &pKey);
64 
66  const
67  {
68  return m_Solution;
69  }
70 
72  const
73  {
74  return m_Residual;
75  }
76 
78  const
79  {
80  return m_SourceVec;
81  }
82 
85  {
86  ASSERTL0(in.size() == m_SysDimen,
87  "SetRefResidual dimension not correct");
89 
90  m_ResidualUpdated = true;
91  }
92 
94  {
95  m_tolerance = in;
96  }
97 
99  const unsigned int in)
100  {
101  m_maxiter = in;
102  }
103 
105  {
106  return m_linsol;
107  }
108 
110  {
112  }
113 
115  {
117  }
118 
120  {
121  return m_NtotLinSysIts;
122  }
123 
125  const int nGlobal, const Array<OneD, const NekDouble> &pInput,
126  const Array<OneD, const NekDouble> &pSource, const int nDir)
127  {
128  v_SetupNekNonlinSystem(nGlobal, pInput, pSource, nDir);
129  }
130 
131 protected:
133 
136 
138 
141 
146 
147  bool m_ResidualUpdated = false;
148 
149  virtual void v_InitObject();
150 
152  const int nGlobal, const Array<OneD, const NekDouble> &pInput,
153  const Array<OneD, const NekDouble> &pSource, const int nDir) = 0;
154 
155 private:
156 };
157 } // namespace LibUtilities
158 } // namespace Nektar
159 #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 SetupNekNonlinSystem(const int nGlobal, const Array< OneD, const NekDouble > &pInput, const Array< OneD, const NekDouble > &pSource, const int nDir)
Definition: NekNonlinSys.h:124
void SetLinSysRelativeTolInNonlin(const NekDouble in)
Definition: NekNonlinSys.h:114
void SetNekNonlinSysTolerance(const NekDouble in)
Definition: NekNonlinSys.h:93
Array< OneD, NekDouble > m_Residual
Definition: NekNonlinSys.h:143
const Array< OneD, const NekDouble > & GetRefSourceVec() const
Definition: NekNonlinSys.h:77
const NekLinSysIterSharedPtr & GetLinSys()
Definition: NekNonlinSys.h:104
void SetRefResidual(const Array< OneD, const NekDouble > &in)
Definition: NekNonlinSys.h:83
Array< OneD, NekDouble > m_DeltSltn
Definition: NekNonlinSys.h:144
void SetNonlinIterTolRelativeL2(const NekDouble in)
Definition: NekNonlinSys.h:109
Array< OneD, NekDouble > m_SourceVec
Definition: NekNonlinSys.h:145
NekLinSysIterSharedPtr m_linsol
Definition: NekNonlinSys.h:132
const Array< OneD, const NekDouble > & GetRefSolution() const
Definition: NekNonlinSys.h:65
virtual void v_SetupNekNonlinSystem(const int nGlobal, const Array< OneD, const NekDouble > &pInput, const Array< OneD, const NekDouble > &pSource, const int nDir)=0
const Array< OneD, const NekDouble > & GetRefResidual() const
Definition: NekNonlinSys.h:71
void SetNekNonlinSysMaxIterations(const unsigned int in)
Definition: NekNonlinSys.h:98
Array< OneD, NekDouble > m_Solution
Definition: NekNonlinSys.h:142
NekDouble m_tolerance
Tolerance of iterative solver.
Definition: NekSys.h:278
int m_SysDimen
The dimension of the system.
Definition: NekSys.h:291
int m_maxiter
Maximum iterations.
Definition: NekSys.h:276
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:2
double NekDouble
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1255