Extension: Geometries
#include "dg/geometries/geometries.h"
dg::geo::aRealGenerator2d< real_type > Struct Template Referenceabstract

The abstract generator base class. More...

Inheritance diagram for dg::geo::aRealGenerator2d< real_type >:
[legend]

Public Member Functions

real_type width () const
 length in \( \zeta\) of the computational space More...
 
real_type height () const
 length in \( \eta\) of the computational space More...
 
bool isOrthogonal () const
 sparsity pattern for metric More...
 
void generate (const thrust::host_vector< real_type > &zeta1d, const thrust::host_vector< real_type > &eta1d, thrust::host_vector< real_type > &x, thrust::host_vector< real_type > &y, thrust::host_vector< real_type > &zetaX, thrust::host_vector< real_type > &zetaY, thrust::host_vector< real_type > &etaX, thrust::host_vector< real_type > &etaY) const
 Generate grid points and elements of the Jacobian. More...
 
virtual aRealGenerator2dclone () const =0
 Abstract clone method that returns a copy on the heap. More...
 
virtual ~aRealGenerator2d ()
 

Protected Member Functions

 aRealGenerator2d ()
 empty More...
 
 aRealGenerator2d (const aRealGenerator2d &)
 empty More...
 
aRealGenerator2doperator= (const aRealGenerator2d &)
 return *this More...
 

Detailed Description

template<class real_type>
struct dg::geo::aRealGenerator2d< real_type >

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;
//create the magnetic field
js["magnetic_field"]["params"]);
//create a grid generator
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 RX = mag.R0()-1.1*mag.params().triangularity()*mag.params().a();
double ZX = -1.1*mag.params().elongation()*mag.params().a();
dg::geo::findXpoint( mag.get_psip(), RX, ZX);
//dg::geo::CylindricalSymmTensorLvl1 monitor_chi;
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);
//psi_1 = -fx/(1.-fx)*psi_0;
}
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
Note
the origin of the computational space is assumed to be (0,0)

Constructor & Destructor Documentation

◆ ~aRealGenerator2d()

template<class real_type >
virtual dg::geo::aRealGenerator2d< real_type >::~aRealGenerator2d ( )
inlinevirtual

◆ aRealGenerator2d() [1/2]

template<class real_type >
dg::geo::aRealGenerator2d< real_type >::aRealGenerator2d ( )
inlineprotected

empty

◆ aRealGenerator2d() [2/2]

template<class real_type >
dg::geo::aRealGenerator2d< real_type >::aRealGenerator2d ( const aRealGenerator2d< real_type > &  )
inlineprotected

empty

Member Function Documentation

◆ clone()

template<class real_type >
virtual aRealGenerator2d * dg::geo::aRealGenerator2d< real_type >::clone ( ) const
pure virtual

◆ generate()

template<class real_type >
void dg::geo::aRealGenerator2d< real_type >::generate ( const thrust::host_vector< real_type > &  zeta1d,
const thrust::host_vector< real_type > &  eta1d,
thrust::host_vector< real_type > &  x,
thrust::host_vector< real_type > &  y,
thrust::host_vector< real_type > &  zetaX,
thrust::host_vector< real_type > &  zetaY,
thrust::host_vector< real_type > &  etaX,
thrust::host_vector< real_type > &  etaY 
) const
inline

Generate grid points and elements of the Jacobian.

Parameters
zeta1d(input) a list of \( N_\zeta\) points \( 0<\zeta_i<\)width()
eta1d(input) a list of \( N_\eta\) points \( 0<\eta_j<\)height()
x(output) the list of \( N_\eta N_\zeta\) coordinates \( x(\zeta_i, \eta_j)\)
y(output) the list of \( N_\eta N_\zeta\) coordinates \( y(\zeta_i, \eta_j)\)
zetaX(output) the list of \( N_\eta N_\zeta\) elements \( \partial\zeta/\partial x (\zeta_i, \eta_j)\)
zetaY(output) the list of \( N_\eta N_\zeta\) elements \( \partial\zeta/\partial y (\zeta_i, \eta_j)\)
etaX(output) the list of \( N_\eta N_\zeta\) elements \( \partial\eta/\partial x (\zeta_i, \eta_j)\)
etaY(output) the list of \( N_\eta N_\zeta\) elements \( \partial\eta/\partial y (\zeta_i, \eta_j)\)
Note
the first ( \( \zeta\)) coordinate shall be constructed contiguously in memory, i.e. the resuling lists are \( x_0=x(\zeta_0, \eta_0),\ x_1=x(\zeta_1, \eta_0)\ x_2=x(\zeta_2, \eta_0)\dots x_{NM-1}=x(\zeta_{N-1} \eta_{M-1})\)
All the resulting vectors are write-only and get properly resized

◆ height()

template<class real_type >
real_type dg::geo::aRealGenerator2d< real_type >::height ( ) const
inline

length in \( \eta\) of the computational space

◆ isOrthogonal()

template<class real_type >
bool dg::geo::aRealGenerator2d< real_type >::isOrthogonal ( ) const
inline

sparsity pattern for metric

◆ operator=()

template<class real_type >
aRealGenerator2d & dg::geo::aRealGenerator2d< real_type >::operator= ( const aRealGenerator2d< real_type > &  )
inlineprotected

return *this

◆ width()

template<class real_type >
real_type dg::geo::aRealGenerator2d< real_type >::width ( ) const
inline

length in \( \zeta\) of the computational space


The documentation for this struct was generated from the following file: