15 #if !defined(KRATOS_BINBASED_NODES_IN_ELEMENT_LOCATOR_INCLUDED )
16 #define KRATOS_BINBASED_NODES_IN_ELEMENT_LOCATOR_INCLUDED
42 template<
unsigned int TDim>
50 typedef typename std::vector<PointType::Pointer >::iterator
PointIterator;
74 mlist_of_new_nodes.clear();
76 node_it != mr_model_part.
NodesEnd(); ++node_it)
79 Node::Pointer pnode = *(node_it.base());
82 mlist_of_new_nodes.push_back( pnode );
88 typename StaticBins::Pointer paux =
typename StaticBins::Pointer(
new StaticBins(mlist_of_new_nodes.begin(),mlist_of_new_nodes.end(),bucket_size) );
89 paux.swap(mp_search_structure);
104 mlist_of_new_nodes.clear();
106 node_it != mr_model_part.
NodesEnd(); ++node_it)
109 Node::Pointer pnode = *(node_it.base());
112 mlist_of_new_nodes.push_back( pnode );
115 typename StaticBins::Pointer paux =
typename StaticBins::Pointer(
new StaticBins(mlist_of_new_nodes.begin(),mlist_of_new_nodes.end(),CellSize) );
116 paux.swap(mp_search_structure);
136 const unsigned int max_results,
146 CalculateCenterAndSearchRadius( geom,
xc,
yc,zc,
radius,
N);
152 int number_of_points_in_radius;
155 number_of_points_in_radius = mp_search_structure->SearchInRadius(work_point,
radius, work_results, work_distances, max_results);
160 for(
PointIterator it_found = work_results; it_found != work_results + number_of_points_in_radius; it_found++)
162 bool is_inside =
false;
163 is_inside = CalculatePosition(geom, (*it_found)->X(),(*it_found)->Y(),(*it_found)->Z(),
N);
166 if(is_inside ==
true)
168 positions[
counter] = it_found - work_results;
169 for(
unsigned int k=0;
k<TDim+1;
k++)
190 inline void CalculateCenterAndSearchRadius(
199 const double x0 = geom[0].X();
200 const double y0 = geom[0].Y();
201 const double x1 = geom[1].X();
202 const double y1 = geom[1].Y();
203 const double x2 = geom[2].X();
204 const double y2 = geom[2].Y();
206 xc = 0.3333333333333333333*(x0+
x1+
x2);
207 yc = 0.3333333333333333333*(y0+y1+y2);
210 const double R1 = (
xc-x0)*(
xc-x0) + (
yc-y0)*(
yc-y0);
218 R = 1.01 * std::sqrt(
R);
229 inline void CalculateCenterAndSearchRadius(
230 Geometry<Node >&geom,
235 array_1d<double,4>&
N
238 const double x0 = geom[0].X();
239 const double y0 = geom[0].Y();
240 const double z0 = geom[0].Z();
241 const double x1 = geom[1].X();
242 const double y1 = geom[1].Y();
243 const double z1 = geom[1].Z();
244 const double x2 = geom[2].X();
245 const double y2 = geom[2].Y();
246 const double z2 = geom[2].Z();
247 const double x3 = geom[3].X();
248 const double y3 = geom[3].Y();
249 const double z3 = geom[3].Z();
252 yc = 0.25*(y0+y1+y2+y3);
253 zc = 0.25*(z0+z1+z2+z3);
255 const double R1 = (
xc-x0)*(
xc-x0) + (
yc-y0)*(
yc-y0) + (zc-z0)*(zc-z0);
256 const double R2 = (
xc-
x1)*(
xc-
x1) + (
yc-y1)*(
yc-y1) + (zc-z1)*(zc-z1);
257 const double R3 = (
xc-
x2)*(
xc-
x2) + (
yc-y2)*(
yc-y2) + (zc-z2)*(zc-z2);
258 const double R4 = (
xc-x3)*(
xc-x3) + (
yc-y3)*(
yc-y3) + (zc-z3)*(zc-z3);
277 inline bool CalculatePosition(
278 Geometry<Node >&geom,
282 array_1d<double, 3 > &
N
285 const double x0 = geom[0].X();
286 const double y0 = geom[0].Y();
287 const double x1 = geom[1].X();
288 const double y1 = geom[1].Y();
289 const double x2 = geom[2].X();
290 const double y2 = geom[2].Y();
292 const double area = CalculateVol(x0, y0,
x1, y1,
x2, y2);
293 double inv_area = 0.0;
301 inv_area = 1.0 / area;
304 N[0] = CalculateVol(
x1, y1,
x2, y2,
xc,
yc) * inv_area;
305 N[1] = CalculateVol(
x2, y2, x0, y0,
xc,
yc) * inv_area;
306 N[2] = CalculateVol(x0, y0,
x1, y1,
xc,
yc) * inv_area;
308 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0)
323 inline bool CalculatePosition(
324 Geometry<Node >&geom,
328 array_1d<double, 4 > &
N
332 const double x0 = geom[0].X();
333 const double y0 = geom[0].Y();
334 const double z0 = geom[0].Z();
335 const double x1 = geom[1].X();
336 const double y1 = geom[1].Y();
337 const double z1 = geom[1].Z();
338 const double x2 = geom[2].X();
339 const double y2 = geom[2].Y();
340 const double z2 = geom[2].Z();
341 const double x3 = geom[3].X();
342 const double y3 = geom[3].Y();
343 const double z3 = geom[3].Z();
345 const double vol = CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2, x3, y3, z3);
347 double inv_vol = 0.0;
348 if (vol < 0.0000000000001)
358 N[0] = CalculateVol(
x1, y1, z1, x3, y3, z3,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
359 N[1] = CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
360 N[2] = CalculateVol(x3, y3, z3,
x1, y1, z1, x0, y0, z0,
xc,
yc, zc) * inv_vol;
361 N[3] = CalculateVol(x3, y3, z3, x0, y0, z0,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
364 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[3] >= 0.0 &&
365 N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0 &&
N[3] <= 1.0)
375 inline double CalculateVol(
const double x0,
const double y0,
376 const double x1,
const double y1,
377 const double x2,
const double y2
380 return 0.5 * ((
x1 - x0)*(y2 - y0)- (y1 - y0)*(
x2 - x0));
387 inline double CalculateVol(
const double x0,
const double y0,
const double z0,
388 const double x1,
const double y1,
const double z1,
389 const double x2,
const double y2,
const double z2,
390 const double x3,
const double y3,
const double z3
393 const double x10 =
x1 - x0;
394 const double y10 = y1 - y0;
395 const double z10 = z1 - z0;
397 const double x20 =
x2 - x0;
398 const double y20 = y2 - y0;
399 const double z20 = z2 - z0;
401 const double x30 = x3 - x0;
402 const double y30 = y3 - y0;
403 const double z30 = z3 - z0;
405 const double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
406 return detJ * 0.1666666666666666666667;
414 typename StaticBins::Pointer mp_search_structure;
REMARK: the location function is threadsafe, and can be used in OpenMP loops.
Definition: binbased_nodes_in_element_locator.h:44
std::vector< PointType::Pointer > PointVector
Definition: binbased_nodes_in_element_locator.h:49
unsigned int FindNodesInElement(Element::Pointer &pelement, DenseVector< int > &positions, Matrix &Nmat, const unsigned int max_results, PointIterator work_results, DistanceIterator work_distances, Node &work_point)
function to find all teh nodes of a fixed mesh contained in the elements of a moving mesh
Definition: binbased_nodes_in_element_locator.h:133
std::vector< PointType::Pointer >::iterator PointIterator
Definition: binbased_nodes_in_element_locator.h:50
void UpdateSearchDatabaseAssignedSize(double CellSize)
Definition: binbased_nodes_in_element_locator.h:100
BinBasedNodesInElementLocator(ModelPart &model_part)
Definition: binbased_nodes_in_element_locator.h:60
Node PointType
Definition: binbased_nodes_in_element_locator.h:47
std::vector< double >::iterator DistanceIterator
Definition: binbased_nodes_in_element_locator.h:52
Node::Pointer PointTypePointer
Definition: binbased_nodes_in_element_locator.h:48
void UpdateSearchDatabase()
Function to construct or update the search database.
Definition: binbased_nodes_in_element_locator.h:70
KRATOS_CLASS_POINTER_DEFINITION(BinBasedNodesInElementLocator)
Bins< TDim, PointType, PointVector, PointTypePointer, PointIterator, DistanceIterator > StaticBins
Definition: binbased_nodes_in_element_locator.h:55
~BinBasedNodesInElementLocator()
Definition: binbased_nodes_in_element_locator.h:65
std::vector< double > DistanceVector
Definition: binbased_nodes_in_element_locator.h:51
Definition: bins_static.h:35
TreeNodeType::SizeType SizeType
Definition: bins_static.h:51
Geometry base class.
Definition: geometry.h:71
Definition: amatrix_interface.h:41
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
This class defines the node.
Definition: node.h:65
double Y() const
Definition: point.h:187
double Z() const
Definition: point.h:193
double X() const
Definition: point.h:181
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
model_part
Definition: face_heat.py:14
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
R
Definition: isotropic_damage_automatic_differentiation.py:172
float radius
Definition: mesh_to_mdpa_converter.py:18
int k
Definition: quadrature.py:595
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
int counter
Definition: script_THERMAL_CORRECT.py:218
N
Definition: sensitivityMatrix.py:29