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;
250 for(i = 0; i < nvariables; ++i)
276 Array<OneD, Array<OneD, Array<OneD, NekDouble> > >
277 fluxvector(nvariables);
279 for (i = 0; i < nvariables; ++i)
281 fluxvector[i] = Array<OneD, Array<OneD, NekDouble> >(ndim);
282 for(j = 0; j < ndim; ++j)
284 fluxvector[i][j] = Array<OneD, NekDouble>(nq);
295 Array<OneD,NekDouble> tmp(nq);
296 Array<OneD, NekDouble>tmp1(nq);
298 for(i = 0; i < nvariables; ++i)
319 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
326 Array<
OneD, Array<OneD, NekDouble> >&outarray,
330 int nvariables = inarray.num_elements();
341 for(i = 0; i < nvariables; ++i)
355 for(i = 0; i < nvariables; ++i)
357 m_fields[i]->FwdTrans(inarray[i],coeffs);
358 m_fields[i]->BwdTrans_IterPerExp(coeffs,outarray[i]);
363 ASSERTL0(
false,
"Unknown projection scheme");
371 Array<
OneD, Array<OneD, NekDouble> > &inarray,
375 int nvariables =
m_fields.num_elements();
379 for(
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
382 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
389 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
392 for (
int i = 0; i < nvariables; ++i)
395 m_fields[i]->EvaluateBoundaryConditions(time, varName);
398 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
409 Array<
OneD, Array<OneD, NekDouble> > &physarray)
413 int nvariables = physarray.num_elements();
416 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
417 for (i = 0; i < nvariables; ++i)
419 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
420 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
425 int e, id1, id2,
npts;
427 for (e = 0; e <
m_fields[0]->GetBndCondExpansions()[bcRegion]
430 npts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
431 GetExp(e)->GetTotPoints();
432 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
434 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
436 GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
439 Array<OneD, NekDouble> tmp(npts, 0.0);
465 for (i = 0; i < nvariables; ++i)
468 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
469 UpdatePhys())[id1], 1);
480 int nvariables = physarray.num_elements();
483 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
484 for (i = 0; i < nvariables; ++i)
486 Fwd[i] = Array<OneD, NekDouble>(nTraceNumPoints);
487 m_fields[i]->ExtractTracePhys(physarray[i],Fwd[i]);
492 int e, id1, id2,
npts;
494 for(e = 0; e <
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize(); ++e)
496 npts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExp(e)->GetNumPoints(0);
497 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e) ;
498 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
510 Array<OneD, NekDouble> tmp_n(npts);
511 Array<OneD, NekDouble> tmp_t(npts);
531 ASSERTL0(
false,
"3D not implemented for Shallow Water Equations");
534 ASSERTL0(
false,
"Illegal expansion dimension");
540 for (i = 0; i < nvariables; ++i)
542 Vmath::Vcopy(npts,&Fwd[i][id2], 1,&(
m_fields[i]->GetBndCondExpansions()[bcRegion]->UpdatePhys())[id1],1);
550 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
551 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &flux)
554 int nq =
m_fields[0]->GetTotPoints();
565 Array<OneD, NekDouble> tmp(nq);
578 Vmath::Vadd(nq, flux[i+1][i], 1, tmp, 1, flux[i+1][i], 1);
584 Array<
OneD, Array<OneD, NekDouble> >&physout)
588 if(physin.get() == physout.get())
591 Array<OneD, Array<OneD, NekDouble> >tmp(3);
592 for (
int i = 0; i < 3; ++i)
595 tmp[i] = Array<OneD, NekDouble>(nq);
614 Vmath::Vdiv(nq,physin[1],1,physin[0],1,physout[1],1);
617 Vmath::Vdiv(nq,physin[2],1,physin[0],1,physout[2],1);
637 Array<
OneD, Array<OneD, NekDouble> >&physout)
642 if(physin.get() == physout.get())
645 Array<OneD, Array<OneD, NekDouble> >tmp(3);
646 for (
int i = 0; i < 3; ++i)
649 tmp[i] = Array<OneD, NekDouble>(nq);
657 Vmath::Vmul(nq,physout[0],1,tmp[1],1,physout[1],1);
660 Vmath::Vmul(nq,physout[0],1,tmp[2],1,physout[2],1);
669 Vmath::Vmul(nq,physout[0],1,physin[1],1,physout[1],1);
672 Vmath::Vmul(nq,physout[0],1,physin[2],1,physout[2],1);
701 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
702 Array<
OneD, Array<OneD, NekDouble> > &velocity)
704 const int npts = physfield[0].num_elements();
716 if (
m_session->DefinesSolverInfo(
"UpwindType"))
718 std::string UpwindType;
719 UpwindType =
m_session->GetSolverInfo(
"UpwindType");
720 if (UpwindType ==
"LinearAverage")
724 if (UpwindType ==
"LinearHLL")