66 template<
class TGeometryType>
68 const TGeometryType& rGeometry,
84 const auto& r_coordinates_0 = rGeometry[0].Coordinates();
85 const auto& r_coordinates_1 = rGeometry[1].Coordinates();
86 const auto& r_coordinates_2 = rGeometry[2].Coordinates();
87 const auto& r_coordinates_3 = rGeometry[3].Coordinates();
88 const double x1 = r_coordinates_0[0];
89 const double y1 = r_coordinates_0[1];
90 const double z1 = r_coordinates_0[2];
91 const double x2 = r_coordinates_1[0];
92 const double y2 = r_coordinates_1[1];
93 const double z2 = r_coordinates_1[2];
94 const double x3 = r_coordinates_2[0];
95 const double y3 = r_coordinates_2[1];
96 const double z3 = r_coordinates_2[2];
97 const double x4 = r_coordinates_3[0];
98 const double y4 = r_coordinates_3[1];
99 const double z4 = r_coordinates_3[2];
102 const double x12 =
x1 -
x2;
103 const double x13 =
x1 - x3;
104 const double x14 =
x1 - x4;
105 const double x21 =
x2 -
x1;
106 const double x24 =
x2 - x4;
107 const double x31 = x3 -
x1;
108 const double x32 = x3 -
x2;
109 const double x34 = x3 - x4;
110 const double x42 = x4 -
x2;
111 const double x43 = x4 - x3;
112 const double y12 = y1 - y2;
113 const double y13 = y1 - y3;
114 const double y14 = y1 - y4;
115 const double y21 = y2 - y1;
116 const double y24 = y2 - y4;
117 const double y31 = y3 - y1;
118 const double y32 = y3 - y2;
119 const double y34 = y3 - y4;
120 const double y42 = y4 - y2;
121 const double y43 = y4 - y3;
122 const double z12 = z1 - z2;
123 const double z13 = z1 - z3;
124 const double z14 = z1 - z4;
125 const double z21 = z2 - z1;
126 const double z24 = z2 - z4;
127 const double z31 = z3 - z1;
128 const double z32 = z3 - z2;
129 const double z34 = z3 - z4;
130 const double z42 = z4 - z2;
131 const double z43 = z4 - z3;
135 const double aux_volume = 1.0/(6.0*rGeometry.Volume());
136 invJ(0,0) = aux_volume * (
x2*(y3*z4-y4*z3)+x3*(y4*z2-y2*z4)+x4*(y2*z3-y3*z2));
137 invJ(1,0) = aux_volume * (
x1*(y4*z3-y3*z4)+x3*(y1*z4-y4*z1)+x4*(y3*z1-y1*z3));
138 invJ(2,0) = aux_volume * (
x1*(y2*z4-y4*z2)+
x2*(y4*z1-y1*z4)+x4*(y1*z2-y2*z1));
139 invJ(3,0) = aux_volume * (
x1*(y3*z2-y2*z3)+
x2*(y1*z3-y3*z1)+x3*(y2*z1-y1*z2));
140 invJ(0,1) = aux_volume * (y42*z32 - y32*z42);
141 invJ(1,1) = aux_volume * (y31*z43 - y34*z13);
142 invJ(2,1) = aux_volume * (y24*z14 - y14*z24);
143 invJ(3,1) = aux_volume * (y13*z21 - y12*z31);
144 invJ(0,2) = aux_volume * (x32*z42 - x42*z32);
145 invJ(1,2) = aux_volume * (x43*z31 - x13*z34);
146 invJ(2,2) = aux_volume * (x14*z24 - x24*z14);
147 invJ(3,2) = aux_volume * (x21*z13 - x31*z12);
148 invJ(0,3) = aux_volume * (x42*y32 - x32*y42);
149 invJ(1,3) = aux_volume * (x31*y43 - x34*y13);
150 invJ(2,3) = aux_volume * (x24*y14 - x14*y24);
151 invJ(3,3) = aux_volume * (x13*y21 - x12*y31);
157 if (rResult.size() != 3) {
158 rResult.resize(3,
false);
162 rResult[0] = result[1];
163 rResult[1] = result[2];
164 rResult[2] = result[3];
183 const double x10 = rGeometry[1].X() - rGeometry[0].X();
184 const double y10 = rGeometry[1].Y() - rGeometry[0].Y();
185 const double z10 = rGeometry[1].Z() - rGeometry[0].Z();
187 const double x20 = rGeometry[2].X() - rGeometry[0].X();
188 const double y20 = rGeometry[2].Y() - rGeometry[0].Y();
189 const double z20 = rGeometry[2].Z() - rGeometry[0].Z();
191 const double x30 = rGeometry[3].X() - rGeometry[0].X();
192 const double y30 = rGeometry[3].Y() - rGeometry[0].Y();
193 const double z30 = rGeometry[3].Z() - rGeometry[0].Z();
195 const double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
197 rDN_DX(0,0) = -y20 * z30 + y30 * z20 + y10 * z30 - z10 * y30 - y10 * z20 + z10 * y20;
198 rDN_DX(0,1) = -z20 * x30 + x20 * z30 - x10 * z30 + z10 * x30 + x10 * z20 - z10 * x20;
199 rDN_DX(0,2) = -x20 * y30 + y20 * x30 + x10 * y30 - y10 * x30 - x10 * y20 + y10 * x20;
200 rDN_DX(1,0) = y20 * z30 - y30 * z20;
201 rDN_DX(1,1) = z20 * x30 - x20 * z30;
202 rDN_DX(1,2) = x20 * y30 - y20 * x30;
203 rDN_DX(2,0) = -y10 * z30 + z10 * y30;
204 rDN_DX(2,1) = x10 * z30 - z10 * x30;
205 rDN_DX(2,2) = -x10 * y30 + y10 * x30;
206 rDN_DX(3,0) = y10 * z20 - z10 * y20;
207 rDN_DX(3,1) = -x10 * z20 + z10 * x20;
208 rDN_DX(3,2) = x10 * y20 - y10 * x20;
217 rVolume = detJ*0.1666666666666666666667;
228 const double x10 = rGeometry[1].X() - rGeometry[0].X();
229 const double y10 = rGeometry[1].Y() - rGeometry[0].Y();
230 const double z10 = rGeometry[1].Z() - rGeometry[0].Z();
232 const double x20 = rGeometry[2].X() - rGeometry[0].X();
233 const double y20 = rGeometry[2].Y() - rGeometry[0].Y();
234 const double z20 = rGeometry[2].Z() - rGeometry[0].Z();
236 const double x30 = rGeometry[3].X() - rGeometry[0].X();
237 const double y30 = rGeometry[3].Y() - rGeometry[0].Y();
238 const double z30 = rGeometry[3].Z() - rGeometry[0].Z();
240 const double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
241 return detJ*0.1666666666666666666667;
258 const double x10 = rGeometry[1].X() - rGeometry[0].X();
259 const double y10 = rGeometry[1].Y() - rGeometry[0].Y();
261 const double x20 = rGeometry[2].X() - rGeometry[0].X();
262 const double y20 = rGeometry[2].Y() - rGeometry[0].Y();
269 double detJ = x10 * y20-y10 * x20;
271 DN_DX(0,0) = -y20 + y10;
272 DN_DX(0,1) = x20 - x10;
279 N[0] = 0.333333333333333;
280 N[1] = 0.333333333333333;
281 N[2] = 0.333333333333333;
294 double x10 = rGeometry[1].X() - rGeometry[0].X();
295 double y10 = rGeometry[1].Y() - rGeometry[0].Y();
297 double x20 = rGeometry[2].X() - rGeometry[0].X();
298 double y20 = rGeometry[2].Y() - rGeometry[0].Y();
300 double detJ = x10 * y20-y10 * x20;
317 const double x10 = rGeometry[1].X() - rGeometry[0].X();
318 const double y10 = rGeometry[1].Y() - rGeometry[0].Y();
320 const double x20 = rGeometry[2].X() - rGeometry[0].X();
321 const double y20 = rGeometry[2].Y() - rGeometry[0].Y();
323 double l = std::pow(x20, 2) + std::pow(y20, 2);
328 else if(
l<hmin) hmin =
l;
330 l = (x20-x10)*(x20-x10) + (y20-y10)*(y20-y10);
332 else if(
l<hmin) hmin =
l;
334 hmax = std::sqrt(hmax);
335 hmin = std::sqrt(hmin);
352 const double lx = rGeometry[0].X() - rGeometry[1].X();
353 const double ly = rGeometry[0].Y() - rGeometry[1].Y();
354 const double detJ = 0.5 * std::sqrt(std::pow(lx, 2) + std::pow(ly, 2));
363 rLength = 2.0 * detJ;
371 template<std::
size_t TSize>
377 int number_of_intersection_points = CalculateTetrahedraIntersectionPoints(rGeometry, rDistances, intersection_points);
379 if(number_of_intersection_points == 0) {
380 KRATOS_WARNING(
"CalculateTetrahedraDistances") <<
"WARNING:: The intersection with interface hasn't found!" << std::endl <<
"The distances are: " << rDistances << std::endl;
381 }
else if(number_of_intersection_points == 1) {
385 for(
unsigned int i_node = 0; i_node < rGeometry.
size() ; ++i_node) {
386 noalias(
temp) = intersection_points[0] - rGeometry[i_node];
389 }
else if(number_of_intersection_points == 2) {
391 for(
unsigned int i_node = 0; i_node < rGeometry.
size() ; ++i_node) {
392 rDistances[i_node] = PointDistanceToLineSegment3D(intersection_points[0], intersection_points[1], rGeometry[i_node]);
394 }
else if(number_of_intersection_points == 3) {
396 for(
unsigned int i_node = 0; i_node < rGeometry.
size() ; ++i_node) {
397 rDistances[i_node] = PointDistanceToTriangle3D(intersection_points[0], intersection_points[1], intersection_points[2], rGeometry[i_node]);
401 }
else if(number_of_intersection_points == 4) {
403 for(
unsigned int i_node = 0; i_node < rGeometry.
size() ; ++i_node) {
405 double d1 = PointDistanceToTriangle3D(intersection_points[0], intersection_points[1], intersection_points[3], rGeometry[i_node]);
406 double d2 = PointDistanceToTriangle3D(intersection_points[0], intersection_points[3], intersection_points[2], rGeometry[i_node]);
408 rDistances[i_node] = (
d1 > d2) ? d2 :
d1;
418 template<std::
size_t TSize>
426 int number_of_intersection_points = CalculateTetrahedraIntersectionPoints(rGeometry, rDistances, intersection_points);
428 if(number_of_intersection_points == 0) {
429 KRATOS_WARNING(
"CalculateTriangleDistances") <<
"WARNING:: The intersection with interface hasn't found!" << std::endl <<
"The distances are: " << rDistances << std::endl;
430 }
else if(number_of_intersection_points == 1) {
433 for(
unsigned int i_node = 0; i_node < rGeometry.
size() ; ++i_node) {
434 noalias(
temp) = intersection_points[0] - rGeometry[i_node];
437 }
else if(number_of_intersection_points == 2) {
439 for(
unsigned int i_node = 0; i_node < rGeometry.
size() ; ++i_node) {
440 rDistances[i_node] = PointDistanceToLineSegment3D(intersection_points[0], intersection_points[1], rGeometry[i_node]);
443 KRATOS_WARNING(
"CalculateTriangleDistances") <<
"WARNING:: This is a triangle with more than two intersections!" << std::endl <<
"Too many intersections: " << number_of_intersection_points << std::endl <<
"The distances are: " << rDistances << std::endl;
453 template<std::
size_t TSize>
460 int number_of_intersection_points = CalculateTetrahedraIntersectionPoints(rThisGeometry, rDistances, intersection_points);
462 if(number_of_intersection_points == 0) {
463 KRATOS_WARNING(
"GeometryUtilities") <<
"Warning: The intersection with interface hasn't found! The distances are" << rDistances << std::endl;
470 double distance_gradient_norm =
norm_2(distance_gradient);
471 if (distance_gradient_norm < 1
e-15) distance_gradient_norm = 1
e-15;
472 distance_gradient /= distance_gradient_norm;
474 const auto &ref_point = intersection_points[0].Coordinates();
475 for (
unsigned int i = 0;
i < TSize;
i++) {
477 const auto &i_coords = rThisGeometry[
i].Coordinates();
478 for (
unsigned int Dim = 0; Dim < TSize - 1; Dim++) {
479 d += (i_coords[Dim] - ref_point[Dim]) * distance_gradient[Dim];
482 rDistances[
i] =
std::min(std::abs(rDistances[
i]),
d);
494 template<std::
size_t TSize1, std::
size_t TSize2>
501 const double epsilon = 1
e-15;
503 int number_of_intersection_points = 0;
504 for(
unsigned int i = 0 ;
i < TSize1 ;
i++) {
505 if(std::abs(rDistances[
i]) < epsilon) {
506 noalias(rIntersectionPoints[number_of_intersection_points].Coordinates()) = rGeometry[
i].Coordinates();
508 number_of_intersection_points++;
511 for(
unsigned int j =
i + 1 ;
j < TSize1 ;
j++) {
512 if(std::abs(rDistances[
j]) < epsilon)
515 if(rDistances[
i] * rDistances[
j] < 0.00) {
516 const double delta_d = std::abs(rDistances[
i]) + std::abs(rDistances[
j]);
518 const double di = std::abs(rDistances[
i]) / delta_d;
519 const double dj = std::abs(rDistances[
j]) / delta_d;
521 noalias(rIntersectionPoints[number_of_intersection_points].Coordinates()) = dj * rGeometry[
i].Coordinates();
522 noalias(rIntersectionPoints[number_of_intersection_points].Coordinates()) += di * rGeometry[
j].Coordinates();
524 number_of_intersection_points++;
529 return number_of_intersection_points;
539 static double PointDistanceToLineSegment3D(
540 const Point& rLinePoint1,
541 const Point& rLinePoint2,
542 const Point& rToPoint
555 static double PointDistanceToTriangle3D(
556 const Point& rTrianglePoint1,
557 const Point& rTrianglePoint2,
558 const Point& rTrianglePoint3,
574 static double PointDistanceToTriangle3D(
575 const Point& rTrianglePoint1,
576 const Point& rTrianglePoint2,
577 const Point& rTrianglePoint3,
578 const Point& rTrianglePoint4,
579 const Point& rTrianglePoint5,
580 const Point& rTrianglePoint6,
594 static double PointDistanceToQuadrilateral3D(
595 const Point& rQuadrilateralPoint1,
596 const Point& rQuadrilateralPoint2,
597 const Point& rQuadrilateralPoint3,
598 const Point& rQuadrilateralPoint4,
608 template<
class TMatrix1,
class TMatrix2,
class TMatrix3>
610 TMatrix1
const& rDN_De,
611 TMatrix2
const& rInvJ,
615 if (rDN_DX.size1() != rDN_De.size1() || rDN_DX.size2() != rInvJ.size2())
616 rDN_DX.resize(rDN_De.size1(), rInvJ.size2(),
false);
628 template<
class TMatrix1,
class TMatrix2,
class TMatrix3>
631 TMatrix2
const& rInvJ0,
635 if (rF.size1() != rJ.size1() || rF.size2() != rInvJ0.size2())
636 rF.resize(rJ.size1(), rInvJ0.size2(),
false);
656 delta_position(
i,
j) = rGeom[
i].Coordinates()[
j] -
657 rGeom[
i].GetInitialPosition().Coordinates()[
j];
658 rGeom.
Jacobian(rJ0, rCoords, delta_position);
667 template<
class TMatrix>
678 Matrix shape_functions_gradients(points_number, local_space_dimension);
685 const double value = r_coordinates[
j];
687 rJ(
j,
m) += value * shape_functions_gradients(
i,
m);
700 template<
class TMatrix>
718 const double value = r_coordinates[
j];
720 rJ0(
j,
m) += value * rDN_De(
i,
m);
738 template <
class TDataType>
739 static void EvaluateHistoricalVariableValueAtGaussPoint(
743 const Vector& rGaussPointShapeFunctionValues,
758 static void EvaluateHistoricalVariableGradientAtGaussPoint(
762 const Matrix& rGaussPointShapeFunctionDerivativeValues,
781 static void EvaluateHistoricalVariableGradientAtGaussPoint(
785 const Matrix& rGaussPointShapeFunctionDerivativeValues,
792 static void ShapeFunctionsSecondDerivativesTransformOnAllIntegrationPoints(
804 static void ShapeFunctionsSecondDerivativesTransformOnIntegrationPoint(
818 static bool ProjectedIsInside(
822 const double Tolerance = std::numeric_limits<double>::epsilon()
834 template <
class TGeometryType>
836 const TGeometryType& rGeometry,
838 const double Tolerance = std::numeric_limits<double>::epsilon()
842 if (rGeometry.IsInside(rPointGlobalCoordinates, aux_coordinates, Tolerance)) {
847 std::vector<double> distances(rGeometry.FacesNumber());
849 for (
auto& r_face : rGeometry.GenerateFaces()) {
850 distances[
i] = r_face.CalculateDistance(rPointGlobalCoordinates, Tolerance);
853 const auto min = std::min_element(distances.begin(), distances.end());
KratosGeometryType
Definition: geometry_data.h:110
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
SizeType size() const
Definition: geometry.h:518
SizeType LocalSpaceDimension() const
Definition: geometry.h:1300
const ShapeFunctionsGradientsType & ShapeFunctionsLocalGradients() const
Definition: geometry.h:3539
JacobiansType & Jacobian(JacobiansType &rResult) const
Definition: geometry.h:2901
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
This function provides basic routines for working with simplicial meshes.
Definition: geometry_utilities.h:34
static TGeometryType::CoordinatesArrayType & PointLocalCoordinatesPlanarFaceTetrahedra(const TGeometryType &rGeometry, typename TGeometryType::CoordinatesArrayType &rResult, const typename TGeometryType::CoordinatesArrayType &rPoint)
Returns the local coordinates of a given arbitrary point for a given linear tetrahedra.
Definition: geometry_utilities.h:67
static void CalculateTriangleDistances(const GeometryType &rGeometry, array_1d< double, TSize > &rDistances)
Calculate the exact distances to the interface SEGMENT defined by a set of initial distances.
Definition: geometry_utilities.h:419
static void CalculateExactDistancesToPlane(const GeometryType &rThisGeometry, array_1d< double, TSize > &rDistances)
Calculate the exact distances to the plane interface defined by a set of initial distances.
Definition: geometry_utilities.h:454
static void SideLenghts2D(const GeometryType &rGeometry, double &hmin, double &hmax)
This function compute the maximum and minimum edge lenghts.
Definition: geometry_utilities.h:311
std::size_t SizeType
The size type definition.
Definition: geometry_utilities.h:40
std::size_t IndexType
The index type definition.
Definition: geometry_utilities.h:43
static void CalculateGeometryData(const GeometryType &rGeometry, BoundedMatrix< double, 2, 1 > &rDN_DX, array_1d< double, 2 > &rN, double &rLength)
This function is designed to compute the shape function derivatives, shape functions and length.
Definition: geometry_utilities.h:345
static void DeformationGradient(TMatrix1 const &rJ, TMatrix2 const &rInvJ0, TMatrix3 &rF)
Calculate the deformation gradient.
Definition: geometry_utilities.h:629
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 ShapeFunctionsGradients(TMatrix1 const &rDN_De, TMatrix2 const &rInvJ, TMatrix3 &rDN_DX)
Calculate the gradients of shape functions.
Definition: geometry_utilities.h:609
static int CalculateTetrahedraIntersectionPoints(const GeometryType &rGeometry, array_1d< double, TSize1 > &rDistances, array_1d< Point, TSize2 > &rIntersectionPoints)
This function calculates the coordinates of the intersecion points between edges of tetrahedra and a ...
Definition: geometry_utilities.h:495
static void JacobianOnInitialConfiguration(GeometryType const &rGeom, GeometryType::CoordinatesArrayType const &rCoords, Matrix &rJ0)
Calculate the Jacobian on the initial configuration.
Definition: geometry_utilities.h:647
static void CalculateGeometryData(const GeometryType &rGeometry, BoundedMatrix< double, 3, 2 > &DN_DX, array_1d< double, 3 > &N, double &rArea)
This function is designed to compute the shape function derivatives, shape functions and area of a tr...
Definition: geometry_utilities.h:251
static double CalculateDistanceFrom3DGeometry(const TGeometryType &rGeometry, const typename TGeometryType::CoordinatesArrayType &rPointGlobalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon())
Computes the distance between an point in global coordinates and the closest point of this geometry.
Definition: geometry_utilities.h:835
static void DirectJacobianOnInitialConfiguration(GeometryType const &rGeometry, TMatrix &rJ0, const IndexType PointNumber, const GeometryType::IntegrationMethod &rIntegrationMethod)
Calculate the Jacobian on the initial configuration.
Definition: geometry_utilities.h:701
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
static void DirectJacobianOnCurrentConfiguration(GeometryType const &rGeometry, GeometryType::CoordinatesArrayType const &rCoords, TMatrix &rJ)
Calculate the Jacobian on the initial configuration.
Definition: geometry_utilities.h:668
Definition: amatrix_interface.h:41
void clear()
Definition: amatrix_interface.h:284
Point class.
Definition: point.h:59
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_DEBUG_ERROR_IF_NOT(conditional)
Definition: exception.h:172
#define KRATOS_WARNING(label)
Definition: logger.h:265
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
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
namespace KRATOS_DEPRECATED_MESSAGE("Please use std::filesystem directly") filesystem
Definition: kratos_filesystem.h:33
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
tuple const
Definition: ode_solve.py:403
int d
Definition: ode_solve.py:397
int j
Definition: quadrature.py:648
float temp
Definition: rotating_cone.py:85
int m
Definition: run_marine_rain_substepping.py:8
N
Definition: sensitivityMatrix.py:29
volume
Definition: sp_statistics.py:15
integer i
Definition: TensorModule.f:17
subroutine d1(DSTRAN, D, dtime, NDI, NSHR, NTENS)
Definition: TensorModule.f:594
integer l
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31