38#include <boost/algorithm/string.hpp>
46#include <boost/math/special_functions/spherical_harmonic.hpp>
86 int shapedim =
m_fields[0]->GetShapeDimension();
88 for (
int j = 0; j < shapedim; ++j)
97 if (
m_session->DefinesSolverInfo(
"TESTTYPE"))
99 std::string TestTypeStr =
m_session->GetSolverInfo(
"TESTTYPE");
115 if (
m_session->DefinesSolverInfo(
"INITWAVETYPE"))
117 std::string InitWaveTypeStr =
m_session->GetSolverInfo(
"INITWAVETYPE");
144 for (
int k = 0; k < MFdim; ++k)
196 int nvariables = inarray.size();
206 for (
int n = 1; n < nvariables; ++n)
208 F[n] = F[n - 1] + nq;
217 for (
int i = 0; i < nvariables; ++i)
254 for (
int k = 0; k < nq; k++)
258 sin(
m_pi * x[k]) * cos(
m_pi * y[k]);
272 for (
int k = 0; k < nq; k++)
296 Vmath::Svtvp(nq, m_a, &inarray[0][0], 1, &temp[0], 1, &temp[0], 1);
301 Vmath::Svtvp(nq, m_c, &inarray[0][0], 1, &temp[0], 1, &temp[0], 1);
316 Vmath::Vmul(nq, &inarray[0][0], 1, &inarray[0][0], 1, &cube[0], 1);
317 Vmath::Vmul(nq, &inarray[1][0], 1, &cube[0], 1, &cube[0], 1);
322 Vmath::Svtvp(nq, coeff, &inarray[0][0], 1, &cube[0], 1, &tmp[0], 1);
323 Vmath::Vadd(nq, &Aonevec[0], 1, &tmp[0], 1, &outarray[0][0], 1);
326 Vmath::Svtvm(nq, B, &inarray[0][0], 1, &cube[0], 1, &outarray[1][0],
343 Vmath::Smul(nq, -1.0 * c1, inarray[0], 1, outarray[0], 1);
345 Vmath::Vmul(nq, tmp, 1, inarray[0], 1, outarray[0], 1);
347 Vmath::Vmul(nq, tmp, 1, outarray[0], 1, outarray[0], 1);
350 Vmath::Vadd(nq, tmp, 1, outarray[0], 1, outarray[0], 1);
355 Vmath::Smul(nq, b, outarray[1], 1, outarray[1], 1);
370 Vmath::Smul(nq, -1.0 * c1, inarray[0], 1, outarray[0], 1);
372 Vmath::Vmul(nq, tmp, 1, outarray[0], 1, outarray[0], 1);
374 Vmath::Vmul(nq, tmp, 1, outarray[0], 1, outarray[0], 1);
376 Vmath::Vmul(nq, inarray[0], 1, inarray[1], 1, tmp, 1);
378 Vmath::Vadd(nq, tmp, 1, outarray[0], 1, outarray[0], 1);
383 Vmath::Smul(nq, b, outarray[1], 1, outarray[1], 1);
400 Vmath::Smul(nq, -1.0 * c1, inarray[0], 1, outarray[0], 1);
402 Vmath::Vmul(nq, tmp, 1, outarray[0], 1, outarray[0], 1);
404 Vmath::Vmul(nq, tmp, 1, outarray[0], 1, outarray[0], 1);
406 Vmath::Vmul(nq, inarray[0], 1, inarray[1], 1, tmp, 1);
408 Vmath::Vadd(nq, tmp, 1, outarray[0], 1, outarray[0], 1);
413 Vmath::Smul(nq, mu1, inarray[1], 1, outarray[1], 1);
415 Vmath::Vdiv(nq, outarray[1], 1, tmp, 1, outarray[1], 1);
416 Vmath::Sadd(nq, c0, outarray[1], 1, outarray[1], 1);
418 Vmath::Sadd(nq, (-a - 1.0), inarray[0], 1, tmp, 1);
424 Vmath::Vmul(nq, tmp, 1, outarray[1], 1, outarray[1], 1);
437 bool dumpInitialConditions,
438 [[maybe_unused]]
const int domain)
494 for (
int i = 0; i <
m_fields.size(); ++i)
501 if (dumpInitialConditions)
521 for (
int k = 0; k < nq; k++)
523 outfield[k] = exp(-1.0 *
m_pi *
m_pi * time) * sin(
m_pi * x[k]) *
541 for (
int k = 0; k < nq; k++)
543 outfield[k] = exp(-1.0 *
m_pi *
m_pi * time) * sin(
m_pi * x[k]) *
555 NekDouble A_mn, C_mn, theta, phi, radius;
557 std::complex<double> Spericharmonic, delta_n, temp;
558 std::complex<double> varphi0, varphi1;
559 std::complex<double> B_mn, D_mn;
563 int Maxm = 2 * Maxn - 1;
581 for (i = 0; i < Maxn; ++i)
587 Ainit[5][0] = -0.5839;
588 Ainit[5][1] = -0.8436;
589 Ainit[5][2] = -0.4764;
590 Ainit[5][3] = 0.6475;
591 Ainit[5][4] = 0.1886;
592 Ainit[5][5] = 0.8709;
593 Ainit[5][6] = -0.8338;
594 Ainit[5][7] = 0.1795;
595 Ainit[5][8] = -0.7873;
596 Ainit[5][9] = 0.8842;
597 Ainit[5][10] = 0.2943;
599 Binit[5][0] = -0.6263;
600 Binit[5][1] = 0.9803;
601 Binit[5][2] = 0.7222;
602 Binit[5][3] = 0.5945;
603 Binit[5][4] = 0.6026;
604 Binit[5][5] = -0.2076;
605 Binit[5][6] = 0.4556;
606 Binit[5][7] = 0.6024;
607 Binit[5][8] = 0.9695;
608 Binit[5][9] = -0.4936;
609 Binit[5][10] = 0.1098;
618 for (
int i = 0; i < nq; ++i)
620 radius =
sqrt(x[i] * x[i] + y[i] * y[i] +
z[i] *
z[i]);
623 theta = asin(
z[i] / radius) + 0.5 *
m_pi;
626 phi = atan2(y[i], x[i]) +
m_pi;
628 varphi0 = 0.0 * varphi0;
629 varphi1 = 0.0 * varphi1;
630 for (n = 0; n < Maxn; ++n)
633 a_n = m_a -
m_mu * (n * (n + 1) / radius / radius);
634 d_n = m_d - m_nu * (n * (n + 1) / radius / radius);
636 gamma_n = 0.5 * (a_n + d_n);
638 temp = (a_n + d_n) * (a_n + d_n) - 4.0 * (a_n * d_n - m_b * m_c);
639 delta_n = 0.5 *
sqrt(temp);
641 for (m = -n; m <= n; ++m)
644 A_mn = Ainit[n][ind];
645 C_mn = Binit[n][ind];
647 B_mn = ((a_n - gamma_n) * Ainit[n][ind] + m_b * Binit[n][ind]) /
649 D_mn = (m_c * Ainit[n][ind] + (d_n - gamma_n) * Binit[n][ind]) /
653 boost::math::spherical_harmonic(n, m, theta, phi);
654 varphi0 += exp(gamma_n * time) *
655 (A_mn * cosh(delta_n * time) +
656 B_mn * sinh(delta_n * time)) *
658 varphi1 += exp(gamma_n * time) *
659 (C_mn * cosh(delta_n * time) +
660 D_mn * sinh(delta_n * time)) *
665 u[i] = varphi0.real();
666 v[i] = varphi1.real();
703 for (
int i = 0; i < nq; i++)
714 1.0 / (1.0 + exp((xp - radiusofinit) / frontstiff));
728 exp((
sqrt(xp * xp) - radiusofinit) / frontstiff)) +
730 exp((
sqrt(xp2 * xp2) - radiusofinit) / frontstiff));
741 1.0 / (1.0 + exp((xp - radiusofinit) / frontstiff));
755 (1.0 + exp((
sqrt(xp * xp + yp * yp) / bs - radiusofinit) /
769 rad =
sqrt(xloc * xloc + yloc * yloc + zloc * zloc);
771 xloc = xloc / radiusofinit;
772 yloc = yloc / radiusofinit;
773 zloc = zloc / radiusofinit;
775 if (
rad < radiusofinit)
779 (xloc * xloc + yloc * yloc + zloc * zloc));
796 (1.0 / (1.0 + exp(2.0 * yp))) *
797 (1.0 / (1.0 + exp(-2.0 * xp))) *
798 (1.0 / (1.0 + exp((xp - radiusofinit) / frontstiff)));
866int main(
int argc,
char *argv[])
870 std::string vDriverModule;
876 session = LibUtilities::SessionReader::CreateInstance(argc, argv);
879 graph = SpatialDomains::MeshGraphIO::Read(session);
882 session->LoadSolverInfo(
"Driver", vDriverModule,
"Standard");
891 catch (
const std::runtime_error &e)
895 catch (
const std::string &eStr)
897 std::cout <<
"Error: " << eStr << std::endl;
int main(int argc, char *argv[])
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
StdRegions::VarCoeffMap m_varcoeff
Variable diffusivity.
void v_GenerateSummary(SolverUtils::SummaryList &s) override
Prints a summary of the model parameters.
void Morphogenesis(const NekDouble time, unsigned int field, Array< OneD, NekDouble > &outfield)
void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
InitWaveType m_InitWaveType
MMFDiffusion(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Constructor.
Array< OneD, NekDouble > m_epsu
void TestCubeProblem(const NekDouble time, Array< OneD, NekDouble > &outfield)
Array< OneD, NekDouble > m_epsilon
void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0) override
Sets a custom initial condition.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Computes the reaction terms and .
Array< OneD, NekDouble > PlanePhiWave()
void DoImplicitSolve(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, NekDouble time, NekDouble lambda)
Solve for the diffusion term.
static std::string className
Name of class.
~MMFDiffusion() override
Desctructor.
void TestPlaneProblem(const NekDouble time, Array< OneD, NekDouble > &outfield)
void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time) override
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
int m_spacedim
Spatial dimension (>= expansion dim).
virtual SOLVER_UTILS_EXPORT void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
virtual SOLVER_UTILS_EXPORT void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname)
Write field data to the given filename.
std::string m_sessionName
Name of the session.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
SOLVER_UTILS_EXPORT int GetTotPoints()
A base class for PDEs which include an advection component.
Array< OneD, Array< OneD, NekDouble > > m_DivMF
SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s) override
Virtual function for generating summary information.
Array< OneD, Array< OneD, NekDouble > > m_movingframes
SOLVER_UTILS_EXPORT void MMFInitObject(const Array< OneD, const Array< OneD, NekDouble > > &Anisotropy, const int TangentXelem=-1)
Base class for unsteady solvers.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
static NekDouble rad(NekDouble x, NekDouble y)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
std::vector< std::pair< std::string, std::string > > SummaryList
DriverFactory & GetDriverFactory()
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::map< ConstFactorType, NekDouble > ConstFactorMap
std::vector< double > z(NPUPPER)
std::vector< double > d(NPUPPER *NPUPPER)
StdRegions::ConstFactorMap factors
const char *const InitWaveTypeMap[]
@ SIZE_TestType
Length of enum list.
const char *const TestTypeMap[]
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.
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
void Neg(int n, T *x, const int incx)
Negate x = -x.
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
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
void Svtvm(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvm (scalar times vector minus vector): z = alpha*x - y.
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 Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
void Zero(int n, T *x, const int incx)
Zero vector.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)