Discontinuous Galerkin Library
#include "dg/algorithm.h"
base_geometryX.h
Go to the documentation of this file.
1#pragma once
2
3#include "gridX.h"
4#include "evaluationX.h"
5#include "tensor.h"
6
7namespace dg
8{
9
12
16template<class real_type>
17struct aRealGeometryX2d : public aRealTopologyX2d<real_type>
18{
21 return do_compute_jacobian();
22 }
25 return do_compute_metric();
26 }
28 std::vector<thrust::host_vector<real_type> > map()const{
29 return do_compute_map();
30 }
32 virtual aRealGeometryX2d* clone()const=0;
34 virtual ~aRealGeometryX2d() = default;
35 protected:
38 aRealGeometryX2d( const aRealGeometryX2d& src) = default;
41 private:
42 virtual SparseTensor<thrust::host_vector<real_type> > do_compute_metric()const {
44 }
45 virtual SparseTensor<thrust::host_vector<real_type> > do_compute_jacobian()const {
47 }
48 virtual std::vector<thrust::host_vector<real_type> > do_compute_map()const{
49 std::vector<thrust::host_vector<real_type> > map(2);
50 map[0] = dg::evaluate(dg::cooX2d, *this);
51 map[1] = dg::evaluate(dg::cooY2d, *this);
52 return map;
53 }
54
55
56};
57
61template<class real_type>
62struct aRealGeometryX3d : public aRealTopologyX3d<real_type>
63{
66 return do_compute_jacobian();
67 }
70 return do_compute_metric();
71 }
73 std::vector<thrust::host_vector<real_type> > map()const{
74 return do_compute_map();
75 }
77 virtual aRealGeometryX3d* clone()const=0;
79 virtual ~aRealGeometryX3d() = default;
80 protected:
83 aRealGeometryX3d( const aRealGeometryX3d& src) = default;
86 private:
87 virtual SparseTensor<thrust::host_vector<real_type> > do_compute_metric()const {
89 }
90 virtual SparseTensor<thrust::host_vector<real_type> > do_compute_jacobian()const {
92 }
93 virtual std::vector<thrust::host_vector<real_type> > do_compute_map()const{
94 std::vector<thrust::host_vector<real_type> > map(3);
95 map[0] = dg::evaluate(dg::cooX3d, *this);
96 map[1] = dg::evaluate(dg::cooY3d, *this);
97 map[2] = dg::evaluate(dg::cooZ3d, *this);
98 return map;
99 }
100};
101
103
106
110template<class real_type>
112{
114 RealCartesianGridX2d( real_type x0, real_type x1, real_type y0, real_type y1, real_type fx, real_type fy, unsigned n, unsigned Nx, unsigned Ny, bc bcx = PER, bc bcy = PER): dg::aRealGeometryX2d<real_type>(x0,x1,y0,y1,fx,fy,n,Nx,Ny,bcx,bcy){}
119 RealCartesianGridX2d( const dg::GridX2d& g):dg::aRealGeometryX2d<real_type>(g.x0(),g.x1(),g.y0(),g.y1(),g.fx(),g.fy(),g.n(),g.Nx(),g.Ny(),g.bcx(),g.bcy()){}
120 virtual RealCartesianGridX2d* clone()const override final{
121 return new RealCartesianGridX2d(*this);
122 }
123};
124
128template<class real_type>
130{
132 RealCartesianGridX3d( real_type x0, real_type x1, real_type y0, real_type y1, real_type z0, real_type z1, real_type fx, real_type fy, unsigned n, unsigned Nx, unsigned Ny, unsigned Nz, bc bcx = PER, bc bcy = PER, bc bcz = PER): dg::aRealGeometryX3d<real_type>(x0,x1,y0,y1,z0,z1,fx,fy,n,Nx,Ny,Nz,bcx,bcy,bcz){}
137 RealCartesianGridX3d( const dg::GridX3d& g):dg::aRealGeometryX3d<real_type>(g.x0(), g.x1(), g.y0(), g.y1(), g.z0(), g.z1(),g.fx(),g.fy(),g.n(),g.Nx(),g.Ny(),g.Nz(),g.bcx(),g.bcy(),g.bcz()){}
138 virtual RealCartesianGridX3d* clone()const override final{
139 return new RealCartesianGridX3d(*this);
140 }
141};
143
146template< class Functor, class real_type>
147thrust::host_vector<real_type> pullback( const Functor& f, const aRealGeometryX2d<real_type>& g)
148{
149 std::vector<thrust::host_vector<real_type> > map = g.map();
150 thrust::host_vector<real_type> vec( g.size());
151 for( unsigned i=0; i<g.size(); i++)
152 vec[i] = f( map[0][i], map[1][i]);
153 return vec;
154}
155
158template< class Functor, class real_type>
159thrust::host_vector<real_type> pullback( const Functor& f, const aRealGeometryX3d<real_type>& g)
160{
161 std::vector<thrust::host_vector<real_type> > map = g.map();
162 thrust::host_vector<real_type> vec( g.size());
163 for( unsigned i=0; i<g.size(); i++)
164 vec[i] = f( map[0][i], map[1][i], map[2][i]);
165 return vec;
166}
167
175} //namespace dg
Function discretization routines on X-point topology.
base X-point topology classes
static DG_DEVICE double cooY2d(double x, double y)
Definition: functions.h:45
static DG_DEVICE double cooZ3d(double x, double y, double z)
Definition: functions.h:49
static DG_DEVICE double cooY3d(double x, double y, double z)
Definition: functions.h:47
static DG_DEVICE double cooX2d(double x, double y)
Definition: functions.h:40
static DG_DEVICE double cooX3d(double x, double y, double z)
Definition: functions.h:42
bc
Switch between boundary conditions.
Definition: enums.h:15
@ PER
periodic boundaries
Definition: enums.h:16
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
thrust::host_vector< real_type > pullback(const Functor &f, const aRealGeometryX2d< real_type > &g)
Definition: base_geometryX.h:147
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
two-dimensional GridX with RealCartesian metric
Definition: base_geometryX.h:112
RealCartesianGridX2d(const dg::GridX2d &g)
Construct from existing topology.
Definition: base_geometryX.h:119
virtual RealCartesianGridX2d * clone() const override final
Geometries are cloneable.
Definition: base_geometryX.h:120
RealCartesianGridX2d(real_type x0, real_type x1, real_type y0, real_type y1, real_type fx, real_type fy, unsigned n, unsigned Nx, unsigned Ny, bc bcx=PER, bc bcy=PER)
Definition: base_geometryX.h:114
three-dimensional GridX with RealCartesian metric
Definition: base_geometryX.h:130
RealCartesianGridX3d(const dg::GridX3d &g)
Implicit type conversion from GridX3d.
Definition: base_geometryX.h:137
virtual RealCartesianGridX3d * clone() const override final
Geometries are cloneable.
Definition: base_geometryX.h:138
RealCartesianGridX3d(real_type x0, real_type x1, real_type y0, real_type y1, real_type z0, real_type z1, real_type fx, real_type fy, unsigned n, unsigned Nx, unsigned Ny, unsigned Nz, bc bcx=PER, bc bcy=PER, bc bcz=PER)
Definition: base_geometryX.h:132
The simplest implementation of aRealTopologyX2d.
Definition: gridX.h:514
The simplest implementation of aRealTopologyX3d.
Definition: gridX.h:806
Class for 2x2 and 3x3 matrices sharing elements.
Definition: tensor.h:66
This is the abstract interface class for a two-dimensional RealGeometryX.
Definition: base_geometryX.h:18
aRealGeometryX2d & operator=(const aRealGeometryX2d &src)=default
SparseTensor< thrust::host_vector< real_type > > jacobian() const
The Jacobian of the coordinate transformation from physical to computational space.
Definition: base_geometryX.h:20
std::vector< thrust::host_vector< real_type > > map() const
The coordinate map from computational to physical space.
Definition: base_geometryX.h:28
SparseTensor< thrust::host_vector< real_type > > metric() const
The (inverse) metric tensor of the coordinate system.
Definition: base_geometryX.h:24
virtual aRealGeometryX2d * clone() const =0
Geometries are cloneable.
aRealGeometryX2d(const aRealGeometryX2d &src)=default
virtual ~aRealGeometryX2d()=default
allow deletion through base class pointer
This is the abstract interface class for a three-dimensional RealGeometryX.
Definition: base_geometryX.h:63
aRealGeometryX3d & operator=(const aRealGeometryX3d &src)=default
virtual ~aRealGeometryX3d()=default
allow deletion through base class pointer
SparseTensor< thrust::host_vector< real_type > > jacobian() const
The Jacobian of the coordinate transformation from physical to computational space.
Definition: base_geometryX.h:65
SparseTensor< thrust::host_vector< real_type > > metric() const
The (inverse) metric tensor of the coordinate system.
Definition: base_geometryX.h:69
aRealGeometryX3d(const aRealGeometryX3d &src)=default
virtual aRealGeometryX3d * clone() const =0
Geometries are cloneable.
std::vector< thrust::host_vector< real_type > > map() const
The coordinate map from computational to physical space.
Definition: base_geometryX.h:73
A 2D grid class with X-point topology.
Definition: gridX.h:257
unsigned size() const
real_typehe total number of points
Definition: gridX.h:394
real_type y0() const
left boundary in y
Definition: gridX.h:280
bc bcy() const
boundary conditions in y
Definition: gridX.h:376
real_type y1() const
Right boundary in y.
Definition: gridX.h:286
unsigned Nx() const
number of cells in x
Definition: gridX.h:334
real_type x1() const
Right boundary in x.
Definition: gridX.h:274
real_type x0() const
Left boundary in x.
Definition: gridX.h:268
real_type fx() const
partition factor in x
Definition: gridX.h:316
bc bcx() const
boundary conditions in x
Definition: gridX.h:370
unsigned Ny() const
number of cells in y
Definition: gridX.h:352
real_type fy() const
partition factor in y
Definition: gridX.h:322
unsigned n() const
number of polynomial coefficients in x and y
Definition: gridX.h:328
A 3D grid class with X-point topology.
Definition: gridX.h:541
bc bcx() const
boundary conditions in x
Definition: gridX.h:687
unsigned n() const
number of polynomial coefficients in x and y
Definition: gridX.h:639
real_type y1() const
right boundary in y
Definition: gridX.h:570
real_type z1() const
right boundary in z
Definition: gridX.h:583
real_type fx() const
partition factor in x
Definition: gridX.h:627
unsigned Nz() const
number of points in z
Definition: gridX.h:681
unsigned Ny() const
number of cells in y
Definition: gridX.h:663
unsigned Nx() const
number of points in x
Definition: gridX.h:645
bc bcy() const
boundary conditions in y
Definition: gridX.h:693
unsigned size() const
real_typehe total number of points
Definition: gridX.h:719
real_type z0() const
left boundary in z
Definition: gridX.h:577
real_type y0() const
left boundary in y
Definition: gridX.h:564
real_type x0() const
left boundary in x
Definition: gridX.h:551
real_type x1() const
right boundary in x
Definition: gridX.h:557
real_type fy() const
partition factor in y
Definition: gridX.h:633
bc bcz() const
boundary conditions in z
Definition: gridX.h:699