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,
160  outarrayAdv, time);
161 
162  for (i = 0; i < nvariables; ++i)
163  {
164  Vmath::Neg(npoints, outarrayAdv[i], 1);
165  }
166 
167  // Extract pressure and temperature
168  Array<OneD, NekDouble > pressure (npoints, 0.0);
169  Array<OneD, NekDouble > temperature(npoints, 0.0);
170  GetPressure(inarray, pressure);
171  GetTemperature(inarray, pressure, temperature);
172 
173  // Extract velocities
174  for (i = 1; i < nvariables-1; ++i)
175  {
176  Vmath::Vdiv(npoints,
177  inarray[i], 1,
178  inarray[0], 1,
179  inarrayTemp[i-1], 1);
180  }
181 
182  // Copy velocities into new inarrayDiff
183  for (i = 0; i < nvariables-2; ++i)
184  {
185  Vmath::Vcopy(npoints, inarrayTemp[i], 1, inarrayDiff[i], 1);
186  }
187 
188  // Copy temperature into new inarrayDiffusion
189  Vmath::Vcopy(npoints,
190  temperature, 1,
191  inarrayDiff[nvariables-2], 1);
192 
193  // Diffusion term in physical rhs form
194  m_diffusion->Diffuse(nvariables, m_fields, inarrayDiff, outarrayDiff);
195 
196  for (i = 0; i < nvariables; ++i)
197  {
198  Vmath::Vadd(npoints,
199  outarrayAdv[i], 1,
200  outarrayDiff[i], 1,
201  outarray[i], 1);
202  }
203  }
204 
206  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
207  Array<OneD, Array<OneD, NekDouble> > &outarray,
208  const NekDouble time)
209  {
210  int i;
211  int nvariables = inarray.num_elements();
212 
213  switch(m_projectionType)
214  {
216  {
217  // Just copy over array
218  int npoints = GetNpoints();
219 
220  for(i = 0; i < nvariables; ++i)
221  {
222  Vmath::Vcopy(npoints, inarray[i], 1, outarray[i], 1);
223  }
224  SetBoundaryConditions(outarray, time);
225  break;
226  }
229  {
230  ASSERTL0(false, "No Continuous Galerkin for full compressible "
231  "Navier-Stokes equations");
232  break;
233  }
234  default:
235  ASSERTL0(false, "Unknown projection scheme");
236  break;
237  }
238  }
239 
241  Array<OneD, Array<OneD, NekDouble> > &inarray,
242  NekDouble time)
243  {
244  std::string varName;
245  int nvariables = m_fields.num_elements();
246  int cnt = 0;
247 
248  // loop over Boundary Regions
249  for (int n = 0; n < m_fields[0]->GetBndConditions().num_elements(); ++n)
250  {
251  // Wall Boundary Condition
252  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
254  {
255  ASSERTL0(false, "Wall is a wrong bc for the full "
256  "compressible Navier-Stokes equations");
257  }
258 
259  // Wall Boundary Condition
260  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
262  {
263  WallViscousBC(n, cnt, inarray);
264  }
265 
266  // Symmetric Boundary Condition
267  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
269  {
270  SymmetryBC(n, cnt, inarray);
271  }
272 
273  // Riemann invariant characteristic Boundary Condition (CBC)
274  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
276  {
277  RiemannInvariantBC(n, cnt, inarray);
278  }
279 
280  // Extrapolation of the data at the boundaries
281  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
283  {
284  ExtrapOrder0BC(n, cnt, inarray);
285  }
286 
287  // Time Dependent Boundary Condition (specified in meshfile)
288  if (m_fields[0]->GetBndConditions()[n]->GetUserDefined()
290  {
291  for (int i = 0; i < nvariables; ++i)
292  {
293  varName = m_session->GetVariable(i);
294  m_fields[i]->EvaluateBoundaryConditions(time, varName);
295  }
296  }
297 
298  cnt += m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
299  }
300  }
301 }