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  int i;
60  for(i = 0; i < (int) SIZE_ProblemType; ++i)
61  {
62  if(NoCaseStringCompare(ProblemTypeMap[i],ProblemTypeStr) == 0)
63  {
65  break;
66  }
67  }
68  }
69  else
70  {
72  }
73 
75  {
78  }
79  else
80  {
81  ASSERTL0(false, "Implicit CFE not set up.");
82  }
83  }
84 
86  {
87 
88  }
89 
91  {
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,m_comm->GetColumnComm()->GetRank()+1);
116  Vmath::Vadd(phystot,m_fields[i]->GetPhys(),1,noise,1,m_fields[i]->UpdatePhys(),1);
117  m_fields[i]->FwdTrans_IterPerExp(m_fields[i]->GetPhys(),m_fields[i]->UpdateCoeffs());
118  }
119  }
120 
121 
122  if (dumpInitialConditions)
123  {
124  // Dump initial conditions to file
126  }
127  }
128 
130  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
131  Array<OneD, Array<OneD, NekDouble> > &outarray,
132  const NekDouble time)
133  {
134  int i;
135  int nvariables = inarray.num_elements();
136  int npoints = GetNpoints();
137 
138 
139  Array<OneD, Array<OneD, NekDouble> > advVel(m_spacedim);
140  Array<OneD, Array<OneD, NekDouble> > outarrayAdv(nvariables);
141  Array<OneD, Array<OneD, NekDouble> > outarrayDiff(nvariables);
142 
143  Array<OneD, Array<OneD, NekDouble> > inarrayTemp(nvariables-1);
144  Array<OneD, Array<OneD, NekDouble> > inarrayDiff(nvariables-1);
145 
146  for (i = 0; i < nvariables; ++i)
147  {
148  outarrayAdv[i] = Array<OneD, NekDouble>(npoints, 0.0);
149  outarrayDiff[i] = Array<OneD, NekDouble>(npoints, 0.0);
150  }
151 
152  for (i = 0; i < nvariables-1; ++i)
153  {
154  inarrayTemp[i] = Array<OneD, NekDouble>(npoints, 0.0);
155  inarrayDiff[i] = Array<OneD, NekDouble>(npoints, 0.0);
156  }
157 
158  // Advection term in physical rhs form
159  m_advection->Advect(nvariables, m_fields, advVel, inarray, outarrayAdv);
160 
161  for (i = 0; i < nvariables; ++i)
162  {
163  Vmath::Neg(npoints, outarrayAdv[i], 1);
164  }
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::Vadd(npoints,
198  outarrayAdv[i], 1,
199  outarrayDiff[i], 1,
200  outarray[i], 1);
201  }
202  }
203 
205  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
206  Array<OneD, Array<OneD, NekDouble> > &outarray,
207  const NekDouble time)
208  {
209  int i;
210  int nvariables = inarray.num_elements();
211 
212  switch(m_projectionType)
213  {
215  {
216  // Just copy over array
217  int npoints = GetNpoints();
218 
219  for(i = 0; i < nvariables; ++i)
220  {
221  Vmath::Vcopy(npoints, inarray[i], 1, outarray[i], 1);
222  }
223  SetBoundaryConditions(outarray, time);
224  break;
225  }
228  {
229  ASSERTL0(false, "No Continuous Galerkin for full compressible "
230  "Navier-Stokes equations");
231  break;
232  }
233  default:
234  ASSERTL0(false, "Unknown projection scheme");
235  break;
236  }
237  }
238 
240  Array<OneD, Array<OneD, NekDouble> > &inarray,
241  NekDouble time)
242  {
243  std::string varName;
244  int nvariables = m_fields.num_elements();
245  int cnt = 0;
246 
247  // loop over Boundary Regions
248  for (int n = 0; n < m_fields[0]->GetBndConditions().num_elements(); ++n)
249  {
250  // Wall Boundary Condition
251  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
253  {
254  ASSERTL0(false, "Wall is a wrong bc for the full "
255  "compressible Navier-Stokes equations");
256  }
257 
258  // Wall Boundary Condition
259  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
261  {
262  WallViscousBC(n, cnt, inarray);
263  }
264 
265  // Symmetric Boundary Condition
266  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
268  {
269  SymmetryBC(n, cnt, inarray);
270  }
271 
272  // Riemann invariant characteristic Boundary Condition (CBC)
273  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
275  {
276  RiemannInvariantBC(n, cnt, inarray);
277  }
278 
279  // Extrapolation of the data at the boundaries
280  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
282  {
283  ExtrapOrder0BC(n, cnt, inarray);
284  }
285 
286  // Time Dependent Boundary Condition (specified in meshfile)
287  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined()
289  {
290  for (int i = 0; i < nvariables; ++i)
291  {
292  varName = m_session->GetVariable(i);
293  m_fields[i]->EvaluateBoundaryConditions(time, varName);
294  }
295  }
296 
297  cnt += m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
298  }
299  }
300 }