73template<
class real_type>
77template<
class host_vector>
80 std::vector<host_vector> values( 5, R);
83 dg::blas1::pointwiseDot( 1., jac.
value(0,0), jac.
value(0,0), 1., jac.
value(0,1), jac.
value(0,1), 0., values[1]);
84 dg::blas1::pointwiseDot( 1., jac.
value(1,0), jac.
value(1,0), 1., jac.
value(1,1), jac.
value(1,1), 0., values[2]);
88 dg::blas1::pointwiseDot( 1., jac.
value(0,0), jac.
value(1,0), 1., jac.
value(0,1), jac.
value(1,1), 0., values[4]);
91 metric.values().pop_back();
92 metric.idx(0,0) = 1; metric.values().push_back( values[1]);
93 metric.idx(1,1) = 2; metric.values().push_back( values[2]);
94 metric.idx(2,2) = 3; metric.values().push_back( values[3]);
97 metric.idx(1,0) = metric.idx(0,1) = 4;
98 metric.values().push_back( values[4]);
111template<
class real_type>
119 dg::
aRealGeometry2d<real_type>( {0,
generator.width(), tx.
n, tx.
N, tx.
b}, {0.,
generator.height(), ty.n, ty.N, ty.b}), m_handle(
generator)
121 construct( tx.n, tx.N, ty.n, ty.N);
134 virtual void do_set(
unsigned nx,
unsigned Nx,
unsigned ny,
unsigned Ny)
override final
139 void construct(
unsigned nx,
unsigned Nx,
unsigned ny,
unsigned Ny);
143 virtual SparseTensor<thrust::host_vector<real_type>> do_compute_metric( ) const override final{
146 virtual std::vector<thrust::host_vector<real_type>> do_compute_map()const override final{
return m_map;}
148 std::vector<thrust::host_vector<real_type>> m_map;
158template<
class real_type>
165 RealCurvilinearProductGrid3d(
generator, {
n,
Nx,
bcx}, {
n,
Ny,
bcy}, {0., 2.*
M_PI, 1,
Nz,
bcz}){}
169 dg::
aRealProductGeometry3d<real_type>( {0,
generator.width(), tx.
n, tx.
N, tx.
b}, {0.,
generator.height(), ty.n, ty.N, ty.b},
gz), m_handle(
generator)
172 constructPerp( this->
nx(), this->
Nx(), this->
ny(), this->
Ny());
173 constructParallel(this->
nz(), this->
Nz());
182 virtual
void do_set(
unsigned nx,
unsigned Nx,
unsigned ny,
unsigned Ny,
unsigned nz,
unsigned Nz) override final{
184 if( !(
nx == this->
nx() && Nx == this->
Nx() && ny == this->
ny() && Ny == this->
Ny() ) )
186 constructParallel(
nz,
Nz);
189 void constructParallel(
unsigned nz,
unsigned Nz)
193 unsigned size2d = this->
nx()*this->
ny()*this->
Nx()*this->
Ny();
195 for(
unsigned r=0; r<6;r++)
197 m_map[0].resize(
size);
198 m_map[1].resize(
size);
200 for(
unsigned k=1; k<
nz*
Nz; k++)
201 for(
unsigned i=0; i<size2d; i++)
203 for(
unsigned r=0; r<6; r++)
204 m_jac.
values()[r][k*size2d+i] = m_jac.
values()[r][(k-1)*size2d+i];
205 m_map[0][k*size2d+i] = m_map[0][(k-1)*size2d+i];
206 m_map[1][k*size2d+i] = m_map[1][(k-1)*size2d+i];
210 void constructPerp(
unsigned nx,
unsigned Nx,
unsigned ny,
unsigned Ny)
216 m_jac = SparseTensor< thrust::host_vector<real_type>>( x_vec);
217 m_jac.
values().resize( 6);
218 m_handle->generate( x_vec, y_vec, m_map[0], m_map[1], m_jac.
values()[2], m_jac.
values()[3], m_jac.
values()[4], m_jac.
values()[5]);
219 m_jac.
idx(0,0) = 2, m_jac.
idx(0,1) = 3, m_jac.
idx(1,0)=4, m_jac.
idx(1,1) = 5;
221 virtual SparseTensor<thrust::host_vector<real_type> > do_compute_jacobian( ) const override final{
224 virtual SparseTensor<thrust::host_vector<real_type> > do_compute_metric( ) const override final
226 return detail::square( m_jac, m_map[0], m_handle->isOrthogonal());
228 virtual std::vector<thrust::host_vector<real_type> > do_compute_map()const override final{
return m_map;}
229 std::vector<thrust::host_vector<real_type> > m_map;
230 SparseTensor<thrust::host_vector<real_type> > m_jac;
245template<
class real_type>
249 g.
set( this->nx(), this->Nx(), this->ny(), this->Ny(), 1, 1);
259template<
class real_type>
260void RealCurvilinearGrid2d<real_type>::construct(
unsigned nx,
unsigned Nx,
unsigned ny,
unsigned Ny)
262 RealCurvilinearProductGrid3d<real_type> g( *m_handle, {nx,Nx,this->bcx()}, {ny,Ny,this->bcy()}, {0., 2.*
M_PI, 1,1});
263 *
this = RealCurvilinearGrid2d<real_type>(g);
265template<
class real_type>
static DG_DEVICE double cooX1d(double x)
static DG_DEVICE double cooZ3d(double x, double y, double z)
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
void scal(ContainerType &x, get_value_type< ContainerType > alpha)
void pointwiseDivide(get_value_type< ContainerType > alpha, const ContainerType1 &x1, const ContainerType2 &x2, get_value_type< ContainerType > beta, ContainerType &y)
void pointwiseDot(get_value_type< ContainerType > alpha, const ContainerType1 &x1, const ContainerType2 &x2, get_value_type< ContainerType > beta, ContainerType &y)
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
@ square
closed flux surfaces centered around an O-point and bordered by a square with four X-points in the co...
CurvilinearGrid2d CurvilinearGrid2d
Definition: curvilinear.h:238
CurvilinearProductGrid3d CurvilinearProductGrid3d
Definition: curvilinear.h:239
int idx(unsigned i, unsigned j) const
std::vector< container > & values()
const container & value(size_t i, size_t j) const
SparseTensor< thrust::host_vector< real_type > > jacobian() const
SparseTensor< thrust::host_vector< real_type > > metric() const
std::vector< thrust::host_vector< real_type > > map() const
virtual void do_set(unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny)=0
const RealGrid1d< real_type > & gz() const
virtual void do_set(unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny, unsigned new_nz, unsigned new_Nz)=0
void set(unsigned new_n, unsigned new_Nx, unsigned new_Ny, unsigned new_Nz)
A two-dimensional grid based on curvilinear coordinates.
Definition: curvilinear.h:113
RealCurvilinearGrid2d(const aRealGenerator2d< real_type > &generator, unsigned n, unsigned Nx, unsigned Ny, dg::bc bcx=dg::DIR, bc bcy=dg::PER)
Construct a 2D grid.
Definition: curvilinear.h:115
const aRealGenerator2d< real_type > & generator() const
read access to the generator
Definition: curvilinear.h:131
RealCurvilinearGrid2d(const aRealGenerator2d< real_type > &generator, Topology1d tx, Topology1d ty)
Construct the computational space as the product of two 1d grids.
Definition: curvilinear.h:118
virtual RealCurvilinearGrid2d * clone() const override final
Definition: curvilinear.h:132
RealCurvilinearGrid2d(RealCurvilinearProductGrid3d< real_type > g)
Explicitly convert 3d product grid to the perpendicular grid.
A 2x1 curvilinear product space grid.
Definition: curvilinear.h:160
const aRealGenerator2d< real_type > & generator() const
read access to the generator
Definition: curvilinear.h:178
RealCurvilinearProductGrid3d(const aRealGenerator2d< real_type > &generator, unsigned n, unsigned Nx, unsigned Ny, unsigned Nz, bc bcx=dg::DIR, bc bcy=dg::PER, bc bcz=dg::PER)
Construct a 3D grid.
Definition: curvilinear.h:164
virtual RealCurvilinearProductGrid3d * clone() const override final
Definition: curvilinear.h:179
RealCurvilinearGrid2d< real_type > perpendicular_grid
Definition: curvilinear.h:161
RealCurvilinearProductGrid3d(const aRealGenerator2d< real_type > &generator, Topology1d tx, Topology1d ty, RealGrid1d< real_type > gz)
Construct the computational space as the product of three 1d grids.
Definition: curvilinear.h:168
Helper class for construction.
Definition: curvilinear.h:65
unsigned n
Definition: curvilinear.h:66
bc b
Definition: curvilinear.h:68
unsigned N
Definition: curvilinear.h:67
The abstract generator base class.
Definition: generator.h:20