10 #if !defined(KRATOS_SOLID_MECHANICS_MATH_UTILITIES_H_INCLUDED)
11 #define KRATOS_SOLID_MECHANICS_MATH_UTILITIES_H_INCLUDED
18 #define FIND_MAX(a, b) ((a)>(b)?(a):(b))
33 template<
class TDataType>
34 class SolidMechanicsMathUtilities
83 std::cout<<
"This is not a cubic equation: CardanoFormula"<<std::endl;
88 double p= (3.0*
a*
c-
b*
b)/(3.0*
a*
a);
92 double discriminante=
p*
p*
p/27.0+
q*
q/4.0;
111 if(
p < 0)
return false;
114 -sqrt(-4.0/3.0*
p)*cos(1.0/3.0*acos(-
q/2.0*sqrt(-27.0/(
p*
p*
p)))+
Globals::Pi / 3.0)
117 sqrt(-4.0/3.0*
p)*cos(1.0/3.0*acos(-
q/2.0*sqrt(-27.0/(
p*
p*
p))))-
b/(3*
a)
120 -sqrt(-4.0/3.0*
p)*cos(1.0/3.0*acos(-
q/2.0*sqrt(-27.0/(
p*
p*
p)))-
Globals::Pi / 3.0)
168 bool is_converged=
false;
169 unsigned int max_iters = 10;
170 unsigned int iter = 0;
172 while(is_converged ==
false && iter<max_iters )
174 double shift= HelpA((
dim-1),(
dim-1));
178 HelpA(
i,
i) = HelpA(
i,
i)- shift;
192 HelpA(
i,
j) += HelpR(
i,
k)*HelpQ(
k,
j);
203 Convergence(0,
i)=Convergence(1,
i);
204 Convergence(1,
i)=HelpA(
i,
i);
205 delta+= (Convergence(1,
i)-Convergence(0,
i))*(Convergence(1,
i)-Convergence(0,
i));
206 abs+=(Convergence(1,
i))*(Convergence(1,
i));
225 Result(
i)= HelpA(
i,
i);
227 if(fabs(Result(
i)) <
zero)
251 const double p1 =
A(0,1)*
A(0,1) +
A(0,2)*
A(0,2) +
A(1,2)*
A(1,2);
260 const double q = (
A(0,0) +
A(1,1) +
A(2,2)) / 3.0;
261 const double p2 = (
A(0,0) -
q) * (
A(0,0) -
q) + (
A(1,1) -
q) * (
A(1,1) -
q) + (
A(2,2) -
q) * (
A(2,2) -
q) + 2.0 * p1;
262 const double p = sqrt(p2 / 6.0);
265 const double inv_p = 1.0/
p;
268 B(0,0) = inv_p * (
A(0,0) -
q);
269 B(1,1) = inv_p * (
A(1,1) -
q);
270 B(2,2) = inv_p * (
A(2,2) -
q);
271 B(0,1) = inv_p *
A(0,1);
272 B(1,0) = inv_p *
A(1,0);
273 B(0,2) = inv_p *
A(0,2);
274 B(2,0) = inv_p *
A(2,0);
275 B(1,2) = inv_p *
A(1,2);
276 B(2,1) = inv_p *
A(2,1);
279 double r = 0.5 * (
B(0,0)*
B(1,1)*
B(2,2) +
B(0,1)*
B(1,2)*
B(2,0) +
B(1,0)*
B(2,1)*
B(0,2) -
B(2,0)*
B(1,1)*
B(0,2) -
B(1,0)*
B(0,1)*
B(2,2) -
B(0,0)*
B(2,1)*
B(1,2) );
285 else if (r >= 1) {
phi = 0.0; }
286 else {
phi = acos(r) / 3.0;}
289 Result[0] =
q + 2.0 *
p * cos(
phi);
291 Result[1] = 3.0 *
q - Result[0] - Result[2];
335 std::vector<Matrix> HelpQ(
dim-1);
337 std::vector<Matrix> HelpR(
dim-1);
339 for(
int i=0;
i<
dim-1;
i++)
341 HelpQ[
i].resize(
dim,
dim,
false);
342 HelpR[
i].resize(
dim,
dim,
false);
362 double l= sqrt((normy*(normy+fabs(
y(
iteration))))/2);
396 for(
int k=0;
k<
dim-1;
k++)
405 for(
int k=1;
k<
dim-1;
k++)
410 Q(
i,
j)+= HelpQ[(
k-1)](
i,
l)*HelpQ[
k](
l,
j);
436 double zero_tolerance =1
e-9,
441 for(
int i=0;
i<3;
i++)
442 for(
int j=0;
j<3;
j++)
443 Help(
i,
j)= Help(
i,
j);
446 vectors.
resize(Help.size1(),Help.size2(),
false);
448 lambda.
resize(Help.size1(),
false);
450 Matrix HelpDummy(Help.size1(),Help.size2());
452 bool is_converged =
false;
454 Matrix unity(Help.size1(),Help.size2());
457 for(
unsigned int i=0;
i< Help.size1();
i++)
462 Matrix VDummy(Help.size1(),Help.size2());
464 Matrix Rotation(Help.size1(),Help.size2());
474 unsigned int index1= 0;
476 unsigned int index2= 1;
478 for(
unsigned int i=0;
i< Help.size1();
i++)
480 for(
unsigned int j=(
i+1);
j< Help.size2();
j++)
482 if((fabs(Help(
i,
j)) >
a ) && (fabs(Help(
i,
j)) > zero_tolerance))
501 double gamma= (Help(index2,index2)-Help(index1,index1))/(2*Help(index1,index2));
505 if(fabs(
gamma) > zero_tolerance && fabs(
gamma)< (1/zero_tolerance))
511 if (fabs(
gamma)>= (1.0/zero_tolerance))
515 double c= 1.0/(sqrt(1.0+
u*
u));
519 double teta= s/(1.0+
c);
524 HelpDummy(index2,index2)= Help(index2,index2)+
u*Help(index1,index2);
525 HelpDummy(index1,index1)= Help(index1,index1)-
u*Help(index1,index2);
526 HelpDummy(index1,index2)= 0.0;
527 HelpDummy(index2,index1)= 0.0;
529 for(
unsigned int i=0;
i<Help.size1();
i++)
531 if((
i!= index1) && (
i!= index2))
533 HelpDummy(index2,
i)=Help(index2,
i)+s*(Help(index1,
i)- teta*Help(index2,
i));
534 HelpDummy(
i,index2)=Help(index2,
i)+s*(Help(index1,
i)- teta*Help(index2,
i));
536 HelpDummy(index1,
i)=Help(index1,
i)-s*(Help(index2,
i)+ teta*Help(index1,
i));
537 HelpDummy(
i,index1)=Help(index1,
i)-s*(Help(index2,
i)+ teta*Help(index1,
i));
546 Rotation(index2,index1)=-s;
547 Rotation(index1,index2)=s;
548 Rotation(index1,index1)=
c;
549 Rotation(index2,index2)=
c;
556 for(
unsigned int i=0;
i< Help.size1();
i++)
558 for(
unsigned int j=0;
j< Help.size1();
j++)
560 for(
unsigned int k=0;
k< Help.size1();
k++)
562 VDummy(
i,
j) +=
V(
i,
k)*Rotation(
k,
j);
596 std::cout<<
"########################################################"<<std::endl;
597 std::cout<<
"Max_Iterations exceed in Jacobi-Seidel-Iteration (eigenvectors)"<<std::endl;
598 std::cout<<
"########################################################"<<std::endl;
601 for(
unsigned int i=0;
i< Help.size1();
i++)
603 for(
unsigned int j=0;
j< Help.size1();
j++)
605 vectors(
i,
j)=
V(
j,
i);
609 for(
unsigned int i=0;
i<Help.size1();
i++)
610 lambda(
i)= Help(
i,
i);
629 if(
A.size1()!=3 ||
A.size2()!=3)
630 std::cout<<
" GIVEN MATRIX IS NOT 3x3 eigenvectors calculation "<<std::endl;
636 for (
int i = 0;
i < 3;
i++) {
637 for (
int j = 0;
j < 3;
j++) {
645 for (
int j = 0;
j < 3;
j++) {
651 for (
int i = 2;
i > 0;
i--) {
657 for (
int k = 0;
k <
i;
k++) {
658 scale = scale + fabs(
d[
k]);
662 for (
int j = 0;
j <
i;
j++) {
671 for (
int k = 0;
k <
i;
k++) {
683 for (
int j = 0;
j <
i;
j++) {
689 for (
int j = 0;
j <
i;
j++) {
693 for (
int k =
j+1;
k <=
i-1;
k++) {
700 for (
int j = 0;
j <
i;
j++) {
704 double hh =
f / (
h +
h);
705 for (
int j = 0;
j <
i;
j++) {
708 for (
int j = 0;
j <
i;
j++) {
711 for (
int k =
j;
k <=
i-1;
k++) {
723 for (
int i = 0;
i < 2;
i++) {
728 for (
int k = 0;
k <=
i;
k++) {
731 for (
int j = 0;
j <=
i;
j++) {
733 for (
int k = 0;
k <=
i;
k++) {
736 for (
int k = 0;
k <=
i;
k++) {
741 for (
int k = 0;
k <=
i;
k++) {
745 for (
int j = 0;
j < 3;
j++) {
756 for (
int i = 1;
i < 3;
i++) {
763 double eps = std::pow(2.0,-52.0);
764 for (
int l = 0;
l < 3;
l++) {
771 if (fabs(
e[
m]) <= eps*tst1) {
788 double p = (
d[
l+1] - g) / (2.0 *
e[
l]);
793 d[
l] =
e[
l] / (
p + r);
794 d[
l+1] =
e[
l] * (
p + r);
797 for (
int i =
l+2;
i < 3;
i++) {
811 for (
int i =
m-1;
i >=
l;
i--) {
821 p =
c *
d[
i] - s * g;
822 d[
i+1] =
h + s * (
c * g + s *
d[
i]);
826 for (
int k = 0;
k < 3;
k++) {
832 p = -s * s2 * c3 * el1 *
e[
l] / dl1;
838 }
while (fabs(
e[
l]) > eps*tst1);
846 for (
int i = 0;
i < 2;
i++) {
849 for (
int j =
i+1;
j < 3;
j++) {
858 for (
int j = 0;
j < 3;
j++) {
875 return std::sqrt(
x*
x+
y*
y);
893 TDataType& error_tolerance,
894 TDataType zero_tolerance)
897 TDataType
error = 1.0;
905 while(
error > error_tolerance )
907 for(
int i=0;
i<
n;
i++ )
909 for(
int j=
i+1;
j<
n;
j++ )
912 if( std::abs(
A(
i,
j) ) >= zero_tolerance )
914 if( std::abs(
A(
i,
i)-
A(
j,
j) ) > 0.0 )
916 theta = 0.5*atan(2*
A(
i,
j)/(
A(
i,
i)-
A(
j,
j)));
924 T(
i,
j) = -sin(theta);
936 for(
unsigned int i=0;
i<
A.size1();
i++ )
938 for(
unsigned int j=0;
j<
A.size2();
j++ )
940 sTot += std::abs(
A(
i,
j));
942 sDiag+= std::abs(
A(
i,
i));
944 error=(sTot-sDiag)/sDiag;
948 TDataType maxEv =
A(0,0);
949 for(
unsigned int i=0;
i<
A.size1();
i++ )
951 for(
unsigned int j=
i;
j<
A.size1();
j++ )
961 A(
i,
i) =
A(maxIndex,maxIndex);
962 A(maxIndex,maxIndex) =
dummy;
964 for(
unsigned int k=0;
k<
A.size2();
k++ )
967 V(
k,
i) =
V(
k,maxIndex);
984 for(
unsigned int i=0;
i<size ;
i++ )
999 for(
unsigned int i=0;
i<
A.size1();
i++ )
1001 for(
unsigned int j=0;
j<
A.size2();
j++ )
1018 for(
unsigned int i=0;
i<
A.size1();
i++ )
1020 for(
unsigned int j=0;
j<
B.size2();
j++ )
1022 for(
unsigned int k=0;
k<
A.size2();
k++ )
1036 for(
unsigned int i=0;
i<M.size1();
i++ )
1038 for(
unsigned int j=0;
j<M.size2();
j++ )
1050 for(
unsigned int i=0;
i<
v.size();
i++ )
1065 for(
unsigned int i=0;
i<
A.size1();
i++ )
1067 for(
unsigned int j=0;
j<
A.size2();
j++ )
1099 if (Strains.size()==3)
1101 StrainTensor.
resize(2,2,
false);
1103 StrainTensor(0,0) = Strains[0];
1104 StrainTensor(0,1) = 0.5*Strains[2];
1105 StrainTensor(1,0) = 0.5*Strains[2];
1106 StrainTensor(1,1) = Strains[1];
1108 else if (Strains.size()==6)
1110 StrainTensor.
resize(3,3,
false);
1111 StrainTensor(0,0) = Strains[0];
1112 StrainTensor(0,1) = 0.5*Strains[3];
1113 StrainTensor(0,2) = 0.5*Strains[5];
1114 StrainTensor(1,0) = 0.5*Strains[3];
1115 StrainTensor(1,1) = Strains[1];
1116 StrainTensor(1,2) = 0.5*Strains[4];
1117 StrainTensor(2,0) = 0.5*Strains[5];
1118 StrainTensor(2,1) = 0.5*Strains[4];
1119 StrainTensor(2,2) = Strains[2];
1123 return StrainTensor;
1133 if (Tensor.size1()==2)
1137 StrainVector(0) = Tensor(0,0);
1138 StrainVector(1) = Tensor(1,1);
1139 StrainVector(2) = 2.00*Tensor(0,1);
1141 else if (Tensor.size1()==3)
1143 StrainVector.resize(6);
1145 StrainVector(0) = Tensor(0,0);
1146 StrainVector(1) = Tensor(1,1);
1147 StrainVector(2) = Tensor(2,2);
1148 StrainVector(3) = 2.00*Tensor(0,1);
1149 StrainVector(4) = 2.00*Tensor(1,2);
1150 StrainVector(5) = 2.00*Tensor(0,2);
1154 return StrainVector;
1166 typedef permutation_matrix<std::size_t> pmatrix;
1168 pmatrix pm(
A.size1());
1169 int singular = lu_factorize(
A,pm);
1171 lu_substitute(
A, pm, inverse);
1183 for(
unsigned int i=0;
i< Tensor.size1();
i++)
1184 for(
unsigned int j=0;
j< Tensor.size2();
j++)
1185 result+= Tensor(
i,
j)*Tensor(
i,
j);
1187 result= sqrt(result);
1201 Tensor.
resize(3,3,
false);
1214 Tensor.
resize(2,2,
false);
1231 unsigned int dim = Tensor.size1();
1259 if (Tensor[0].size()== 3)
1264 Matrix(0,0) = Tensor[0][0](0,0);
1265 Matrix(0,1) = Tensor[0][0](1,1);
1266 Matrix(0,2) = Tensor[0][0](2,2);
1267 Matrix(0,3) = Tensor[0][0](0,1);
1268 Matrix(0,4) = Tensor[0][0](0,2);
1269 Matrix(0,5) = Tensor[0][0](1,2);
1271 Matrix(1,0) = Tensor[1][1](0,0);
1272 Matrix(1,1) = Tensor[1][1](1,1);
1273 Matrix(1,2) = Tensor[1][1](2,2);
1274 Matrix(1,3) = Tensor[1][1](0,1);
1275 Matrix(1,4) = Tensor[1][1](0,2);
1276 Matrix(1,5) = Tensor[1][1](1,2);
1278 Matrix(2,0) = Tensor[2][2](0,0);
1279 Matrix(2,1) = Tensor[2][2](1,1);
1280 Matrix(2,2) = Tensor[2][2](2,2);
1281 Matrix(2,3) = Tensor[2][2](0,1);
1282 Matrix(2,4) = Tensor[2][2](0,2);
1283 Matrix(2,5) = Tensor[2][2](1,2);
1285 Matrix(3,0) = Tensor[0][1](0,0);
1286 Matrix(3,1) = Tensor[0][1](1,1);
1287 Matrix(3,2) = Tensor[0][1](2,2);
1288 Matrix(3,3) = Tensor[0][1](0,1);
1289 Matrix(3,4) = Tensor[0][1](0,2);
1290 Matrix(3,5) = Tensor[0][1](1,2);
1292 Matrix(4,0) = Tensor[0][2](0,0);
1293 Matrix(4,1) = Tensor[0][2](1,1);
1294 Matrix(4,2) = Tensor[0][2](2,2);
1295 Matrix(4,3) = Tensor[0][2](0,1);
1296 Matrix(4,4) = Tensor[0][2](0,2);
1297 Matrix(4,5) = Tensor[0][2](1,2);
1299 Matrix(5,0) = Tensor[1][2](0,0);
1300 Matrix(5,1) = Tensor[1][2](1,1);
1301 Matrix(5,2) = Tensor[1][2](2,2);
1302 Matrix(5,3) = Tensor[1][2](0,1);
1303 Matrix(5,4) = Tensor[1][2](0,2);
1304 Matrix(5,5) = Tensor[1][2](1,2);
1311 Matrix(0,0) = Tensor[0][0](0,0);
1312 Matrix(0,1) = Tensor[0][0](1,1);
1313 Matrix(0,2) = Tensor[0][0](0,1);
1314 Matrix(1,0) = Tensor[1][1](0,0);
1315 Matrix(1,1) = Tensor[1][1](1,1);
1316 Matrix(1,2) = Tensor[1][1](0,1);
1317 Matrix(2,0) = Tensor[0][1](0,0);
1318 Matrix(2,1) = Tensor[0][1](1,1);
1319 Matrix(2,2) = Tensor[0][1](0,1);
1338 for(
unsigned int i=0;
i<3;
i++)
1340 Tensor[
i].resize(3);
1341 for(
unsigned int j=0;
j<3;
j++)
1343 Tensor[
i][
j].resize(3,3,
false);
1345 for(
unsigned int k=0;
k<3;
k++)
1346 for(
unsigned int l=0;
l<3;
l++)
1351 if((
i==0 &&
j==1) || (
i==1 &&
j==0)) help1= 3;
1352 if((
i==1 &&
j==2) || (
i==2 &&
j==1)) help1= 4;
1353 if((
i==2 &&
j==0) || (
i==0 &&
j==2)) help1= 5;
1363 if((
k==0 &&
l==1) || (
k==1 &&
l==0)) help2= 3;
1364 if((
k==1 &&
l==2) || (
k==2 &&
l==1)) help2= 4;
1365 if((
k==2 &&
l==0) || (
k==0 &&
l==2)) help2= 5;
1385 std::fill(Tensor.
begin(), Tensor.
end(), 0.0);
1386 for(
unsigned int i=0;
i<3;
i++)
1388 for(
unsigned int j=0;
j<3;
j++)
1390 for(
unsigned int k=0;
k<3;
k++)
1391 for(
unsigned int l=0;
l<3;
l++)
1396 if((
i==0 &&
j==1) || (
i==1 &&
j==0)) help1= 3;
1397 if((
i==1 &&
j==2) || (
i==2 &&
j==1)) help1= 4;
1398 if((
i==2 &&
j==0) || (
i==0 &&
j==2)) help1= 5;
1408 if((
k==0 &&
l==1) || (
k==1 &&
l==0)) help2= 3;
1409 if((
k==1 &&
l==2) || (
k==2 &&
l==1)) help2= 4;
1410 if((
k==2 &&
l==0) || (
k==0 &&
l==2)) help2= 5;
1413 Tensor[
i*27+
j*9+
k*3+
l]=
A(help1,help2)*
coeff;
1436 for(
unsigned int i=0;
i<6;
i++)
1437 for(
unsigned int j=0;
j<6;
j++)
1507 Matrix(0,3) = 2.0*Tensor[1];
1508 Matrix(0,4) = 2.0*Tensor[5];
1509 Matrix(0,5) = 2.0*Tensor[6];
1511 Matrix(1,0) = Tensor[36];
1512 Matrix(1,1) = Tensor[40];
1513 Matrix(1,2) = Tensor[44];
1514 Matrix(1,3) = 2.0*Tensor[37];
1515 Matrix(1,4) = 0.0*Tensor[41];
1516 Matrix(1,5) = 0.0*Tensor[42];
1518 Matrix(2,0) = Tensor[72];
1519 Matrix(2,1) = Tensor[76];
1520 Matrix(2,2) = Tensor[80];
1521 Matrix(2,3) = 2.0*Tensor[73];
1522 Matrix(2,4) = 2.0*Tensor[77];
1523 Matrix(2,5) = 2.0*Tensor[78];
1526 Matrix(3,1) = Tensor[13];
1527 Matrix(3,2) = Tensor[18];
1528 Matrix(3,3) = 2.0*Tensor[10];
1529 Matrix(3,4) = 2.0*Tensor[14];
1530 Matrix(3,5) = 2.0*Tensor[15];
1532 Matrix(4,0) = Tensor[45];
1533 Matrix(4,1) = Tensor[49];
1534 Matrix(4,2) = Tensor[53];
1535 Matrix(4,3) = 2.0*Tensor[46];
1536 Matrix(4,4) = 0.0*Tensor[50];
1537 Matrix(4,5) = 0.0*Tensor[51];
1539 Matrix(5,0) = Tensor[54];
1540 Matrix(5,1) = Tensor[58];
1541 Matrix(5,2) = Tensor[62];
1542 Matrix(5,3) = 2.0*Tensor[55];
1543 Matrix(5,4) = 2.0*Tensor[59];
1544 Matrix(5,5) = 2.0*Tensor[60];
1557 for(
unsigned int i=0;
i<3;
i++)
1562 for(
unsigned int i=0;
i<3;
i++)
1565 for(
unsigned int j=0;
j<3;
j++)
1567 Unity[
i][
j].resize(3,3,
false);
1570 for(
unsigned int k=0;
k<3;
k++)
1572 for(
unsigned int l=0;
l<3;
l++)
1574 Unity[
i][
j](
k,
l)=kronecker(
i,
k)*kronecker(
j,
l)
1575 -1.0/3.0*kronecker(
i,
j)*kronecker(
k,
l);
1590 for(
unsigned int i=0;
i<3;
i++)
1595 for(
unsigned int i=0;
i<3;
i++)
1596 for(
unsigned int j=0;
j<3;
j++)
1597 for(
unsigned int k=0;
k<3;
k++)
1598 for(
unsigned int l=0;
l<3;
l++)
1599 Unity[27*
i+9*
j+3*
k+
l]=kronecker(
i,
k)*kronecker(
j,
l)
1600 -1.0/3.0*kronecker(
i,
j)*kronecker(
k,
l);
1613 static bool Clipping(std::vector<Point* >& clipping_points,std::vector<Point* >& subjected_points, std::vector<Point* >& result_points,
double tolerance)
1615 result_points= subjected_points;
1618 std::vector<Point* > temp_results;
1619 bool is_visible=
false;
1620 for(
unsigned int clipp_edge=0; clipp_edge<clipping_points.size(); clipp_edge++)
1622 temp_results.clear();
1623 unsigned int index_clipp_2=0;
1624 if(clipp_edge< (clipping_points.size()-1))
1625 index_clipp_2= clipp_edge+1;
1627 noalias(actual_edge)= *(clipping_points[clipp_edge])-*(clipping_points[index_clipp_2]);
1631 if(clipp_edge< (clipping_points.size()-2))
1632 actual_normal=*(clipping_points[clipp_edge+2])-(*(clipping_points[clipp_edge])+actual_edge*
inner_prod((*(clipping_points[clipp_edge+2])-*(clipping_points[clipp_edge])),actual_edge));
1633 else if(clipp_edge< (clipping_points.size()-1))
1634 actual_normal=*(clipping_points[0])-(*(clipping_points[clipp_edge])+actual_edge*
inner_prod((*(clipping_points[0])-*(clipping_points[clipp_edge])),actual_edge));
1636 actual_normal=*(clipping_points[1])-(*(clipping_points[clipp_edge])+actual_edge*
inner_prod((*(clipping_points[1])-*(clipping_points[clipp_edge])),actual_edge));
1638 noalias(actual_normal)=actual_normal/(sqrt(
inner_prod(actual_normal,actual_normal)));
1641 if(
inner_prod((*(result_points[0])-*(clipping_points[clipp_edge])), actual_normal)> tolerance)
1650 for(
unsigned int subj_edge=0; subj_edge< result_points.size(); subj_edge++)
1652 unsigned int index_subj_2=0;
1654 if(subj_edge< (result_points.size()-1))
1655 index_subj_2= subj_edge+1;
1658 if(fabs(
inner_prod((*(result_points[subj_edge])-(*(clipping_points[clipp_edge]))), actual_normal))<= tolerance)
1660 temp_results.push_back(result_points[subj_edge]);
1661 if(
inner_prod((*(result_points[index_subj_2])-*(clipping_points[clipp_edge])), actual_normal)> tolerance)
1670 b(0)= -
inner_prod((*(result_points[index_subj_2])-*(result_points[subj_edge])),(*(result_points[subj_edge])-*(clipping_points[clipp_edge])));
1671 b(1)=
inner_prod((*(clipping_points[index_clipp_2])-*(clipping_points[clipp_edge])),(*(result_points[subj_edge])-*(clipping_points[clipp_edge])));
1673 A(0,0)=
inner_prod((*(result_points[index_subj_2])-*(result_points[subj_edge])),(*(result_points[index_subj_2])-*(result_points[subj_edge])));
1674 A(0,1)=-
inner_prod((*(result_points[index_subj_2])-*(result_points[subj_edge])),(*(clipping_points[index_clipp_2])-*(clipping_points[clipp_edge])));
1676 A(1,1)=
inner_prod(*(clipping_points[index_clipp_2])-*(clipping_points[clipp_edge]),*(clipping_points[index_clipp_2])-*(clipping_points[clipp_edge]));
1678 coeff(0)=1.0/
A(0,0)*(
b(0)-
A(0,1)/(
A(1,1)-
A(0,1)*
A(1,0)/
A(0,0))*(
b(1)-
b(0)*
A(1,0)/
A(0,0)));
1679 coeff(1)=1.0/(
A(1,1)-
A(0,1)*
A(1,0)/
A(0,0))*(
b(1)-
b(0)*
A(1,0)/
A(0,0));
1684 noalias(dist_vec)= *(result_points[subj_edge])+
coeff(0)*(*(result_points[index_subj_2])-*(result_points[subj_edge]))-(*(clipping_points[clipp_edge])+
coeff(1)*(*(clipping_points[index_clipp_2])-*(clipping_points[clipp_edge])));
1686 if(
coeff(0) > tolerance &&
coeff(0) < (1-tolerance)&& (sqrt(
inner_prod(dist_vec,dist_vec))< tolerance))
1689 temp_results.push_back(result_points[subj_edge]);
1691 temp_results.push_back(
new Point((*(clipping_points[clipp_edge])+
coeff(1)*(*(clipping_points[index_clipp_2])-*(clipping_points[clipp_edge])))));
1693 is_visible= !is_visible;
1698 temp_results.push_back(result_points[subj_edge]);
1700 result_points=temp_results;
1702 if(result_points.size()==0)
1717 for(
int i = 0;
i<size; ++
i)
1729 for(
unsigned int i = 0;
i<irange.size(); ++
i)
1730 for(
unsigned int j = 0;
j<jrange.size(); ++
j)
1731 A(
i,
j) = rMatrix(irange[
i],jrange[
j]);
1740 for(
unsigned int i = 0;
i<irange.size(); ++
i)
1741 for(
unsigned int j = 0;
j<jrange.size(); ++
j)
1742 rMatrixA(irange[
i],jrange[
j]) = rMatrixB(
i,
j);
1753 for(
unsigned int i = 0;
i<irange.size(); ++
i)
1754 b[
i] = rVector[irange[
i]];
#define FIND_MAX(a, b)
Definition: solid_mechanics_math_utilities.hpp:18
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
Various mathematical utilitiy functions.
Definition: math_utils.h:62
static double Norm(const Vector &a)
Calculates the norm of vector "a".
Definition: math_utils.h:703
Point class.
Definition: point.h:59
static void TensorToVector(const Matrix &Tensor, Vector &Vector)
Definition: solid_mechanics_math_utilities.hpp:1228
static VectorType project(const VectorType &rVector, VectorType irange)
Definition: solid_mechanics_math_utilities.hpp:1748
static void TensorToMatrix(std::vector< std::vector< Matrix > > &Tensor, Matrix &Matrix)
Definition: solid_mechanics_math_utilities.hpp:1425
static MatrixType IdentityMatrix(SizeType size)
Definition: solid_mechanics_math_utilities.hpp:979
static void Normalize(VectorType &v)
Definition: solid_mechanics_math_utilities.hpp:1078
static MatrixType StrainVectorToTensor(const VectorType &Strains)
Definition: solid_mechanics_math_utilities.hpp:1093
static void QRFactorization(const MatrixType &A, MatrixType &Q, MatrixType &R)
Definition: solid_mechanics_math_utilities.hpp:307
static void EigenVectors(const MatrixType &A, MatrixType &vectors, VectorType &lambda, double zero_tolerance=1e-9, int max_iterations=10)
Definition: solid_mechanics_math_utilities.hpp:433
static void MatrixToTensor(MatrixType &A, array_1d< double, 81 > &Tensor)
Definition: solid_mechanics_math_utilities.hpp:1380
static MatrixType project(const MatrixType &rMatrix, VectorType irange, VectorType jrange)
Definition: solid_mechanics_math_utilities.hpp:1724
static Vector EigenValues(const Matrix &A, double tolerance, double zero)
Definition: solid_mechanics_math_utilities.hpp:143
static void DeviatoricUnity(array_1d< double, 81 > &Unity)
Definition: solid_mechanics_math_utilities.hpp:1586
static Vector EigenValuesDirectMethod(const Matrix &A)
Definition: solid_mechanics_math_utilities.hpp:244
DenseVector< Vector > Second_Order_Tensor
Definition: solid_mechanics_math_utilities.hpp:51
Matrix MatrixType
Definition: solid_mechanics_math_utilities.hpp:41
unsigned int SizeType
Definition: solid_mechanics_math_utilities.hpp:47
static void DeviatoricUnity(std::vector< std::vector< Matrix > > &Unity)
Definition: solid_mechanics_math_utilities.hpp:1551
static VectorType range(const unsigned int start, const unsigned int end)
Definition: solid_mechanics_math_utilities.hpp:1709
static MatrixType Transpose(MatrixType &A)
Definition: solid_mechanics_math_utilities.hpp:1060
static void TensorToMatrix(const array_1d< double, 81 > &Tensor, Matrix &Matrix)
Definition: solid_mechanics_math_utilities.hpp:1499
static bool CardanoFormula(double a, double b, double c, double d, Vector &solution)
Definition: solid_mechanics_math_utilities.hpp:76
DenseMatrix< Second_Order_Tensor > Matrix_Second_Tensor
Definition: solid_mechanics_math_utilities.hpp:57
static void Mult(MatrixType &M, TDataType a)
Definition: solid_mechanics_math_utilities.hpp:1034
static MatrixType Mult(MatrixType &A, MatrixType &B)
Definition: solid_mechanics_math_utilities.hpp:1013
static void EigenVectors3x3(const Matrix &A, Matrix &V, Vector &d)
Definition: solid_mechanics_math_utilities.hpp:626
static Vector TensorToStrainVector(const Matrix &Tensor)
Definition: solid_mechanics_math_utilities.hpp:1127
MathUtils< TDataType > MathUtilsType
Definition: solid_mechanics_math_utilities.hpp:49
static int InvertMatrix(const MatrixType &input, MatrixType &inverse)
Definition: solid_mechanics_math_utilities.hpp:1164
static void MatrixToTensor(MatrixType &A, std::vector< std::vector< Matrix > > &Tensor)
Definition: solid_mechanics_math_utilities.hpp:1330
static bool Clipping(std::vector< Point * > &clipping_points, std::vector< Point * > &subjected_points, std::vector< Point * > &result_points, double tolerance)
Definition: solid_mechanics_math_utilities.hpp:1613
static void Add(MatrixType &A, MatrixType &B)
Definition: solid_mechanics_math_utilities.hpp:997
static void Mult(VectorType &v, TDataType a)
Definition: solid_mechanics_math_utilities.hpp:1048
static void EigenVectors(MatrixType &A, MatrixType &V, TDataType &error_tolerance, TDataType zero_tolerance)
Definition: solid_mechanics_math_utilities.hpp:891
unsigned int IndexType
Definition: solid_mechanics_math_utilities.hpp:45
Vector VectorType
Definition: solid_mechanics_math_utilities.hpp:43
static double NormTensor(Matrix &Tensor)
Definition: solid_mechanics_math_utilities.hpp:1180
static void VectorToTensor(const Vector &Stress, Matrix &Tensor)
Definition: solid_mechanics_math_utilities.hpp:1197
static double hypot2(double x, double y)
Definition: solid_mechanics_math_utilities.hpp:873
DenseVector< Second_Order_Tensor > Third_Order_Tensor
Definition: solid_mechanics_math_utilities.hpp:53
static MatrixType & project(MatrixType &rMatrixA, VectorType irange, VectorType jrange, const MatrixType &rMatrixB)
Definition: solid_mechanics_math_utilities.hpp:1737
static void TensorToMatrix(Fourth_Order_Tensor &Tensor, Matrix &Matrix)
Definition: solid_mechanics_math_utilities.hpp:1252
DenseVector< DenseVector< Matrix > > Fourth_Order_Tensor
Definition: solid_mechanics_math_utilities.hpp:55
Short class definition.
Definition: array_1d.h:61
BOOST_UBLAS_INLINE const_iterator end() const
Definition: array_1d.h:611
BOOST_UBLAS_INLINE const_iterator begin() const
Definition: array_1d.h:606
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
start
Definition: DEM_benchmarks.py:17
end
Definition: DEM_benchmarks.py:180
iteration
Definition: DEM_benchmarks.py:172
constexpr double Pi
Definition: global_variables.h:25
solution
Definition: KratosDEM.py:9
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
float error
Definition: PecletTest.py:102
int max_iterations
Definition: ProjectParameters.py:53
list coeff
Definition: bombardelli_test.py:41
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
v
Definition: generate_convection_diffusion_explicit_element.py:114
w
Definition: generate_convection_diffusion_explicit_element.py:108
q
Definition: generate_convection_diffusion_explicit_element.py:109
f
Definition: generate_convection_diffusion_explicit_element.py:112
V
Definition: generate_droplet_dynamics.py:256
h
Definition: generate_droplet_dynamics.py:91
input
Definition: generate_frictional_mortar_condition.py:435
int C
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:27
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
u
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:30
float gamma
Definition: generate_two_fluid_navier_stokes.py:131
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
phi
Definition: isotropic_damage_automatic_differentiation.py:168
R
Definition: isotropic_damage_automatic_differentiation.py:172
Stress
Definition: isotropic_damage_automatic_differentiation.py:135
tuple Q
Definition: isotropic_damage_automatic_differentiation.py:235
int d
Definition: ode_solve.py:397
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int m
Definition: run_marine_rain_substepping.py:8
dummy
Definition: script.py:194
A
Definition: sensitivityMatrix.py:70
p
Definition: sensitivityMatrix.py:52
x
Definition: sensitivityMatrix.py:49
int dim
Definition: sensitivityMatrix.py:25
B
Definition: sensitivityMatrix.py:76
integer i
Definition: TensorModule.f:17
double precision, dimension(3, 3), public delta
Definition: TensorModule.f:16
integer l
Definition: TensorModule.f:17
zero
Definition: test_pureconvectionsolver_benchmarking.py:94
e
Definition: run_cpp_mpi_tests.py:31