14 #if !defined(KRATOS_PROJECTION_NURBS_GEOMETRY_UTILITIES_H_INCLUDED)
15 #define KRATOS_PROJECTION_NURBS_GEOMETRY_UTILITIES_H_INCLUDED
27 template<
int TDimension,
class TPo
intType>
class NurbsSurfaceGeometry;
50 template <
class TPo
intType>
56 const int MaxIterations = 20,
57 const double Accuracy = 1
e-6)
62 std::vector<array_1d<double, 3>> derivatives(3);
65 bool projection_reset_to_boundary =
false;
68 for (
int i = 0;
i < MaxIterations; ++
i)
73 rProjectedPointLocalCoordinates,
75 rProjectedPointGlobalCoordinates = derivatives[0];
79 distance_vector = rProjectedPointGlobalCoordinates - rPointGlobalCoordinatesCoordinates;
80 if (
norm_2(distance_vector) < Accuracy)
92 rProjectedPointLocalCoordinates[0] -=
delta_t;
101 rProjectedPointLocalCoordinates, rProjectedPointLocalCoordinates);
103 if (projection_reset_to_boundary) {
return false; }
104 else { projection_reset_to_boundary =
true; }
128 template <
int TDimension,
class TPo
intType>
134 const int MaxIterations = 20,
135 const double Accuracy = 1
e-6)
138 bool is_first_row_zero, is_second_row_zero, is_first_column_zero, is_second_column_zero, is_system_invertible;
141 double xi_cos, eta_cos, residual_u, residual_v, j_00, j_01, j_11, det_j;
144 for (
int i = 0;
i < MaxIterations;
i++) {
147 std::vector<array_1d<double, 3>> s;
149 rProjectedPointGlobalCoordinates = s[0];
155 const double distance =
norm_2(distance_vector);
156 if (distance < Accuracy)
160 residual_u = -
inner_prod(s[1], distance_vector);
161 residual_v = -
inner_prod(s[2], distance_vector);
164 xi_cos = std::abs(residual_u) /
norm_2(s[1]) /
norm_2(distance_vector);
167 eta_cos = std::abs(residual_v) /
norm_2(s[2]) /
norm_2(distance_vector);
170 if (xi_cos < Accuracy && eta_cos < Accuracy)
179 is_first_row_zero =
false;
180 if ((std::abs(j_00) < Accuracy && std::abs(j_01) < Accuracy)) {
181 is_first_row_zero =
true;
183 is_second_row_zero =
false;
184 if (std::abs(j_01) < Accuracy && fabs(j_11) < Accuracy) {
185 is_second_row_zero =
true;
187 is_first_column_zero =
false;
188 if ((std::abs(j_00) < Accuracy && std::abs(j_01) < Accuracy)) {
189 is_first_column_zero =
true;
191 is_second_column_zero =
false;
192 if ((std::abs(j_01) < Accuracy && std::abs(j_11) < Accuracy)) {
193 is_second_column_zero =
true;
197 is_system_invertible =
true;
198 if (is_first_row_zero || is_second_row_zero || is_first_column_zero || is_second_column_zero) {
199 is_system_invertible =
false;
203 if (is_system_invertible) {
204 det_j = j_00 * j_11 - j_01 * j_01;
205 d_u = -(residual_v * j_01 - residual_u * j_11) / det_j;
206 d_v = -(residual_u * j_01 - residual_v * j_00) / det_j;
209 if (is_first_row_zero) {
210 d_u = residual_v / j_11;
213 else if (is_second_row_zero) {
214 d_u = residual_u / j_00;
217 else if (is_first_column_zero) {
218 d_v = (residual_u + residual_v) / (j_01 + j_11);
221 else if (is_second_column_zero) {
222 d_u = (residual_u + residual_v) / (j_00 + j_01);
228 if (
norm_2(d_u * s[1] + d_v * s[2]) < Accuracy)
232 rProjectedPointLocalCoordinates[0] += d_u;
233 rProjectedPointLocalCoordinates[1] += d_v;
Geometry base class.
Definition: geometry.h:71
virtual int ClosestPointLocalToLocalSpace(const CoordinatesArrayType &rPointLocalCoordinates, CoordinatesArrayType &rClosestPointLocalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon()) const
Calculates the closes point projection This method calculates the closest point projection of a point...
Definition: geometry.h:2792
virtual void GlobalSpaceDerivatives(std::vector< CoordinatesArrayType > &rGlobalSpaceDerivatives, const CoordinatesArrayType &rLocalCoordinates, const SizeType DerivativeOrder) const
This method maps from dimension space to working space and computes the number of derivatives at the ...
Definition: geometry.h:2473
bool IsInside(double &ParameterT) const
Definition: nurbs_interval.h:143
Definition: nurbs_surface_geometry.h:38
void GlobalSpaceDerivatives(std::vector< CoordinatesArrayType > &rGlobalSpaceDerivatives, const CoordinatesArrayType &rLocalCoordinates, const SizeType DerivativeOrder) const override
Definition: nurbs_surface_geometry.h:742
NurbsInterval DomainIntervalU() const
Definition: nurbs_surface_geometry.h:407
NurbsInterval DomainIntervalV() const
Definition: nurbs_surface_geometry.h:417
Definition: projection_nurbs_geometry_utilities.h:29
array_1d< double, 3 > CoordinatesArrayType
Definition: projection_nurbs_geometry_utilities.h:32
static bool NewtonRaphsonSurface(CoordinatesArrayType &rProjectedPointLocalCoordinates, const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rProjectedPointGlobalCoordinates, const NurbsSurfaceGeometry< TDimension, TPointType > &rNurbsSurface, const int MaxIterations=20, const double Accuracy=1e-6)
Definition: projection_nurbs_geometry_utilities.h:129
static bool NewtonRaphsonCurve(CoordinatesArrayType &rProjectedPointLocalCoordinates, const CoordinatesArrayType &rPointGlobalCoordinatesCoordinates, CoordinatesArrayType &rProjectedPointGlobalCoordinates, const Geometry< TPointType > &rGeometry, const int MaxIterations=20, const double Accuracy=1e-6)
Definition: projection_nurbs_geometry_utilities.h:51
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
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
residual
Definition: hinsberg_optimization_4.py:433
float delta_t
Definition: rotatingcone_PureConvectionBenchmarking.py:129
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31