OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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#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
45namespace oofem {
46
47int
48SpatialLocalizerInterface :: SpatialLocalizerI_containsPoint(const FloatArray &coords)
49{
50 FloatArray lcoords;
51 return this->element->computeLocalCoordinates(lcoords, coords);
52}
53
54void
55SpatialLocalizerInterface :: SpatialLocalizerI_giveBBox(FloatArray &bb0, FloatArray &bb1)
56{
57 bb1 = bb0 = element->giveNode(1)->giveCoordinates();
58
59 for ( int i = 2; i <= element->giveNumberOfNodes(); ++i ) {
60 const auto &coordinates = element->giveNode(i)->giveCoordinates();
61 bb0.beMinOf(bb0, coordinates);
62 bb1.beMaxOf(bb1, coordinates);
63 }
64}
65
66
67double
68SpatialLocalizerInterface :: SpatialLocalizerI_giveClosestPoint(FloatArray &lcoords, FloatArray &closest, const FloatArray &gcoords)
69{
70 FEInterpolation *interp = element->giveInterpolation();
71
72 if ( !interp->global2local( lcoords, gcoords, FEIElementGeometryWrapper(element) ) ) { // Outside element
73 interp->local2global( closest, lcoords, FEIElementGeometryWrapper(element) );
74 return distance(closest, gcoords);
75 } else {
76 closest = gcoords;
77 return 0.0;
78 }
79}
80
81
82int
83SpatialLocalizerInterface :: SpatialLocalizerI_BBoxContainsPoint(const FloatArray &coords)
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
100void
101SpatialLocalizer :: giveAllElementsWithNodesWithinBox(elementContainerType &elemSet, const FloatArray &coords,
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
const IntArray * giveDofManConnectivityArray(int dofman)
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo) const =0
virtual void local2global(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void beMinOf(const FloatArray &a, const FloatArray &b)
Definition floatarray.C:377
void beMaxOf(const FloatArray &a, const FloatArray &b)
Definition floatarray.C:350
bool insertSortedOnce(int value, int allocChunk=0)
Definition intarray.C:309
int & at(std::size_t i)
Definition intarray.h:104
int giveSize() const
Definition intarray.h:211
virtual void SpatialLocalizerI_giveBBox(FloatArray &bb0, FloatArray &bb1)
Domain * domain
Link to domain object.
virtual void giveAllNodesWithinBox(nodeContainerType &nodeList, const FloatArray &coords, const double radius)=0
std ::list< int > nodeContainerType
Typedefs to introduce the container type for nodal numbers, returned by some services.
IntArray elementContainerType
Typedefs to introduce the container type for element numbers, returned by some services.
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
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