OOFEM 3.0
Loading...
Searching...
No Matches
octreelocalizer.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#ifndef octreelocalizer_h
36#define octreelocalizer_h
37
38#include "oofemenv.h"
39#include "spatiallocalizer.h"
40#include "floatarray.h"
41#include "intarray.h"
42
43#include <set>
44#include <list>
45#include <vector>
46#include <memory>
47
48#ifdef _OPENMP
49#include <omp.h>
50#endif
51
52namespace oofem {
53class Domain;
54class Element;
55class TimeStep;
58#define OCTREE_MAX_NODES_LIMIT 10
60#define OCTREE_MAX_DEPTH 15
61
62
70{
71protected:
75 std::unique_ptr<OctantRec> child [ 2 ] [ 2 ] [ 2 ];
76 //std::unique_ptr<OctantRec[2][2][2]> child2;
80 double halfWidth;
82 int depth;
83
85 std :: list< int > nodeList;
89 std :: vector< std :: list< int > >elementList;
90
91
92public:
95
97 OctantRec(OctantRec * parent, FloatArray origin, double halfWidth);
100
102 OctantRec *giveParent() { return this->parent; }
107 const FloatArray & giveOrigin() { return this->origin; }
109 double giveWidth() { return 2. * this->halfWidth; }
111 int giveCellDepth() { return this->depth; }
119 OctantRec *giveChild(int xi, int yi, int zi);
131 ChildStatus giveChildContainingPoint(OctantRec *&child, const FloatArray &coords, const IntArray &mask);
133 bool isTerminalOctant();
135 std :: list< int > &giveNodeList();
137 IntArray &giveIPElementList();
139 std :: list< int > &giveElementList(int region);
140
146 void divideLocally(int level, const IntArray &octantMask);
154 BoundingBoxStatus testBoundingBox(const FloatArray &coords, double radius, const IntArray &mask);
159 void addElementIP(int elementNum) { this->giveIPElementList().insertSortedOnce(elementNum); }
165 void addElement(int region, int elementNum) { this->giveElementList(region).push_back(elementNum); }
170 void addNode(int nodeNum) { this->giveNodeList().push_back(nodeNum); }
175 nodeList.clear();
176 }
177
178 void printYourself();
180 std :: string errorInfo(const char *func) const { return std :: string("OctantRec") + func; }
181};
182
183
193{
194protected:
196 std::unique_ptr<OctantRec> rootCell;
203#ifdef _OPENMP
204 omp_lock_t initLock;
205 omp_lock_t buildOctreeDataStructureLock;
206 omp_lock_t ElementIPDataStructureLock;
207#endif
208public:
213
219 int giveOctreeMaskValue(int indx) { return octreeMask.at(indx); }
220
225 int init(bool force = false) override;
226
227 Element *giveElementContainingPoint(const FloatArray &coords, const IntArray *regionList = nullptr) override;
228 Element *giveElementContainingPoint(const FloatArray &coords, const Set &eset) override;
229 Element *giveElementClosestToPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &gcoords, int region) override;
230
231 GaussPoint *giveClosestIP(const FloatArray &coords, int region, bool iCohesiveZoneGP = false) override;
232 GaussPoint *giveClosestIP(const FloatArray &coords, Set &elemSet, bool iCohesiveZoneGP = false) override;
233
234 void giveAllElementsWithIpWithinBox_EvenIfEmpty(elementContainerType &elemSet, const FloatArray &coords, const double radius) override { giveAllElementsWithIpWithinBox_EvenIfEmpty(elemSet, coords, radius, false); }
235 void giveAllElementsWithIpWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius) override { giveAllElementsWithIpWithinBox(elemSet, coords, radius, false); }
236 void giveAllElementsWithIpWithinBox_EvenIfEmpty(elementContainerType &elemSet, const FloatArray &coords, const double radius, bool iCohesiveZoneGP);
237 void giveAllElementsWithIpWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius, bool iCohesiveZoneGP);
238
239 void giveAllNodesWithinBox(nodeContainerType &nodeList, const FloatArray &coords, const double radius) override;
240 Node * giveNodeClosestToPoint(const FloatArray &coords, double maxDist) override;
241
242 const char *giveClassName() const override { return "OctreeSpatialLocalizer"; }
243
244protected:
252 bool buildOctreeDataStructure();
257 void initElementIPDataStructure();
261 void initElementDataStructure(int region = 0);
268 OctantRec *findTerminalContaining(OctantRec &startCell, const FloatArray &coords);
278 void insertNodeIntoOctree(OctantRec &rootCell, int nodeNum, const FloatArray &coords);
287 void insertIPElementIntoOctree(OctantRec &rootCell, int elemNum, const FloatArray &coords);
296 void insertElementIntoOctree(OctantRec &rootCell, int region, int elemNum, const FloatArray &b0, const FloatArray &b1);
305 void insertElementsUsingNodalConnectivitiesIntoOctree(OctantRec &rootCell);
313 void giveElementsWithIPWithinBox(elementContainerType &elemSet, OctantRec &currentCell,
314 const FloatArray &coords, const double radius, bool iCohesiveZoneGP = false);
322 void giveNodesWithinBox(nodeContainerType &nodeList, OctantRec &currentCell,
323 const FloatArray &coords, const double radius);
324
333 void giveClosestIPWithinOctant(OctantRec &currentCell, //elementContainerType& visitedElems,
334 const FloatArray &coords,
335 int region, double &dist, GaussPoint *&answer, bool iCohesiveZoneGP);
344 void giveClosestIPWithinOctant(OctantRec &currentCell, //elementContainerType& visitedElems,
345 const FloatArray &coords,
346 Set &elemSet, double &dist, GaussPoint *&answer, bool iCohesiveZoneGP);
356 Element *giveElementContainingPoint(OctantRec &cell, const FloatArray &coords,
357 OctantRec *scannedChild = nullptr, const IntArray *regionList = nullptr);
366 Element *giveElementContainingPoint(OctantRec &cell, const FloatArray &coords,
367 OctantRec *scannedChild = nullptr, const Set *elset = nullptr);
378 void giveElementClosestToPointWithinOctant(OctantRec &currCell, const FloatArray &gcoords,
379 double &minDist, FloatArray &lcoords, FloatArray &closest, Element * &answer, int region);
387 void giveNodeClosestToPointWithinOctant(OctantRec &cell, const FloatArray &gcoords, double &minDist, Node * &answer);
396 int giveMaxTreeDepthFrom(OctantRec &root);
405 void giveListOfTerminalCellsInBoundingBox(std :: list< OctantRec * > &cellList, const FloatArray &coords,
406 const double radius, double innerRadius, OctantRec &currentCell);
407};
408} // end namespace oofem
409#endif // octreelocalizer_h
void addElement(int region, int elementNum)
std ::list< int > nodeList
Octant node list.
std ::list< int > & giveNodeList()
void addNode(int nodeNum)
FloatArray origin
Octant origin coordinates (lower corner).
std ::vector< std ::list< int > > elementList
Element list of all elements close to the cell.
~OctantRec()
Destructor.
std::unique_ptr< OctantRec > child[2][2][2]
Link to octant children.
OctantRec * giveParent()
std ::list< int > & giveElementList(int region)
double halfWidth
Octant size.
OctantRec * parent
Link to parent cell record.
OctantRec(OctantRec *parent, FloatArray origin, double halfWidth)
Constructor.
int depth
Tree depth.
const FloatArray & giveOrigin()
void addElementIP(int elementNum)
IntArray elementIPList
Element list, containing all elements having IP in cell.
IntArray & giveIPElementList()
std::string errorInfo(const char *func) const
Error printing helper.
virtual ~OctreeSpatialLocalizer()
Destructor - deletes the octree tree.
bool elementIPListsInitialized
Flag indicating elementIP tables are initialized.
OctreeSpatialLocalizer(Domain *d)
Constructor.
void giveAllElementsWithIpWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius) override
std::unique_ptr< OctantRec > rootCell
Root cell of octree.
IntArray octreeMask
Octree degenerate mask.
const char * giveClassName() const override
void giveAllElementsWithIpWithinBox_EvenIfEmpty(elementContainerType &elemSet, const FloatArray &coords, const double radius) override
SpatialLocalizer(Domain *d)
Constructor.
IntArray elementContainerType
Typedefs to introduce the container type for element numbers, returned by some services.
#define OOFEM_EXPORT
Definition oofemcfg.h:7
#define OOFEM_NO_EXPORT
Definition oofemcfg.h:8

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