The abstract generator base class.
A generator is there to construct coordinate transformations from physical coordinates \( x,y\) to the computational domain \(\zeta, \eta\), which is a product space. It can be used to construct curvilinear grids like the following code snippet demonstrates:
std::unique_ptr<dg::geo::aGenerator2d> generator;
js["magnetic_field"]["params"]);
std::string type = js["grid"]["generator"]["type"].asString();
int mode = 0;
if( type != "dsp")
mode = js["grid"]["generator"]["mode"].asInt();
std::cout << "Constructing "<<type<<" grid ... \n";
if( type == "flux")
generator = std::make_unique<dg::geo::FluxGenerator>( mag.
get_psip(),
mag.
get_ipol(), psi_0, psi_1, mag.
R0(), 0., mode,
false);
else if( type == "orthogonal")
{
double psi_init = js["grid"]["generator"]["firstline"].asDouble();
if( mode == 0 || mode == 1)
generator = std::make_unique<dg::geo::SimpleOrthogonal>(
mag.
get_psip(), psi_0, psi_1, mag.
R0(), 0., psi_init, mode);
if( mode > 1)
{
generator = std::make_unique<dg::geo::SimpleOrthogonal>(
mag.
get_psip(), lc, psi_0, psi_1, mag.
R0(), 0., psi_init,
mode%2);
}
}
else if( type == "separatrix-orthogonal")
{
double fx = js["grid"]["generator"]["fx"].asDouble();
generator = std::make_unique<dg::geo::SeparatrixOrthogonalAdaptor>(
mag.
get_psip(), monitor_chi, psi_0, RX, ZX, mag.
R0(), 0., mode,
false, fx);
}
else if ( type == "dsp")
{
double boxscaleRm = js["grid"][ "scaleR"].get( 0u, 1.05).asDouble();
double boxscaleRp = js["grid"][ "scaleR"].get( 1u, 1.05).asDouble();
double boxscaleZm = js["grid"][ "scaleZ"].get( 0u, 1.05).asDouble();
double boxscaleZp = js["grid"][ "scaleZ"].get( 1u, 1.05).asDouble();
const double Rmin=mag.
R0()-boxscaleRm*mag.
params().
a();
const double Zmin=-boxscaleZm*mag.
params().
a();
const double Rmax=mag.
R0()+boxscaleRp*mag.
params().
a();
const double Zmax=boxscaleZp*mag.
params().
a();
generator = std::make_unique<dg::geo::DSPGenerator>( mag,
Rmin, Rmax, Zmin, Zmax, 2.*M_PI/(double)Nz);
}
else if( type == "ribeiro-flux")
generator = std::make_unique<dg::geo::RibeiroFluxGenerator>( mag.
get_psip(),
psi_0, psi_1, mag.
R0(), 0., mode,
false);
else if( type == "ribeiro")
generator = std::make_unique<dg::geo::Ribeiro>( mag.
get_psip(),
psi_0, psi_1, mag.
R0(), 0., mode,
false);
static TokamakMagneticField createMagneticField(dg::file::WrappedJsonValue gs)
Create a Magnetic field based on the given parameters.
Definition: make_field.h:75
static void findXpoint(const CylindricalFunctorsLvl2 &psi, double &RC, double &ZC)
This function finds X-points of psi.
Definition: fluxfunctions.h:350
static CylindricalSymmTensorLvl1 make_LiseikinCollective(const CylindricalFunctorsLvl2 &psi, double k, double eps)
Definition: adaption.h:254
static CylindricalSymmTensorLvl1 make_Xconst_monitor(const CylindricalFunctorsLvl2 &psi, double &R_X, double &Z_X)
construct a monitor metric in which the Laplacian vanishes at the X-point
Definition: utilitiesX.h:92
Definition: fluxfunctions.h:361
double a() const
The minor radius.
Definition: magnetic_field.h:122
double elongation() const
Definition: magnetic_field.h:128
double triangularity() const
Definition: magnetic_field.h:134
A tokamak field as given by R0, Psi and Ipol plus Meta-data like shape and equilibrium.
Definition: magnetic_field.h:162
const CylindricalFunctorsLvl2 & get_psip() const
Definition: magnetic_field.h:197
const CylindricalFunctorsLvl1 & get_ipol() const
Definition: magnetic_field.h:198
const MagneticFieldParameters & params() const
Access Meta-data of the field.
Definition: magnetic_field.h:204
double R0() const
Definition: magnetic_field.h:177