PLaSK library
Loading...
Searching...
No Matches
rectangular3d.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__RECTANGULAR3D_H
15#define PLASK__RECTANGULAR3D_H
16
22#include "rectilinear3d.hpp"
23#include "../optional.hpp"
24
25namespace plask {
26
37
38 public:
39
41
47
56 RectangularMesh3D(shared_ptr<MeshAxis> mesh0, shared_ptr<MeshAxis> mesh1, shared_ptr<MeshAxis> mesh2, IterationOrder iterationOrder = ORDER_012);
57
63 RectangularMesh3D(const RectangularMesh3D& src, bool clone_axes = false);
64
69 const shared_ptr<MeshAxis>& lon() const { return axis[0]; }
70
75 const shared_ptr<MeshAxis>& tran() const { return axis[1]; }
76
81 const shared_ptr<MeshAxis>& vert() const { return axis[2]; }
82
87 const shared_ptr<MeshAxis>& ee_z() const { return axis[0]; }
88
93 const shared_ptr<MeshAxis>& ee_x() const { return axis[1]; }
94
99 const shared_ptr<MeshAxis>& ee_y() const { return axis[2]; }
100
105 const shared_ptr<MeshAxis>& rad_r() const { return axis[0]; }
106
111 const shared_ptr<MeshAxis>& rad_phi() const { return axis[1]; }
112
117 const shared_ptr<MeshAxis>& rad_z() const { return axis[2]; }
118
123 void writeXML(XMLElement& object) const override;
124
125 using RectilinearMesh3D::at; // MSVC needs this
126
134 Vec<3, double> at(std::size_t index0, std::size_t index1, std::size_t index2) const override {
135 return Vec<3, double>(axis[0]->at(index0), axis[1]->at(index1), axis[2]->at(index2));
136 }
137
142 shared_ptr<RectangularMesh3D::ElementMesh> getElementMesh() const;
143
149 double getElementArea(std::size_t index0, std::size_t index1, std::size_t index2) const {
150 return (axis[0]->at(index0+1) - axis[0]->at(index0)) * (axis[1]->at(index1+1) - axis[1]->at(index1)) * (axis[2]->at(index2+1) - axis[2]->at(index2));
151 }
152
158 double getElementArea(std::size_t element_index) const {
159 std::size_t bl_index = getElementMeshLowIndex(element_index);
160 return getElementArea(index0(bl_index), index1(bl_index), index2(bl_index));
161 }
162
168 Vec<3, double> getElementMidpoint(std::size_t index0, std::size_t index1, std::size_t index2) const override {
169 return vec(getElementMidpoint0(index0), getElementMidpoint1(index1), getElementMidpoint2(index2));
170 }
171
178 std::size_t bl_index = getElementMeshLowIndex(element_index);
179 return getElementMidpoint(index0(bl_index), index1(bl_index), index2(bl_index));
180 }
181
187 Box3D getElementBox(std::size_t index0, std::size_t index1, std::size_t index2) const {
188 return Box3D(axis[0]->at(index0), axis[1]->at(index1), axis[2]->at(index2), axis[0]->at(index0+1), axis[1]->at(index1+1), axis[2]->at(index2+1));
189 }
190
196 Box3D getElementBox(std::size_t element_index) const {
197 std::size_t bl_index = getElementMeshLowIndex(element_index);
198 return getElementBox(index0(bl_index), index1(bl_index), index2(bl_index));
199 }
200
201};
202
203template <typename SrcT, typename DstT>
206 const shared_ptr<const MeshD<3>>& dst_mesh, const InterpolationFlags& flags) {
207 if (src_mesh->axis[0]->size() == 0 || src_mesh->axis[1]->size() == 0 || src_mesh->axis[2]->size() == 0)
208 throw BadMesh("interpolate", "source mesh empty");
209 return new LinearInterpolatedLazyDataImpl<DstT, RectilinearMesh3D, SrcT>(src_mesh, src_vec, dst_mesh, flags);
210 }
211};
212
213template <typename SrcT, typename DstT>
216 const shared_ptr<const MeshD<3>>& dst_mesh, const InterpolationFlags& flags) {
217 if (src_mesh->axis[0]->size() == 0 || src_mesh->axis[1]->size() == 0 || src_mesh->axis[2]->size() == 0)
218 throw BadMesh("interpolate", "source mesh empty");
219 return new NearestNeighborInterpolatedLazyDataImpl<DstT, RectilinearMesh3D, SrcT>(src_mesh, src_vec, dst_mesh, flags);
220 }
221};
222
223
224
225template <typename SrcT, typename DstT, InterpolationMethod method>
226struct InterpolationAlgorithm<typename std::enable_if<method != INTERPOLATION_DEFAULT, RectangularMesh3D::ElementMesh>::type, SrcT, DstT, method> {
228 const shared_ptr<const MeshD<3>>& dst_mesh, const InterpolationFlags& flags) {
230 }
231};
232
233template <typename SrcT, typename DstT>
236 const shared_ptr<const MeshD<3>>& dst_mesh, const InterpolationFlags& flags) {
237 if (src_mesh->axis[0]->size() == 0 || src_mesh->axis[1]->size() == 0)
238 throw BadMesh("interpolate", "source mesh empty");
240 }
241};
242
243
251
252} // namespace plask
253
254#endif // PLASK__RECTANGULAR3D_H