38 #include <boost/algorithm/string.hpp>
48 "Linear shallow water equation in primitive variables.");
67 ASSERTL0(
false,
"Implicit SWE not set up.");
90 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
102 m_session->LoadSolverInfo(
"UpwindType", riemName,
"NoSolver");
105 ASSERTL0(
false,
"LinearHLL only valid for constant depth");
126 int nTracePointsTot =
m_fields[0]->GetTrace()->GetTotPoints();
127 m_dFwd = Array<OneD, NekDouble>(nTracePointsTot);
128 m_dBwd = Array<OneD, NekDouble>(nTracePointsTot);
158 ASSERTL0(
false,
"Unsupported projection type.");
173 Array<
OneD, Array<OneD, NekDouble> > &outarray)
179 Array<OneD, NekDouble> tmp(nq);
180 Array<OneD, NekDouble> mod(ncoeffs);
188 m_fields[0]->IProductWRTBase(tmp,mod);
189 m_fields[0]->MultiplyByElmtInvMass(mod,mod);
196 m_fields[0]->IProductWRTBase(tmp,mod);
197 m_fields[0]->MultiplyByElmtInvMass(mod,mod);
216 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
224 Array<
OneD, Array<OneD, NekDouble> >&outarray,
229 int nvariables = inarray.num_elements();
242 Array<OneD, Array<OneD, NekDouble> > advVel;
251 for(i = 0; i < nvariables; ++i)
277 Array<OneD, Array<OneD, Array<OneD, NekDouble> > >
278 fluxvector(nvariables);
280 for (i = 0; i < nvariables; ++i)
282 fluxvector[i] = Array<OneD, Array<OneD, NekDouble> >(ndim);
283 for(j = 0; j < ndim; ++j)
285 fluxvector[i][j] = Array<OneD, NekDouble>(nq);
296 Array<OneD,NekDouble> tmp(nq);
297 Array<OneD, NekDouble>tmp1(nq);
299 for(i = 0; i < nvariables; ++i)
320 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
327 Array<
OneD, Array<OneD, NekDouble> >&outarray,
331 int nvariables = inarray.num_elements();
342 for(i = 0; i < nvariables; ++i)
356 for(i = 0; i < nvariables; ++i)
358 m_fields[i]->FwdTrans(inarray[i],coeffs);
359 m_fields[i]->BwdTrans_IterPerExp(coeffs,outarray[i]);
364 ASSERTL0(
false,
"Unknown projection scheme");
372 Array<
OneD, Array<OneD, NekDouble> > &inarray,
376 int nvariables =
m_fields.num_elements();
380 for(
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
383 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
390 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
393 for (
int i = 0; i < nvariables; ++i)
396 m_fields[i]->EvaluateBoundaryConditions(time, varName);
399 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
410 Array<
OneD, Array<OneD, NekDouble> > &physarray)
414 int nvariables = physarray.num_elements();
417 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
418 for (i = 0; i < nvariables; ++i)
420 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
421 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
426 int e, id1, id2,
npts;
428 for (e = 0; e <
m_fields[0]->GetBndCondExpansions()[bcRegion]
431 npts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
432 GetExp(e)->GetTotPoints();
433 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
435 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
437 GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
440 Array<OneD, NekDouble> tmp(npts, 0.0);
466 for (i = 0; i < nvariables; ++i)
469 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
470 UpdatePhys())[id1], 1);
481 int nvariables = physarray.num_elements();
484 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
485 for (i = 0; i < nvariables; ++i)
487 Fwd[i] = Array<OneD, NekDouble>(nTraceNumPoints);
488 m_fields[i]->ExtractTracePhys(physarray[i],Fwd[i]);
493 int e, id1, id2,
npts;
495 for(e = 0; e <
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize(); ++e)
497 npts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExp(e)->GetNumPoints(0);
498 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e) ;
499 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
511 Array<OneD, NekDouble> tmp_n(npts);
512 Array<OneD, NekDouble> tmp_t(npts);
532 ASSERTL0(
false,
"3D not implemented for Shallow Water Equations");
535 ASSERTL0(
false,
"Illegal expansion dimension");
541 for (i = 0; i < nvariables; ++i)
543 Vmath::Vcopy(npts,&Fwd[i][id2], 1,&(
m_fields[i]->GetBndCondExpansions()[bcRegion]->UpdatePhys())[id1],1);
551 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
552 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &flux)
555 int nq =
m_fields[0]->GetTotPoints();
566 Array<OneD, NekDouble> tmp(nq);
579 Vmath::Vadd(nq, flux[i+1][i], 1, tmp, 1, flux[i+1][i], 1);
585 Array<
OneD, Array<OneD, NekDouble> >&physout)
589 if(physin.get() == physout.get())
592 Array<OneD, Array<OneD, NekDouble> >tmp(3);
593 for (
int i = 0; i < 3; ++i)
596 tmp[i] = Array<OneD, NekDouble>(nq);
615 Vmath::Vdiv(nq,physin[1],1,physin[0],1,physout[1],1);
618 Vmath::Vdiv(nq,physin[2],1,physin[0],1,physout[2],1);
638 Array<
OneD, Array<OneD, NekDouble> >&physout)
643 if(physin.get() == physout.get())
646 Array<OneD, Array<OneD, NekDouble> >tmp(3);
647 for (
int i = 0; i < 3; ++i)
650 tmp[i] = Array<OneD, NekDouble>(nq);
658 Vmath::Vmul(nq,physout[0],1,tmp[1],1,physout[1],1);
661 Vmath::Vmul(nq,physout[0],1,tmp[2],1,physout[2],1);
670 Vmath::Vmul(nq,physout[0],1,physin[1],1,physout[1],1);
673 Vmath::Vmul(nq,physout[0],1,physin[2],1,physout[2],1);
702 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
703 Array<
OneD, Array<OneD, NekDouble> > &velocity)
705 const int npts = physfield[0].num_elements();
717 if (
m_session->DefinesSolverInfo(
"UpwindType"))
719 std::string UpwindType;
720 UpwindType =
m_session->GetSolverInfo(
"UpwindType");
721 if (UpwindType ==
"LinearAverage")
725 if (UpwindType ==
"LinearHLL")