PLaSK library
Loading...
Searching...
No Matches
rectangular3d.cpp
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#include "rectangular3d.hpp"
15
16#include "regular1d.hpp"
17#include "ordered1d.hpp"
18
19namespace plask {
20
21
23 return plask::make_shared<RectangularMesh3D::ElementMesh>(this, axis[0]->getMidpointAxis(), axis[1]->getMidpointAxis(), axis[2]->getMidpointAxis(), getIterationOrder());
24}
25
27
28RectangularMesh3D::RectangularMesh3D(shared_ptr<MeshAxis> mesh0, shared_ptr<MeshAxis> mesh1, shared_ptr<MeshAxis> mesh2, IterationOrder iterationOrder):
29 RectilinearMesh3D(std::move(mesh0), std::move(mesh1), std::move(mesh2), iterationOrder) {}
30
32
34 object.attr("type", "rectangular3d");
35 { auto a = object.addTag("axis0"); axis[0]->writeXML(a); }
36 { auto a = object.addTag("axis1"); axis[1]->writeXML(a); }
37 { auto a = object.addTag("axis2"); axis[2]->writeXML(a); }
38}
39
48
49static shared_ptr<Mesh> readRectangularMesh3D(XMLReader& reader) {
50 shared_ptr<MeshAxis> axis[3];
51 XMLReader::CheckTagDuplication dub_check;
52 for (int i = 0; i < 3; ++i) {
53 reader.requireTag();
54 std::string node = reader.getNodeName();
55 if (node != "axis0" && node != "axis1" && node != "axis2") throw XMLUnexpectedElementException(reader, "<axis0>, <axis1> or <axis2>");
56 dub_check(std::string("<mesh>"), node);
57 axis[node[4]-'0'] = readMeshAxis(reader);
58 }
59 reader.requireTagEnd();
60 return plask::make_shared<RectangularMesh3D>(std::move(axis[0]), std::move(axis[1]), std::move(axis[2]));
61}
62
63static RegisterMeshReader rectangular3d_reader("rectangular3d", readRectangularMesh3D);
64
65} // namespace plask
66
67
68
69