Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NonlinearSWE.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File NonlinearSWE.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: Nonlinear Shallow water equations in conservative variables
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include <iostream>
37 #include <iomanip>
38 #include <boost/algorithm/string.hpp>
39 
42 
43 namespace Nektar
44 {
45  string NonlinearSWE::className =
47  "NonlinearSWE", NonlinearSWE::create,
48  "Nonlinear shallow water equation in conservative variables.");
49 
52  : ShallowWaterSystem(pSession)
53  {
54  }
55 
57  {
59 
61  {
64  }
65  else
66  {
67  ASSERTL0(false, "Implicit SWE not set up.");
68  }
69 
70  // Type of advection class to be used
71  switch(m_projectionType)
72  {
73  // Continuous field
75  {
76  // Do nothing
77  break;
78  }
79  // Discontinuous field
81  {
82  string advName;
83  string diffName;
84  string riemName;
85 
86  //---------------------------------------------------------------
87  // Setting up advection and diffusion operators
88  // NB: diffusion not set up for SWE at the moment
89  // but kept here for future use ...
90  m_session->LoadSolverInfo("AdvectionType", advName, "WeakDG");
91  // m_session->LoadSolverInfo("DiffusionType", diffName, "LDGEddy");
93  .CreateInstance(advName, advName);
94  // m_diffusion = SolverUtils::GetDiffusionFactory()
95  // .CreateInstance(diffName, diffName);
96 
97  m_advection->SetFluxVector(&NonlinearSWE::GetFluxVector, this);
98  // m_diffusion->SetFluxVectorNS(&ShallowWaterSystem::
99  // GetEddyViscosityFluxVector, this);
100 
101  // Setting up Riemann solver for advection operator
102  m_session->LoadSolverInfo("UpwindType", riemName, "Average");
104  .CreateInstance(riemName);
105 
106  // Setting up upwind solver for diffusion operator
107  // m_riemannSolverLDG = SolverUtils::GetRiemannSolverFactory()
108  // .CreateInstance("UpwindLDG");
109 
110  // Setting up parameters for advection operator Riemann solver
111  m_riemannSolver->SetParam (
112  "gravity",
113  &NonlinearSWE::GetGravity, this);
114  m_riemannSolver->SetAuxVec(
115  "vecLocs",
116  &NonlinearSWE::GetVecLocs, this);
117  m_riemannSolver->SetVector(
118  "N",
119  &NonlinearSWE::GetNormals, this);
120  m_riemannSolver->SetScalar(
121  "depth",
122  &NonlinearSWE::GetDepth, this);
123 
124  // Setting up parameters for diffusion operator Riemann solver
125  // m_riemannSolverLDG->AddParam (
126  // "gravity",
127  // &NonlinearSWE::GetGravity, this);
128  // m_riemannSolverLDG->SetAuxVec(
129  // "vecLocs",
130  // &NonlinearSWE::GetVecLocs, this);
131  // m_riemannSolverLDG->AddVector(
132  // "N",
133  // &NonlinearSWE::GetNormals, this);
134 
135  // Concluding initialisation of advection / diffusion operators
136  m_advection->SetRiemannSolver (m_riemannSolver);
137  //m_diffusion->SetRiemannSolver (m_riemannSolverLDG);
138  m_advection->InitObject (m_session, m_fields);
139  //m_diffusion->InitObject (m_session, m_fields);
140  break;
141  }
142  default:
143  {
144  ASSERTL0(false, "Unsupported projection type.");
145  break;
146  }
147  }
148 
149 
150  }
151 
153  {
154 
155  }
156 
157  // physarray contains the conservative variables
159  Array<OneD, Array<OneD, NekDouble> > &outarray)
160  {
161 
162  int ncoeffs = GetNcoeffs();
163  int nq = GetTotPoints();
164 
165  Array<OneD, NekDouble> tmp(nq);
166  Array<OneD, NekDouble> mod(ncoeffs);
167 
168  switch(m_projectionType)
169  {
171  {
172  // add to hu equation
173  Vmath::Vmul(nq,m_coriolis,1,physarray[2],1,tmp,1);
174  m_fields[0]->IProductWRTBase(tmp,mod);
175  m_fields[0]->MultiplyByElmtInvMass(mod,mod);
176  m_fields[0]->BwdTrans(mod,tmp);
177  Vmath::Vadd(nq,tmp,1,outarray[1],1,outarray[1],1);
178 
179  // add to hv equation
180  Vmath::Vmul(nq,m_coriolis,1,physarray[1],1,tmp,1);
181  Vmath::Neg(nq,tmp,1);
182  m_fields[0]->IProductWRTBase(tmp,mod);
183  m_fields[0]->MultiplyByElmtInvMass(mod,mod);
184  m_fields[0]->BwdTrans(mod,tmp);
185  Vmath::Vadd(nq,tmp,1,outarray[2],1,outarray[2],1);
186  }
187  break;
190  {
191  // add to hu equation
192  Vmath::Vmul(nq,m_coriolis,1,physarray[2],1,tmp,1);
193  Vmath::Vadd(nq,tmp,1,outarray[1],1,outarray[1],1);
194 
195  // add to hv equation
196  Vmath::Vmul(nq,m_coriolis,1,physarray[1],1,tmp,1);
197  Vmath::Neg(nq,tmp,1);
198  Vmath::Vadd(nq,tmp,1,outarray[2],1,outarray[2],1);
199  }
200  break;
201  default:
202  ASSERTL0(false,"Unknown projection scheme for the NonlinearSWE");
203  break;
204  }
205 
206 
207  }
208 
209 
210  // physarray contains the conservative variables
212  Array<OneD, Array<OneD, NekDouble> > &outarray)
213  {
214 
215  int ncoeffs = GetNcoeffs();
216  int nq = GetTotPoints();
217 
218  Array<OneD, NekDouble> tmp(nq);
219  Array<OneD, NekDouble> mod(ncoeffs);
220 
221  switch(m_projectionType)
222  {
224  {
225  for (int i = 0; i < m_spacedim; ++i)
226  {
227  Vmath::Vmul(nq,m_bottomSlope[i],1,physarray[0],1,tmp,1);
228  Vmath::Smul(nq,m_g,tmp,1,tmp,1);
229  m_fields[0]->IProductWRTBase(tmp,mod);
230  m_fields[0]->MultiplyByElmtInvMass(mod,mod);
231  m_fields[0]->BwdTrans(mod,tmp);
232  Vmath::Vadd(nq,tmp,1,outarray[i+1],1,outarray[i+1],1);
233  }
234  }
235  break;
238  {
239  for (int i = 0; i < m_spacedim; ++i)
240  {
241  Vmath::Vmul(nq,m_bottomSlope[i],1,physarray[0],1,tmp,1);
242  Vmath::Smul(nq,m_g,tmp,1,tmp,1);
243  Vmath::Vadd(nq,tmp,1,outarray[i+1],1,outarray[i+1],1);
244  }
245  }
246  break;
247  default:
248  ASSERTL0(false,"Unknown projection scheme for the NonlinearSWE");
249  break;
250  }
251 
252 
253  }
254 
256  Array<OneD, Array<OneD, NekDouble> >&outarray,
257  const NekDouble time)
258  {
259  int i, j;
260  int ndim = m_spacedim;
261  int nvariables = inarray.num_elements();
262  int nq = GetTotPoints();
263 
264 
265  switch(m_projectionType)
266  {
268  {
269 
270  //-------------------------------------------------------
271  // Compute the DG advection including the numerical flux
272  // by using SolverUtils/Advection
273  // Input and output in physical space
275 
276  m_advection->Advect(nvariables, m_fields, advVel, inarray,
277  outarray, time);
278  //-------------------------------------------------------
279 
280 
281  //-------------------------------------------------------
282  // negate the outarray since moving terms to the rhs
283  for(i = 0; i < nvariables; ++i)
284  {
285  Vmath::Neg(nq,outarray[i],1);
286  }
287  //-------------------------------------------------------
288 
289 
290  //-------------------------------------------------
291  // Add "source terms"
292  // Input and output in physical space
293 
294  // Coriolis forcing
295  if (m_coriolis.num_elements() != 0)
296  {
297  AddCoriolis(inarray,outarray);
298  }
299 
300  // Variable Depth
301  if (m_constantDepth != true)
302  {
303  AddVariableDepth(inarray,outarray);
304  }
305  //-------------------------------------------------
306 
307  }
308  break;
311  {
312 
313  //-------------------------------------------------------
314  // Compute the fluxvector in physical space
316  fluxvector(nvariables);
317 
318  for (i = 0; i < nvariables; ++i)
319  {
320  fluxvector[i] = Array<OneD, Array<OneD, NekDouble> >(ndim);
321  for(j = 0; j < ndim; ++j)
322  {
323  fluxvector[i][j] = Array<OneD, NekDouble>(nq);
324  }
325  }
326 
327  NonlinearSWE::GetFluxVector(inarray, fluxvector);
328  //-------------------------------------------------------
329 
330 
331 
332  //-------------------------------------------------------
333  // Take the derivative of the flux terms
334  // and negate the outarray since moving terms to the rhs
335  Array<OneD,NekDouble> tmp(nq);
336  Array<OneD, NekDouble>tmp1(nq);
337 
338  for(i = 0; i < nvariables; ++i)
339  {
340  m_fields[i]->PhysDeriv(MultiRegions::DirCartesianMap[0],fluxvector[i][0],tmp);
341  m_fields[i]->PhysDeriv(MultiRegions::DirCartesianMap[1],fluxvector[i][1],tmp1);
342  Vmath::Vadd(nq,tmp,1,tmp1,1,outarray[i],1);
343  Vmath::Neg(nq,outarray[i],1);
344  }
345 
346 
347  //-------------------------------------------------
348  // Add "source terms"
349  // Input and output in physical space
350 
351  // Coriolis forcing
352  if (m_coriolis.num_elements() != 0)
353  {
354  AddCoriolis(inarray,outarray);
355  }
356 
357  // Variable Depth
358  if (m_constantDepth != true)
359  {
360  AddVariableDepth(inarray,outarray);
361  }
362  //-------------------------------------------------
363  }
364  break;
365  default:
366  ASSERTL0(false,"Unknown projection scheme for the NonlinearSWE");
367  break;
368  }
369  }
370 
371 
373  Array<OneD, Array<OneD, NekDouble> >&outarray,
374  const NekDouble time)
375  {
376  int i;
377  int nvariables = inarray.num_elements();
378 
379 
380  switch(m_projectionType)
381  {
383  {
384 
385  // Just copy over array
386  int npoints = GetNpoints();
387 
388  for(i = 0; i < nvariables; ++i)
389  {
390  Vmath::Vcopy(npoints, inarray[i], 1, outarray[i], 1);
391  }
392  SetBoundaryConditions(outarray, time);
393  break;
394  }
397  {
398 
399  EquationSystem::SetBoundaryConditions(time);
401 
402  for(i = 0; i < nvariables; ++i)
403  {
404  m_fields[i]->FwdTrans(inarray[i],coeffs);
405  m_fields[i]->BwdTrans_IterPerExp(coeffs,outarray[i]);
406  }
407  break;
408  }
409  default:
410  ASSERTL0(false,"Unknown projection scheme");
411  break;
412  }
413  }
414 
415 
416  //----------------------------------------------------
418  Array<OneD, Array<OneD, NekDouble> > &inarray,
419  NekDouble time)
420  {
421  std::string varName;
422  int nvariables = m_fields.num_elements();
423  int cnt = 0;
424  int nTracePts = GetTraceTotPoints();
425 
426  // Extract trace for boundaries. Needs to be done on all processors to avoid
427  // deadlock.
428  Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
429  for (int i = 0; i < nvariables; ++i)
430  {
431  Fwd[i] = Array<OneD, NekDouble>(nTracePts);
432  m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
433  }
434 
435  // Loop over Boundary Regions
436  for (int n = 0; n < m_fields[0]->GetBndConditions().num_elements(); ++n)
437  {
438 
439  // Wall Boundary Condition
440  if (boost::iequals(m_fields[0]->GetBndConditions()[n]->GetUserDefined(),"Wall"))
441  {
442  WallBoundary2D(n, cnt, Fwd, inarray);
443  }
444 
445  // Time Dependent Boundary Condition (specified in meshfile)
446  if (m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
447  {
448  for (int i = 0; i < nvariables; ++i)
449  {
450  varName = m_session->GetVariable(i);
451  m_fields[i]->EvaluateBoundaryConditions(time, varName);
452  }
453  }
454  cnt += m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
455  }
456  }
457 
458  //----------------------------------------------------
459  /**
460  * @brief Wall boundary condition.
461  */
463  int bcRegion,
464  int cnt,
466  Array<OneD, Array<OneD, NekDouble> > &physarray)
467  {
468  int i;
469  int nvariables = physarray.num_elements();
470 
471  // Adjust the physical values of the trace to take
472  // user defined boundaries into account
473  int e, id1, id2, npts;
474 
475  for (e = 0; e < m_fields[0]->GetBndCondExpansions()[bcRegion]
476  ->GetExpSize(); ++e)
477  {
478  npts = m_fields[0]->GetBndCondExpansions()[bcRegion]->
479  GetExp(e)->GetTotPoints();
480  id1 = m_fields[0]->GetBndCondExpansions()[bcRegion]->
481  GetPhys_Offset(e);
482  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(
483  m_fields[0]->GetTraceMap()->
484  GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
485 
486  // For 2D/3D, define: v* = v - 2(v.n)n
487  Array<OneD, NekDouble> tmp(npts, 0.0);
488 
489  // Calculate (v.n)
490  for (i = 0; i < m_spacedim; ++i)
491  {
492  Vmath::Vvtvp(npts,
493  &Fwd[1+i][id2], 1,
494  &m_traceNormals[i][id2], 1,
495  &tmp[0], 1,
496  &tmp[0], 1);
497  }
498 
499  // Calculate 2.0(v.n)
500  Vmath::Smul(npts, -2.0, &tmp[0], 1, &tmp[0], 1);
501 
502  // Calculate v* = v - 2.0(v.n)n
503  for (i = 0; i < m_spacedim; ++i)
504  {
505  Vmath::Vvtvp(npts,
506  &tmp[0], 1,
507  &m_traceNormals[i][id2], 1,
508  &Fwd[1+i][id2], 1,
509  &Fwd[1+i][id2], 1);
510  }
511 
512  // copy boundary adjusted values into the boundary expansion
513  for (i = 0; i < nvariables; ++i)
514  {
515  Vmath::Vcopy(npts, &Fwd[i][id2], 1,
516  &(m_fields[i]->GetBndCondExpansions()[bcRegion]->
517  UpdatePhys())[id1], 1);
518  }
519  }
520  }
521 
522 
524  {
525 
526  int i;
527  int nvariables = physarray.num_elements();
528 
529  // Adjust the physical values of the trace to take
530  // user defined boundaries into account
531  int e, id1, id2, npts;
532 
533  for(e = 0; e < m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize(); ++e)
534  {
535  npts = m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExp(e)->GetNumPoints(0);
536  id1 = m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e) ;
537  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
538 
539  switch(m_expdim)
540  {
541  case 1:
542  {
543  // negate the forward flux
544  Vmath::Neg(npts,&Fwd[1][id2],1);
545  }
546  break;
547  case 2:
548  {
549  Array<OneD, NekDouble> tmp_n(npts);
550  Array<OneD, NekDouble> tmp_t(npts);
551 
552  Vmath::Vmul(npts,&Fwd[1][id2],1,&m_traceNormals[0][id2],1,&tmp_n[0],1);
553  Vmath::Vvtvp(npts,&Fwd[2][id2],1,&m_traceNormals[1][id2],1,&tmp_n[0],1,&tmp_n[0],1);
554 
555  Vmath::Vmul(npts,&Fwd[1][id2],1,&m_traceNormals[1][id2],1,&tmp_t[0],1);
556  Vmath::Vvtvm(npts,&Fwd[2][id2],1,&m_traceNormals[0][id2],1,&tmp_t[0],1,&tmp_t[0],1);
557 
558  // negate the normal flux
559  Vmath::Neg(npts,tmp_n,1);
560 
561  // rotate back to Cartesian
562  Vmath::Vmul(npts,&tmp_t[0],1,&m_traceNormals[1][id2],1,&Fwd[1][id2],1);
563  Vmath::Vvtvm(npts,&tmp_n[0],1,&m_traceNormals[0][id2],1,&Fwd[1][id2],1,&Fwd[1][id2],1);
564 
565  Vmath::Vmul(npts,&tmp_t[0],1,&m_traceNormals[0][id2],1,&Fwd[2][id2],1);
566  Vmath::Vvtvp(npts,&tmp_n[0],1,&m_traceNormals[1][id2],1,&Fwd[2][id2],1,&Fwd[2][id2],1);
567  }
568  break;
569  case 3:
570  ASSERTL0(false,"3D not implemented for Shallow Water Equations");
571  break;
572  default:
573  ASSERTL0(false,"Illegal expansion dimension");
574  }
575 
576 
577 
578  // copy boundary adjusted values into the boundary expansion
579  for (i = 0; i < nvariables; ++i)
580  {
581  Vmath::Vcopy(npts,&Fwd[i][id2], 1,&(m_fields[i]->GetBndCondExpansions()[bcRegion]->UpdatePhys())[id1],1);
582  }
583  }
584  }
585 
586 
587  // Physfield in conservative Form
589  const Array<OneD, const Array<OneD, NekDouble> > &physfield,
591  {
592  int i, j;
593  int nq = m_fields[0]->GetTotPoints();
594 
595  NekDouble g = m_g;
597 
598  // Flux vector for the mass equation
599  for (i = 0; i < m_spacedim; ++i)
600  {
601  velocity[i] = Array<OneD, NekDouble>(nq);
602  Vmath::Vcopy(nq, physfield[i+1], 1, flux[0][i], 1);
603  }
604 
605  GetVelocityVector(physfield, velocity);
606 
607  // Put (0.5 g h h) in tmp
608  Array<OneD, NekDouble> tmp(nq);
609  Vmath::Vmul(nq, physfield[0], 1, physfield[0], 1, tmp, 1);
610  Vmath::Smul(nq, 0.5*g, tmp, 1, tmp, 1);
611 
612  // Flux vector for the momentum equations
613  for (i = 0; i < m_spacedim; ++i)
614  {
615  for (j = 0; j < m_spacedim; ++j)
616  {
617  Vmath::Vmul(nq, velocity[j], 1, physfield[i+1], 1,
618  flux[i+1][j], 1);
619  }
620 
621  // Add (0.5 g h h) to appropriate field
622  Vmath::Vadd(nq, flux[i+1][i], 1, tmp, 1, flux[i+1][i], 1);
623  }
624 
625  }
626 
628  Array<OneD, Array<OneD, NekDouble> >&physout)
629  {
630  int nq = GetTotPoints();
631 
632  if(physin.get() == physout.get())
633  {
634  // copy indata and work with tmp array
636  for (int i = 0; i < 3; ++i)
637  {
638  // deep copy
639  tmp[i] = Array<OneD, NekDouble>(nq);
640  Vmath::Vcopy(nq,physin[i],1,tmp[i],1);
641  }
642 
643  // \eta = h - d
644  Vmath::Vsub(nq,tmp[0],1,m_depth,1,physout[0],1);
645 
646  // u = hu/h
647  Vmath::Vdiv(nq,tmp[1],1,tmp[0],1,physout[1],1);
648 
649  // v = hv/ v
650  Vmath::Vdiv(nq,tmp[2],1,tmp[0],1,physout[2],1);
651  }
652  else
653  {
654  // \eta = h - d
655  Vmath::Vsub(nq,physin[0],1,m_depth,1,physout[0],1);
656 
657  // u = hu/h
658  Vmath::Vdiv(nq,physin[1],1,physin[0],1,physout[1],1);
659 
660  // v = hv/ v
661  Vmath::Vdiv(nq,physin[2],1,physin[0],1,physout[2],1);
662  }
663  }
664 
665 
667  {
668  int nq = GetTotPoints();
669 
670  // u = hu/h
671  Vmath::Vdiv(nq,m_fields[1]->GetPhys(),1,m_fields[0]->GetPhys(),1,m_fields[1]->UpdatePhys(),1);
672 
673  // v = hv/ v
674  Vmath::Vdiv(nq,m_fields[2]->GetPhys(),1,m_fields[0]->GetPhys(),1,m_fields[2]->UpdatePhys(),1);
675 
676  // \eta = h - d
677  Vmath::Vsub(nq,m_fields[0]->GetPhys(),1,m_depth,1,m_fields[0]->UpdatePhys(),1);
678  }
679 
681  Array<OneD, Array<OneD, NekDouble> >&physout)
682  {
683 
684  int nq = GetTotPoints();
685 
686  if(physin.get() == physout.get())
687  {
688  // copy indata and work with tmp array
690  for (int i = 0; i < 3; ++i)
691  {
692  // deep copy
693  tmp[i] = Array<OneD, NekDouble>(nq);
694  Vmath::Vcopy(nq,physin[i],1,tmp[i],1);
695  }
696 
697  // h = \eta + d
698  Vmath::Vadd(nq,tmp[0],1,m_depth,1,physout[0],1);
699 
700  // hu = h * u
701  Vmath::Vmul(nq,physout[0],1,tmp[1],1,physout[1],1);
702 
703  // hv = h * v
704  Vmath::Vmul(nq,physout[0],1,tmp[2],1,physout[2],1);
705 
706  }
707  else
708  {
709  // h = \eta + d
710  Vmath::Vadd(nq,physin[0],1,m_depth,1,physout[0],1);
711 
712  // hu = h * u
713  Vmath::Vmul(nq,physout[0],1,physin[1],1,physout[1],1);
714 
715  // hv = h * v
716  Vmath::Vmul(nq,physout[0],1,physin[2],1,physout[2],1);
717 
718  }
719 
720  }
721 
723  {
724  int nq = GetTotPoints();
725 
726  // h = \eta + d
727  Vmath::Vadd(nq,m_fields[0]->GetPhys(),1,m_depth,1,m_fields[0]->UpdatePhys(),1);
728 
729  // hu = h * u
730  Vmath::Vmul(nq,m_fields[0]->GetPhys(),1,m_fields[1]->GetPhys(),1,m_fields[1]->UpdatePhys(),1);
731 
732  // hv = h * v
733  Vmath::Vmul(nq,m_fields[0]->GetPhys(),1,m_fields[2]->GetPhys(),1,m_fields[2]->UpdatePhys(),1);
734  }
735 
736 
737  /**
738  * @brief Compute the velocity field \f$ \mathbf{v} \f$ given the momentum
739  * \f$ h\mathbf{v} \f$.
740  *
741  * @param physfield Momentum field.
742  * @param velocity Velocity field.
743  */
745  const Array<OneD, Array<OneD, NekDouble> > &physfield,
746  Array<OneD, Array<OneD, NekDouble> > &velocity)
747  {
748  const int npts = physfield[0].num_elements();
749 
750  for (int i = 0; i < m_spacedim; ++i)
751  {
752  Vmath::Vdiv(npts, physfield[1+i], 1, physfield[0], 1,
753  velocity[i], 1);
754  }
755  }
756 
757 
759  {
761  SolverUtils::AddSummaryItem(s, "Variables", "h should be in field[0]");
762  SolverUtils::AddSummaryItem(s, "", "hu should be in field[1]");
763  SolverUtils::AddSummaryItem(s, "", "hv should be in field[2]");
764  }
765 
766 } //end of namespace
767 
Array< OneD, NekDouble > m_coriolis
Coriolis force.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
void GetFluxVector(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &flux)
virtual void v_PrimitiveToConservative()
Base class for unsteady solvers.
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
Array< OneD, NekDouble > m_depth
Still water depth.
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:47
void GetVelocityVector(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &velocity)
Compute the velocity field given the momentum .
int m_expdim
Expansion dimension.
static std::string className
Name of class.
Definition: NonlinearSWE.h:64
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:428
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
const Array< OneD, const Array< OneD, NekDouble > > & GetVecLocs()
SolverUtils::AdvectionSharedPtr m_advection
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
void WallBoundary(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray)
Wall boundary condition.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
Creates an instance of this class.
Definition: NonlinearSWE.h:56
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
void WallBoundary2D(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
void AddVariableDepth(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
const Array< OneD, NekDouble > & GetDepth()
virtual void v_InitObject()
Init object for UnsteadySystem class.
SOLVER_UTILS_EXPORT int GetTotPoints()
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
Array< OneD, Array< OneD, NekDouble > > m_bottomSlope
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:199
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
virtual void v_InitObject()
Init object for UnsteadySystem class.
void AddCoriolis(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
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
RiemannSolverFactory & GetRiemannSolverFactory()
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
static std::string npts
Definition: InputFld.cpp:43
int m_spacedim
Spatial dimension (>= expansion dim).
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:46
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:382
double NekDouble
EquationSystemFactory & GetEquationSystemFactory()
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
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
SOLVER_UTILS_EXPORT int GetPhys_Offset(int n)
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:86
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
void Vvtvm(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvm (vector times vector plus vector): z = w*x - y
Definition: Vmath.cpp:451
virtual void v_ConservativeToPrimitive()
SOLVER_UTILS_EXPORT int GetNcoeffs()
NonlinearSWE(const LibUtilities::SessionReaderSharedPtr &pSession)
bool m_constantDepth
Indicates if constant depth case.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
NekDouble m_g
Acceleration of gravity.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
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
void Vmul(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:169
void SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble > > &physarray, NekDouble time)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215