15 #if !defined(KRATOS_ENRICHMENT_2D_UTILITIES_INCLUDED )
16 #define KRATOS_ENRICHMENT_2D_UTILITIES_INCLUDED
85 template<
class TMatrixType,
class TVectorType,
class TGradientType>
87 TVectorType rDistances, TVectorType& rVolumes, TMatrixType& rGPShapeFunctionValues,
88 TVectorType& rPartitionsSign, std::vector<TMatrixType>& rGradientsValue, TMatrixType& NEnriched,
89 TVectorType& face_gauss_N, TVectorType& face_gauss_Nenriched,
double& face_Area, TVectorType& face_n ,
unsigned int& type_of_cut)
94 unsigned int i_aux,j_aux,k_aux;
96 const double one_third=1.0/3.0;
99 rGPShapeFunctionValues(0,0)=one_third; rGPShapeFunctionValues(0,1)=one_third; rGPShapeFunctionValues(0,2)=one_third;
100 Area = CalculateVolume2D( rPoints );
104 if( (rDistances(0)*rDistances(1))>0.0 && (rDistances(0)*rDistances(2))>0.0 )
107 rGPShapeFunctionValues(0,0)=one_third; rGPShapeFunctionValues(0,1)=one_third; rGPShapeFunctionValues(0,2)=one_third;
108 NEnriched(0,0) = 0.0;
110 for (
int j = 0;
j < 3;
j++)
111 rGradientsValue[0](0,
j) = 0.0;
112 if (rDistances(0) < 0.0) rPartitionsSign[0] = -1;
113 else rPartitionsSign[0] = 1.0;
121 if ((rDistances(0)*rDistances(1))<0.0)
123 if ((rDistances(0)*rDistances(2))<0.0)
165 if (rDistances(i_aux) < 0.0)
167 rPartitionsSign[0] = -1.0;
168 rPartitionsSign[1] = 1.0;
169 rPartitionsSign[2] = 1.0;
173 rPartitionsSign[0] = 1.0;
174 rPartitionsSign[1] = -1.0;
175 rPartitionsSign[2] = -1.0;
181 const double unsigned_distance0=fabs(rDistances(0));
182 const double unsigned_distance1=fabs(rDistances(1));
183 const double unsigned_distance2=fabs(rDistances(2));
185 double longest_distance=fabs(unsigned_distance0);
186 if (unsigned_distance1>longest_distance)
187 longest_distance=unsigned_distance1;
188 if (unsigned_distance2>longest_distance)
189 longest_distance=unsigned_distance2;
191 const double tolerable_distance =longest_distance*0.000001;
194 if (unsigned_distance0<tolerable_distance)
195 rDistances[0]=tolerable_distance*(rDistances[0]/fabs(rDistances[0]));
196 if (unsigned_distance1<tolerable_distance)
197 rDistances[1]=tolerable_distance*(rDistances[1]/fabs(rDistances[1]));
198 if (unsigned_distance2<tolerable_distance)
199 rDistances[2]=tolerable_distance*(rDistances[2]/fabs(rDistances[2]));
207 const double node4_relative_position=fabs(rDistances(j_aux)/(rDistances(i_aux)-rDistances(j_aux) ) ) ;
208 const double node5_relative_position=fabs(rDistances(k_aux)/(rDistances(i_aux)-rDistances(k_aux) ) ) ;
213 const double Ni_aux_node4 = node4_relative_position;
214 const double Nj_aux_node4 = (1.0-node4_relative_position);
216 const double Ni_aux_node5 = node5_relative_position;
218 const double Nk_aux_node5 = (1.0-node5_relative_position);
221 const double x_midpoint=((rPoints(i_aux,0)*Ni_aux_node4+rPoints(j_aux,0)*Nj_aux_node4)+
222 (rPoints(i_aux,0)*Ni_aux_node5+rPoints(k_aux,0)*Nk_aux_node5))*0.5;
223 const double y_midpoint=((rPoints(i_aux,1)*Ni_aux_node4+rPoints(j_aux,1)*Nj_aux_node4)+
224 (rPoints(i_aux,1)*Ni_aux_node5+rPoints(k_aux,1)*Nk_aux_node5))*0.5;
225 const double z_midpoint=0.0;
228 coord_subdomain = rPoints;
230 bool is_found = CalculatePosition ( coord_subdomain , x_midpoint,y_midpoint,z_midpoint,
N);
234 const double adim_Nenriched_i_aux = 1.0 /(face_gauss_N(i_aux));
236 const double adim_Nenriched_j_aux = adim_Nenriched_i_aux * Ni_aux_node4 / Nj_aux_node4 ;
237 const double adim_Nenriched_k_aux = adim_Nenriched_i_aux * Ni_aux_node5 / Nk_aux_node5 ;
240 const double adim_Nenriched_j_aux_b = (2.0 - node4_relative_position * adim_Nenriched_i_aux) / Nj_aux_node4;
241 const double adim_Nenriched_k_aux_b = (2.0 - node5_relative_position * adim_Nenriched_i_aux) / Nk_aux_node5;
245 face_gauss_Nenriched(i_aux)= 1.0;
246 face_gauss_Nenriched(j_aux)= 0.0;
249 rGradientsValue[0](0,0)=DN_DX(j_aux,0)*adim_Nenriched_j_aux+DN_DX(k_aux,0)*adim_Nenriched_k_aux;
250 rGradientsValue[0](0,1)=DN_DX(j_aux,1)*adim_Nenriched_j_aux+DN_DX(k_aux,1)*adim_Nenriched_k_aux;
252 rGradientsValue[0](1,0)=DN_DX(j_aux,0)*adim_Nenriched_j_aux_b+DN_DX(k_aux,0)*adim_Nenriched_k_aux_b;
253 rGradientsValue[0](1,1)=DN_DX(j_aux,1)*adim_Nenriched_j_aux_b+DN_DX(k_aux,1)*adim_Nenriched_k_aux_b;
255 coord_subdomain(0,0)=rPoints(i_aux,0);
256 coord_subdomain(0,1)=rPoints(i_aux,1);
257 coord_subdomain(1,0)=rPoints(i_aux,0)*Ni_aux_node4+rPoints(j_aux,0)*Nj_aux_node4;
258 coord_subdomain(1,1)=rPoints(i_aux,1)*Ni_aux_node4+rPoints(j_aux,1)*Nj_aux_node4;
259 coord_subdomain(2,0)=rPoints(i_aux,0)*Ni_aux_node5+rPoints(k_aux,0)*Nk_aux_node5;
260 coord_subdomain(2,1)=rPoints(i_aux,1)*Ni_aux_node5+rPoints(k_aux,1)*Nk_aux_node5;
261 rVolumes(0)=CalculateVolume2D(coord_subdomain);
263 double x_GP_partition = one_third * ( coord_subdomain(0,0) + coord_subdomain(1,0) + coord_subdomain(2,0) );
264 double y_GP_partition = one_third * ( coord_subdomain(0,1) + coord_subdomain(1,1) + coord_subdomain(2,1) );
265 double z_GP_partition = 0.0;
267 coord_subdomain = rPoints;
269 is_found = CalculatePosition ( coord_subdomain , x_GP_partition ,y_GP_partition ,z_GP_partition ,
N);
270 rGPShapeFunctionValues(0,0)=
N(0);
271 rGPShapeFunctionValues(0,1)=
N(1);
272 rGPShapeFunctionValues(0,2)=
N(2);
273 NEnriched(0,0)=rGPShapeFunctionValues(0,j_aux)*adim_Nenriched_j_aux+rGPShapeFunctionValues(0,k_aux)*adim_Nenriched_k_aux;
274 NEnriched(0,1)=NEnriched(0,0);
278 face_Area=sqrt(pow((coord_subdomain(2,0)-coord_subdomain(1,0)),2)+pow((coord_subdomain(2,1)-coord_subdomain(1,1)),2));
280 face_n(0)=(coord_subdomain(2,1)-coord_subdomain(1,1))/face_Area;
281 face_n(1)=-(coord_subdomain(2,0)-coord_subdomain(1,0))/face_Area;
298 rGradientsValue[1](0,0)=DN_DX(i_aux,0)*adim_Nenriched_i_aux;
299 rGradientsValue[1](0,1)=DN_DX(i_aux,1)*adim_Nenriched_i_aux;
302 rGradientsValue[1](1,0)= -rGradientsValue[1](0,0);
303 rGradientsValue[1](1,1)= -rGradientsValue[1](0,1);
308 coord_subdomain(0,0) = rPoints(j_aux,0);
309 coord_subdomain(0,1) = rPoints(j_aux,1);
310 coord_subdomain(1,0) = rPoints(k_aux,0);
311 coord_subdomain(1,1) = rPoints(k_aux,1);
312 coord_subdomain(2,0) = rPoints(i_aux,0)*Ni_aux_node5+rPoints(k_aux,0)*Nk_aux_node5;
313 coord_subdomain(2,1) = rPoints(i_aux,1)*Ni_aux_node5+rPoints(k_aux,1)*Nk_aux_node5;
314 rVolumes(1)=CalculateVolume2D(coord_subdomain);
316 x_GP_partition = one_third * ( coord_subdomain(0,0) + coord_subdomain(1,0) + coord_subdomain(2,0) );
317 y_GP_partition = one_third * ( coord_subdomain(0,1) + coord_subdomain(1,1) + coord_subdomain(2,1) );
318 z_GP_partition = 0.0;
320 coord_subdomain = rPoints;
322 is_found = CalculatePosition ( coord_subdomain , x_GP_partition ,y_GP_partition ,z_GP_partition ,
N);
323 rGPShapeFunctionValues(1,0)=
N(0);
324 rGPShapeFunctionValues(1,1)=
N(1);
325 rGPShapeFunctionValues(1,2)=
N(2);
326 NEnriched(1,0) = rGPShapeFunctionValues(1,i_aux)*adim_Nenriched_i_aux;
327 NEnriched(1,1) = -NEnriched(1,0);
345 coord_subdomain(2,0) = rPoints(i_aux,0)*Ni_aux_node4+rPoints(j_aux,0)*Nj_aux_node4;
346 coord_subdomain(2,1) = rPoints(i_aux,1)*Ni_aux_node4+rPoints(j_aux,1)*Nj_aux_node4;
347 rVolumes(3)=CalculateVolume2D(coord_subdomain);
350 rGradientsValue[2](0,0)=DN_DX(i_aux,0)*adim_Nenriched_i_aux;
351 rGradientsValue[2](0,1)=DN_DX(i_aux,1)*adim_Nenriched_i_aux;
353 rGradientsValue[2](1,0)= -rGradientsValue[2](0,0);
354 rGradientsValue[2](1,1)= -rGradientsValue[2](0,1);
358 coord_subdomain(0,0) = rPoints(j_aux,0);
359 coord_subdomain(0,1) = rPoints(j_aux,1);
360 coord_subdomain(1,0)=rPoints(i_aux,0)*Ni_aux_node5+rPoints(k_aux,0)*Nk_aux_node5;
361 coord_subdomain(1,1)=rPoints(i_aux,1)*Ni_aux_node5+rPoints(k_aux,1)*Nk_aux_node5;
362 coord_subdomain(2,0)=rPoints(i_aux,0)*Ni_aux_node4+rPoints(j_aux,0)*Nj_aux_node4;
363 coord_subdomain(2,1)=rPoints(i_aux,1)*Ni_aux_node4+rPoints(j_aux,1)*Nj_aux_node4;
364 rVolumes(2)=Area-rVolumes(0)-rVolumes(1);
365 x_GP_partition = one_third * ( coord_subdomain(0,0) + coord_subdomain(1,0) + coord_subdomain(2,0) );
366 y_GP_partition = one_third * ( coord_subdomain(0,1) + coord_subdomain(1,1) + coord_subdomain(2,1) );
367 z_GP_partition = 0.0;
368 coord_subdomain = rPoints;
369 is_found = CalculatePosition ( coord_subdomain , x_GP_partition ,y_GP_partition ,z_GP_partition ,
N);
370 rGPShapeFunctionValues(2,0)=
N(0);
371 rGPShapeFunctionValues(2,1)=
N(1);
372 rGPShapeFunctionValues(2,2)=
N(2);
373 NEnriched(2,0)= rGPShapeFunctionValues(2,i_aux)*adim_Nenriched_i_aux;
374 NEnriched(2,1)= -NEnriched(2,0);
419 static inline void CalculateGeometryData(
425 double x10 = coordinates(1,0) - coordinates(0,0);
426 double y10 = coordinates(1,1) - coordinates(0,1);
428 double x20 = coordinates(2,0) - coordinates(0,0);
429 double y20 = coordinates(2,1) - coordinates (0,1);
437 double detJ = x10 * y20-y10 * x20;
439 DN_DX(0,0) = -y20 + y10;
440 DN_DX(0,1) = x20 - x10;
447 N[0] = 0.333333333333333;
448 N[1] = 0.333333333333333;
449 N[2] = 0.333333333333333;
455 static inline double CalculateVolume2D(
456 const BoundedMatrix<double, 3, 3 > & coordinates)
458 double x10 = coordinates(1,0) - coordinates(0,0);
459 double y10 = coordinates(1,1) - coordinates(0,1);
461 double x20 = coordinates(2,0) - coordinates(0,0);
462 double y20 = coordinates(2,1) - coordinates (0,1);
463 double detJ = x10 * y20-y10 * x20;
467 static inline bool CalculatePosition(
const BoundedMatrix<double, 3, 3 > & coordinates,
468 const double xc,
const double yc,
const double zc,
469 array_1d<double, 3 > &
N
472 double x0 = coordinates(0,0);
473 double y0 = coordinates(0,1);
474 double x1 = coordinates(1,0);
475 double y1 = coordinates(1,1);
476 double x2 = coordinates(2,0);
477 double y2 = coordinates(2,1);
479 double area = CalculateVol(x0, y0,
x1, y1,
x2, y2);
480 double inv_area = 0.0;
486 inv_area = 1.0 / area;
490 N[0] = CalculateVol(
x1, y1,
x2, y2,
xc,
yc) * inv_area;
491 N[1] = CalculateVol(
x2, y2, x0, y0,
xc,
yc) * inv_area;
492 N[2] = CalculateVol(x0, y0,
x1, y1,
xc,
yc) * inv_area;
495 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0)
501 static inline double CalculateVol(
const double x0,
const double y0,
502 const double x1,
const double y1,
503 const double x2,
const double y2
506 return 0.5 * ((
x1 - x0)*(y2 - y0)- (y1 - y0)*(
x2 - x0));
This utility can be used to calculate the enriched shape function for tetrahedra element.
Definition: enrich_2d_2dofs.h:41
static int CalculateTriangleEnrichedShapeFuncions(TMatrixType const &rPoints, TGradientType const &DN_DX, TVectorType rDistances, TVectorType &rVolumes, TMatrixType &rGPShapeFunctionValues, TVectorType &rPartitionsSign, std::vector< TMatrixType > &rGradientsValue, TMatrixType &NEnriched, TVectorType &face_gauss_N, TVectorType &face_gauss_Nenriched, double &face_Area, TVectorType &face_n, unsigned int &type_of_cut)
Definition: enrich_2d_2dofs.h:86
Definition: amatrix_interface.h:41
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
int j
Definition: quadrature.py:648
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
N
Definition: sensitivityMatrix.py:29