PLaSK library
Loading...
Searching...
No Matches
mesh.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 "mesh.hpp"
15
16namespace plask {
17
19 throw NotImplemented("mesh::writeXML()");
20}
21
23
24std::map<std::string, RegisterMeshReader::ReadingFunction>& RegisterMeshReader::getReaders() {
25 static std::map<std::string, RegisterMeshReader::ReadingFunction> result;
26 return result;
27}
28
32
34 auto reader = getReaders().find(name);
35 if (reader == getReaders().end()) throw Exception("no registered reader for mesh of type '{0}'", name);
36 return reader->second;
37}
38
39
40std::map<std::string, RegisterMeshGeneratorReader::ReadingFunction>& RegisterMeshGeneratorReader::getReaders() {
41 static std::map<std::string, RegisterMeshGeneratorReader::ReadingFunction> result;
42 return result;
43}
44
48
50 auto reader = getReaders().find(name);
51 if (reader == getReaders().end()) throw Exception("no registered reader for mesh generator of type '{0}'", name);
52 return reader->second;
53}
54
55template <int dimension>
56void MeshD<dimension>::print(std::ostream& out) const {
57 print_seq(out << '[', begin(), end(), ", ") << ']';
58}
59
60template<int dimension>
62 const std::size_t s = this->size();
63 if (s != to_compare.size()) return false;
64 for (std::size_t i = 0; i < s; ++i) if (this->at(i) != to_compare.at(i)) return false;
65 return true;
66}
67
69
70template <int MESH_DIM>
72 if (auto res = cache.get(geometry))
73 return res;
74 else
75 return cache(geometry, generate(geometry));
76}
77
78template struct PLASK_API MeshD<1>;
79template struct PLASK_API MeshD<2>;
80template struct PLASK_API MeshD<3>;
81
85
86
87} // namespace plask