Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Line/triangle IsInside removing projection #7401

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ template<SizeType TDim>
void NodalValuesInterpolationProcess<TDim>::Execute()
{
// We create the locator
BinBasedFastPointLocator<TDim> point_locator = BinBasedFastPointLocator<TDim>(mrOriginMainModelPart);
ProjectedBinBasedFastPointLocator<TDim> point_locator = ProjectedBinBasedFastPointLocator<TDim>(mrOriginMainModelPart);
point_locator.UpdateSearchDatabase();

// Iterate in the nodes
Expand Down Expand Up @@ -301,7 +301,7 @@ void NodalValuesInterpolationProcess<TDim>::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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "includes/kratos_parameters.h"

/* Utilities */
#include "utilities/geometry_utilities.h"
#include "utilities/binbased_fast_point_locator.h"

/* Tree structures */
Expand Down Expand Up @@ -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<TDim> >
class ProjectedBinBasedFastPointLocator
: public BinBasedFastPointLocator<TDim, TConfigureType>
{
public:
///@name Type Definitions
///@{

/// The base type
typedef BinBasedFastPointLocator<TDim, TConfigureType> BaseType;

/// Geometry definitions
typedef Node<3> NodeType;
typedef Geometry<NodeType> 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<TDim, TConfigureType>(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<double>::epsilon()
) const override
{
return GeometryUtils::ProjectedIsInside(rGeometry, rPointGlobalCoordinates, rResult, Tolerance);
}

///@}
};

/**
* @ingroup MeshingApplication
* @class PointBoundary
Expand Down Expand Up @@ -534,19 +602,19 @@ class KRATOS_API(MESHING_APPLICATION) NodalValuesInterpolationProcess
/****************************** INPUT STREAM FUNCTION ******************************/
/***********************************************************************************/

// template<class TPointType, class TPointerType>
// inline std::istream& operator >> (std::istream& rIStream,
// NodalValuesInterpolationProcess& rThis);
template<SizeType TDim>
inline std::istream& operator >> (std::istream& rIStream,
NodalValuesInterpolationProcess<TDim>& rThis);

/***************************** OUTPUT STREAM FUNCTION ******************************/
/***********************************************************************************/

// template<class TPointType, class TPointerType>
// inline std::ostream& operator << (std::ostream& rOStream,
// const NodalValuesInterpolationProcess& rThis)
// {
// return rOStream;
// }
template<SizeType TDim>
inline std::ostream& operator << (std::ostream& rOStream,
const NodalValuesInterpolationProcess<TDim>& rThis)
{
return rOStream;
}

///@}

Expand Down
15 changes: 1 addition & 14 deletions kratos/geometries/line_2d_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -941,20 +941,7 @@ class Line2D2 : public Geometry<TPointType>
const double Tolerance = std::numeric_limits<double>::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<double>::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;
Expand Down
24 changes: 1 addition & 23 deletions kratos/geometries/triangle_3d_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -874,28 +873,7 @@ template<class TPointType> class Triangle3D3
const double Tolerance = std::numeric_limits<double>::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<double, 3> 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<double>::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)) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down