muMECH  1.0
esei_Cylinder.cpp
Go to the documentation of this file.
1 //********************************************************************************************************
2 // code: ### ### ##### #### ## ##
3 // ## ## ######## ## ## ## ## ##
4 // ## ## ## ## ## ### ## ######
5 // ## ## ## ## ## ## ## ## ##
6 // ##### ## ## ##### #### ## ##
7 // ##
8 //
9 // name: eshelbySoluEllipticIntegralsCylinder.cpp
10 // author(s): Jan Novak, Tomas Janda
11 // language: C, C++
12 // license: This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 //********************************************************************************************************
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <math.h>
30 #include <cmath>
31 #include <iostream>
32 
33 #include "macros.h"
34 #include "esei_Cylinder.h"
35 #include "eshelbySoluLambda.h"
36 #include "legendreIntegrals.h"
37 #include "elementaryFunctions.h"
38 #include "inclusion.h"
39 
40 
41 namespace mumech {
42 
43 // Function gives the values of Ferers-Dysons integrals
44 // Last edit: 14-Jan-2014
45 void eshelbySoluEllipticIntegralsCylinder::giveEllipticIntegrals(double J[13], double lambda, bool intpoint)
46 {
47  // Cylinder: a2 = a3, a1 -> infinity
48  if (I->a[1] != I->a[2])
49  {
50  _warningg( "Values of semiaxes do not fit the condition for circular cylinder (a2 = a3, a1 = infinity is ignored). " );
51  std::cout << "a1, a2, a3 = " << I->a[0] << ", " << I->a[1] << ", " << I->a[2];
52  }
53 
54  double a2 = I->a[1];
55  CleanVector(J, 13);
56 
57  J[0] = 0.;
58 
59  J[1] = 0.0; // I1
60  J[2] = this->I2(a2, lambda); // I2
61  J[3] = J[2]; // I3 = I2
62 
63  // (Order changed due to sequential evaluation)
64  J[4] = 0.0; // I11
65  J[5] = 0.0; // I12
66  J[6] = 0.0; // I13
67 
68  J[7] = 0.0; // I21
69  J[8] = this->I22(a2, lambda); // I22
70  J[9] = J[8]; // I23 = I22
71 
72  J[10] = 0.0; // I31
73  J[11] = J[8]; // I32 = I22
74  J[12] = J[8]; // I33 = I22
75 
76 #ifdef TOM_DEBUG
77  if (log)
78  {
79  std::cout << "J integrals" << std::endl;
80  for (int i = 0; i < 13; i++)
81  std::cout << "J[" << i << "] = " << J[i] << std::endl;
82  std::cout << std::endl;
83  }
84 #endif
85 }
86 
87 
88 // Function gives the derivatives of Ferers-Dysons integrals
89 // Last edit: 14-Jan-2014
90 // Flat shapes has zero drtivatives
92 {
93  //if (point->position == PPF_INT_POINT) {
94  // CleanVector( point->dJi, 9 );
95  // CleanVector( point->dJij, 27 );
96  // CleanVector( point->ddJi, 27 );
97  // CleanVector( point->ddJij, 81 );
98  //}
99  //else if (point->position == PPF_EXT_POINT) {
100  // NUMERICAL DERIVATIVES (using REAL ARGUMENTS)
101 
102  double ndiff = I->ndiff_1;
103 
104  // Get perturbated points and their lambdas
105  double lambdas[NUM_PERTURB];
106  this->getPerturbatedLambdas(lambdas, point->loc_x);
107 
108  // Create and fill a two dimensional array containing values of J-integrals at perturbated points.
109  const int NUM_ELLIP_INT = 13;
110  double J_pert[NUM_PERTURB][NUM_ELLIP_INT]; // All perturbations of all elliptical integrals.
111 
112  this->log = false;
113  for (int i = 0; i < NUM_PERTURB; i++) // For each perturbated point
114  this->giveEllipticIntegrals(J_pert[i], lambdas[i], intpoint); // Get elliptical integrals for lambda of perturbated point.
115  this->log = true;
116 
117  // Compute numerial derivatives of first and second order of J_i integrals.
118  for (int i = 0; i < 3; i++) // For each elliptic integral Ji
119  {
120  // See types.c, section "Derivatives of Ferers-Dysons' integrals".
121  // Ji_j = dJi[3*i+j-4], i,j=1..3.
122  //point->dJi[3*i] = (J_pert[_Xp_][i+1] - J_pert[_Xm_][i+1]) / (2.0 * ndiff);
123  point->dJi[3*i+1] = (J_pert[_Yp_][i+1] - J_pert[_Ym_][i+1]) / (2.0 * ndiff);
124  point->dJi[3*i+2] = (J_pert[_Zp_][i+1] - J_pert[_Zm_][i+1]) / (2.0 * ndiff);
125 
126  // See types.c, section "Derivatives of Ferers-Dysons' integrals".
127  // Ji_jk = ddJi[9*i+3*j+k-13], i,j,k=1..3.
128  //point->ddJi[9*i] = (J_pert[_Xp_][i+1] - 2.0 * J_pert[_CENTER_][i+1] + J_pert[_Xm_][i+1]) / (ndiff * ndiff); // d^2f(x,y,z)/dx^2 = (f(x+h,y,z) - 2*f(x,y,z) + f(x-h,y,z)) / h^2
129  //point->ddJi[9*i+1] = (J_pert[_XpYp_][i+1] - J_pert[_XpYm_][i+1] - J_pert[_XmYp_][i+1] + J_pert[_XmYm_][i+1]) / (4.0*ndiff*ndiff); // d^2f(x,y,z)/dxdy = (f(x+h,y+h,z) - f(x+h,y-h,z) - f(x-h,y+h,z) + f(x-h,y-h,z)) / (4*h^2)
130  //point->ddJi[9*i+2] = (J_pert[_XpZp_][i+1] - J_pert[_XpZm_][i+1] - J_pert[_XmZp_][i+1] + J_pert[_XmZm_][i+1]) / (4.0*ndiff*ndiff);
131 
132  //point->ddJi[9*i+3] = point->ddJi[9*i+1];
133  point->ddJi[9*i+4] = (J_pert[_Yp_][i+1] - 2.0 * J_pert[_CENTER_][i+1] + J_pert[_Ym_][i+1]) / (ndiff * ndiff);
134  point->ddJi[9*i+5] = (J_pert[_YpZp_][i+1] - J_pert[_YpZm_][i+1] - J_pert[_YmZp_][i+1] + J_pert[_YmZm_][i+1]) / (4.0*ndiff*ndiff);
135 
136  //point->ddJi[9*i+6] = point->ddJi[9*i+2];
137  point->ddJi[9*i+7] = point->ddJi[9*i+5];
138  point->ddJi[9*i+8] = (J_pert[_Zp_][i+1] - 2.0 * J_pert[_CENTER_][i+1] + J_pert[_Zm_][i+1]) / (ndiff * ndiff);
139  }
140 
141  // Compute numerial derivatives of first and second order of J_ij integrals.
142  for (int i = 0; i < 9; i++) // For each elliptic integral Jij
143  {
144  // See types.c, section "Derivatives of Ferers-Dysons' integrals".
145  // Jij_k = dJij[9*k+3*i+j-13], i,j,k=1..3.
146  //point->dJij[i] = (J_pert[_Xp_][i+4] - J_pert[_Xm_][i+4]) / (2.0 * ndiff);
147  point->dJij[i+9] = (J_pert[_Yp_][i+4] - J_pert[_Ym_][i+4]) / (2.0 * ndiff);
148  point->dJij[i+18] = (J_pert[_Zp_][i+4] - J_pert[_Zm_][i+4]) / (2.0 * ndiff);
149 
150  // See types.c, section "Derivatives of Ferers-Dysons' integrals".
151  // Jij_kl = ddJi[27*i+9*j+3*k+l-40] i,j,k,l=1..3.
152  //point->ddJij[9*i] = (J_pert[_Xp_][i+4] - 2.0 * J_pert[_CENTER_][i+4] + J_pert[_Xm_][i+4]) / (ndiff * ndiff);
153  //point->ddJij[9*i+1] = (J_pert[_XpYp_][i+4] - J_pert[_XpYm_][i+4] - J_pert[_XmYp_][i+4] + J_pert[_XmYm_][i+4]) / (4.0*ndiff*ndiff);
154  //point->ddJij[9*i+2] = (J_pert[_XpZp_][i+4] - J_pert[_XpZm_][i+4] - J_pert[_XmZp_][i+4] + J_pert[_XmZm_][i+4]) / (4.0*ndiff*ndiff);
155 
156  //point->ddJij[9*i+3] = point->ddJij[9*i+1];
157  point->ddJij[9*i+4] = (J_pert[_Yp_][i+4] - 2.0 * J_pert[_CENTER_][i+4] + J_pert[_Ym_][i+4]) / (ndiff * ndiff);
158  point->ddJij[9*i+5] = (J_pert[_YpZp_][i+4] - J_pert[_YpZm_][i+4] - J_pert[_YmZp_][i+4] + J_pert[_YmZm_][i+4]) / (4.0*ndiff*ndiff);
159 
160  //point->ddJij[9*i+6] = point->ddJij[9*i+2];
161  point->ddJij[9*i+7] = point->ddJij[9*i+5];
162  point->ddJij[9*i+8] = (J_pert[_Zp_][i+4] - 2.0 * J_pert[_CENTER_][i+4] + J_pert[_Zm_][i+4]) / (ndiff * ndiff);
163  }
164  //}
165  //else _errorr("point position is not defined");
166 
167 #ifdef TOM_DEBUG
168  std::cout << "dJi integrals" << std::endl;
169  for (int i = 0; i < 9; i++)
170  std::cout << "dJi[" << i << "] = " << point->dJi[i] << std::endl;
171  std::cout << std::endl;
172  std::cout << "dJij integrals" << std::endl;
173  for (int i = 0; i < 27; i++)
174  std::cout << "dJij[" << i << "] = " << point->dJij[i] << std::endl;
175  std::cout << std::endl;
176  std::cout << "ddJi integrals" << std::endl;
177  for (int i = 0; i < 27; i++)
178  std::cout << "ddJi[" << i << "] = " << point->ddJi[i] << std::endl;
179  std::cout << std::endl;
180  std::cout << "ddJij integrals" << std::endl;
181  for (int i = 0; i < 81; i++)
182  std::cout << "ddJij[" << i << "] = " << point->ddJij[i] << std::endl;
183  std::cout << std::endl;
184 #endif
185 }
186 
187 double eshelbySoluEllipticIntegralsCylinder::I2(double a2, double lambda)
188 {
189  return 2.0 * PI * SQR(a2) / (SQR(a2) + lambda); // I2
190 }
191 
192 double eshelbySoluEllipticIntegralsCylinder::I22(double a2, double lambda)
193 {
194  return PI * SQR(a2) / (SQR(a2) + lambda) / (SQR(a2) + lambda) ;
195 }
196 
197 // Returns lambda for a given point coordinates
198 double eshelbySoluEllipticIntegralsCylinder :: getLambda (const double a[3], double x1, double x2, double x3)
199 {
200  // The cubic equation simplify to this expression for circular cylinder.
201  return SQR(x2) + SQR(x3) - SQR(a[1]);
202 }
203 
204 
205 } // end of namespace mumech
206 
207 /*end of file*/
208 
double getLambda(const double a[3], double x1, double x2, double x3)
Returns lambda for a given point (x1, x2, x3)
#define _warningg(_1)
Definition: gelib.h:163
double loc_x[3]
Local coordinates of a point.
Definition: matrix.h:137
Class legendreIntegrals.
#define PI
Definition: macros.h:71
const InclusionRecord3D * I
Definition: esei.h:45
void giveEllipticIntegrals(double J[13], double lambda, bool intpoint)
Function gives the values of Ferers-Dyson&#39;s elliptic integrals of the inclusion this->I.
#define NUM_PERTURB
Definition: types.h:732
Class eshelbySoluEllipticIntegralsCylinder.
The header file of usefull macros.
void getPerturbatedLambdas(double *lambdas, const double loc_x[3])
Helper function.
Definition: esei.cpp:51
Collection of the functions of basic manipulations, some of them can be used instead of their counter...
double ddJij[81]
Second derivatives of elliptic integral Iij.
Definition: matrix.h:145
Single Point data structure - contribution from Single inclusion.
Definition: matrix.h:133
double ndiff_1
derivative step for the first derivations
Definition: inclusion.h:108
Class inclusion contains and handles all inclusion data.
#define SQR(a)
Definition: macros.h:97
double dJi[9]
First derivatives of elliptic integral Ii.
Definition: matrix.h:142
double * a
Inclusion semiaxes&#39; dimensions in global arrangement.
Definition: inclusion.h:76
double ddJi[27]
Second derivatives of elliptic integral Ii.
Definition: matrix.h:144
double dJij[27]
First derivatives of elliptic integral Iij.
Definition: matrix.h:143
double I2(double a2, double lambda)
void CleanVector(double *a, long n)
Functin cleans a &#39;double&#39; vector, initialize each value being 0-zero.
void giveDerivativesOfEllipticIntegrals(Point *point, bool intpoint)
Function gives the values of Ferers-Dyson&#39;s elliptic integral derivatives of the inclusion this->I...
double I22(double a1, double lambda)