OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 2013 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 "oofemcfg.h"
39 #include "spatiallocalizer.h"
40 #include "floatarray.h"
41 #include "intarray.h"
42 
43 #include <set>
44 #include <list>
45 #include <vector>
46 
47 namespace oofem {
48 class Domain;
49 class Element;
50 class TimeStep;
51 class OctreeSpatialLocalizer;
53 #define OCTREE_MAX_NODES_LIMIT 10
54 #define OCTREE_MAX_DEPTH 15
56 
57 
64 class OOFEM_NO_EXPORT OctantRec
65 {
66 protected:
72  OctantRec *child [ 2 ] [ 2 ] [ 2 ];
76  double halfWidth;
78  int depth;
79 
81  std :: list< int > nodeList;
85  std :: vector< std :: list< int > >elementList;
86 
87 public:
88  enum BoundingBoxStatus { BBS_OutsideCell, BBS_InsideCell, BBS_ContainsCell };
89  enum ChildStatus { CS_ChildFound, CS_NoChild };
90 
92  OctantRec(OctreeSpatialLocalizer * loc, OctantRec * parent, FloatArray & origin, double halfWidth);
94  ~OctantRec();
95 
97  OctantRec *giveParent() { return this->parent; }
102  const FloatArray & giveOrigin() { return this->origin; }
104  double giveWidth() { return 2. * this->halfWidth; }
106  int giveCellDepth() { return this->depth; }
114  OctantRec *giveChild(int xi, int yi, int zi);
125  ChildStatus giveChildContainingPoint(OctantRec **child, const FloatArray &coords);
127  bool isTerminalOctant();
129  std :: list< int > &giveNodeList();
131  IntArray &giveIPElementList();
133  std :: list< int > &giveElementList(int region);
134 
140  void divideLocally(int level, const IntArray &octantMask);
147  BoundingBoxStatus testBoundingBox(const FloatArray &coords, double radius);
152  void addElementIP(int elementNum) { this->giveIPElementList().insertSortedOnce(elementNum); }
158  void addElement(int region, int elementNum) { this->giveElementList(region).push_back(elementNum); }
163  void addNode(int nodeNum) { this->giveNodeList().push_back(nodeNum); }
167  void deleteNodeList() {
168  nodeList.clear();
169  }
171  void printYourself();
173  std :: string errorInfo(const char *func) const { return std :: string("OctantRec") + func; }
174 };
175 
176 
185 class OOFEM_EXPORT OctreeSpatialLocalizer : public SpatialLocalizer
186 {
187 protected:
195 
196 public:
200  virtual ~OctreeSpatialLocalizer();
201 
207  int giveOctreeMaskValue(int indx) { return octreeMask.at(indx); }
208 
213  virtual int init(bool force = false);
214 
215  virtual Element *giveElementContainingPoint(const FloatArray &coords, const IntArray *regionList = NULL);
216  virtual Element *giveElementContainingPoint(const FloatArray &coords, const Set &eset);
217  virtual Element *giveElementClosestToPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &gcoords, int region);
218  virtual GaussPoint *giveClosestIP(const FloatArray &coords, int region, bool iCohesiveZoneGP = false);
219  virtual GaussPoint *giveClosestIP(const FloatArray &coords, Set &elemSet, bool iCohesiveZoneGP = false);
220  virtual void giveAllElementsWithIpWithinBox_EvenIfEmpty(elementContainerType &elemSet, const FloatArray &coords, const double radius) { giveAllElementsWithIpWithinBox_EvenIfEmpty(elemSet, coords, radius, false); }
221  virtual void giveAllElementsWithIpWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius) { giveAllElementsWithIpWithinBox(elemSet, coords, radius, false); }
222  virtual void giveAllElementsWithIpWithinBox_EvenIfEmpty(elementContainerType &elemSet, const FloatArray &coords, const double radius, bool iCohesiveZoneGP);
223  virtual void giveAllElementsWithIpWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius, bool iCohesiveZoneGP);
224  virtual void giveAllNodesWithinBox(nodeContainerType &nodeList, const FloatArray &coords, const double radius);
225  virtual Node * giveNodeClosestToPoint(const FloatArray &coords, double maxDist);
226 
227  virtual const char *giveClassName() const { return "OctreeSpatialLocalizer"; }
228 
229 protected:
237  bool buildOctreeDataStructure();
242  void initElementIPDataStructure();
246  void initElementDataStructure(int region = 0);
253  OctantRec *findTerminalContaining(OctantRec *startCell, const FloatArray &coords);
263  void insertNodeIntoOctree(OctantRec *rootCell, int nodeNum, const FloatArray &coords);
272  void insertIPElementIntoOctree(OctantRec *rootCell, int elemNum, const FloatArray &coords);
281  void insertElementIntoOctree(OctantRec *rootCell, int region, int elemNum, const FloatArray &b0, const FloatArray &b1);
290  void insertElementsUsingNodalConnectivitiesIntoOctree(OctantRec *rootCell);
298  void giveElementsWithIPWithinBox(elementContainerType &elemSet, OctantRec *currentCell,
299  const FloatArray &coords, const double radius, bool iCohesiveZoneGP = false);
307  void giveNodesWithinBox(nodeContainerType &nodeList, OctantRec *currentCell,
308  const FloatArray &coords, const double radius);
309 
318  void giveClosestIPWithinOctant(OctantRec *currentCell, //elementContainerType& visitedElems,
319  const FloatArray &coords,
320  int region, double &dist, GaussPoint **answer, bool iCohesiveZoneGP);
329  void giveClosestIPWithinOctant(OctantRec *currentCell, //elementContainerType& visitedElems,
330  const FloatArray &coords,
331  Set &elemSet, double &dist, GaussPoint **answer, bool iCohesiveZoneGP);
341  Element *giveElementContainingPoint(OctantRec *cell, const FloatArray &coords,
342  OctantRec *scannedChild = NULL, const IntArray *regionList = NULL);
351  Element *giveElementContainingPoint(OctantRec *cell, const FloatArray &coords,
352  OctantRec *scannedChild = NULL, const Set *elset = NULL);
363  void giveElementClosestToPointWithinOctant(OctantRec *currCell, const FloatArray &gcoords,
364  double &minDist, FloatArray &lcoords, FloatArray &closest, Element * &answer, int region);
372  void giveNodeClosestToPointWithinOctant(OctantRec* cell, const FloatArray &gcoords, double &minDist, Node * &answer);
381  void giveMaxTreeDepthFrom(OctantRec *root, int &maxDepth);
390  void giveListOfTerminalCellsInBoundingBox(std :: list< OctantRec * > &cellList, const FloatArray &coords,
391  const double radius, double innerRadius, OctantRec *currentCell);
392 };
393 } // end namespace oofem
394 #endif // octreelocalizer_h
The base class for all spatial localizers.
OctantRec * parent
Link to parent cell record.
int depth
Tree depth.
Class and object Domain.
Definition: domain.h:115
The implementation of spatial localizer based on octree technique.
std::list< int > nodeList
Octant node list.
OctreeSpatialLocalizer * localizer
Link to octree class.
virtual const char * giveClassName() const
bool insertSortedOnce(int value, int allocChunk=0)
Inserts given value into a receiver, which is assumed to be sorted.
Definition: intarray.C:360
FloatArray origin
Octant origin coordinates (lower corner)
int giveOctreeMaskValue(int indx)
Returns the octreeMask value given by the index.
Abstract base class for all finite elements.
Definition: element.h:145
void deleteNodeList()
Clears and deletes the nodeList.
Class representing the octant of octree.
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
std::list< int > nodeContainerType
Typedefs to introduce the container type for nodal numbers, returned by some services.
Set of elements, boundaries, edges and/or nodes.
Definition: set.h:66
bool elementIPListsInitialized
Flag indicating elementIP tables are initialized.
OctantRec * rootCell
Root cell of octree.
IntArray octreeMask
Octree degenerate mask.
virtual void giveAllElementsWithIpWithinBox_EvenIfEmpty(elementContainerType &elemSet, const FloatArray &coords, const double radius)
Returns container (set) of all domain elements having integration point within given box...
void addElement(int region, int elementNum)
Adds given element to cell list of elements having IP within this cell.
Class representing vector of real numbers.
Definition: floatarray.h:82
void addNode(int nodeNum)
Adds given Node to node list of nodes contained by receiver.
std::string errorInfo(const char *func) const
Error printing helper.
virtual void giveAllElementsWithIpWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius)
Returns container (set) of all domain elements having integration point within given box...
double halfWidth
Octant size.
std::vector< std::list< int > > elementList
Element list of all elements close to the cell.
IntArray elementIPList
Element list, containing all elements having IP in cell.
const FloatArray & giveOrigin()
Gives the cell origin.
the oofem namespace is to define a context or scope in which all oofem names are defined.
Class implementing node in finite element mesh.
Definition: node.h:87
void addElementIP(int elementNum)
Adds given element to cell list of elements having IP within this cell.
OctantRec * giveParent()
Class representing integration point in finite element program.
Definition: gausspoint.h:93

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011