OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
spatiallocalizer.C
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 #include "spatiallocalizer.h"
36 #include "connectivitytable.h"
37 #include "element.h"
38 #include "node.h"
39 #include "mathfem.h"
40 #include "error.h"
41 #include "floatarray.h"
42 #include "intarray.h"
43 #include "feinterpol.h"
44 
45 namespace oofem {
46 
47 int
49 {
50  FloatArray lcoords;
51  return this->element->computeLocalCoordinates(lcoords, coords);
52 }
53 
54 void
56 {
57  bb1 = bb0 = * element->giveNode(1)->giveCoordinates();
58 
59  for ( int i = 2; i <= element->giveNumberOfNodes(); ++i ) {
60  FloatArray *coordinates = element->giveNode(i)->giveCoordinates();
61  bb0.beMinOf(bb0, * coordinates);
62  bb1.beMaxOf(bb1, * coordinates);
63  }
64 }
65 
66 
67 double
69 {
71 
72  if ( !interp->global2local( lcoords, gcoords, FEIElementGeometryWrapper(element) ) ) { // Outside element
73  interp->local2global( closest, lcoords, FEIElementGeometryWrapper(element) );
74  return closest.distance(gcoords);
75  } else {
76  closest = gcoords;
77  return 0.0;
78  }
79 }
80 
81 
82 int
84 {
85  FloatArray coordMin, coordMax;
86  this->SpatialLocalizerI_giveBBox(coordMin, coordMax);
87 
88  int size = min( coordMin.giveSize(), coords.giveSize() );
89  for ( int j = 1; j <= size; j++ ) {
90  if ( coords.at(j) < coordMin.at(j) || coords.at(j) > coordMax.at(j) ) {
91  return 0;
92  }
93  }
94 
95  return 1;
96 }
97 
98 
99 
100 void
102  const double radius)
103 {
104  nodeContainerType nodesWithinBox;
105  const IntArray *dofmanConnectivity;
106 
107  elemSet.clear();
108 
109  ConnectivityTable *ct = domain->giveConnectivityTable();
110 
111  this->giveAllNodesWithinBox(nodesWithinBox, coords, radius);
112 
113  for ( int node: nodesWithinBox ) {
114  dofmanConnectivity = ct->giveDofManConnectivityArray(node);
115  for ( int i = 1; i <= dofmanConnectivity->giveSize(); i++ ) {
116  elemSet.insertSortedOnce( dofmanConnectivity->at(i) );
117  }
118  }
119 }
120 } // end namespace oofem
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
bool insertSortedOnce(int value, int allocChunk=0)
Inserts given value into a receiver, which is assumed to be sorted.
Definition: intarray.C:360
virtual void giveAllElementsWithNodesWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius)
Returns container (set) of all domain elements having node within given box.
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
virtual FEInterpolation * giveInterpolation() const
Definition: element.h:629
void beMaxOf(const FloatArray &a, const FloatArray &b)
Sets receiver to maximum of a or b&#39;s respective elements.
Definition: floatarray.C:288
virtual int giveNumberOfNodes() const
Returns number of nodes of receiver.
Definition: element.h:662
std::list< int > nodeContainerType
Typedefs to introduce the container type for nodal numbers, returned by some services.
double distance(const FloatArray &x) const
Computes the distance between position represented by receiver and position given as parameter...
Definition: floatarray.C:489
Class representing a general abstraction for finite element interpolation class.
Definition: feinterpol.h:132
virtual double SpatialLocalizerI_giveClosestPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &gcoords)
Gives the closest point on the element.
void beMinOf(const FloatArray &a, const FloatArray &b)
Sets receiver to be minimum of a or b&#39;s respective elements.
Definition: floatarray.C:315
void clear()
Clears the array (zero size).
Definition: intarray.h:177
Class representing connectivity table.
Wrapper around element definition to provide FEICellGeometry interface.
Definition: feinterpol.h:95
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo)=0
Evaluates local coordinates from given global ones.
virtual void SpatialLocalizerI_giveBBox(FloatArray &bb0, FloatArray &bb1)
Creates a bounding box of the nodes and checks if it includes the given coordinate.
virtual int SpatialLocalizerI_containsPoint(const FloatArray &coords)
Checks if element contains specified coordinate.
Class representing vector of real numbers.
Definition: floatarray.h:82
const IntArray * giveDofManConnectivityArray(int dofman)
virtual bool computeLocalCoordinates(FloatArray &answer, const FloatArray &gcoords)
Computes the element local coordinates from given global coordinates.
Definition: element.C:1222
virtual FloatArray * giveCoordinates()
Definition: node.h:114
int min(int i, int j)
Returns smaller value from two given decimals.
Definition: mathfem.h:59
int giveSize() const
Definition: intarray.h:203
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
Node * giveNode(int i) const
Returns reference to the i-th node of element.
Definition: element.h:610
int SpatialLocalizerI_BBoxContainsPoint(const FloatArray &coords)
Creates a bounding box of the nodes and checks if it includes the given coordinate.
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)=0
Evaluates global coordinates from given local ones.

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:31 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011