PLaSK library
Loading...
Searching...
No Matches
rectangular_masked3d.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 */
15
16namespace plask {
17
20 initNodesAndElements(predicate);
21}
22
28
30{
31 this->fullMesh.reset(rectangularMesh, clone_axes);
32 reset(predicate);
33}
34
37{
38}
39
40void RectangularMaskedMesh3D::initNodesAndElements(const RectangularMaskedMesh3D::Predicate &predicate)
41{
42 for (auto el_it = this->fullMesh.elements().begin(); el_it != this->fullMesh.elements().end(); ++el_it)
43 if (predicate(*el_it)) {
45 nodeSet.insert(el_it->getLoLoLoIndex());
46
47 nodeSet.insert(el_it->getUpLoLoIndex());
48 nodeSet.insert(el_it->getLoUpLoIndex());
49 nodeSet.insert(el_it->getLoLoUpIndex());
50
51 nodeSet.insert(el_it->getLoUpUpIndex());
52 nodeSet.insert(el_it->getUpLoUpIndex());
53 nodeSet.insert(el_it->getUpUpLoIndex());
54
55 nodeSet.push_back(el_it->getUpUpUpIndex());
56 /*boundaryIndex[0].improveLo(el_it->getLowerIndex0());
57 boundaryIndex[0].improveUp(el_it->getUpperIndex0());
58 boundaryIndex[1].improveLo(el_it->getLowerIndex1());
59 boundaryIndex[1].improveUp(el_it->getUpperIndex1());
60 boundaryIndex[2].improveLo(el_it->getLowerIndex2());
61 boundaryIndex[2].improveUp(el_it->getUpperIndex2());*/ // this is initialized lazy
62 }
66}
67
69 std::size_t& index0_lo, std::size_t& index0_hi,
70 std::size_t& index1_lo, std::size_t& index1_hi,
71 std::size_t& index2_lo, std::size_t& index2_hi,
72 const InterpolationFlags &flags) const {
73 wrapped_point = flags.wrap(point);
74
75 if (!canBeIncluded(wrapped_point)) return false;
76
83
84 double lo0 = fullMesh.axis[0]->at(index0_lo), hi0 = fullMesh.axis[0]->at(index0_hi),
85 lo1 = fullMesh.axis[1]->at(index1_lo), hi1 = fullMesh.axis[1]->at(index1_hi),
86 lo2 = fullMesh.axis[2]->at(index2_lo), hi2 = fullMesh.axis[2]->at(index2_hi);
87
89 for (char i2 = 0; i2 < 2; ++i2) {
90 for (char i1 = 0; i1 < 2; ++i1) {
91 for (char i0 = 0; i0 < 2; ++i0) {
92 if (elementSet.includes(fullMesh.getElementIndexFromLowIndexes(index0_lo, index1_lo, index2_lo))) {
94 return true;
95 }
97 else if (index0_lo < fullMesh.axis[0]->size()-2 && hi0-MIN_DISTANCE < wrapped_point.c0 && wrapped_point.c0 <= hi0) index0_lo = index0_hi;
98 else break;
99 }
100 index0_lo = index0_hi - 1;
102 else if (index1_lo < fullMesh.axis[1]->size()-2 && hi1-MIN_DISTANCE < wrapped_point.c1 && wrapped_point.c1 <= hi1) index1_lo = index1_hi;
103 else break;
104 }
105 index1_lo = index1_hi - 1;
107 else if (index2_lo < fullMesh.axis[2]->size()-2 && hi2-MIN_DISTANCE < wrapped_point.c2 && wrapped_point.c2 <= hi1) index2_lo = index2_hi;
108 else break;
109 }
110
111 return false;
112}
113
115{
116 if (this->fullMesh.isChangeSlower(1, 2))
117 return new BoundaryNodeSetImpl<1, 2>(*this, line_nr_axis0, index1Begin, index2Begin, index1End, index2End);
118 else
120}
121
126
128{
129 if (this->fullMesh.isChangeSlower(0, 2))
130 return new BoundaryNodeSetImpl<0, 2>(*this, index0Begin, line_nr_axis1, index2Begin, index0End, index2End);
131 else
133}
134
139
141{
142 if (this->fullMesh.isChangeSlower(0, 1))
143 return new BoundaryNodeSetImpl<0, 1>(*this, index0Begin, index1Begin, line_nr_axis2, index0End, index1End);
144 else
146}
147
152
156
160
164
168
172
176
178 std::size_t line, begInd1, endInd1, begInd2, endInd2;
179 if (details::getLineLo(line, *fullMesh.axis[0], box.lower.c0, box.upper.c0) &&
180 details::getIndexesInBounds(begInd1, endInd1, *fullMesh.axis[1], box.lower.c1, box.upper.c1) &&
181 details::getIndexesInBounds(begInd2, endInd2, *fullMesh.axis[2], box.lower.c2, box.upper.c2))
183 else
184 return new EmptyBoundaryImpl();
185}
186
188 std::size_t line, begInd1, endInd1, begInd2, endInd2;
189 if (details::getLineHi(line, *fullMesh.axis[0], box.lower.c0, box.upper.c0) &&
190 details::getIndexesInBounds(begInd1, endInd1, *fullMesh.axis[1], box.lower.c1, box.upper.c1) &&
191 details::getIndexesInBounds(begInd2, endInd2, *fullMesh.axis[2], box.lower.c2, box.upper.c2))
193 else
194 return new EmptyBoundaryImpl();
195}
196
198 std::size_t line, begInd0, endInd0, begInd2, endInd2;
199 if (details::getLineLo(line, *fullMesh.axis[1], box.lower.c1, box.upper.c1) &&
200 details::getIndexesInBounds(begInd0, endInd0, *fullMesh.axis[0], box.lower.c0, box.upper.c0) &&
201 details::getIndexesInBounds(begInd2, endInd2, *fullMesh.axis[2], box.lower.c2, box.upper.c2))
203 else
204 return new EmptyBoundaryImpl();
205}
206
208 std::size_t line, begInd0, endInd0, begInd2, endInd2;
209 if (details::getLineHi(line, *fullMesh.axis[1], box.lower.c1, box.upper.c1) &&
210 details::getIndexesInBounds(begInd0, endInd0, *fullMesh.axis[0], box.lower.c0, box.upper.c0) &&
211 details::getIndexesInBounds(begInd2, endInd2, *fullMesh.axis[2], box.lower.c2, box.upper.c2))
213 else
214 return new EmptyBoundaryImpl();
215}
216
218 std::size_t line, begInd0, endInd0, begInd1, endInd1;
219 if (details::getLineLo(line, *fullMesh.axis[2], box.lower.c2, box.upper.c2) &&
220 details::getIndexesInBounds(begInd0, endInd0, *fullMesh.axis[0], box.lower.c0, box.upper.c0) &&
221 details::getIndexesInBounds(begInd1, endInd1, *fullMesh.axis[1], box.lower.c1, box.upper.c1))
223 else
224 return new EmptyBoundaryImpl();
225}
226
228 std::size_t line, begInd0, endInd0, begInd1, endInd1;
229 if (details::getLineHi(line, *fullMesh.axis[2], box.lower.c2, box.upper.c2) &&
230 details::getIndexesInBounds(begInd0, endInd0, *fullMesh.axis[0], box.lower.c0, box.upper.c0) &&
231 details::getIndexesInBounds(begInd1, endInd1, *fullMesh.axis[1], box.lower.c1, box.upper.c1))
233 else
234 return new EmptyBoundaryImpl();
235}
236
237} // namespace plask