diff --git a/applications/ContactStructuralMechanicsApplication/custom_utilities/mortar_explicit_contribution_utilities.cpp b/applications/ContactStructuralMechanicsApplication/custom_utilities/mortar_explicit_contribution_utilities.cpp index 18f1d5612daa..4143eef6872b 100644 --- a/applications/ContactStructuralMechanicsApplication/custom_utilities/mortar_explicit_contribution_utilities.cpp +++ b/applications/ContactStructuralMechanicsApplication/custom_utilities/mortar_explicit_contribution_utilities.cpp @@ -15,6 +15,7 @@ // External includes // Project includes +#include "utilities/geometrical_projection_utilities.h" #include "custom_utilities/mortar_explicit_contribution_utilities.h" #include "utilities/atomic_utilities.h" diff --git a/applications/MeshingApplication/custom_processes/nodal_values_interpolation_process.cpp b/applications/MeshingApplication/custom_processes/nodal_values_interpolation_process.cpp index bcae12585535..c8b1d2a337f1 100755 --- a/applications/MeshingApplication/custom_processes/nodal_values_interpolation_process.cpp +++ b/applications/MeshingApplication/custom_processes/nodal_values_interpolation_process.cpp @@ -68,7 +68,7 @@ template void NodalValuesInterpolationProcess::Execute() { // We create the locator - BinBasedFastPointLocator point_locator = BinBasedFastPointLocator(mrOriginMainModelPart); + ProjectedBinBasedFastPointLocator point_locator = ProjectedBinBasedFastPointLocator(mrOriginMainModelPart); point_locator.UpdateSearchDatabase(); // Iterate in the nodes @@ -301,7 +301,7 @@ void NodalValuesInterpolationProcess::ExtrapolateValues( GeometryType::CoordinatesArrayType projected_point_local; - const bool is_inside = r_geom.IsInside(projected_point_global.Coordinates( ), projected_point_local); + const bool is_inside = GeometryUtils::ProjectedIsInside(r_geom, projected_point_global.Coordinates( ), projected_point_local); if (is_inside) { // SHAPE FUNCTIONS diff --git a/applications/MeshingApplication/custom_processes/nodal_values_interpolation_process.h b/applications/MeshingApplication/custom_processes/nodal_values_interpolation_process.h index 29bc24c7f6ec..0e58bfed6d12 100755 --- a/applications/MeshingApplication/custom_processes/nodal_values_interpolation_process.h +++ b/applications/MeshingApplication/custom_processes/nodal_values_interpolation_process.h @@ -27,6 +27,7 @@ #include "includes/kratos_parameters.h" /* Utilities */ +#include "utilities/geometry_utilities.h" #include "utilities/binbased_fast_point_locator.h" /* Tree structures */ @@ -71,6 +72,73 @@ namespace NodalInterpolationFunctions ///@name Kratos Classes ///@{ +/** + * @ingroup MeshingApplication + * @class PointBoundary + * @brief Custom Point container to be used to look in the boundary skin + * @details The main difference with this point and the base one is that it contains the pointer to condition where the center of the points belongs + * @author Vicente Mataix Ferrandiz + */ +template< SizeType TDim, class TConfigureType = SpatialContainersConfigure > +class ProjectedBinBasedFastPointLocator + : public BinBasedFastPointLocator +{ +public: + ///@name Type Definitions + ///@{ + + /// The base type + typedef BinBasedFastPointLocator BaseType; + + /// Geometry definitions + typedef Node<3> NodeType; + typedef Geometry GeometryType; + + /// Pointer definition of ProjectedBinBasedFastPointLocator + KRATOS_CLASS_POINTER_DEFINITION(ProjectedBinBasedFastPointLocator); + + ///@} + ///@name Life Cycle + ///@{ + + /** + * @brief This is the default constructor + * @param rModelPart The model part of the mesh used in the search + */ + explicit ProjectedBinBasedFastPointLocator(ModelPart& rModelPart) + : BinBasedFastPointLocator(rModelPart) + { + } + + /// Destructor. + virtual ~ProjectedBinBasedFastPointLocator() = default; + + ///@} +protected: + ///@name Protected Operations + ///@{ + + /** + * @brief Checks if given point in global space coordinates is inside the geometry boundaries. + * @details This function computes the local coordinates and checks then if this point lays within the boundaries. + * @param rPointGlobalCoordinates the global coordinates of the external point. + * @param rResult the local coordinates of the point. + * @param Tolerance the tolerance to the boundary. + * @return true if the point is inside, false otherwise + */ + bool LocalIsInside( + const GeometryType& rGeometry, + const GeometryType::CoordinatesArrayType& rPointGlobalCoordinates, + GeometryType::CoordinatesArrayType& rResult, + const double Tolerance = std::numeric_limits::epsilon() + ) const override + { + return GeometryUtils::ProjectedIsInside(rGeometry, rPointGlobalCoordinates, rResult, Tolerance); + } + + ///@} +}; + /** * @ingroup MeshingApplication * @class PointBoundary @@ -534,19 +602,19 @@ class KRATOS_API(MESHING_APPLICATION) NodalValuesInterpolationProcess /****************************** INPUT STREAM FUNCTION ******************************/ /***********************************************************************************/ -// template -// inline std::istream& operator >> (std::istream& rIStream, -// NodalValuesInterpolationProcess& rThis); +template +inline std::istream& operator >> (std::istream& rIStream, + NodalValuesInterpolationProcess& rThis); /***************************** OUTPUT STREAM FUNCTION ******************************/ /***********************************************************************************/ -// template -// inline std::ostream& operator << (std::ostream& rOStream, -// const NodalValuesInterpolationProcess& rThis) -// { -// return rOStream; -// } +template +inline std::ostream& operator << (std::ostream& rOStream, + const NodalValuesInterpolationProcess& rThis) +{ + return rOStream; +} ///@} diff --git a/kratos/geometries/line_2d_2.h b/kratos/geometries/line_2d_2.h index 5a12a0e1d9aa..16aec5ebac48 100644 --- a/kratos/geometries/line_2d_2.h +++ b/kratos/geometries/line_2d_2.h @@ -941,20 +941,7 @@ class Line2D2 : public Geometry const double Tolerance = std::numeric_limits::epsilon() ) const override { - // We compute the distance, if it is not in the plane we project - const Point point_to_project(rPoint); - Point point_projected; - const double distance = GeometricalProjectionUtilities::FastProjectOnLine2D(*this, point_to_project, point_projected); - - // We check if we are on the plane - if (std::abs(distance) > std::numeric_limits::epsilon()) { - if (std::abs(distance) > 1.0e-6 * Length()) { - KRATOS_WARNING_FIRST_N("Line2D2", 10) << "The point of coordinates X: " << rPoint[0] << "\tY: " << rPoint[1] << " it is in a distance: " << std::abs(distance) << std::endl; - return false; - } - } - - PointLocalCoordinates( rResult, point_projected ); + PointLocalCoordinates( rResult, rPoint ); if ( std::abs( rResult[0] ) <= (1.0 + Tolerance) ) { return true; diff --git a/kratos/geometries/triangle_3d_3.h b/kratos/geometries/triangle_3d_3.h index 611528836b96..fde2885c09ba 100644 --- a/kratos/geometries/triangle_3d_3.h +++ b/kratos/geometries/triangle_3d_3.h @@ -28,7 +28,6 @@ #include "geometries/line_3d_2.h" #include "integration/triangle_gauss_legendre_integration_points.h" #include "integration/triangle_collocation_integration_points.h" -#include "utilities/geometrical_projection_utilities.h" #include "utilities/intersection_utilities.h" namespace Kratos @@ -874,28 +873,7 @@ template class Triangle3D3 const double Tolerance = std::numeric_limits::epsilon() ) const override { - // We compute the normal to check the normal distances between the point and the triangles, so we can discard that is on the triangle - const auto center = this->Center(); - const array_1d normal = this->UnitNormal(center); - - // We compute the distance, if it is not in the plane we project - const Point point_to_project(rPoint); - double distance; - CoordinatesArrayType point_projected; - point_projected = GeometricalProjectionUtilities::FastProject( center, point_to_project, normal, distance); - - // We check if we are on the plane - if (std::abs(distance) > std::numeric_limits::epsilon()) { - if (std::abs(distance) > 1.0e-6 * Length()) { - KRATOS_WARNING_FIRST_N("Triangle3D3", 10) << "The " << rPoint << " is in a distance: " << std::abs(distance) << std::endl; - return false; - } - - // Not in the plane, but allowing certain distance, projecting - noalias(point_projected) = rPoint - normal * distance; - } - - PointLocalCoordinates( rResult, point_projected ); + PointLocalCoordinates( rResult, rPoint ); if ( (rResult[0] >= (0.0-Tolerance)) && (rResult[0] <= (1.0+Tolerance)) ) { if ( (rResult[1] >= (0.0-Tolerance)) && (rResult[1] <= (1.0+Tolerance)) ) { diff --git a/kratos/tests/cpp_tests/geometries/test_quadrature_point_geometry.cpp b/kratos/tests/cpp_tests/geometries/test_quadrature_point_geometry.cpp index f6e9812cf7e1..56bb338363c2 100644 --- a/kratos/tests/cpp_tests/geometries/test_quadrature_point_geometry.cpp +++ b/kratos/tests/cpp_tests/geometries/test_quadrature_point_geometry.cpp @@ -18,7 +18,7 @@ #include "includes/stream_serializer.h" #include "utilities/quadrature_points_utility.h" - +#include "utilities/geometrical_projection_utilities.h" #include "geometries/point.h" #include "geometries/triangle_2d_3.h"