38 #include <boost/algorithm/string.hpp>
48 "Nonlinear shallow water equation in conservative variables.");
67 ASSERTL0(
false,
"Implicit SWE not set up.");
90 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
102 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Average");
144 ASSERTL0(
false,
"Unsupported projection type.");
159 Array<
OneD, Array<OneD, NekDouble> > &outarray)
165 Array<OneD, NekDouble> tmp(nq);
166 Array<OneD, NekDouble> mod(ncoeffs);
174 m_fields[0]->IProductWRTBase(tmp,mod);
175 m_fields[0]->MultiplyByElmtInvMass(mod,mod);
182 m_fields[0]->IProductWRTBase(tmp,mod);
183 m_fields[0]->MultiplyByElmtInvMass(mod,mod);
202 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
212 Array<
OneD, Array<OneD, NekDouble> > &outarray)
218 Array<OneD, NekDouble> tmp(nq);
219 Array<OneD, NekDouble> mod(ncoeffs);
229 m_fields[0]->IProductWRTBase(tmp,mod);
230 m_fields[0]->MultiplyByElmtInvMass(mod,mod);
232 Vmath::Vadd(nq,tmp,1,outarray[i+1],1,outarray[i+1],1);
243 Vmath::Vadd(nq,tmp,1,outarray[i+1],1,outarray[i+1],1);
248 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
256 Array<
OneD, Array<OneD, NekDouble> >&outarray,
261 int nvariables = inarray.num_elements();
274 Array<OneD, Array<OneD, NekDouble> > advVel;
282 for(i = 0; i < nvariables; ++i)
314 Array<OneD, Array<OneD, Array<OneD, NekDouble> > >
315 fluxvector(nvariables);
317 for (i = 0; i < nvariables; ++i)
319 fluxvector[i] = Array<OneD, Array<OneD, NekDouble> >(ndim);
320 for(j = 0; j < ndim; ++j)
322 fluxvector[i][j] = Array<OneD, NekDouble>(nq);
333 Array<OneD,NekDouble> tmp(nq);
334 Array<OneD, NekDouble>tmp1(nq);
336 for(i = 0; i < nvariables; ++i)
363 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
370 Array<
OneD, Array<OneD, NekDouble> >&outarray,
374 int nvariables = inarray.num_elements();
385 for(i = 0; i < nvariables; ++i)
399 for(i = 0; i < nvariables; ++i)
401 m_fields[i]->FwdTrans(inarray[i],coeffs);
402 m_fields[i]->BwdTrans_IterPerExp(coeffs,outarray[i]);
407 ASSERTL0(
false,
"Unknown projection scheme");
415 Array<
OneD, Array<OneD, NekDouble> > &inarray,
419 int nvariables =
m_fields.num_elements();
423 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
427 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
434 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
437 for (
int i = 0; i < nvariables; ++i)
440 m_fields[i]->EvaluateBoundaryConditions(time, varName);
443 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
454 Array<
OneD, Array<OneD, NekDouble> > &physarray)
458 int nvariables = physarray.num_elements();
461 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
462 for (i = 0; i < nvariables; ++i)
464 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
465 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
470 int e, id1, id2,
npts;
472 for (e = 0; e <
m_fields[0]->GetBndCondExpansions()[bcRegion]
475 npts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
476 GetExp(e)->GetTotPoints();
477 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
479 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
481 GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
484 Array<OneD, NekDouble> tmp(npts, 0.0);
510 for (i = 0; i < nvariables; ++i)
513 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
514 UpdatePhys())[id1], 1);
525 int nvariables = physarray.num_elements();
528 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
529 for (i = 0; i < nvariables; ++i)
531 Fwd[i] = Array<OneD, NekDouble>(nTraceNumPoints);
532 m_fields[i]->ExtractTracePhys(physarray[i],Fwd[i]);
537 int e, id1, id2,
npts;
539 for(e = 0; e <
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize(); ++e)
541 npts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExp(e)->GetNumPoints(0);
542 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e) ;
543 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
555 Array<OneD, NekDouble> tmp_n(npts);
556 Array<OneD, NekDouble> tmp_t(npts);
576 ASSERTL0(
false,
"3D not implemented for Shallow Water Equations");
579 ASSERTL0(
false,
"Illegal expansion dimension");
585 for (i = 0; i < nvariables; ++i)
587 Vmath::Vcopy(npts,&Fwd[i][id2], 1,&(
m_fields[i]->GetBndCondExpansions()[bcRegion]->UpdatePhys())[id1],1);
595 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
596 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &flux)
599 int nq =
m_fields[0]->GetTotPoints();
602 Array<OneD, Array<OneD, NekDouble> > velocity(
m_spacedim);
607 velocity[i] = Array<OneD, NekDouble>(nq);
614 Array<OneD, NekDouble> tmp(nq);
615 Vmath::Vmul(nq, physfield[0], 1, physfield[0], 1, tmp, 1);
628 Vmath::Vadd(nq, flux[i+1][i], 1, tmp, 1, flux[i+1][i], 1);
634 Array<
OneD, Array<OneD, NekDouble> >&physout)
638 if(physin.get() == physout.get())
641 Array<OneD, Array<OneD, NekDouble> >tmp(3);
642 for (
int i = 0; i < 3; ++i)
645 tmp[i] = Array<OneD, NekDouble>(nq);
664 Vmath::Vdiv(nq,physin[1],1,physin[0],1,physout[1],1);
667 Vmath::Vdiv(nq,physin[2],1,physin[0],1,physout[2],1);
687 Array<
OneD, Array<OneD, NekDouble> >&physout)
692 if(physin.get() == physout.get())
695 Array<OneD, Array<OneD, NekDouble> >tmp(3);
696 for (
int i = 0; i < 3; ++i)
699 tmp[i] = Array<OneD, NekDouble>(nq);
707 Vmath::Vmul(nq,physout[0],1,tmp[1],1,physout[1],1);
710 Vmath::Vmul(nq,physout[0],1,tmp[2],1,physout[2],1);
719 Vmath::Vmul(nq,physout[0],1,physin[1],1,physout[1],1);
722 Vmath::Vmul(nq,physout[0],1,physin[2],1,physout[2],1);
751 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
752 Array<
OneD, Array<OneD, NekDouble> > &velocity)
754 const int npts = physfield[0].num_elements();
758 Vmath::Vdiv(npts, physfield[1+i], 1, physfield[0], 1,