PLaSK library
Loading...
Searching...
No Matches
transformed.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK__MESH_TRANSFORMED_H
15#define PLASK__MESH_TRANSFORMED_H
16
17#include "mesh.hpp"
18#include "../geometry/space.hpp"
19
20namespace plask {
21
25//TODO better version for rectangular source (with size reduction by the size of removed axis)
26struct ReductionTo2DMesh: public MeshD<2> {
27
30
33
35 enum { SRC_DIM = 3 };
36
38
40
43
46
47 Vec<2, double> at(std::size_t index) const override {
48 return vec<2>(sourceMesh->at(index)) - translation;
49 }
50
51 std::size_t size() const override {
52 return sourceMesh->size();
53 }
54};
55
56
61
64
67
69 enum { SRC_DIM = 3 };
70
72
74
75 CylReductionTo2DMesh(const shared_ptr<const MeshD<3>> sourceMesh, const Vec<3,double>& translation=Primitive<3>::ZERO_VEC)
76 : translation(translation), sourceMesh(sourceMesh) {}
77
78 Vec<2, double> at(std::size_t index) const override {
79 return rotateToLonTranAbs(sourceMesh->at(index) - translation);
80 }
81
82 std::size_t size() const override {
83 return sourceMesh->size();
84 }
85
86 Vec<3,double> rVector(std::size_t index) const {
87 return sourceMesh->at(index) - translation;
88 }
89};
90
91
97
98 Vec<3,double> translation;
99
100 const shared_ptr<const MeshD<2>> sourceMesh;
101
102public:
103
106
109
111 enum { SRC_DIM = 2 };
112
113 CartesianMesh2DTo3D(const shared_ptr<const MeshD<2>>& sourceMesh, Vec<3,double> translation=Primitive<3>::ZERO_VEC, double lon=0)
114 : translation(translation), sourceMesh(sourceMesh) {
115 this->translation.lon() += lon;
116 }
117
118 Vec<3, double> at(std::size_t index) const override {
119 return vec3Dplus2D(translation, sourceMesh->at(index));
120 }
121
122 std::size_t size() const override {
123 return sourceMesh->size();
124 }
125};
126
127
134
135 const shared_ptr<const MeshD<2>> sourceMesh;
136
137 Vec<3,double> translation;
138
139 double stepSize;
140
142 std::size_t pointsCount;
143
144public:
145
148
151
153 enum { SRC_DIM = 2 };
154
155 CartesianMesh2DTo3DExtend(const shared_ptr<const MeshD<2>>& sourceMesh, const Vec<3,double>& translation, double longBegin, double lonSize, std::size_t pointsCount=10)
156 : sourceMesh(sourceMesh), translation(translation), stepSize(lonSize / double(pointsCount-1)), pointsCount(pointsCount) {
157 this->translation.lon() += longBegin;
158 }
159
160 Vec<3, double> at(std::size_t index) const override {
161 return translation + vec(sourceMesh->at(index / pointsCount), stepSize * double(index));
162 }
163
164 std::size_t size() const override {
165 return sourceMesh->size() * pointsCount;
166 }
167};
168
169
176
178
180
181 double slice;
182
183 std::size_t pointsCount;
184
186 return Vec<3, double>(this->translation.lon(), this->translation.tran(), this->translation.vert() + p.rad_z());
187 }
188
189public:
190
193
196
198 enum { SRC_DIM = 2 };
199
200 PointsOnCircleMeshExtend(const shared_ptr<const MeshD<2>>& sourceMesh, const Vec<3, double>& translation=Primitive<3>::ZERO_VEC, std::size_t pointsCount=18)
201 : sourceMesh(sourceMesh), translation(translation), slice(PI_DOUBLED / double(pointsCount)), pointsCount(pointsCount) {
202 }
203
204 Vec<3, double> at(std::size_t index) const override {
205 Vec<2, double> p = sourceMesh->at(index / pointsCount);
206 const double angle = slice * double(index % pointsCount);
207 return Vec<3, double>(
208 this->translation.lon() + p.rad_r() * cos(angle),
209 this->translation.tran() + p.rad_r() * sin(angle),
210 this->translation.vert() + p.rad_z()
211 );
212 }
213
214 std::size_t size() const override {
215 return sourceMesh->size() * pointsCount;
216 }
217
218 Vec<3,double> rVector(std::size_t index) const {
219 return at(index) - translation;
220 }
221};
222
223} // namespace plask
224
225#endif // PLASK__MESH_TRANSFORMED_H