OOFEM 3.0
Loading...
Searching...
No Matches
octreelocalizertutil.h
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35// ****************************************************
36// *** UTILITY CLASSES FOR OCTREE SPATIAL LOCALIZER ***
37// ****************************************************
38
39#ifndef octreelocalizertutil_h
40#define octreelocalizertutil_h
41
42#include "spatiallocalizer.h"
43#include "octreelocalizer.h"
44#include "octreelocalizert.h"
45#include "delaunaytriangle.h"
46#include "dofmanager.h"
47#include "node.h"
48#include "element.h"
49#include "mathfem.h"
50#include "timer.h"
51
52#include <set>
53#include <list>
54
55namespace oofem {
56class Domain;
57class Element;
58class TimeStep;
59class DofManager;
60class IntArray;
61
67class InsertNode : public SL_Insertion_Functor< int >
68{
69protected:
71
72public:
75 domain(d)
76 { }
77
79
86 bool evaluate(int &nodeNr, OctantRecT< int > *cell) override
87 {
88 FloatArray coords(3);
89 for ( int i = 1; i <= 3; i++ ) {
90 coords.at(i) = this->domain->giveNode(nodeNr)->giveCoordinate(i);
91 }
92
93 if ( cell->containsPoint(coords) ) {
94 return true;
95 } else {
96 return false;
97 }
98 };
99
100 void registerInsertion(int &nodeNr, LocalInsertionData< int >LIdata) override { }
101
102 std :: list< LocalInsertionData< int > > *giveInsertionList(int &nodeNr) override
103 {
104 return nullptr;
105 }
106};
107
113class InsertTriangleBasedOnCircumcircle : public SL_Insertion_Functor< DelaunayTriangle * >
114{
115protected:
117
118public:
123
125
133 {
134 double radius = DTptr->giveCircumRadius();
135 FloatArray centerCoords(3);
136 centerCoords.at(1) = DTptr->giveXCenterCoordinate();
137 centerCoords.at(2) = DTptr->giveYCenterCoordinate();
138 centerCoords.at(3) = 0.0;
139
140 if ( cell->testBoundingSphere(centerCoords, radius) == SphereOutsideCell ) {
141 return false;
142 } else {
143 return true;
144 }
145 }
147 {
148 ( TEptr->giveListOfCellsAndPosition() )->push_back(LIdata);
149 }
150 std :: list< LocalInsertionData< DelaunayTriangle * > > *giveInsertionList(DelaunayTriangle * &DTptr) override
151 {
152 return DTptr->giveListOfCellsAndPosition();
153 }
154};
155
162{
163protected:
169
170 std :: list< int >closestNodeIndices;
171
172public:
178 ClosestNode(const FloatArray &pos, Domain *d) :
179 startingPosition(pos),
180 domain(d),
181 initFlag(false)
182 { }
183
185
190 void giveStartingPosition(FloatArray &position) override
191 {
192 position = startingPosition;
193 }
194
201 bool evaluate(int &nodeNr) override
202 {
203 if ( initFlag ) {
204 double dist = distance(startingPosition, this->domain->giveNode(nodeNr)->giveCoordinates());
205
206 if ( ( dist - distanceToClosestNode ) <= dist * 0.001 ) {
207 if ( ( dist - distanceToClosestNode ) >= -0.001 * dist ) {
208 closestNodeIndices.push_back(nodeNr);
209 } else {
210 closestNodeIndices.clear();
211 closestNodeIndices.push_back(nodeNr);
213 }
214 }
215 } else {
216 closestNodeIndices.push_back(nodeNr);
218 initFlag = true;
219 }
220
221 return true;
222 }
223
228 void giveResult(std :: list< int > &answer) override {
229 answer = closestNodeIndices;
230 }
231
232 bool isBBXStage1Defined(BoundingBox &BBXStage1) override
233 {
234 return false;
235 }
236
237 bool isBBXStage2Defined(BoundingBox &BBXStage2) override
238 {
239 if ( initFlag ) {
240 BBXStage2.setOrigin(startingPosition);
242 return true;
243 } else {
244 return false;
245 }
246 }
247};
248
249
256{
257protected:
260 std :: list< DelaunayTriangle * >result;
261
262public:
269 startingPosition(std::move(pos)),
270 domain(d)
271 { }
273
279 bool evaluate(DelaunayTriangle * &DTptr) override
280 {
281 double radius = DTptr->giveCircumRadius();
282 FloatArray centerCoords(3);
283 centerCoords.at(1) = DTptr->giveXCenterCoordinate();
284 centerCoords.at(2) = DTptr->giveYCenterCoordinate();
285 centerCoords.at(3) = 0.0;
286
287 if ( distance(startingPosition, centerCoords) < radius ) {
288 result.push_back(DTptr);
289 return true;
290 } else {
291 return false;
292 }
293 }
294
299 void giveStartingPosition(FloatArray &answer) override
300 {
301 answer = startingPosition;
302 }
303
308 void giveResult(std :: list< DelaunayTriangle * > &answer) override
309 {
310 answer = result;
311 }
312
313 // neither stage1, nor stage 2 are defined
314 bool isBBXStage1Defined(BoundingBox &BBXStage1) override { return false; }
315 bool isBBXStage2Defined(BoundingBox &BBXStage2) override { return false; }
316};
317
318} // end namespace oofem
319#endif // octreelocalizertutil_h
void setOrigin(FloatArray &coords)
Sets the origin of the bounding box.
void setSize(double s)
Sets the size of the bounding box (all sides are equal).
void giveResult(std ::list< int > &answer) override
ClosestNode(const FloatArray &pos, Domain *d)
void giveStartingPosition(FloatArray &position) override
bool evaluate(int &nodeNr) override
std ::list< int > closestNodeIndices
bool isBBXStage2Defined(BoundingBox &BBXStage2) override
bool isBBXStage1Defined(BoundingBox &BBXStage1) override
double giveYCenterCoordinate() const
Gives the y coordinate of the center of the circumscribed circle.
double giveCircumRadius() const
Gives the radius of the circumscribed circle.
std ::list< LocalInsertionData< DelaunayTriangle * > > * giveListOfCellsAndPosition()
Returns a list of octree cells and with iterator position in their member lists.
double giveXCenterCoordinate() const
Gives the x coordinate of the center of the circumscribed circle.
double giveCoordinate(int i) const
Definition dofmanager.h:383
const FloatArray & giveCoordinates() const
Definition dofmanager.h:390
Node * giveNode(int n)
Definition domain.h:398
std ::list< DelaunayTriangle * > result
bool evaluate(DelaunayTriangle *&DTptr) override
ElementCircumCirclesContainingNode(FloatArray pos, Domain *d)
void giveResult(std ::list< DelaunayTriangle * > &answer) override
bool isBBXStage1Defined(BoundingBox &BBXStage1) override
void giveStartingPosition(FloatArray &answer) override
bool isBBXStage2Defined(BoundingBox &BBXStage2) override
double & at(Index i)
Definition floatarray.h:202
bool evaluate(int &nodeNr, OctantRecT< int > *cell) override
void registerInsertion(int &nodeNr, LocalInsertionData< int >LIdata) override
Stores LocalInsertionData on the member.
InsertNode(Domain *d)
Constuctor.
std ::list< LocalInsertionData< int > > * giveInsertionList(int &nodeNr) override
Returns list of LocalInsertionData stored on the member.
bool evaluate(DelaunayTriangle *&DTptr, OctantRecT< DelaunayTriangle * > *cell) override
std ::list< LocalInsertionData< DelaunayTriangle * > > * giveInsertionList(DelaunayTriangle *&DTptr) override
Returns list of LocalInsertionData stored on the member.
void registerInsertion(DelaunayTriangle *&TEptr, LocalInsertionData< DelaunayTriangle * >LIdata) override
Stores LocalInsertionData on the member.
int containsPoint(const FloatArray &coords)
boundingSphereStatus testBoundingSphere(const FloatArray &coords, double radius)
@ SphereOutsideCell
double distance(const FloatArray &x, const FloatArray &y)

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011