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;
283 for(i = 0; i < nvariables; ++i)
315 Array<OneD, Array<OneD, Array<OneD, NekDouble> > >
316 fluxvector(nvariables);
318 for (i = 0; i < nvariables; ++i)
320 fluxvector[i] = Array<OneD, Array<OneD, NekDouble> >(ndim);
321 for(j = 0; j < ndim; ++j)
323 fluxvector[i][j] = Array<OneD, NekDouble>(nq);
335 Array<OneD,NekDouble> tmp(nq);
336 Array<OneD, NekDouble>tmp1(nq);
338 for(i = 0; i < nvariables; ++i)
366 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
373 Array<
OneD, Array<OneD, NekDouble> >&outarray,
377 int nvariables = inarray.num_elements();
388 for(i = 0; i < nvariables; ++i)
402 for(i = 0; i < nvariables; ++i)
404 m_fields[i]->FwdTrans(inarray[i],coeffs);
405 m_fields[i]->BwdTrans_IterPerExp(coeffs,outarray[i]);
410 ASSERTL0(
false,
"Unknown projection scheme");
418 Array<
OneD, Array<OneD, NekDouble> > &inarray,
422 int nvariables =
m_fields.num_elements();
426 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
430 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
437 if (
m_fields[0]->GetBndConditions()[n]->GetUserDefined() ==
440 for (
int i = 0; i < nvariables; ++i)
443 m_fields[i]->EvaluateBoundaryConditions(time, varName);
446 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
457 Array<
OneD, Array<OneD, NekDouble> > &physarray)
461 int nvariables = physarray.num_elements();
464 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
465 for (i = 0; i < nvariables; ++i)
467 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
468 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
473 int e, id1, id2,
npts;
475 for (e = 0; e <
m_fields[0]->GetBndCondExpansions()[bcRegion]
478 npts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
479 GetExp(e)->GetTotPoints();
480 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->
482 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
484 GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
487 Array<OneD, NekDouble> tmp(npts, 0.0);
513 for (i = 0; i < nvariables; ++i)
516 &(
m_fields[i]->GetBndCondExpansions()[bcRegion]->
517 UpdatePhys())[id1], 1);
528 int nvariables = physarray.num_elements();
531 Array<OneD, Array<OneD, NekDouble> > Fwd(nvariables);
532 for (i = 0; i < nvariables; ++i)
534 Fwd[i] = Array<OneD, NekDouble>(nTraceNumPoints);
535 m_fields[i]->ExtractTracePhys(physarray[i],Fwd[i]);
540 int e, id1, id2,
npts;
542 for(e = 0; e <
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize(); ++e)
544 npts =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExp(e)->GetNumPoints(0);
545 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e) ;
546 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
558 Array<OneD, NekDouble> tmp_n(npts);
559 Array<OneD, NekDouble> tmp_t(npts);
579 ASSERTL0(
false,
"3D not implemented for Shallow Water Equations");
582 ASSERTL0(
false,
"Illegal expansion dimension");
588 for (i = 0; i < nvariables; ++i)
590 Vmath::Vcopy(npts,&Fwd[i][id2], 1,&(
m_fields[i]->GetBndCondExpansions()[bcRegion]->UpdatePhys())[id1],1);
598 const Array<
OneD,
const Array<OneD, NekDouble> > &physfield,
599 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &flux)
602 int nq =
m_fields[0]->GetTotPoints();
605 Array<OneD, Array<OneD, NekDouble> > velocity(
m_spacedim);
610 velocity[i] = Array<OneD, NekDouble>(nq);
617 Array<OneD, NekDouble> tmp(nq);
618 Vmath::Vmul(nq, physfield[0], 1, physfield[0], 1, tmp, 1);
631 Vmath::Vadd(nq, flux[i+1][i], 1, tmp, 1, flux[i+1][i], 1);
637 Array<
OneD, Array<OneD, NekDouble> >&physout)
641 if(physin.get() == physout.get())
644 Array<OneD, Array<OneD, NekDouble> >tmp(3);
645 for (
int i = 0; i < 3; ++i)
648 tmp[i] = Array<OneD, NekDouble>(nq);
667 Vmath::Vdiv(nq,physin[1],1,physin[0],1,physout[1],1);
670 Vmath::Vdiv(nq,physin[2],1,physin[0],1,physout[2],1);
690 Array<
OneD, Array<OneD, NekDouble> >&physout)
695 if(physin.get() == physout.get())
698 Array<OneD, Array<OneD, NekDouble> >tmp(3);
699 for (
int i = 0; i < 3; ++i)
702 tmp[i] = Array<OneD, NekDouble>(nq);
710 Vmath::Vmul(nq,physout[0],1,tmp[1],1,physout[1],1);
713 Vmath::Vmul(nq,physout[0],1,tmp[2],1,physout[2],1);
722 Vmath::Vmul(nq,physout[0],1,physin[1],1,physout[1],1);
725 Vmath::Vmul(nq,physout[0],1,physin[2],1,physout[2],1);
754 const Array<
OneD, Array<OneD, NekDouble> > &physfield,
755 Array<
OneD, Array<OneD, NekDouble> > &velocity)
757 const int npts = physfield[0].num_elements();
761 Vmath::Vdiv(npts, physfield[1+i], 1, physfield[0], 1,