14 #ifndef _SIGNED_DISTANCE_CALCULATION_UTILS_H
15 #define _SIGNED_DISTANCE_CALCULATION_UTILS_H
24 #include "utilities/geometry_utilities.h"
80 template<
unsigned int TDim>
113 const double max_distance
116 if constexpr (TDim == 2)
118 else if constexpr (TDim == 3)
129 const double max_distance
134 double large_distance = 1e6;
135 double tol = 1.0/large_distance;
140 it->GetValue(rDistanceVar) = it->FastGetSolutionStepValue(rDistanceVar);
141 it->FastGetSolutionStepValue(rDistanceVar) = large_distance;
142 it->GetValue(IS_VISITED) = 0;
157 unsigned int n_positive = 0;
158 unsigned int n_negative = 0;
159 for(
unsigned int kk = 0; kk<TDim+1 ; kk++)
162 distances[kk] =
dist;
169 if(n_negative > 0 && n_positive > 0)
228 double norm =
norm_2(grad_d);
232 for(
unsigned int i = 1;
i<TDim+1;
i++)
234 if(distances[0]*distances[
i]<=0)
236 double delta_d = fabs(distances[
i]) + fabs(distances[0]);
240 double Ni = fabs(distances[0]) / delta_d;
241 double N0 = fabs(distances[
i]) / delta_d;
243 noalias(coord_on_0) = N0 * geom[0].Coordinates();
244 noalias(coord_on_0) += Ni * geom[
i].Coordinates();
247 noalias(coord_on_0) = geom[0].Coordinates();
255 for(
unsigned int i = 0;
i<TDim+1;
i++)
260 double real_distance = 0.0;
261 for(
unsigned int k=0;
k<TDim;
k++)
262 real_distance +=
temp[
k]*grad_d[
k];
263 real_distance = fabs(real_distance);
265 double& dist_i = geom[
i].FastGetSolutionStepValue(rDistanceVar);
266 if(real_distance < dist_i)
267 dist_i = real_distance;
284 if(fabs(it->GetValue(rDistanceVar)) <
tol)
286 it->FastGetSolutionStepValue(rDistanceVar) = 0.0;
287 it->GetValue(IS_VISITED) = 1;
316 if(it->GetValue(rDistanceVar) < 0)
317 it->FastGetSolutionStepValue(rDistanceVar) = -it->FastGetSolutionStepValue(rDistanceVar);
323 if(fabs(it->FastGetSolutionStepValue(rDistanceVar)) == large_distance)
325 KRATOS_WATCH(
"error in the calculation of the distance for node")
341 const double max_distance
346 const double large_distance = 1e9;
348 std::vector<array_1d<double,TDim + 1> > distances;
349 std::vector<Element::Pointer> interface_elements;
354 it->GetValue(rDistanceVar) = it->FastGetSolutionStepValue(rDistanceVar);
355 it->GetValue(IS_VISITED) = 0;
365 bool positive =
false;
366 bool negative =
false;
369 for(
unsigned int i_node = 0; i_node < element_geometry.
size() ; i_node++)
371 const double distance = element_geometry[i_node].GetSolutionStepValue(rDistanceVar);
372 element_distance[i_node] = distance;
373 negative |= (distance < 0);
374 positive |= (distance >= 0);
377 if(negative && positive)
379 interface_elements.push_back(*(i_element.base()));
380 distances.push_back(element_distance);
387 double& distance = it->FastGetSolutionStepValue(rDistanceVar);
390 distance = large_distance;
392 distance = -large_distance;
396 int size =
static_cast<int>(interface_elements.size());
397 for(
int i = 0 ;
i < size ;
i++)
405 for(
unsigned int i_node = 0; i_node < element_geometry.
size() ; i_node++)
407 double& distance = element_geometry[i_node].GetSolutionStepValue(rDistanceVar);
408 double new_distance = distances[
i][i_node];
420 if(fabs(distance) > fabs(new_distance))
423 distance = new_distance;
425 distance = new_distance;
427 element_geometry[i_node].
GetValue(IS_VISITED) = 1;
437 if(it->GetValue(rDistanceVar) < 0)
438 it->FastGetSolutionStepValue(rDistanceVar) = -it->FastGetSolutionStepValue(rDistanceVar);
444 if(fabs(it->FastGetSolutionStepValue(rDistanceVar)) == large_distance)
446 KRATOS_WATCH(
"error in the calculation of the distance for node")
476 i != in->GetValue(NEIGHBOUR_NODES).end();
i++)
483 l += (
z - zc)*(
z - zc);
489 if(
h > h_max) h_max =
h;
Definition: body_distance_calculation_utils.h:93
void CalculateDistances(ElementsArrayType &rElements, Variable< double > &rDistanceVar, const double max_distance)
Definition: body_distance_calculation_utils.h:134
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
static void CalculateTetrahedraDistances(const GeometryType &rGeometry, array_1d< double, TSize > &rDistances)
Calculate the exact distances to the interface TRIANGLE defined by a set of initial distances.
Definition: geometry_utilities.h:372
static void CalculateGeometryData(const GeometryType &rGeometry, BoundedMatrix< double, 4, 3 > &rDN_DX, array_1d< double, 4 > &rN, double &rVolume)
This function is designed to compute the shape function derivatives, shape functions and volume in 3D...
Definition: geometry_utilities.h:176
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
Definition: amatrix_interface.h:41
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
Definition: signed_distance_calculation_utils.h:82
void CalculateDistances(ModelPart &r_model_part, Variable< double > &rDistanceVar, const double max_distance)
Definition: signed_distance_calculation_utils.h:110
void CalculateDistances2D(ModelPart &r_model_part, Variable< double > &rDistanceVar, const double max_distance)
Definition: signed_distance_calculation_utils.h:126
double FindMaximumEdgeSize(ModelPart &r_model_part)
Definition: signed_distance_calculation_utils.h:460
void CalculateDistances3D(ModelPart &r_model_part, Variable< double > &rDistanceVar, const double max_distance)
Definition: signed_distance_calculation_utils.h:338
ModelPart::NodesContainerType NodesArrayType
Definition: signed_distance_calculation_utils.h:86
ModelPart::ElementsContainerType ElementsArrayType
Definition: signed_distance_calculation_utils.h:87
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
z
Definition: GenerateWind.py:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
float dist
Definition: edgebased_PureConvection.py:89
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
h
Definition: generate_droplet_dynamics.py:91
int tol
Definition: hinsberg_optimization.py:138
int k
Definition: quadrature.py:595
float temp
Definition: rotating_cone.py:85
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
N
Definition: sensitivityMatrix.py:29
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17
integer l
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31