PLaSK library

Loading...
Searching...
No Matches
basic.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 "basic.hpp"
15
16 namespace plask {
17
18 template <int DIM>
19std::size_t OnePointMesh<DIM>::size() const {
20 return 1;
21}
22
23 template <int DIM>
24 typename OnePointMesh<DIM>::DVec OnePointMesh<DIM>::at(std::size_t) const {
25 return point;
26}
27
28 template struct PLASK_API OnePointMesh<2>;
29 template struct PLASK_API OnePointMesh<3>;
30
31 template <>
32 void OnePointMesh<3>::writeXML(XMLElement& object) const {
33 object.attr("type", "point3d"); // this is required attribute for the provided object
34 object.addTag("point")
35 .attr("c0", point.c0)
36 .attr("c1", point.c1)
37 .attr("c2", point.c2);
38}
39
40 template <>
41 void OnePointMesh<2>::writeXML(XMLElement &object) const {
42 object.attr("type", "point2d"); // this is required attribute for the provided object
43 object.addTag("point")
44 .attr("c0", point.c0)
45 .attr("c1", point.c1);
46}
47
48 static shared_ptr<Mesh> readOnePoint3DMesh(XMLReader& reader) {
49 reader.requireTag("point");
50 double c0 = reader.requireAttribute<double>("c0");
51 double c1 = reader.requireAttribute<double>("c1");
52 double c2 = reader.requireAttribute<double>("c2");
53 reader.requireTagEnd(); // this is necessary to make sure the tag <point> is closed
54 // Now create the mesh into a shared pointer and return it:
55 return plask::make_shared<OnePointMesh<3>>(vec(c0, c1, c2));
56}
57
58 static RegisterMeshReader onepoint3dmesh_reader("point3d", &readOnePoint3DMesh);
59
60 static shared_ptr<Mesh> readOnePoint2DMesh(XMLReader& reader) {
61 reader.requireTag("point");
62 double c0 = reader.requireAttribute<double>("c0");
63 double c1 = reader.requireAttribute<double>("c1");
64 reader.requireTagEnd(); // this is necessary to make sure the tag <point> is closed
65 // Now create the mesh into a shared pointer and return it:
66 return plask::make_shared<OnePointMesh<2>>(vec(c0, c1));
67}
68
69 static RegisterMeshReader onepoint2dmesh_reader("point2d", &readOnePoint2DMesh);
70
71 template <int DIM>
72 typename TranslatedMesh<DIM>::DVec TranslatedMesh<DIM>::at(std::size_t index) const {
73 return sourceMesh->at(index) + translation;
74}
75
76 template <int DIM>
77std::size_t TranslatedMesh<DIM>::size() const {
78 return sourceMesh->size();
79}
80
81 template struct PLASK_API TranslatedMesh<2>;
82 template struct PLASK_API TranslatedMesh<3>;
83
84
85
86} // namespace plask