38 #include <boost/core/ignore_unused.hpp> 39 #include <boost/algorithm/string.hpp> 67 int shapedim =
m_fields[0]->GetShapeDimension();
69 for (
int j = 0; j < shapedim; ++j)
78 "No TESTTYPE defined in session.");
79 std::string TestTypeStr =
m_session->GetSolverInfo(
"TESTTYPE");
98 std::vector<std::string> vel;
148 std::string riemName;
150 "AdvectionType", advName,
"WeakDG");
156 "UpwindType", riemName,
"Upwind");
170 std::cout <<
"m_vellc is generated with mag = " <<
AvgInt(
m_vellc)
198 ASSERTL0(
false,
"Implicit unsteady Advection not set up.");
215 int nfields =
m_fields.num_elements();
220 for (i = 0; i < nfields; ++i)
224 nvariables = nfields;
236 for (i = 0; i < nvariables; ++i)
250 "Only one of IO_CheckTime and IO_CheckSteps " 254 bool doCheckTime =
false;
268 for (
int i = 0; i < nvariables; ++i)
287 std::cout <<
"Steps: " << std::setw(8) << std::left << step + 1 <<
" " 288 <<
"Time: " << std::setw(12) << std::left <<
m_time;
290 std::stringstream ss;
291 ss << cpuTime <<
"s";
292 std::cout <<
" CPU Time: " << std::setw(8) << std::left << ss.str()
300 std::cout <<
"dMass = " << std::setw(8) << std::left << dMass[indx]
307 for (i = 0; i < nvariables; ++i)
327 std::cout <<
"dMass = ";
328 for (i = 0; i < Ntot; ++i)
330 std::cout << dMass[i] <<
" , ";
332 std::cout << std::endl << std::endl;
335 if (
m_session->GetComm()->GetRank() == 0)
340 <<
"CFL time-step : " <<
m_timestep << std::endl;
343 if (
m_session->GetSolverInfo(
"Driver") !=
"SteadyState")
345 std::cout <<
"Time-integration : " << intTime <<
"s" << std::endl;
349 for (i = 0; i < nvariables; ++i)
355 for (i = 0; i < nvariables; ++i)
377 for (i = 0; i <
m_velocity.num_elements(); ++i)
399 boost::ignore_unused(time);
402 int nvariables = inarray.num_elements();
409 int ncoeffs = inarray[0].num_elements();
416 for (i = 1; i < nvariables; ++i)
418 WeakAdv[i] = WeakAdv[i - 1] + ncoeffs;
424 for (i = 0; i < nvariables; ++i)
426 m_fields[i]->MultiplyByElmtInvMass(WeakAdv[i], WeakAdv[i]);
427 m_fields[i]->BwdTrans(WeakAdv[i], outarray[i]);
441 for (i = 0; i < nvariables; ++i)
453 ASSERTL0(
false,
"Unknown projection scheme");
473 int nVariables = inarray.num_elements();
488 for (i = 0; i < nVariables; ++i)
490 Vmath::Vcopy(nQuadraturePts, inarray[i], 1, outarray[i], 1);
500 for (i = 0; i < nVariables; ++i)
502 m_fields[i]->FwdTrans(inarray[i], coeffs);
503 m_fields[i]->BwdTrans_IterPerExp(coeffs, outarray[i]);
509 ASSERTL0(
false,
"Unknown projection scheme");
526 "Dimension of flux array and velocity array do not match");
529 int nq = physfield[0].num_elements();
531 for (i = 0; i < flux.num_elements(); ++i)
533 for (j = 0; j < flux[0].num_elements(); ++j)
547 int nvariables =
m_fields.num_elements();
553 for (i = 0; i < nvariables; ++i)
555 physfield[i] = InField[i];
559 for (i = 0; i < nvariables; ++i)
568 m_fields[0]->IProductWRTDirectionalDerivBase(
585 m_fields[i]->GetFwdBwdTracePhys(physfield[i], Fwd, Bwd);
602 m_fields[i]->AddFwdBwdTraceIntegral(fluxFwd, fluxBwd, WeakDeriv[j]);
605 Vmath::Vadd(ncoeffs, &WeakDeriv[j][0], 1, &OutField[i][0], 1,
616 NekDouble vel_phi, vel_theta, sin_varphi, cos_varphi, sin_theta, cos_theta;
626 for (
int j = 0; j < nq; j++)
640 -1.0 * vel_phi * sin_varphi - vel_theta * sin_theta * cos_varphi;
642 vel_phi * cos_varphi - vel_theta * sin_theta * sin_varphi;
643 velocity[2][j] = vel_theta * cos_theta;
678 Vmath::Vmul(nq, &tmp[0], 1, &tmp[0], 1, &tmp[0], 1);
679 Vmath::Vadd(nq, tmp, 1, Projection, 1, Projection, 1);
683 <<
"Velocity vector is projected onto the tangent plane: Diff = " 872 NekDouble Tol = 0.0001, Maxiter = 1000, N = 100;
873 NekDouble newy, F = 0.0, dF = 1.0, y0, tmp;
884 intval = sqrt(Rhs - zlevel * zlevel);
890 intval = sqrt(0.5 * (Rhs - zlevel * zlevel * zlevel * zlevel -
898 (Rhs - zlevel * zlevel * zlevel * zlevel - zlevel * zlevel);
899 intval = sqrt(0.5 * (1.0 + sqrt(1.0 + 4.0 * tmp)));
914 for (
int j = 0; j < N + 1; ++j)
916 xp[j] = j * 2.0 * intval / N - intval;
919 for (
int i = 0; i < Maxiter; ++i)
927 F = xp[j] * xp[j] + y0 * y0 + zlevel * zlevel - Rhs;
934 F = 2.0 * xp[j] * xp[j] + y0 * y0 * y0 * y0 +
935 y0 * y0 + zlevel * zlevel * zlevel * zlevel +
936 zlevel * zlevel - Rhs;
937 dF = 4.0 * y0 * y0 * y0 + 2.0 * y0;
947 if (fabs(F / dF) < Tol)
959 "Advection Velocity convergence fails");
968 for (
int j = 0; j < N + 1; ++j)
970 xp[j] = j * 2.0 * intval / N - intval;
972 0.5 * (zlevel * zlevel * zlevel * zlevel +
974 (xp[j] * xp[j] * xp[j] * xp[j] - xp[j] * xp[j]);
991 for (
int j = 0; j < N; ++j)
993 arclength = arclength +
994 sqrt((yp[j + 1] - yp[j]) * (yp[j + 1] - yp[j]) +
995 (xp[j + 1] - xp[j]) * (xp[j + 1] - xp[j])) /
1003 bool dumpInitialConditions,
1006 boost::ignore_unused(domain);
1008 int nq =
m_fields[0]->GetNpoints();
1022 for (
int i = 0; i <
m_fields.num_elements(); ++i)
1039 for (
int i = 0; i <
m_fields.num_elements(); ++i)
1054 std::cout <<
"m_Mass0 = " <<
m_Mass0 << std::endl;
1057 for (
int i = 0; i <
m_fields.num_elements(); ++i)
1072 for (
int i = 0; i <
m_fields.num_elements(); ++i)
1085 if (dumpInitialConditions)
1095 int nq =
m_fields[0]->GetNpoints();
1106 m_radius_limit = 0.5;
1110 for (
int j = 0; j < nq; ++j)
1115 dist = sqrt(x0j * x0j + x1j * x1j);
1117 if (dist < m_radius_limit)
1119 outfield[j] = 0.5 * (1.0 + cos(
m_pi * dist / m_radius_limit));
1130 int nq =
m_fields[0]->GetNpoints();
1132 NekDouble dist, radius, cosdiff, sin_theta, cos_theta, sin_varphi,
1134 NekDouble m_theta_c, m_varphi_c, m_radius_limit, m_c0;
1144 m_varphi_c = 3.0 *
m_pi / 2.0;
1145 m_radius_limit = 7.0 *
m_pi / 64.0;
1150 for (
int j = 0; j < nq; ++j)
1156 radius = sqrt(x0j * x0j + x1j * x1j + x2j * x2j);
1158 sin_varphi = x1j / sqrt(x0j * x0j + x1j * x1j);
1159 cos_varphi = x0j / sqrt(x0j * x0j + x1j * x1j);
1161 sin_theta = x2j / radius;
1162 cos_theta = sqrt(x0j * x0j + x1j * x1j) / radius;
1164 cosdiff = cos_varphi * cos(m_varphi_c) + sin_varphi * sin(m_varphi_c);
1165 dist = radius * acos(sin(m_theta_c) * sin_theta +
1166 cos(m_theta_c) * cos_theta * cosdiff);
1168 if (dist < m_radius_limit)
1171 0.5 * (1.0 + cos(
m_pi * dist / m_radius_limit)) + m_c0;
1183 int nq =
m_fields[0]->GetNpoints();
1189 m_fields[0]->GetCoords(x0, x1, x2);
1193 for (
int i = 0; i < nq; ++i)
1205 int nq =
m_fields[0]->GetNpoints();
1211 m_fields[0]->GetCoords(x0, x1, x2);
1215 for (
int i = 0; i < nq; ++i)
1227 int nq =
m_fields[0]->GetNpoints();
1249 1, &velcoeff[0], 1, &velcoeff[0], 1);
1253 m_fields[0]->PhysDeriv(velcoeff, Dtmp0, Dtmp1, Dtmp2);
1263 1, &vellc[0], 1, &vellc[0], 1);
1270 1, &vellc[0], 1, &vellc[0], 1);
1277 1, &vellc[0], 1, &vellc[0], 1);
1288 int nq =
m_fields[0]->GetNpoints();
1300 1, &veldotMF[j][0], 1, &veldotMF[j][0], 1);
1309 boost::ignore_unused(field);
void AdvectionBellPlane(Array< OneD, NekDouble > &outfield)
Array< OneD, NekDouble > m_vellc
void ComputeveldotMF(Array< OneD, Array< OneD, NekDouble >> &veldotMF)
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the projection.
#define ASSERTL0(condition, msg)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
void EvaluateAdvectionVelocity(Array< OneD, Array< OneD, NekDouble >> &velocity)
MMFAdvection(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Session reader.
Array< OneD, Array< OneD, NekDouble > > m_ncdotMFBwd
const char *const TestTypeMap[]
virtual void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
NekDouble ComputeCirculatingArclength(const NekDouble zlevel, const NekDouble Rhs)
NekDouble m_time
Current time of simulation.
A base class for PDEs which include an advection component.
SOLVER_UTILS_EXPORT void ComputencdotMF()
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print Summary.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
NekDouble m_timestep
Time step size.
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
std::vector< std::pair< std::string, std::string > > SummaryList
SOLVER_UTILS_EXPORT void GramSchumitz(const Array< OneD, const Array< OneD, NekDouble >> &v1, const Array< OneD, const Array< OneD, NekDouble >> &v2, Array< OneD, Array< OneD, NekDouble >> &outarray, bool KeepTheMagnitude=true)
Array< OneD, Array< OneD, NekDouble > > m_velocity
Advection velocity.
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
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
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
virtual void v_SetInitialConditions(const NekDouble initialtime, bool dumpInitialConditions, const int domain)
NekDouble m_checktime
Time between checkpoints.
std::string m_sessionName
Name of the session.
virtual void v_InitObject()
Initialise the object.
int m_checksteps
Number of steps between checkpoints.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
Array< OneD, Array< OneD, NekDouble > > m_veldotMF
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the RHS.
Array< OneD, Array< OneD, NekDouble > > m_movingframes
NekDouble m_fintime
Finish time of the simulation.
void GetFluxVector(const Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble >>> &flux)
Evaluate the flux at each solution point.
int m_steps
Number of steps to take.
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
void Test3Dproblem(const NekDouble time, Array< OneD, NekDouble > &outfield)
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
void ComputeNablaCdotVelocity(Array< OneD, NekDouble > &vellc)
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
static const NekDouble kNekZeroTol
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
SurfaceType m_surfaceType
SOLVER_UTILS_EXPORT void VectorCrossProd(const Array< OneD, const Array< OneD, NekDouble >> &v1, const Array< OneD, const Array< OneD, NekDouble >> &v2, Array< OneD, Array< OneD, NekDouble >> &v3)
virtual ~MMFAdvection()
Destructor.
Base class for unsteady solvers.
SOLVER_UTILS_EXPORT NekDouble RootMeanSquare(const Array< OneD, const NekDouble > &inarray)
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
RiemannSolverFactory & GetRiemannSolverFactory()
void AdvectionBellSphere(Array< OneD, NekDouble > &outfield)
int m_spacedim
Spatial dimension (>= expansion dim).
Array< OneD, NekDouble > & GetNormalVelocity()
Get the normal velocity.
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
void Neg(int n, T *x, const int incx)
Negate x = -x.
SOLVER_UTILS_EXPORT void MMFInitObject(const Array< OneD, const Array< OneD, NekDouble >> &Anisotropy, const int TangentXelem=-1)
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
Array< OneD, Array< OneD, NekDouble > > m_ncdotMFFwd
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
EquationSystemFactory & GetEquationSystemFactory()
SOLVER_UTILS_EXPORT void CartesianToSpherical(const NekDouble x0j, const NekDouble x1j, const NekDouble x2j, NekDouble &sin_varphi, NekDouble &cos_varphi, NekDouble &sin_theta, NekDouble &cos_theta)
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
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.
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname)
Write field data to the given filename.
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
Array< OneD, NekDouble > m_traceVn
SOLVER_UTILS_EXPORT int GetTraceNpoints()
SOLVER_UTILS_EXPORT int GetNcoeffs()
SOLVER_UTILS_EXPORT NekDouble AvgInt(const Array< OneD, const NekDouble > &inarray)
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.
int m_infosteps
Number of time steps between outputting status information.
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static std::string className
Name of class.
void Zero(int n, T *x, const int incx)
Zero vector.
void WeakDGDirectionalAdvection(const Array< OneD, Array< OneD, NekDouble >> &InField, Array< OneD, Array< OneD, NekDouble >> &OutField)
A base class for PDEs which include an advection component.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s)
Print a summary of time stepping parameters.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
LibUtilities::TimeIntegrationSolutionSharedPtr m_intSoln
std::shared_ptr< SessionReader > SessionReaderSharedPtr
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.
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.
virtual void v_DoSolve()
Solves an unsteady problem.
std::vector< int > m_intVariables
void Test2Dproblem(const NekDouble time, Array< OneD, NekDouble > &outfield)