muMECH  1.0
problem.cpp
Go to the documentation of this file.
1 //********************************************************************************************************
2 // code: ### ### ##### #### ## ##
3 // ## ## ######## ## ## ## ## ##
4 // ## ## ## ## ## ### ## ######
5 // ## ## ## ## ## ## ## ## ##
6 // ##### ## ## ##### #### ## ##
7 // ##
8 //
9 // name: problem.cpp
10 // author(s): Jan Novak
11 // language: C, C++
12 // license: This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 //********************************************************************************************************
26 
27 // toto je kvuli WIN32_LEAN_AND_MEAN
28 #include "types.h"
29 
30 //included libraries
31 #include "problem.h"
32 
33 #include "matrixOperations.h"
34 //#include "elementaryFunctions.h"
35 #include "macros.h"
36 #include "inclusion.h"
37 #include "transformTensors.h"
38 #include "esuf.h"
39 #include "vtk.h"
40 #include "mesh.h"
41 #include "homogenization.h"
42 #include "mnode.h"
43 #include "melement.h"
44 #include "selfBalanceAlgorithm.h"
45 //#include "matrix.h"
46 #include "homogenizationMethods.h"
47 
48 #include "tixy2.h"
49 #include "gelib.h"
50 #include "librw.h"
51 #include "mathlib.h"
52 
53 #include <stdio.h>
54 #include <math.h>
55 
56 
57 using namespace tinyxml2;
58 
59 namespace mumech {
60 
61 
62 //********************************************************************************************************
63 // PUBLIC FUNCTIONS
64 //********************************************************************************************************
65 #define maxNumberOfMeshes 1000
66 Problem :: Problem (void) : Problems ()
68 {
69  data_set = false;
70  data_equivalent = false;
71 
72  twodim = false;
73 
74  matrix = new MatrixRecord (this);
75  noIncl = 0;
76  inclusions = NULL;
77 
78  SBA_optimized = true;
79  SBA_maxiters = 999;
80  SBA_reqiters = 1000;
81 
82  intFieldsShape = 2; // now 2 is default -> all the tests give the same results
83  approximation = 0;
84  approx_point_pos1 = 0.99;
85 
86  SBA_type = SBAT_VOID;
87 
88  diffType = DT_NUMERICAL;
89 
90  CleanVector(problem_size_A, 3);
91  CleanVector(problem_size_B, 3);
92  node_dist = 0.;
93 
94  verbose = 0;
95 
96  min_axes_diff = _MIN_AXES_DIFF;
97  max_axes_diff = _MAX_AXES_DIFF;
98 
99  min_axes_diff_change = true;
100  max_axes_diff_change = false;
101 
102  volumeOfIncls = 0.0;
103  totalNoActingIncls = 0;
104 
105  nmeshes = 0;
106  meshes = new Mesh*[maxNumberOfMeshes];
107  memset (meshes, 0, maxNumberOfMeshes * sizeof(Mesh*));
108 
109  nhomogs = 0;
110  homogs = new Homogenization*[maxNumberOfMeshes];
111  memset (homogs, 0, maxNumberOfMeshes * sizeof(Homogenization*));
112 }
113 
115 Problem :: ~Problem ()
116 {
117  for (int i=0; i<noIncl; i++) delete inclusions[i];
118  delete [] inclusions;
119 
120  if (meshes) { for (int i=0; i<maxNumberOfMeshes; i++) delete meshes[i]; delete [] meshes; }
121  if (homogs) { for (int i=0; i<maxNumberOfMeshes; i++) delete homogs[i]; delete [] homogs; }
122 
123  delete matrix;
124 } // end of function: destructor
125 
127 void Problem :: input_data_initialize_and_check_consistency (void)
128 {
129  for (int i=0; i<noIncl; i++)
130  inclusions[i]->input_data_initialize_and_check_consistency();
131 
132 }
133 
134 
136 void Problem :: set_number_of_inclusions (long n)
137 {
138  noIncl = n; // number of inclusions
139  if (twodim) { inclusions = new Inclusion*[noIncl]; for (int i=0; i<noIncl; i++) inclusions[i] = new InclusionRecord2D(i, this); }
140  else { inclusions = new Inclusion*[noIncl]; for (int i=0; i<noIncl; i++) inclusions[i] = new InclusionRecord3D(i, this); }
141 }
142 
143 
144 
145 
146 // allocate and generate a single 2d inclusion 2d problem
147 void Problem :: generate_equiv_1x2dI_2d (double Em, double num, const double *rs, double x, double y, double E, double nu, double a1, double a2, double ea, DiffTypes dt)
148 {
149  // ************** DATA INPUT VIA FUNCTIONS ******************
150  // problem
151  this->set_data_set();
152  this->set_dimension(2);
153  this->set_diffType(dt);
154  this->set_matrix_E_nu(Em, num);
155  if (rs) {
156  this->set_numberOfRemoteStrains(1);
157  this->set_RemoteStrain(0, rs);
158  }
159  else
160  this->set_UnitRemoteStrains();
161 
162  // inclusions
163  this->set_number_of_inclusions(1);
164  // first inclusion
165  this->set_inclusion_centroids(0, x, y);
166  this->set_inclusion_E_nu(0, E, nu);
167  this->set_inclusion_semiaxesDimensions(0, a1, a2);
168  this->set_inclusion_EulerAnglesDEG(0, ea);
169 
170  this->input_data_initialize_and_check_consistency();
171  // ************** DATA INPUT VIA FUNCTIONS ******************
172 
173  this->convert_to_equivalent_problem();
174 
175 }
176 
178 void Problem :: set_approximation (int val)
179 {
180  if (val < 0 || val>2)_errorr("Wrong approximation value.");
181  if (this->approximation > 0)_errorr("Another approximation is already set. It can be set only once.");
182  int n_points = 0;
183  int n_approximations = 0;
184 
185  this->approximation = val;
186  //2D
187  // x y | xx yy xy
188  //3D
189  // x y z | xx yy zz yz xy xy
190 
191  if (val == 1) {
192  n_points = this->give_dimension() * 2 + 1;
193  n_approximations = this->give_dimension();
194  for (int i = 0; i < noIncl; i++) {
195  this->inclusions[i]->n_approx_points = n_points;
196  this->inclusions[i]->approx_points = AllocateArray2D(n_points, 3);
197  this->inclusions[i]->approx_points_eps_tau = AllocateArray2D(n_points, this->give_VM_TENS_RANGE());
198  this->inclusions[i]->approx_coef = new double**[this->give_nLC()];
199  for (int j = 0; j < this->give_nLC(); j++) {
200  this->inclusions[i]->approx_coef[j] = new double*[n_approximations];
201  for (int k = 0; k < n_approximations; k++) {
202  this->inclusions[i]->approx_coef[j][k] = new double[this->give_VM_TENS_RANGE()];
203  for (int ii = 0; ii < this->give_VM_TENS_RANGE(); ii++)this->inclusions[i]->approx_coef[j][k][ii] = 0.;
204  }
205  }
206  CleanArray2d(this->inclusions[i]->approx_points, n_points, 3);
207  CleanArray2d(this->inclusions[i]->approx_points_eps_tau, n_points, this->give_VM_TENS_RANGE());
208 
209  this->inclusions[i]->approx_points[1][0] -= approx_point_pos1*this->inclusions[i]->a[0];
210  this->inclusions[i]->approx_points[2][0] += approx_point_pos1*this->inclusions[i]->a[0];
211  this->inclusions[i]->approx_points[3][1] -= approx_point_pos1*this->inclusions[i]->a[1];
212  this->inclusions[i]->approx_points[4][1] += approx_point_pos1*this->inclusions[i]->a[1];
213  if (this->give_dimension() == 3) {
214  this->inclusions[i]->approx_points[5][2] -= approx_point_pos1*this->inclusions[i]->a[2];
215  this->inclusions[i]->approx_points[6][2] += approx_point_pos1*this->inclusions[i]->a[2];
216  }
217  for (int j = 0; j < n_points; j++)this->inclusions[i]->transformCoords_L2G(this->inclusions[i]->approx_points[j], this->inclusions[i]->approx_points[j]);
218  }
219  }
220  if (val == 2) {
221  if (this->give_dimension() == 2) {
222  n_points = 9;
223  n_approximations = 5;
224  }
225  else {
226  n_points = 19;
227  n_approximations = 9;
228  }
229  for (int i = 0; i < noIncl; i++) {
230  this->inclusions[i]->n_approx_points = n_points;
231  this->inclusions[i]->approx_points = AllocateArray2D(n_points, 3);
232  this->inclusions[i]->approx_points_eps_tau = AllocateArray2D(n_points, this->give_VM_TENS_RANGE());
233  this->inclusions[i]->approx_coef = new double**[this->give_nLC()];
234  for (int j = 0; j < this->give_nLC(); j++) {
235  this->inclusions[i]->approx_coef[j] = new double*[n_approximations];
236  for (int k = 0; k < n_approximations; k++) {
237  this->inclusions[i]->approx_coef[j][k] = new double[this->give_VM_TENS_RANGE()];
238  for (int ii = 0; ii < this->give_VM_TENS_RANGE(); ii++)this->inclusions[i]->approx_coef[j][k][ii] = 0.;
239  }
240  }
241  CleanArray2d(this->inclusions[i]->approx_points, n_points, 3);
242  CleanArray2d(this->inclusions[i]->approx_points_eps_tau, n_points, this->give_VM_TENS_RANGE());
243 
244  this->inclusions[i]->approx_points[1][0] -= approx_point_pos1*this->inclusions[i]->a[0];
245  this->inclusions[i]->approx_points[2][0] += approx_point_pos1*this->inclusions[i]->a[0];
246  this->inclusions[i]->approx_points[3][1] -= approx_point_pos1*this->inclusions[i]->a[1];
247  this->inclusions[i]->approx_points[4][1] += approx_point_pos1*this->inclusions[i]->a[1];
248 
249  this->inclusions[i]->approx_points[5][0] -= 0.5*this->inclusions[i]->a[0];
250  this->inclusions[i]->approx_points[5][1] -= 0.5*this->inclusions[i]->a[1];
251  this->inclusions[i]->approx_points[6][0] += 0.5*this->inclusions[i]->a[0];
252  this->inclusions[i]->approx_points[6][1] -= 0.5*this->inclusions[i]->a[1];
253  this->inclusions[i]->approx_points[7][0] -= 0.5*this->inclusions[i]->a[0];
254  this->inclusions[i]->approx_points[7][1] += 0.5*this->inclusions[i]->a[1];
255  this->inclusions[i]->approx_points[8][0] += 0.5*this->inclusions[i]->a[0];
256  this->inclusions[i]->approx_points[8][1] += 0.5*this->inclusions[i]->a[1];
257 
258  if (this->give_dimension() == 3) {
259  this->inclusions[i]->approx_points[9][2] -= approx_point_pos1*this->inclusions[i]->a[2];
260  this->inclusions[i]->approx_points[10][2] += approx_point_pos1*this->inclusions[i]->a[2];
261 
262  this->inclusions[i]->approx_points[11][0] -= 0.5*this->inclusions[i]->a[0];
263  this->inclusions[i]->approx_points[11][2] -= 0.5*this->inclusions[i]->a[2];
264  this->inclusions[i]->approx_points[12][0] += 0.5*this->inclusions[i]->a[0];
265  this->inclusions[i]->approx_points[12][2] -= 0.5*this->inclusions[i]->a[2];
266  this->inclusions[i]->approx_points[13][0] -= 0.5*this->inclusions[i]->a[0];
267  this->inclusions[i]->approx_points[13][2] += 0.5*this->inclusions[i]->a[2];
268  this->inclusions[i]->approx_points[14][0] += 0.5*this->inclusions[i]->a[0];
269  this->inclusions[i]->approx_points[14][2] += 0.5*this->inclusions[i]->a[2];
270  this->inclusions[i]->approx_points[15][1] -= 0.5*this->inclusions[i]->a[1];
271  this->inclusions[i]->approx_points[15][2] -= 0.5*this->inclusions[i]->a[2];
272  this->inclusions[i]->approx_points[16][1] += 0.5*this->inclusions[i]->a[1];
273  this->inclusions[i]->approx_points[16][2] -= 0.5*this->inclusions[i]->a[2];
274  this->inclusions[i]->approx_points[17][1] -= 0.5*this->inclusions[i]->a[1];
275  this->inclusions[i]->approx_points[17][2] += 0.5*this->inclusions[i]->a[2];
276  this->inclusions[i]->approx_points[18][1] += 0.5*this->inclusions[i]->a[1];
277  this->inclusions[i]->approx_points[18][2] += 0.5*this->inclusions[i]->a[2];
278 
279  }
280 
281 
282  for (int j = 0; j < n_points; j++)this->inclusions[i]->transformCoords_L2G(this->inclusions[i]->approx_points[j], this->inclusions[i]->approx_points[j]);
283  }
284  }
285 
286  /*for (int i = 0; i < noIncl; i++) {
287  printf("\nIncl n. %d\n(%d points)\n", i, this->inclusions[i]->n_approx_points);
288  for (int j = 0; j < this->inclusions[i]->n_approx_points; j++) {
289  printf("%lf %lf %lf\n",this->inclusions[i]->approx_points[j][0], this->inclusions[i]->approx_points[j][1], this->inclusions[i]->approx_points[j][2]);
290  }
291  }
292  enter();*/
293 }
294 
295 
296 // /**
297 // * @brief scan_DATA_field_head
298 // *
299 // * @param stream
300 // * @param strm
301 // * @param str
302 // * @param type
303 // * @param nexc
304 // * @param format
305 // * @param name
306 // */
307 // void scan_DATA_field_head (Stream *stream, Stream *strm, const char *str, char type, int nexc, char format, const char *name)
308 // {
309 // char flint[8];
310 // if (format == 'i') { if (stream->isFile()) sprintf(flint,"int"); else sprintf(flint,"Int32"); }
311 // else if (format == 'f') { if (stream->isFile()) sprintf(flint,"float"); else sprintf(flint,"Float32"); }
312 // else errol;
313 //
314 // char auxs[255];
315 // sprintf (auxs, "Error in section %s", name);
316 //
317 // if (stream->isFile()) {
318 // SP_scan_expected_word_exit (str, flint, auxs, CASE);
319 // if (type == 'S') {
320 // SP_scan_expected_number_exit (str, nexc, auxs);
321 // FP_scan_expected_word_exit (stream->file(), "LOOKUP_TABLE default", auxs, CASE);
322 // FP_skip_line (stream->file());
323 // }
324 // strm->redefine( stream->file() );
325 // }
326 // else {
327 // strm->redefine( XP_giveDAtext (stream->tixel(), 0, false, "ascii", flint, name, &nexc));
328 // }
329 // }
330 void scan_FIELD_head (FILE *stream, long noincl, int nexc, char format, const char *name)
331 {
332  char flint[8];
333  if (format == 'i') sprintf(flint,"int");
334  else if (format == 'f') sprintf(flint,"float");
335  else errol;
336 
337  char auxs[255];
338  sprintf (auxs, "Error in section %s", name);
339 
340  FP_scan_expected_number_exit (stream, noincl, auxs);
341  FP_scan_expected_number_exit (stream, nexc, auxs);
342  FP_scan_expected_word_exit (stream, flint, auxs, CASE);
343 }
344 
346 bool Problem :: file_type_s2e (const char *s)
347 {
348  if (_STRCMP(s, "2D" ) == 0) { twodim = true; return false; }
349  else if (_STRCMP(s, "2Dequiv") == 0) { twodim = true; return true; }
350  else if (_STRCMP(s, "3D" ) == 0) { twodim = false; return false; }
351  else if (_STRCMP(s, "3Dequiv") == 0) { twodim = false; return true; }
352  else _errorr2 ("Invalid structure of the given VTK file, the key word %s at the second line is not supported", s);
353  return false;
354 }
355 
357 void Problem :: read_input_file (const char *filename)
358 {
359  if (data_set) _errorr("data_set already given");
360  data_set = true;
361 
362  if (this->verbose > 0)
363  printf( "Reading of VTK file of multiple inclusion, please wait ...\n" );
364 
365  // open stream with automatic detection VTK legaci/XML file format
366  char *fn = new char[255];
367  strcpy(fn, filename);
368  Stream *stream = new Stream();
369  stream->open(STRM_void, "r", (const char*&)fn); // do not delete fn, it is deleted inside of the function
370 
371  //
372  char *WORD=NULL;
373  const XMLElement *xnel = NULL;
374 
375  bool lgc = stream->isFile();
376  bool amd = false;
377 
378  if (lgc) WORD = new char[255];
379 
380 
381  // HEAD OD FILE
382  if (lgc) {
383  // 1. line
384  FP_skip_line (stream->file());
385 
386  // 2. line
387  FP_scan_word (stream->file(), WORD);
388  FP_skip_line (stream->file());
389 
390  amd = this->file_type_s2e (WORD);
391 
392  // 3. line
393  FP_scan_expected_word_exit (stream->file(), "ASCII", "Invalid structure of the given VTK file", true);
394  FP_skip_line (stream->file());
395  // 4. line
396  FP_scan_expected_word_exit (stream->file(), "DATASET UNSTRUCTURED_GRID", "Invalid structure of the given VTK file", true);
397  FP_skip_line (stream->file());
398  }
399  else {
400  // check head of xml file and read possible ctrl section
401  // return XMLElement "Piece"
402  const XMLNode *parent = stream->tixnod();
403 
404  //* declaration - delete if present
405  if (parent->FirstChild()->ToDeclaration() != NULL) stream->tixnod()->DeleteChild( stream->tixnod()->FirstChild() );
406 
407  //* comment - delete if present
408  while (true)
409  if (parent->FirstChild()->ToComment() != NULL) stream->tixnod()->DeleteChild( stream->tixnod()->FirstChild() );
410  else break;
411 
412  //
413  parent = XP_give_unique_expected_elem (parent, "VTKFile");
414  stream->relink_downF();
415 
417  XP_check_expected_attribute (parent, "type", "UnstructuredGrid");
418  XP_check_expected_attribute (parent, "version", "0.1");
419  XP_check_expected_attribute (parent, "byte_order", "LittleEndian");
420 
421  //
422  parent = XP_give_unique_expected_elem (parent, "UnstructuredGrid", false);
423  stream->relink_downF();
424 
425  // read AppendedData section
426  parent = parent->NextSibling();
427  if (! parent)
428  _errorr("No AppendedData section");
429 
430  if (_STRCMP(parent->Value(), "AppendedData") != 0) _errorr ("name of xelement is not \"AppendedData\"");
431 
432  if (! (parent = parent->FirstChild ())) _errorr("No child in AppendedData");
433  if ( parent->Value()[0] != '_' ) _errorr("There is no character \'_\' at the start of section AppendedData");
434  parent = parent->NextSibling();
435 
436  if (_STRCMP(parent->Value(), "Input_Type") != 0) _errorr("name of xelement is not Input_Type");
437  amd = this->file_type_s2e (parent->ToElement()->GetText());
438 
439  while (parent->NextSibling()) {
440  parent = parent->NextSibling();
441  const char *text = parent->Value();
442  long auxl;
443 
444  if (_STRCMP(text, "SBA_mode") == 0) {
445  sscanf (parent->ToElement()->GetText(), "%ld", &auxl);
446  SBA_optimized = (bool)(auxl-1);
447  }
448  else if (_STRCMP(text, "conversion_mode") == 0) {
449  sscanf (parent->ToElement()->GetText(), "%d", &intFieldsShape);
450  }
451  else if (_STRCMP(text, "Matrix_record") == 0) {
452  double e, nu;
453  sscanf (parent->ToElement()->GetText(), "%lf %lf", &e, &nu);
454  matrix->set_E_nu(e, nu);
455  }
456  else if (_STRCMP(text, "Remote_strains") == 0) {
457  long nlc;
458  const char *str = parent->ToElement()->GetText();
459  SP_scan_expected_number_exit (str, this->give_TENS_RANGE(), "wrong length of Remote_strains tensor, expected 4 or 9");
460  SP_scan_number(str, nlc);
461  this->matrix->set_nlc(nlc);
462  // load cases
463  if (this->matrix->scan_Remote_strains(str) != true) _errorr2 ("There is few numbers in section %s", WORD);
464  }
465  else if (_STRCMP(text, "Min_axes_diff") == 0) { double m; sscanf (parent->ToElement()->GetText(), "%lf", &m); this->set_semiaxes_min_difference(m); }
466  else if (_STRCMP(text, "Max_axes_diff") == 0) { double m; sscanf (parent->ToElement()->GetText(), "%lf", &m); this->set_semiaxes_max_difference(m); }
467  }
468 
469  // go to Piece
470  XP_give_unique_expected_elem (stream->tixnod(), "Piece");
471  stream->relink_downF();
472  xnel = stream->tixel();
473  }
474 
475 
476  // variable declaration
477  Stream auxstrm;
478  //
479  bool status = true, prnt;
480  int auxi, les, ges;
481  long i, j, nn, auxl, noel, cno, offset;
482  char ed='-';
483  const char *data=NULL, *offs=NULL, *typs, *str;
484  char LINE[1023];
485  int lLINE=1023;
486  VTKrange range = VTKR_void;
487  int nLC;
488 
489  cno = 0;
490  prnt = true;
491  les = ges = 0;
492  while (true) {
493  //* key WORD
494  if (lgc) {
495  if (fgets (LINE, lLINE, stream->file()) == NULL) break;
496  str = LINE;
497  SP_scan_word (str, WORD);
498  }
499  else {
500  if (prnt) { if (! stream->relink_downF()) errol; else prnt = false; }
501  else { if (! stream->relink_next()) break; }
502  WORD = (char *)stream->tixel()->Value();
503  }
504 
505  //* ******************
506  //* *** POINTS ***
507  //* ******************
508  if (_STRCMP(WORD, "Points") == 0) {
509  if (range == VTKR_void) range = VTKR_points; else errol;
510 
511  // number of nodes
512  if (lgc) {
513  SP_scan_number (str, noel);
514  SP_scan_expected_word2_exit (str, "double", "float", "Invalid structure of the given VTK file, unsupported datatype of POINTS", CASE);
515  }
516  else {
517  xnel->ToElement()->QueryLongAttribute("NumberOfPoints", &noel);
518  data = XP_giveDAtext (stream->tixel(), 1, true, "ascii", "Float32", NULL, &(auxi=3));
519  }
520 
521  noIncl = noel; // number of inclusions
522  if (twodim) { inclusions = new Inclusion*[noIncl]; for (int i=0; i<noIncl; i++) inclusions[i] = new InclusionRecord2D(i, this); }
523  else { inclusions = new Inclusion*[noIncl]; for (int i=0; i<noIncl; i++) inclusions[i] = new InclusionRecord3D(i, this); }
524 
525  // for (i=0; i<noIncl; i++) inclRec[i].set_id_problem(i, this);
526 
527  // coords
528  noIncl = 0;
529  if (twodim) {
530  while (noel) { noel--;
531  if (lgc) { status += ( fscanf (stream->file(), "%lf %lf %lf", inclusions[noIncl]->origin, inclusions[noIncl]->origin+1, inclusions[noIncl]->origin+2) == 3 ); if (inclusions[noIncl]->origin[2] != 0.0) _errorr("3. coordinates is not 0.0"); }
532  else { status += ( sscanf (data, "%lf %lf %lf", inclusions[noIncl]->origin, inclusions[noIncl]->origin+1, inclusions[noIncl]->origin+2) == 3 ); if (inclusions[noIncl]->origin[2] != 0.0) _errorr("3. coordinates is not 0.0"); status += (SP_skip_word(data) && SP_skip_word(data) && SP_skip_word(data)); }
533  noIncl ++;
534  }
535  }
536  else {
537  while (noel) { noel--;
538  if (lgc) { status += ( fscanf (stream->file(), "%lf %lf %lf", inclusions[noIncl]->origin, inclusions[noIncl]->origin+1, inclusions[noIncl]->origin+2) == 3 ); }
539  else { status += ( sscanf (data, "%lf %lf %lf", inclusions[noIncl]->origin, inclusions[noIncl]->origin+1, inclusions[noIncl]->origin+2) == 3 ); status += (SP_skip_word(data) && SP_skip_word(data) && SP_skip_word(data)); }
540  noIncl ++;
541  }
542  }
543 
544  if (lgc) FP_skip_line (stream->file());
545  }
546  //* *************************************
547  //* *** UNSTRUCTURED GRID - CELLS ***
548  //* *************************************
549  else if (_STRCMP(WORD, "CELLS") == 0) {
550  if (range == VTKR_points) range = VTKR_cells; else errol;
551 
552  // number of cells
553  if (lgc) {
554  SP_scan_number (str, noel);
555  SP_scan_number (str, cno);
556  }
557  else {
558  xnel->ToElement()->QueryLongAttribute("NumberOfCells" , &noel);
559  data = XP_giveDAtext (stream->tixel(), 1, false, "ascii", "Int32", "connectivity", NULL);
560  offs = XP_giveDAtext (stream->tixel(), 2, false, "ascii", "Int32", "offsets", NULL);
561  typs = XP_giveDAtext (stream->tixel(), 3, true, "ascii", "UInt8", "types", NULL);
562  }
563 
564  if (!lgc) offset = 0;
565  // elem nodes
566  for (i=0; i<noel; i++) {
567  // nn
568  if (lgc) { fscanf (stream->file(),"%ld",&nn); cno = cno - nn - 1; }
569  else { nn = offset; status += SP_scan_number (offs, offset); nn = offset - nn; }
570  //
571  if (nn != 1) _errorr3 ("The number of CELL(%ld) nodes is %ld, it should be 1", i, nn);
572  //
573  if (lgc) fscanf (stream->file(),"%ld", &auxl);
574  else status += SP_scan_number (data, auxl);
575  if (auxl != i) _errorr4 ("The CELL(%ld) node ID is %ld, it should be %ld", i, auxl, i);
576  }
577 
578  if (lgc) FP_skip_line (stream->file(), 1);
579 
580  // types of elems
581  if (lgc) {
582  fgets (LINE, lLINE, stream->file()); str=LINE;
583  SP_scan_expected_word_exit (str, "CELL_TYPES", "Invalid structure of the given VTK file", CASE);
584  SP_scan_expected_number_exit (str, noel, "Invalid structure of the given VTK file, the number following CELL_TYPES");
585  }
586 
587  while (noel) { noel--;
588  if (lgc) fscanf (stream->file(),"%ld",&auxl);
589  else status += SP_scan_number (typs, auxl);
590  if (auxl != 1) _errorr2 ("Unsupported CELL_TYPE %ld, only \"1\" is supported", auxl);
591  }
592 
593  if (lgc) FP_skip_line (stream->file(), 1);
594  }
595  //* *******************************
596  //* *** POLYDATA - ELEMENTS ***
597  //* *******************************
598  else if (_STRCMP(WORD, "LINES") == 0 || _STRCMP(WORD, "POLYGONS" ) == 0 || _STRCMP(WORD, "POLYS") == 0 || _STRCMP(WORD, "Vertices") == 0 || _STRCMP(WORD, "Verts") == 0 || _STRCMP(WORD, "Strips") == 0) {
599  _errorr2("Invalid structure of the given VTK file, the key word %s is not supported", WORD);
600  }
601  //* **********************
602  //* *** POINT_DATA ***
603  //* **********************
604  else if (_STRCMP(WORD, "POINT_DATA") == 0 || _STRCMP(WORD, "PointData") == 0) {
605  if (range == VTKR_cells || range == VTKR_points || range == VTKR_fields) range = VTKR_pd; else errol;
606  ed = 'p';
607  // head
608  if (lgc) { SP_scan_expected_number_exit (str, noIncl, "The number following POINT_DATA is not equal to number of inclusions"); }
609  else { prnt = true; }
610  }
611  //* *********************
612  //* *** CELL_DATA ***
613  //* *********************
614  else if (_STRCMP(WORD, "CELL_DATA") == 0 || _STRCMP(WORD, "CellData") == 0) {
615  if (range == VTKR_cells || range == VTKR_data) range = VTKR_cd; else errol;
616  ed = 'c';
617  // head
618  if (lgc) { SP_scan_expected_number_exit (str, noIncl, "The number following CELL_DATA is not equal to number of inclusions"); }
619  else { prnt = true; }
620  }
621  //* ******************
622  //* *** FIELDS ***
623  //* ******************
624  else if (_STRCMP(WORD, "FIELD") == 0) {
625  if (range == VTKR_cells || range == VTKR_data) range = VTKR_fields; else errol;
626 
627  if (!lgc) _errorr("FIELD in nonlegacy");
628 
629  // head
630  if (lgc) SP_scan_word (str, WORD);
631  else { WORD = (char *)stream->tixel()->ToElement()->Attribute("Name"); if (!WORD) _errorr ("there is no attribute \"Name\""); }
632 
633  if (_STRCMP(WORD, "unstructured_data") != 0) _errorr("...");
634 
635  SP_scan_number (str, noel);
636 
637  for (i=0; i<noel; i++) {
638  FP_scan_word (stream->file(), WORD);
639 
640  if (_STRCMP(WORD, "Acting_inclusions_list") == 0) {
641  auxl = this->totalNoActingIncls;
642  scan_FIELD_head (stream->file(), 1, auxl, 'i', WORD);
643  if (auxl)
644  for (j=0; j<noIncl; j++)
645  if (FP_scan_array (stream->file(), inclusions[i]->noActingIncls, inclusions[i]->actingIncls) != true) _errorr2 ("There is few numbers in section %s", WORD);
646  }
647  else if (_STRCMP(WORD, "Remote_strains") == 0) {
648  // length of tensor
649  FP_scan_expected_number_exit (stream->file(), this->give_TENS_RANGE(), "wrong length of Remote_strains tensor, expected 4 or 9");
650  // number of load cases
651  fscanf (stream->file(), "%d", &nLC);
652  this->matrix->set_nlc(nLC);
653  FP_scan_expected_word_exit (stream->file(), "float", "float expected in remote strain", CASE);
654  // load cases
655  if (this->matrix->scan_Remote_strains(stream->file()) != true) _errorr2 ("There is few numbers in section %s", WORD);
656  }
657  else if (_STRCMP(WORD, "SBA_mode") == 0) {
658  scan_FIELD_head (stream->file(), 1, 1, 'i', WORD);
659  fscanf (stream->file(), "%ld", &auxl);
660  SBA_optimized = (bool)(auxl-1);
661  }
662  else if (_STRCMP(WORD, "conversion_mode") == 0) {
663  scan_FIELD_head (stream->file(), 1, 1, 'i', WORD);
664  fscanf (stream->file(), "%d", &intFieldsShape);
665  }
666  else if (_STRCMP(WORD, "Matrix_record") == 0) {
667  scan_FIELD_head (stream->file(), 1, 2, 'f', WORD);
668  double e, nu;
669  fscanf (stream->file(), "%lf %lf", &e, &nu);
670 
671  this->matrix->set_E_nu(e, nu);
672  }
673  else
674  _errorr3 ("Invalid name of %d -th FIELD \"%s\"", i, WORD);
675  }
676  }
677  //* **************************
678  //* *** DATA - SCALARS ***
679  //* **************************
680  else if (_STRCMP(WORD, "SCALARS") == 0 || _STRCMP(WORD, "VECTORS") == 0 || _STRCMP(WORD, "TENSORS") == 0 || _STRCMP(WORD, "DataArray") == 0) {
681  if (range == VTKR_pd || range == VTKR_cd || range == VTKR_data) range = VTKR_data; else errol;
682 
683  char type = WORD[0]; // save type of data - Scalar, Vector, Tensor, DataArray
684  // head
685  if (lgc) SP_scan_word (str, WORD);
686  else { WORD = (char *)stream->tixel()->ToElement()->Attribute("Name"); if (!WORD) _errorr ("there is no attribute \"Name\""); }
687 
688  //* *** DATA for POINTS ***
689  if (ed == 'p') {
690  // bacic
691  if (_STRCMP(WORD, "Inclusion_shape" ) == 0) { auxl = 1; scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'i', WORD); for (j=0; j<noIncl; j++) if (ST_scan_number (&auxstrm, auxl ) != true) _errorr2 ("There is few numbers in section %s", WORD); else inclusions[j]->shape = (InclusionGeometry)auxl; }
692  else if (_STRCMP(WORD, "Youngs_modulus" ) == 0) { auxl = 1; scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_number (&auxstrm, inclusions[j] ->E ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
693  else if (_STRCMP(WORD, "Poissons_ratio" ) == 0) { auxl = 1; scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_number (&auxstrm, inclusions[j] ->nu ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
694 
695  else if (_STRCMP(WORD, "Semiaxes_dimensions" ) == 0) { auxl = this->give_VECT_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, inclusions[j] ->a ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
696 
697  else if (_STRCMP(WORD, "Euller_angles_deg" ) == 0) { auxl = this->give_EA_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (inclusions[j]->scan_eAngles_DEG(&auxstrm) != true) _errorr2 ("There is few numbers in section %s", WORD); }
698  else if (_STRCMP(WORD, "Euller_angles_rad" ) == 0) { auxl = this->give_EA_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (inclusions[j]->scan_eAngles_RAD(&auxstrm) != true) _errorr2 ("There is few numbers in section %s", WORD); }
699 
700  // else if (_STRNCMP(WORD, "Remote_strains_", 15 ) == 0) {
701  // auxl = atoi(WORD+18);
702  // if (this->give_nLC() == 0) { this->set_nlc_allocate_nlc_fields(auxl); lc = les = ges = 0; }
703  // else if (auxl != nLC) _errorr("Number of load cases mismatch");
704  // WORD[17] = '\0';
705  // auxl = atoi(WORD+15) - 1;
706  // pokud tady bude cteni, tak se musi udelat pres fci 'scan_...' uvnitr ktere se udela zmena notace z tensorove na feep
707  // if (auxl != lc) _errorr("Load case ID mismatch"); auxl = this->give_TENS_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, inclRec[j]->Remote_strains[lc]) != true) _errorr2 ("There is few numbers in section %s", WORD); lc++; }
708 
709  // computed values
710  else if (_STRCMP(WORD, "Action_radius" ) == 0) { auxl = 1; scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_number (&auxstrm, inclusions[j]->actionRadius ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
711  else if (_STRCMP(WORD, "Acting_inclusions_number" ) == 0) { auxl = 1; scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'i', WORD); for (j=0; j<noIncl; j++) if (ST_scan_number (&auxstrm, inclusions[j]->noActingIncls ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
712 
713  else if (_STRNCMP(WORD, "Local_Eq_strain_", 16 ) == 0) {
714  auxl = atoi(WORD+19); if (auxl != nLC) _errorr("Local_Eq_strain: Number of load cases mismatch"); WORD[18] = '\0';
715  auxl = atoi(WORD+16) - 1; if (auxl != les) _errorr("Local_Eq_strain ID mismatch");
716  auxl = this->give_VM_TENS_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if ( inclusions[j]->scan_locEigStrain_LC(&auxstrm, les) != true) _errorr2 ("There is few numbers in section %s", WORD); les++; }
717  else if (_STRNCMP(WORD, "Global_Eq_strain_", 17 ) == 0) {
718  auxl = atoi(WORD+20); if (auxl != nLC) _errorr("Global_Eq_strain: Number of load cases mismatch"); WORD[19] = '\0';
719  auxl = atoi(WORD+17) - 1; if (auxl != ges) _errorr("Global_Eq_strain ID mismatch");
720  auxl = this->give_VM_TENS_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (((InclusionRecord3D*)inclusions[j])->scan_globEigStrain_LC(&auxstrm, ges) != true) _errorr2 ("There is few numbers in section %s", WORD); ges++; }
721 
722  else if (_STRCMP(WORD, "Stiffnesses_C" ) == 0) { auxl = this->give_ISO_C_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, ((InclusionRecord3D*)inclusions[j])->C ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
723  else if (_STRCMP(WORD, "Elliptic_potentials" ) == 0) { auxl = this->give_EL_POT_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, ((InclusionRecord3D*)inclusions[j])->eInt ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
724  else if (_STRCMP(WORD, "Eshelby_tensor" ) == 0) { auxl = this->give_ISO_C_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, ((InclusionRecord3D*)inclusions[j])->S ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
725  else if (_STRCMP(WORD, "Eshelby_tensor_inverse" ) == 0) { auxl = this->give_ISO_C_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, ((InclusionRecord3D*)inclusions[j])->SInv ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
726  else if (_STRCMP(WORD, "Global_2_local_transform_matrix_for_vectors") == 0) { auxl = this->give_TRNSFM_MTRX_VEC_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, ( inclusions[j])->T ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
727  //else if (_STRCMP(WORD, "Local_2_global_transform_matrix_for_vectors") == 0) { auxl = this->give_TRNSFM_MTRX_VEC_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, ( inclRec[j])->TInv ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
728  else if (_STRCMP(WORD, "Global_2_local_transform_matrix_for_tensors") == 0) { auxl = this->give_TRNSFM_MTRX_TENS_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, ((InclusionRecord3D*)inclusions[j])->Te ) != true) _errorr2 ("There is few numbers in section %s", WORD); }
729  else if (_STRCMP(WORD, "Local_2_global_transform_matrix_for_tensors") == 0) { auxl = this->give_TRNSFM_MTRX_TENS_RANGE(); scan_DATA_field_head (stream, &auxstrm, str, type, auxl, 'f', WORD); for (j=0; j<noIncl; j++) if (ST_scan_array (&auxstrm, auxl, ((InclusionRecord3D*)inclusions[j])->TeInv) != true) _errorr2 ("There is few numbers in section %s", WORD); }
730 
731  else
732  _errorr2 ("Invalid name of SCALARS/DataArray for POINT_DATA/PointData \"%s\"", WORD);
733 
734  //
735  if (_STRCMP(WORD, "Acting_inclusions_number") == 0)
736  for (j=0; j<noIncl; j++) {
737  inclusions[j]->ActingIncls_allocate();
738  this->totalNoActingIncls += inclusions[j]->noActingIncls;
739  }
740  }
741 
742  //* *** DATA for CELLS ***
743  if (lgc) FP_skip_line (stream->file(), 1);
744  else { if (stream->tixel()->NextSibling() == NULL) stream->relink_up(); }
745  }
746  else if (_STRCMP(WORD, "") == 0) {;}
747  else _errorr2 ("Invalid structure of the given VTK file, unexpected key word \"%s\"", WORD);
748 
749  if (lgc) { if (cno) _errorr2 ("cno(%ld) is not zero", cno); }
750  else {
751  if (data && data[0] != '\0') _errorr2("CellData of name \"%s\" has too many numbers", WORD);
752  if (offs && offs[0] != '\0') _errorr("error");
753  }
754  }
755 
756  if (lgc) delete [] WORD;
757  if (status == false) _errorr("error");
758 
759  //if (lc != nLC) _errorr("few Remote_strains in input file");
760  if (this->data_equivalent) {
761  if (les != nLC) _errorr("few Local_Eq_strain in input file");
762  if (ges != nLC) _errorr("few Global_Eq_strain in input file");
763  }
764 
765  //* close
766  stream->close();
767  delete stream;
768 
769  if (amd) data_equivalent = true;
770 
771  // initialization
772  if (this->data_equivalent) {
773  if (matrix == NULL) _errorr("Matrix record is not given");
774  //if (SelfBalAlgorithm == SBAT_VOID) _errorr("SelfBalAlgorithm is not given");
775  }
776 
777 } // end of function Problem :: read_vtk_file (const char *vtkTopologyFile)
778 
779 
781 void Problem :: convert_to_equivalent_problem (void)
782 {
783  if (!this->data_set) _errorr("set");
784  if ( this->data_equivalent) _errorr("initialized");
785 
786  if (matrix == NULL) _errorr("Matrix record is not given");
787  //if (SelfBalAlgorithm == SBAT_VOID) _errorr("SelfBalAlgorithm is not given");
788 
789 
790  if (this->verbose > 0)
791  printf( "Creating inclusion records, please wait ...\n" );
792 
793  Inclusion *prevInclRec = NULL;
794 
795  for (int i=0; i<noIncl; i++) {
796  inclusions[i]->initialize(prevInclRec);
797  prevInclRec = inclusions[i];
798  }
799 
800  // inclusion dependencies, e.g. searching for adjacent inclusion with respect to acting radius
801  if (SBA_optimized) this->findAffectedInclusions();
802 
803  // incorporation of mutual interactions
804  this->updateEigenstrainsBySBalgorithm();
805 
806  //
807  this->data_equivalent = true;
808 }
809 
814 void Problem :: updateEigenstrainsBySBalgorithm (void)
815 {
816  clock_t selfUpdateTimeStart = clock( ); // time measurement 'start'
817 
818  long i, j;
819  for (i=0; i<this->give_nLC(); i++) {
820  if (this->verbose > 0)
821  printf( "Transformation strain update of LoadCase no. %ld in progress, please wait ... \n", i );
822 
823  //
824  for (j=0; j<noIncl; j++)
825  inclusions[j]->SBA_computeInitialStrains(i);
826 
827  if (this->twodim) {
828  this->updateEigenstrainsBySBalgorithm_2D (i);
829  }
830  else {
831  selfBalanceAlgorithm::totalEigStrainInInclCentroidsUpdate (this);
832  //
833  for (j=0; j<noIncl; j++)
834  ((InclusionRecord3D*)inclusions[j])->init_EigStrain_LC(i);
835  }
836  }
837 
838  //
839  clock_t selfUpdateTimeEnd = clock( ); // time measurement 'end'
840  // printing of computional time status
841  if (this->verbose > 0)
842  printf( "updateEigenstrainsBySBalgorithm: multiple self-balance algorithm time: %.5e sec\n",
843  ( selfUpdateTimeEnd - selfUpdateTimeStart )/ ( double ) CLOCKS_PER_SEC );
844 
845 }
846 
848 void Problem :: updateEigenstrainsBySBalgorithm_2D (int strainID)
849 {
850  if (SBA_type == SBAT_STANDA) {
851  //#####################################################################################
852  //##################################################### STANDOVO ######################
853  //#####################################################################################
854  double **last_eps_tau = NULL;
855 
856  double norma;
857 
858  int step = 0;
859 
860  do {
861  // maximum number of interations reached - non convergence
862  if (step >= this->get_SBA_maxiters()) _errorr("convergence not reached");
863  // required number of interations reached - break
864  if (step >= this->get_SBA_reqiters()) break;
865 
866  step++;
867  norma = updateEpsTauInSBal(strainID, last_eps_tau);
868 
869  } while (norma > _SELF_BALANCE_NORM_LIMIT_);
870 
871  if (last_eps_tau != NULL) {
872  for (int i = 0; i < this->give_nLC(); i++)delete[]last_eps_tau[i];
873  delete[]last_eps_tau;
874  }
875 
876  if (this->verbose > 0)
877  printf("\nBallancing : %d steps\n", step);
878 
879  FILE *f;
880  f = fopen("./EpsilonyTau.txt", "wt");
881  for (int i = 0; i < this->noIncl; i++) {
882  fprintf(f,"Inkluze %d\n", i);
883  for (int j = 0; j < this->inclusions[i]->n_approx_points; j++) {
884  for (int k = 0; k < this->give_VM_TENS_RANGE(); k++)fprintf(f,"%lf ", this->inclusions[i]->approx_points_eps_tau[j][k]);
885  fprintf(f,"\n");
886  }
887  }
888  fprintf(f, "Lokalni souradnice\n");
889  for (int j = 0; j < this->inclusions[0]->n_approx_points; j++) {
890  fprintf(f, "%d] %lf %lf\n", j, this->inclusions[0]->approx_points[j][0] - this->inclusions[0]->origin[0], this->inclusions[0]->approx_points[j][1] - this->inclusions[0]->origin[1]);
891  }
892 
893  fclose(f);
894 
895  //for (int i = 0; i < this->noIncl; i++)printf("%lf %lf %lf\n", this->inclusions[i]->Epsilon_Tau[strainID][0], this->inclusions[i]->Epsilon_Tau[strainID][1], this->inclusions[i]->Epsilon_Tau[strainID][2]);
896  //e(111);
897  }
898  else if (SBA_type == SBAT_ORIGINAL) {
899  //#####################################################################################
900  //##################################################### ORIGINAL ######################
901  //#####################################################################################
902  // odkomentoval jsem to, protoze to mam v testovacich prikladkach
903 
904  int i, j, jj;
905  vektor pricinek_strain(3);
906  double norma_delta_e_s;
907 
908  int step = 0;
909 
910  vektor *suma_e_s = new vektor[noIncl];
911  for (i = 0; i < noIncl; i++)
912  suma_e_s[i].define(3);
913 
914  do {
915  // maximum number of interations reached - non convergence
916  if (step >= this->get_SBA_maxiters()) _errorr("convergence not reached");
917  // required number of interations reached - break
918  if (step >= this->get_SBA_reqiters()) break;
919 
920  step++;
921  for (i = 0; i < noIncl; i++)
922  suma_e_s[i].vynulovat();
923 
924  if (SBA_optimized) {
925  for (i = 0; i < noIncl; i++) {
926  for (j = 0; j < inclusions[i]->noActingIncls; j++) {
927  jj = inclusions[i]->actingIncls[j];
928  ((InclusionRecord2D*)inclusions[jj])->compute_from_eps_tau(inclusions[i]->origin, pricinek_strain, ((InclusionRecord2D*)inclusions[jj])->delta_e_t);
929  suma_e_s[i].pricist(pricinek_strain);
930  }
931  }
932  }
933  else {
934  for (i = 0; i < noIncl; i++) {
935  for (j = 0; j < noIncl; j++) {
936  if (i != j) {
937  ((InclusionRecord2D*)inclusions[j])->compute_from_eps_tau(inclusions[i]->origin, pricinek_strain, ((InclusionRecord2D*)inclusions[j])->delta_e_t);
938  suma_e_s[i].pricist(pricinek_strain);
939  }
940  }
941  }
942  }
943 
944  for (i = 0; i < noIncl; i++)
945  ((InclusionRecord2D*)inclusions[i])->delta_e_s.rovna_se(suma_e_s[i]);
946 
947  for (i = 0; i < noIncl; i++) {
948  ((InclusionRecord2D*)inclusions[i])->compute_eps_tau_back(((InclusionRecord2D*)inclusions[i])->delta_e_s, ((InclusionRecord2D*)inclusions[i])->delta_e_t);
949 
950  AddVector(((InclusionRecord2D*)inclusions[i])->delta_e_t.v , inclusions[i]->Epsilon_Tau[strainID] , this->give_VM_TENS_RANGE());
951  }
952 
953  norma_delta_e_s = 0.0;
954  for (i = 0; i < noIncl; i++)
955  norma_delta_e_s += ((InclusionRecord2D*)inclusions[i])->delta_e_s.norma();
956 
957  } while (norma_delta_e_s > _SELF_BALANCE_NORM_LIMIT_);
958 
959  delete[] suma_e_s;
960 
961  if (this->verbose > 0)
962  printf("\nBallancing : %d steps\n", step);
963  }
964  else if (SBA_type == SBAT_MESHLESS) {
965  //#####################################################################################
966  //##################################################### MESHLESS ######################
967  //#####################################################################################
968  printf("Ballancing loadcase %d\n", strainID);
969  double **tuhost = new double*[3];
970  for (int i = 0; i < 3; i++)tuhost[i] = new double[3];
971  for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)tuhost[i][j] = 0.;
972  tuhost[0][0] = this->matrix->C[0];
973  tuhost[0][1] = this->matrix->C[1];
974  tuhost[1][0] = this->matrix->C[2];
975  tuhost[1][1] = this->matrix->C[3];
976  tuhost[2][2] = this->matrix->C[4];
977  //for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)tuhost[i][j] *= 1.2;
978  double AvSA[4], AvSB[4];
979 
980  // SET OF THE WAY OF COMPUTING
981  int way = 0;
982  bool onlyMatrixC = false;
983  bool onlyVxV = false;
984  int plus3 = 0;
985  bool onlyExternal = true;
986 
987  int celk_cyklu = this->noIncl * 3, cyklu = 0;
988  int celk_cyklu_integrace = 0;
989  for (int iA = 0; iA < noIncl; iA++)for (int iAl = 0; iAl < 3; iAl++)for (int iB = iA; iB < noIncl; iB++)for (int iBl = 0; iBl < 3; iBl++)celk_cyklu_integrace++;
990 
991 
992  double **ballance_matrix;
993  double *right_side;
994  double **load;
995  load = new double*[3];
996  for (int i = 0; i < 3; i++) load[i] = new double[3];
997  load[0][0] = 1.; load[0][1] = 0.; load[0][2] = 0.;
998  load[1][0] = 0.; load[1][1] = 1.; load[1][2] = 0.;
999  load[2][0] = 0.; load[2][1] = 0.; load[2][2] = 1.;
1000  int q = this->noIncl * 3 + plus3;
1001  int nnodes[2];
1002  FILE *ft;
1003 
1004  int nnn, pointInInclusion;
1005  double res, resv[3];
1006  double matC[3][3];
1007  for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)matC[i][j] = 0.;
1008 
1009  double ***node_values;
1010  double **nodes;
1011  double *strain;
1012  strain = new double[3];
1013  right_side = new double[q];
1014  ballance_matrix = new double *[q];
1015  for (int i = 0; i < q; i++)ballance_matrix[i] = new double[q];
1016 
1017  double problem_size[3];
1018  //update the problem size to be suitable for the mesh
1019  for (int i = 0; i < 2; i++) {
1020  if (floor(this->problem_size_A[i] / this->node_dist)*this->node_dist != this->problem_size_A[i])this->problem_size_A[i] = floor(this->problem_size_A[i] / this->node_dist)*this->node_dist;
1021  if (floor(this->problem_size_B[i] / this->node_dist)*this->node_dist != this->problem_size_B[i])this->problem_size_B[i] = floor(this->problem_size_B[i] / this->node_dist)*this->node_dist;
1022  }
1023  for (int i = 0; i < 3; i++)problem_size[i] = problem_size_B[i] - problem_size_A[i];
1024  if (problem_size[0] * problem_size[1] <= 0 || problem_size[0] < 0 || problem_size[1] < 0)_errorr("Wrong problem size.");
1025  for (int i = 0; i < 2; i++) {
1026  nnodes[i] = floor(problem_size[i] / this->node_dist) + 1;
1027  }
1028  int nnnodes = nnodes[0] * nnodes[1];
1029  node_values = new double**[this->noIncl * 3];
1030  for (int i = 0; i < this->noIncl * 3; i++) {
1031  node_values[i] = new double*[nnnodes];
1032  for (int j = 0; j < nnnodes; j++)node_values[i][j] = new double[3];
1033  }
1034  nodes = new double*[nnnodes];
1035  for (int i = 0; i < nnnodes; i++)nodes[i] = new double[3];
1036  nnn = 0;
1037  for (int i = 0; i < nnodes[1]; i++)for (int j = 0; j < nnodes[0]; j++) {
1038  nodes[nnn][0] = problem_size_A[0] + this->node_dist*j;
1039  nodes[nnn][1] = problem_size_A[1] + this->node_dist*i;
1040  nodes[nnn][2] = 0.;
1041  nnn++;
1042  }
1043 
1044 
1045  double dsds = this->node_dist*this->node_dist;
1046  double volume = problem_size[0] * problem_size[1];
1047  double dsds_div_volume = dsds / volume;
1048 
1049  int iA, iB;
1050  printf("Pocitam hodnoty strainu...\n");
1051  // compute all the strain values
1052  for (int inclA = 0; inclA < this->noIncl; inclA++)
1053  for (int inclAload = 0; inclAload < 3; inclAload++) {
1054  iA = inclA * 3 + inclAload;
1055  for (int nodeID = 0; nodeID < nnnodes; nodeID++) {
1056  if (((InclusionRecord2D*)inclusions[inclA])->point_is_inside(nodes[nodeID], 0.) == true)
1057  ((InclusionRecord2D*)inclusions[inclA])->compute_strain_pert_from_eps_zero_int(nodes[nodeID], strain, load[inclAload]);
1058  else
1059  ((InclusionRecord2D*)inclusions[inclA])->compute_strain_pert_from_eps_zero_ext(nodes[nodeID], strain, load[inclAload]);
1060 
1061  /*if (((InclusionRecord2D*)inclusions[inclA])->point_is_inside(nodes[nodeID], 0.) == true)
1062  for (int i = 0; i < 3; i++)node_values[iA][nodeID][i] = 0.;
1063  else*/
1064  for (int i = 0; i < 3; i++)node_values[iA][nodeID][i] = strain[i];
1065  }
1066  cyklu++;
1067  printf("%3.1lf %%\n", 100.*cyklu / celk_cyklu);
1068  }
1069 
1070  //e(951);
1071 
1072  // export do souboru..
1073  /*printf("Zapisuju do souboru...\n");
1074  FILE *f;
1075  FILE *tf;
1076  tf = fopen("./bal/inside.txt", "wt");
1077  char nazev_souboru[100];
1078  f = fopen("./bal/coords.txt", "wt");
1079  for (int nodeID = 0; nodeID < nnnodes; nodeID++)
1080  fprintf(f, "%lf %lf\n", nodes[nodeID][0], nodes[nodeID][1]);
1081  fclose(f);
1082 
1083  for (int inclA = 0; inclA < this->noIncl; inclA++)
1084  for (int inclAload = 0; inclAload < 3; inclAload++) {
1085  sprintf(nazev_souboru, "./bal/incl_%03d_load_%d.txt",inclA,inclAload);
1086  f = fopen(nazev_souboru, "wt");
1087  iA = inclA * 3 + inclAload;
1088  for (int nodeID = 0; nodeID < nnnodes; nodeID++) {
1089  fprintf(f, "%lf %lf %lf\n", node_values[iA][nodeID][0], node_values[iA][nodeID][1], node_values[iA][nodeID][2]);
1090  if(iA==0)fprintf(tf,"%d\n", this->give_inclusion_with_point_inside(nodes[nodeID]));
1091  }
1092  fclose(f);
1093  }
1094  fclose(tf);
1095  e(69);*/
1096 
1097 
1098 
1099 
1100  printf("Integruju...\n");
1101  cyklu = 0;
1102  // and now integrate
1103  if (onlyVxV) {
1104  for (int inclA = 0; inclA < this->noIncl; inclA++) {
1105  for (int inclAload = 0; inclAload < 3; inclAload++) {
1106  iA = inclA * 3 + inclAload;
1107 
1108  // compute the integrals for vector
1109  res = 0;
1110  for (int nodeID = 0; nodeID < nnnodes; nodeID++) {
1111  for (int i = 0; i < 3; i++)res -= node_values[iA][nodeID][i] * this->matrix->Remote_strain[strainID][i];
1112  }
1113  res *= dsds;
1114  right_side[inclA * 3 + inclAload] = res;
1115 
1116  for (int inclB = inclA; inclB < this->noIncl; inclB++) {
1117  for (int inclBload = 0; inclBload < 3; inclBload++) {
1118  iB = inclB * 3 + inclBload;
1119 
1120  // compute the integrals for matrix
1121  res = 0;
1122  for (int nodeID = 0; nodeID < nnnodes; nodeID++) {
1123  for (int i = 0; i < 3; i++)res += node_values[iA][nodeID][i] * node_values[iB][nodeID][i];
1124  }
1125  res *= dsds;
1126  ballance_matrix[inclA * 3 + inclAload][inclB * 3 + inclBload] = res;
1127  ballance_matrix[inclB * 3 + inclBload][inclA * 3 + inclAload] = res;
1128 
1129  cyklu++;
1130 
1131  }
1132  printf("%3.1lf %%\n", 100.*cyklu / celk_cyklu_integrace);
1133  }
1134  }
1135  }
1136  }
1137  else {
1138  for (int inclA = 0; inclA < this->noIncl; inclA++) {
1139  for (int inclAload = 0; inclAload < 3; inclAload++) {
1140  iA = inclA * 3 + inclAload;
1141 
1142  //MD
1143  for (int i = 0; i < 3; i++)AvSA[i] = 0.;
1144 
1145  // compute the integrals for vector
1146  res = 0;
1147  for (int nodeID = 0; nodeID < nnnodes; nodeID++) {
1148  //MD
1149  for (int i = 0; i < 3; i++)AvSA[i] += node_values[iA][nodeID][i];
1150 
1151  pointInInclusion = this->give_inclusion_with_point_inside(nodes[nodeID]);
1152  //if (pointInInclusion != inclA && pointInInclusion != inclA)pointInInclusion = -1;
1153  if (!onlyExternal || (onlyExternal && pointInInclusion == -1)) {
1154  if (pointInInclusion == -1 || onlyMatrixC) {
1155  matC[0][0] = this->matrix->C[0];
1156  matC[0][1] = this->matrix->C[1];
1157  matC[1][0] = this->matrix->C[2];
1158  matC[1][1] = this->matrix->C[3];
1159  matC[2][2] = this->matrix->C[4];
1160  }
1161  else {
1162  // toto jsme sem davali spolu, tak jsem to zakomentoval a pro jistotu zde nechal
1163  // matC[0][0] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[0] - this->matrix->C[0];
1164  // matC[0][1] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[1] - this->matrix->C[1];
1165  // matC[1][0] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[2] - this->matrix->C[2];
1166  // matC[1][1] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[3] - this->matrix->C[3];
1167  // matC[2][2] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[4] - this->matrix->C[4];
1168 
1169  matC[0][0] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[0];
1170  matC[0][1] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[1];
1171  matC[1][0] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[2];
1172  matC[1][1] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[3];
1173  matC[2][2] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[4];
1174  }
1175  for (int i = 0; i < 3; i++)resv[i] = 0.;
1176  for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)
1177  resv[i] += matC[j][i] * node_values[iA][nodeID][j];
1178  for (int i = 0; i < 3; i++)res -= resv[i] * this->matrix->Remote_strain[strainID][i];
1179 
1180  //MD
1181  if (way == 2) {
1182  for (int i = 0; i < 3; i++)resv[i] = 0.;
1183  for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)
1184  resv[i] += node_values[iA][nodeID][j] * tuhost[j][i];
1185  for (int i = 0; i < 3; i++)res += resv[i] * this->matrix->Remote_strain[strainID][i];//+
1186  }
1187  }
1188  }
1189  //e(111);
1190  //MD
1191  for (int i = 0; i < 3; i++)AvSA[i] *= dsds_div_volume;
1192 
1193  res *= dsds;
1194 
1195  //MD
1196  if (way == 1) {
1197  for (int i = 0; i < 3; i++)resv[i] = 0.;
1198  for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)
1199  resv[i] += tuhost[j][i] * AvSA[j];
1200  for (int i = 0; i < 3; i++)res += resv[i] * this->matrix->Remote_strain[strainID][i] * volume;
1201  }
1202 
1203  right_side[inclA * 3 + inclAload] = res;
1204 
1205  for (int inclB = inclA; inclB < this->noIncl; inclB++) {
1206  for (int inclBload = 0; inclBload < 3; inclBload++) {
1207  iB = inclB * 3 + inclBload;
1208 
1209  //MD
1210  for (int i = 0; i < 3; i++)AvSB[i] = 0.;
1211 
1212  // compute the integrals for matrix
1213  res = 0;
1214  for (int nodeID = 0; nodeID < nnnodes; nodeID++) {
1215  //MD
1216  for (int i = 0; i < 3; i++)AvSB[i] += node_values[iB][nodeID][i];
1217 
1218  pointInInclusion = this->give_inclusion_with_point_inside(nodes[nodeID]);
1219  //if (pointInInclusion != inclA && pointInInclusion != inclA)pointInInclusion = -1;
1220  if (!onlyExternal || (onlyExternal && pointInInclusion == -1)) {
1221  if (pointInInclusion == -1 || onlyMatrixC) {
1222  matC[0][0] = this->matrix->C[0];
1223  matC[0][1] = this->matrix->C[1];
1224  matC[1][0] = this->matrix->C[2];
1225  matC[1][1] = this->matrix->C[3];
1226  matC[2][2] = this->matrix->C[4];
1227  }
1228  else {
1229  // toto jsme sem davali spolu, tak jsem to zakomentoval a pro jistotu zde nechal
1230  // matC[0][0] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[0] - this->matrix->C[0];
1231  // matC[0][1] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[1] - this->matrix->C[1];
1232  // matC[1][0] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[2] - this->matrix->C[2];
1233  // matC[1][1] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[3] - this->matrix->C[3];
1234  // matC[2][2] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[4] - this->matrix->C[4];
1235 
1236  matC[0][0] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[0];
1237  matC[0][1] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[1];
1238  matC[1][0] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[2];
1239  matC[1][1] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[3];
1240  matC[2][2] = ((InclusionRecord2D*)inclusions[pointInInclusion])->C[4];
1241  }
1242  for (int i = 0; i < 3; i++)resv[i] = 0.;
1243  for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)
1244  resv[i] += node_values[iA][nodeID][j] * matC[j][i];
1245  for (int i = 0; i < 3; i++)res += resv[i] * node_values[iB][nodeID][i];
1246 
1247  //MD
1248  if (way == 2) {
1249  for (int i = 0; i < 3; i++)resv[i] = 0.;
1250  for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)
1251  resv[i] += node_values[iA][nodeID][j] * tuhost[j][i];
1252  for (int i = 0; i < 3; i++)res -= resv[i] * node_values[iB][nodeID][i];//-
1253  }
1254  }
1255 
1256  }
1257  //MD
1258  for (int i = 0; i < 3; i++)AvSB[i] *= dsds_div_volume;
1259 
1260  res *= dsds;
1261 
1262  if (way == 1) {
1263  //MD
1264  for (int i = 0; i < 3; i++)resv[i] = 0.;
1265  for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++)
1266  resv[i] += tuhost[j][i] * AvSA[j];
1267  for (int i = 0; i < 3; i++)res -= resv[i] * AvSB[i] * problem_size[0] * problem_size[1];
1268  }
1269 
1270  ballance_matrix[inclA * 3 + inclAload][inclB * 3 + inclBload] = res;
1271  ballance_matrix[inclB * 3 + inclBload][inclA * 3 + inclAload] = res;
1272 
1273  cyklu++;
1274 
1275  }
1276  printf("%3.1lf %%\n", 100.*cyklu / celk_cyklu_integrace);
1277  }
1278  }
1279  }
1280  }
1281  if (plus3) {
1282  for (int i = 0; i < 3; i++) {
1283  for (int j = 0; j < 3; j++) {
1284  ;
1285  }
1286  }
1287  }
1288 
1289 
1290  //printf("\nmatice sestavena\n");
1291  matice M(noIncl * 3, noIncl * 3);
1292  vektor V(noIncl * 3);
1293 
1294  for (int i = 0; i < noIncl * 3; i++)for (int j = 0; j < noIncl * 3; j++)M.g(i, j) = ballance_matrix[i][j];
1295  for (int i = 0; i < noIncl * 3; i++)V.v[i] = right_side[i];
1296 
1297  /*FILE *fo;
1298  fo = fopen("./matlab_mat.txt", "wt");
1299  M.print(fo);
1300  fclose(fo);
1301  fo = fopen("./matlab_vec.txt", "wt");
1302  V.print(fo);
1303  fclose(fo);*/
1304 
1305  printf("Resim soustavu rovnic...\n");
1306  gaussovaEliminace(M, V);
1307  V.print(stdout);
1308  e(555);
1309  double computed_load[3];
1310  for (int inclID = 0; inclID < noIncl; inclID++) {
1311  for (int j = 0; j < 3; j++)
1312  computed_load[j] = V.v[inclID * 3 + j];
1313  ((InclusionRecord2D*)inclusions[inclID])->compute_eps_tau(strainID, this->inclusions[inclID]->Epsilon_Tau[strainID], computed_load, false);
1314  }
1315 
1316  for (int i = 0; i < this->noIncl; i++)printf("%lf %lf %lf\n", this->inclusions[i]->Epsilon_Tau[strainID][0], this->inclusions[i]->Epsilon_Tau[strainID][1], this->inclusions[i]->Epsilon_Tau[strainID][2]);
1317  e(111);
1318  }
1319  else if (SBA_type == SBAT_VOID) {
1320  ;
1321  }
1322  else _errorr("Unknown SBAmode");
1323 }
1324 
1325 
1327 void Problem :: findAffectedInclusions (void)
1328 {
1329  int *auxActingIncls = NULL;
1330  int i, j;
1331 
1332  // auxiliary memory allocation
1333  auxActingIncls = new int[noIncl];
1334 
1335  // finding the dependencies
1336  for (i=0; i<noIncl; i++) {
1337  // initial initialization of the number of acting inclusions
1338  inclusions[i]->noActingIncls = 0;
1339  for (j=0; j<noIncl; j++) {
1340  if (i != j && inclusions[j]->point_is_affected(inclusions[i]->origin)) {
1341  auxActingIncls[inclusions[i]->noActingIncls] = j;
1342  inclusions[i]->noActingIncls++;
1343  }
1344  }
1345 
1346  if (this->inclusions[i]->noActingIncls != 0) {
1347  inclusions[i]->ActingIncls_allocate();
1348  CopyVector( auxActingIncls, inclusions[i]->actingIncls, inclusions[i]->noActingIncls );
1349  }
1350  }
1351 
1352  // deallocation of auxiliary memory
1353  delete [] auxActingIncls;
1354 }
1355 
1357 void Problem :: give_ovlivneni (const double *coords, double *result)
1358 {
1359  // auxiliary 'Point' memory allocation
1360  Point point;
1361  point.set_nlc (this, 1);
1362  point.x[0] = coords[0];
1363  point.x[1] = coords[1];
1364  point.x[2] = coords[2];
1365 
1366  if (inclusions[0]->point_is_inside(point.x, 1.e-7)) {
1367  CopyVector(((InclusionRecord3D*) inclusions[0])->locEigStrain, result, 6);
1368  }
1369  else {
1370  CleanVector(((InclusionRecord3D*) inclusions[0])->locEigStrainTot, 6);
1371  ((InclusionRecord3D*) inclusions[0])->esuf->giveEshelbyStrainOfOnePoint(&point);
1372  ((InclusionRecord3D*) inclusions[0])->SBA_updateGlobAndLocStrains(&point);
1373 
1374  CopyVector(((InclusionRecord3D*) inclusions[0])->locEigStrainTot, result, 6);
1375  }
1376 }
1377 
1379 double Problem :: compute_supplement_energy (int lc)
1380 {
1381  double E = 0.0;
1382  for (int i=0; i<noIncl; i++)
1383  E += this->inclusions[i]->compute_supplement_energy(lc);
1384 
1385  return E;
1386 }
1387 
1388 
1389 
1390 // ********************************************************************************************************
1391 // *** *** *** *** PRINT FUNCTIONS *** *** *** ***
1392 // ********************************************************************************************************
1393 
1394 //* *** ELEMENTS ***
1395 void print_VTK_elems_head (Stream *stream, long noIncl)
1396 {
1397  long i;
1398 
1399  if (stream->isFile()) {
1400  fprintf (stream->file(), "CELLS %ld %ld\n", noIncl, 2*noIncl);
1401  for (i=0; i<noIncl; i++)
1402  fprintf (stream->file(), "1 %ld\n", i);
1403 
1404  fprintf (stream->file(), "CELL_TYPES %ld\n", noIncl);
1405  for (i=0; i<noIncl; i++)
1406  fprintf (stream->file(), "1\n");
1407  }
1408  else {
1409  stream->tixel()->SetAttribute("NumberOfCells", (int)noIncl);
1410 
1411  XMLElement *cells = stream->tix_doc()->NewElement("Cells"); stream->tixel()->InsertEndChild(cells);
1412 
1413  XMLElement *dac = stream->tix_doc()->NewElement("DataArray"); cells->InsertEndChild(dac);
1414  dac->SetAttribute("format", "ascii");
1415  dac->SetAttribute("type", "Int32");
1416  dac->SetAttribute("Name", "connectivity");
1417 
1418  XMLElement *dao = (XMLElement*)dac->ShallowClone(NULL); cells->InsertEndChild(dao);
1419  dao->SetAttribute("Name", "offsets");
1420 
1421  XMLElement *dat = (XMLElement*)dac->ShallowClone(NULL); cells->InsertEndChild(dat);
1422  dat->SetAttribute("type", "UInt8");
1423  dat->SetAttribute("Name", "types");
1424 
1425  char auxs[7];
1426  sprintf (auxs,"0");
1427  for (long i=1; i<=noIncl; i++) {
1428  ; dac->InsertEndChild(stream->tix_doc()->NewText(auxs));
1429  sprintf (auxs,"%ld", i); dao->InsertEndChild(stream->tix_doc()->NewText(auxs));
1430  ; dat->InsertEndChild(stream->tix_doc()->NewText("1" ));
1431  }
1432  }
1433 }
1434 
1435 
1436 
1437 // *** SCALAR / VECTOR / TENSOR body ***
1438 XMLElement* print_VTK_field_head (Stream *stream, const char *name, char format, int slen, int noincl)
1439 {
1440  XMLElement *da = NULL;
1441 
1442  char flint[8];
1443  if (format == 'i') { if (stream->isFile()) sprintf(flint,"int"); else sprintf(flint,"Int32"); }
1444  else if (format == 'f') { if (stream->isFile()) sprintf(flint,"float"); else sprintf(flint,"Float32"); }
1445  else errol;
1446 
1447  if (stream->isFile()) {
1448  fprintf (stream->file(), "%s %d %d %s\n", name, noincl, slen, flint);
1449  }
1450  else {
1451  errol;
1452  //da = stream->tix_doc()->NewElement("DataArray"); stream->tixel()->InsertEndChild(da);
1453  //da->SetAttribute("format", "ascii");
1454  //da->SetAttribute("type", flint);
1455  //da->SetAttribute("Name", name);
1456  //if (type == 's') da->SetAttribute("NumberOfComponents", "1");
1457  //else if (type == 'v') da->SetAttribute("NumberOfComponents", "3");
1458  //else if (type == 't') da->SetAttribute("NumberOfComponents", "9");
1459  //else _errorr ("error");
1460  }
1461 
1462  return da;
1463 }
1464 
1465 
1466 
1467 // ///
1468 // void print_values (char *auxs, int n, const double *values, int rv)
1469 // {
1470 // if (n==0) {
1471 // _errorr("");
1472 // auxs[0] = '\0';
1473 // return;
1474 // }
1475 //
1476 // //int n1 = 15;
1477 // int n1 = 14; // debug
1478 // int pos = 0;
1479 //
1480 // for (int i=0; i<n; i++) {
1481 // sprintf (auxs+pos, "%*.*e", n1, 8, values[i]); pos += n1;
1482 //
1483 // if (auxs[pos] != '\0') pos++;
1484 // if (auxs[pos] != '\0') errol;
1485 //
1486 // if (i+1<n) {
1487 // if ((i+1)%rv == 0) sprintf (auxs+pos, "\n");
1488 // else sprintf (auxs+pos, " ");
1489 // pos++;
1490 // }
1491 // }
1492 // }
1494 
1495 
1497 void print_valuesi (char *auxs, int n, const int *values, int rv)
1498 {
1499  if (n==0) {
1500  auxs[0] = '\0';
1501  return;
1502  }
1503 
1504  int pos = 0;
1505 
1506  for (int i=0; i<n; i++) {
1507  sprintf (auxs+pos, "%15d", values[i]); pos += 15;
1508 
1509  if (auxs[pos] != '\0') pos++;
1510  if (auxs[pos] != '\0') errol;
1511 
1512  if (i+1<n) {
1513  if ((i+1)%rv == 0) sprintf (auxs+pos, "\n");
1514  else sprintf (auxs+pos, " ");
1515  pos++;
1516  }
1517  }
1518 }
1519 
1520 
1521 //
1522 void Problem :: printVtkFileCompleteInclRec (const char *rsltFileName)
1523 {
1524  long i, j;
1525  XMLElement *da;
1526  long auxl;
1527  Stream *stream;
1528  bool lgc = true;
1529  char auxs[20001]; auxs[20000] = '\0';
1530 
1531  // allocate stream
1532  if (lgc) stream = new Stream(STRM_file);
1533  else stream = new Stream(STRM_tixel);
1534 
1535  //* START
1536  char *filename = new char[255];
1537  strcpy(filename, rsltFileName);// do not delete filename, it is deleted inside of the function
1538  //
1539  print_VTK_START (stream, filename);
1540 
1541  //* HEAD
1542  char type[8];
1543  if (this->twodim) sprintf (type,"2Dequiv");
1544  else sprintf (type,"3Dequiv");
1545 
1546  if (lgc)
1547  print_VTK_head (stream->file(), type);
1548 
1549  //* NODES
1550  da = print_VTK_nodes_head (stream, this->noIncl);
1551 
1552  for (i=0; i<this->noIncl; i++) {
1553  sprintf (auxs, "%15.8e %15.8e %15.8e", this->inclusions[i]->origin[0], this->inclusions[i]->origin[1], this->inclusions[i]->origin[2]);
1554 
1555  if (lgc) fprintf (stream->file(), "%s\n", auxs);
1556  else da->InsertEndChild( stream->tix_doc()->NewText(auxs) );
1557  }
1558 
1559  // ELEMENTS
1560  print_VTK_elems_head (stream, this->noIncl);
1561 
1562 
1563  // FIELDS
1564  fprintf (stream->file(), "FIELD unstructured_data %d\n", 4);
1565  // SBA
1566  da = print_VTK_field_head (stream, "SBA_mode", 'i', 1, 1);
1567  sprintf (auxs, "%d", 1 + (int)this->SBA_optimized);
1568  print_auxs (lgc, stream, da, auxs);
1569  // intFieldsShape
1570  da = print_VTK_field_head (stream, "conversion_mode", 'i', 1, 1);
1571  sprintf (auxs, "%d", this->intFieldsShape);
1572  print_auxs (lgc, stream, da, auxs);
1573  // Matrix record
1574  da = print_VTK_field_head (stream, "Matrix_record", 'f', 2, 1);
1575  sprintf (auxs , "%12.6e", this->matrix->E());
1576  sprintf (auxs+12, " %12.6e", this->matrix->nu());
1577  print_auxs (lgc, stream, da, auxs);
1578  // Remote_strains
1579  da = print_VTK_field_head (stream, "Remote_strains", 'f', this->give_nLC(), this->give_TENS_RANGE());
1580  double rs[9];
1581  for (i=0; i<this->give_nLC(); i++) {
1582  CopyVector (this->matrix->Remote_strain[i], rs, this->give_TENS_RANGE());
1585 
1586  for (j=0; j<this->give_TENS_RANGE(); j++)
1587  sprintf (auxs+j*13, " %12.6e", rs[j]);
1588 
1589  print_auxs (lgc, stream, da, auxs);
1590  }
1591 
1592  // POINT DATA
1593  print_VTK_init_point_data (stream, this->noIncl);
1594 
1595  auxl = 1; da = print_VTK_data_head (stream, "Inclusion_shape", 's', 'i', auxl); for (i=0; i<this->noIncl; i++) { sprintf (auxs, "%d", this->inclusions[i]->shape); print_auxs (lgc, stream, da, auxs); }
1596  auxl = 1; da = print_VTK_data_head (stream, "Youngs_modulus", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { sprintf (auxs, "%.8e", this->inclusions[i] ->E ); print_auxs (lgc, stream, da, auxs); }
1597  auxl = 1; da = print_VTK_data_head (stream, "Poissons_ratio", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { sprintf (auxs, "%.8e", this->inclusions[i] ->nu ); print_auxs (lgc, stream, da, auxs); }
1598  auxl = this->give_VECT_RANGE(); da = print_VTK_data_head (stream, "Semiaxes_dimensions", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i] ->a ); print_auxs (lgc, stream, da, auxs); }
1599  auxl = this->give_EA_RANGE(); da = print_VTK_data_head (stream, "Euller_angles_rad", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i]->eAngles ); print_auxs (lgc, stream, da, auxs); }
1600  auxl = 1 ; da = print_VTK_data_head (stream, "Action_radius", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { sprintf (auxs, "%.8e", this->inclusions[i]->actionRadius); print_auxs (lgc, stream, da, auxs); }
1601 
1602  if (! this->twodim) { da = print_VTK_data_head (stream, "Acting_inclusions_number", 's', 'i', 1); for (i=0; i<this->noIncl; i++) { sprintf (auxs, "%d", this->inclusions[i]->noActingIncls); print_auxs (lgc, stream, da, auxs); } }
1603 
1604  auxl = this->give_ISO_C_RANGE(); da = print_VTK_data_head (stream, "Stiffnesses_C", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i]->C); print_auxs (lgc, stream, da, auxs); }
1605 
1606  if (! this->twodim) { da = print_VTK_data_head (stream, "Elliptic_potentials", 's', 'f', 13); for (i=0; i<this->noIncl; i++) { print_values (auxs, 13, ((InclusionRecord3D*)this->inclusions[i])->eInt); print_auxs (lgc, stream, da, auxs); } }
1607 
1608  auxl = this->give_ISO_C_RANGE(); da = print_VTK_data_head (stream, "Eshelby_tensor", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i]->S); print_auxs (lgc, stream, da, auxs); }
1609 
1610  if (! this->twodim) { da = print_VTK_data_head (stream, "Eshelby_tensor_inverse", 's', 'f', 12); for (i=0; i<this->noIncl; i++) { print_values (auxs, 12, ((InclusionRecord3D*)this->inclusions[i])->SInv); print_auxs (lgc, stream, da, auxs); } }
1611 
1612  auxl = this->give_TRNSFM_MTRX_VEC_RANGE(); da = print_VTK_data_head (stream, "Global_2_local_transform_matrix_for_vectors", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i]->T); print_auxs (lgc, stream, da, auxs); }
1613  // = this->give_TRNSFM_MTRX_VEC_RANGE(); da = print_VTK_data_head (stream, "Local_2_global_transform_matrix_for_vectors", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i]->TInv); print_auxs (lgc, stream, da, auxs); }
1614  auxl = this->give_TRNSFM_MTRX_TENS_RANGE(); da = print_VTK_data_head (stream, "Global_2_local_transform_matrix_for_tensors", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i]->Te); print_auxs (lgc, stream, da, auxs); }
1615  auxl = this->give_TRNSFM_MTRX_TENS_RANGE(); da = print_VTK_data_head (stream, "Local_2_global_transform_matrix_for_tensors", 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i]->TeInv); print_auxs (lgc, stream, da, auxs); }
1616 
1617 
1618  int nlc = this->give_nLC();
1619 
1620  if (this->twodim) {
1621  auxl = this->give_VM_TENS_RANGE();
1622  for (j=0; j<nlc; j++) { sprintf (auxs, "Local_Eq_strain_%02ld_%02d", j+1, nlc); da = print_VTK_data_head (stream, auxs, 's', 'f', auxl); for (i=0; i<this->noIncl; i++) { print_values (auxs, auxl, this->inclusions[i]->Epsilon_Tau[j]); print_auxs (lgc, stream, da, auxs); } }
1623  }
1624  else {
1625  for (j=0; j<nlc; j++) { sprintf (auxs, "Local_Eq_strain_%02ld_%02d", j+1, nlc); da = print_VTK_data_head (stream, auxs, 's', 'f', 6); for (i=0; i<this->noIncl; i++) { print_values (auxs, 6, ((InclusionRecord3D*)this->inclusions[i])->locEigStrain_LC[j]); print_auxs (lgc, stream, da, auxs); } }
1626 
1627  for (j=0; j<nlc; j++) { sprintf (auxs, "Global_Eq_strain_%02ld_%02d", j+1, nlc); da = print_VTK_data_head (stream, auxs, 's', 'f', 6); for (i=0; i<this->noIncl; i++) { print_values (auxs, 6, ((InclusionRecord3D*)this->inclusions[i])->globEigStrain_LC[j]); print_auxs (lgc, stream, da, auxs); } }
1628 
1629  // FIELDS
1630  fprintf (stream->file(), "FIELD unstructured_data %d\n", 1);
1631  // Acting inclusions
1632  auxl = this->totalNoActingIncls;
1633  da = print_VTK_field_head (stream, "Acting_inclusions_list", 'i', auxl, 1);
1634  for (i=0; i<this->noIncl; i++) {
1635  print_valuesi (auxs, this->inclusions[i]->noActingIncls, this->inclusions[i]->actingIncls, 10);
1636  print_auxs (lgc, stream, da, auxs);
1637  }
1638  }
1639 
1640  // END
1641  print_VTK_FINISH (stream);
1642  delete stream;
1643 
1644 }//end of function: printVtkFileCompleteInclRec()
1645 
1647 long Problem :: give_inclusion_with_point_inside (const double *coords, double epsilon) const
1648 {
1649  long i;
1650  for (i=0; i<noIncl; i++)
1651  if (inclusions[i]->point_is_inside(coords, epsilon) == true) {
1652  //printf("inside: %d\n",i);
1653  return i;
1654  }
1655 
1656  return -1;
1657 }
1658 
1659 
1661 void convertTensorStrain (bool twodim, double *tens, STRNotation oldNot, STRNotation newNot)
1662 {
1663  //
1664  if (oldNot == STRN_THEORETICAL_FEEP) {
1665  if (newNot == STRN_THEORETICAL_FEEP) { ; }
1666  else if (newNot == STRN_THEORETICAL_ROW) {
1669  }
1670  else if (newNot == STRN_VOIGT_FEEP) {
1673  }
1674  else _errorr ("not supported notation");
1675  }
1676  else
1677  _errorr ("not supported notation");
1678 }
1680 void convertTensorStress (bool twodim, double *tens, STRNotation oldNot, STRNotation newNot)
1681 {
1682  //
1683  if (oldNot == STRN_THEORETICAL_FEEP) {
1684  if (newNot == STRN_THEORETICAL_FEEP) { ; }
1685  else if (newNot == STRN_THEORETICAL_ROW) {
1688  }
1689  else if (newNot == STRN_VOIGT_FEEP) { ; }
1690  else _errorr ("not supported notation");
1691  }
1692  else
1693  _errorr ("not supported notation");
1694 }
1695 
1696 
1697 
1699 long Problem :: giveFieldsOfPointOneRS (double *displc, double *strain, double *stress, const double *coords,
1700  char ptFlag, int rs, PFCmode pfcMode, long reqIncl, STRNotation tn) const
1701 {
1702  return this->giveFieldsOfPoint ( displc ? &displc : NULL, strain ? &strain : NULL, stress ? &stress : NULL, coords, ptFlag, rs, 1, pfcMode, reqIncl, tn);
1703 }
1704 
1706 long Problem :: giveFieldsOfPoint (double **displc, double **strain, double **stress, const double *coords,
1707  char ptFlag, int rs, int nrs, PFCmode pfcMode, long reqIncl, STRNotation tn) const
1708 {
1709  // perturbation fields
1710  long parent_incl = this->give_EshelbyPertFieldsOnePoint (coords, displc, strain, stress, rs, nrs, pfcMode, reqIncl);
1711 
1712  // add homogeneous fields in case of total fields
1713  if (ptFlag == 't') {
1714  for (int i=0; i<nrs; i++) {
1715  // pro kontrolu dilute
1716  //if (parent_incl == -1) {
1717  // CleanVector(strain[i], this->give_VM_TENS_RANGE());
1718  // CleanVector(stress[i], this->give_VM_TENS_RANGE());
1719  //}
1720  if (displc) AddVector (this->matrix->give_globHomog_Displc(i+rs, coords), displc[i], this->give_VECT_RANGE());
1721  if (strain) AddVector (this->matrix->give_globHomog_Strain(i+rs), strain[i], this->give_VM_TENS_RANGE());
1722  if (stress) AddVector (this->matrix->give_globHomog_Stress(i+rs), stress[i], this->give_VM_TENS_RANGE());
1723  }
1724  }
1725  else if (ptFlag != 'p') _errorr("wrong pt flag");
1726 
1727  // convert to required notation
1728  if (strain) for (int i=0; i<nrs; i++) convertTensorStrain(twodim, strain[i], STRN_THEORETICAL_FEEP, tn);
1729  if (stress) for (int i=0; i<nrs; i++) convertTensorStress(twodim, stress[i], STRN_THEORETICAL_FEEP, tn);
1730 
1731  return parent_incl;
1732 }
1733 
1734 
1736 long Problem :: give_EshelbyPertFieldsOnePoint (const double *coo, double **displc, double **strain, double **stress,
1737  int lc, int nlc, PFCmode pfcMode, long reqIincl) const
1738 {
1739  double *coords;
1740  // shift of coordinates od inclusion set
1741  if (this->matrix->origin) {
1742  coords = new double[3];
1743  SubtractTwoVectors (coo, this->matrix->origin, coords, this->give_VECT_RANGE());
1744  }
1745  else
1746  coords = (double*)coo;
1747 
1748  nlc = this->check_lc_nlc(lc, nlc);
1749 
1750  // point position
1751  long parent_incl;
1752 
1753  // no supposal of point position
1754  if (reqIincl == -3) {
1755  parent_incl = this->give_inclusion_with_point_inside (coords, 0.0);
1756  }
1757  // point is supposed to lay on any inclusion
1758  else if (reqIincl == -2) {
1759  parent_incl = this->give_inclusion_with_point_inside (coords, 1.e-6);
1760  if (parent_incl == -1)
1761  _errorr("point doesnot lay on inclusion, nekde asi zustala -2, ted tam ma byt -3 pro neurcitou polohu");
1762  }
1763  // point is supposed to lay on matrix
1764  else if (reqIincl == -1) {
1765  parent_incl = this->give_inclusion_with_point_inside (coords, -1.e-6);
1766  if (parent_incl != -1)
1767  _errorr("point doesnot lay on matrix");
1768  }
1769  // point is supposed to lay on an inclucion
1770  else if (reqIincl >= 0) {
1771  parent_incl = reqIincl;
1772  if (inclusions[parent_incl]->point_is_inside (coords, 1.e-3) == false)
1773  _errorr("point doesnot lay inside of the supposed inclusion");
1774  }
1775  else errol;
1776 
1777  // *** EVALUATION OF PERTURBATION FIELDS ***
1778  if (displc != NULL || strain != NULL || stress != NULL) {
1779  //parent_incl = -1; // pro debug hrany NEMAZAT
1780 
1782 
1855  double **strain_r;
1856  double **e_t_updated;
1857 
1858 
1859  // termitovo, na toto si udelat prikladek o dvou inkluzich, a porovnat grafy
1860  // zaroven poradne pochopit standovo balancing
1861  // pak vykostit starej balancing, asi
1862  // intFieldsShape:
1863  // 0 = nekonstanta, s pricinku vnejsich inkluzi redukovana
1864  // 1 = polynomial - if available
1865  // 2 = konstanta, s pricinku vnejsich inkluzi redukovana
1866  // 3 = nekonstanta, s pricinku vnejsich inkluzi neredukovana
1867  // 4 = konstanta, bez pricinku vnejsich inkluzi
1868 
1869 
1870  if (parent_incl == -1) {
1871  // EXTERIOR POINT
1872  this->give_EshelbyPertFieldsOnePoint_external (coords, displc, strain, stress, lc, nlc, pfcMode, parent_incl);
1873  }
1874  else {
1875  // INTERIOR POINT
1876 
1877  // SUM EXT AND RECALCULATE, THEN ADD INT
1878  if (intFieldsShape == 0) {
1879  // I need to compute strain even if strain==NULL
1880  if (strain) strain_r = strain;
1881  else strain_r = AllocateArray2D(nlc, this->give_VM_TENS_RANGE());
1882 
1883  // add ext
1884  this->give_EshelbyPertFieldsOnePoint_external(coords, displc, strain_r, stress, lc, nlc, pfcMode, parent_incl);
1885 
1886  // field for recalculated eps_tau
1887  e_t_updated = AllocateArray2D(nlc, this->give_VM_TENS_RANGE());
1888 
1889  if (strain || stress) {
1890  // computing the eps_tau
1891 
1892  // termitovo a bude to tady vubec fungovat kdyz nebude spustenej balancing??
1893  // termitovo takze tady se v danem bode spocita strain_r jako vnejsi zatizeni a pak z predpokladu konstantniho prubehu se spocte epstau a z nej strain
1894  // ale kdyz neni vnejsi zatizeni konstanta, tak by tady spis mel byt polynom, ne?
1895 
1896  // termitovo proc je tady true, tim se pocita na inkluzi strain_r plus remote_strain, neni lepsi dat false a nakonci secist s strainGlob...
1897  for (int i = 0; i < nlc; i++) ((InclusionRecord2D*)inclusions[parent_incl])->compute_eps_tau(i+lc, e_t_updated[i], strain_r[i], true);
1898  // termitovo jaktoze je tady add, nema to neco spolecneho s CHYBOU kde nesouhlasi strain se steessem?
1899  // musim si prostudovat balancing
1900  this->inclusions[parent_incl]->add_EshelbyPertStrain_internal_SIFCM (strain_r, lc, nlc, e_t_updated);
1901 
1902  if (stress) {
1903  CleanArray2d(stress, nlc, this->give_VM_TENS_RANGE());
1904  this->inclusions[parent_incl]->add_EshelbyPertStress_internal_SIFCM(stress, lc, nlc, e_t_updated, strain_r);
1905  }
1906  }
1907 
1908  if (!strain) DeleteArray2D (strain_r, nlc);
1909 
1910  DeleteArray2D (e_t_updated, nlc);
1911 
1912  if (displc) {
1913  //CleanArray2d(displc, nlc, this->give_VECT_RANGE());
1914  // add bylo uvnitr fce, vytahl jsem to nahoru at je to videt
1915  // termitovo proc je tady add??
1916  AddArray2D (this->inclusions[parent_incl]->give_EshelbyPertDisplc_internal(lc, nlc, coords), displc, nlc, this->give_VECT_RANGE());
1917  }
1918  }
1919 
1920  // POLYNOMIAL INT FIELDS
1921  if (intFieldsShape == 1) {
1922  _errorr("Not implemented yet.");
1923  }
1924 
1925  // CONST INT STRAIN AND STRESS
1926  if (intFieldsShape == 2) {
1927  this->give_EshelbyPertFieldsOnePoint_external(this->inclusions[parent_incl]->origin, displc, strain, stress, lc, nlc, pfcMode, parent_incl);
1928 
1929  if (strain) AddArray2D (this->inclusions[parent_incl]->give_EshelbyPertStrain_internal(lc, nlc) , strain, nlc, this->give_VM_TENS_RANGE());
1930  if (stress) AddArray2D (this->inclusions[parent_incl]->give_EshelbyPertStress_internal(lc, nlc) , stress, nlc, this->give_VM_TENS_RANGE());
1931  if (displc) AddArray2D (this->inclusions[parent_incl]->give_EshelbyPertDisplc_internal(lc, nlc, coords), displc, nlc, this->give_VECT_RANGE() );
1932  }
1933 
1934  // SUM ALL
1935  if (intFieldsShape == 3) {
1936  this->give_EshelbyPertFieldsOnePoint_external(coords, displc, strain, stress, lc, nlc, pfcMode, parent_incl);
1937 
1938  if (strain) AddArray2D (this->inclusions[parent_incl]->give_EshelbyPertStrain_internal(lc, nlc) , strain, nlc, this->give_VM_TENS_RANGE());
1939  if (stress) AddArray2D (this->inclusions[parent_incl]->give_EshelbyPertStress_internal(lc, nlc) , stress, nlc, this->give_VM_TENS_RANGE());
1940  if (displc) AddArray2D (this->inclusions[parent_incl]->give_EshelbyPertDisplc_internal(lc, nlc, coords), displc, nlc, this->give_VECT_RANGE() );
1941  }
1942 
1943  // CONST INT STRAIN AND STRESS - only the current inclusion
1944  if (intFieldsShape == 4) {
1945  if (strain) CopyArray2D (this->inclusions[parent_incl]->give_EshelbyPertStrain_internal(lc, nlc) , strain, nlc, this->give_VM_TENS_RANGE());
1946  if (stress) CopyArray2D (this->inclusions[parent_incl]->give_EshelbyPertStress_internal(lc, nlc) , stress, nlc, this->give_VM_TENS_RANGE());
1947  if (displc) CopyArray2D (this->inclusions[parent_incl]->give_EshelbyPertDisplc_internal(lc, nlc, coords), displc, nlc, this->give_VECT_RANGE() );
1948  }
1949 
1950  }
1951 
1952  }
1953 
1954 
1955  // dealloc
1956  if (this->matrix->origin) delete [] coords;
1957  else coords = NULL;
1958 
1959  return parent_incl;
1960 }
1961 
1962 
1964 void Problem :: give_EshelbyPertFieldsOnePoint_external (const double *coords, double **displc, double **strain, double **stress,
1965  int lc, int nlc, PFCmode pfcMode, long parent_incl) const
1966 {
1967  Inclusion *incl;
1968 
1969  // affected inclusions
1970  long noActIncls;
1971  long *actIncls = NULL;
1972  if (pfcMode == PFCM_FULL) {
1973  noActIncls = this->noIncl;
1974  }
1975  else if (pfcMode == PFCM_OPTIMIZED) {
1976  // creating of auxiliary fields
1977  actIncls = new long[this->noIncl];
1978  //searching for acting inclusions
1979  noActIncls = this->giveActingInclusions(actIncls, coords);
1980  }
1981  else _errorr("giveEshelbyPertFieldsOfOnePoint: unknofn PFCmode");
1982 
1983  // tenhle point mozna alokovat na Problemu at se furt nealokuje znovu
1984  Point *point = new Point;
1985  point->set_nlc(this, nlc);
1986  CopyVector (coords, point->x, this->give_VECT_RANGE());
1987 
1988  bool delstrain = false;
1989  // initialization fields
1990  if (stress && strain == NULL) {
1991  delstrain = true;
1992  AllocateArray2D (strain, nlc, this->give_VM_TENS_RANGE());
1993  }
1994 
1995  if (displc) CleanArray2d (displc, nlc, this->give_VECT_RANGE());
1996  if (strain) CleanArray2d (strain, nlc, this->give_VM_TENS_RANGE());
1997 
1998  for (int i=0; i<noActIncls; i++) {
1999  if (parent_incl == i) continue;
2000 
2001  // affected inclusion
2002  if (pfcMode == PFCM_FULL) incl = this->inclusions[i];
2003  else incl = this->inclusions[actIncls[i]];
2004 
2005  // calculation of perturbation fields
2006  incl->give_EshelbyPertFields_external (point, lc, nlc, displc, strain);
2007 
2008  // superposition of perturbation fields from all inclusions
2009  if (displc) AddArray2D (point->displacement, displc, nlc, this->give_VECT_RANGE() );
2010  if (strain) AddArray2D (point->strain, strain, nlc, this->give_VM_TENS_RANGE());
2011  }
2012 
2013  // evaluation of stress perturbation
2014  if (stress) {
2015  for (int i=0; i<nlc; i++)
2016  if (twodim) MatrixOperations::giveTVproduct_3is3x3to5and3 (stress[i], this->matrix->C, strain[i]);
2017  else MatrixOperations::giveTVproduct_6is6x6to12and6 (stress[i], this->matrix->C, strain[i]);
2018  }
2019 
2020  // deallocation
2021  if (pfcMode == PFCM_OPTIMIZED) delete [] actIncls;
2022  if (delstrain) DeleteArray2D (strain, nlc);
2023  delete point;
2024 
2025 }//end of function: addEshelbyPertFieldsOfOnePoint( )
2026 
2028 void Problem :: printFieldsOnMeshVTK (const char *mesh_file_out, const char *mesh_file,
2029  char ptFlag, int rs, int nrs,
2030  PFCmode pfcMode) const
2031 {
2032  nrs = this->check_lc_nlc(rs, nrs);
2033 
2034  Mesh mesh(1, this);
2035  mesh.read_geometry_file_vtk (mesh_file, -1, -1, false);
2036  mesh.compute_node_fields(ptFlag, true, true, true, 0, rs, nrs, pfcMode);
2037  mesh.print_geometry_file_vtk (mesh_file_out, 0, rs, nrs);
2038 }
2039 
2041 void Problem :: printFieldsOnMeshGrid (const char *mesh_file_out, const double *p1, const double *p2, const long *n,
2042  char ptFlag, int rs, int nrs,
2043  PFCmode pfcMode) const
2044 {
2045  nrs = this->check_lc_nlc(rs, nrs);
2046 
2047  Mesh mesh(1, this);
2048  mesh.generate_regular_mesh (p1, p2, n);
2049  mesh.compute_node_fields(ptFlag, true, true, true, 0, rs, nrs, pfcMode);
2050  mesh.print_geometry_file_vtk (mesh_file_out, 0, rs, nrs);
2051 }
2052 
2053 
2054 
2055 
2056 
2057 
2059 Problem *Problem::read_inclusions_plus_initialize_and_print (const char *inclusion_file, const char *equiv_file, DiffTypes dt)
2060 {
2061  this->set_diffType (dt);
2062  this->read_input_file (inclusion_file);
2063 
2064  this->input_data_initialize_and_check_consistency();
2065 
2066  if (this->data_equivalent == false)
2067  this->convert_to_equivalent_problem ();
2068 
2069  if (equiv_file)
2070  this->print_equivalent_problem (equiv_file);
2071 
2072  return this;
2073 }
2074 
2076 Mesh* Problem :: give_new_mesh (void)
2077 {
2078  meshes[nmeshes] = new Mesh(nmeshes, this);
2079  nmeshes++;
2080  return meshes[nmeshes-1];
2081 }
2082 
2084 Homogenization* Problem :: give_new_homogenization (HomogenizationType ht)
2085 {
2086  switch( ht )
2087  {
2088  case HT_Dilute: {
2089  homogs[nhomogs] = new Dilute(nhomogs, this);
2090  break;
2091  }
2092  case HT_MoriTanaka: {
2093  homogs[nhomogs] = new MoriTanaka(nhomogs, this);
2094  break;
2095  }
2096  case HT_ReussBound: {
2097  homogs[nhomogs] = new ReussBound(nhomogs, this);
2098  break;
2099  }
2100  case HT_VoightBound: {
2101  homogs[nhomogs] = new VoightBound(nhomogs, this);
2102  break;
2103  }
2104  case HT_RegGrid: {
2105  homogs[nhomogs] = new RegGrid(nhomogs, this);
2106  break;
2107  }
2108  case HT_DifferentialScheme: {
2109  homogs[nhomogs] = new DifferentialScheme(nhomogs, this);
2110  break;
2111  }
2112  default:
2113  _errorr( "Unknown homogenization type" );
2114 
2115  }
2116 
2117  nhomogs++;
2118  return homogs[nhomogs-1];
2119 }
2120 
2122 void Problem :: print_equivalent_problem (const char *vtkTopologyFileRec)
2123 {
2124  // gives the total value of Kn number. Kn is the numbre of inclusion within the action region of each inclusion
2125  this->totalNoActingIncls = 0;
2126  for (long i=0; i<noIncl; i++)
2127  this->totalNoActingIncls += inclusions[i]->noActingIncls;
2128 
2129  // printing the complete inclusion topology and geometry file containing equivalent strains
2130  this->printVtkFileCompleteInclRec (vtkTopologyFileRec);
2131 }
2132 
2133 
2134 
2137 //void Problem :: compute_fields_and_cmp_with_FEM_on_mesh (const char *mesh_file, const char *fem_results, int lc, int nlc, PFCmode pfcMode)
2138 //{
2139  // nlc = P->check_lc_nlc(lc, nlc);
2140  //
2141  // Mesh mesh(1, this);
2142  // mesh.read_geometry_file_vtk (mesh_file);
2143  // mesh.compute_fields(lc, nlc, pfcMode);
2144  // mesh.print_geometry_file_vtk (mesh_file_out, lc, nlc);
2145 //}
2146 
2147 
2148 
2149 
2150 
2151 //********************************************************************************************************
2152 // PROTECTED FUNCTIONS
2153 //********************************************************************************************************
2154 
2155 
2156 //********************************************************************************************************
2157 // description: function gives a set of acting inclusions to a given point. Function returns the number
2158 // of acting inclusions. Function is a clon of 'inclRecordInit::giveAffectedInclusions'
2159 // method.
2160 // last edit: 17. 03. 2010
2161 // -------------------------------------------------------------------------------------------------------
2162 // note: @actIncls - pointer to an empty array on noIncls size, i.e.: actIncls[noIncls]
2163 // @coords - coordinates of a point to be checked out
2164 //********************************************************************************************************
2165 long Problem :: giveActingInclusions (long *actIncls, const double *coords) const
2166 {
2167  long noActIncls = 0;
2168 
2169  //finding the dependencies
2170  for (long i=0; i<this->noIncl; i++)
2171  if (inclusions[i]->point_is_affected(coords)) {
2172  actIncls[noActIncls] = i;
2173  noActIncls++;
2174  }
2175 
2176  return noActIncls;
2177 }//end of function: giveActingInclusions( )
2178 
2179 
2181 double Problem :: updateEpsTauInSBal (int strainID, double **&last_eps_tau)
2182 {
2183  vektor suma_e_s(this->give_VM_TENS_RANGE());
2184  double point[3];
2185  double **strain = AllocateArray2D(1, this->give_VM_TENS_RANGE());
2186  for (int i = 0; i < noIncl; i++) {
2187  for (int ap = -1; ap < this->inclusions[i]->n_approx_points; ap++) {
2188  if (ap == -1)for (int k = 0; k < 3; k++) point[k] = inclusions[i]->origin[k];
2189  else for (int k = 0; k < 3; k++) point[k] = inclusions[i]->approx_points[ap][k];
2190  suma_e_s.vynulovat();
2191  if (SBA_optimized) {
2192  for (int j = 0; j < inclusions[i]->noActingIncls; j++) {
2193  ((InclusionRecord2D*)inclusions[inclusions[i]->actingIncls[j]])->giveExtStrainPert(point, strain, strainID, 1);
2194  for (int ii = 0; ii < this->give_VM_TENS_RANGE(); ii++)suma_e_s.v[ii] += strain[0][ii];
2195  }
2196  }
2197  else {
2198  for (int j = 0; j < noIncl; j++) {
2199  if (i != j) {
2200  ((InclusionRecord2D*)inclusions[j])->giveExtStrainPert(point, strain, strainID, 1);
2201  for (int ii = 0; ii < this->give_VM_TENS_RANGE(); ii++)suma_e_s.v[ii] += strain[0][ii];
2202  }
2203  }
2204  }
2205  for (int j = 0; j < this->give_VM_TENS_RANGE(); j++)suma_e_s.v[j] += this->matrix->remote_strains()[strainID][j];
2206 
2207  if (ap == -1)this->inclusions[i]->Eps02EpsTau(this->inclusions[i]->Epsilon_Tau[strainID], suma_e_s.v);
2208  else this->inclusions[i]->Eps02EpsTau(this->inclusions[i]->approx_points_eps_tau[ap], suma_e_s.v);
2209  }
2210  if (this->inclusions[i]->n_approx_points)this->inclusions[i]->update_approximations(strainID);
2211  }
2212 
2213 
2214 
2215  double norma = 0.;
2216  if (last_eps_tau == NULL) {
2217  last_eps_tau = AllocateArray2D(this->noIncl, this->give_VM_TENS_RANGE());
2218  for (int i = 0; i < this->noIncl; i++)for (int j = 0; j < this->give_VM_TENS_RANGE(); j++) {
2219  last_eps_tau[i][j] = this->inclusions[i]->Epsilon_Tau[strainID][j];
2220  }
2221  norma = 100.;
2222  }
2223  else {
2224  for (int i = 0; i < this->noIncl; i++) {
2225  for (int j = 0; j < this->give_VM_TENS_RANGE(); j++)
2226  norma += SQR(this->inclusions[i]->Epsilon_Tau[strainID][j] - last_eps_tau[i][j]);
2227 
2228  for (int j = 0; j < this->give_VM_TENS_RANGE(); j++)
2229  last_eps_tau[i][j] = this->inclusions[i]->Epsilon_Tau[strainID][j];
2230  }
2231  }
2232  return norma;
2233 }
2234 
2235 
2237 void Problem :: print_visualization (const char *name, int n, int dim, bool refined)
2238 {
2239  if (this->data_equivalent == false) _errorr("Inverse matrix TInv at inclusion have to be computed before calling print_geom function, for example call initialize_inclusion_records");
2240 
2241  if (dim == 0) dim = this->give_dimension();
2242 
2243  if (refined) _errorr("refined je nejaky pokus, je rozbitej momentalne, ale mozna jen ve 2d");
2244 
2245  if (dim != this->give_dimension())
2246  _errorr("error in visualization of 3d problem in xy plane, still not repaired");
2247 
2248  if (dim == 2) {
2249  // unit mesh
2250  Mesh umesh(1, NULL);
2251  umesh.generate_regularSphereMesh_2d(n, NULL);
2252 
2253  long nn = umesh.nNodes;
2254  long ne = umesh.nElems;
2255 
2256  // Total mesh
2257  Mesh mesh(1, this);
2258  mesh.set_coll(3);
2259  mesh.nNodes = noIncl * nn; mesh.Nodes = new mNode* [mesh.nNodes];
2260  mesh.nElems = noIncl * ne; mesh.Elems = new mElement*[mesh.nElems];
2261 
2262  // auxiliary mesh of one inclusion
2263  Mesh *mesh1;
2264  const InclusionRecord2D *incl;
2265 
2266  // loop over all inclusions
2267  for (int i=0; i<noIncl; i++) {
2268  incl = (InclusionRecord2D*)inclusions[i];
2269  if (!refined) mesh1 = new Mesh(1, this, &umesh);
2270  else { mesh1 = new Mesh(1, this);
2271  errol; // tady by melo byt asi 2d a ne 3d
2272  mesh1->generate_regularSphereMesh_3d(n, incl->a);
2273  }
2274 
2275  mesh1->scale(incl->a);
2276  mesh1->local2global(incl->origin, incl->TInv);
2277  mesh1->shift_id(i*nn, i*ne);
2278 
2279  for (int j=0; j<nn; j++) {
2280  mesh.Nodes[i*nn+j] = mesh1->Nodes[j];
2281  mesh.Nodes[i*nn+j]->M = &mesh;
2282  }
2283  delete [] mesh1->Nodes; mesh1->Nodes = NULL;
2284 
2285  for (int j=0; j<ne; j++) {
2286  mesh.Elems[i*ne+j] = mesh1->Elems[j];
2287  mesh.Elems[i*ne+j]->M = &mesh;
2288  }
2289  delete [] mesh1->Elems; mesh1->Elems = NULL;
2290 
2291  delete mesh1;
2292  }
2293 
2294  mesh.print_geometry_file_vtk (name, 0, 0, 1);
2295  }
2296  else {
2297  if (this->twodim) _errorr("print_geom problem is 3d, please use parameter dim 2");
2298 
2299  // unit mesh
2300  Mesh umesh(1, NULL);
2301  umesh.generate_regularSphereMesh_3d (n, NULL);
2302 
2303  long nn = umesh.nNodes;
2304  long ne = umesh.nElems;
2305 
2306  // Total mesh
2307  Mesh mesh(1, this);
2308  mesh.set_coll(0);
2309  mesh.nNodes = noIncl * nn; mesh.Nodes = new mNode* [mesh.nNodes];
2310  mesh.nElems = noIncl * ne; mesh.Elems = new mElement*[mesh.nElems];
2311 
2312  // auxiliary mesh of one inclusion
2313  Mesh *mesh1;
2314  const InclusionRecord3D *incl;
2315 
2316  // loop over all inclusions
2317  for (int i=0; i<noIncl; i++) {
2318  incl = (InclusionRecord3D*)inclusions[i];
2319  if (!refined) mesh1 = new Mesh(1, this, &umesh);
2320  else { mesh1 = new Mesh(1, this);
2321  mesh1->generate_regularSphereMesh_3d (n, incl->a);
2322  }
2323 
2324  mesh1->scale(incl->a);
2325  mesh1->local2global(incl->origin, incl->TInv);
2326  mesh1->shift_id(i*nn, i*ne);
2327 
2328  for (int j=0; j<nn; j++) {
2329  mesh.Nodes[i*nn+j] = mesh1->Nodes[j];
2330  mesh.Nodes[i*nn+j]->M = &mesh;
2331  }
2332  delete [] mesh1->Nodes; mesh1->Nodes = NULL;
2333 
2334  for (int j=0; j<ne; j++) {
2335  mesh.Elems[i*ne+j] = mesh1->Elems[j];
2336  mesh.Elems[i*ne+j]->M = &mesh;
2337  }
2338  delete [] mesh1->Elems; mesh1->Elems = NULL;
2339 
2340  delete mesh1;
2341  }
2342 
2343  mesh.print_geometry_file_vtk (name, 0, 0, 1);
2344  }
2345 }
2346 
2348 void Problem :: check_overlap (void)
2349 {
2350  long i, j, status;
2351 
2352  for (i=0; i<this->noIncl; i++) {
2353  for (j=i+1; j<this->noIncl; j++) {
2354  status = this->inclusions[i]->find_overlap(this->inclusions[j]);
2355 
2356  if (status == -1) {
2357  //
2358  _errorr("check_overlap: NOT converged");
2359  }
2360 
2361  if (status == 1) {
2362  //
2363  _errorr("check_overlap: OVERLAP");
2364  }
2365  }
2366  }
2367 }
2368 
2369 
2370 
2371 } // end of namespace mumech
2372 
2373 /*end of file*/
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1130
XMLText * NewText(const char *text)
Create a new Text associated with this Document.
Definition: tinyxml2.cpp:1573
DiffTypes
Definition: types.h:672
void print_geometry_file_vtk(const char *rsltFileName, int pid, int lc, int nLC)
Print output file with mesh geometry with results to vtk file.
Definition: mesh.cpp:956
Class eshelbySoluUniformField.
void convert2Dtensor_TRtoVR_notation(double *t)
Function convert the symmetric double 2D tensor &#39;t&#39;.
virtual void initialize(const Inclusion *prevInclRec)=0
double * origin
coordinates of the inclusions&#39; centorids
Definition: inclusion.h:75
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
void shift_id(long snn, long sne)
Definition: mesh.cpp:246
#define _STRNCMP
Definition: macros.h:58
Galerkin...
Definition: types.h:92
file of various types and symbolic constant definitions
void generate_regularSphereMesh_2d(int n, const double *a)
Function generates uniform mesh on an unit circle.
Definition: mesh.cpp:767
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
#define _SELF_BALANCE_NORM_LIMIT_
Definition: types.h:54
Class InclusionRecord contains and handles all inclusion data.
Definition: inclusion.h:60
void local2global(const double *origin, const double *TInv)
Local to global transformation of all nodes.
Definition: mesh.cpp:212
void set_coll(int val)
Definition: mesh.cpp:166
Problem description.
Definition: problem.h:154
void set_nlc(const Problem *p, int nlc)
Definition: matrix.cpp:313
General functions.
Original Honza Novak&#39;s balancing.
Definition: types.h:90
void XP_check_expected_attribute(const XMLNode *xelem, const char *name, const char *value)
Definition: tixy2.cpp:134
#define maxNumberOfMeshes
Definition: problem.cpp:65
Class of function for Mori-Tanaka homogenization.
double & g(int radek, int sloupec)
Definition: matrix_vector.h:93
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:603
#define SP_scan_expected_word_exit(_1, _2, _3, _4)
Definition: librw.h:223
Namespace MatrixOperations.
Input / output function.
const XMLElement * XP_give_unique_expected_elem(const XMLNode *xelem, const char *name, bool uniq)
Definition: tixy2.cpp:125
Class mNode contains and handles all mesh node data.
Definition: mnode.h:43
double ** displacement
Calculated value - global displacement field.
Definition: matrix.h:153
#define _MIN_AXES_DIFF
Definition: types.h:391
XMLDocument * tix_doc(void)
Definition: tixy2.h:144
double x[3]
Global coordinates of a point.
Definition: matrix.h:136
int pricist(vektor &co)
Definition: matrix_vector.h:57
Class of function for homogenization of stress fields.
void generate_regularSphereMesh_3d(int n, const double *a)
Function generates uniform mesh on an unit sphere.
Definition: mesh.cpp:808
Class Mesh.
#define SP_scan_expected_number_exit(_1, _2, _3)
Definition: librw.h:249
XMLNode * tixnod(void)
Definition: tixy2.h:141
long nNodes
Number of nodes.
Definition: mesh.h:83
void CopyVector(const double *src, double *dest, long n)
Function copy given number of components from vector, &#39;a&#39; to vector &#39;b&#39;.
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:671
long SP_scan_word(const char *&src, char *dest)
... word; return value is length of the word
Definition: librw.cpp:647
XMLElement * tixel(void)
Definition: tixy2.h:142
The element is a container class.
Definition: tinyxml2.h:1116
#define FP_scan_expected_number_exit(_1, _2, _3)
Definition: librw.h:153
void open(Stream_type t, const char *rw, const char *&fn, XMLNode *node=NULL)
*** SET ***
Definition: tixy2.h:75
#define SP_scan_expected_word2_exit(_1, _2, _3, _4, _5)
Definition: librw.h:224
Class mElement, mesh element.
void giveTVproduct_6is6x6to12and6(double *result, const double *T, const double *vect)
Function gives product of tensor and vector - &#39;result = T * vect&#39;.
void CopyArray2D(const double *const *src, double **dest, long d1, long d2)
Function copy two 2D double arrays with dimensions d1xd2 from &#39;src&#39; to &#39;dest&#39;.
mNode ** Nodes
1d array of pointers to Node.
Definition: mesh.h:84
PFCmode
Algorithm type of a point fields calculation.
Definition: types.h:97
void give_EshelbyPertFields_external(Point *point, int lc, int nlc, bool disp, bool strn)
Function gives the &#39;Eshelby&#39; STRAIN and DISPLACEMENT field in an arbitrary EXTERNAL point for given l...
Definition: inclusion.cpp:986
#define errol
Definition: gelib.h:151
Notation used in the Brdecko&#39;s book or Jan Zeman&#39;s PhD thesis (generally used CTU&#39;s notation)...
Definition: types.h:140
void AddArray2D(const double *const *src, double **dest, long d1, long d2)
Function add 2D double array with dimensions d1xd2 from &#39;src&#39; to &#39;dest&#39;.
const Mesh * M
mesh
Definition: melement.h:46
void convertTensorStress(bool twodim, double *tens, STRNotation oldNot, STRNotation newNot)
Definition: problem.cpp:1680
bool FP_scan_array(FILE *stream, int n, int *dest)
scan/copy array of numbers from src to dest, src pointer is shifted over the field ...
Definition: librw.cpp:313
The header file of usefull macros.
3D inclusion record.
Definition: inclusion.h:278
#define _errorr2(_1, _2)
Definition: gelib.h:154
FILE * file(void)
*** GET ***
Definition: tixy2.h:140
#define _MAX_AXES_DIFF
Definition: types.h:392
void SubtractTwoVectors(const double *v1, const double *v2, double *answer, long n)
Function subtracts two vectors of entries. answer = v1 - v2.
bool ST_scan_number(Stream *src, int &dest)
*** *** *** *** TINYXML FCE *** *** *** ***
Definition: tixy2.cpp:36
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1299
XMLElement * print_VTK_field_head(Stream *stream, const char *name, char format, int slen, int noincl)
Definition: problem.cpp:1438
void CleanArray2d(double **a, long rows, long columns)
Function cleans an 2d &#39;double&#39; array, initialize each value being 0-zero.
STRNotation
This enum defines a notation how to represent a symmetric second/fourth-order tensor by reducing its ...
Definition: types.h:122
VTKrange
Definition: tixy2.h:29
void scan_DATA_field_head(Stream *stream, Stream *strm, const char *str, char type, int nexc, char format, const char *name)
scan_DATA_field_head
Definition: vtk.cpp:241
void print(FILE *soubor)
Definition: matrix_vector.h:39
XMLElement * NewElement(const char *name)
Create a new Element associated with this Document.
Definition: tinyxml2.cpp:1555
void print_VTK_FINISH(Stream *stream)
Definition: vtk.cpp:224
VOIGHT / engineering notation saved in FEEP order.
Definition: types.h:147
void print_VTK_head(FILE *stream, const char *type)
Definition: vtk.cpp:63
void compute_node_fields(char flag, bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC, PFCmode pfcMode)
Definition: mesh.cpp:1111
Single Point data structure - contribution from Single inclusion.
Definition: matrix.h:133
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
long nElems
Number of elements.
Definition: mesh.h:85
double ** strain
Calculated value - global strain fields.
Definition: matrix.h:154
double * TInv
LOCAL->GLOBAL displacement vector transfrmation matrix; TInv = T^-1 (inversion) = T^T (transposed) ...
Definition: inclusion.h:93
bool SP_scan_number(const char *&src, int &dest)
... number of type int/long/double
Definition: librw.cpp:714
void print_auxs(bool lgc, Stream *stream, XMLElement *da, const char *auxs)
Definition: vtk.cpp:214
#define _STRCMP
Definition: macros.h:57
void convert3Dtensor_TRtoVR_notation(double *t)
Function convert the symmetric double 3D tensor &#39;t&#39;.
XMLNode is a base class for every object that is in the XML Document Object Model (DOM)...
Definition: tinyxml2.h:579
void print_valuesi(char *auxs, int n, const int *values, int rv)
Definition: problem.cpp:1497
const char * Value() const
The meaning of &#39;value&#39; changes for the specific type.
Definition: tinyxml2.h:647
bool relink_downF(void)
Definition: tixy2.h:155
const char * Attribute(const char *name, const char *value=0) const
Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists.
Definition: tinyxml2.cpp:1226
TinyXML functions.
HomogenizationType
Definition: types.h:69
const char * GetText() const
Convenience function for easy access to the text inside an element.
Definition: tinyxml2.cpp:1239
Class inclusion contains and handles all inclusion data.
Class Homogenization.
XMLError QueryLongAttribute(const char *name, long *value) const
Given an attribute name, QueryIntAttribute() returns XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the co...
Definition: tinyxml2.h:1212
#define SQR(a)
Definition: macros.h:97
Class HomogenizationMethods.
void convert2Dtensor_TRtoROW_notation(double *t)
Function convert the symmetric double 2D tensor &#39;t&#39;.
double * a
Inclusion semiaxes&#39; dimensions in global arrangement.
Definition: inclusion.h:76
I/O VTK functions.
void print_VTK_init_point_data(Stream *stream, long n)
Definition: vtk.cpp:105
#define _errorr(_1)
Definition: gelib.h:160
Class mNode, mesh node.
Class of function for Mori-Tanaka homogenization.
void print_VTK_START(Stream *stream, const char *filename)
Print head of vtk file.
Definition: vtk.cpp:41
InclusionGeometry
Inclusion shapes&#39; type.
Definition: types.h:161
#define _errorr3(_1, _2, _3)
Definition: gelib.h:155
static double epsilon
Definition: meso2d.cpp:172
void close(void)
Definition: tixy2.h:113
Mathematic functions.
#define CASE
Definition: macros.h:56
void giveTVproduct_3is3x3to5and3(double *result, const double *T, const double *vect)
Function gives product of tensor and vector - &#39;result = T * vect&#39;.
void gaussovaEliminace(matice &m, vektor &right)
XMLElement * print_VTK_nodes_head(Stream *stream, long n)
Definition: vtk.cpp:82
void print_VTK_elems_head(Stream *stream, long noIncl)
Definition: problem.cpp:1395
bool relink_next(void)
Definition: tixy2.h:158
void convert3Dtensor_TFEEPtoROW_notation(double *t)
Function convert the symmetric double 3D tensor &#39;t&#39;.
void scan_FIELD_head(FILE *stream, long noincl, int nexc, char format, const char *name)
scan_DATA_field_head
Definition: problem.cpp:330
void DeleteArray2D(bool **array, long d1)
Function deletes a 2D &#39;bool&#39; array of dimension d1 x ??, allocated by new.
const char * XP_giveDAtext(const XMLNode *xelem, int n, bool last, const char *format, const char *type, const char *name, int *noc)
Definition: tixy2.cpp:145
void DeleteChild(XMLNode *node)
Delete a child of this node.
Definition: tinyxml2.cpp:651
double ** AllocateArray2D(long d1, long d2)
Operations with 2d, 3d, 4d arrays of various sizes.
virtual XMLNode * ShallowClone(XMLDocument *document) const
Make a copy of this node, but not its children.
Definition: tinyxml2.cpp:1453
#define _errorr4(_1, _2, _3, _4)
Definition: gelib.h:156
bool isFile(void)
Definition: tixy2.h:151
bool relink_up(void)
Definition: tixy2.h:157
Class of function for ... homogenization.
const Mesh * M
mesh
Definition: mnode.h:47
Class of function for Voight bound.
#define FP_scan_expected_word_exit(_1, _2, _3, _4)
Definition: librw.h:137
Class Mesh contains and handles all mesh data.
Definition: mesh.h:52
Class of function for Mori-Tanaka homogenization.
The set of the functions returning the Eshelby solution of multiple inclusion task using the self-bal...
DEFAULT / INTERNAL FOR muMECH Theoretical notation saved in row-by-row form 2d: {t_11, t_12, t_21, t_22} 2d: {s_11, s_12, s_21, s_22} 3d: {t_11, t_12, t_13, t_21, t_22, t_23, t_31, t_32, t_33} 3d: {s_11, s_12, s_13, s_21, s_22, s_23, s_31, s_32, s_33}.
Definition: types.h:132
New Standa&#39;s b.
Definition: types.h:91
bool ST_scan_array(Stream *src, int n, int *dest)
scan/copy array of numbers from src to dest, src pointer is shifted over the field ...
Definition: tixy2.cpp:55
int FP_scan_word(FILE *src, char *dest)
... word; return value is length of the word
Definition: librw.cpp:455
bool SP_skip_word(const char *&src, int n)
... word and space before
Definition: librw.cpp:591
void CleanVector(double *a, long n)
Functin cleans a &#39;double&#39; vector, initialize each value being 0-zero.
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:611
mElement ** Elems
1d array of pointers to Element.
Definition: mesh.h:86
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:595
void convertTensorStrain(bool twodim, double *tens, STRNotation oldNot, STRNotation newNot)
Definition: problem.cpp:1661
XMLNode * InsertEndChild(XMLNode *addThis)
Add a child node as the last (right) child.
Definition: tinyxml2.cpp:658
void AddVector(const double *a, double *b, long n)
Function add given number of components from vector &#39;a&#39; to vector &#39;b&#39;, b += a.
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:723
No balancing.
Definition: types.h:89
void scale(const double *s)
Scale all nodes coordinates by vector s.
Definition: mesh.cpp:199
Class Problem.
void print_values(char *auxs, int n, const double *values, int precision)
Definition: vtk.cpp:155
Class mElement contains and handles all mesh element data.
Definition: melement.h:42
Class of function for Reuss bound.
XMLElement * print_VTK_data_head(Stream *stream, const char *name, char type, char format, int slen)
Definition: vtk.cpp:125
void e(int i)
Namespace TransformTensors.