Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NavierStokesCFE.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File NavierStokesCFE.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: Navier Stokes equations in conservative variables
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 namespace Nektar
39 {
42  "NavierStokesCFE", NavierStokesCFE::create,
43  "NavierStokes equations in conservative variables.");
44 
47  : CompressibleFlowSystem(pSession)
48  {
49  }
50 
52  {
54 
55  if(m_session->DefinesSolverInfo("PROBLEMTYPE"))
56  {
57 
58  std::string ProblemTypeStr = m_session->GetSolverInfo("PROBLEMTYPE");
59  for(int i = 0; i < (int) SIZE_ProblemType; ++i)
60  {
61  if(NoCaseStringCompare(ProblemTypeMap[i],ProblemTypeStr) == 0)
62  {
64  break;
65  }
66  }
67  }
68  else
69  {
71  }
72 
74  {
77  }
78  else
79  {
80  ASSERTL0(false, "Implicit CFE not set up.");
81  }
82  }
83 
85  {
86 
87  }
88 
90  {
92  SolverUtils::AddSummaryItem(s, "Problem Type",
94  }
95 
97  NekDouble initialtime,
98  bool dumpInitialConditions,
99  const int domain)
100  {
101  EquationSystem::v_SetInitialConditions(initialtime, false);
102 
103  // insert white noise in initial condition
104  NekDouble Noise;
105  int phystot = m_fields[0]->GetTotPoints();
106  Array<OneD, NekDouble> noise(phystot);
107 
108  m_session->LoadParameter("Noise", Noise,0.0);
109  int m_nConvectiveFields = m_fields.num_elements();
110 
111  if (Noise > 0.0)
112  {
113  for (int i = 0; i < m_nConvectiveFields; i++)
114  {
115  Vmath::FillWhiteNoise(phystot, Noise, noise, 1,
116  m_comm->GetColumnComm()->GetRank()+1);
117  Vmath::Vadd(phystot, m_fields[i]->GetPhys(), 1,
118  noise, 1, m_fields[i]->UpdatePhys(), 1);
119  m_fields[i]->FwdTrans_IterPerExp(m_fields[i]->GetPhys(),
120  m_fields[i]->UpdateCoeffs());
121  }
122  }
123 
125 
126  if (dumpInitialConditions)
127  {
128  // Dump initial conditions to file
130  }
131  }
132 
134  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
135  Array<OneD, Array<OneD, NekDouble> > &outarray,
136  const NekDouble time)
137  {
138  int i;
139  int nvariables = inarray.num_elements();
140  int npoints = GetNpoints();
141 
142 
144  Array<OneD, Array<OneD, NekDouble> > outarrayAdv(nvariables);
145  Array<OneD, Array<OneD, NekDouble> > outarrayDiff(nvariables);
146 
147  Array<OneD, Array<OneD, NekDouble> > inarrayTemp(nvariables-1);
148  Array<OneD, Array<OneD, NekDouble> > inarrayDiff(nvariables-1);
149 
150  for (i = 0; i < nvariables; ++i)
151  {
152  outarrayAdv[i] = Array<OneD, NekDouble>(npoints, 0.0);
153  outarrayDiff[i] = Array<OneD, NekDouble>(npoints, 0.0);
154  }
155 
156  for (i = 0; i < nvariables-1; ++i)
157  {
158  inarrayTemp[i] = Array<OneD, NekDouble>(npoints, 0.0);
159  inarrayDiff[i] = Array<OneD, NekDouble>(npoints, 0.0);
160  }
161 
162  // Advection term in physical rhs form
163  m_advection->Advect(nvariables, m_fields, advVel, inarray,
164  outarrayAdv, time);
165 
166  // Extract pressure and temperature
167  Array<OneD, NekDouble > pressure (npoints, 0.0);
168  Array<OneD, NekDouble > temperature(npoints, 0.0);
169  GetPressure(inarray, pressure);
170  GetTemperature(inarray, pressure, temperature);
171 
172  // Extract velocities
173  for (i = 1; i < nvariables-1; ++i)
174  {
175  Vmath::Vdiv(npoints,
176  inarray[i], 1,
177  inarray[0], 1,
178  inarrayTemp[i-1], 1);
179  }
180 
181  // Copy velocities into new inarrayDiff
182  for (i = 0; i < nvariables-2; ++i)
183  {
184  Vmath::Vcopy(npoints, inarrayTemp[i], 1, inarrayDiff[i], 1);
185  }
186 
187  // Copy temperature into new inarrayDiffusion
188  Vmath::Vcopy(npoints,
189  temperature, 1,
190  inarrayDiff[nvariables-2], 1);
191 
192  // Diffusion term in physical rhs form
193  m_diffusion->Diffuse(nvariables, m_fields, inarrayDiff, outarrayDiff);
194 
195  for (i = 0; i < nvariables; ++i)
196  {
197  Vmath::Vsub(npoints,
198  outarrayDiff[i], 1,
199  outarrayAdv[i], 1,
200  outarray[i], 1);
201  }
202 
203  // Add sponge layer if defined in the session file
204  std::vector<SolverUtils::ForcingSharedPtr>::const_iterator x;
205  for (x = m_forcing.begin(); x != m_forcing.end(); ++x)
206  {
207  (*x)->Apply(m_fields, inarray, outarray, time);
208  }
209  }
210 
212  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
213  Array<OneD, Array<OneD, NekDouble> > &outarray,
214  const NekDouble time)
215  {
216  int i;
217  int nvariables = inarray.num_elements();
218 
219  switch(m_projectionType)
220  {
222  {
223  // Just copy over array
224  int npoints = GetNpoints();
225 
226  for(i = 0; i < nvariables; ++i)
227  {
228  Vmath::Vcopy(npoints, inarray[i], 1, outarray[i], 1);
229  }
230  SetBoundaryConditions(outarray, time);
231  break;
232  }
235  {
236  ASSERTL0(false, "No Continuous Galerkin for full compressible "
237  "Navier-Stokes equations");
238  break;
239  }
240  default:
241  ASSERTL0(false, "Unknown projection scheme");
242  break;
243  }
244  }
245 
247  Array<OneD, Array<OneD, NekDouble> > &inarray,
248  NekDouble time)
249  {
250  std::string varName;
251  int cnt = 0;
252 
253  // loop over Boundary Regions
254  for (int n = 0; n < m_fields[0]->GetBndConditions().num_elements(); ++n)
255  {
256  std::string type = m_fields[0]->GetBndConditions()[n]->GetUserDefined();
257  SetCommonBC(type,n,time,cnt,inarray);
258  }
259  }
260 }
virtual void v_InitObject()
Initialization object for CompressibleFlowSystem class.
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
virtual void v_InitObject()
Initialization object for CompressibleFlowSystem class.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:47
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
virtual void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
void GetTemperature(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &pressure, Array< OneD, NekDouble > &temperature)
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:227
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
LibUtilities::CommSharedPtr m_comm
Communicator.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
void SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble > > &physarray, NekDouble time)
SOLVER_UTILS_EXPORT int NoCaseStringCompare(const string &s1, const string &s2)
Perform a case-insensitive string comparison.
void SetCommonBC(const std::string &userDefStr, const int n, const NekDouble time, int &cnt, Array< OneD, Array< OneD, NekDouble > > &inarray)
Set boundary conditions which can be: a) Wall and Symmerty BCs implemented at CompressibleFlowSystem ...
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:50
int m_spacedim
Spatial dimension (>= expansion dim).
double NekDouble
Length of enum list.
Definition: EulerADCFE.h:47
EquationSystemFactory & GetEquationSystemFactory()
SolverUtils::AdvectionSharedPtr m_advection
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.
Definition: Vmath.cpp:329
SolverUtils::DiffusionSharedPtr m_diffusion
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
virtual void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
void FillWhiteNoise(int n, const T eps, T *x, const int incx, int outseed)
Fills a vector with white noise.
Definition: Vmath.cpp:138
SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr GetPressure()
Get pressure field if available.
static std::string className
ProblemType
Definition: EulerADCFE.h:44
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
NavierStokesCFE(const LibUtilities::SessionReaderSharedPtr &pSession)
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.
Definition: Vmath.cpp:285
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215
const char *const ProblemTypeMap[]
Definition: EulerADCFE.h:50