muMECH  1.0
tests_tools.cpp
Go to the documentation of this file.
1 #include "tests.h"
2 
3 #include "problem.h"
4 #include "mesh.h"
6 #include "comparison.h"
7 #include "types.h"
8 #include "mnode.h"
9 #include "melement.h"
10 #include "vtk.h"
11 #include "mesoface.h"
12 
13 #include "gelib.h"
14 #include "librw.h"
15 
16 #include <algorithm>
17 
18 using namespace mumech;
19 
20 struct Bod {
21  int ID;
22  double coord[3];
23  int mat[2];
24  double rslt[2][6];
25  double disp[4];
26  bool last=false;
27 };
28 
29 // ******************************************* ULOHY ********************************************
30 
31 // *** 2d ulohy pocitane 2d a 3d mumechem a ansysem, tisk rezu napeti
32 
33 // Jedna inkluze.
34 void x2d_1I (void);
35 // Dve 2d elipticke inkluze na ose x, muze se menit jejich vzdalenost 'dx'.
36 void x2d_2I (void);
37 // Pravidelny grid kruhovych 2d inkluzi poctu "2n+1" x "2n+1".
38 void x2d_grid (void);
39 
40 
41 // *** ulohy do clanku o mumechu
42 
43 // vzorovy 3d priklad o dvou inkluzich
44 void clanek_3d_vzor (void);
45 // homogenizace - 2d uloha, pravidelny grid kruhovych inkluzi "2n+1" x "2n+1".
46 void clanek_homog_grid (void);
47 
48 
49 // *** ruzne
50 
51 // testovani visualizace
52 void visualization_1I_2d (void);
53 void visualization_1I_3d (void);
54 void visualization_197I_2d3d (void);
55 
56 
57 void intersection_2d (void);
58 void intersection_3d (void);
59 
60 // 2d uloha pocitana 2d a 3d mumechem, postupna rotace inkluze, tisk hodnot v jednom bode; NUMERIKA je zubata!!
61 void x2Dx3D_rotation (void);
62 
63 void penergy_2d (void);
64 
65 // ---
66 
67 void hrana_inkluze (void);
68 
69 void Energy_x2D_1I_MMxFEM (void);
70 
71 void ovlivneni (void);
72 
73 // nove testy od standy, speedtests, zatim nezpracovane
74 void speedtest2Dx3D(void);
75 void createNodes(double a, double b, double c, double da, double db, double dc, double **&points, int &n);
76 void test3D();
77 
78 
79 // ************************************** DROBNE FUNKCE **************************************
80 void modeset (Problem *p, int mode);
81 // ************************************** KOMPLEXNI FUNKCE **************************************
82 void print_graf (const char *vtkGeomFile, const char *path, const char *suff, int lc, char axe, int comp, double coordMin, double coordMax, double coordDelta, char pt_flag, double dshift, DiffTypes dt, Bod * b = NULL, bool odd = false);
83 void compute_and_print_reg_mesh (const char *vtkGeomFile, const char *vtkMeshFileOutPert, double x, int n, char pt, DiffTypes dt);
84 
85 // ************************************ ANSYS POSTPROCESSING ************************************
86 Bod* read_ansys_strain_stress_plot (const char *path, int lc, char axe, int comp, double coordMin, double coordMax, bool strn, bool half=false, bool bod=false);
87 void read_ansys_displ_plot (const char *path, int lc, char axe, int comp, double coordMin, double coordMax);
88 
89 // ********************************** GENEROVANI EQIV SOUBORU ***********************************
90 void eqiv_gener_1x2dI_3d (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double y, double E, double nu, double a1, double a2, double ea, DiffTypes dt);
91 void eqiv_gener_1x2dI_2d (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double y, double E, double nu, double a1, double a2, double ea, DiffTypes dt);
92 void eqiv_gener_2x2dI_2d (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double E, double nu, double a1, double a2, DiffTypes dt, int mode=0);
93 void eqiv_gener_2x2dI_3d (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double E, double nu, double a1, double a2, DiffTypes dt, int mode=0);
94 void eqiv_gener_gx2dI_2d (const char *vtkAmndFile, int gx, int gy, double dx, double dy, double Em, double num, const double *rs, double E, double nu, double a1, double a2, DiffTypes dt, int mode);
95 void eqiv_gener_gx2dI_3d (const char *vtkAmndFile, int gx, int gy, double dx, double dy, double Em, double num, const double *rs, double E, double nu, double a1, double a2, DiffTypes dt, int mode);
96 
97 void eqiv_gener_1x3dI (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double y, double z, double E, double nu,
98  double a1, double a2, double a3, double ea1, double ea2, double ea3, DiffTypes dt);
99 
100 
102 void tests_tools (void)
103 {
104  //x2d_1I ();
105  x2d_2I ();
106  //x2d_grid ();
107 
108  // visualization ();
109 
110  //intersection_2d();
111  //intersection_3d ();
112 
113  //clanek_3d_vzor ();
114  //clanek_homog_grid ();
115 
116  // ---
117 
118  //x2Dx3D_rotation();
119 
120  //penergy_2d ();
121 
122 
123 
124  // *** hrana inkluze ext x int
125  //hrana_inkluze ();
126 
127  //print_incls ();
128  //print_incls_2d ();
129 }
130 
131 // **************************************************************************************************
132 // ******************************************* ULOHY ********************************************
133 // **************************************************************************************************
134 void compare_grafs (const char *name1, const char *name2)
135 {
136  FILE *file1 = fopen(name1, "r");
137  FILE *file2 = fopen(name2, "r");
138  char c;
139  int n=0;
140  double v1, v2;
141  bool bre=false;
142 
143  while (true) {
144  c = fgetc(file1); ungetc(c,file1);
145  if (c == '\n' || c == EOF) break;
146 
147  fscanf (file1, "%lf", &v1);
148  fscanf (file2, "%lf", &v2);
149  if (v1 != v2) errol;
150 
151  fscanf (file1, "%lf", &v1);
152  fscanf (file2, "%lf", &v2);
153  if (! areSame(1e-9, 0.01, v1, v2)) {
154  printf ("%lf %lf \n", v1, v2);
155  printf ("cd .. ; xmgrace -param /home/termit/.config/grace/link.par %s %s ; cd -\n", name1, name2);
156  bre = true;
157  break;//warningerrol;
158  }
159 
160  FP_skip_line(file1);
161  FP_skip_line(file2);
162  n++;
163  }
164  if (bre==false && n<20)
165  errol;
166 
167  fclose(file1);
168  fclose(file2);
169 }
170 
171 
172 
174 void penergy_2d (void)
175 {
178 
179  return;
180 }
181 
182 
183 
184 
199 void x2d_1I (void)
200 {
201  Bod* b = NULL;
202  //char suff[100];
203  char vtkAmndFile2d [] = "x2d_1I/amnd.2d.vtk";
204  char vtkAmndFile3d [] = "x2d_1I/amnd.3d.vtk";
205 
206  // **************************************
207  // ZDE URCIT, CO SE BUDE POCITAT/TISKNOUT
208  // **************************************
209  double angle = 30.0; // 0.0 or 30.0 !! Kdyz zde zmenis uhel a chces porovnat s ANSYSem, tak zmen link viz vyse.
210  bool pert = false;
211  bool totl = true;
212  char xy[] = "XY"; // nebo treba "X-" "-Y"
213  int nlc = 3; if (nlc !=1 && nlc != 3) errol; // nlc musi byt jen 1 nebo 3 aby se to mohlo automaticky generovat, tj. rucne zadany rs23 nebo vsechno
214  int ncomp = 3; if (ncomp<1 || ncomp>3) errol;
215 
216  double rs2 [] = { 1.0, 0.0, 0.0, 0.0 };
217  double rs3 [] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
218 
219  bool m2d = true;
220  bool m3d = true;
221 
222  // *******
223  // COMPUTE
224  // *******
225 
226  // vytvoreni 2d a 3d prikladu
227  if(m2d) eqiv_gener_1x2dI_2d (vtkAmndFile2d, 1.0, 0.2, nlc == 1 ? rs2 : NULL, 0.0, 0.0, 10.0, 0.4, 1.0, 0.5, angle, DT_NUMERICAL);
228  if(m3d) eqiv_gener_1x2dI_3d (vtkAmndFile3d, 1.0, 0.2, nlc == 1 ? rs3 : NULL, 0.0, 0.0, 10.0, 0.4, 1.0, 0.5, angle, DT_NUMERICAL);
229 
230  //char name1[100], name2[100], name3[100];
231  // loop over nlc (number of load cases)
232  for (int i=0; i<nlc; i++) {
233  // loop over ncomp (number of components)
234  for (int j=0; j<ncomp; j++) {
235  // loop over axes
236  for (int k=0; k<2; k++) {
237  if (xy[k] == '-') continue;
238 
239  // GRAFY TISK - anasys
240  ; b = read_ansys_strain_stress_plot("x2d_1I/", i, xy[k], j==2 ? 3 : j, -20.0, 20.0, true, false, true);
241  ; read_ansys_strain_stress_plot("x2d_1I/", i, xy[k], j==2 ? 3 : j, -20.0, 20.0, false);
242  if (j<2) read_ansys_displ_plot ("x2d_1I/", i, xy[k], j==2 ? 3 : j, -20.0, 20.0);
243 
244  // GRAFY TISK - mumech
245  if (pert) { print_graf(vtkAmndFile2d, "x2d_1I/", ".2d.pert", i, xy[k], j, -20.0, 20.0, 0.01, 'p', 0, DT_NUMERICAL, b); }
246  if (totl) { print_graf(vtkAmndFile2d, "x2d_1I/", ".2d" , i, xy[k], j, -20.0, 20.0, 0.01, 't', 0, DT_NUMERICAL, b); }
247 
248  if (pert) { print_graf(vtkAmndFile3d, "x2d_1I/", ".3d.pert", i==2 ? 3 : i, xy[k], j==2 ? 3 : j, -20.0, 20.0, 0.01, 'p', 0, DT_ANALITICAL, b); }
249  if (totl) { print_graf(vtkAmndFile3d, "x2d_1I/", ".3d" , i==2 ? 3 : i, xy[k], j==2 ? 3 : j, -20.0, 20.0, 0.01, 't', 0, DT_ANALITICAL, b); }
250 
251  // // COMPARE grafs
252  // sprintf (name1, "%sgraf_lc%ld_%c_displc_%d%s.dat", "x2d_1I/", i, xy[k], j, ".2d");
253  // sprintf (name2, "%sgraf_lc%ld_%c_displc_%d%s.dat", "x2d_1I/", i, xy[k], j, ".3d");
254  // sprintf (name3, "%sgraf_lc%ld_%c_displc_%d%s.dat", "x2d_1I/", i, xy[k], j, ".ansys");
255  // if (j < 2) { compare_grafs(name1, name2); compare_grafs(name2, name3); }
256  //
257  // sprintf (name1, "%sgraf_lc%ld_%c_strain_%d%s.dat", "x2d_1I/", i, xy[k], j, ".2d");
258  // sprintf (name2, "%sgraf_lc%ld_%c_strain_%d%s.dat", "x2d_1I/", i, xy[k], j, ".3d");
259  // sprintf (name3, "%sgraf_lc%ld_%c_strain_%d%s.dat", "x2d_1I/", i, xy[k], j, ".ansys");
260  // compare_grafs(name1, name2); compare_grafs(name2, name3);
261  //
262  // sprintf (name1, "%sgraf_lc%ld_%c_stress_%d%s.dat", "x2d_1I/", i, xy[k], j, ".2d");
263  // sprintf (name2, "%sgraf_lc%ld_%c_stress_%d%s.dat", "x2d_1I/", i, xy[k], j, ".3d");
264  // sprintf (name3, "%sgraf_lc%ld_%c_stress_%d%s.dat", "x2d_1I/", i, xy[k], j, ".ansys");
265  // compare_grafs(name1, name2); compare_grafs(name2, name3);
266  }
267  }
268  }
269 }
270 
271 void read_number_from_file (double &dx, const char *name)
272 {
273  FILE *file = fopen(name, "r");
274  fscanf (file,"%lf", &dx);
275  fclose(file);
276 }
277 
278 // Dve 2d elipticke inkluze na ose x, muze se menit jejich vzdalenost 'dx'.
279 // Inkluze jsou porad stejne, protoze v ANSYS reseni se da momentalne menit jen parametr 'dx' a hustota site.
280 void x2d_2I (void)
281 {
282  Bod* b = NULL;
283  char suff[100];
284  char vtkAmndFile2d [] = "x2d_2I/amnd.2d.vtk";
285  char vtkAmndFile3d [] = "x2d_2I/amnd.3d.vtk";
286 
287  // **************************************
288  // ZDE URCIT, CO SE BUDE POCITAT/TISKNOUT
289  // **************************************
290  //double angle = 0.0;// -> u 2 inkluzi je uhel vzdy 0.0
291  char xy[] = "X-"; // nebo treba "X-" "-Y" -> zatim jen X
292  int nlc = 1; if (nlc !=1 && nlc != 1) errol; // -> zatim jen 1 lc, 3 nlc viz x2d_1I
293  int ncomp = 3; if (ncomp<1 || ncomp>3) errol;
294 
295  double dx = 1.25;
296 
297  double Em = 1.0, num = 0.2; // 1.0 0.2
298  double Ei = 10.0, nui = 0.3; // 1.0 0.4
299  double rs2 [] = { 1.0, 0.0, 0.0, 0.0 };
300  double rs3 [] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
301 
302  read_number_from_file (dx, "x2d_2I/dx.txt");
303 
304  bool m2d = true;
305  bool m3d = false;
306  bool ANSYS = true; // void standa add
307  bool mode[] = { false, false, 1, false, 0, 0, false, false }; int cm = 8;
308 
309  // OK SET - jeden vybrany set, ktery je ulozen, pouze pro kontrolu s novym resenim, ze se nic nezmenilo/neposralo
310  m2d = true;
311  m3d = false;
312  ANSYS = false;
313  mode[0] = mode[2] = mode[4] = mode[5] = true;
314  mode[1] = mode[3] = mode[6] = mode[7] = false;
315 
316 
317  // *******
318  // COMPUTE
319  // *******
320 
321  for (int m=0; m<cm; m++) {
322  if (! mode[m]) continue;
323 
324  // vytvoreni 2d a 3d prikladu
325  if(m2d) eqiv_gener_2x2dI_2d (vtkAmndFile2d, Em, num, rs2, dx, Ei, nui, 1.0, 0.5, DT_NUMERICAL , m);
326  if(m3d) eqiv_gener_2x2dI_3d (vtkAmndFile3d, Em, num, rs3, dx, Ei, nui, 1.0, 0.5, DT_ANALITICAL, m);
327 
328  // GRAFY TISK - anasys
329  if (ANSYS) b = read_ansys_strain_stress_plot("x2d_2I/", 0, 'X', 0, -20.0, 20.0, true, false, true);
330  if (ANSYS) read_ansys_strain_stress_plot("x2d_2I/", 0, 'X', 0, -20.0, 20.0, false);
331  if (ANSYS) read_ansys_displ_plot ("x2d_2I/", 0, 'X', 0, -20.0, 20.0);
332 
333  // GRAFY TISK - mumech
334  if(m2d) { sprintf (suff, ".%02d.2d", m); print_graf(vtkAmndFile2d, "x2d_2I/", suff, 0, 'X', 0, -20.0, 20.0, 0.01, 't', 0, DT_NUMERICAL , b); }
335  if(m3d) { sprintf (suff, ".%02d.3d", m); print_graf(vtkAmndFile3d, "x2d_2I/", suff, 0, 'X', 0, -20.0, 20.0, 0.01, 't', 0, DT_ANALITICAL, b); }
336 
337  delete [] b; b = NULL;
338 
339  //Comparison::cmp_mm_ansys_total_energy("x2d_2I/", vtkAmndFile2d, 0);
340 
341 
342  // // debug
343  // Problem *p = new Problem;
344  // p->read_inclusions_plus_initialize_and_print (vtkAmndFile2d, NULL, DT_NUMERICAL);
345  //
346  // double coords[] = { 4.5, 0.0, 0.0};
347  // double **strain = AllocateArray2D(1,3);
348  // double **stress = AllocateArray2D(1,3);
349  // double **stress2 = AllocateArray2D(1,3);
350  // p->giveFieldsOfPoint(NULL,strain,stress,coords,'t',0,1,PFCM_FULL,-3, TVRN_THEORETICAL_FEEP);
351  // double C[5];
352  // p->give_inclusion(1)->give_StiffnessMatrixReduced(C);
353  // MatrixOperations::giveTVproduct_3is3x3to5and3(stress2[0], C, strain[0]);
354  //
355  // coords[1] = 0.0; // kvuli break pointu
356  //
357  // DeleteArray2D(strain,1);
358  // DeleteArray2D(stress,1);
359  // DeleteArray2D(stress2,1);
360  // // debug
361 
362  }
363 }
364 
365 
366 // 2d uloha, pravidelny grid kruhovych inkluzi "2n+1" x "2n+1".
367 void x2d_grid (void)
368 {
369  Bod* b = NULL;
370  char suff[100];
371  char vtkAmndFile2d [] = "x2d_grid/amnd.2d.vtk";
372  char vtkAmndFile3d [] = "x2d_grid/amnd.3d.vtk";
373 
374  // **************************************
375  // ZDE URCIT, CO SE BUDE POCITAT/TISKNOUT
376  // **************************************
377  //double angle = 0.0;// -> u gridu inkluzi je uhel vzdy 0.0
378  char xy[] = "XY"; // nebo treba "X-" "-Y" -> zatim jen X
379  int nlc = 1; if (nlc !=1 && nlc != 1) errol; // -> zatim jen 1 lc, 3 nlc viz x2d_1I
380  int ncomp = 3; if (ncomp<0 || ncomp>3) errol; // -> obvykle 3, at se tisknou vsechny slozky
381 
382  int nx = 2;
383  int ny = 2;
384  double dx = 1.5;
385 
386  double Em = 1.0, num = 0.2;
387  double Ei = 10.0, nui = 0.3; // 10.0 0.3
388  double rs2 [] = { 1.0, 0.0, 0.0, 0.0 };
389  double rs3 [] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
390 
391  //read_number_from_file (dx, "x2d_grid/dx.txt");
392  //read_number_from_file (Ei, "x2d_grid/Ei.txt");
393 
394  bool m2d = true;
395  bool m3d = false;
396  bool ANSYS = true; // void standa addext
397  bool mode[] = { false, false, true, false, false, false, false, false }; int cm = 8;
398 
399  // *******
400  // COMPUTE
401  // *******
402  for (int m=0; m<cm; m++) {
403  if (! mode[m]) continue;
404 
405  // vytvoreni 2d a 3d prikladu
406  if(m2d) eqiv_gener_gx2dI_2d (vtkAmndFile2d, 1+2*nx, 1+2*ny, 2*dx, 2*dx, Em, num, nlc == 1 ? rs2 : NULL, Ei, nui, 1.0, 1.0, DT_NUMERICAL , m);
407  if(m3d) eqiv_gener_gx2dI_3d (vtkAmndFile3d, 1+2*nx, 1+2*ny, 2*dx, 2*dx, Em, num, nlc == 1 ? rs3 : NULL, Ei, nui, 1.0, 1.0, DT_ANALITICAL, m);
408 
409  for (int i=0; i<nlc; i++) {
410  if (0) {
411  //double e2, e3;
412  Comparison::cmp_mm_ansys_total_energy("x2d_grid/", vtkAmndFile2d, 0);
413  //if (d3) e3 = Comparison::cmp_mm_ansys_total_energy("x2d_grid/ansys.IB", vtkAmndFile3d, "x2d_grid/ansys.IB.mesh.vtu", "x2d_grid/ansys.IB.rslt.vtu");
414 
415  //double vf = (PI*1.0*1.0) / (2*dx * 2*dx) * 100.0;
416  //vf = (vf < 10) ? ((int)vf*10)/10 : vf;
417 
418  //if (d2) { FILE *file = fopen("x2d_grid/energy_error_2d.dat", "a"); fprintf(file, "%lf %lf %g\n", 2*dx, e2, vf); fclose(file); }
419  //if (d3) { FILE *file = fopen("x2d_grid/energy_error_3d.dat", "a"); fprintf(file, "%lf %lf %g\n", 2*dx, e3, vf); fclose(file); }
420  }
421 
422  if (1) {
423  // loop over ncomp (number of components)
424  for (int j=0; j<ncomp; j++) {
425  // loop over axes
426  for (int k=0; k<2; k++) {
427  if (xy[k] == '-') continue;
428 
429  // GRAFY TISK - anasys
430  if (ANSYS) b = read_ansys_strain_stress_plot("x2d_grid/", i, xy[k], j==2 ? 3 : j, -20.0, 20.0, true, false, true);
431  if (ANSYS) read_ansys_strain_stress_plot("x2d_grid/", i, xy[k], j==2 ? 3 : j, -20.0, 20.0, false);
432  if (ANSYS && j<2) read_ansys_displ_plot ("x2d_grid/", i, xy[k], j==2 ? 3 : j, -20.0, 20.0);
433 
434  // GRAFY TISK - mumech
435  if(m2d) { sprintf (suff, ".%02d.2d", m); print_graf(vtkAmndFile2d, "x2d_grid/", suff, i, xy[k], j, -20.0, 20.0, 0.01, 't', 0, DT_NUMERICAL , b, true); }
436  if(m3d) { sprintf (suff, ".%02d.3d", m); print_graf(vtkAmndFile3d, "x2d_grid/", suff, i==2 ? 3 : i, xy[k], j==2 ? 3 : j, -20.0, 20.0, 0.01, 't', 0, DT_ANALITICAL, b, true); }
437 
438  // one
439  //eqiv_gener_1x2dI_3d (vtkAmndFile3d, 1.0, 0.2, rs3, 0.0, 0.0, 10.0, 0.4, 1.0, 1.0, 0.0, DT_ANALITICAL);
440  //print_graf(vtkAmndFile3d, "x2d_grid/", ".3dONE" , 'x', 0, -dx, dx, 0.01, 't', 20, DT_ANALITICAL);
441  }
442  }
443  }
444  }
445  }
446 }
447 
448 
449 
450 // --------------------------------------------------------
451 
452 
453 
454 
455 
456 
457 
458 // vzorovy 3d priklad o dvou inkluzich
459 void clanek_3d_vzor (void)
460 {
461  Problem *p = new Problem;
462  p->read_input_file("clanek/inhomogeneity.vtk");
465  p->print_equivalent_problem("clanek/equivalent.vtk");
466  delete p;
467  p = new Problem;
468  p->read_input_file("clanek/equivalent.vtk");
470  double coords[] = { 5.0, 2.0, 0.0};
471  double **stress = AllocateArray2D(2,9);
472  p->giveFieldsOfPoint(NULL,NULL,stress,coords,'p',0,2);
473  p->printFieldsOnMeshVTK("clanek/results.vtk","clanek/mesh.vtk",'t',2,1);
474 
475 
476  const double p1[] = {-4,-3,-3};
477  const double p2[] = { 5, 4, 3};
478  const long nn[] = {100,100,100};
479  p->printFieldsOnMeshGrid("clanek/results_grid.vtk", p1, p2, nn, 't', 0, 1, PFCM_FULL);
480  //p->compute_and_print_fields_on_regular_mesh((const double[]){-4,-3,-3}, (const double[]){5,4,3}, (const long[]){20,20,20}, "clanek/fields_reg.vtk", 0, 1, PFCM_OPTIMIZED, 't');
481 
482  // int hID = p->give_new_homogenization_id();
483  // p->homogenization(hID)->compute_fields_??? (TypeOfHomogenization);
484  // const double **field = p->homogenization(hID)->give_stress();
485  //p->print_equivalent_problem(vtkAmndFile);
486 
487 
488  p->print_visualization("clanek/visualization.vtk",5);
489  delete p;
490  DeleteArray2D(stress,2);
491 }
492 
494 {
495  char vtkAmndFile [] = "print/amnd2d.vtk";
496  char vtkMeshFileF [] = "print/meshF.2d.vtk";
497  //char vtkMeshFileX [] = "print/meshX.2d.vtk";
498 
499  double rs2 [] = { 1.0, 0.0, 0.0, 0.0 };
500  eqiv_gener_1x2dI_2d (vtkAmndFile, 1.0, 0.2, rs2, 0.0, 0.0, 10.0, 0.4, 1.0, 0.5, 0.0, DT_NUMERICAL);
501 
502  Problem *p = new Problem;
504 
505  p->print_visualization(vtkMeshFileF, 10, 2, true);
506  //p->print_geom(vtkMeshFileX, 10, 2, false);
507  delete p;
508 }
509 
511 {
512  char vtkAmndFile [] = "print/amnd.vtk";
513  char vtkMeshFileF [] = "print/meshF.vtk";
514  char vtkMeshFileX [] = "print/meshX.vtk";
515 
516  double rs [] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
517 
518  // ellipsoid Em num x y z E nu sa1 sa2 sa3 ea1 ea2 ea3
519  eqiv_gener_1x3dI (vtkAmndFile, 1.0, 0.4, rs, -2.0, 0.0, 0.0, 5.0, 0.4, 4.0, 0.9, 0.8, 0.0, 0.0, 0.0, DT_NUMERICAL);
520 
521  Problem *p = new Problem;
523 
524  p->print_visualization(vtkMeshFileF, 20, 3, true);
525  p->print_visualization(vtkMeshFileX, 20, 3, false);
526  delete p;
527 }
528 
529 // The most simple way to visualize input geometry.
531 {
532  Problem *p =new Problem;
533  p->set_matrix_E_nu(1.0, 0.25);
534  p->read_inclusions_plus_initialize_and_print("visualization/stackSmashing.geom.vtk", NULL, DT_ANALITICAL);
535  p->print_visualization("visualization/stackSmashing.topo.vtk", 4, 3);
536  delete p;
537 }
538 
539 
540 
541 // homogenizace - 2d uloha, pravidelny grid kruhovych inkluzi "2n+1" x "2n+1".
542 void clanek_homog_grid (void)
543 {
544  char vtkAmndFile2d [] = "clanek/grid.amnd.2d.vtk";
545 
546  int n = 3;
547  double dx = 1.6; // 1.2 1.6
548 
549  // vytvoreni 2d prikladu
550  eqiv_gener_gx2dI_2d (vtkAmndFile2d, 1+2*n, 1+2*n, 2*dx, 2*dx, 1.0, 0.2, NULL, 10.0, 0.3, 1.0, 1.0, DT_NUMERICAL , 5);
551 
552  Problem *p = new Problem;
553  Homogenization *h;
554 
555  double sm[3*3];
556  double p1[3]; p1[0] = -dx; p1[1] = -dx; p1[2] = 0.0;
557  double p2[3]; p2[0] = dx; p2[1] = dx; p2[2] = 0.0;
558 
559 
560  // ******
561  // 2D
562  // ******
563  // PROBLEM
564  p->read_input_file (vtkAmndFile2d);
566  //p->print_visualization("clanek/grid.2d.vtk", 5);
567  file_delete_if_exist(vtkAmndFile2d);
568 
569  // MESHES
570  // muMECH solution
571  long nn[3]; nn[0] = nn[1] = 80; nn[2] = 0;
572 
573  Mesh *meshMM = p->give_new_mesh();
574  meshMM->generate_regular_mesh (p1, p2, nn);
575  meshMM->compute_element_fields ('t', false, true, true, 0, 0, 0, PFCM_FULL); // false
576  //meshMM->print_geometry_file_vtk("clanek/bounding_boxde.vtk",0,1); // debug
577 
578 
579  // ANSYS solution
580  Mesh *meshAS = p->give_new_mesh();
581  meshAS->read_geometry_file_vtk ("clanek/homog_ansys/list.IB.rslt.lc0.vtu", 0, 0, false);
582  meshAS->read_geometry_file_vtk ("clanek/homog_ansys/list.IB.rslt.lc1.vtu", 0, 1, true);
583  meshAS->read_geometry_file_vtk ("clanek/homog_ansys/list.IB.rslt.lc2.vtu", 0, 2, true);
584 
585  FILE *file = fopen("clanek/grid.2d.txt", "w");
586 
587  // *** STANDARDNI HOMOGENIZACE ***
588  p->give_inclusion(0)->give_StiffnessMatrixFull(sm); fprintf (file, "%s:\t", "Inclusion" ); for (int i=0; i<9; i++) fprintf (file, " %15.8lf", sm[i]); fprintf (file, "\n");
589  h = p->give_new_homogenization (HT_VoightBound); h->set_boundingBox (p1, p2); h->find_inclusions_in_BB(); h->giveHomogenizedStiffnessMatrix (sm); fprintf (file, "%s:\t", h->giveClassName()); for (int i=0; i<9; i++) fprintf (file, " %15.8lf", sm[i]); fprintf (file, "\n");
590  h = p->give_new_homogenization (HT_RegGrid); ((RegGrid*)h)->set_mesh(meshMM); h->giveHomogenizedStiffnessMatrix (sm); fprintf (file, "%s:\t", h->giveClassName()); for (int i=0; i<9; i++) fprintf (file, " %15.8lf", sm[i]); fprintf (file, "\n");
591  h = p->give_new_homogenization (HT_RegGrid); ((RegGrid*)h)->set_mesh(meshAS); h->giveHomogenizedStiffnessMatrix (sm); fprintf (file, "%s:\t", h->giveClassName()); for (int i=0; i<9; i++) fprintf (file, " %15.8lf", sm[i]); fprintf (file, "\n");
592  h = p->give_new_homogenization (HT_MoriTanaka); h->set_boundingBox (p1, p2); h->find_inclusions_in_BB(); h->giveHomogenizedStiffnessMatrix (sm); fprintf (file, "%s:\t", h->giveClassName()); for (int i=0; i<9; i++) fprintf (file, " %15.8lf", sm[i]); fprintf (file, "\n");
593  h = p->give_new_homogenization (HT_Dilute); h->set_boundingBox (p1, p2); h->find_inclusions_in_BB(); h->giveHomogenizedStiffnessMatrix (sm); fprintf (file, "%s:\t\t", h->giveClassName()); for (int i=0; i<9; i++) fprintf (file, " %15.8lf", sm[i]); fprintf (file, "\n");
594  h = p->give_new_homogenization (HT_ReussBound); h->set_boundingBox (p1, p2); h->find_inclusions_in_BB(); h->giveHomogenizedStiffnessMatrix (sm); fprintf (file, "%s:\t", h->giveClassName()); for (int i=0; i<9; i++) fprintf (file, " %15.8lf", sm[i]); fprintf (file, "\n");
595  p->matrix_giveFullStiffMatrix(sm); fprintf (file, "%s:\t\t", "Matrix" ); for (int i=0; i<9; i++) fprintf (file, " %15.8lf", sm[i]); fprintf (file, "\n");
596 
597  double fv = h->giveTotalVolumeFractionOfInclusions();
598 
599 
600  fprintf (file, "Fraction volume: %6.2lf\n", 100*fv);
601  fclose(file);
602 
603  //
604  delete p;
605 }
606 
607 
608 
609 
610 
611 
617 void hrana_inkluze (void)
618 {
619  char vtkAmndFile [] = "hrana_inkluze/amnd.vtk";
620 
621  double rs [] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
622 
623  // ellipsoid Em num x y z E nu sa1 sa2 sa3 ea1 ea2 ea3
624  eqiv_gener_1x3dI (vtkAmndFile, 1.0, 0.4, rs, -2.0, 0.0, 0.0, 5.0, 0.4, 1.0, 0.9, 0.8, 0.0, 0.0, 0.0, DT_NUMERICAL);
625  print_graf(vtkAmndFile, "hrana_inkluze/", ".1I.ellipsoid.numer.3d", 0, 'x', 0, -3.12, -2.88, 0.01, 'p', 0, DT_NUMERICAL);
626  print_graf(vtkAmndFile, "hrana_inkluze/", ".1I.ellipsoid.anal.3d" , 0, 'x', 0, -3.12, -2.88, 0.01, 'p', 0, DT_ANALITICAL);
627 
628  // sphere Em num x y z E nu sa1 sa2 sa3 ea1 ea2 ea3
629  eqiv_gener_1x3dI (vtkAmndFile, 1.0, 0.4, rs, -2.0, 0.0, 0.0, 5.0, 0.4, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, DT_NUMERICAL);
630  print_graf(vtkAmndFile, "hrana_inkluze/", ".1I.sphere.numer.3d", 0, 'x', 0, -3.12, -2.88, 0.01, 'p', 0, DT_NUMERICAL);
631  print_graf(vtkAmndFile, "hrana_inkluze/", ".1I.sphere.anal.3d" , 0, 'x', 0, -3.12, -2.88, 0.01, 'p', 0, DT_ANALITICAL);
632 
633  // oblate spheroid Em num x y z E nu sa1 sa2 sa3 ea1 ea2 ea3
634  eqiv_gener_1x3dI (vtkAmndFile, 1.0, 0.4, rs, -2.0, 0.0, 0.0, 5.0, 0.4, 1.0, 1.0, 0.9, 0.0, 0.0, 0.0, DT_NUMERICAL);
635  print_graf(vtkAmndFile, "hrana_inkluze/", ".1I.oblatesph.numer.3d", 0, 'x', 0, -3.12, -2.88, 0.01, 'p', 0, DT_NUMERICAL);
636  print_graf(vtkAmndFile, "hrana_inkluze/", ".1I.oblatesph.anal.3d" , 0, 'x', 0, -3.12, -2.88, 0.01, 'p', 0, DT_ANALITICAL);
637 
638  // prolate spheroid Em num x y z E nu sa1 sa2 sa3 ea1 ea2 ea3
639  eqiv_gener_1x3dI (vtkAmndFile, 1.0, 0.4, rs, -2.0, 0.0, 0.0, 5.0, 0.4, 1.0, 0.9, 0.9, 0.0, 0.0, 0.0, DT_NUMERICAL);
640  print_graf(vtkAmndFile, "hrana_inkluze/", ".1I.prolatesph.numer.3d", 0, 'x', 0, -3.12, -2.88, 0.01, 'p', 0, DT_NUMERICAL);
641  print_graf(vtkAmndFile, "hrana_inkluze/", ".1I.prolatesph.anal.3d" , 0, 'x', 0, -3.12, -2.88, 0.01, 'p', 0, DT_ANALITICAL);
642 }
643 
644 
645 
646 
648 // **************************************** ENERGY **********************************************
650 
651 
652 
653 // **************************************************************************************************
654 // ************************************** KOMPLEXNI FUNKCE **************************************
655 // **************************************************************************************************
657 void compute_and_print_reg_mesh (const char *vtkGeomFile, const char *vtkMeshFileOutPert, double x, int n, char pt, DiffTypes dt)
658 {
659  Problem *p = new Problem;
660  p->read_inclusions_plus_initialize_and_print (vtkGeomFile, NULL, dt);
661 
662  // regular mesh
663  double p1[3] = {-x, -x, 0 };
664  double p2[3] = { x, x, 0 };
665  long nn[3] = { n, n, 0 };
666 
667  p->printFieldsOnMeshGrid(vtkMeshFileOutPert, p1, p2, nn, pt, 0, 0, PFCM_FULL);
668 
669  delete p;
670 }
671 
672 
673 
674 // **************************************************************************************************
675 // ********************************** GENEROVANI EQIV SOUBORU ***********************************
676 // **************************************************************************************************
677 
678 // generovani eqiv souboru s jednou 3d inkluzi
679 void eqiv_gener_1x3dI (const char *vtkAmndFile, double Em, double num, const double *rs,
680  double x, double y, double z, double E, double nu,
681  double a1, double a2, double a3, double ea1, double ea2, double ea3, DiffTypes dt)
682 {
683  Problem *p = new Problem;
684 
685  // ************** DATA INPUT VIA FUNCTIONS ******************
686  // problem
687  p->set_data_set();
688  p->set_dimension(3);
689  p->set_diffType(dt);
690  p->set_matrix_E_nu(Em, num);
691  //
693  p->set_RemoteStrain(0, rs);
694 
695  // inclusions
697  // first inclusion
698  p->set_inclusion_centroids(0, x, y, z);
699  p->set_inclusion_E_nu(0, E, nu);
700  p->set_inclusion_semiaxesDimensions(0, a1, a2, a3);
701  p->set_inclusion_EulerAnglesDEG(0, ea1, ea2, ea3);
702 
704  // ************** DATA INPUT VIA FUNCTIONS ******************
705 
707 
708  p->print_equivalent_problem(vtkAmndFile);
709 
710  delete p;
711 }
712 
713 
714 // generovani eqiv souboru s jednou 2d inkluzi pomoci 2d mumechu
715 void eqiv_gener_1x2dI_2d (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double y, double E, double nu, double a1, double a2, double ea, DiffTypes dt)
716 {
717  Problem *p = new Problem;
718 
719  // ************** DATA INPUT VIA FUNCTIONS ******************
720  // problem
721  p->set_data_set();
722  p->set_dimension(2);
723  p->set_diffType(dt);
724  p->set_matrix_E_nu(Em, num);
725  if (rs) { p->set_numberOfRemoteStrains(1);
726  p->set_RemoteStrain(0, rs); }
727  else p->set_UnitRemoteStrains();
728 
729  // inclusions
731  // first inclusion
732  p->set_inclusion_centroids(0, x, y);
733  p->set_inclusion_E_nu(0, E, nu);
734  p->set_inclusion_semiaxesDimensions(0, a1, a2);
736 
738  // ************** DATA INPUT VIA FUNCTIONS ******************
739 
741  p->print_visualization("vis.vtk",4);
742  p->print_equivalent_problem(vtkAmndFile);
743 
744  delete p;
745 }
746 
747 // generovani eqiv souboru s jednou 2d inkluzi pomoci 3d mumechu
748 void eqiv_gener_1x2dI_3d (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double y, double E, double nu, double a1, double a2, double ea, DiffTypes dt)
749 {
750  Problem *p = new Problem;
751 
752  // ************** DATA INPUT VIA FUNCTIONS ******************
753  // problem
754  p->set_data_set();
755  p->set_dimension(3);
756  p->set_diffType(dt);
757  p->set_matrix_E_nu(Em, num);
758  if (rs) { p->set_numberOfRemoteStrains(1);
759  p->set_RemoteStrain(0, rs); }
760  else p->set_UnitRemoteStrains();
761 
762  // inclusions
764  // first inclusion
765  p->set_inclusion_centroids(0, x, y, 0.0);
766  p->set_inclusion_E_nu(0, E, nu);
767  p->set_inclusion_semiaxesDimensions(0, 100.0*a1, a1, a2);
768  p->set_inclusion_EulerAnglesDEG(0, ea, 90.0, 90.0);
769 
771  // ************** DATA INPUT VIA FUNCTIONS ******************
772 
774 
775  p->print_equivalent_problem(vtkAmndFile);
776 
777  delete p;
778 }
779 
780 
782 void eqiv_gener_gx2dI_2d (const char *vtkAmndFile, int gx, int gy, double dx, double dy, double Em, double num, const double *rs, double E, double nu, double a1, double a2, DiffTypes dt, int mode)
783 {
784  Problem *p = new Problem;
785 
786  // ************** DATA INPUT VIA FUNCTIONS ******************
787  // problem
788  p->set_data_set();
789  p->set_dimension(2);
790  p->set_diffType(dt);
791  p->set_matrix_E_nu(Em, num);
792  //
793  if (rs) { p->set_numberOfRemoteStrains(1);
794  p->set_RemoteStrain(0, rs); }
795  else p->set_UnitRemoteStrains();
796 
797  // inclusions
798  p->set_number_of_inclusions(gx*gy);
799  long i, j, id;
800  id = 0;
801  for (i=0; i<gx; i++) {
802  for (j=0; j<gy; j++) {
803  p->set_inclusion_centroids(id, dx*(0.5*(gx-1)-i), dy*(0.5*(gy-1)-j));
804  p->set_inclusion_E_nu(id, E, nu);
805  p->set_inclusion_semiaxesDimensions(id, a1, a2);
806  p->set_inclusion_EulerAnglesDEG(id, 0.0);
807  id++;
808  }
809  }
810 
812  // ************** DATA INPUT VIA FUNCTIONS ******************
813 
814  p->set_SBA_optimized(false);
815 
816  modeset (p, mode);
817 
818  int na = 6;
819  p->set_problem_size( -dx*(0.5*gx - 0.5) - na*a1, -dy*(0.5*gy - 0.5) - na*a2, 0.0, dx*(0.5*gx - 0.5) + na*a1, dy*(0.5*gy - 0.5) + na*a2, 0.0, 0.05);
820 
822  p->print_equivalent_problem(vtkAmndFile);
823  p->print_visualization("vis2d.vtk", 4, 2);
824 
825  delete p;
826 }
827 //
828 void eqiv_gener_gx2dI_3d (const char *vtkAmndFile, int gx, int gy, double dx, double dy, double Em, double num, const double *rs, double E, double nu, double a1, double a2, DiffTypes dt, int mode)
829 {
830  Problem *p = new Problem;
831 
832  // ************** DATA INPUT VIA FUNCTIONS ******************
833  // problem
834  p->set_data_set();
835  p->set_dimension(3);
836  p->set_diffType(dt);
837  p->set_matrix_E_nu(Em, num);
838  //
839  if (rs) { p->set_numberOfRemoteStrains(1);
840  p->set_RemoteStrain(0, rs); }
841  else p->set_UnitRemoteStrains();
842 
843  // inclusions
844  p->set_number_of_inclusions(gx*gy);
845  long i, j, id;
846  id = 0;
847  for (i=0; i<gx; i++) {
848  for (j=0; j<gy; j++) {
849  p->set_inclusion_centroids(id, dx*(0.5*(gx-1)-i), dy*(0.5*(gy-1)-j), 0.0);
850  p->set_inclusion_E_nu(id, E, nu);
851  p->set_inclusion_semiaxesDimensions(id, 100*a1, a1, a2);
852  p->set_inclusion_EulerAnglesDEG(id, 0.0, 90.0, 90.0);
853  id++;
854  }
855  }
856 
858  // ************** DATA INPUT VIA FUNCTIONS ******************
859 
860  p->set_SBA_optimized(false);
861 
862  modeset (p, mode);
863 
865  p->print_equivalent_problem(vtkAmndFile);
866  //p->print_visualization("vis3d.vtk", 4, 3);
867 
868  delete p;
869 }
870 
871 //
872 void eqiv_gener_2x2dI_3d (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double E, double nu, double a1, double a2, DiffTypes dt, int mode)
873 {
874  Problem *p = new Problem;
875 
876  // ************** DATA INPUT VIA FUNCTIONS ******************
877  // problem
878  p->set_data_set();
879  p->set_dimension(3);
880  p->set_diffType(dt);
881  p->set_matrix_E_nu(Em, num);
882  //
884  p->set_RemoteStrain(0, rs);
885 
886  // loop over all inclusions
888  // first inclusion
889  p->set_inclusion_centroids(0, -x, 0.0, 0.0);
890  p->set_inclusion_E_nu(0, E, nu);
891  p->set_inclusion_semiaxesDimensions(0, 100*a1, a1, a2);
892  p->set_inclusion_EulerAnglesDEG(0, 0.0, 90.0, 90.0);
893  // second inclusion
894  p->set_inclusion_centroids(1, x, 0.0, 0.0);
895  p->set_inclusion_E_nu(1, E, nu);
896  p->set_inclusion_semiaxesDimensions(1, 100*a1, a1, a2);
897  p->set_inclusion_EulerAnglesDEG(1, 0.0, 90.0, 90.0);
898 
900  // ************** DATA INPUT ******************
901 
902  p->set_SBA_optimized(false);
903 
904  modeset (p, mode);
905 
907 
908  p->print_equivalent_problem(vtkAmndFile);
909 
910  delete p;
911 }
912 
913 //
914 void eqiv_gener_2x2dI_2d (const char *vtkAmndFile, double Em, double num, const double *rs, double x, double E, double nu, double a1, double a2, DiffTypes dt, int mode)
915 {
916  Problem *p = new Problem;
917 
918  // ************** DATA INPUT ******************
919  // START - DATA INPUT VIA FUNCTIONS
920  // do not change the order of command
921 
922  // set problem
923  p->set_data_set();
924  p->set_dimension(2);
925  p->set_diffType(dt);
926  p->set_matrix_E_nu(Em, num);
927  //
929  p->set_RemoteStrain(0, rs);
930 
931  // loop over all inclusions
933  // first inclusion
934  p->set_inclusion_centroids(0, -x, 0.0);
935  p->set_inclusion_E_nu(0, E, nu);
936  p->set_inclusion_semiaxesDimensions(0, a1, a2);
937  p->set_inclusion_EulerAnglesDEG(0, 0.0);
938  // second inclusion
939  p->set_inclusion_centroids(1, x, 0.0);
940  p->set_inclusion_E_nu(1, E, nu);
941  p->set_inclusion_semiaxesDimensions(1, a1, a2);
942  p->set_inclusion_EulerAnglesDEG(1, 0.0);
943 
945  // ************** DATA INPUT ******************
946 
947  modeset (p, mode);
948  p->set_SBA_optimized(false);
950 
951  p->print_equivalent_problem(vtkAmndFile);
952 
953  delete p;
954 }
955 
956 
958 void modeset (Problem *p, int mode)
959 {
960  if (mode == 0) { p->set_intFieldsShape(4); p->set_SBAM(SBAT_ORIGINAL); } // puvodni balancing
961  else if (mode == 1) { p->set_intFieldsShape(3); p->set_SBAM(SBAT_ORIGINAL); } // puvodni balancing s addExt
962  else if (mode == 2) { p->set_intFieldsShape(4); p->set_SBAM(SBAT_VOID); } // zadny balancing
963  else if (mode == 3) { p->set_intFieldsShape(3); p->set_SBAM(SBAT_VOID); } // zadny balancing s addExt
964  else if (mode == 4) { p->set_intFieldsShape(4); p->set_SBAM(SBAT_STANDA); }
965  else if (mode == 5) { p->set_intFieldsShape(0); p->set_SBAM(SBAT_STANDA); }
966  else if (mode == 6) { p->set_intFieldsShape(2); p->set_SBAM(SBAT_MESHLESS); }
967  else if (mode == 7) { p->set_intFieldsShape(0); p->set_SBAM(SBAT_MESHLESS); }
968  else errol;
969 }
970 
971 
973 void print_graf (const char *vtkGeomFile, const char *path, const char *suff, int lc, char axe, int comp, double coordMin, double coordMax, double coordDelta, char pt_flag, double dshift, DiffTypes dt, Bod *b, bool odd)
974 {
975  bool adapt = true;
976 
977  if (coordMin >= coordMax) errol;
978 
979  double *d = new double[9]; CleanVector(d, 9);
980  double *e = new double[9];
981  double *s = new double[9];
982 
983  Problem *p = new Problem;
984  p->read_inclusions_plus_initialize_and_print (vtkGeomFile, NULL, dt);
985 
986  //
987  int cind;
988  if (axe == 'X') cind = 0;
989  else if (axe == 'Y') cind = 1;
990  else if (axe == 'Z') cind = 2;
991  else errol;
992 
993  double coords[] = { 0.0, 0.0, 0.0 };
994  coords[cind] = coordMin;
995  long n=0;
996 
997  char name[100];
998 
999  // 2D: predpoklad natvrdo, ze graf se tiskne na 2d uloze (pocitana muze byt i 3d mumechem)
1000  bool D = comp >1 ? false : true;
1001 
1002  // 2D: predpoklad natvrdo, ze graf se tiskne na 2d uloze (pocitana muze byt i 3d mumechem)
1003  FILE * fileD; sprintf(name, "%sgraf_lc%d_%c_displc_%d%s.dat", path, lc == 3 ? 2 : lc, axe, comp, suff); if (D) OpenFile(fileD, name, _WRITE_);
1004  FILE * fileE; sprintf(name, "%sgraf_lc%d_%c_strain_%d%s.dat", path, lc == 3 ? 2 : lc, axe, comp == 3 ? 2 : comp, suff); OpenFile(fileE, name, _WRITE_);
1005  FILE * fileS; sprintf(name, "%sgraf_lc%d_%c_stress_%d%s.dat", path, lc == 3 ? 2 : lc, axe, comp == 3 ? 2 : comp, suff); OpenFile(fileS, name, _WRITE_);
1006 
1007  if (b) {
1008  long i= 0;
1009  bool out = ! odd;
1010  do {
1011  if (b[i].coord[cind] < coordMin || coordMax < b[i].coord[cind]) continue;
1012  for (int aa=0; aa<2; aa++) {
1013  p->giveFieldsOfPointOneRS(d, e, s, b[i].coord, pt_flag, lc, PFCM_FULL, out ? -1 : -2, STRN_VOIGT_FEEP);
1014 
1015  if (aa==0 && D) fprintf (fileD, "%lf\t%lf\n", b[i].coord[cind], d[comp] + dshift);
1016  ; fprintf (fileE, "%lf\t%lf\n", b[i].coord[cind], e[comp]);
1017  ; fprintf (fileS, "%lf\t%lf\n", b[i].coord[cind], s[comp]);
1018 
1019  if (b[i].mat[0] != 0 && b[i].mat[1] != 0 && b[i].mat[0] != b[i].mat[1]) { // pokud bod obsahuje dva materialy
1020  if (b[i].mat[0] > 9 && b[i].mat[1] > 9) break; // oba materialy jsou matrice, tj. maji cisla vetsi nez 9
1021  if(aa==0) out = out ? false : true;
1022  }
1023  else {
1024  break;
1025  }
1026  }
1027  }
1028  while (b[i++].last != true);
1029  }
1030  else {
1031  double toler = 1.e-3;
1032  if (3*toler > coordDelta) toler = 0.2 * coordDelta;
1033  long pic_old, pic, picreq; // parent incl id
1034  pic_old = -1;
1035  picreq = -2;
1036  bool doublep = false;
1037  //double c1;
1038 
1039  while (coords[cind] - coordMax < 0.1*coordDelta ) {
1040  if (!doublep)
1041  pic = p->give_inclusion_with_point_inside (coords, ((pic_old == -1) ? 1.0 : -1.0) * toler);
1042  else
1043  doublep = false;
1044 
1045  picreq = pic;
1046  // prekrocil jsem hranici inkluze ...
1047  if (pic != pic_old) {
1048  // ... smerem dovnitr inkluze
1049  if (pic_old == -1) {
1050  if ( p->give_inclusion(pic )->point_is_inside (coords, -1 * toler) == false) {
1051  picreq = pic_old;
1052  doublep = true;
1053  }
1054  }
1055  // ... smerem ven z inkluze
1056  else {
1057  if ( p->give_inclusion(pic_old)->point_is_inside (coords, toler) == true ) {
1058  picreq = pic_old;
1059  doublep = true;
1060  }
1061  }
1062  }
1063  pic_old = pic;
1064 
1065  p->giveFieldsOfPointOneRS(d, e, s, coords, pt_flag, lc, PFCM_FULL, picreq, STRN_VOIGT_FEEP);
1066 
1067  if (D) fprintf (fileD, "%lf\t%lf\n", coords[cind], d[comp] + dshift);
1068  ; fprintf (fileE, "%lf\t%lf\n", coords[cind], e[comp]);
1069  ; fprintf (fileS, "%lf\t%lf\n", coords[cind], s[comp]);
1070 
1071  if (!doublep) {
1072  if (!adapt) coords[cind] = coordMin + (++n)*coordDelta;
1073  else coords[cind] += coordDelta;
1074  }
1075  //c1 = coords[0];
1076 
1077  picreq = -2;
1078  }
1079  }
1080 
1081  if (D) CloseFile(fileD);
1082  CloseFile(fileE);
1083  CloseFile(fileS);
1084 
1085  delete p;
1086 
1087  delete [] d;
1088  delete [] e;
1089  delete [] s;
1090 }
1091 
1092 // **************************************************************************************************
1093 // ************************************ ANSYS POSTPROCESSING ************************************
1094 // **************************************************************************************************
1095 
1096 bool compare_x(Bod const& first, Bod const& second) { return first.coord[0] < second.coord[0]; }
1097 bool compare_y(Bod const& first, Bod const& second) { return first.coord[1] < second.coord[1]; }
1098 
1100 Bod* read_ansys_strain_stress_plot (const char *path, int lc, char axe, int comp, double coordMin, double coordMax, bool strn, bool half, bool bod)
1101 {
1102  char name[1000];
1103  long i, j, nNodes;
1104  Bod * Res;
1105  FILE *file;
1106 
1107  // nacti souradnice
1108  sprintf (name, "%sANSYS/rslts_lc%d/list.%c.nodes.txt", path, lc, axe);
1109  file = _openFileN("r", "ansys coords file", name);
1110 
1111  FP_skip_line(file);
1112  FP_skip_expected_string(file, " *GET NNODE FROM NODE ITEM=COUN VALUE=", true);
1113  fscanf(file, "%ld", &nNodes);
1114  FP_skip_line(file, 3);
1115 
1116  Res = new Bod[nNodes];
1117  memset(Res, 0, nNodes*sizeof(Bod));
1118 
1119  for (i = 0; i < nNodes; i++) {
1120  if (i % 50 == 0)
1121  FP_skip_line(file, 11);
1122 
1123  fscanf(file, "%d", &Res[i].ID);
1124  fscanf(file, "%lf %lf %lf", &Res[i].coord[0], &Res[i].coord[1], &Res[i].coord[2]);
1125  }
1126 
1127  fclose(file);
1128 
1129 
1130  // nacti vysledky
1131  sprintf (name, "%sANSYS/rslts_lc%d/list.%c.%s.txt", path, lc, axe, strn ? "strain" : "stress");
1132  file = _openFileN("r", "ansys result file", name);
1133 
1134  int current_mat;
1135 
1136  FP_skip_to_line_starting_with(file, "NODAL RESULTS ARE FOR MATERIAL", true);
1137  fscanf(file, "%d", &current_mat);
1138  FP_skip_line(file, 5);
1139 
1140  int current_node;
1141  char c;
1142 
1143  while (true) { // podle poctu uzlu
1144  c = fgetc(file);
1145  if (c == ' ') {
1146  fscanf(file, "%d", &current_node); // kontroluju jestli radek zacina cislem
1147  for (i = 0; i < nNodes; i++) { // cyklus pres vsechny body
1148  if (current_node == Res[i].ID) { // kdyz se shoduje ID
1149  int pos = 0;
1150  if (Res[i].mat[0] != 0) {
1151  if (Res[i].mat[1] != 0) errol;
1152  pos = 1;
1153  }
1154 
1155  Res[i].mat[pos] = current_mat;
1156  for (j = 0; j < 6; j++)
1157  fscanf(file, "%lf", &Res[i].rslt[pos][j]);
1158  break;
1159  }
1160  }
1161  if (i == nNodes)
1162  errol;
1163 
1164  FP_skip_line(file);
1165  }
1166  else if (c == '1') {
1167  FP_skip_to_line_starting_with(file, "NODAL RESULTS ARE FOR MATERIAL", true);
1168  fscanf(file, "%d", &current_mat);
1169  FP_skip_line(file, 5);
1170  }
1171  else
1172  break;
1173  }
1174 
1175  fclose(file);
1176 
1177  int coord_index;
1178  if (axe == 'X') { coord_index = 0; std::sort(Res, Res + nNodes, &compare_x); }
1179  else if (axe == 'Y') { coord_index = 1; std::sort(Res, Res + nNodes, &compare_y); }
1180  else errol;
1181 
1182  // tiskni graf
1183  sprintf (name, "%sgraf_lc%d_%c_%s_%d.ansys.dat", path, lc, axe, strn ? "strain" : "stress", comp == 3 ? 2 : comp);
1184  file = _openFileN("w", "plot file", name);
1185 
1186  int cind;
1187  if (axe == 'X') cind = 0;
1188  else if (axe == 'Y') cind = 1;
1189  else if (axe == 'Z') cind = 2;
1190  else errol;
1191 
1192  for (i = 0; i < nNodes; i++) {
1193  if (Res[i].coord[cind] < coordMin || coordMax < Res[i].coord[cind]) continue;
1194 
1195  if (Res[i].mat[0] != 0 && Res[i].mat[1] != 0) { // pokud bod obsahuje dva materialy
1196 
1197  // kdyz predchozi bod.material na prvni pozici neni nula vytisknu nejdriv pro prvni material a pak pro druhy
1198  if (Res[i - 1].mat[0] == Res[i].mat[0]) {
1199  fprintf(file, "%lf\t%lf\n", Res[i].coord[coord_index], Res[i].rslt[0][comp]);
1200  fprintf(file, "%lf\t%lf\n", Res[i].coord[coord_index], Res[i].rslt[1][comp]);
1201  }
1202  // kdyz predchozi bod.material na druhe pozici neni nula vytisknu nejdriv pro druhy material a pak pro prvni
1203  else if (Res[i - 1].mat[0] == Res[i].mat[1]) {
1204  fprintf(file, "%lf\t%lf\n", Res[i].coord[coord_index], Res[i].rslt[1][comp]);
1205  fprintf(file, "%lf\t%lf\n", Res[i].coord[coord_index], Res[i].rslt[0][comp]);
1206  }
1207  else errol;
1208  }
1209  else { // kdyz bod neobsahuje dva materialy
1210  if (Res[i].mat[0]) // kdyz je to material 1
1211  fprintf(file, "%lf\t%lf\n", Res[i].coord[coord_index], Res[i].rslt[0][comp]);
1212  else if (Res[i].mat[1]) // kdyz je to material 2
1213  fprintf(file, "%lf\t%lf\n", Res[i].coord[coord_index], Res[i].rslt[1][comp]);
1214  else
1215  errol;
1216  }
1217  }
1218 
1219  fclose(file);
1220 
1221  Bod *b = NULL;
1222  int nn;
1223  if (bod) {
1224  if (half) nn = nNodes-1;
1225  else nn = 0;
1226 
1227  b = new Bod[nNodes + nn];
1228  memcpy (b+nn, Res, sizeof(Bod));
1229 
1230  for (i = 1; i < nNodes; i++) {
1231  ; memcpy (b+nn+i, Res+i, sizeof(Bod));
1232  if (half) { memcpy (b+nn-i, Res+i, sizeof(Bod));
1233  b[nn-i].coord[coord_index] *= -1; }
1234  }
1235 
1236  b[nn + nNodes-1].last = true;
1237  }
1238 
1239  delete [] Res;
1240 
1241  return b;
1242 }
1243 
1244 void read_ansys_displ_plot (const char *path, int lc, char axe, int comp, double coordMin, double coordMax)
1245 {
1246  char name[1000];
1247  long i, j, nNodes;
1248  Bod * Res;
1249  FILE *file;
1250 
1251  // nacti souradnice
1252  sprintf (name, "%sANSYS/rslts_lc%d/list.%c.nodes.txt", path, lc, axe);
1253  file = _openFileN("r", "ansys coords file", name);
1254 
1255  FP_skip_line(file);
1256  FP_skip_expected_string(file, " *GET NNODE FROM NODE ITEM=COUN VALUE=", true);
1257  fscanf(file, "%ld", &nNodes);
1258  FP_skip_line(file, 3);
1259 
1260  Res = new Bod[nNodes];
1261  memset(Res, 0, nNodes*sizeof(Bod));
1262 
1263  for (i = 0; i < nNodes; i++) {
1264  if (i % 50 == 0)
1265  FP_skip_line(file, 11);
1266 
1267  fscanf(file, "%d", &Res[i].ID);
1268  fscanf(file, "%lf %lf %lf", &Res[i].coord[0], &Res[i].coord[1], &Res[i].coord[2]);
1269  }
1270 
1271  fclose(file);
1272 
1273 
1274  // nacti vysledky
1275  sprintf (name, "%sANSYS/rslts_lc%d/list.%c.%s.txt", path, lc, axe, "displ");
1276  file = _openFileN("r", "ansys result file", name);
1277 
1278  FP_skip_to_line_starting_with(file, "NODE UX UY UZ USUM ", true);
1279  FP_skip_line(file);
1280 
1281  int current_node;
1282  char c;
1283 
1284  while (true) { // podle poctu uzlu
1285  c = fgetc(file);
1286  if (c == ' ') {
1287  fscanf(file, "%d", &current_node); // kontroluju jestli radek zacina cislem
1288  for (i = 0; i < nNodes; i++) { // cyklus pres vsechny body
1289  if (current_node == Res[i].ID) { // kdyz se shoduje ID
1290 
1291  for (j = 0; j < 4; j++)
1292  fscanf(file, "%lf", &Res[i].disp[j]);
1293  break;
1294  }
1295  }
1296  if (i == nNodes)
1297  errol;
1298 
1299  FP_skip_line(file);
1300  }
1301  else if (c == '1') {
1302  FP_skip_to_line_starting_with(file, "NODE UX UY UZ USUM ", true);
1303  FP_skip_line(file);
1304  }
1305  else
1306  break;
1307  }
1308 
1309  fclose(file);
1310 
1311  int coord_index;
1312  if (axe == 'X') { coord_index = 0; std::sort(Res, Res + nNodes, &compare_x); }
1313  else if (axe == 'Y') { coord_index = 1; std::sort(Res, Res + nNodes, &compare_y); }
1314  else errol;
1315 
1316  // tiskni graf
1317  sprintf (name, "%sgraf_lc%d_%c_%s_%d.ansys.dat", path, lc, axe, "displc", comp);
1318  file = _openFileN("w", "plot file", name);
1319 
1320  int cind;
1321  if (axe == 'X') cind = 0;
1322  else if (axe == 'Y') cind = 1;
1323  else if (axe == 'Z') cind = 2;
1324  else errol;
1325 
1326  for (i = 0; i < nNodes; i++) {
1327  if (Res[i].coord[cind] < coordMin || coordMax < Res[i].coord[cind]) continue;
1328 
1329  fprintf(file, "%lf\t%lf\n", Res[i].coord[coord_index], Res[i].disp[comp]);
1330  }
1331 
1332  fclose(file);
1333 
1334  delete [] Res;
1335 
1336  return;
1337 }
1338 
1339 
1341 void speedtest2Dx3D(void){
1342  int i, j;
1343  double ax[3];
1344  ax[0] = 50.;
1345  ax[1] = 1.;
1346  ax[2] = 0.5;
1347  double r1 = ax[1] * 1.01;
1348  double r2 = ax[1] * 4.5;
1349  double dr = ax[1] * 0.005;
1350  int boduu = round((r2 - r1) / dr + 1);
1351  int bodu = 360 * boduu;
1352  double **points2D;
1353  double **points3D;
1354  points2D = new double*[bodu];
1355  points3D = new double*[bodu];
1356  for (i = 0; i < bodu; i++)points2D[i] = new double[3];
1357  for (i = 0; i < bodu; i++)points3D[i] = new double[3];
1358  for (i = 0; i < 360; i++)for (j = 0; j < boduu; j++){
1359  points2D[i * boduu + j][0] = (r1 + dr*j)*cos(PI*i / 180);
1360  points2D[i * boduu + j][1] = (r1 + dr*j)*sin(PI*i / 180);
1361  points2D[i * boduu + j][2] = 0.;
1362  points3D[i * boduu + j][0] = 0.;
1363  points3D[i * boduu + j][1] = (r1 + dr*j)*cos(PI*i / 180);
1364  points3D[i * boduu + j][2] = (r1 + dr*j)*sin(PI*i / 180);
1365  }
1366  /*double a = ax[1]*3.;
1367  double da = ax[1]*0.01;
1368  int bodu = round((2 * a / da + 1)*(2 * a / da + 1));
1369  int bodusqrt = round(2 * a / da + 1);
1370  double **points2D;
1371  double **points3D;
1372  points2D = new double*[bodu];
1373  points3D = new double*[bodu];
1374  for (i = 0; i < bodu; i++)points2D[i] = new double[3];
1375  for (i = 0; i < bodu; i++)points3D[i] = new double[3];
1376  for (i = 0; i < bodusqrt; i++)for (j = 0; j < bodusqrt; j++){
1377  points2D[i*bodusqrt + j][0] = da*(i - a / da);
1378  points2D[i*bodusqrt + j][1] = da*(j - a / da);
1379  points2D[i*bodusqrt + j][2] = 0.;
1380  points3D[i*bodusqrt + j][0] = 0.;
1381  points3D[i*bodusqrt + j][1] = da*(i - a / da);
1382  points3D[i*bodusqrt + j][2] = da*(j - a / da);
1383  }*/
1384  Problem *analFce2D, *analFce3D;
1385 
1386  int nlc = 1;
1387 
1388  double **strain_2D;
1389  strain_2D = new double*[nlc];
1390  for (i = 0; i < nlc; i++)strain_2D[i] = new double[4];
1391  double **stress_2D;
1392  stress_2D = new double*[nlc];
1393  for (i = 0; i < nlc; i++)stress_2D[i] = new double[4];
1394  double **disp_2D;
1395  disp_2D = new double*[nlc];
1396  for (i = 0; i < nlc; i++)disp_2D[i] = new double[2];
1397 
1398  double **strain_3D;
1399  strain_3D = new double*[nlc];
1400  for (i = 0; i < nlc; i++)strain_3D[i] = new double[9];
1401  double **stress_3D;
1402  stress_3D = new double*[nlc];
1403  for (i = 0; i < nlc; i++)stress_3D[i] = new double[9];
1404  double **disp_3D;
1405  disp_3D = new double*[nlc];
1406  for (i = 0; i < nlc; i++)disp_3D[i] = new double[3];
1407  //int _2D[] = { 0, 3, 1 };
1408  //int _3D[] = { 4, 8, 5 };
1409  clock_t ta, tb;
1410  double times[4];
1411  double rs2D[] = { 1.0, 0.0, 0.0, 0.0 };
1412  double rs3D[] = { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 };
1413  //rozjezd
1414 
1415  //2D
1416  printf("Starting the measurement...\n");
1417  analFce2D = new Problem();
1418 
1419  analFce2D->set_dimension(2);
1420  analFce2D->set_number_of_inclusions(1);
1421  analFce2D->set_inclusion_shape(0, IS_ELLIPSE);
1422  analFce2D->set_inclusion_centroids(0, 0, 0);
1423  analFce2D->set_inclusion_E_nu(0, 2.4, 0.3);
1424  analFce2D->set_inclusion_EulerAnglesDEG(0, 30);
1425  analFce2D->set_inclusion_semiaxesDimensions(0, ax[1], ax[2]);
1426  //analFce2D->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, 1., 0.5, 0, 30, 0, 0);
1427  analFce2D->set_numberOfRemoteStrains(1);
1428  analFce2D->set_RemoteStrain(0, rs2D);
1429  analFce2D->set_data_set();
1430 
1431  analFce2D->set_SBA_optimized(true);
1432  analFce2D->set_diffType(DT_NUMERICAL);
1434  analFce2D->convert_to_equivalent_problem();
1435  for (i = 0; i < bodu; i++)analFce2D->giveFieldsOfPoint(disp_2D, strain_2D, stress_2D, points2D[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1436  delete analFce2D;
1437 
1438  //zacatek mereni
1439 
1440  //2D
1441  printf("Measuring 2D numerical diff...\n");
1442  analFce2D = new Problem();
1443 
1444  analFce2D->set_dimension(2);
1445  analFce2D->set_number_of_inclusions(1);
1446  analFce2D->set_inclusion_shape(0, IS_ELLIPSE);
1447  analFce2D->set_inclusion_centroids(0, 0, 0);
1448  analFce2D->set_inclusion_E_nu(0, 2.4, 0.3);
1449  analFce2D->set_inclusion_EulerAnglesDEG(0, 30);
1450  analFce2D->set_inclusion_semiaxesDimensions(0, ax[1], ax[2]);
1451  //analFce2D->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, 1., 0.5, 0, 30, 0, 0);
1452  analFce2D->set_numberOfRemoteStrains(1);
1453  analFce2D->set_RemoteStrain(0, rs2D);
1454  analFce2D->set_data_set();
1455 
1456  analFce2D->set_SBA_optimized(true);
1457  analFce2D->set_diffType(DT_NUMERICAL);
1459  analFce2D->convert_to_equivalent_problem();
1460  ta = clock();
1461  for (i = 0; i < bodu; i++)analFce2D->giveFieldsOfPoint(disp_2D, strain_2D, stress_2D, points2D[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1462  tb = clock();
1463  delete analFce2D;
1464  times[0] = (tb - ta) / (double)CLOCKS_PER_SEC;
1465  printf("It took %.2lf seconds.\n", times[0]);
1466 
1467  //3D
1468  printf("Measuring 3D numerical diff...\n");
1469  analFce3D = new Problem();
1470 
1471  analFce3D->set_dimension(3);
1472  analFce3D->set_number_of_inclusions(1);
1473  analFce3D->set_inclusion_shape(0, IS_ELLIPSOID);
1474  analFce3D->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, ax[0], ax[1], ax[2], 0, 30, 0);
1475  analFce3D->set_numberOfRemoteStrains(1);
1476  analFce3D->set_RemoteStrain(0, rs3D);
1477  analFce3D->set_data_set();
1478 
1479  analFce3D->set_SBA_optimized(true);
1480  analFce3D->set_diffType(DT_NUMERICAL);
1482  analFce3D->convert_to_equivalent_problem();
1483  ta = clock();
1484  for (i = 0; i < bodu; i++)analFce3D->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points3D[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1485  tb = clock();
1486  delete analFce3D;
1487  times[1] = (tb - ta) / (double)CLOCKS_PER_SEC;
1488  printf("It took %.2lf seconds.\n", times[1]);
1489 
1490  //3D
1491  printf("Measuring 3D analytical diff...\n");
1492  analFce3D = new Problem();
1493 
1494  analFce3D->set_dimension(3);
1495  analFce3D->set_number_of_inclusions(1);
1496  analFce3D->set_inclusion_shape(0, IS_ELLIPSOID);
1497  analFce3D->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, ax[0], ax[1], ax[2], 0, 30, 0);
1498  analFce3D->set_numberOfRemoteStrains(1);
1499  analFce3D->set_RemoteStrain(0, rs3D);
1500  analFce3D->set_data_set();
1501 
1502  analFce3D->set_SBA_optimized(true);
1503  analFce3D->set_diffType(DT_ANALITICAL);
1505  analFce3D->convert_to_equivalent_problem();
1506  ta = clock();
1507  for (i = 0; i < bodu; i++)analFce3D->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points3D[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1508  tb = clock();
1509  delete analFce3D;
1510  times[2] = (tb - ta) / (double)CLOCKS_PER_SEC;
1511  printf("It took %.2lf seconds.\n", times[2]);
1512 
1513  //3D
1514  printf("Measuring 3D complex diff...\n");
1515  analFce3D = new Problem();
1516 
1517  analFce3D->set_dimension(3);
1518  analFce3D->set_number_of_inclusions(1);
1519  analFce3D->set_inclusion_shape(0, IS_ELLIPSOID);
1520  analFce3D->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, ax[0], ax[1], ax[2], 0, 30, 0);
1521  analFce3D->set_numberOfRemoteStrains(1);
1522  analFce3D->set_RemoteStrain(0, rs3D);
1523  analFce3D->set_data_set();
1524 
1525  analFce3D->set_SBA_optimized(true);
1526  analFce3D->set_diffType(DT_COMPLEX);
1528  analFce3D->convert_to_equivalent_problem();
1529  ta = clock();
1530  for (i = 0; i < bodu; i++)analFce3D->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points3D[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1531  tb = clock();
1532  delete analFce3D;
1533  times[3] = (tb - ta) / (double)CLOCKS_PER_SEC;
1534  printf("It took %.2lf seconds.\n", times[3]);
1535 
1536  //konec mereni -> prehled vysledku
1537  double ref = times[2];
1538  printf("\n2D ND: %.1lf\n3D ND: %.1lf\n3D AD: %.1lf\n3D CD: %.1lf\n", times[0] / ref * 100, times[1] / ref * 100, times[2] / ref * 100, times[3] / ref * 100);
1539 }
1541 void createNodes(double a, double b, double c, double da, double db, double dc,double **&points,int &n) {
1542  int i,ia,ib,ic;
1543  int na, nb, nc;
1544  na = round((2.*a / da + 1));
1545  nb = round((2.*b / db + 1));
1546  nc = round((2.*c / dc + 1));
1547  n = na*nb*nc;
1548  points = new double*[n];
1549  for (i = 0; i < n; i++)points[i] = new double[3];
1550  int id = 0;
1551  for (ia = 0; ia < na; ia++)for (ib = 0; ib < nb; ib++)for (ic = 0; ic < nc; ic++) {
1552  points[id][0] = -a + ia*da;
1553  points[id][1] = -b + ib*db;
1554  points[id][2] = -c + ic*dc;
1555  id++;
1556  }
1557 }
1559 void test3D(void) {
1560 
1561 
1562 
1563  int i, j, bodu;
1564  double **points;
1565  Problem *analFce;
1566  int nlc = 1;
1567  double a = 10., b = 10., c = 10., da = .5, db = .5, dc = .5;
1568  // enum DiffTypes { DT_Void, DT_ANALITICAL, DT_NUMERICAL, DT_COMPLEX };
1569  DiffTypes difftype = DT_NUMERICAL;
1570 
1571 
1572 
1573  double **strain_3D;
1574  strain_3D = new double*[nlc];
1575  for (i = 0; i < nlc; i++)strain_3D[i] = new double[9];
1576  double **stress_3D;
1577  stress_3D = new double*[nlc];
1578  for (i = 0; i < nlc; i++)stress_3D[i] = new double[9];
1579  double **disp_3D;
1580  disp_3D = new double*[nlc];
1581  for (i = 0; i < nlc; i++)disp_3D[i] = new double[3];
1582  clock_t ta, tb;
1583  //double times[4];
1584  double rs3D[] = { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 };
1585 
1586  if (difftype == DT_NUMERICAL)printf("NUMERICAL DIFF\n");
1587  if (difftype == DT_ANALITICAL)printf("ANALYTICAL DIFF\n");
1588  if (difftype == DT_COMPLEX)printf("COMPLEX DIFF\n");
1589 
1590  //3D Ellipsoid
1591  createNodes(a,b,c,da,db,dc, points, bodu);
1592  printf("Computing 3D Ellipsoid...\n");
1593  analFce = new Problem();
1594  analFce->set_dimension(3);
1595  analFce->set_number_of_inclusions(1);
1596  analFce->set_inclusion_shape(0, IS_ELLIPSOID);
1597  analFce->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, 8., 5., 4., 20., 30., 50.);
1598  analFce->set_numberOfRemoteStrains(1);
1599  analFce->set_RemoteStrain(0, rs3D);
1600  analFce->set_data_set();
1601  analFce->set_SBA_optimized(true);
1602  analFce->set_diffType(difftype);
1604  analFce->convert_to_equivalent_problem();
1605  for (i = 0; i < bodu; i++)analFce->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1606  delete analFce;
1607  for (i = 0; i < bodu; i++)delete []points[i];
1608  delete[]points;
1609 
1610  //3D Sphere
1611  createNodes(a, b, c, da, db, dc, points, bodu);
1612  printf("Computing 3D Sphere...\n");
1613  analFce = new Problem();
1614  analFce->set_dimension(3);
1615  analFce->set_number_of_inclusions(1);
1616  analFce->set_inclusion_shape(0, IS_SPHERE);
1617  analFce->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, 5., 5., 5., 20., 30., 50.);
1618  analFce->set_numberOfRemoteStrains(1);
1619  analFce->set_RemoteStrain(0, rs3D);
1620  analFce->set_data_set();
1621  analFce->set_SBA_optimized(true);
1622  analFce->set_diffType(difftype);
1624  analFce->convert_to_equivalent_problem();
1625  for (i = 0; i < bodu; i++)analFce->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1626  delete analFce;
1627  for (i = 0; i < bodu; i++)delete[]points[i];
1628  delete[]points;
1629 
1631  //createNodes(a, b, c, da, db, dc, points, bodu);
1632  //printf("Computing 3D Ellyptic cylinder...\n");
1633  //analFce = new Problem();
1634  //analFce->set_dimension(3);
1635  //analFce->set_number_of_inclusions(1);
1636  //analFce->set_inclusion_shape(0, IS_ELLIPTIC_CYLINDER);
1637  //analFce->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, INFTY, 5., 2., 20., 30., 50.);
1638  //analFce->set_numberOfRemoteStrains(1);
1639  //analFce->set_RemoteStrain(0, rs3D);
1640  //analFce->set_data_set();
1641  //analFce->set_SBA_optimized(true);
1642  //analFce->set_diffType(difftype);
1643  //analFce->input_data_initialize_and_check_consistency();
1644  //analFce->convert_to_equivalent_problem();
1645  //for (i = 0; i < bodu; i++)analFce->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1646  //delete analFce;
1647  //for (i = 0; i < bodu; i++)delete[]points[i];
1648  //delete[]points;
1649 
1651  //createNodes(a, b, c, da, db, dc, points, bodu);
1652  //printf("Computing 3D Cylinder...\n");
1653  //analFce = new Problem();
1654  //analFce->set_dimension(3);
1655  //analFce->set_number_of_inclusions(1);
1656  //analFce->set_inclusion_shape(0, IS_CYLINDER);
1657  //analFce->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, INFTY, 5., 5., 20., 30., 50.);
1658  //analFce->set_numberOfRemoteStrains(1);
1659  //analFce->set_RemoteStrain(0, rs3D);
1660  //analFce->set_data_set();
1661  //analFce->set_SBA_optimized(true);
1662  //analFce->set_diffType(difftype);
1663  //analFce->input_data_initialize_and_check_consistency();
1664  //analFce->convert_to_equivalent_problem();
1665  //for (i = 0; i < bodu; i++)analFce->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1666  //delete analFce;
1667  //for (i = 0; i < bodu; i++)delete[]points[i];
1668  //delete[]points;
1669 
1670  //3D Oblate spheroid
1671  createNodes(a, b, c, da, db, dc, points, bodu);
1672  printf("Computing 3D Oblate spheroid...\n");
1673  analFce = new Problem();
1674  analFce->set_dimension(3);
1675  analFce->set_number_of_inclusions(1);
1677  analFce->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, 5., 5., 2., 20., 30., 50.);
1678  analFce->set_numberOfRemoteStrains(1);
1679  analFce->set_RemoteStrain(0, rs3D);
1680  analFce->set_data_set();
1681  analFce->set_SBA_optimized(true);
1682  analFce->set_diffType(difftype);
1684  analFce->convert_to_equivalent_problem();
1685  for (i = 0; i < bodu; i++)analFce->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1686  delete analFce;
1687  for (i = 0; i < bodu; i++)delete[]points[i];
1688  delete[]points;
1689 
1690  //3D Prolate spheroid
1691  createNodes(a, b, c, da, db, dc, points, bodu);
1692  printf("Computing 3D Prolate spheroid...\n");
1693  analFce = new Problem();
1694  analFce->set_dimension(3);
1695  analFce->set_number_of_inclusions(1);
1697  analFce->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, 8., 5., 5., 20., 30., 50.);
1698  analFce->set_numberOfRemoteStrains(1);
1699  analFce->set_RemoteStrain(0, rs3D);
1700  analFce->set_data_set();
1701  analFce->set_SBA_optimized(true);
1702  analFce->set_diffType(difftype);
1704  analFce->convert_to_equivalent_problem();
1705  for (i = 0; i < bodu; i++)analFce->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1706  delete analFce;
1707  for (i = 0; i < bodu; i++)delete[]points[i];
1708  delete[]points;
1709 
1711  //createNodes(a, b, c, da, db, dc, points, bodu);
1712  //printf("Computing 3D Flat ellipsoid...\n");
1713  //analFce = new Problem();
1714  //analFce->set_dimension(3);
1715  //analFce->set_number_of_inclusions(1);
1716  //analFce->set_inclusion_shape(0, IS_FLAT_ELLIPSOID);
1717  //analFce->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, 5., 3., 0., 20., 30., 50.);
1718  //analFce->set_numberOfRemoteStrains(1);
1719  //analFce->set_RemoteStrain(0, rs3D);
1720  //analFce->set_data_set();
1721  //analFce->set_SBA_optimized(true);
1722  //analFce->set_diffType(difftype);
1723  //analFce->input_data_initialize_and_check_consistency();
1724  //analFce->convert_to_equivalent_problem();
1725  //for (i = 0; i < bodu; i++)analFce->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1726  //delete analFce;
1727  //for (i = 0; i < bodu; i++)delete[]points[i];
1728  //delete[]points;
1729 
1731  //createNodes(a, b, c, da, db, dc, points, bodu);
1732  //printf("Computing 3D Penny...\n");
1733  //analFce = new Problem();
1734  //analFce->set_dimension(3);
1735  //analFce->set_number_of_inclusions(1);
1736  //analFce->set_inclusion_shape(0, IS_PENNY);
1737  //analFce->set_inclusion_all(0, 0, 0, 0, 2.4, 0.3, 5., 5., 0., 20., 30., 50.);
1738  //analFce->set_numberOfRemoteStrains(1);
1739  //analFce->set_RemoteStrain(0, rs3D);
1740  //analFce->set_data_set();
1741  //analFce->set_SBA_optimized(true);
1742  //analFce->set_diffType(difftype);
1743  //analFce->input_data_initialize_and_check_consistency();
1744  //analFce->convert_to_equivalent_problem();
1745  //for (i = 0; i < bodu; i++)analFce->giveFieldsOfPoint(disp_3D, strain_3D, stress_3D, points[i], 'p', 0, nlc, PFCM_OPTIMIZED);
1746  //delete analFce;
1747  //for (i = 0; i < bodu; i++)delete[]points[i];
1748  //delete[]points;
1749 
1750  /*
1751  IS_ELLIPSOID = 1, IS_SPHERE = 2,
1752  IS_OBLATE_SPHEROID = 8, IS_PROLATE_SPHEROID = 9,
1753  IS_ELLIPTIC_CYLINDER = 3, IS_CYLINDER = 4,
1754  IS_PENNY = 5,
1755  IS_FLAT_ELLIPSOID = 7,
1756  */
1757 }
1758 
1759 
1760 
1761 
1762 
1763 
1764 
1765 
1766 
1767 
1768 
1769 
1770 // ***********************************************************************************************************************
1771 // *********************************** INTERSECTION ******************************************************************
1772 // ***********************************************************************************************************************
1774 void intersection_3d_core (double c1x, double c1y, double c1z, double a1x, double a1y, double a1z, double e1x, double e1y, double e1z,
1775  double c2x, double c2y, double c2z, double a2x, double a2y, double a2z, double e2x, double e2y, double e2z,
1776  bool expected, bool ee, const char *s)
1777 {
1778  Problem *p = new Problem;
1779 
1780  // ************** DATA INPUT VIA FUNCTIONS ******************
1781  // problem
1782  p->set_data_set ();
1783  p->set_dimension (3);
1785  p->set_matrix_E_nu (1.0, 0.4);
1786  double rs [] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
1788  p->set_RemoteStrain (0, rs);
1789 
1790  // inclusions
1791  p->set_number_of_inclusions (2); // id coordinates E nu semiaxes eAngles
1792  p->set_inclusion_all (0, c1x, c1y, c1z, 5.0, 0.4, a1x, a1y, a1z, e1x, e1y, e1z);
1793  p->set_inclusion_all (1, c2x, c2y, c2z, 5.0, 0.4, a2x, a2y, a2z, e2x, e2y, e2z);
1794 
1796  // ************** DATA INPUT VIA FUNCTIONS ******************
1797 
1799  p->print_visualization("intersection_3d_visualization_DELETE.vtk", 12);
1800 
1801  int result = MesoFace::ellipsoids_overlap ( p->give_inclusion(0), p->give_inclusion(1) );
1802 
1803  if (result == -1) {
1804  if (ee == false || (ee == true && expected == false)) {
1805  printf (" NOT CONVERGED %s", s);
1806  return;
1807  }
1808  }
1809  else {
1810  if ((bool)result != expected) {
1811  printf (" \nERRORR - expectation of overlap is %s\n", expected ? "YES" : "NO");
1812  return;
1813  }
1814  }
1815 
1816  printf (" OK%s", s);
1817 
1818  //get_confirm ("run visualization", true);
1819 
1820  delete p;
1821 }
1822 
1823 // 2d uloha pocitana 2d a 3d mumechem, postupna rotace inkluze, tisk hodnot v jednom bode
1824 // Pokud je 3d uloha derivovana numericky, vysledna krivka je zubata.
1825 // Pokud je 3d uloha derivovana analyticky, vysledna krivka je hladka.
1827 {
1828  int i, k;
1829  Problem *analFce2D, *analFce3D;
1830 
1831  const double rs2d[] = { 1.0, 0.0, 0.0, 0.0 };
1832  const double rs3d[] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
1833 
1834  double *point = new double[3];
1835  point[0] = 3.5;
1836  point[1] = 1.5;
1837  point[2] = 0.;
1838 
1839  double *displc_2D = new double[2]; double *displc_3D = new double[3];
1840  double *strain_2D = new double[4]; double *strain_3D = new double[9];
1841  double *stress_2D = new double[4]; double *stress_3D = new double[9];
1842 
1843  int _2D[] = { 0, 3, 1 };
1844  int _3D[] = { 0, 4, 1 };
1845 
1846  double **results = NULL;
1847  AllocateArray2D(results, 181, 16);
1848 
1849  DiffTypes dt2d = DT_NUMERICAL;
1850  DiffTypes dt3d = DT_NUMERICAL;
1851 
1852  char vtkAmndFile2d [] = "rotation/amnd.2d.vtk";
1853  char vtkAmndFile3d [] = "rotation/amnd.3d.vtk";
1854  for (int ii = 0; ii <= 180; ii++){
1855  // vytvoreni prikladu
1856  eqiv_gener_1x2dI_2d (vtkAmndFile2d, 1.0, 0.4, rs2d, 0.0, 0.0, 2.4, 0.3, 1.0, 0.5, ii*1.0, dt2d);
1857  eqiv_gener_1x2dI_3d (vtkAmndFile3d, 1.0, 0.4, rs3d, 0.0, 0.0, 2.4, 0.3, 1.0, 0.5, ii*1.0, dt3d);
1858 
1859  analFce2D = (new Problem())->read_inclusions_plus_initialize_and_print (vtkAmndFile2d, NULL, dt2d);
1860  analFce3D = (new Problem())->read_inclusions_plus_initialize_and_print (vtkAmndFile3d, NULL, dt3d);
1861 
1862  analFce2D->giveFieldsOfPointOneRS(displc_2D, strain_2D, stress_2D, point, 'p', 0, PFCM_OPTIMIZED);
1863  analFce3D->giveFieldsOfPointOneRS(displc_3D, strain_3D, stress_3D, point, 'p', 0, PFCM_OPTIMIZED);
1864 
1865  for (k = 0; k < 3; k++){
1866  results[ii][2 * k ] = strain_2D[_2D[k]];
1867  results[ii][2 * k + 1] = strain_3D[_3D[k]];
1868  }
1869  for (k = 0; k < 3; k++){
1870  results[ii][2 * k + 6] = stress_2D[_2D[k]];
1871  results[ii][2 * k + 7] = stress_3D[_3D[k]];
1872  }
1873  for (k = 0; k < 2; k++){
1874  results[ii][2 * k + 12] = displc_2D[k];
1875  results[ii][2 * k + 13] = displc_3D[k];
1876  }
1877  delete analFce2D;
1878  delete analFce3D;
1879  }
1880  int index;
1881  char name[10], filename2d[25], filename3d[25];
1882  // 0-2 strain, 3-5 stress, 6-7 displacement
1883  for (index = 0; index < 8; index++) {
1884  if (index == 0) sprintf(name, "strain1");
1885  if (index == 1) sprintf(name, "strain2");
1886  if (index == 2) sprintf(name, "strain3");
1887  if (index == 3) sprintf(name, "stress1");
1888  if (index == 4) sprintf(name, "stress2");
1889  if (index == 5) sprintf(name, "stress3");
1890  if (index == 6) sprintf(name, "disp1");
1891  if (index == 7) sprintf(name, "disp2");
1892  FILE *o2, *o3;
1893  sprintf (filename2d, "./rotation/%s.2d.dat", name);
1894  sprintf (filename3d, "./rotation/%s.3d.dat", name);
1895  o2 = fopen(filename2d, "wt");
1896  o3 = fopen(filename3d, "wt");
1897  for (i = 0; i <= 180; i++) {
1898  fprintf(o2, "%d %.14lf\n", i, results[i][2 * index ]);
1899  fprintf(o3, "%d %.14lf\n", i, results[i][2 * index + 1]);
1900  }
1901  fclose(o2);
1902  fclose(o3);
1903  }
1904 }
1905 
1906 
1908 void intersection_3d_core_6 (double cx, double cy, double cz,
1909  double a1x, double a1y, double a1z, double g1x, double g1y, double g1z, double e1x, double e1y, double e1z,
1910  double a2x, double a2y, double a2z, double g2x, double g2y, double g2z, double e2x, double e2y, double e2z)
1911 {
1912  double e = 0.01 * (a1y+a2y)/2.0;
1913 
1914  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1915  cx + (g1x+g2x ), cy , cz , a2x,a2y,a2z, e2x,e2y,e2z, true , true, ""); // endik
1916  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1917  cx + (g1x+g2x+e), cy , cz , a2x,a2y,a2z, e2x,e2y,e2z, false, true, ""); // endik
1918  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1919  cx - (g1x+g2x ), cy , cz , a2x,a2y,a2z, e2x,e2y,e2z, true , true, ""); // endik
1920  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1921  cx - (g1x+g2x+e), cy , cz , a2x,a2y,a2z, e2x,e2y,e2z, false, true, " "); // endik
1922 
1923  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1924  cx , cy + (g1y+g2y ), cz , a2x,a2y,a2z, e2x,e2y,e2z, true , true, ""); // endik
1925  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1926  cx , cy + (g1y+g2y+e), cz , a2x,a2y,a2z, e2x,e2y,e2z, false, true, ""); // endik
1927  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1928  cx , cy - (g1y+g2y ), cz , a2x,a2y,a2z, e2x,e2y,e2z, true , true, ""); // endik
1929  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1930  cx , cy - (g1y+g2y+e), cz , a2x,a2y,a2z, e2x,e2y,e2z, false, true, " "); // endik
1931 
1932  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1933  cx , cy , cz + (g1z+g2z ), a2x,a2y,a2z, e2x,e2y,e2z, true , true, ""); // endik
1934  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1935  cx , cy , cz + (g1z+g2z+e), a2x,a2y,a2z, e2x,e2y,e2z, false, true, ""); // endik
1936  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1937  cx , cy , cz - (g1z+g2z ), a2x,a2y,a2z, e2x,e2y,e2z, true , true, ""); // endik
1938  intersection_3d_core (cx , cy , cz , a1x,a1y,a1z, e1x,e1y,e1z,
1939  cx , cy , cz - (g1z+g2z+e), a2x,a2y,a2z, e2x,e2y,e2z, false, true, " \n"); // endik
1940 }
1941 // Prvni inkluze ma dane pootoceni, pootoceni druhe je zde generovano, pokud predpokladam uhel 90, tak je pouze 6 pozic.
1942 void intersection_3d_core_6x6 (double cx, double cy, double cz,
1943  double a1x, double a1y, double a1z, double g1x, double g1y, double g1z, double e1x, double e1y, double e1z,
1944  double a2x, double a2y, double a2z)
1945 {
1946  intersection_3d_core_6 (cx,cy,cz, a1x,a1y,a1z, g1x,g1y,g1z, e1x,e1y,e1z, a2x,a2y,a2z, a2x, a2y, a2z, 0.0, 0.0, 0.0);
1947  intersection_3d_core_6 (cx,cy,cz, a1x,a1y,a1z, g1x,g1y,g1z, e1x,e1y,e1z, a2x,a2y,a2z, a2y, a2x, a2z, 0.0, 0.0, 90.0);
1948  intersection_3d_core_6 (cx,cy,cz, a1x,a1y,a1z, g1x,g1y,g1z, e1x,e1y,e1z, a2x,a2y,a2z, a2y, a2z, a2x, 0.0, 90.0, 90.0);
1949  intersection_3d_core_6 (cx,cy,cz, a1x,a1y,a1z, g1x,g1y,g1z, e1x,e1y,e1z, a2x,a2y,a2z, a2x, a2z, a2y, 0.0, 90.0, 0.0);
1950  intersection_3d_core_6 (cx,cy,cz, a1x,a1y,a1z, g1x,g1y,g1z, e1x,e1y,e1z, a2x,a2y,a2z, a2z, a2x, a2y, 90.0, 90.0, 0.0);
1951  intersection_3d_core_6 (cx,cy,cz, a1x,a1y,a1z, g1x,g1y,g1z, e1x,e1y,e1z, a2x,a2y,a2z, a2z, a2y, a2x, 90.0, 90.0, 90.0);
1952 }
1953 // Prvni inkluze pootoceni je zde generovano, pokud predpokladam uhel 90, tak je pouze 6 pozic.
1954 void intersection_3d_core_6x6x6 (double cx, double cy, double cz,
1955  double a1x, double a1y, double a1z,
1956  double a2x, double a2y, double a2z)
1957 {
1958  intersection_3d_core_6x6 (cx,cy,cz, a1x,a1y,a1z, a1x, a1y, a1z, 0.0, 0.0, 0.0, a2x,a2y,a2z);
1959  intersection_3d_core_6x6 (cx,cy,cz, a1x,a1y,a1z, a1y, a1x, a1z, 0.0, 0.0, 90.0, a2x,a2y,a2z);
1960  intersection_3d_core_6x6 (cx,cy,cz, a1x,a1y,a1z, a1y, a1z, a1x, 0.0, 90.0, 90.0, a2x,a2y,a2z);
1961  intersection_3d_core_6x6 (cx,cy,cz, a1x,a1y,a1z, a1x, a1z, a1y, 0.0, 90.0, 0.0, a2x,a2y,a2z);
1962  intersection_3d_core_6x6 (cx,cy,cz, a1x,a1y,a1z, a1z, a1x, a1y, 90.0, 90.0, 0.0, a2x,a2y,a2z);
1963  intersection_3d_core_6x6 (cx,cy,cz, a1x,a1y,a1z, a1z, a1y, a1x, 90.0, 90.0, 90.0, a2x,a2y,a2z);
1964 }
1965 
1967 void intersection_3d (void)
1968 {
1969  printf ("\n TOOLS - 3D intersection:\n");
1970 
1971  double cx = 0.0, cy = 0.0, cz = 0.0; // shift origin both inclusions
1972  double a1x = 3.0, a1y = 2.0, a1z = 1.0; // 1. inclusion semiaxes
1973  double a2x = 3.0, a2y = 2.0, a2z = 1.0; // 2. inclusion semiaxes
1974 
1975  // 6x6x6 prikladu - dve elipsy se dotykaji nebo tesne nedotykaji ve vrcholech
1976  // Vypada to, ze pokud lokalni osa x jedne elipsy miri do stredu druhe a elipsy se dotykaji v bode tak to obcas nedokonverguje.
1977  // Toto se bude dit tak vzacne, asi, ze tam proste hodim error natvrdo a uvidime.
1978  // V tomto prikladu 6x6x6 se s tim pocita (ee == true) a chyba je potlacena, v jinych prikladech nedokonvergovani hodi error.
1979  intersection_3d_core_6x6x6(cx,cy,cz, a1x,a1y,a1z, a2x,a2y,a2z);
1980 
1981  //
1982  intersection_3d_core (cx , cy , cz , 3.0, 2.0, 1.0, 0.0, 0.0, 0.0,
1983  cx + 4.24 , cy + 2.0, cz + 1.0, 3.0, 2.0, 1.0, 0.0, 0.0, 0.0, true , false, "\n"); // endik
1984  intersection_3d_core (cx , cy , cz , 3.0, 2.0, 1.0, 0.0, 0.0, 0.0,
1985  cx + 4.26 , cy + 2.0, cz + 1.0, 3.0, 2.0, 1.0, 0.0, 0.0, 0.0, false, false, "\n"); // endik
1986 
1987  //
1988  intersection_3d_core (cx , cy , cz , 3.0, 2.0, 2.0, 30.0, 45.0, 17.0,
1989  cx + 4.35 , cy + 2.0, cz + 1.0, 2.0, 2.0, 2.0, 0.0, 0.0, 0.0, true , false, "\n"); // endik
1990  intersection_3d_core (cx , cy , cz , 3.0, 2.0, 2.0, 30.0, 45.0, 17.0,
1991  cx + 4.40 , cy + 2.0, cz + 1.0, 2.0, 2.0, 2.0, 0.0, 0.0, 0.0, false, false, "\n"); // endik
1992 
1993 
1994  //
1995  intersection_3d_core (cx , cy , cz , 3.0, 2.0, 1.0, 90.0, 90.0, 90.0,
1996  cx + 1.68 , cy + 2.0, cz + 1.0, 3.0, 2.0, 1.0, 90.0, 90.0, 90.0, true , false, "\n"); // endik
1997  intersection_3d_core (cx , cy , cz , 3.0, 2.0, 1.0, 90.0, 90.0, 90.0,
1998  cx + 1.70 , cy + 2.0, cz + 1.0, 3.0, 2.0, 1.0, 90.0, 90.0, 90.0, false, false, "\n"); // endik
1999 
2000 
2001 
2002  printf("\n\n");
2003 }
2004 
2005 
2007 void intersection_2d_core (double c1x, double c1y, double a1x, double a1y, double e1,
2008  double c2x, double c2y, double a2x, double a2y, double e2,
2009  bool expected, const char *s)
2010 {
2011  Problem *p = new Problem;
2012 
2013  // ************** DATA INPUT VIA FUNCTIONS ******************
2014  // problem
2015  p->set_data_set ();
2016  p->set_dimension (2);
2017 
2018  p->set_matrix_E_nu (2.0, 0.2);
2019  double rs [] = { 1.0, 0.0, 0.0, 0.0 };
2021  p->set_RemoteStrain (0, rs);
2022 
2023  // inclusions
2024  p->set_number_of_inclusions (2); // id coords E nu semiaxes eAngle
2025  p->set_inclusion_all (0, c1x, c1y, 1.0, 0.1, a1x, a1y, e1);
2026  p->set_inclusion_all (1, c2x, c2y, 1.0, 0.1, a2x, a2y, e2);
2027 
2029  // ************** DATA INPUT VIA FUNCTIONS ******************
2030 
2032  p->print_visualization("intersection_2d_visualization_DELETE.vtk", 20);
2033 
2034  bool result = MesoFace::ellipses_overlap (p->give_inclusion (0), p->give_inclusion (1));
2035 
2036  if (result != expected) {
2037  printf (" \nERRORR - expectation of overlap is %s\n", expected ? "YES" : "NO");
2038  return;
2039  }
2040 
2041  printf (" OK%s", s);
2042 
2043  delete p;
2044 }
2046 void intersection_2d_core_4 (double cx, double cy,
2047  double a1x, double a1y, double g1x, double g1y, double e1,
2048  double a2x, double a2y, double g2x, double g2y, double e2)
2049 {
2050  double e = 0.01 * (a1y+a2y)/2.0;
2051 
2052  intersection_2d_core (cx , cy , a1x,a1y, e1,
2053  cx + (g1x+g2x ), cy , a2x,a2y, e2, true , ""); // endik
2054  intersection_2d_core (cx , cy , a1x,a1y, e1,
2055  cx + (g1x+g2x+e), cy , a2x,a2y, e2, false, ""); // endik
2056  intersection_2d_core (cx , cy , a1x,a1y, e1,
2057  cx - (g1x+g2x ), cy , a2x,a2y, e2, true , ""); // endik
2058  intersection_2d_core (cx , cy , a1x,a1y, e1,
2059  cx - (g1x+g2x+e), cy , a2x,a2y, e2, false, " "); // endik
2060 
2061  intersection_2d_core (cx , cy , a1x,a1y, e1,
2062  cx , cy + (g1y+g2y ), a2x,a2y, e2, true , ""); // endik
2063  intersection_2d_core (cx , cy , a1x,a1y, e1,
2064  cx , cy + (g1y+g2y+e), a2x,a2y, e2, false, ""); // endik
2065  intersection_2d_core (cx , cy , a1x,a1y, e1,
2066  cx , cy - (g1y+g2y ), a2x,a2y, e2, true , ""); // endik
2067  intersection_2d_core (cx , cy , a1x,a1y, e1,
2068  cx , cy - (g1y+g2y+e), a2x,a2y, e2, false, " "); // endik
2069 
2070 }
2071 
2072 //
2073 void intersection_2d (void)
2074 {
2075  printf ("\n TOOLS - 2D intersection:\n");
2076 
2077  double cx = 0.0, cy = 0.0; // shift origin both inclusions
2078  double a1x = 5.0, a1y = 2.0; // 1. inclusion semiaxes
2079  double a2x = 4.0, a2y = 1.5; // 2. inclusion semiaxes
2080 
2081  // 2x2x4 prikladu - dve elipsy se dotykaji nebo tesne nedotykaji ve vrcholech
2082  intersection_2d_core_4 (cx, cy, a1x, a1y, a1x, a1y, 0.0, a2x, a2y, a2x, a2y, 0.0);
2083  intersection_2d_core_4 (cx, cy, a1x, a1y, a1x, a1y, 0.0, a2x, a2y, a2y, a2x, 90.0);
2084  intersection_2d_core_4 (cx, cy, a1x, a1y, a1y, a1x, 90.0, a2x, a2y, a2x, a2y, 0.0);
2085  intersection_2d_core_4 (cx, cy, a1x, a1y, a1y, a1x, 90.0, a2x, a2y, a2y, a2x, 90.0);
2086 
2087  //
2088  intersection_2d_core (cx , cy , a1x,a1y, 0.0,
2089  cx - 4.62, cy + 3.0, a2x,a2y, 0.0, true , "\n"); // endik
2090  intersection_2d_core (cx , cy , a1x,a1y, 0.0,
2091  cx - 4.66, cy + 3.0, a2x,a2y, 0.0, false, "\n"); // endik
2092 
2093  intersection_2d_core (cx , cy , a1x,a1y, 90.0,
2094  cx - 3.952, cy + 2.0, a2x,a2y, 110.0, true , "\n"); // endik
2095  intersection_2d_core (cx , cy , a1x,a1y, 90.0,
2096  cx - 3.952, cy + 2.0, a2x,a2y, 109.0, false, "\n"); // endik
2097 
2098  intersection_2d_core (cx , cy , a1x,a1y, 90.0,
2099  cx - 4.50, cy + 2.0, a2x,a2y, 40.0, true , "\n"); // endik
2100  intersection_2d_core (cx , cy , a1x,a1y, 90.0,
2101  cx - 4.52, cy + 2.0, a2x,a2y, 40.0, false, "\n"); // endik
2102 
2103  printf("\n\n");
2104 }
2105 
2106 // XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX
2107 // Tisk grafu ovlivneni, viz p->give_ovlivneni (x, result)
2108 void ovlivneni (void)
2109 {
2110  //char vtkAmndFile [] = "ovlivneni_jednaInkluze.amnd.vtk";
2111 
2112  Problem *p;
2113  p = new Problem();
2114 
2115  // ************** DATA INPUT ******************
2116  // set problem
2117  p->set_data_set();
2118  p->set_dimension(3);
2120  p->set_matrix_E_nu(1.0, 0.4);
2121  //
2123  double rs1 [] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
2124  p->set_RemoteStrain(0, rs1);
2125 
2126  // loop over all inclusions
2128 
2129  // first inclusion
2130  p->give_inclusion(0)->set_centroids(0.0, 0.0, 0.0);
2132  p->give_inclusion(0)->set_Youngs_modulus(10.0);
2133  p->give_inclusion(0)->set_Poissons_ratio(0.4);
2134  p->give_inclusion(0)->set_Semiaxes_dimensions(1.2, 1.0, 1.0);
2135  p->give_inclusion(0)->set_Euller_angles_deg(0.0, 90.0, 90.0);
2136 
2138  // ************** DATA INPUT ******************
2139 
2140  p->set_SBA_optimized(false);
2142 
2143  long i;
2144 
2145  // menit dle libosti
2146  double minCoord = -4.0;
2147  double maxCoord = 4.0;
2148  double step = 0.1;
2149  double x[3];
2150  double result[6] = { 0., 0., 0., 0., 0., 0. };
2151 
2152  FILE * out1 = NULL;
2153  FILE * out2 = NULL;
2154  char name[100];
2155 
2156 
2157  for (i = 0; i < 2; i++) { // over X & Y
2158  sprintf(name, "pokus_graf_2.0_X_%02ld.dat", i); OpenFile(out1, name, _WRITE_);
2159  sprintf(name, "pokus_graf_2.0_Y_%02ld.dat", i); OpenFile(out2, name, _WRITE_);
2160 
2161  double coord = minCoord;
2162 
2163  while (coord <= maxCoord) { // over points
2164  x[0] = x[1] = x[2] = 0.0;
2165  x[i] = coord;
2166 
2167  p->give_ovlivneni (x, result);
2168 
2169  fprintf(out1, "%e\t%e\n", x[i], result[0]);
2170  fprintf(out2, "%e\t%e\n", x[i], result[1]);
2171 
2172  coord += step;
2173 
2174  } // end of while loop over points
2175 
2176  CloseFile(out1);
2177  CloseFile(out2);
2178  } // end of for loop over X & Y
2179 
2180  delete p;
2181 
2182  return;
2183 }
2184 
2185 /*end of file*/
DiffTypes
Definition: types.h:672
void set_Euller_angles_deg(double x)
Definition: inclusion.cpp:239
void set_centroids(double x, double y)
Definition: inclusion.cpp:235
void input_data_initialize_and_check_consistency(void)
Initializes and checks consistency of all input data. This function has to be called after data input...
Definition: problem.cpp:127
void generate_regular_mesh(const double *p1, const double *p2, const long *n)
Generate regular mesh geometry of rectangular cuboid shape compound of rectangular cuboid shape eleme...
Definition: mesh.cpp:260
bool point_is_inside(const double *coords, double epsilon=0.0) const
Function returns the position of a given point related to an inclusion.
Definition: inclusion.cpp:329
bool FP_skip_expected_string(FILE *src, const char *expctd, bool cs)
... word and compare with expected one
Definition: librw.cpp:475
void set_dimension(int d)
Definition: problem.h:109
Galerkin...
Definition: types.h:92
file of various types and symbolic constant definitions
void modeset(Problem *p, int mode)
bool compare_x(Bod const &first, Bod const &second)
void createNodes(double a, double b, double c, double da, double db, double dc, double **&points, int &n)
void clanek_homog_grid(void)
bool FP_skip_line(FILE *stream, int n)
move file descriptor to the start of the n-th new line //[former read_line]
Definition: librw.cpp:178
void set_inclusion_semiaxesDimensions(long id, double a1, double a2, double a3=0.0)
Sets the id -th inclusion sorted semiaxes dimensions [a1,a2,a3]. The a3 dimension is ignored in the c...
Definition: problem.h:440
void set_inclusion_shape(long id, InclusionGeometry shape)
Sets the id -th inclusion shape. Default shape is detected automaticly.
Definition: problem.h:453
void print_graf(const char *vtkGeomFile, const char *path, const char *suff, int lc, char axe, int comp, double coordMin, double coordMax, double coordDelta, char pt_flag, double dshift, DiffTypes dt, Bod *b=NULL, bool odd=false)
Tiskne grafy hodnot displacement, strain, stress na rezu ve smeru dane osy v danem rozsahu...
Problem * read_inclusions_plus_initialize_and_print(const char *inclusion_file, const char *equiv_file, DiffTypes dt)
Definition: problem.cpp:2059
Problem description.
Definition: problem.h:154
General functions.
Original Honza Novak&#39;s balancing.
Definition: types.h:90
#define _openFileN(_1, _2, _3)
Definition: gelib.h:182
Bod * read_ansys_strain_stress_plot(const char *path, int lc, char axe, int comp, double coordMin, double coordMax, bool strn, bool half=false, bool bod=false)
Pozor, zatim asi dost predpokladam, ze je uloha 2d.
static void give_energy_MM()
compute energy of mumech solution
Definition: comparison.cpp:88
void find_inclusions_in_BB(void)
int ID
Definition: tests_tools.cpp:21
Input / output function.
void give_StiffnessMatrixFull(double *answer) const
Copy stiffness tensor into full matrix answer.
Definition: inclusion.cpp:799
void set_inclusion_E_nu(long id, double E, double nu)
Sets the id -th inclusion material properties, Young&#39;s modulus E and Poissons ratio nu...
Definition: problem.h:438
void CloseFile(FILE *file)
description: function closes a previously opened file and tests the succes of the closing note: funct...
#define PI
Definition: macros.h:71
void print_equivalent_problem(const char *filename)
Prints the equivalent problem record into the VTK file.
Definition: problem.cpp:2122
Class of function for homogenization of stress fields.
void set_problem_size(double a1, double a2, double a3, double b1, double b2, double b3, double node_distance)
Definition: problem.h:376
Class Mesh.
Inclusion * give_inclusion(long i) const
debug, for one function in tools
Definition: problem.h:402
void set_inclusion_EulerAnglesDEG(long id, double e1, double e2=0.0, double e3=0.0)
Sets the id -th inclusion Euler angles [e1,e2,e3] given in degrees. The e2 and e3 angles are ignored ...
Definition: problem.h:442
void set_Inclusion_shape(InclusionGeometry val)
Definition: inclusion.h:185
void visualization_1I_2d(void)
void set_Semiaxes_dimensions(double x, double y)
Definition: inclusion.cpp:237
int mat[2]
Definition: tests_tools.cpp:23
Class mElement, mesh element.
void intersection_3d(void)
void read_ansys_displ_plot(const char *path, int lc, char axe, int comp, double coordMin, double coordMax)
void set_RemoteStrain(int id, const double *rs)
Sets the id -th remote strain, rs is row-by-row matrix of dimensions 2x2 or 3x3 for 2d or 3d problem...
Definition: problem.h:431
void set_inclusion_centroids(long id, double x, double y, double z=0.0)
Sets the id -th inclusion centroids [x,y,z]. The z coordinate is ignored in the case of 2 dimensions...
Definition: problem.h:436
#define errol
Definition: gelib.h:151
void set_boundingBox(double x1, double y1, double x2, double y2)
void set_SBA_optimized(bool val)
Set type of self-balancing algorithm.
Definition: problem.h:368
void intersection_3d_core_6x6(double cx, double cy, double cz, double a1x, double a1y, double a1z, double g1x, double g1y, double g1z, double e1x, double e1y, double e1z, double a2x, double a2y, double a2z)
bool compare_y(Bod const &first, Bod const &second)
void intersection_3d_core(double c1x, double c1y, double c1z, double a1x, double a1y, double a1z, double e1x, double e1y, double e1z, double c2x, double c2y, double c2z, double a2x, double a2y, double a2z, double e2x, double e2y, double e2z, bool expected, bool ee, const char *s)
ee - THE XX error expected
void matrix_giveFullStiffMatrix(double *m) const
Definition: problem.h:330
void set_number_of_inclusions(long n)
Sets number of inclusions.
Definition: problem.cpp:136
void intersection_2d_core_4(double cx, double cy, double a1x, double a1y, double g1x, double g1y, double e1, double a2x, double a2y, double g2x, double g2y, double e2)
Dve inkluze s danym pootocenim se mohou dotykat ve vrcholech v 4 pozicich.
VOIGHT / engineering notation saved in FEEP order.
Definition: types.h:147
void x2d_2I(void)
void set_SBAM(SBAtype val)
Definition: problem.h:372
static double cmp_mm_ansys_total_energy(const char *basename, const char *vtkGeomFile, int lc)
Definition: comparison.cpp:39
Class Comparison.
void read_geometry_file_vtk(const char *vtkMeshFile, int pid, int lc, bool add)
Read input file with mesh geometry from vtk file.
Definition: mesh.cpp:355
void eqiv_gener_gx2dI_3d(const char *vtkAmndFile, int gx, int gy, double dx, double dy, double Em, double num, const double *rs, double E, double nu, double a1, double a2, DiffTypes dt, int mode)
long give_inclusion_with_point_inside(const double *coords, double epsilon=0.0) const
Returns inclusion ID inside the point lays.
Definition: problem.cpp:1647
void hrana_inkluze(void)
Test jestli externi pole dokazou plynule prechazet i dovnit inkluze.
void set_data_set(void)
Function switches bool flag data_set on true. That indicates start of the process of data input...
Definition: problem.h:423
void set_matrix_E_nu(double E, double nu)
Sets problem dimension.
Definition: problem.h:427
void intersection_3d_core_6(double cx, double cy, double cz, double a1x, double a1y, double a1z, double g1x, double g1y, double g1z, double e1x, double e1y, double e1z, double a2x, double a2y, double a2z, double g2x, double g2y, double g2z, double e2x, double e2y, double e2z)
Dve inkluze s danym pootocenim se mohou dotykat ve vrcholech v 6-ti pozicich.
double giveTotalVolumeFractionOfInclusions(void) const
void compute_element_fields(char flag, bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC, PFCmode pfcMode)
predpokladame trojuhelnikove nebo tetrahedron prvky, tj. na elementu budeme drzet jednu hodnotu ...
Definition: mesh.cpp:1138
void x2d_1I(void)
Jedna 2D inkluze v centru SS s poloosama 1.0 a 0.5.
void visualization_197I_2d3d(void)
void tests_tools(void)
void Energy_x2D_1I_MMxFEM(void)
void x2Dx3D_rotation(void)
void read_number_from_file(double &dx, const char *name)
Class HomogenizationMethods.
static bool ellipses_overlap(const Inclusion *inc1, const Inclusion *inc2)
Definition: mesoface.cpp:53
void give_ovlivneni(const double *coords, double *result)
Funkce pro zkoumani ucinku inkluze na druhou v balancovacim algoritmu. Casem smazat, pac balancing se asi nebude pouzivat.
Definition: problem.cpp:1357
I/O VTK functions.
void set_diffType(DiffTypes val)
Sets type of differentiation, analytical by default.
Definition: problem.h:455
Homogenization * give_new_homogenization(HomogenizationType ht)
Definition: problem.cpp:2084
Class mNode, mesh node.
bool FP_skip_to_line_starting_with(FILE *stream, const char *string, bool cs)
move file descriptor to the line starting with string, exactly behind the string; white space can be ...
Definition: librw.cpp:202
void penergy_2d(void)
u jedne inkluze bych mel vyzkouset, jestli jsou opravdu energie stejne, zda se mi ze se zahustenim si...
bool areSame(double abszero, double relzero, double a, double b)
Definition: mathlib.cpp:319
void compare_grafs(const char *name1, const char *name2)
void intersection_3d_core_6x6x6(double cx, double cy, double cz, double a1x, double a1y, double a1z, double a2x, double a2y, double a2z)
Mesh * give_new_mesh(void)
Give verbose level.
Definition: problem.cpp:2076
bool file_delete_if_exist(const char *name)
Definition: gelib.h:427
void set_inclusion_all(long id, double x, double y, double e, double n, double a1, double a2, double e1)
Agregates ...
Definition: problem.h:464
void DeleteArray2D(bool **array, long d1)
Function deletes a 2D &#39;bool&#39; array of dimension d1 x ??, allocated by new.
void eqiv_gener_1x2dI_2d(const char *vtkAmndFile, double Em, double num, const double *rs, double x, double y, double E, double nu, double a1, double a2, double ea, DiffTypes dt)
void intersection_2d(void)
void printFieldsOnMeshGrid(const char *mesh_file_out, const double *p1, const double *p2, const long *n, char ptFlag, int rs, int nrs, PFCmode pfcMode=PFCM_OPTIMIZED) const
Function computes all fields (displacements, strains and stresses) in nodes a regular orthogonal mesh...
Definition: problem.cpp:2041
Class mesoface.
void eqiv_gener_gx2dI_2d(const char *vtkAmndFile, int gx, int gy, double dx, double dy, double Em, double num, const double *rs, double E, double nu, double a1, double a2, DiffTypes dt, int mode)
dx, dy ... roztec stredu inkluzi
virtual void giveHomogenizedStiffnessMatrix(double *answer)=0
Function returning the homogenized stiffness matrix according the defined method termitovo pridat par...
void intersection_2d_core(double c1x, double c1y, double a1x, double a1y, double e1, double c2x, double c2y, double a2x, double a2y, double e2, bool expected, const char *s)
ee - THE XX error expected
double ** AllocateArray2D(long d1, long d2)
Operations with 2d, 3d, 4d arrays of various sizes.
void print_visualization(const char *filename, int n, int dim=0, bool refined=false)
Triangulates inclusions surfaces and prints filename VTK file.
Definition: problem.cpp:2237
void set_Youngs_modulus(double val)
Definition: inclusion.h:186
void read_input_file(const char *filename)
Reads filename VTK input file containing inclusion geometry and topology.
Definition: problem.cpp:357
Class of function for ... homogenization.
void test3D()
void compute_and_print_reg_mesh(const char *vtkGeomFile, const char *vtkMeshFileOutPert, double x, int n, char pt, DiffTypes dt)
void OpenFile(FILE **file, char *name, const char mode[])
Operations with file descriptors.
void printFieldsOnMeshVTK(const char *mesh_file_out, const char *mesh_file, char ptFlag, int rs, int nrs, PFCmode pfcMode=PFCM_OPTIMIZED) const
Function computes all fields (displacements, strains and stresses) in nodes a mesh given via VTK file...
Definition: problem.cpp:2028
void ovlivneni(void)
Class Mesh contains and handles all mesh data.
Definition: mesh.h:52
void speedtest2Dx3D(void)
Speedtest comparing 2D problem - computes only external points.
New Standa&#39;s b.
Definition: types.h:91
void eqiv_gener_2x2dI_3d(const char *vtkAmndFile, double Em, double num, const double *rs, double x, double E, double nu, double a1, double a2, DiffTypes dt, int mode=0)
void eqiv_gener_1x2dI_3d(const char *vtkAmndFile, double Em, double num, const double *rs, double x, double y, double E, double nu, double a1, double a2, double ea, DiffTypes dt)
void eqiv_gener_2x2dI_2d(const char *vtkAmndFile, double Em, double num, const double *rs, double x, double E, double nu, double a1, double a2, DiffTypes dt, int mode=0)
virtual const char * giveClassName()
Function returning class name.
static int ellipsoids_overlap(const Inclusion *inc1, const Inclusion *inc2)
Definition: mesoface.cpp:37
void x2d_grid(void)
void set_Poissons_ratio(double val)
Definition: inclusion.h:187
long giveFieldsOfPoint(double **displc, double **strain, double **stress, const double *coords, char ptFlag, int rs, int nrs, PFCmode pfcMode=PFCM_OPTIMIZED, long reqIncl=-3, STRNotation tn=STRN_THEORETICAL_ROW) const
Function gives the analytical solution of the perturbation or total fields (displacements, strains and stresses) of a point for given set of remote strains.
Definition: problem.cpp:1706
void CleanVector(double *a, long n)
Functin cleans a &#39;double&#39; vector, initialize each value being 0-zero.
void clanek_3d_vzor(void)
No balancing.
Definition: types.h:89
void set_intFieldsShape(int val)
Definition: problem.h:371
void eqiv_gener_1x3dI(const char *vtkAmndFile, double Em, double num, const double *rs, double x, double y, double z, double E, double nu, double a1, double a2, double a3, double ea1, double ea2, double ea3, DiffTypes dt)
void set_UnitRemoteStrains(void)
Function sets a set of unit remote strains.
Definition: problem.h:462
double coord[3]
Definition: tests_tools.cpp:22
Class Problem.
bool last
Definition: tests_tools.cpp:26
void set_numberOfRemoteStrains(int n)
Sets number of remote strains.
Definition: problem.h:429
void visualization_1I_3d(void)
long giveFieldsOfPointOneRS(double *displc, double *strain, double *stress, const double *coords, char ptFlag, int rs, PFCmode pfcMode=PFCM_OPTIMIZED, long reqIncl=-3, STRNotation tn=STRN_THEORETICAL_ROW) const
Function gives results for only one remote strain. See function giveFieldsOfPoint().
Definition: problem.cpp:1699
void e(int i)
void convert_to_equivalent_problem(void)
Converts the given heterogeneous problem to the equivalent problem.
Definition: problem.cpp:781