Extension: Geometries
#include "dg/geometries/geometries.h"
polar.h
Go to the documentation of this file.
1#pragma once
2#include "generator.h"
3
4namespace dg {
5namespace geo {
6
16{
17 private:
18 double r_min, r_max;
19
20 public:
21
28 PolarGenerator(double _r_min, double _r_max) : r_min(_r_min), r_max(_r_max) {}
29 virtual PolarGenerator* clone() const override final{return new PolarGenerator(*this); }
30
31 private:
32 virtual void do_generate(
33 const thrust::host_vector<double>& zeta1d,
34 const thrust::host_vector<double>& eta1d,
35 thrust::host_vector<double>& x,
36 thrust::host_vector<double>& y,
37 thrust::host_vector<double>& zetaX,
38 thrust::host_vector<double>& zetaY,
39 thrust::host_vector<double>& etaX,
40 thrust::host_vector<double>& etaY) const override final {
41
42 int size_r = zeta1d.size();
43 int size_phi = eta1d.size();
44 int size = size_r*size_phi;
45
46 x.resize(size); y.resize(size);
47 zetaX.resize(size); zetaY.resize(size);
48 etaX.resize(size); etaY.resize(size);
49
50 // the first coordinate has stride=1
51 for(int j=0;j<size_phi;j++)
52 for(int i=0;i<size_r;i++) {
53 double r = zeta1d[i] + r_min;
54 double phi = eta1d[j];
55
56 x[i+size_r*j] = r*cos(phi);
57 y[i+size_r*j] = r*sin(phi);
58
59 zetaX[i+size_r*j] = cos(phi);
60 zetaY[i+size_r*j] = sin(phi);
61 etaX[i+size_r*j] = -sin(phi)/r;
62 etaY[i+size_r*j] = cos(phi)/r;
63 }
64
65 }
66
67 virtual double do_width() const override final{return r_max-r_min;}
68 virtual double do_height() const override final{return 2*M_PI;}
69 virtual bool do_isOrthogonal() const override final{return true;}
70};
71
72
82{
83 private:
84 double r_min, r_max;
85
86 public:
87
94 LogPolarGenerator(double _r_min, double _r_max) : r_min(_r_min), r_max(_r_max) {}
95 virtual LogPolarGenerator* clone() const override final{return new LogPolarGenerator(*this); }
96
97 private:
98 virtual void do_generate(
99 const thrust::host_vector<double>& zeta1d,
100 const thrust::host_vector<double>& eta1d,
101 thrust::host_vector<double>& x,
102 thrust::host_vector<double>& y,
103 thrust::host_vector<double>& zetaX,
104 thrust::host_vector<double>& zetaY,
105 thrust::host_vector<double>& etaX,
106 thrust::host_vector<double>& etaY) const override final{
107
108 int size_r = zeta1d.size();
109 int size_phi = eta1d.size();
110 int size = size_r*size_phi;
111
112 x.resize(size); y.resize(size);
113 zetaX.resize(size); zetaY.resize(size);
114 etaX.resize(size); etaY.resize(size);
115
116 // the first coordinate has stride=1
117 for(int j=0;j<size_phi;j++)
118 for(int i=0;i<size_r;i++) {
119 double l = zeta1d[i] + log(r_min);
120 double phi = eta1d[j];
121
122 x[i+size_r*j] = exp(l)*cos(phi);
123 y[i+size_r*j] = exp(l)*sin(phi);
124
125 zetaX[i+size_r*j] = cos(phi)*exp(-l);
126 zetaY[i+size_r*j] = sin(phi)*exp(-l);
127 etaX[i+size_r*j] = -sin(phi)*exp(-l);
128 etaY[i+size_r*j] = cos(phi)*exp(-l);
129 }
130
131 }
132
133 virtual double do_width() const override final{return log(r_max)-log(r_min);}
134 virtual double do_height() const override final{return 2*M_PI;}
135 virtual bool do_isOrthogonal() const override final{return true;}
136};
137
138}
139}
#define M_PI
Log Polar coordinates (conformal)
Definition: polar.h:82
LogPolarGenerator(double _r_min, double _r_max)
Construct a ring with minimal and maximal radius.
Definition: polar.h:94
virtual LogPolarGenerator * clone() const override final
Abstract clone method that returns a copy on the heap.
Definition: polar.h:95
Polar coordinates.
Definition: polar.h:16
virtual PolarGenerator * clone() const override final
Abstract clone method that returns a copy on the heap.
Definition: polar.h:29
PolarGenerator(double _r_min, double _r_max)
Construct a ring with minimal and maximal radius.
Definition: polar.h:28
The abstract generator base class.
Definition: generator.h:20