15 #ifndef _EDGEBASED_LEVELSET_AUXILIARY_UTILS_H
16 #define _EDGEBASED_LEVELSET_AUXILIARY_UTILS_H
25 #include "utilities/geometry_utilities.h"
63 template<
unsigned int TDim>
95 const double max_distance
98 if constexpr (TDim == 2)
100 else if constexpr (TDim == 3)
111 const double max_distance
116 double large_distance = 1e6;
117 double tol = 1.0/large_distance;
120 for(ModelPart::NodesContainerType::iterator it = r_model_part.
NodesBegin(); it !=r_model_part.
NodesEnd(); it++)
122 it->GetValue(rDistanceVar) = it->FastGetSolutionStepValue(rDistanceVar);
123 it->FastGetSolutionStepValue(rDistanceVar) = large_distance;
124 it->GetValue(IS_VISITED) = 0;
139 unsigned int n_positive = 0;
140 unsigned int n_negative = 0;
141 for(
unsigned int kk = 0; kk<TDim+1 ; kk++)
144 distances[kk] =
dist;
151 if(n_negative > 0 && n_positive > 0)
158 double norm =
norm_2(grad_d);
162 for(
unsigned int i = 1;
i<TDim+1;
i++)
164 if(distances[0]*distances[
i]<=0)
166 double delta_d = fabs(distances[
i]) + fabs(distances[0]);
170 double Ni = fabs(distances[0]) / delta_d;
171 double N0 = fabs(distances[
i]) / delta_d;
173 noalias(coord_on_0) = N0 * geom[0].Coordinates();
174 noalias(coord_on_0) += Ni * geom[
i].Coordinates();
177 noalias(coord_on_0) = geom[0].Coordinates();
185 for(
unsigned int i = 0;
i<TDim+1;
i++)
190 double real_distance = 0.0;
191 for(
unsigned int k=0;
k<TDim;
k++)
192 real_distance +=
temp[
k]*grad_d[
k];
193 real_distance = fabs(real_distance);
195 double& dist_i = geom[
i].FastGetSolutionStepValue(rDistanceVar);
196 if(real_distance < dist_i)
197 dist_i = real_distance;
212 for(ModelPart::NodesContainerType::iterator it = r_model_part.
NodesBegin(); it !=r_model_part.
NodesEnd(); it++)
214 if(fabs(it->GetValue(rDistanceVar)) <
tol)
216 it->FastGetSolutionStepValue(rDistanceVar) = 0.0;
217 it->GetValue(IS_VISITED) = 1;
226 for(ModelPart::NodesContainerType::iterator it = r_model_part.
NodesBegin(); it !=r_model_part.
NodesEnd(); it++)
228 if(it->GetValue(rDistanceVar) < 0)
229 it->FastGetSolutionStepValue(rDistanceVar) = -it->FastGetSolutionStepValue(rDistanceVar);
233 for(ModelPart::NodesContainerType::iterator it = r_model_part.
NodesBegin(); it !=r_model_part.
NodesEnd(); it++)
235 if(fabs(it->FastGetSolutionStepValue(rDistanceVar)) == large_distance)
237 KRATOS_WATCH(
"error in the calculation of the distance for node")
249 const double max_distance
254 const double large_distance = 1e9;
256 std::vector<array_1d<double,TDim + 1> > distances;
257 std::vector<Element::Pointer> interface_elements;
260 for(ModelPart::NodesContainerType::iterator it = r_model_part.
NodesBegin(); it !=r_model_part.
NodesEnd(); it++)
262 it->GetValue(rDistanceVar) = it->FastGetSolutionStepValue(rDistanceVar);
263 it->GetValue(IS_VISITED) = 0;
267 for(ElementsArrayType::iterator i_element = r_model_part.
ElementsBegin(); i_element !=r_model_part.
ElementsEnd(); i_element++)
273 bool positive =
false;
274 bool negative =
false;
277 for(
unsigned int i_node = 0; i_node < element_geometry.
size() ; i_node++)
279 const double distance = element_geometry[i_node].GetSolutionStepValue(rDistanceVar);
280 element_distance[i_node] = distance;
281 negative |= (distance < 0);
282 positive |= (distance >= 0);
285 if(negative && positive)
287 interface_elements.push_back(*(i_element.base()));
288 distances.push_back(element_distance);
293 for(ModelPart::NodesContainerType::iterator it = r_model_part.
NodesBegin(); it !=r_model_part.
NodesEnd(); it++)
295 double& distance = it->FastGetSolutionStepValue(rDistanceVar);
298 distance = large_distance;
300 distance = -large_distance;
304 int size =
static_cast<int>(interface_elements.size());
305 for(
int i = 0 ;
i < size ;
i++)
313 for(
unsigned int i_node = 0; i_node < element_geometry.
size() ; i_node++)
315 double& distance = element_geometry[i_node].GetSolutionStepValue(rDistanceVar);
316 double new_distance = distances[
i][i_node];
318 if(fabs(distance) > fabs(new_distance))
321 distance = new_distance;
323 distance = new_distance;
325 element_geometry[i_node].
GetValue(IS_VISITED) = 1;
333 for(ModelPart::NodesContainerType::iterator it = r_model_part.
NodesBegin(); it !=r_model_part.
NodesEnd(); it++)
335 if(it->GetValue(rDistanceVar) < 0)
336 it->FastGetSolutionStepValue(rDistanceVar) = -it->FastGetSolutionStepValue(rDistanceVar);
340 for(ModelPart::NodesContainerType::iterator it = r_model_part.
NodesBegin(); it !=r_model_part.
NodesEnd(); it++)
342 if(fabs(it->FastGetSolutionStepValue(rDistanceVar)) == large_distance)
344 KRATOS_WATCH(
"error in the calculation of the distance for node")
363 for (ModelPart::NodesContainerType::iterator in = rNodes.begin(); in != rNodes.end(); in++)
371 i != in->GetValue(NEIGHBOUR_NODES).end();
i++)
378 l += (
z - zc)*(
z - zc);
384 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
Definition: edgebased_levelset_auxiliary_utils.h:65
ModelPart::ElementsContainerType ElementsArrayType
Definition: edgebased_levelset_auxiliary_utils.h:70
void CalculateDistances(ModelPart &r_model_part, Variable< double > &rDistanceVar, const double max_distance)
Definition: edgebased_levelset_auxiliary_utils.h:92
ModelPart::NodesContainerType NodesArrayType
Definition: edgebased_levelset_auxiliary_utils.h:69
void CalculateDistances2D(ModelPart &r_model_part, Variable< double > &rDistanceVar, const double max_distance)
Definition: edgebased_levelset_auxiliary_utils.h:108
void CalculateDistances3D(ModelPart &r_model_part, Variable< double > &rDistanceVar, const double max_distance)
Definition: edgebased_levelset_auxiliary_utils.h:246
double FindMaximumEdgeSize(ModelPart &r_model_part)
Definition: edgebased_levelset_auxiliary_utils.h:355
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
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
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
#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