52 RADIUS_NOT_PROJECTED_OUTSIDE,
53 RADIUS_NOT_PROJECTED_INSIDE
90 template<
class TGeometryType>
92 const TGeometryType& rGeom,
101 const double zero_tolerance = std::numeric_limits<double>::epsilon();
104 double distance = 0.0;
108 if(
norm_2( rVector ) < zero_tolerance &&
norm_2( rNormal ) > zero_tolerance ) {
111 KRATOS_WARNING_IF(
"GeometricalProjectionUtilities",
EchoLevel > 0) <<
"WARNING:: Zero projection vector. Projection using the condition vector instead." << std::endl;
112 }
else if (std::abs(
inner_prod(rVector, rNormal) ) > zero_tolerance) {
117 KRATOS_WARNING_IF(
"GeometricalProjectionUtilities",
EchoLevel > 0) <<
"WARNING:: The line and the plane are coplanar. Something wrong happened " << std::endl;
134 template<
class TPo
intClass1,
class TPo
intClass2 = TPo
intClass1,
class TPo
intClass3 = Po
intType>
136 const TPointClass1& rPointOrigin,
137 const TPointClass2& rPointToProject,
144 rDistance =
inner_prod(vector_points, rNormal);
146 TPointClass3 point_projected;
148 noalias(point_projected) = rPointToProject - rNormal * rDistance;
150 return point_projected;
162 template<
class TGeometryType>
164 const Point& rPointToProject,
170 rGeom.PointLocalCoordinates(local_coords_center, rGeom.Center());
173 return FastProjectDirection(
191 template<
class TGeometryType>
219 template<
class TGeometryType>
221 const TGeometryType& rGeometry,
223 const double Tolerance = 1.0e-9
227 const double projected_distance = FastProjectOnLine(rGeometry, rPoint, projected_point);
229 if (rGeometry.IsInside(projected_point.
Coordinates(), projected_local, Tolerance)) {
230 return projected_distance;
232 const double distance_a = rPoint.
Distance(rGeometry[0]);
233 const double distance_b = rPoint.
Distance(rGeometry[1]);
234 return std::min(distance_a, distance_b);
248 static DistanceComputed FastMinimalDistanceOnLineWithRadius(
253 const double Tolerance = 1.0e-9
266 template<
class TGeometryType,
class TPo
intClass1,
class TPo
intClass2 = TPo
intClass1>
268 const TGeometryType& rGeometry,
269 const TPointClass1& rPointToProject,
270 TPointClass2& rPointProjected
280 normal[0] = r_p_b[1] - r_p_a[1];
281 normal[1] = r_p_a[0] - r_p_b[0];
284 const double norm_normal =
norm_2(normal);
285 KRATOS_ERROR_IF(norm_normal <= std::numeric_limits<double>::epsilon()) <<
"Zero norm normal: X: " << normal[0] <<
"\tY: " << normal[1] << std::endl;
286 normal /= norm_normal;
289 const double distance =
inner_prod(vector_points, normal);
290 noalias(rPointProjected) = r_p_c + normal * distance;
303 template<
class TGeometryType>
305 TGeometryType& rGeomOrigin,
309 const double Tolerance = 1.0e-8,
315 double old_delta_xi = 0.0;
323 normals[0] = rGeomOrigin[0].FastGetSolutionStepValue(NORMAL);
324 normals[1] = rGeomOrigin[1].FastGetSolutionStepValue(NORMAL);
328 for(
unsigned int i=0;
i<2;++
i) {
329 X(0,
i) = rGeomOrigin[
i].X();
330 X(1,
i) = rGeomOrigin[
i].Y();
341 N_origin[0] = 0.5 * ( 1.0 - rResultingPoint[0]);
342 N_origin[1] = 0.5 * ( 1.0 + rResultingPoint[0]);
345 normal_xi = normal_xi/
norm_2(normal_xi);
348 for(
IndexType i_node = 0; i_node < 2; ++i_node )
349 current_global_coords += N_origin[i_node] * rGeomOrigin[i_node].Coordinates();
353 const array_1d<double, 3> current_destiny_global_coords = rPointDestiny - normal_xi * distance;
356 Matrix ShapeFunctionsGradients;
357 ShapeFunctionsGradients = rGeomOrigin.ShapeFunctionsLocalGradients(ShapeFunctionsGradients, rResultingPoint );
365 old_delta_xi = DeltaXi;
366 DeltaXi = RHS[0]/
J(0, 0);
368 rResultingPoint[0] += DeltaXi;
370 if (rResultingPoint[0] <= -1.0)
371 rResultingPoint[0] = -1.0;
372 else if (rResultingPoint[0] >= 1.0)
373 rResultingPoint[0] = 1.0;
375 if ( std::abs(DeltaXi - old_delta_xi) < Tolerance )
This is a class that provides auxiliar utilities for projections.
Definition: geometrical_projection_utilities.h:39
KRATOS_CLASS_POINTER_DEFINITION(GeometricalProjectionUtilities)
Pointer definition of GeometricalProjectionUtilities.
std::size_t SizeType
Size type definition.
Definition: geometrical_projection_utilities.h:67
static double FastProjectDirection(const TGeometryType &rGeom, const PointType &rPointToProject, PointType &rPointProjected, const array_1d< double, 3 > &rNormal, const array_1d< double, 3 > &rVector, const SizeType EchoLevel=0)
Project a point over a line/plane following an arbitrary direction.
Definition: geometrical_projection_utilities.h:91
Node NodeType
Definition: geometrical_projection_utilities.h:60
static double FastMinimalDistanceOnLine(const TGeometryType &rGeometry, const PointType &rPoint, const double Tolerance=1.0e-9)
Computes the minimal distance to a line.
Definition: geometrical_projection_utilities.h:220
static bool ProjectIterativeLine2D(TGeometryType &rGeomOrigin, const array_1d< double, 3 > &rPointDestiny, array_1d< double, 3 > &rResultingPoint, const array_1d< double, 3 > &rNormal, const double Tolerance=1.0e-8, double DeltaXi=0.5)
Projects iteratively to get the coordinate.
Definition: geometrical_projection_utilities.h:304
std::size_t IndexType
Index type definition.
Definition: geometrical_projection_utilities.h:64
static TPointClass3 FastProject(const TPointClass1 &rPointOrigin, const TPointClass2 &rPointToProject, const array_1d< double, 3 > &rNormal, double &rDistance)
Project a point over a plane (avoiding some steps)
Definition: geometrical_projection_utilities.h:135
DistanceComputed
How the distance is computed enum.
Definition: geometrical_projection_utilities.h:48
Point PointType
Definition: geometrical_projection_utilities.h:61
static double FastProjectOnLine2D(const TGeometryType &rGeometry, const TPointClass1 &rPointToProject, TPointClass2 &rPointProjected)
Project a point over a line (2D only)
Definition: geometrical_projection_utilities.h:267
static double FastProjectOnGeometry(const TGeometryType &rGeom, const Point &rPointToProject, PointType &rPointProjected, const SizeType EchoLevel=0)
Project a point over a line/plane (simplified since using the normal in the center)
Definition: geometrical_projection_utilities.h:163
static double FastProjectOnLine(const TGeometryType &rGeometry, const PointType &rPointToProject, PointType &rPointProjected)
Project a point over a line (2D or 3D)
Definition: geometrical_projection_utilities.h:192
GeometricalProjectionUtilities()=delete
Geometry base class.
Definition: geometry.h:71
Definition: amatrix_interface.h:41
This class defines the node.
Definition: node.h:65
Point class.
Definition: point.h:59
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
double Distance(const Point &rOtherPoint) const
This method computes the distance between this point and another one.
Definition: point.h:166
#define KRATOS_DEBUG_CHECK_VARIABLE_IN_NODAL_DATA(TheVariable, TheNode)
Definition: checks.h:242
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_WARNING_IF(label, conditional)
Definition: logger.h:266
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
static double min(double a, double b)
Definition: GeometryFunctions.h:71
typename Point::CoordinatesArrayType CoordinatesArrayType
Definition: add_geometries_to_python.cpp:63
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
AMatrix::SubVector< const TExpressionType > subrange(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t From, std::size_t To)
Definition: amatrix_interface.h:662
DN
Definition: generate_convection_diffusion_explicit_element.py:98
int max_iter
Definition: hinsberg_optimization.py:139
int k
Definition: quadrature.py:595
J
Definition: sensitivityMatrix.py:58
integer i
Definition: TensorModule.f:17
float factor
for node in (self.combined_model_part).Nodes: pold = node.GetSolutionStepValue(PRESSURE,...
Definition: ulf_PGLASS.py:254