Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Driver.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File Driver.cpp
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: Base class for Drivers
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include <SolverUtils/Driver.h>
37 
38 namespace Nektar
39 {
40 namespace SolverUtils
41 {
42 
43 std::string Driver::evolutionOperatorLookupIds[6] = {
45  "EvolutionOperator","Nonlinear" ,eNonlinear),
47  "EvolutionOperator","Direct" ,eDirect),
49  "EvolutionOperator","Adjoint" ,eAdjoint),
51  "EvolutionOperator","TransientGrowth",eTransientGrowth),
53  "EvolutionOperator","SkewSymmetric" ,eSkewSymmetric),
55  "EvolutionOperator","AdaptiveSFD" ,eAdaptiveSFD)
56 };
57 std::string Driver::evolutionOperatorDef =
59  "EvolutionOperator","Nonlinear");
60 std::string Driver::driverDefault =
62  "Driver", "Standard");
63 
65 {
66  typedef Loki::SingletonHolder<DriverFactory,
67  Loki::CreateUsingNew,
68  Loki::NoDestroy > Type;
69  return Type::Instance();
70 }
71 
72 /**
73  *
74  */
76  : m_comm(pSession->GetComm()),
77  m_session(pSession)
78 {
79 }
80 
82 
83 {
84 }
85 
86 /**
87  *
88  */
89 void Driver::v_InitObject(ostream &out)
90 {
91  try
92  {
93  // Retrieve the equation system to solve.
94  ASSERTL0(m_session->DefinesSolverInfo("EqType"),
95  "EqType SolverInfo tag must be defined.");
96  std::string vEquation = m_session->GetSolverInfo("EqType");
97  if (m_session->DefinesSolverInfo("SolverType"))
98  {
99  vEquation = m_session->GetSolverInfo("SolverType");
100  }
101 
102  // Check such a module exists for this equation.
103  ASSERTL0(GetEquationSystemFactory().ModuleExists(vEquation),
104  "EquationSystem '" + vEquation + "' is not defined.\n"
105  "Ensure equation name is correct and module is compiled.\n");
106 
107  // Retrieve the type of evolution operator to use
108  /// @todo At the moment this is Navier-Stokes specific - generalise?
110  m_session->GetSolverInfoAsEnum<EvolutionOperatorType>(
111  "EvolutionOperator");
112 
114  m_EvolutionOperator == eAdaptiveSFD) ? 2 : 1);
115 
116  m_equ = Array<OneD, EquationSystemSharedPtr>(m_nequ);
117 
118  // Set the AdvectiveType tag and create EquationSystem objects.
119  switch (m_EvolutionOperator)
120  {
121  case eNonlinear:
122  m_session->SetTag("AdvectiveType","Convective");
124  vEquation, m_session);
125  break;
126  case eDirect:
127  m_session->SetTag("AdvectiveType","Linearised");
129  vEquation, m_session);
130  break;
131  case eAdjoint:
132  m_session->SetTag("AdvectiveType","Adjoint");
134  vEquation, m_session);
135  break;
136  case eTransientGrowth:
137  //forward timestepping
138  m_session->SetTag("AdvectiveType","Linearised");
140  vEquation, m_session);
141 
142  //backward timestepping
143  m_session->SetTag("AdvectiveType","Adjoint");
145  vEquation, m_session);
146  break;
147  case eSkewSymmetric:
148  m_session->SetTag("AdvectiveType","SkewSymmetric");
150  vEquation, m_session);
151  break;
152  case eAdaptiveSFD:
153  {
154  // Coupling SFD method and Arnoldi algorithm
155  // For having 2 equation systems defined into 2 different
156  // session files (with the mesh into a file named 'session'.gz)
157  string meshfile;
158  string LinNSCondFile;
159  vector<string> LinNSFilename;
160  meshfile = m_session->GetSessionName() + ".gz";
161  LinNSCondFile = m_session->GetSessionName();
162  LinNSCondFile += "_LinNS.xml";
163  LinNSFilename.push_back(meshfile);
164  LinNSFilename.push_back(LinNSCondFile);
166  0, NULL, LinNSFilename, m_session->GetComm());
167 
168  //For running stability analysis
169  session_LinNS->SetTag("AdvectiveType","Linearised");
171  vEquation, session_LinNS);
172 
173  //For running the SFD method on the nonlinear problem
174  m_session->SetTag("AdvectiveType","Convective");
176  vEquation, m_session);
177  }
178  break;
179  default:
180  ASSERTL0(false, "Unrecognised evolution operator.");
181 
182  }
183  }
184  catch (int e)
185  {
186  ASSERTL0(e == -1, "No such class class defined.");
187  out << "An error occurred during driver initialisation." << endl;
188  }
189 }
190 
191 Array<OneD, NekDouble> Driver::v_GetRealEvl(void)
192 {
193  ASSERTL0(false,"This routine is not valid in this class");
194  return NullNekDouble1DArray;
195 }
196 
197 Array<OneD, NekDouble> Driver::v_GetImagEvl(void)
198 {
199  ASSERTL0(false,"This routine is not valid in this class");
200  return NullNekDouble1DArray;
201 }
202 
203 }
204 }