MIDAS  0.75
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
cell.cpp
Go to the documentation of this file.
1 #include "cell.h"
2 
3 #include "point.h"
4 #include "attribute.h"
5 
6 #include "gelib.h"
7 #include "arrays.h"
8 #include "mathlib.h"
9 #include "geometrylib.h"
10 
11 #include <math.h>
12 
13 
14 namespace midaspace {
15 
17  switch (cid) {
18  case classComponentGeometry1D : return (src ? new ComponentGeometry1D (dynamic_cast<ComponentGeometry1D *>(src)) : new ComponentGeometry1D (owner, ZERO)); break;
19  case classComponentGeometry2Dtriangle : return (src ? new ComponentGeometry2Dtriangle (dynamic_cast<ComponentGeometry2Dtriangle *>(src)) : new ComponentGeometry2Dtriangle (owner, ZERO)); break;
20  case classComponentGeometry2Dquadrangle : return (src ? new ComponentGeometry2Dquadrangle (dynamic_cast<ComponentGeometry2Dquadrangle *>(src)) : new ComponentGeometry2Dquadrangle (owner, ZERO)); break;
21  case classComponentGeometry3Dhexahedron : return (src ? new ComponentGeometry3Dhexahedron (dynamic_cast<ComponentGeometry3Dhexahedron *>(src)) : new ComponentGeometry3Dhexahedron (owner, ZERO)); break;
22  case classComponentGeometry3Dtetrahedron: return (src ? new ComponentGeometry3Dtetrahedron (dynamic_cast<ComponentGeometry3Dtetrahedron*>(src)) : new ComponentGeometry3Dtetrahedron(owner, ZERO)); break;
23  case classComponentGeometry2Dpolygon : return (src ? new ComponentGeometry2Dpolygon (dynamic_cast<ComponentGeometry2Dpolygon *>(src)) : new ComponentGeometry2Dpolygon (owner, ZERO)); break;
24  case classComponentGeometry1Dpoly : return (src ? new ComponentGeometry1Dpoly (dynamic_cast<ComponentGeometry1Dpoly *>(src)) : new ComponentGeometry1Dpoly (owner, ZERO)); break;
25  default: errol;
26  }
27  return NULL;
28 }
29 
30 //* ********************************************************************************************
31 //* *** *** *** *** CLASS CELL *** *** *** ***
32 //* ********************************************************************************************
34 Cell :: Cell (classID mecg, long gid, long oid, long prop, const Geometry *mg, long nn, long ne, long nf) : GeometryComponent (mg, gid, oid, prop) //, ComponentGeometry()
35 {
36  // this has to be before cg
37  ; points.resizeup(nn);
38  if (ne) edges. resizeup(ne);
39  if (nf) faces. resizeup(nf);
40 
41  if (mecg) cg = allocComponentGeometry (mecg, this);
42  else cg = NULL;
43 
44  //
45  connectivity_assembled = false;
46  //
47  duplmaster = NULL;
48 }
50 Cell :: Cell (classID mecg, const Cell * src) : GeometryComponent (src)
51 {
52  //
53  points.be_copy_of(&src->points);
54  edges.resizeup(src->edges());
55  faces.resizeup(src->faces());
56  //
57  connectivity_assembled = false;
58  //
59  duplmaster = NULL;
60 
61  if (((Mesh*)Geom)->connectivity_is_assembled()) _errorr ("error");
62 
63  if (src->cg && src->cg->give_classid() == mecg) { cg = allocComponentGeometry (mecg, this, src->cg); cg->set_owner(this); }
64  else errol;
65 }
68 {
69  delete cg;
70 }
71 
72 
73 //* *********************************************
74 //* *** *** *** DUPLICITY *** *** ***
75 //* *********************************************
78 {
79  if ( duplmaster != (Cell *)-1 ) return;
80  if ( dynamic_cast<FElement *>(this) == NULL ) _errorr ("Error");
82 
83  int i;
84  FElement *master;
85 
86  for (i=0; i<edges[0]->give_numsuperelem(); i++) {
87  master = (FElement*)edges[0]->give_superelem(i);
88  if (master == this) continue;
89 
90  if (master->has_same_geom_with(this)) {
91  duplmaster = master;
92  if ( this->give_ID() < duplmaster->give_ID() ) _errorr ("Ascending duplicity chain");
93  break;
94  }
95  }
96  if (i == edges[0]->give_numsuperelem())
97  duplmaster = NULL;
98 
99 }
100 
103 {
104  if (this == duplmaster)
105  _errorr ("");
106 
107  ((Cell*)this)->assure_duplicity_master();
108 
109  if (!duplmaster) return NULL;
110 
111  Cell *master;
112  if ( (master = duplmaster->last_duplicity_master()) ) return master;
113 
114  return duplmaster;
115 }
116 
119 {
120 # ifdef DEBUG
121  //
122  if (!points.has_same_members_as(slave->points)) _errorr ("Duplicity slave and master differ in list of nodes");
124  long i;
125  if (edges() != slave->edges()) errol;
126  for (i=0; i<edges(); i++)
127  if ( ( edges[i]->last_duplicity_master() ? edges[i]->last_duplicity_master() : edges[i]) !=
128  (slave->edges[i]->last_duplicity_master() ? slave->edges[i]->last_duplicity_master() : slave->edges[i]) )
129  _errorr ("Duplicity slave and master differ in list of edges");
131  if (faces() != slave->faces()) errol;
132  for (i=0; i<faces(); i++)
133  if ( ( faces[i]->last_duplicity_master() ? faces[i]->last_duplicity_master() : faces[i]) !=
134  (slave->faces[i]->last_duplicity_master() ? slave->faces[i]->last_duplicity_master() : slave->faces[i]) )
135  _errorr ("Duplicity slave and master differ in list of faces");
136 # endif
137 }
138 
140 void Cell :: switch_node_pointer (Point *slave, Point *master, bool duplcheck)
141 {
142  if (points.replace_member_by (slave, master))
143  if ( this->check_collapse() )
144  duplmaster = this;
145 }
147 bool Cell :: switch_edge_pointer (Edge *slave, Edge *master)
148 {
149  return edges.replace_member_by (slave, master);
150 }
152 bool Cell :: switch_face_pointer (Face *slave, Face *master)
153 {
154  return faces.replace_member_by (slave, master);
155 }
156 
157 
160 {
161  if ( newmaster == ((Cell*)-1) ) {
162  if (duplmaster) _errorr ("");
163  duplmaster = newmaster;
164  return;
165  }
166 
167  if (this == duplmaster)
168  errol;
169 
170  if ( this->give_classid() != newmaster->give_classid() )
171  _errorr ("Mismatch");
172 
173  if ( newmaster == duplmaster ) return;
174 
175  Cell *oldmaster = this->last_duplicity_master();
176 
177  if ( newmaster == oldmaster ) return;
178 
179  if (oldmaster == NULL) {
180  duplmaster = newmaster;
181  if ( this->give_ID() < duplmaster->give_ID() ) _errorr ("Ascending duplicity chain");
182  }
183  else
184  if ( newmaster->give_ID() > oldmaster->give_ID() )
185  newmaster->setup_duplicity_master(oldmaster);
186  else
187  oldmaster->setup_duplicity_master(newmaster);
188 
189 }
190 
193 {
194  if (flag != 'a' && flag != 'c' && flag != 'r') _errorr("forbidden flag");
195 
196  this->assure_duplicity_master();
197 
198  // no duplicity
199  if (duplmaster == NULL) return false;
200 
201  // collapsed cell
202  if (duplmaster == this) {
203  if (flag == 'r') return false;
204  this->connectivity_removing();
205  }
206  // duplicated
207  else {
208  if (flag == 'c') return false;
211  }
212 
213  return true;
214 }
215 
218 {
219 # ifdef DEBUG
220  if (!master) errol;
221 # endif
222  this->connectivity_removing();
223 }
224 
225 
226 //* ********************************************
227 //* *** *** *** ASSORTED *** *** ***
228 //* ********************************************
229 
231 bool Cell :: has_same_geom_with (Cell *slave) const
232 {
233  if (this == slave) return false;
234  //return nodes.has_same_members_as(slave->nodes);
235  return points.has_these_members(slave->give_points()[0]);
236 }
237 
251 bool Cell :: cross_abscissa_node (const PoinT *a1, const PoinT *a2, long cunn, const Point **unnod, const Point *&nod, double &ksi, PoinT *cp) const
252 {
253  long i, j;
254  for (i=0; i<points(); i++) {
255  for (j=0; j<cunn; j++)
256  if (points[i] == unnod[j]) break;
257 
258  if (j==cunn && points[i]->give_coords()->give_ksiAtAbscissa(ZERO, this->give_circum(), a1, a2, ksi)) {
259  nod = points[i];
260  cp->bePointAtAbscissa (a1, a2, ksi);
261  return true;
262  }
263  }
264  return false;
265 }
266 
280 int Cell :: cross_abscissa_face (const PoinT *a1, const PoinT *a2, long cunf, const Face **unfac, const Cell *&comp, PoinT *nc, PoinT *cp)
281 {
282  // napsano pro brick
283  long i,j,nr;
284  double ksi[2],eta[2],t[2];
285  PoinT i1, i2, *ip;
286 
287  for (i=0; i<faces(); i++) {
288  for (j=0; j<cunf; j++) if (faces[i] == unfac[j]) break;
289  if (j!=cunf) continue;
290 
292  faces[i]->points[0]->give_coords(),faces[i]->points[1]->give_coords(),
293  faces[i]->points[2]->give_coords(),faces[i]->points[3]->give_coords(),
294  a1,a2,ksi,eta,t,&i1,&i2);
295  if (nr==0) continue;
296  if (nr==-1)
297  _errorr("Something is wrong in function cross_abscissa_face");
298 
299  if ( fabs(ksi[0])<(1.0+ZERO) && fabs(eta[0])<(1.0+ZERO) && fabs(t[0])<(1.0+ZERO) ){
300  nc->x = ksi[0];
301  nc->y = eta[0];
302  ip = &i1;
303  if (nr==1) break;
304  if (nr==2) nr=3;
305  }
306 
307  if (nr==1) continue;
308 
309  if ( fabs(ksi[1])<(1.0+ZERO) && fabs(eta[1])<(1.0+ZERO) && fabs(t[1])<(1.0+ZERO) ){
310  if (nr==3) continue;
311  if (nr==2){
312  nc->x = ksi[1];
313  nc->y = eta[1];
314  ip = &i2;
315  break;
316  }
317  }
318 
319  if (nr==3) break;
320  }
321 
322  if (i==faces()) return 0;
323 
324  const Face *fac = faces[i];
325 
326  cp->copy(ip);
327 
328  const Edge *edg;
329  const Point *t1, *t2;
330 
331  if ( fabs(nc->x-1.0) < ZERO ) { t1=fac->give_point(3); t2=fac->give_point(0); nc->x=nc->y; edg=(Edge*)fac->give_edge(3); } // ksi = 1.0
332  else if ( fabs(nc->x+1.0) < ZERO ) { t1=fac->give_point(2); t2=fac->give_point(1); nc->x=nc->y; edg=(Edge*)fac->give_edge(1); } // ksi = -1.0
333  else if ( fabs(nc->y-1.0) < ZERO ) { t1=fac->give_point(1); t2=fac->give_point(0); edg=(Edge*)fac->give_edge(0); } // eta = 1.0
334  else if ( fabs(nc->y+1.0) < ZERO ) { t1=fac->give_point(2); t2=fac->give_point(3); edg=(Edge*)fac->give_edge(2); } // eta = -1.0
335  else {
336  comp = fac;
337  return 2;
338  }
339 
340  comp = edg;
341  ((Edge*)edg)->transform_nc (t1,t2,nc->x);
342 
343  return 1;
344 }
345 
346 
347 
348 //* ********************************************************************************************
349 //* *** *** *** *** CLASS FACEDGE *** *** *** ***
350 //* ********************************************************************************************
353 {
354  int dim = comp->give_dimension();
355 
356  if (dim > masterel_dim) return;
357 
358  if (dim < masterel_dim) {
359  masterel_dim = dim;
360  masterels.resize_zero();
361  }
362 
363  masterels.add(comp);
364 }
365 
368 {
370 
371  if (masterel_dim == this->give_dimension()) {
372  if (masterels() == 1)
373  return masterels[0];
374  else
375  _errorr3("Facedge %ld of dim %d has multiple superelems with same dimension", this->give_ID(), this->give_dimension());
376  }
377 
378  return NULL;
379 }
380 
383 {
385 
386  superelems.add_unique (slave->give_superelems()[0]);
387 }
388 
389 
390 
391 
392 //* ********************************************************************************************
393 //* *** *** *** *** CLASS EDGE *** *** *** ***
394 //* ********************************************************************************************
397 {
398  if (!re && this->connectivity_assembled == true) return;
399  this->connectivity_assembled = true;
400 
401  int i;
402  for (i=0; i<points(); i++) const_cast<Point*>(points[i])->setadd_superedge(this, re);
403 }
406 {
407  if (this->connectivity_assembled == false) return;
408  this->connectivity_assembled = false;
409 
410  int i;
411  for (i=0; i<points(); i++) const_cast<Point*>(points[i])->remove_superedge(this);
412 }
413 
416 {
418 
419  for (int i=0; i<superfaces(); i++) const_cast<Face* >(superfaces[i])->switch_edge_pointer (this, (Edge*)master);
420  for (int i=0; i<superelems(); i++) const_cast<Element*>(superelems[i])->switch_edge_pointer (this, (Edge*)master);
421 }
422 
424 void Edge :: set_model_prop (long val, const Model *model, bool flag)
425 {
426  const Edge *mdl_master_edge;
427 
428  if (flag == false) {
430  if (val > model->give_Nels())
431  val = val - model->give_Nels();
432  else
433  flag = true;
434  }
435 
436  if (flag) {
437 # ifdef DEBUG
438  if (model->give_Elem(val-1)->give_ned() != 1) errol;
439 # endif
440  mdl_master_edge = model->give_Elem(val-1)->give_edge(0);
441  val = mdl_master_edge->give_ID()+1;
442  }
443  else {
444  mdl_master_edge = model->give_Edge(val-1);
445  }
446 
447  if ( this->checkset_mprop(val) )
448  this->give_facedgeAttribs()->set_new (mdl_master_edge->give_facedgeAttribs());
449 
450 }
451 
454 {
456 
457  superfaces.add_unique (slave->give_superfaces()[0]);
458 }
459 
460 
461 /*
462 void edge::transform_nc (long t,double ksi)
463 // releas verse
464 {
465  if (t==nodes[1]) ksi = -ksi;
466 }
467 */
468 void Edge :: transform_nc (const Point *t1, const Point *t2, double &ksi)
469 // debug verse
470 {
471  if (t1==points[1] && t2==points[0]) ksi = -ksi;
472  else if (t1!=points[0] || t2!=points[1]) exit (2);
473 }
484 bool Edge :: is_nod_on (double norm, const PoinT *point, double &ksi) const
485 {
486  return point->give_ksiAtAbscissa (ZERO, norm, points[0]->give_coords(), points[1]->give_coords(), ksi);
487 }
488 
490 const Face* Edge :: give_superface (long ne, const Edge **edgs) const
491 {
492  for (int i=0; i<superfaces(); i++)
493  if (superfaces[i]->give_ned() == ne)
494  if ( superfaces[i]->give_edges()->has_these_members(ne, edgs) )
495  return superfaces[i];
496 
497  return NULL;
498 }
499 
501 void Edge :: switch_node_pointer (Point *slave, Point *master, bool duplcheck)
502 {
503  Cell :: switch_node_pointer (slave, master, duplcheck);
504 
505  if (duplmaster == this || !duplcheck) return;
506 
507  for (int i=0; i<master->give_numsuperedge(); i++)
508  if ( master->give_superedge(i)->has_same_geom_with(this) ) {
509  if ( this->give_ID() > master->give_superedge(i)->give_ID() )
510  this->setup_duplicity_master((Edge*)master->give_superedge(i));
511  else
512  ((Edge *)master->give_superedge(i))->setup_duplicity_master(this);
513  }
514 }
515 
517 void Edge :: print_row (FILE *stream, femFileFormat fff, bool endline, long did) const
518 {
519  switch (fff) {
520  case FFF_T3d: {
521  const Element* master = this->give_main_masterel_uniq();
522 
523  // name + id
524  fprintf (stream, "curve %3ld vertex ", this->give_ID()+1);
525 
526  // vertices
527  if (points() != 2) errol;
528  fprintf (stream, " %3ld %3ld", points[0]->give_ID()+1, points[1]->give_ID()+1);
529 
530  // property
531  fprintf (stream, " property %ld", master ? master->give_ID() + 1 : Geom->give_Nels() + this->give_ID() + 1);
532 
533  // size
534  double size = this->give_elemSize();
535  if (master && master->isTruss()) {
536  if (superelems() !=1) errol;
537  size = -1;
538  }
539  if (size > 0.0) fprintf (stream, " size %lf", size);
540  else fprintf (stream, " count %d", (int)-size);
541 
543  if (master) {
544  const GelemAttribs *gatt = dynamic_cast<const GelemAttribs*>(master->give_elemAttribs());
545  if (!gatt) errol;
546 
547  if (gatt->give_virtual()) fprintf (stream, " output no");
548  else fprintf (stream, " output yes");
549  }
550  break;
551  }
552  default: errol;
553  }
554 
555  //
556  if (endline) fprintf (stream, "\n");
557 }
558 
559 double Edge :: give_elemSize (void) const
560 {
561  double size;
562  const Element* master = this->give_main_masterel_uniq();
563 
565  if (master)
566  size = ((FacedgeAttribs*)this->attributes)->give_elemSize();
567  else
568  size = superfaces[0]->give_elemSize();
569 
571  if (master) {
572  long count = ((FacedgeAttribs*)this->attributes)->give_elemCount();
573  if (count) {
574  double cntsize = master->give_characteristic_size() / count;
575  if (size > cntsize)
576  size = - count;
577  }
578  }
579 
581  if (master) {
582  const GelemAttribs *gatt = dynamic_cast<const GelemAttribs*>(master->give_elemAttribs());
583  if (!gatt) errol;
584  if (! gatt->give_virtual()) {
585  if (gatt->give_mat()->give_type() == MAT_RIGID)
586  size = -1;
587  }
588  }
589 
590  return size;
591 }
592 
593 
594 //* ********************************************************************************************
595 //* *** *** *** *** CLASS FACE *** *** *** ***
596 //* ********************************************************************************************
599 {
600  if (!re && this->connectivity_assembled == true) return;
601  this->connectivity_assembled = true;
602 
603  int i;
604  for (i=0; i<points(); i++) const_cast<Point*>(points[i])->setadd_superface(this, re);
605  for (i=0; i<edges(); i++) const_cast<Edge*> (edges[i]) ->setadd_superface(this, re);
606 }
609 {
610  if (this->connectivity_assembled == false) return;
611  this->connectivity_assembled = false;
612 
613  int i;
614  for (i=0; i<points(); i++) const_cast<Point*>(points[i])->remove_superface(this);
615  for (i=0; i<edges(); i++) const_cast<Edge*> (edges[i]) ->remove_superface(this);
616 }
617 
620 {
622 
623  for (int i=0; i<superelems(); i++) const_cast<Element*>(superelems[i])->switch_face_pointer (this, (Face*)master);
624 }
625 
627 void Face :: set_model_prop (long val, const Model *model, bool flag)
628 {
629  const Face *mdl_master_face;
630 
631  if (flag == false) {
633  if (val > model->give_Nels())
634  val = val - model->give_Nels();
635  else
636  flag = true;
637  }
638 
639  if (flag) {
640 # ifdef DEBUG
641  if (model->give_Elem(val-1)->give_nfa() != 1) errol;
642 # endif
643  mdl_master_face = model->give_Elem(val-1)->give_face(0);
644  val = mdl_master_face->give_ID()+1;
645  }
646  else {
647  mdl_master_face = model->give_Face(val-1);
648  }
649 
650  if ( this->checkset_mprop(val) )
651  this->give_facedgeAttribs()->set_new (mdl_master_face->give_facedgeAttribs());
652 
653 }
654 
655 
656 /*
657 void face::transform_nc (const long *t,double *nc)
658 // releas verse
659 {
660  if (t1==edges[0]) { nc->z=nc->y; nc->y= nc->x; if (t2==edges[1]) nc->x=-nc->z;
661  else nc->x= nc->z; }
662  else if (t1==edges[1]) { nc->x=-nc->x; if (t2==edges[2]) nc->y=-nc->y; }
663  else if (t1==edges[2]) { nc->z=nc->y; nc->y=-nc->x; if (t2==edges[3]) nc->x= nc->z;
664  else nc->x=-nc->z; }
665  else if (t2!=edges[0]) nc->y=-nc->y;
666 }
667 */
668 void Face :: transform_nc (const Edge *t1, const Edge *t2, PoinT *nc) const
669 // debug verse
670 {
671  if (t1==edges[0]) { nc->z=nc->y; nc->y= nc->x; if (t2==edges[1]) nc->x=-nc->z;
672  else if (t2==edges[3]) nc->x= nc->z;
673  else exit (3); }
674  else if (t1==edges[1]) { nc->x=-nc->x; if (t2==edges[2]) nc->y=-nc->y;
675  else if (t2!=edges[0]) exit (4); }
676  else if (t1==edges[2]) { nc->z=nc->y; nc->y=-nc->x; if (t2==edges[3]) nc->x= nc->z;
677  else if (t2==edges[1]) nc->x=-nc->z;
678  else exit (5); }
679  else if (t1==edges[3]) if (t2==edges[2]) nc->y=-nc->y;
680  else { if (t2!=edges[0]) exit (6); }
681  else exit (7);
682 }
683 
684 
686 void Face :: switch_node_pointer (Point *slave, Point *master, bool duplcheck)
687 {
688  Cell :: switch_node_pointer (slave, master, duplcheck);
689 
690  if (duplmaster == this || !duplcheck) return;
691 
692  for (int i=0; i<master->give_numsuperface(); i++)
693  if ( master->give_superface(i)->has_same_geom_with(this) ) {
694  if ( this->give_ID() > master->give_superface(i)->give_ID() )
695  this->setup_duplicity_master((Face*)master->give_superface(i));
696  else
697  ((Face *)master->give_superface(i))->setup_duplicity_master(this);
698  }
699 }
700 
702 void Face :: print_row (FILE *stream, femFileFormat fff, bool endline, long did) const
703 {
704  switch (fff) {
705  case FFF_T3d: {
706  const VectoR *norm = NULL;
707 
708  switch (cg->give_elemGeom()) {
709  case CG_Triangle:
710  case CG_Quadrangle:
711  case CG_Polygon: {
712  const Gelement* master = dynamic_cast<const Gelement*>(this->give_main_masterel_uniq());
713  if (!master) errol;
714 
715  // name + id
716  fprintf (stream, "patch %3ld", this->give_ID()+1);
717 
718  // normal
719  norm = ((ComponentGeometry2D*)cg)->give_normal();
720  fprintf (stream, " normal %21.14e %21.14e %21.14e", norm->x, norm->y, norm->z);
721 
722  // property
723  fprintf (stream, " property %ld", master ? master->give_ID() + 1 : Geom->give_Nels() + this->give_ID() + 1);
724 
725  // boundary curves
726  fprintf (stream, " boundary curve ");
727  int i=0, frwd=1;
728  for (i=0; i<edges()-1; i++) {
729  if (edges[i]->give_point(0) == points[i ] && edges[i]->give_point(1) == points[i+1]) frwd = 1;
730  else if (edges[i]->give_point(0) == points[i+1] && edges[i]->give_point(1) == points[i ]) frwd = -1;
731  else errol;
732  fprintf (stream, " %3ld", frwd*(edges[i]->give_ID()+1));
733  }
734  if (edges[i]->give_point(0) == points[i] && edges[i]->give_point(1) == points[0]) frwd = 1;
735  else if (edges[i]->give_point(0) == points[0] && edges[i]->give_point(1) == points[i]) frwd = -1;
736  else errol;
737  fprintf (stream, " %3ld", frwd*(edges[i]->give_ID()+1));
738 
739  // size
740  fprintf (stream, " size %lf", this->give_elemSize());
741 
742  // count
743  if (master) {
744  const GelemAttribs *gatt = dynamic_cast<const GelemAttribs*>(master->give_elemAttribs());
745  if (!gatt) errol;
746 
747  if (gatt->give_virtual()) fprintf (stream, " output no");
748  else fprintf (stream, " output yes");
749  }
750 
751  // fixed
752  if (master) {
753  const GPA<const Vertex> *fixvers = master->give_fixedVertices();
754  if (fixvers) {
755  fprintf (stream, " fixed vertex");
756  for (i=0; i<fixvers[0](); i++)
757  fprintf (stream, " %ld", fixvers[0][i]->give_ID()+1);
758  }
759  const GPA<const Gelement> *fixgelems = master->give_fixedGelements();
760  if (fixgelems) {
761  fprintf (stream, " fixed curve");
762  for (i=0; i<fixgelems[0](); i++)
763  fprintf (stream, " %ld", fixgelems[0][i]->give_same_dimension_facedge()->give_ID()+1);
764  }
765  }
766 
767  //
769  fprintf (stream, " quad map yes equidistant");
770 
771  break;
772  }
773  default: errol;
774  }
775  break;
776  }
777  default: errol;
778  }
779 
780  //
781  if (endline) fprintf (stream, "\n");
782 }
783 
784 double Face :: give_elemSize (void) const
785 {
786  double size;
787  const Element* master = this->give_main_masterel_uniq();
788 
789  //* size
790  if (master)
791  size = ((FacedgeAttribs*)this->attributes)->give_elemSize();
792  else
793  errol;
794  // tady bude asi volani volume
795 
796  //* Rigid Material
797  if (master) {
798  const GelemAttribs *gatt = dynamic_cast<const GelemAttribs*>(master->give_elemAttribs());
799  if (!gatt) errol;
800  if (! gatt->give_virtual()) {
801  if (gatt->give_mat() && gatt->give_mat()->give_type() == MAT_RIGID)
802  size = master->give_characteristic_size();
803  }
804  }
805 
806  return size;
807 }
808 
809 
810 //* ********************************************************************************************
811 //* *** *** *** *** CLASS ELEMENT *** *** *** ***
812 //* ********************************************************************************************
815 {
816  switch (CellGeometry_e2i_VTK(this->give_cellGeom())) {
817  case 3: return VTKPD_LINE; // VTK_LINE
818  case 5: return VTKPD_POLYGON; // VTK_TRIANGLE
819  case 9: return VTKPD_POLYGON; // VTK_QUAD
820  default: _errorr ("element is not polydata unsuported VTK cell type");
821  }
822  return VTKPD_Void;
823 }
824 // ///
825 // const Facedge* Element :: give_same_dimension_facedge (void) const
826 // {
827 // switch (this->give_dimension()) {
828 // case 1: return edges[0];
829 // case 2: return faces[0];
830 // case 3: errol;
831 // default: errol;
832 // }
833 // return NULL;
834 // }
837 {
838  switch (this->give_dimension()) {
839  case 1: if (edges() != 1) errol; return edges[0];
840  case 2: if (faces() != 1) errol; return faces[0];
841  case 3: errol;
842  default: errol;
843  }
844  return NULL;
845 }
846 
847 
853 {
854  if (!re && this->connectivity_assembled == true) return;
855  this->connectivity_assembled = true;
856 
857  //* *** NODES ***
859  for (int i=0; i<points(); i++)
860  const_cast<Point*>(points[i])->setadd_superelem(this, re);
861 
863  long i, nned, nnfa;
864  bool all_exist_subs;
865  const Point **subnodes = NULL; // nodes at sub-element
866  const Edge **subedges = NULL; // edges at sub-element
867  //
868  Edge *edg;
869  Face *fac;
870 
871 
872  //* *** EDGES ***
873  nned = this->give_edge_nodes (subnodes);
874  all_exist_subs = true;
875 
876  for (i=0; i<edges(); i++) {
878  // edge uz je prirazeno
879  if (edges[i]) {
880  if (!re) errol; // to lze jen kdyz dam re
881  if (!edges[i]->give_points()->has_these_members(nned, subnodes+nned*i) ) errol; // kontrola ze uz prirazena edge ma spravny nodes
882  edg = (Edge*)edges[i];
883  }
884  // priradim nejakou existujici, nebo nove naallocovanou
885  else {
886  edg = (Edge*) subnodes[nned*i]->give_superedge (nned, subnodes+nned*i);
887  if (edg==NULL) {
888  edg = new Edge(nned, subnodes+nned*i);
889  const_cast<Geometry*>(Geom)->add_another_Edge (edg);
890  all_exist_subs = false;
891  }
892  this->set_edge(i, edg);
893  }
894 
895  edg->connectivity_assembling(re);
896 
898  edg->setadd_superelem(this, re);
899  }
900  if (all_exist_subs) this->setup_duplicity_master ((Element*)-1);
901 
902  delete [] subnodes; subnodes = NULL;
903 
904 
906  nnfa = this->give_face_nodes_edges (subnodes, subedges);
907  all_exist_subs = true;
908 
909  for (i=0; i<faces(); i++) {
911  // face uz je prirazeno
912  if (faces[i]) {
913  if (!re) errol; // to lze jen kdyz dam re
914  if (!faces[i]->give_edges()->has_these_members(nnfa, subedges+nnfa*i) ) errol; // kontrola ze uz prirazena face ma spravny edges
915  fac = (Face*)faces[i];
916  }
917  // priradim nejakou existujici, nebo nove naallocovanou
918  else {
919  fac = (Face*) subedges[nnfa*i]->give_superface (nnfa, subedges+nnfa*i);
920  if (fac==NULL) {
921  fac = new Face(nnfa, nnfa, subnodes+nnfa*i, subedges+nnfa*i);
922  const_cast<Geometry*>(Geom)->add_another_Face (fac);
923  all_exist_subs = false;
924  }
925  this->set_face(i, fac);
926  }
927 
928  fac->connectivity_assembling(re);
929 
931  fac->setadd_superelem(this, re);
932  }
933  if (nnfa && all_exist_subs) if (duplmaster == NULL) errol;
934 
935  delete [] subnodes;
936  delete [] subedges;
937 }
940 {
941  if (this->connectivity_assembled == false) return;
942  this->connectivity_assembled = false;
943 
944  int i;
945  for (i=0; i<points(); i++) const_cast<Point*>(points[i])->remove_superelem (this);
946  for (i=0; i<edges(); i++) const_cast<Edge*> (edges[i]) ->remove_superelem (this);
947  for (i=0; i<faces(); i++) const_cast<Face*> (faces[i]) ->remove_superelem (this);
948 
949  // toto smaz pokut to zde nebude padat
950  // for (i=0; i<points(); i++) const_cast<Point*>(points[i])->remove_superelem (this);
951  // for (i=0; i<edges(); i++) if (edges[i]) const_cast<Edge*> (edges[i]) ->remove_superelem (this); else if (master) errol;
952  // for (i=0; i<faces(); i++) if (faces[i]) const_cast<Face*> (faces[i]) ->remove_superelem (this); else if (master) errol;
953 }
954 
956 void Element :: set_load (int i, int indx)
957 {
958  const BoundaryCond *bc = Pd->give_BC(i); if (bc == NULL) _errorr2("There is no boundary condition with ID = %d", i+1);
959 
960  switch (bc->give_loctype()) {
961  case BC_CEL: this->connectivity_assembling(false); ((Geometry*)Geom)->assign_EdgeLoad_by_elem_ID(bc, this->give_ID(), indx); break;
962  case BC_CFL: this->connectivity_assembling(false); ((Geometry*)Geom)->assign_FaceLoad_by_elem_ID(bc, this->give_ID(), indx); break;
963  case BC_CBL:
964  case BC_DW: ((Geometry*)Geom)->assign_BodyLoad_by_elem_ID(bc, this->give_ID() ); break;
965  default: _errorr("unsupported bc type");
966  }
967 }
968 
969 
971 void Element :: set_mprop (long val)
972 {
974  elemAttribs()->set_Patt();
975 }
977 void Element :: set_prop_node_inher (bool everynode)
978 {
979  long i;
980 
981  if (this->give_mproperty_cnt() == 0) errol;
982 
983  for (i=0; i<points(); i++)
984  if (everynode || points[i]->give_numsuperelem() == 1)
985  ((Point*)points[i])->set_mprop(this->give_mproperty());
986 
987 }
988 
991 {
993 
995 }
996 
997 
998 
999 
1001 void Element :: switch_node_pointer_in_all_components (Point *slave, Point *master, bool duplcheck)
1002 {
1003  this->switch_node_pointer(slave, master, duplcheck);
1004  long i;
1005  for (i=0; i<edges(); i++) ((Edge*)edges[i])->switch_node_pointer(slave, master, duplcheck);
1006  for (i=0; i<faces(); i++) ((Face*)faces[i])->switch_node_pointer(slave, master, duplcheck);
1007 }
1008 
1010 void Element :: switch_node_pointer (Point *slave, Point *master, bool duplcheck)
1011 {
1012  Cell :: switch_node_pointer (slave, master, duplcheck);
1013 
1014  if (duplmaster == this || !duplcheck) return;
1015 
1016  for (int i=0; i<master->give_numsuperelem(); i++)
1017  if ( master->give_superelem(i)->has_same_geom_with(this) ) {
1018  if ( this->give_ID() > master->give_superelem(i)->give_ID() )
1019  this->setup_duplicity_master((Cell*)master->give_superelem(i));
1020  else
1021  ((Cell *)master->give_superelem(i))->setup_duplicity_master(this);
1022  }
1023 }
1024 
1025 
1028 bool Element :: is_point_on (const PoinT *point, const GeometryComponent *&comp, PoinT *nc) const
1029 {
1030  // check, jestli je point vubec v circum
1031  if ( ! const_cast<Element*>(this)->is_point_in_sphere(point) )
1032  return false;
1033 
1034  long i;
1035 
1036  // check, jestli se point nerovna nejakemu nodu
1037  for (i=0; i<points(); i++)
1038  if ( points[i]->is_identical_to (this->give_circum(), point) ) {
1039  comp = points[i];
1040  return true;
1041  }
1042 
1043  // check, jestli neni point nahodou on an edge
1044  for (i=0; i<edges(); i++)
1045  if (edges[i]->is_nod_on (this->give_circum(), point, nc->x)) {
1046  comp = edges[i];
1047  return true;
1048  }
1049 
1050  // check, jestli neni point nahodou na ??
1051  const Face *fac=NULL;
1052  const Edge *t1, *t2; t1 = t2 = NULL;
1053 
1054  switch (this->give_classid()) {
1055  case classBrick:
1056  double x[8],y[8],z[8];
1057  for (i=0;i<8;i++) {
1058  x[i] = this->give_point(i)->give_coord(0); // *****
1059  y[i] = this->give_point(i)->give_coord(1); // *(2)*
1060  z[i] = this->give_point(i)->give_coord(2); // *****
1061  }
1062  if (nc_brick_3d (ZERO,x,y,z,point,nc)) {
1063  if ( fabs(nc->x-1.0) < ZERO ) { fac=faces[4]; nc->x=nc->y; nc->y=nc->z; t1=edges[10]; t2=edges[ 2]; } // ksi = 1.0
1064  else if ( fabs(nc->x+1.0) < ZERO ) { fac=faces[2]; nc->x=nc->y; nc->y=nc->z; t1=edges[ 9]; t2=edges[ 0]; } // ksi = -1.0 *****
1065  else if ( fabs(nc->y-1.0) < ZERO ) { fac=faces[3]; nc->y=nc->z; t1=edges[10]; t2=edges[ 1]; } // eta = 1.0 *(2)*
1066  else if ( fabs(nc->y+1.0) < ZERO ) { fac=faces[5]; nc->y=nc->z; t1=edges[11]; t2=edges[ 3]; } // eta = -1.0 *****
1067  else if ( fabs(nc->z-1.0) < ZERO ) { fac=faces[0]; t1=edges[ 2]; t2=edges[ 1]; } // dzeta = 1.0
1068  else if ( fabs(nc->z+1.0) < ZERO ) { fac=faces[1]; t1=edges[ 6]; t2=edges[ 5]; } // dzeta = -1.0
1069  else {
1070  // volume
1071  comp = this;
1072  return true;
1073  }
1074 
1075  // face
1076  fac->transform_nc (t1, t2, nc);
1077  comp = fac;
1078  return true;
1079 
1080  }
1081  else return false;
1082 
1083  break;
1084  default: _errorr("Unknown element type is required in function is_point_on_el");
1085  }
1086 
1087  return false;
1088 }
1089 
1091 void Element :: print_row_VTK (FILE *stream) const
1092 {
1093  // nodes
1094  fprintf (stream, "%ld", points());
1095  for (int i=0; i<points(); i++)
1096  fprintf (stream, " %ld", ((Node*)points[i])->give_lid_id(0));
1097 
1098  fprintf (stream, "\n");
1099 }
1100 void Element :: print_row_VTX (char *str) const
1101 {
1102  // nodes
1103  str[0]='\0';
1104  for (int i=0; i<points(); i++)
1105  sprintf (strchr(str, '\0'), " %ld", ((Node*)points[i])->give_lid_id(0));
1106 }
1107 
1108 
1109 
1110 //* ********************************************************************************************
1111 //* *** *** *** *** CLASS GELEMENT *** *** *** ***
1112 //* ********************************************************************************************
1114 Gelement :: Gelement (classID mecg, long gid, long oid, const Geometry *mg, long nn, long ne, long nf) : Element (mecg, gid, oid, 0, mg, nn, ne, nf)
1115 {
1116  attributes = new GelemAttribs(this, (long)0, EAL_direct);
1117  fixedVertices = NULL;
1118  fixedGelements = NULL;
1119 }
1121 Gelement :: Gelement (classID mecg, const Gelement * src) : Element(mecg, src)
1122 {
1123  //
1124  attributes = new GelemAttribs(this, (const GelemAttribs*)src->attributes, EAL_direct);
1125 }
1126 
1128 void Gelement :: set_elemSize (double val)
1129 {
1130  if (this->give_nfa()) {
1131  if (this->give_nfa() != 1) _errorr("elemSize at element with more than 1 face");
1132 
1133  ((Face*)this->give_face(0))->give_facedgeAttribs()->set_elemSize(val);
1134  }
1135  else {
1136  if (this->give_ned() != 1) _errorr("elemSize at element with more than 1 edge");
1137 
1138  ((Edge*)this->give_edge(0))->give_facedgeAttribs()->set_elemSize(val);
1139  }
1140 }
1141 
1143 void Gelement :: set_elemCount (double val)
1144 {
1145  if (this->give_ned() != 1) _errorr("elemCount at element with more than 1 edge");
1146 
1147  ((Edge*)this->give_edge(0))->give_facedgeAttribs()->set_elemCount(val);
1148 }
1149 
1151 void Gelement :: assign_fixed_entities_by_ID (bool node, long ncn, const long *icn)
1152 {
1153  if (node) { if (fixedVertices == NULL) fixedVertices = new GPA<const Vertex>; }
1154  else { if (fixedGelements == NULL) fixedGelements = new GPA<const Gelement>; }
1155 
1156  if (node) for (long i=0; i<ncn; i++) fixedVertices ->add(((Model*)Geom)->give_Vertex (icn[i]-1));
1157  else for (long i=0; i<ncn; i++) fixedGelements->add(((Model*)Geom)->give_Gelement(icn[i]-1));
1158 }
1159 
1160 
1161 //* ********************************************************************************************
1162 //* *** *** *** *** CLASS POLYLINE *** *** *** ***
1163 //* ********************************************************************************************
1166 {
1168 
1169  //* Detects (poly)line with hinges/condensed rotation DOFs at both end point.
1170  switch (this->elemAttribs()->give_dpn()) {
1171  case DPN_Dxy_R___:
1172  case DPN_DxyzR___: break;
1173  case DPN_Dxy_R__z:
1174  case DPN_DxyzRxyz:
1175  if (this->elemAttribs()->has_fullhinge_ends())
1176  _errorr2("Rotation DOFs condensed at both ends of Polyline - forbidden kinematic mechanism at elemnet %ld.", ID+1);
1177  break;
1178  default: errol;
1179  }
1180 }
1181 
1183 void PolyLine :: init_point_on (Mesh* pm, GPA<const Node> &hnodes, const PoinT *point, const GeometryComponent* comp, const PoinT *nc, const Point *parentpoint) const
1184 {
1185  const Node* node = dynamic_cast<const Node *> (comp);
1186  if (node) {
1187  hnodes.add(node);
1188  return;
1189  }
1190 
1191  const Cell* cell = dynamic_cast<const Cell *> (comp); if (!cell) errol;
1192 
1193  HangingNode *hn = new HangingNode(pm, (long)-1);
1194 
1195  int ord = -4;
1196  //
1197  const Facedge *faed = dynamic_cast<const Facedge*>(cell);
1198  if (faed)
1199  ord = faed->give_ord();
1200  else {
1201  const FElement *elem = dynamic_cast<const FElement*>(cell);
1202  if (elem)
1203  ord = elem->give_ord();
1204  else errol;
1205  }
1206 
1207  // !!!!!!!!!!!!!!
1208  hn->initialize_hn (point, cell, cell->give_dimension(), ord, cell->give_nno(), (const Node**)cell->give_points()->v(), nc);
1209  // set property
1210  if (parentpoint) { if (parentpoint->give_mproperty_cnt()) hn->set_mprop(parentpoint->give_mproperty()); }
1211  // tady hn zdedil property z elementu, byla prirazena do mproperty, to jsem ale zmenil:
1212  //else { if ( this->give_mproperty_cnt()) hn->set_mprop( this->give_mproperty()); }
1213  // zmenil jsem to na prirazeni do vproperty
1214  if ( this->give_mproperty_cnt()) hn->add_property (3, this->give_mproperty());
1215 
1216  hnodes.add((const Node*)hn);
1217  ((Mesh*)pm)->add_another_Pjnt ((Point*)hn);
1218 }
1219 
1222 {
1223  long i;
1224  PolyLine *pol1, *pol2 = NULL;
1225 
1227  if (hnodes()==0) {
1228  const GeometryComponent *comp;
1229  PoinT nc; nc.zero();
1230  int stpid = 0;
1231  while (true) {
1232  if ( pm->give_3Delement_with_point_inside (points[stpid]->give_coords(), comp, &nc) ) {
1233  // first point is inside
1234  if (stpid == 0)
1235  this->init_point_on (pm, hnodes, points[0]->give_coords(), comp, &nc, points[0]);
1236  // last point is inside => reverse polyline
1237  else if (stpid == points()-1) {
1238  ((PolyLine*)this)->points.reverse();
1239  this->init_point_on (pm, hnodes, points[0]->give_coords(), comp, &nc, points[0]);
1240  }
1241  // middle point is inside => split polyline
1242  else {
1243  pol1 = (PolyLine*)this;
1244  pol2 = new PolyLine(this);
1245 
1246  pol2->points.reverse();
1247  pol2->del_points_down(points()-stpid);
1248  pol2->points.reverse();
1249 
1250  pol1->del_points_down(1 +stpid);
1251  pol1->points.reverse();
1252 
1253  this->init_point_on (pm, hnodes, points[0]->give_coords(), comp, &nc, points[0]);
1254  }
1255 
1256  break;
1257  }
1258  else {
1259  if (Pd->give_PDBO(PDBO_cutRF)) {
1260  // first point is outside => try the last
1261  if (stpid == 0) stpid = points()-1;
1262  // last point is outside => try the second
1263  else if (stpid == points()-1) stpid = 1;
1264  // all point are outside => warning
1265  else if (stpid == points()-2) { _warningg2("Entire polygon (id %ld) lies outside of primary mesh", this->give_ID()); }
1266  // n-th point is outside => try n+1
1267  else stpid++;
1268  }
1269  else
1270  // first point is outside => error
1271  _errorr2 ("Start point of RF bar %ld doesn't lay inside of domain", this->give_ID());
1272  }
1273  }
1274  }
1275 
1277  this->divide(pm, hnodes);
1278 
1280  if (pm->give_Parallel()) {
1281  HangingNode *hn;
1282 
1283  for (i=0; i<hnodes(); i++) {
1284  hn = dynamic_cast<HangingNode *>((Node*)hnodes[i]);
1285  if (hn) ((HNAttribs*)hn->give_pointAttribs())->find_hndomain ();
1286  }
1287  }
1288 
1290  this->findout_segment_domain (pm, hnodes);
1291 
1292  return pol2;
1293 }
1294 
1299 void PolyLine :: divide (Mesh* pm, GPA<const Node> &hnodes) const
1300 {
1301  int dimMC;
1302  long i,j,tc,konec,clastelem;
1303  long csuperel=0,cunwnod=0,cunwfac=0; //
1304  PoinT ip, nc;
1305  const PoinT *curvert;
1306  const Node *nod, *curnod;
1307  const Point *auxnod, **unwnod=NULL;
1308  const HangingNode *curhnod;
1309  const Cell *compid;
1310  const Face *face, **unwfac=NULL; // unwanted faces
1311  const Edge *edge;
1312  const Element *elem, **superel=NULL, **lastelem;
1313  const GeometryComponent *comp;
1314 
1315  nc.zero();
1316 
1317  // loop over all segments
1318  for (i=1; i<points(); i++) {
1319  curvert = points[i]->give_coords();
1320  clastelem = 0;
1321  lastelem = NULL;
1322  konec = 0;
1323 
1324  // it goes along polyline to the end (konec) point
1325  while (!konec) {
1326  curnod = hnodes.last();
1327  curhnod = dynamic_cast<const HangingNode *> (curnod);
1328 
1329  if (curhnod) dimMC = curhnod->give_HNattrb()->give_dimMC();
1330  else dimMC = 0;
1331 
1332  // najde superior elements, kde by teoreticky mohl; byt dalsi HN
1333  // find superior elements = elements with potential HN
1334  switch (dimMC){
1335  case 0:
1336  nod = curnod;
1337 
1338  csuperel = nod->give_numsuperelem(); superel = nod->give_superelems()->v();
1339  cunwnod = 1; unwnod = (const Point**)&nod;
1340  cunwfac = nod->give_numsuperface(); unwfac = nod->give_superfaces()->v();
1341  break;
1342  case 1:
1343  edge = (const Edge*)curhnod->give_HNattrb()->give_MC();
1344 
1345  csuperel = edge->give_numsuperelem(); superel = edge->give_superelems()->v();
1346  cunwfac = edge->give_numsuperface(); unwfac = edge->give_superfaces()->v();
1347  if (clastelem) { cunwnod = edge->give_nno(); unwnod = edge->give_points()->v(); }
1348  else { cunwnod = 0; unwnod = NULL; }
1349  break;
1350  case 2:
1351  face = (const Face*)curhnod->give_HNattrb()->give_MC();
1352 
1353  csuperel = face->give_numsuperelem(); superel = face->give_superelems()->v();
1354  cunwfac = 1; unwfac = &face;
1355  if (clastelem) { cunwnod = face->give_nno(); unwnod = face->give_points()->v(); }
1356  else { cunwnod = 0; unwnod = NULL; }
1357  break;
1358  case 3:
1359  elem = (const Element*)curhnod->give_HNattrb()->give_MC();
1360 
1361  csuperel = 1; superel = (const Element**)&elem;
1362  cunwnod = 0; unwnod = NULL;
1363  cunwfac = 0; unwfac = NULL;
1364  break;
1365  default: _errorr ("Unknown dimension of master node");
1366  }
1367 
1368  // find intersection point of "superior element" and polyline
1369  for (j=0; j<csuperel; j++){
1370  if (same_array_elements_asym (1,superel+j,clastelem,lastelem)) continue;
1371  if (superel[j]->give_dimension() != 3) continue;
1372 
1373  // segment konci inside of element
1374  if (((FElement*)superel[j])->is_point_on (curvert, comp, &nc)) {
1375  this->init_point_on (pm, hnodes, curvert, comp, &nc, points[i]);
1376 
1377  konec = 1;
1378  break;
1379  }
1380 
1381  // segment protina node of element
1382  if (((FElement*)superel[j])->cross_abscissa_node (curnod->give_coords(), curvert, cunwnod, unwnod, auxnod, nc.x, &ip)){
1383  this->init_point_on (pm, hnodes, NULL, auxnod, &nc, NULL);
1384  break;
1385  }
1386 
1387  // segment intersects edge or face of element
1388  tc = ((FElement*)superel[j])->cross_abscissa_face (curnod->give_coords(), curvert, cunwfac, unwfac, compid, &nc, &ip);
1389 
1390  if (tc==1 || tc==2) { this->init_point_on (pm, hnodes, &ip, compid, &nc, NULL); break; }
1391  }
1392 
1394  if (j==csuperel) {
1395  if (Pd->give_PDBO(PDBO_cutRF)) {
1398  if (dimMC==2 && csuperel==1 && superel[0]->give_dimension()==3) {
1399  konec = 1;
1400  i = points();
1401  }
1403  else {
1405  if (dimMC==2 && csuperel==2 && superel[0]->give_dimension()==3)
1406  errol;
1408  else
1409  errol;
1410  }
1411  }
1412  else
1413  _errorr ("Something is wrong in function polyline_dividing");
1414  }
1415 
1416  lastelem = superel;
1417  clastelem = csuperel;
1418 
1419  } // end of while
1420 
1421  } // end of for
1422 
1424  //for (i=0;i<Np;i++){
1425  // if (PolyLines[i]->te==LiBeam){
1426  // for (j=0;j<PolyLines[i]->nhn;j++){
1427  // if (PolyLines[i]->hnodes[j]->dimMC==0)
1428  // Nodes[ PolyLines[i]->hnodes[j]->idMC ]->property = 7;
1429  // else
1430  // fprintf (stderr,"\n\n unknown type of dimmension of master component is required in function findout_hnode_domain. (%s, line %d).\n",__FILE__,__LINE__);
1431  // }
1432  // }
1433  //}
1435 }
1436 
1439 {
1440  long i,j,dom=0;
1441  FElement *elem = NULL;
1442 
1443  for (i=1; i<hnodes(); i++) {
1444  // find domain
1445  if (!pm->give_Parallel()) dom = 0;
1446  else
1447  if (!hnodes[i-1]->is_shared()) dom = hnodes[i-1]->give_domain();
1448  else if (!hnodes[i ]->is_shared()) dom = hnodes[i ]->give_domain();
1449  else
1450  for (j=0; j<pm->give_NumDomains(); j++)
1451  if (hnodes[i-1]->give_lid(j)>=0 && hnodes[i ]->give_lid(j)>=0)
1452  { dom = j; break; }
1453 
1454  // allocate new segment
1455  if (Pd->give_fulldata())
1456  if (this->elemAttribs()->give_dpn() != DPN_DxyzR___) _errorr ("Unknown type of segment");
1457 
1458  elem = new Beam (-1, -1, pm, this, dom, -1);
1459 
1460  elem->set_node(0, hnodes[i-1]);
1461  elem->set_node(1, hnodes[i ]);
1462  elem->set_mprop(this->give_mproperty());
1463 
1464  pm->add_another_Element (elem, dom);
1465  }
1466 }
1467 
1468 
1469 //* ********************************************************************************************
1470 //* *** *** *** *** CLASS LINE *** *** *** ***
1471 //* ********************************************************************************************
1474 {
1476 
1477  //* The line with hinges/condensed rotation DOFs at both end point is forced to be truss type.
1478  //* Tady by mela byt kontrola, ze na obou koncich neni uvolnena rotace kolem x,
1479  //* pokud je, tak predepisu zakaz rotace kolem osy x, ale jen prvnimu uzlu!!
1480  //* prerod na truss muzu udelat jen pokud argument prikaz radky, a pokud neni stabilita a pokud...
1481  //* Az to naimplementujes, tak rozchod udrzovane/stability/data/TEST_dodelat
1483  if (this->give_nno() != 2) errol;
1484 
1485  this->elemAttribs()->switch_dpn_Line();
1486  }
1487 }
1489 long Line :: give_edge_nodes (const Point **&edgnodes) const
1490 {
1491  if (points() != 2) errol;
1492  edgnodes = new const Point*[2];
1493 
1494  edgnodes[0] = points[0];
1495  edgnodes[1] = points[1];
1496  return 2;
1497 }
1498 
1499 
1500 //* ********************************************************************************************
1501 //* *** *** *** *** CLASS POLYGONMDL *** *** *** ***
1502 //* ********************************************************************************************
1505 {
1506  ((ComponentGeometry2Dpolygon*)cg)->set_nv(n);
1507  points.resizeup(n);
1508  edges. resizeup(n);
1509 }
1510 
1512 long PolygonMdl :: give_edge_nodes (const Point **&edgnodes) const
1513 {
1514  edgnodes = new const Point*[2*edges()];
1515 
1516  int i;
1517  for (i=0; i<edges()-1; i++) {
1518  edgnodes[2*i ] = points[i ];
1519  edgnodes[2*i+1] = points[i+1];
1520  }
1521  edgnodes[2*i ] = points[i];
1522  edgnodes[2*i+1] = points[0];
1523  return 2;
1524 }
1526 long PolygonMdl :: give_face_nodes_edges (const Point **&facnodes, const Edge **&facedges) const
1527 {
1528  facnodes = new const Point* [points()];
1529  facedges = new const Edge* [points()];
1530 
1531  for (int i=0; i<points(); i++) {
1532  facnodes[i] = points[i];
1533  facedges[i] = edges[i];
1534  }
1535  return points();
1536 }
1537 
1538 
1539 
1540 //* ********************************************************************************************
1541 //* *** *** *** *** CLASS FELEMENT *** *** *** ***
1542 //* ********************************************************************************************
1544 FElement :: FElement (classID mecg, long gid, long oid, const Geometry *mg, long o, long nn, long ne, long nf, bool aa, long dom, long lid) : Element (mecg, gid, oid, 0, mg, nn, ne, nf)
1545 {
1546  if (aa) this->attributes_allocation(NULL);
1547 
1548  //
1549  FElement::domain = dom;
1550  FElement::lid = lid;
1551 
1552  mdl_masterel = NULL;
1553 
1554  //
1555  results = NULL;
1556  maxSigmaEq = NULL;
1557  regid = -1;
1558 }
1560 FElement :: FElement (classID mecg, const FElement * src) : Element(mecg, src)
1561 {
1562  //
1563  attributes = new FElemAttribs(this, (const FElemAttribs*)src->attributes, '?');
1564 
1565  domain = 0; if (src->domain) errol;
1566  lid = ID; if (src->lid != src->ID) errol;
1567  results = NULL; if (src->results) errol;
1568  maxSigmaEq = NULL; if (src->maxSigmaEq) errol;
1569 }
1572 {
1573  deallocateCheckUno (results, Msh()->give_rslts_nsteps(), cRTE, false);
1574  if (maxSigmaEq) delete maxSigmaEq;
1575 }
1576 
1579 {
1580  if (attributes) errol;
1581 
1582  if (masterat) attributes = new FElemAttribs(this, masterat, 'm');
1583  else attributes = new FElemAttribs(this, (long)0, EAL_direct);
1584 }
1585 
1586 
1589 {
1591 }
1592 //void FElement :: finitialize (void){ Element :: finitialize (); //attributes->finitialize();}
1595 {
1597 
1598  if (elemAttribs()->give_ord() > 0)
1599  _errorr("odkomentuj nasledujici");
1600  // bool ordcheck;
1601  // if ( Msh()->connectivity_is_assembled() ) ordcheck = true;
1602  // else ordcheck = false;
1603  //
1604  // if (ordcheck) {
1605  // long i;
1606  //
1607  // // *** check same ord ***
1608  // for (i=0; i<edges(); i++)
1609  // if (elemAttribs()->give_ord() != edges[i]->give_ord())
1610  // _errorr2 ("ord != edges[%d]->ord", i);
1611  //
1612  // // *** check same ord ***
1613  // for (i=0; i<faces(); i++)
1614  // if (elemAttribs()->give_ord() != faces[i]->give_ord())
1615  // _errorr2 ("ord != faces[%d]->ord", i);
1616  // }
1617 }
1618 
1620 void FElement :: set_model_prop (long val, const Model *model, bool flag)
1621 {
1623 
1624  mdl_masterel = dynamic_cast<const Gelement*>(model->give_Elem(val-1));
1625 
1626 # ifdef DEBUG
1627  if (mdl_masterel == NULL) errol;
1628  if (this->give_dimension() != mdl_masterel->give_dimension()) errol;
1629  if (flag) errol;
1630 # endif
1631 }
1632 
1633 
1636 {
1637  IntPointSet IPset = this->elemAttribs()->give_IPset();
1638  if (IPset != IPS_Void) return IPset;
1639 
1640  FiniteElementTypeSet fetset;
1641  return IntPointSet_fet2e_comp (FETSet_set2e (this->elemAttribs()->give_FETS(&fetset), sol, Pd->give_analgroup()));
1642 
1643  return IPS_Void;
1644 }
1645 
1648 {
1649  FiniteElementTypeSet fetset;
1650  return IntPointSet_fet2e_rslts (this->give_IPset_comp(sol), FETSet_set2e (this->elemAttribs()->give_FETS(&fetset), sol, Pd->give_analgroup()));
1651 }
1652 
1653 // /// higher set = for displacement^2 computation, or mass matrix or sigma error ...
1654 // IntPointSet FElement :: give_IPset2 (void) const
1655 // {
1656 // //IntPointSet IPset; // = this->elemAttribs()->give_IPset2();
1657 //
1658 // /// default IPset
1659 // FiniteElementTypeSet fetset;
1660 // return IntPointSet_fets2ips_2 (this->elemAttribs()->give_FETS(&fetset));
1661 // }
1662 
1663 
1666 {
1668 
1669  FiniteElementTypeSet fets1; this-> elemAttribs()->give_FETS(&fets1);
1670  FiniteElementTypeSet fets2; ((FElement*)slave)->elemAttribs()->give_FETS(&fets2);
1671 
1672  if (! fets1.is_equal_to(fets2)) _errorr ("Duplicity slave and master differ in rot atribut");
1673 
1674  const FElement *slv = dynamic_cast<const FElement *>(slave);
1675  if (!slv) _errorr ("The slave is not same type as this");
1676 }
1677 
1679  // const Dvctr* FElement :: give_results_d (long step, ResultTypesAtElem rt) const
1680  // {
1681  // if (results[step][rt] == NULL) return NULL;
1682  //
1683  // Dvctr *rslt = dynamic_cast<Dvctr*>(results[step][rt]);
1684  // if (!rslt) errol;
1685  //
1686  // return rslt;
1687  // }
1688 
1689 
1690 //* *******************
1691 //* *** RESULTS ***
1692 //* *******************
1695 {
1696  if (results) return;
1697 
1698  results = new Array**[Msh()->give_rslts_nsteps()];
1699 
1700  for (long i=0; i<Msh()->give_rslts_nsteps(); i++) {
1701  results[i] = new Array*[cRTE];
1702  memset (results[i], 0, cRTE*sizeof(Array*));
1703  }
1704 }
1705 
1706 
1708 void FElement :: add_result ( Array *rslt, long step, ResultTypesAtElem rt) { this->allocate_results(); if (this->results[step][rt]) errol; this->results[step][rt] = rslt;}
1709 void FElement :: set_result (long s, double *rslt, long step, ResultTypesAtElem rt) { this->allocate_results(); if (this->results[step][rt]) errol; this->results[step][rt] = new Dvctr(s, rslt); }
1710 void FElement :: set_result ( double rslt, long step, ResultTypesAtElem rt) { this->allocate_results(); if (this->results[step][rt]) errol; this->results[step][rt] = new Dscal( rslt); }
1711 void FElement :: set_result ( const VectoR *rslt, long step, ResultTypesAtElem rt) { this->allocate_results(); if (this->results[step][rt]) errol; this->results[step][rt] = new Dvctr( rslt); }
1712 
1714 const Dscal* FElement :: give_results_ds (long step, ResultTypesAtElem rt) const { if (results[step][rt] == NULL) return NULL; Dscal *rslt = dynamic_cast<Dscal*>(results[step][rt]); if (!rslt) errol; return rslt; }
1715 const Dvctr* FElement :: give_results_dv (long step, ResultTypesAtElem rt) const { if (results[step][rt] == NULL) return NULL; Dvctr *rslt = dynamic_cast<Dvctr*>(results[step][rt]); if (!rslt) errol; return rslt; }
1716 const Dmtrx* FElement :: give_results_dm (long step, ResultTypesAtElem rt) const { if (results[step][rt] == NULL) return NULL; Dmtrx *rslt = dynamic_cast<Dmtrx*>(results[step][rt]); if (!rslt) errol; return rslt; }
1717 
1720 {
1721  if (maxSigmaEq) return;
1722 
1723  int nl = this->elemAttribs()->give_cs()->give_nlayers();
1724 
1725  if (nl) maxSigmaEq = new double[nl];
1726  else maxSigmaEq = new double;
1727 
1728  this->compute_maxSigmaEq();
1729 
1730  if (maxSigmaEq[0] <= 0.0) {
1731  delete maxSigmaEq;
1732  maxSigmaEq = NULL;
1733  }
1734 }
1735 
1738 {
1739  this->setup_maxSigmaEq();
1740 
1741  if (maxSigmaEq == NULL) return 0.0;
1742 
1743  int nl = this->elemAttribs()->give_cs()->give_nlayers();
1744 
1745  if (nl == 0) return maxSigmaEq[0];
1746 
1747  double max = 0.0;
1748 
1749  for (int i=0; i<nl; i++)
1750  if (max < maxSigmaEq[i])
1751  max = maxSigmaEq[i];
1752 
1753  return max;
1754 }
1755 
1758 {
1759  this->setup_maxSigmaEq();
1760 
1761  if (maxSigmaEq == NULL) return 0.0;
1762 
1763  int nl = this->elemAttribs()->give_cs()->give_nlayers();
1764 
1765  if (nl == 0) return maxSigmaEq[0] / elemAttribs()->give_mat()->give_Ry();
1766 
1767  double val, max = 0.0;
1768 
1769  for (int i=0; i<nl; i++) {
1770  val = maxSigmaEq[i] / this->elemAttribs()->give_cs()->give_mat(i)->give_Ry();
1771  if (max < val)
1772  max = val;
1773  }
1774 
1775  return max;
1776 }
1779 {
1780  double answer = this->give_CSusage_elast_rel();
1781 
1782  return ( answer > 0.0 ? answer > 1.0 : -1 );
1783 }
1784 
1785 double FElement :: fillupbyzero (Dvctr *data, SStype SST) const
1786 {
1787  switch (SST) {
1788  case SST_truss: data->resize_ignore_vals(1); data->zero(); break;
1789  case SST_plstrain:
1790  case SST_plstress: data->resize_ignore_vals(3); data->zero(); break;
1791  case SST_beam: data->resize_ignore_vals(9); data->zero(); break;
1792  case SST_3d:
1793  case SST_3dshell: data->resize_ignore_vals(6); data->zero(); break;
1794  case SST_transp2d: data->resize_ignore_vals(3*Pd->give_global_nDOFs()); data->zero(); break;
1795 
1796  default: _errorr2("unsupported SST_* %d", SST);
1797  }
1798 
1799  return 0.0;
1800 }
1801 
1803 long FElement :: give_result_ncomp (long time_step, ResultTypesAtElem rte) const
1804 {
1805  if (results == NULL) errol;
1806 
1807  if (results[time_step][rte] == NULL) return 0;
1808 
1809  Xmtrx *mtrx = dynamic_cast<Xmtrx*>(results[time_step][rte]);
1810  if (mtrx == NULL) errol;
1811 
1812  return mtrx->give_ccols();
1813 }
1814 
1816 void FElement :: read_input (const char *&str, femFileFormat fff)
1817 {
1818  switch (fff) {
1819  case FFF_T3d: {
1820  long parentdim, auxl, prop;
1821 
1822  this->read_nodes (str, fff);
1823 
1824  SP_scan_number (str, parentdim);
1825  SP_scan_number (str, auxl);
1826  SP_scan_number (str, prop);
1827 
1828  // master model element
1829  const Model *model = ((Mesh*)Geom)->give_Master_model();
1830 
1831 # ifdef DEBUG
1832  if (model && prop<1) errol;
1833 # endif
1834 
1835  if (model) {
1836  this->set_model_prop (prop, model);
1838  }
1839  else {
1840  this->attributes_allocation(NULL);
1841  this->set_mprop(prop); // attributes allocation have to be before property setting
1842  }
1843 
1844  this->connectivity_assembling(false);
1845 
1847  switch (this->give_cellGeom()) {
1848  case CG_Line: if (model) ((Edge*)edges[0])->set_model_prop (prop, model, true); break;
1849  case CG_Triangle:
1850  case CG_Quadrangle: if (model) ((Face*)faces[0])->set_model_prop (prop, model, true);
1851  // edge property
1852  SP_skip_word (str, edges());
1853  for (int i, e=0; e<edges(); e++) {
1854  i = ECN_convert_e2i (e, 1, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
1855  SP_scan_number (str, prop);
1856  if (prop) {
1857  if (model) ((Edge*)edges[i])->set_model_prop (prop, model, false);
1858  else ((Edge*)edges[i])->checkset_mprop(prop);
1859  }
1860 # ifdef DEBUG
1861  else if ( ((Edge*)edges[i])->give_mproperty_cnt()) errol;
1862 # endif
1863  }
1864  break;
1865  case CG_Hexahedron:
1866  // face property
1867  for (int i, e=0; e<faces(); e++) {
1868  i = ECN_convert_e2i (e, 2, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
1869  SP_scan_number (str, prop);
1870  if (prop) {
1871  if (model) ((Face*)faces[i])->set_model_prop (prop, model, false);
1872  else ((Face*)faces[i])->checkset_mprop(prop);
1873  }
1874 # ifdef DEBUG
1875  else if ( ((Face*)faces[i])->give_mproperty_cnt()) errol;
1876 # endif
1877  }
1878  break;
1879  default: _errorr2("unsupported cell geometry CG_* %d", this->give_cellGeom());
1880  }
1881 
1882  break;
1883  }
1884  case FFF_OOFEM:
1885  SP_scan_expected_word_exit (str, "nodes", "Invalid structure of the given OOFEM input file", CASE);
1886  SP_scan_expected_number_exit (str, points(), "Invalid input, number of nodes on element");
1887 
1888  this->read_nodes (str, fff);
1889 
1890  //if (attributes) _errorr ("attributes already allocated");
1891  //attributes = new ElemAttribs(0, Pd, this);
1892  elemAttribs()->initialize_from (str, fff);
1893  break;
1894  case FFF_SIFEL:
1895  this->read_nodes (str, fff);
1896 
1897  int auxi;
1898  SP_scan_number (str, auxi); if (auxi) errol; // code numbers
1899 
1901  break;
1902  case FFF_JKTK:
1903  this->read_nodes (str, fff);
1904 
1905  this->connectivity_assembling(false);
1906 
1907  long prop;
1908  SP_scan_number (str, prop);
1909  this->set_mprop(prop);
1910 
1911  int e, i;
1912  for (e=0; e<edges(); e++) {
1913  SP_scan_number (str, prop);
1914  i = ECN_convert_e2i (e, 1, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
1915  if (prop) ((Edge*)edges[i])->checkset_mprop(prop);
1916 # ifdef DEBUG
1917  else if ( ((Edge*)edges[i])->give_mproperty_cnt()) errol;
1918 # endif
1919  }
1920  for (e=0; e<faces(); e++) {
1921  SP_scan_number (str, prop);
1922  i = ECN_convert_e2i (e, 2, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
1923  if (prop) ((Face*)faces[i])->checkset_mprop(prop);
1924 # ifdef DEBUG
1925  else if ( ((Face*)faces[i])->give_mproperty_cnt()) errol;
1926 # endif
1927  }
1928  break;
1929  default: _errorr("unsupported fem file format");
1930  }
1931 }
1932 
1933 
1935 void FElement :: print_row (FILE *stream, femFileFormat fff, bool endline, long did) const
1936 {
1937  int e;
1938  long i;
1939  FiniteElementTypeSet fets;
1940 
1941  switch (fff) {
1942  case FFF_OOFEM:
1943  // name
1944  fprintf (stream, "%s", FETSet_set2s_OOFEM (this->elemAttribs()->give_FETS(&fets), Pd->give_analgroup()));
1945 
1946  // nodes
1947  if (Parallel()) fprintf (stream, " %4ld nodes %ld ", lid+1, points());
1948  else if (Pd->give_PDBO (PDBO_OUT_origelemid)) fprintf (stream, " %4ld nodes %ld ", origid, points());
1949  else fprintf (stream, " %4ld nodes %ld ", ID+1, points());
1950 
1951  for (e=0; e<points(); e++) {
1952  i = ECN_convert_e2i (e, 0, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
1953  fprintf (stream, "%4ld ", ((Node*)points[i])->give_lid_id(domain)+1);
1954  }
1955 
1956  // attributes
1957  elemAttribs()->print_row (stream, fff, domain);
1958  break;
1959  case FFF_SIFEL:
1960  // nodes
1961  fprintf (stream, "%6ld", this->ID+1);
1962  fprintf (stream, " %d", FETSet_set2i_SIFEL (this->elemAttribs()->give_FETS(&fets), Pd->give_analgroup()));
1963  if (elemAttribs()->give_sst() == SST_plstress) fprintf (stream, " 10");
1964  if (elemAttribs()->give_sst() == SST_plstrain) fprintf (stream, " 11");
1965 
1966  for (e=0; e<points(); e++) {
1967  i = ECN_convert_e2i (e, 0, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
1968  fprintf (stream, " %6ld", points[i]->give_ID()+1);
1969  }
1970 
1971  // attributes
1972  elemAttribs()->print_row (stream, fff, domain);
1973  break;
1974  case FFF_ANSYS:
1975  // type
1976  fprintf (stream, "TYPE, %d\n", FETSet_set2e (this->elemAttribs()->give_FETS(&fets), SOL_ANSYS, Pd->give_analgroup()) - FET_ANSYS_start);
1977 
1978  // attributes
1979  elemAttribs()->print_row (stream, fff, domain);
1980 
1981  fprintf (stream, "E");
1982  for (e=0; e<points(); e++) {
1983  i = ECN_convert_e2i (e, 0, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
1984  fprintf (stream, ",%6ld", points[i]->give_ID()+1);
1985  }
1986 
1987  fprintf (stream,"\n");
1988  break;
1989  case FFF_JKTK: {
1990  bool m = Pd->give_PDBO(PDBO_melnik);
1991 
1992  // nodes
1993  if (!m) fprintf (stream, "%8ld", this->ID+1);
1994  else fprintf (stream, "%ld", this->ID+1);
1995  fprintf (stream, " %d", CellGeometry_e2i_JKTK (this->give_cellGeom()));
1996  if (!m) fprintf (stream, " ");
1997 
1998  for (e=0; e<points(); e++) {
1999  i = ECN_convert_e2i (e, 0, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
2000  if (!m) fprintf (stream, "%7ld", points[i]->give_ID()+1);
2001  else fprintf (stream, " %ld", points[i]->give_ID()+1);
2002  }
2003 
2004  if (!m) fprintf (stream, "%5ld", this->give_mpropertyORzero());
2005  else fprintf (stream, " %ld", this->give_mpropertyORzero());
2006 
2007  if (!m) { if (edges()) fprintf (stream, " "); }
2008  for (e=0; e<edges(); e++) {
2009  i = ECN_convert_e2i (e, 1, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
2010  fprintf (stream, " %ld", edges[i] ? edges[i]->give_mpropertyORzero() : 0);
2011  }
2012  if (!m) { if (faces()) fprintf (stream, " "); }
2013  for (e=0; e<faces(); e++) {
2014  i = ECN_convert_e2i (e, 2, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
2015  fprintf (stream, " %ld", faces[i] ? faces[i]->give_mpropertyORzero() : 0);
2016  }
2017  break;
2018  }
2019  default: errol;
2020  }
2021 
2022  //
2023  if (endline) fprintf (stream,"\n");
2024 }
2025 
2027 void FElement :: read_nodes (const char *&str, femFileFormat fff)
2028 {
2029  int e, i;
2030  long auxl;
2031  for (e=0; e<points(); e++) {
2032  SP_scan_number (str, auxl);
2033  i = ECN_convert_e2i (e, 0, this->elemAttribs()->give_ord(), this->give_cellGeom(), fff);
2034  this->set_node(i, auxl-1);
2035  }
2036 }
2037 
2040 {
2041 // docasne zakomentovano if (nno != 2) _errorr ("nno != 2") ;
2042 // docasne zakomentovano
2043 // docasne zakomentovano const Node *node1 = nodes[0]; if ( node1->give_pointAttribs()->give_BC()[0] ) return false;
2044 // docasne zakomentovano const Node *node2 = nodes[1]; if ( node2->give_pointAttribs()->give_BC()[0] ) return false;
2045 // docasne zakomentovano
2046 // docasne zakomentovano long nexn1 = node1->give_numsuperelem() - 1; //if (nexn1 == 0) return true;
2047 // docasne zakomentovano long nexn2 = node2->give_numsuperelem() - 1; //if (nexn2 == 0) return true;
2048 // docasne zakomentovano
2049 // docasne zakomentovano // smaze pruty ktery se dotykaji nepodepreneho uzlu ktereho se dotykaji jen 1 nebo 2 pruty
2050 // docasne zakomentovano if ( nexn1<2 || nexn2<2 ) {
2051 // docasne zakomentovano this->set_delete_flag(true);
2052 // docasne zakomentovano return true;
2053 // docasne zakomentovano }
2054 
2055  return false;
2056 
2057  // smaze prouty ktery netvori trojuhelnik s jinymi
2058  // u vlny je to bohuzel 100%
2059  //
2060  //const Node **exns = new const Node* [nexn1+nexn2]; nexn1 = 0;
2061  //
2062  //for (int i=0; i<node1->give_numsuperelem(); i++)
2063  // if (node1->give_superelem(i) != this) {
2064  // if (node1->give_superelem(i)->give_node(0) != node1) exns[nexn1++] = node1->give_superelem(i)->give_node(0);
2065  // else exns[nexn1++] = node1->give_superelem(i)->give_node(1);
2066  // }
2067  //
2068  //for (int i=0; i<node2->give_numsuperelem(); i++)
2069  // if (node2->give_superelem(i) != this) {
2070  // if (node2->give_superelem(i)->give_node(0) != node2) exns[nexn1++] = node2->give_superelem(i)->give_node(0);
2071  // else exns[nexn1++] = node2->give_superelem(i)->give_node(1);
2072  // }
2073  //
2074  //nexn2 = members_are_unique (nexn1, exns);
2075  //
2076  //delete [] exns;
2077  //
2078  //if (nexn2) {
2079  // this->set_delete_flag(true);
2080  // return true;
2081  //}
2082  //
2083  //return false;
2084 }
2085 
2086 
2087 //* ********************************************************************************************
2088 //* *** *** *** *** CLASS ELEMENT *** *** *** ***
2089 //* ********************************************************************************************
2090 void OOFEM_output_scan_elem_head (const char *str, long o, long i, bool oid)
2091 {
2092  ; SP_scan_expected_word_exit (str, "element", "Invalid structure of OOFEM output file ", CASE);
2093  if (oid) SP_scan_expected_number_exit (str, o, "Invalid structure of OOFEM output file");
2094  if (oid) SP_scan_expected_word_exit (str, "(", "Invalid structure of OOFEM output file", CASE);
2095  ; SP_scan_expected_number_exit (str, i, "Invalid structure of OOFEM output file");
2096  if (oid) SP_scan_expected_word_exit (str, ")", "Invalid structure of OOFEM output file", CASE);
2097 }
2098 void OOFEM_output_scan_GP (const char *&str, int i, bool old=false)
2099 {
2100  char GP[7];
2101  if (old) sprintf (GP, "%d", i);
2102  else sprintf (GP, "1.%d", i);
2103 
2104  SP_scan_expected_word_exit (str, "GP", "Invalid structure of OOFEM output file", CASE);
2105  SP_scan_expected_word_exit (str, GP , "Invalid structure of OOFEM output file", CASE);
2106  SP_scan_expected_word_exit (str, ":", "Invalid structure of OOFEM output file", CASE);
2107 }
2108 void OOFEM_output_scan_GP (FILE *stream, int i, bool old=false)
2109 {
2110  char GP[7];
2111  if (old) sprintf (GP, "%d", i);
2112  else sprintf (GP, "1.%d", i);
2113 
2114  FP_scan_expected_word_exit (stream, "GP", "Invalid structure of OOFEM output file", CASE);
2115  FP_scan_expected_word_exit (stream, GP , "Invalid structure of OOFEM output file", CASE);
2116  FP_scan_expected_word_exit (stream, ":", "Invalid structure of OOFEM output file", CASE);
2117 }
2118 
2119 
2120 //* ********************************************************************************************
2121 //* *** *** *** *** CLASS BEAM *** *** *** ***
2122 //* ********************************************************************************************
2124 void Beam :: checkConsistency (void) const
2125 {
2127 
2128  //* Detects beam with hinges/condensed rotation DOFs at both end point.
2129  switch (this->elemAttribs()->give_dpn()) {
2130  case DPN_DxyzR___: break;
2131  case DPN_DxyzRxyz:
2132  if (this->elemAttribs()->has_fullhinge_ends())
2133  _errorr2("Rotation DOFs condensed at both ends of Beam - forbidden kinematic mechanism at elemnet %ld.", ID+1);
2134  break;
2135  default: errol;
2136  }
2137 
2138  // NA CO JE TOTO?
2139  // to bych mel spis kontrolovat na vyssi urovni, asi na Elemnetu, ale je to vubec nutne?
2140  // DOFsPerNode DPN = Pd->give_DOFspnod();
2141  //switch (this->elemAttribs()->give_dpn()) {
2142  //case DPN_DxyzR___:
2143  //case DPN_DxyzRxyz: if (DPN != DPN_DxyzR___ && DPN != DPN_DxyzRxyz) errol; break;
2144  //default: errol;
2145  //}
2146 }
2147 
2150 {
2151  switch (Pd->give_DOFspnod()) {
2152  case DPN_DxyzR___: return DPN_DxyzR___; break;
2153  case DPN_DxyzRxyz: return DPN_DxyzRxyz; break;
2154  default: errol;
2155  }
2156  return DPN_Void;
2157 }
2160 {
2161  switch (this->elemAttribs()->give_dpn()) {
2162  case DPN_DxyzR___: return SST_truss; break;
2163  case DPN_DxyzRxyz: return SST_beam; break;
2164  default: errol;
2165  }
2166  return SST_Void;
2167 }
2168 
2169 // /// return type of element for OOFEM solver
2170 // FiniteElementType Beam :: give_fe (Solver sol) const
2171 // {
2172 // FiniteElementType feoDef, feoExpl;
2173 //
2174 // if (elemAttribs()->give_rot() == false) feoDef = FET_Truss3d;
2175 // else feoDef = FET_Beam3d;
2176 //
2177 // feoExpl = elemAttribs()->give_FET();
2178 //
2179 // if (feoExpl != FET_Void && feoExpl != feoDef) {
2180 // if (feoExpl == FET_LiBeam3d && feoDef == FET_Beam3d) feoDef = FET_LiBeam3d;
2181 // else if (feoExpl == FET_LiBeam3dNL && feoDef == FET_Beam3d) feoDef = FET_LiBeam3dNL;
2182 // else errol;
2183 // }
2184 //
2185 // return feoDef;
2186 // }
2187 
2189 long Beam :: give_edge_nodes (const Point **&edgnodes) const
2190 {
2191  if (elemAttribs()->give_ord() != -4) errol;
2192  edgnodes = new const Point*[2];
2193 
2194  edgnodes[0] = points[0];
2195  edgnodes[1] = points[1];
2196  return 2;
2197 }
2198 
2200 {
2201  if (points() != 2) errol;
2202  v->beP2P(points[0]->give_coords(), points[1]->give_coords());
2203 }
2204 
2206 void Beam :: read_output_OOFEM (FILE *stream, long step)
2207 {
2208  const char *str;
2209  char LINE[1023];
2210  double *vald, l;
2211  Dmtrx *strain = new Dmtrx;
2212  Dmtrx *stress = new Dmtrx;
2213 
2215  IntPointSet ips = this->give_IPset_rslts(SOL_OOFEM);
2216  int NIP = IntPointSet_give_number_ips (ips);
2217  if (NIP != 1) errol; // ip nacitat ve spravnem poradi, az nip != 1 !!!
2218 
2219  int ver = Pd->give_P_OOFEM_ver();
2220 
2221  FiniteElementTypeSet fets;
2222  FiniteElementType feto = FETSet_set2e (this->elemAttribs()->give_FETS(&fets), SOL_OOFEM, Pd->give_analgroup());
2223 
2224  switch (feto) {
2225  case FET_OOFEM_Truss3d:
2226  strain->resize_ignore_vals(NIP, 1);
2227  stress->resize_ignore_vals(NIP, 1);
2228  vald = new double[6];
2229 
2231  fgets (LINE, 1023, stream); str=LINE;
2232  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, ver >= 18);
2233 
2235  fgets (LINE, 1023, stream); str=LINE;
2236  OOFEM_output_scan_GP (str, 1, ver < 18);
2237  SP_scan_expected_word_exit (str, "strains", "Invalid structure of OOFEM output file", CASE);
2238  if (!SP_scan_array (str, 6, vald)) _errorr ("Invalid structure of OOFEM output file");
2239  if (! isZero(1e-10, vald[1]+vald[2]+vald[3]+vald[4]+vald[5])) _errorr ("Invalid structure of OOFEM output file");
2240  (*strain)(0,0) = vald[0];
2241 
2243  fgets (LINE, 1023, stream); str=LINE;
2244  SP_scan_expected_word_exit (str, "stresses", "Invalid structure of OOFEM output file", CASE);
2245  if (!SP_scan_array (str, 6, vald)) _errorr ("Invalid structure of OOFEM output file");
2246  if (! isZero(1e-10, vald[1]+vald[2]+vald[3]+vald[4]+vald[5])) _errorr ("Invalid structure of OOFEM output file");
2247  (*stress)(0,0) = vald[0];
2248 
2249  delete [] vald;
2250  break;
2251  case FET_OOFEM_LiBeam3d:
2252  strain->resize_ignore_vals(NIP, 12);
2253  stress->resize_ignore_vals(NIP, 12);
2254  l = this->give_lav();
2255 
2257  fgets (LINE, 1023, stream); str=LINE;
2258  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, ver >= 18);
2259 
2261  vald = strain->give_ptr2val(0, 0);
2262  fgets (LINE, 1023, stream); str=LINE;
2263  OOFEM_output_scan_GP (str, 1, ver < 18);
2264  SP_scan_expected_word_exit (str, "strains", "Invalid structure of OOFEM output file", CASE);
2265  if (!SP_scan_array (str, 12, vald)) _errorr ("Invalid structure of OOFEM output file");
2266  if (! isZero(1e-10, vald[1]+vald[2]+vald[3]+vald[9]+vald[10]+vald[11])) _errorr ("Invalid structure of OOFEM output file");
2267  vald[ 9] = l * vald[6];
2268  vald[10] = l * vald[7];
2269  vald[11] = l * vald[8];
2270  vald[ 6] = l * vald[0];
2271  vald[ 7] = l * vald[5];
2272  vald[ 8] = l * vald[4];
2273  vald[0] = vald[4] = vald[5] = 0.0;
2274  // ??
2275  vald[7] = vald[7] + 0.5 * l * vald[11]; // Vy += 0.5 * l * Mz
2276  vald[8] = vald[8] - 0.5 * l * vald[10]; // Vz -= 0.5 * l * My
2277 
2279  vald = stress->give_ptr2val(0, 0);
2280  fgets (LINE, 1023, stream); str=LINE;
2281  SP_scan_expected_word_exit (str, "stresses", "Invalid structure of OOFEM output file", CASE);
2282  if (!SP_scan_array (str, 12, vald)) _errorr ("Invalid structure of OOFEM output file");
2283  if (! isZero(1e-10, vald[1]+vald[2]+vald[3]+vald[9]+vald[10]+vald[11])) _errorr ("Invalid structure of OOFEM output file");
2284  vald[1] = vald[5];
2285  vald[2] = vald[4];
2286  vald[3] = vald[ 9] = vald[6];
2287  vald[4] = vald[10] = vald[7];
2288  vald[5] = vald[11] = vald[8];
2289  vald[6] = vald[0];
2290  vald[7] = vald[1];
2291  vald[8] = vald[2];
2292 
2293  break;
2294  case FET_OOFEM_Beam3d:
2295  strain->resize_ignore_vals(NIP, 12);
2296  stress->resize_ignore_vals(NIP, 12);
2297 
2299  fgets (LINE, 1023, stream); str=LINE;
2300  SP_scan_expected_word_exit (str, "beam", "Invalid structure of OOFEM output file", CASE);
2301  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, false);
2302 
2303  // /// strain
2304  // vald = strain->give_ptr2val(0, 0);
2305  // fgets (LINE, 1023, stream); str=LINE;
2306  // SP_scan_expected_word_exit (str, "local displacements", "Invalid structure of OOFEM output file", CASE);
2307  // if (!SP_scan_array (str, 12, vald)) _errorr ("Invalid structure of OOFEM output file");
2308  // /// stress
2309  // vald = stress->give_ptr2val(0, 0);
2310  // fgets (LINE, 1023, stream); str=LINE;
2311  // SP_scan_expected_word_exit (str, "local end forces", "Invalid structure of OOFEM output file", CASE);
2312  // if (!SP_scan_array (str, 12, vald)) _errorr ("Invalid structure of OOFEM output file");
2313  // for (int i=0; i<6; i++) vald[i] *= -1;
2314 
2316  vald = strain->give_ptr2val(0, 0);
2317  FP_scan_expected_word_exit (stream, "local displacements", "Invalid structure of OOFEM output file", CASE);
2318  if (!FP_scan_array (stream, 12, vald)) _errorr ("Invalid structure of OOFEM output file");
2319 
2321  vald = stress->give_ptr2val(0, 0);
2322  FP_scan_expected_word_exit (stream, "local end forces", "Invalid structure of OOFEM output file", CASE);
2323  if (!FP_scan_array (stream, 12, vald)) _errorr ("Invalid structure of OOFEM output file");
2324  for (int i=0; i<6; i++) vald[i] *= -1;
2325 
2326  FP_skip_line(stream);
2327 
2328  break;
2329  default: _errorr("unsupported type of beam element");
2330  }
2331 
2332  this->add_result(strain, step, RTE_global_strain);
2333  this->add_result(stress, step, RTE_global_stress);
2334 }
2336 void Beam :: read_output_SIFEL (FILE *stream, long step, ResultTypesAtElem rt)
2337 {
2338  const char *str;
2339  char LINE[1023], msg[60];
2340 
2341  sprintf (msg, "Invalid structure of SIFEL output file, element %ld", origid+1);
2342 
2344  IntPointSet ips = this->give_IPset_rslts(SOL_SIFEL);
2345  int NIP = IntPointSet_give_number_ips (ips);
2346  if (NIP != 1) errol; // toto je zde natvrdo, u tr v transportu je jeden IP, // ip nacitat ve spravnem poradi, az nip != 1 !!!
2347  int NIPa = 1; // ale tisknou se 4, protoze datel a nebo kaser a labus
2348 
2350  fgets (LINE, 1023, stream); str=LINE;
2351  SP_scan_expected_word_exit (str, "Element", msg, CASE);
2352  SP_scan_expected_number_exit (str, origid+1, msg);
2353  SP_scan_expected_word_exit (str, ", integration points", msg, CASE);
2354  long ip1, ip2;
2355  SP_scan_number (str, ip1);
2356  SP_scan_expected_word_exit (str, "-", msg, CASE);
2357  SP_scan_number (str, ip2);
2358  if (ip2-ip1+1 != NIPa) _errorr(msg);
2359 
2360  int nstrcomp = 1;
2362  if (Pd->give_analgroup() == PAG_mechanics) {
2363  int j;
2364  Dmtrx *values = new Dmtrx(NIP, nstrcomp);
2365 
2366  // loop over NIP
2367  for (int i=0; i<NIP; i++) {
2368  fgets (LINE, 1023, stream); str=LINE;
2369 
2370  char r[15];
2371  for (j=0; j<nstrcomp; j++) {
2372  if (rt == RTE_global_strain) sprintf(r, "eps_%d=", j+1);
2373  else if (rt == RTE_global_stress) sprintf(r, "sig_%d=", j+1);
2374  else errol;
2375  SP_scan_expected_word_exit (str, r, msg, CASE);
2376  SP_scan_number (str, (*values)(i,j));
2377  }
2378  }
2379 
2380  FP_skip_line (stream, NIPa-NIP);
2381 
2382  this->add_result (values, step, rt);
2383  }
2384  else errol;
2385 }
2386 
2388 double Beam :: give_ssstate (Dvctr *data, SStype SST, RVType rvtype, char type, long step, const Node *node)
2389 {
2390  if (this->elemAttribs()->give_sst() != SST) return this->fillupbyzero (data, SST);
2391 
2392  if ( Msh()->give_rslts_solver() == SOL_OOFEM ) {
2393  //if (node && this->give_rslt_NIP(SOL_OOFEM) !=1) errol;
2394  if (node) errol;
2395 
2396  if (SST == SST_truss) {
2397  data->resize_ignore_vals(1);
2398 
2399  if (rvtype == RVTstrn) { check_rslts(step, RTE_global_strain); data[0][0] = this->give_results_dm(step, RTE_global_strain)[0](0,0); }
2400  else if (rvtype == RVTstrs) { check_rslts(step, RTE_global_stress); data[0][0] = this->give_results_dm(step, RTE_global_stress)[0](0,0); }
2401  else errol;
2402  }
2403  else if (SST == SST_beam) {
2404  data->resize_ignore_vals(9);
2405 
2406  const Dmtrx *s=NULL;
2407 
2408  if (rvtype==RVTstrn) { check_rslts(step, RTE_global_strain); s = this->give_results_dm(step, RTE_global_strain); }
2409  else if (rvtype==RVTstrs) { check_rslts(step, RTE_global_stress); s = this->give_results_dm(step, RTE_global_stress); }
2410  else errol;
2411 
2412  if (rvtype==RVTstrn) for (int i=0; i<6; i++) data[0][i+3] = s[0](0,i+6) - s[0](0,i) ;
2413  else for (int i=0; i<6; i++) data[0][i+3] = ( s[0](0,i+6) + s[0](0,i) ) / 2.0;
2414 
2415  data[0][0] = data[0][3]; // N
2416  data[0][1] = sqrt( data[0][4] * data[0][4] + data[0][5] * data[0][5] ); // V
2417  data[0][2] = sqrt( data[0][7] * data[0][7] + data[0][8] * data[0][8] ); // M
2418  }
2419  else errol;
2420 
2421  // bf==BF_Beam
2422  if (node) _errorr("error");
2423  //bool first;
2424  //if (node == nodes[0]) first = true;
2425  //if (node == nodes[1]) first = false;
2426  //
2427  //switch (rvtype) {
2428  //case RVT_endDispl:
2429  // if (!strain) _errorr("no strain");
2430  // if (first) data->copy(this->give_results_dm(step, RTE_strain)->give_ptr2val() , 6);
2431  // else { data->copy(this->give_results_dm(step, RTE_strain)->give_ptr2val()+6, 6); data->tmsby(-1.0); }
2432  // break;
2433  //case RVT_endForce:
2434  // if (first) data->copy(this->give_results_dm(step, RTE_stress)->give_ptr2val() , 6);
2435  // else { data->copy(this->give_results_dm(step, RTE_stress)->give_ptr2val()+6, 6); data->tmsby(-1.0); }
2436  // break;
2437  }
2438  else if ( Msh()->give_rslts_solver() == SOL_SIFEL ) {
2439  //if (node && this->give_rslt_NIP(SOL_OOFEM) !=1) errol;
2440  if (node) errol;
2441 
2442  if (SST == SST_truss) {
2443  data->resize_ignore_vals(1);
2444 
2445  if (rvtype == RVTstrn) { check_rslts(step, RTE_global_strain); data[0][0] = this->give_results_dm(step, RTE_global_strain)[0](0,0); }
2446  else if (rvtype == RVTstrs) { check_rslts(step, RTE_global_stress); data[0][0] = this->give_results_dm(step, RTE_global_stress)[0](0,0); }
2447  else errol;
2448  }
2449  else errol;
2450  }
2451  else errol;
2452 
2453  return this->give_GeomWeight1deg();
2454 }
2455 
2457 //double Beam :: give_normal_force (long step) const
2458 //{
2459 // check_rslts(step);
2460 //
2461 // Dmtrx *s = this->give_results_dm(step, RTE_stress);
2462 //
2463 // if (bf == BF_Truss || bf == BF_LiBeam) {
2464 // return s[0](0,0);
2465 // }
2466 // else if (bf == BF_Beam) {
2467 // return ( s[0](0,6) - s[0](0,0) ) / 2.0;
2468 // }
2469 // else _errorr("unsupported type of beam element");
2470 //
2471 // return 0.0;
2472 //}
2473 double SigmaEq (VectoR &s, VectoR &t)
2474 {
2475  return 0.5 * sqrt ( 2.0 * ( (s.x-s.y)*(s.x-s.y) +
2476  (s.y-s.z)*(s.y-s.z) +
2477  (s.z-s.x)*(s.z-s.x) +
2478  6.0 * (t.x*t.x + t.y*t.y + t.z*t.z)));
2479 }
2480 
2483 {
2484  long step = 0;
2485  double answer = 0.0;
2486 
2488 
2489  if (this->elemAttribs()->give_sst() == SST_truss) {
2490  answer = this->give_results_dm(step, RTE_global_stress)[0](0,0);
2491  if (answer < 0) answer *= -1;
2492  }
2493  else if (this->elemAttribs()->give_sst() == SST_beam) {
2494  if (this->elemAttribs()->give_cs()->give_loctype_or_type() == CST_Rectangle) { // _or_type urizni
2495  double A, y, z, Iy, Iz;
2496  A = this->elemAttribs()->give_cs()->give_area();
2497  y = 0.5 * this->elemAttribs()->give_cs()->give_width();
2498  z = 0.5 * this->elemAttribs()->give_cs()->give_height();
2499  Iy= this->elemAttribs()->give_cs()->give_Iy();
2500  Iz= this->elemAttribs()->give_cs()->give_Iz();
2501 
2502  VectoR s, t;
2503  double N, Vy, Vz, Mx, My, Mz, val;
2504 
2505  // 2 points == start & end
2506  for (int i=0; i<2; i++) {
2507  N = fabs(this->give_results_dm(step, RTE_global_stress)[0](0,0+i*6) / A ); // ^ z //
2508  Vy = this->give_results_dm(step, RTE_global_stress)[0](0,1+i*6) / A * 1.5 ; // +--|--+ //
2509  Vz = this->give_results_dm(step, RTE_global_stress)[0](0,2+i*6) / A * 1.5 ; // | | | //
2510  Mx = this->give_results_dm(step, RTE_global_stress)[0](0,3+i*6) ; // 3 4-----> y //
2511  My = fabs(this->give_results_dm(step, RTE_global_stress)[0](0,4+i*6) / Iy * z ); // | | //
2512  Mz = fabs(this->give_results_dm(step, RTE_global_stress)[0](0,5+i*6) / Iz * y ); // 1--2--+ //
2513 
2514  // invariants
2515  s.y = s.z = 0.0;
2516  t.x = 0.0*Mx; // Mx docasne
2517 
2518  s.x = N + My + Mz; t.y = 0; t.z = 0; val = SigmaEq(s, t); if (answer < val) answer = val; // point 1
2519  s.x = N + My ; t.y = 0; t.z = Vy; val = SigmaEq(s, t); if (answer < val) answer = val; // point 2
2520  s.x = N + Mz; t.y = Vz; t.z = 0; val = SigmaEq(s, t); if (answer < val) answer = val; // point 3
2521  s.x = N ; t.y = Vz; t.z = Vy; val = SigmaEq(s, t); if (answer < val) answer = val; // point 4
2522  }
2523  }
2524  }
2525  else errol;
2526 
2527  maxSigmaEq[0] = answer;
2528 }
2529 
2531 void Beam :: print_row (FILE *stream, femFileFormat fff, bool endline, long did) const
2532 {
2533  FElement :: print_row (stream, fff, false);
2534 
2535  if (fff == FFF_OOFEM) {
2537  if (elemAttribs()->give_conDOFs()) {
2538  FiniteElementTypeSet fets;
2539  if (FETSet_set2e (this->elemAttribs()->give_FETS(&fets), SOL_OOFEM, Pd->give_analgroup()) != FET_OOFEM_Beam3d) _errorr ("OOFEM supports hinges at Beam3d elements only");
2540  if (points() != 2) errol;
2541 
2543 
2544  int i,j, n=0, ndofs=0;
2545  if ((*con)[0]) ndofs = (*con)[0]->give_ndofs();
2546  else if ((*con)[1]) ndofs = (*con)[1]->give_ndofs();
2547  else errol;
2548 
2549  for (i=0; i<2; i++) { if (!(*con)[i]) continue; for (j=0; j<ndofs; j++) if ((*con)[i]->give_att(j)) n++; }
2550  fprintf (stream, " dofsToCondense %d", n);
2551  for (i=0; i<2; i++) { if (!(*con)[i]) continue; for (j=0; j<ndofs; j++) if ((*con)[i]->give_att(j)) fprintf (stream, " %d", i*ndofs+j+1); }
2552  }
2553  }
2554  else
2555  if (elemAttribs()->give_conDOFs()) errol;
2556 
2557  if (endline) fprintf (stream,"\n");
2558 }
2559 
2560 
2561 
2562 //* ********************************************************************************************
2563 //* *** *** *** *** CLASS TRIANGLE *** *** *** ***
2564 //* ********************************************************************************************
2566 Triangle :: Triangle (const Quadrangle * src, bool firstr, bool firstdiag) :
2567  FElement (classComponentGeometry2Dtriangle, src->give_ID(), src->give_origID(), src->give_Geom(),1 ,3 ,3 ,1 , true, src->give_domain(), src->give_ID())
2568 {
2570  if (Msh()->connectivity_is_assembled()) errol;
2571 
2573  this->mproperty = *(src->give_mproperty_ptr());
2574  if (src->give_delete_flag()) errol;
2575 
2577  const GPA<const Point> *nds = src->give_points();
2578  if (firstr) {
2579  points.assign(0, (*nds)[0]);
2580  points.assign(1, (*nds)[1]);
2581  if (firstdiag) points.assign(2, (*nds)[2]);
2582  else points.assign(2, (*nds)[3]);
2583  }
2584  else {
2585  points.assign(0, (*nds)[2]);
2586  points.assign(1, (*nds)[3]);
2587  if (firstdiag) points.assign(2, (*nds)[0]);
2588  else points.assign(2, (*nds)[1]);
2589  }
2590 
2592  if (src->give_domain()) errol;
2594  delete attributes;
2595  attributes = new FElemAttribs(this, (const FElemAttribs*)src->give_elemAttribs(), 'd');
2596  //attributes->set_IPset();
2597  if (elemAttribs()->give_prop()) errol;
2598 
2599  // this
2600  rotMg2l = NULL;
2601 }
2602 
2605 {
2607 
2608  FiniteElementTypeSet fets;
2609  this->elemAttribs()->give_FETS(&fets);
2610 
2611  switch (Pd->give_analgroup()) {
2612  case PAG_mechanics:
2613  ; if (fets.dpn == DPN_Dxy_R___) { if (fets.sst != SST_plstrain && fets.sst != SST_plstress) errol; }
2614  else if (fets.dpn == DPN_Dxy_R__z) { if (fets.sst != SST_plstrain && fets.sst != SST_plstress) errol; }
2615  else if (fets.dpn == DPN_D__zRxy_) { if (fets.sst != SST_plate) errol; }
2616  else if (fets.dpn == DPN_DxyzRxyz) { if (fets.sst != SST_3dshell) errol; }
2617  else errol;
2618  break;
2619  case PAG_transport:
2620  if (fets.sst != SST_transp2d) errol;
2621  break;
2622  default: errol;
2623  }
2624 }
2625 
2628 {
2629  switch (Pd->give_DOFspnod()) {
2630  case DPN_Dxy_R___: return DPN_Dxy_R___; break;
2631  case DPN_Dxy_R__z: return DPN_Dxy_R__z; break;
2632  case DPN_D__zRxy_: return DPN_D__zRxy_; break;
2633  case DPN_DxyzRxyz: return DPN_DxyzRxyz; break;
2634  default: errol;
2635  }
2636  return DPN_Void;
2637 }
2640 {
2641  switch (this->elemAttribs()->give_dpn()) {
2642  case DPN_Dxy_R__z: return SST_plstress; break;
2643  case DPN_Dxy_R___: return SST_plstress; break;
2644  case DPN_D__zRxy_: return SST_plate; break;
2645  case DPN_DxyzRxyz: return SST_3dshell; break;
2646  default: errol;
2647  }
2648  return SST_Void;
2649 }
2650 
2651 // FiniteElementType Triangle :: give_fe (Solver sol) const
2652 // {
2653 // if (sol == SOL_OOFEM) {
2654 // switch (elemAttribs()->give_sst()) {
2655 // case SST_3d: return FET_ShellTr; break;
2656 // case SST_planestrain: return FET_PlaneStrainTr; break;
2657 // case SST_planestress: return FET_PlaneStressTr; break;
2658 // default: errol;
2659 // }
2660 // }
2661 // if (sol == SOL_SIFEL) return FET_PlaneTr;
2662 //
2663 // errol; return FET_Void;
2664 // } // "RerShell"; }
2665 
2666 
2668 long Triangle :: give_edge_nodes (const Point **&edgnodes) const
2669 {
2670  if (elemAttribs()->give_ord() != -4) _errorr2("ord is %d", elemAttribs()->give_ord());
2671  edgnodes = new const Point*[6];
2672 
2673  edgnodes[0] = points[0]; edgnodes[1] = points[1];
2674  edgnodes[2] = points[1]; edgnodes[3] = points[2];
2675  edgnodes[4] = points[2]; edgnodes[5] = points[0];
2676  return 2;
2677 }
2679 long Triangle :: give_face_nodes_edges (const Point **&facnodes, const Edge **&facedges) const
2680 {
2681  if (elemAttribs()->give_ord() != -4) errol; // musim vratit i pocet uzlu, to uz budu muset pres parametry
2682  facnodes = new const Point* [3];
2683  facedges = new const Edge* [3];
2684 
2685  facnodes[0] = points[0]; facnodes[ 1] = points[1]; facnodes[ 2] = points[2];
2686  facedges[0] = edges[0]; facedges[ 1] = edges[1]; facedges[ 2] = edges[2];
2687  return 3;
2688 }
2689 
2691 double Triangle :: give_quality (void) const
2692 {
2693  if (elemAttribs()->give_ord() != -4) return -1;
2694 
2695  // f = 4*root(3) = 6.9282032302755088
2696  // quality = f * area / (a*a + b*b + c*c);
2697  // return 6.9282032302755088 * this->give_lav() /
2698  // ( this->give_edge(0)->give_lav() * this->give_edge(0)->give_lav() +
2699  // this->give_edge(1)->give_lav() * this->give_edge(1)->give_lav() +
2700  // this->give_edge(2)->give_lav() * this->give_edge(2)->give_lav() ) ;
2701 
2702  double l1 = this->give_edge(0)->give_lav();
2703  double l2 = this->give_edge(1)->give_lav();
2704  double l3 = this->give_edge(2)->give_lav();
2705 
2706  return 6.9282032302755088 * this->give_lav() / ( l1*l1 + l2*l2 + l3*l3 );
2707 }
2708 
2716 {
2717  if (rotMg2l) return;
2718 
2719  VectoR x, y, z;
2720  //
2721  x.beP2P( points[0]->give_coords(), points[1]->give_coords() );
2722  x.normalize();
2723  //
2724  y.beP2P( points[0]->give_coords(), points[2]->give_coords() );
2725  z.beVectProduct( &x, &y );
2726  z.normalize();
2727  //
2728  y.beVectProduct( &z, &x );
2729  y.normalize();
2730 
2731  //
2732  rotMg2l = new Dmtrx(3,3);
2733  //
2734  rotMg2l->copy_row(0,&x);
2735  rotMg2l->copy_row(1,&y);
2736  rotMg2l->copy_row(2,&z);
2737 }
2738 
2741 {
2742  //this->compute_rotMg2l();
2743 
2744  //data->tnsrRotWith(*rotMg2l);
2745 
2746  double a = 0.5 * atan ( 2*data[0][5] / (data[0][1] - data[0][0]) );
2747 
2748  if (fabs(a) > 1.e-6)
2749  data->tnsrRotAxisZangle (a);
2750 
2751  if (data[0][0] < data[0][1])
2752  data->tnsrRotAxisZangle (1.570796327);
2753 }
2754 
2756 void Triangle :: give_ip_coords_global (IntPointSet ips, int i, PoinT &coords) const
2757 {
2758  PoinT l; // local coords
2759 
2760  IPS_give_ip_coord_native (i, ips, l);
2761 
2762  coords.x = l[0] * points[0]->give_coord(0) + l[1] * points[1]->give_coord(0) + l[2] * points[2]->give_coord(0);
2763  coords.y = l[0] * points[0]->give_coord(1) + l[1] * points[1]->give_coord(1) + l[2] * points[2]->give_coord(1);
2764  coords.z = l[0] * points[0]->give_coord(2) + l[1] * points[1]->give_coord(2) + l[2] * points[2]->give_coord(2);
2765 }
2766 
2768 void Triangle :: read_input (const char *&str, femFileFormat fff)
2769 {
2770  if (fff == FFF_SIFEL) {
2771  FiniteElementTypeSet fets;
2772  if (FETSet_set2e (this->elemAttribs()->give_FETS(&fets), SOL_SIFEL, Pd->give_analgroup()) == FET_SIFEL_planeelementlt) {
2773  int sst;
2774  SP_scan_number (str, sst);
2776  }
2777  }
2778 
2779  FElement :: read_input (str, fff);
2780 }
2781 
2783 void Triangle :: read_output_OOFEM (FILE *stream, long step)
2784 {
2785 //#ifdef DEBUG
2786  //if (! isZero(1e-10, vald[2]+vald[8]+vald[9]+vald[10])) _errorr ("Invalid structure of OOFEM output file");
2787 //#endif
2788  const char *str;
2789  char LINE[1023];
2790  int ipid;
2791  Dmtrx *strain = new Dmtrx;
2792  Dmtrx *stress = new Dmtrx;
2793 
2795  IntPointSet ips = this->give_IPset_rslts(SOL_OOFEM);
2796  int NIP = IntPointSet_give_number_ips (ips);
2797  int nl = this->elemAttribs()->give_cs()->give_nlayers();
2798 
2799  FiniteElementTypeSet fets;
2800  FiniteElementType feto = FETSet_set2e (this->elemAttribs()->give_FETS(&fets), SOL_OOFEM, Pd->give_analgroup());
2801  femFileFormat fff = FFF_OOFEM;
2802 
2803  switch (feto) {
2804  case FET_OOFEM_RerShell:
2805  case FET_OOFEM_Tr_Shell01: {
2806  bool rer = (feto == FET_OOFEM_RerShell) ? true : false;
2807 
2808  int ver = Pd->give_P_OOFEM_ver();
2809 
2810  //** specialni vypis ve lokalni verzi oofemu a v git verzi pro nip 1
2811  if (!rer && (ver == 20 || (ver >= 22 && NIP == 1))) {
2812  if (NIP != 1) errol; // ip nacitat ve spravnem poradi, az nip != 1 !!!
2813  int i;
2814 
2815  // verze je specialni v tom, ze tam jsou krome globalnich i lokalni hodnoty
2816  Dmtrx *strain_loc = new Dmtrx;
2817  Dmtrx *stress_loc = new Dmtrx;
2818 
2819  strain-> resize_ignore_vals(NIP, 12);
2820  stress-> resize_ignore_vals(NIP, 12);
2821  strain_loc->resize_ignore_vals(NIP, 12);
2822  stress_loc->resize_ignore_vals(NIP, 12);
2823 
2825  fgets (LINE, 1023, stream); str=LINE;
2826  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, true);
2827 
2828  OOFEM_output_scan_GP (stream, 1);
2829 
2831 
2833  FP_scan_expected_word_exit (stream, "generalized strains", "Invalid structure of OOFEM output file", CASE);
2834  if (!FP_scan_array (stream, 12, strain->give_ptr2val())) _errorr ("Invalid structure of OOFEM output file");
2835  for (i=6; i<12; i++)
2836  if (2 < i%6 && i%6 < 6) (*strain)(0,i) /= 2.0;
2837 
2839  FP_scan_expected_word_exit (stream, "local", "Invalid structure of OOFEM output file", CASE);
2840  if (!FP_scan_array (stream, 12, strain_loc->give_ptr2val())) _errorr ("Invalid structure of OOFEM output file");
2841  for (i=6; i<12; i++)
2842  if (2 < i%6 && i%6 < 6) (*strain_loc)(0,i) /= 2.0;
2843 
2844 # ifdef DEBUG
2845  // orotuje strain a porovna ho s strain_loc
2846  Dvctr vald(6);
2847  double l, auxd;
2848  this->compute_rotMg2l();
2849 
2850 // // D
2851 // vald.beCopyOf(strain->give_ptr2val(), 6);
2852 // vald.tnsrRotWith(*rotMg2l);
2853 // l = vald.give_lenght();
2854 // auxd = fabs(vald[2]);
2855 // if (l > 2e-8 && auxd > 1e-10 && !isZero(l*1e-8, auxd))
2856 // _errorr3 ("Invalid structure of OOFEM output file, l = %e, auxd = 0 = %e", l, auxd); // 1e-4 is equal to precision of oofem strain/stress output
2857 // vald[2] = 0.0;
2858 //
2859 // for (int i=0; i<6; i++)
2860 // if (vald[i] > 0.0 && fabs(vald[i] - (*strain_loc)(0,i)) > 2e-10 && ! isZero(l*1.e-8, fabs((*strain_loc)(0,i))*1e-4, vald[i] - (*strain_loc)(0,i)))
2861 // _errorr4 ("Invalid structure of OOFEM output file, l = %e, %e - %e ", l, (*strain_loc)(0,i), auxd); // 1e-4 is equal to precision of oofem strain/stress output
2862 //
2863 // // R
2864 // vald.beCopyOf(strain->give_ptr2val(0,6), 6);
2865 // vald.tnsrRotWith(*rotMg2l);
2866 // l = vald.give_lenght();
2867 // auxd = fabs(vald[2]) + fabs(vald[3]) + fabs(vald[4]);
2868 // if (l > 2e-8 && auxd > 1e-09 && !isZero(l*1e-8*3, auxd))
2869 // _errorr3 ("Invalid structure of OOFEM output file, l = %e, auxd = 0 = %e", l, auxd); // 1e-4 is equal to precision of oofem strain/stress output
2870 // vald[2] = vald[3] = vald[4] = 0.0;
2871 //
2872 // for (int i=0; i<6; i++)
2873 // if (vald[i] > 0.0 && fabs(vald[i] - (*strain_loc)(0,i+6)) > 2e-10 && ! isZero(l*1.e-8, fabs((*strain_loc)(0,i+6))*1e-4, vald[i] - (*strain_loc)(0,i+6)))
2874 // _errorr4 ("Invalid structure of OOFEM output file, l = %e, %e - %e ", l, (*strain_loc)(0,i+6), auxd); // 1e-4 is equal to precision of oofem strain/stress output
2875 # endif
2876 
2877  //* STRESS
2878 
2879  //* global
2880  FP_scan_expected_word_exit (stream, "generalized stresses", "Invalid structure of OOFEM output file", CASE);
2881  if (!FP_scan_array (stream, 12, stress->give_ptr2val())) _errorr ("Invalid structure of OOFEM output file");
2882 
2883  //* local
2884  FP_scan_expected_word_exit (stream, "local", "Invalid structure of OOFEM output file", CASE);
2885  if (!FP_scan_array (stream, 12, stress_loc->give_ptr2val())) _errorr ("Invalid structure of OOFEM output file");
2886 
2887 # ifdef DEBUG
2888  // orotuje strain a porovna ho s strain_loc
2889 
2890  // D
2891  vald.beCopyOf(stress->give_ptr2val(), 6);
2892  vald.tnsrRotWith(*rotMg2l);
2893  l = vald.give_lenght();
2894  auxd = fabs(vald[2]);
2895  if (l > 2e-8 && !isZero(l*1e-8, auxd)) // && auxd > 1e-10
2896  _errorr3 ("Invalid structure of OOFEM output file, l = %e, auxd = 0 = %e", l, auxd); // 1e-4 is equal to precision of oofem strain/stress output
2897  vald[2] = 0.0;
2898 
2899  for (int i=0; i<6; i++)
2900  if (vald[i] > 0.0 && fabs(vald[i] - (*stress_loc)(0,i)) > 2e-10 && ! isZero(l*1.e-8, fabs((*stress_loc)(0,i))*1e-4, vald[i] - (*stress_loc)(0,i)))
2901  _errorr4 ("Invalid structure of OOFEM output file, l = %e, %e - %e ", l, (*stress_loc)(0,i), auxd); // 1e-4 is equal to precision of oofem strain/stress output
2902 
2903  // R
2904  vald.beCopyOf(stress->give_ptr2val(0,6), 6);
2905  vald.tnsrRotWith(*rotMg2l);
2906  l = vald.give_lenght();
2907  auxd = fabs(vald[2]) + fabs(vald[3]) + fabs(vald[4]);
2908  if (l > 2e-8 && auxd > 1e-09 && !isZero(l*1e-8*3, auxd))
2909  _errorr3 ("Invalid structure of OOFEM output file, l = %e, auxd = 0 = %e", l, auxd); // 1e-4 is equal to precision of oofem strain/stress output
2910  vald[2] = vald[3] = vald[4] = 0.0;
2911 
2912  for (int i=0; i<6; i++)
2913  if (vald[i] > 0.0 && fabs(vald[i] - (*stress_loc)(0,i+6)) > 2e-10 && ! isZero(l*1.e-8, fabs((*stress_loc)(0,i+6))*1e-4, vald[i] - (*stress_loc)(0,i+6)))
2914  _errorr4 ("Invalid structure of OOFEM output file, l = %e, %e - %e ", l, (*stress_loc)(0,i+6), auxd); // 1e-4 is equal to precision of oofem strain/stress output
2915 # endif
2916 
2917  FP_skip_line(stream);
2918 
2919  this->add_result(strain_loc, step, RTE_localOO_strain);
2920  this->add_result(stress_loc, step, RTE_localOO_stress);
2921  }
2922  //** Strains and stresses in global coordinates.
2923  else {
2924  Dmtrx *lstrain;
2925  Dmtrx *lstress;
2926 
2927  if (nl) {
2928  lstrain = new Dmtrx; lstrain->resize_ignore_vals(nl, 6);
2929  lstress = new Dmtrx; lstress->resize_ignore_vals(nl, 6);
2930  }
2931 
2932  strain->resize_ignore_vals(NIP, 12);
2933  stress->resize_ignore_vals(NIP, 12);
2934 
2936  fgets (LINE, 1023, stream); str=LINE;
2937  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, !rer); // true);
2938 
2939  for (int i=0; i<NIP; i++) {
2940  ipid = ECN_convert_ips_triangle (false, i, fff, ips);
2941 
2942  //* STRAIN
2943  fgets (LINE, 1023, stream); str=LINE;
2944  OOFEM_output_scan_GP (str, i+1, rer);
2945  SP_scan_expected_word_exit (str, "strains", "Invalid structure of OOFEM output file", CASE);
2946  if (!SP_scan_array (str, 12, strain->give_ptr2val(ipid, 0))) _errorr ("Invalid structure of OOFEM output file");
2947 
2948  for (int j=0; j<12; j++) // ????
2949  if (2 < j%6 && j%6 < 6) (*strain)(ipid,j) /= 2.0;
2950 
2951  //* STRESS
2952  fgets (LINE, 1023, stream); str=LINE;
2953  SP_scan_expected_word_exit (str, "stresses", "Invalid structure of OOFEM output file", CASE);
2954  if (!SP_scan_array (str, 12, stress->give_ptr2val(ipid, 0))) _errorr ("Invalid structure of OOFEM output file");
2955 
2956  //* LAYERS
2957  if (nl) {
2958  FP_scan_expected_line_exit(stream, "Layers report", "Invalid structure of OOFEM output file", CASE);
2959  FP_scan_expected_line_exit(stream, "{", "Invalid structure of OOFEM output file", CASE);
2960  for (int j=0; j<nl; j++) {
2961  fgets (LINE, 1023, stream); str=LINE;
2962  OOFEM_output_scan_GP (str, j+1);
2963  SP_scan_expected_word_exit (str, "strains", "Invalid structure of OOFEM output file", CASE);
2964  if (!SP_scan_array (str, 6, lstrain->give_ptr2val(j, 0))) _errorr ("Invalid structure of OOFEM output file");
2965 
2966  fgets (LINE, 1023, stream); str=LINE;
2967  SP_scan_expected_word_exit (str, "stresses", "Invalid structure of OOFEM output file", CASE);
2968  if (!SP_scan_array (str, 6, lstress->give_ptr2val(j, 0))) _errorr ("Invalid structure of OOFEM output file");
2969  }
2970  FP_scan_expected_line_exit(stream, "} end layers report", "Invalid structure of OOFEM output file", CASE);
2971 
2972  this->add_result(lstrain, step, RTE_layered_strain);
2973  this->add_result(lstress, step, RTE_layered_stress);
2974  }
2975  }
2976  }
2977 
2978  break;
2979  }
2981  double vald[6];
2982  strain->resize_ignore_vals(NIP, 3);
2983  stress->resize_ignore_vals(NIP, 3);
2984 
2986  fgets (LINE, 1023, stream); str=LINE;
2987  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, true);
2988 
2989  for (int i=0; i<NIP; i++) {
2990  ipid = ECN_convert_ips_triangle (false, i, fff, ips);
2991 
2993  fgets (LINE, 1023, stream); str=LINE;
2994  OOFEM_output_scan_GP (str, i+1);
2995  SP_scan_expected_word_exit (str, "strains", "Invalid structure of OOFEM output file", CASE);
2996  if (!SP_scan_array (str, 6, vald)) _errorr ("Invalid structure of OOFEM output file");
2997 #ifdef DEBUG
2998  if (! isZero(1e-10, vald[2]+vald[3]+vald[4])) _errorr ("Invalid structure of OOFEM output file");
2999 #endif
3000  (*strain)(ipid,0) = vald[0];
3001  (*strain)(ipid,1) = vald[1];
3002  (*strain)(ipid,2) = vald[5] / 2.0;
3003 
3005  fgets (LINE, 1023, stream); str=LINE;
3006  SP_scan_expected_word_exit (str, "stresses", "Invalid structure of OOFEM output file", CASE);
3007  if (!SP_scan_array (str, 6, vald)) _errorr ("Invalid structure of OOFEM output file");
3008 #ifdef DEBUG
3009  if (! isZero(1e-10, vald[2]+vald[3]+vald[4])) _errorr ("Invalid structure of OOFEM output file");
3010 #endif
3011  (*stress)(ipid,0) = vald[0];
3012  (*stress)(ipid,1) = vald[1];
3013  (*stress)(ipid,2) = vald[5];
3014  }
3015 
3017  if (elemAttribs()->give_mat()->isOOFEMplast()) {
3018  if (! FP_skip_expected_string (stream, "status { ", true)) _errorr("Invalid structure of OOFEM output file");
3019  if (FP_skip_expected_string (stream, " Yielding, plastic strains", true)) {
3020  if (!this->give_results(step, RTE_plaststrain)) {
3021  this->add_result(new Dmtrx(NIP, 5), step, RTE_plaststrain);
3022  ((Dmtrx*)this->give_results_dm(step, RTE_plaststrain))->zero();
3023  }
3024  for (int j=0; j<4; j++) fscanf (stream, "%lf", &(((Dmtrx*)this->give_results_dm(step, RTE_plaststrain))[0](0,j)) );
3025  //if (! FP_skip_expected_string (stream, ", strain space hardening vars", true)) _errorr3("Invalid structure of OOFEM output file, step %ld, element %ld", step+1, id+1);
3026  //fscanf (stream, "%lf", &((*plastthis->give_results_dm(step, RTE_strain))(i,4)) );
3027  }
3028  FP_skip_line (stream);
3029  }
3030  break;
3031  }
3033  // pro tento prvek se pouziva asi redukovana integrace, tj. je tam jedna sada navic
3034  // proto tady natvrdo kontroluju konkretni sadu nip
3035  if (NIP != 4) errol;
3036 
3037  double vald[6];
3038  strain->resize_ignore_vals(NIP, 3);
3039  stress->resize_ignore_vals(NIP, 3);
3040 
3042  fgets (LINE, 1023, stream); str=LINE;
3043  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, true);
3044 
3045  for (int i=0; i<NIP; i++) {
3046  ipid = ECN_convert_ips_triangle (false, i, fff, ips);
3047 
3049  fgets (LINE, 1023, stream); str=LINE;
3050  OOFEM_output_scan_GP (str, i+1);
3051  SP_scan_expected_word_exit (str, "strains", "Invalid structure of OOFEM output file", CASE);
3052  if (!SP_scan_array (str, 6, vald)) _errorr ("Invalid structure of OOFEM output file");
3053 #ifdef DEBUG
3054  if (! isZero(1e-10, vald[2]+vald[3]+vald[4])) _errorr ("Invalid structure of OOFEM output file");
3055 #endif
3056  (*strain)(ipid,0) = vald[0];
3057  (*strain)(ipid,1) = vald[1];
3058  (*strain)(ipid,2) = vald[5] / 2.0;
3059 
3061  fgets (LINE, 1023, stream); str=LINE;
3062  SP_scan_expected_word_exit (str, "stresses", "Invalid structure of OOFEM output file", CASE);
3063  if (!SP_scan_array (str, 6, vald)) _errorr ("Invalid structure of OOFEM output file");
3064 #ifdef DEBUG
3065  if (! isZero(1e-10, vald[2]+vald[3]+vald[4])) _errorr ("Invalid structure of OOFEM output file");
3066 #endif
3067  (*stress)(ipid,0) = vald[0];
3068  (*stress)(ipid,1) = vald[1];
3069  (*stress)(ipid,2) = vald[5];
3070  }
3071 
3072  // preskakuje ip redukovany
3073  FP_skip_line (stream, 2);
3074 
3076  if (elemAttribs()->give_mat()->isOOFEMplast()) errol;
3077  break;
3078  }
3079  default: _errorr("unsupported type of triangle element");
3080  }
3081 
3082  this->add_result(strain, step, RTE_global_strain);
3083  this->add_result(stress, step, RTE_global_stress);
3084 }
3086 void Triangle :: read_output_SIFEL (FILE *stream, long step, ResultTypesAtElem rt)
3087 {
3088  const char *str;
3089  char LINE[1023], msg[60];
3090 
3091  sprintf (msg, "Invalid structure of SIFEL output file, element %ld", origid+1);
3092 
3094  IntPointSet ips = this->give_IPset_rslts(SOL_SIFEL);
3095  int NIP = IntPointSet_give_number_ips (ips);
3096  if (NIP != 1) errol; // toto je zde natvrdo, u tr v transportu je jeden IP, // ip nacitat ve spravnem poradi, az nip != 1 !!!
3097  int NIPa = 4; // ale tisknou se 4, protoze datel a nebo kaser a labus
3098 
3100  fgets (LINE, 1023, stream); str=LINE;
3101  SP_scan_expected_word_exit (str, "Element", msg, CASE);
3102  SP_scan_expected_number_exit (str, origid+1, msg);
3103  SP_scan_expected_word_exit (str, ", integration points", msg, CASE);
3104  long ip1, ip2;
3105  SP_scan_number (str, ip1);
3106  SP_scan_expected_word_exit (str, "-", msg, CASE);
3107  SP_scan_number (str, ip2);
3108  if (ip2-ip1+1 != NIPa) _errorr(msg);
3109 
3111  if (Pd->give_analgroup() == PAG_transport) {
3112  int dim, nmed, j, k;
3113  dim = this->give_dimension();
3114  nmed = Pd->give_global_nDOFs();
3115 
3116  Dmtrx *values = new Dmtrx(NIP, dim*nmed);
3117 
3118  // loop over NIP
3119  fgets (LINE, 1023, stream); str=LINE;
3120 
3121  char r[15];
3122  for (j=0; j<nmed; j++)
3123  for (k=0; k<dim; k++) {
3124  if (rt == RTE_gradient) sprintf(r, "grad_%d_%d=", j+1, k+1);
3125  else if (rt == RTE_fluxes) sprintf(r, "flux_%d_%d=", j+1, k+1);
3126  else errol;
3127  SP_scan_expected_word_exit (str, r, msg, CASE);
3128  SP_scan_number (str, (*values)(0,j*dim+k));
3129  }
3130 
3131  FP_skip_line (stream, NIPa-NIP);
3132 
3133  this->add_result (values, step, rt);
3134  }
3135  else errol;
3136 }
3137 
3139 double Triangle :: give_ssstate (Dvctr *data, SStype SST, RVType rvtype, char type, long step, const Node *node)
3140 {
3141  if (this->elemAttribs()->give_sst() != SST) return this->fillupbyzero (data, SST);
3142 
3143  if ( Msh()->give_rslts_solver() == SOL_OOFEM ) {
3144  if (node && this->give_rslt_NIP(SOL_OOFEM) !=1) errol;
3145 
3146  if (SST == SST_3dshell) {
3147  switch (rvtype) {
3148  case RVTstrn_displ: check_rslts(step, RTE_global_strain); data->beCopyOf(this->give_results_dm(step, RTE_global_strain) ->give_ptr2val() , 6); break;
3149  case RVTstrn_rotat: check_rslts(step, RTE_global_strain); data->beCopyOf(this->give_results_dm(step, RTE_global_strain) ->give_ptr2val()+6, 6); break;
3150  case RVTstrs_displ: check_rslts(step, RTE_global_stress); data->beCopyOf(this->give_results_dm(step, RTE_global_stress) ->give_ptr2val() , 6); break;
3151  case RVTstrs_rotat: check_rslts(step, RTE_global_stress); data->beCopyOf(this->give_results_dm(step, RTE_global_stress) ->give_ptr2val()+6, 6); break;
3152  case RVTstrn_displ_local_main: check_rslts(step, RTE_localOO_strain); data->beCopyOf(this->give_results_dm(step, RTE_localOO_strain)->give_ptr2val() , 6); this->rotate2local(data); break;
3153  case RVTstrn_rotat_local_main: check_rslts(step, RTE_localOO_strain); data->beCopyOf(this->give_results_dm(step, RTE_localOO_strain)->give_ptr2val()+6, 6); this->rotate2local(data); break;
3154  case RVTstrs_displ_local_main: check_rslts(step, RTE_localOO_stress); data->beCopyOf(this->give_results_dm(step, RTE_localOO_stress)->give_ptr2val() , 6); this->rotate2local(data); break;
3155  case RVTstrs_rotat_local_main: check_rslts(step, RTE_localOO_stress); data->beCopyOf(this->give_results_dm(step, RTE_localOO_stress)->give_ptr2val()+6, 6); this->rotate2local(data); break;
3156  default: errol;
3157  }
3158  //
3159  }
3160  else if (SST == SST_plstrain || SST == SST_plstress) {
3161  if (rvtype == RVTstrn_displ) { check_rslts(step, RTE_global_strain); data->beCopyOf(this->give_results_dm(step, RTE_global_strain)->give_ptr2val(), 3); }
3162  else if (rvtype == RVTstrs_displ) { check_rslts(step, RTE_global_stress); data->beCopyOf(this->give_results_dm(step, RTE_global_stress)->give_ptr2val(), 3); }
3163  else errol;
3164  }
3165  else errol;
3166  }
3167  else if ( Msh()->give_rslts_solver() == SOL_SIFEL ) {
3168  errol;
3169  // if (node && this->give_rslt_NIP(SOL_OOFEM) !=1) errol;
3170  // if (rvtype != RVTstrs_grad) errol;
3171  //
3172  // if (SST == SST_transp2d) {
3173  // int nmed = Pd->give_global_nDOFs(); if (nmed != 1 && nmed != 2) errol;
3174  // data->resize_ignore_vals(3*nmed); data->zero();
3175  // if (nmed>0) { (*data)[0] = this->give_results_dm(step, RTE_gradient)->give_ptr2val()[0];
3176  // (*data)[1] = this->give_results_dm(step, RTE_gradient)->give_ptr2val()[1]; }
3177  // if (nmed>1) { (*data)[3] = this->give_results_dm(step, RTE_gradient)->give_ptr2val()[2];
3178  // (*data)[4] = this->give_results_dm(step, RTE_gradient)->give_ptr2val()[3]; }
3179  // }
3180  // else errol;
3181  //
3182  }
3183  else errol;
3184 
3185  return this->give_GeomWeight1deg();
3186 }
3187 
3190 {
3191  long step = 0;
3192  double answer = 0.0;
3193 
3194  if (this->elemAttribs()->give_sst() == SST_3dshell) {
3195  switch (this->elemAttribs()->give_cs()->give_loctype_or_type()) {
3196  case CST_2d: {
3198 
3199  double h;
3200  h = this->elemAttribs()->give_cs()->give_thickness();
3201 
3202  VectoR s, t;
3203  double nx, ny, vyz, vxz, vxy, mx, my, mxy, val;
3204 
3205  nx = this->give_results_dm(step, RTE_localOO_stress)[0](0, 0) / h;
3206  ny = this->give_results_dm(step, RTE_localOO_stress)[0](0, 1) / h;
3207 
3208  vyz = this->give_results_dm(step, RTE_localOO_stress)[0](0, 3) * 1.5 / h;
3209  vxz = this->give_results_dm(step, RTE_localOO_stress)[0](0, 4) * 1.5 / h;
3210 
3211  vxy = this->give_results_dm(step, RTE_localOO_stress)[0](0, 5) / h;
3212 
3213  mx = this->give_results_dm(step, RTE_localOO_stress)[0](0, 6) * 6.0 / h / h;
3214  my = this->give_results_dm(step, RTE_localOO_stress)[0](0, 7) * 6.0 / h / h;
3215  mxy = this->give_results_dm(step, RTE_localOO_stress)[0](0,11) * 6.0 / h / h;
3216 
3218  s.x = nx + mx; t.x = 0;
3219  s.y = ny + my; t.y = 0;
3220  s.z = 0; t.z = vxy + mxy;
3221 
3222  val = SigmaEq(s, t);
3223  if (answer < val) answer = val;
3224 
3226  s.x = nx - mx; t.x = 0;
3227  s.y = ny - my; t.y = 0;
3228  s.z = 0; t.z = vxy - mxy;
3229 
3230  val = SigmaEq(s, t);
3231  if (answer < val) answer = val;
3232 
3234  s.x = nx; t.x = vyz;
3235  s.y = ny; t.y = vxz;
3236  s.z = 0; t.z = vxy;
3237 
3238  val = SigmaEq(s, t);
3239  if (answer < val) answer = val;
3240 
3241  maxSigmaEq[0] = answer;
3242  break;
3243  }
3244  case CST_LayeredCS: {
3246  VectoR s, t;
3247  Dmtrx strs = this->give_results_dm(step, RTE_layered_stress);
3248  int nl = this->elemAttribs()->give_cs()->give_nlayers();
3249 
3250  for (int i=0; i<nl; i++) {
3251  s.x = strs(i,0);
3252  s.y = strs(i,1);
3253  s.z = strs(i,2);
3254  t.x = strs(i,3);
3255  t.y = strs(i,4);
3256  t.z = strs(i,5);
3257 
3258  maxSigmaEq[i] = SigmaEq(s, t);
3259  }
3260  break;
3261  }
3262  default: errol;
3263  }
3264  }
3265  else if (this->elemAttribs()->give_sst() == SST_plstress) {
3266  maxSigmaEq[0] = 0.0;
3267  }
3268  else errol;
3269 }
3270 
3271 
3272 
3273 //* ********************************************************************************************
3274 //* *** *** *** *** CLASS QUADRANGLE *** *** *** ***
3275 //* ********************************************************************************************
3278 {
3280 
3281  FiniteElementTypeSet fets;
3282  this->elemAttribs()->give_FETS(&fets);
3283 
3284  switch (Pd->give_analgroup()) {
3285  case PAG_mechanics:
3286  ; if (fets.dpn == DPN_Dxy_R___) { if (fets.sst != SST_plstrain && fets.sst != SST_plstress) errol; }
3287  else if (fets.dpn == DPN_D__zRxy_) { if (fets.sst != SST_plate) errol; }
3288  else if (fets.dpn == DPN_DxyzRxyz) { if (fets.sst != SST_3dshell) errol; }
3289  else errol; break;
3290  case PAG_transport:
3291  if (fets.sst != SST_transp2d) errol; break;
3292  default: errol;
3293  }
3294 }
3295 
3298 {
3299  switch (Pd->give_DOFspnod()) {
3300  case DPN_Dxy_R___: return DPN_Dxy_R___; break;
3301  case DPN_D__zRxy_: return DPN_D__zRxy_; break;
3302  case DPN_DxyzRxyz: return DPN_DxyzRxyz; break;
3303  default: errol;
3304  }
3305  return DPN_Void;
3306 }
3309 {
3310  switch (this->elemAttribs()->give_dpn()) {
3311  case DPN_Dxy_R___: return SST_plstress; break;
3312  case DPN_D__zRxy_: return SST_plate; break;
3313  case DPN_DxyzRxyz: return SST_3dshell; break;
3314  default: errol;
3315  }
3316  return SST_Void;
3317 }
3318 
3319 
3320 
3321 
3322 // FiniteElementType Quadrangle :: give_fe (Solver sol) const
3323 // {
3324 // if (sol == SOL_OOFEM) {
3325 // if (elemAttribs()->give_sst() == SST_planestrain) return FET_PlaneStrainQuad;
3326 // if (elemAttribs()->give_sst() == SST_planestress) return FET_PlaneStressQuad;
3327 // }
3328 // if (sol == SOL_SIFEL) return FET_PlaneQuad;
3329 //
3330 // errol; return FET_Void;
3331 // }
3332 
3333 
3335 long Quadrangle :: give_edge_nodes (const Point **&edgnodes) const
3336 {
3337  if (elemAttribs()->give_ord() != -4) errol;
3338  edgnodes = new const Point*[8];
3339 
3340  edgnodes[0] = points[0]; edgnodes[1] = points[1];
3341  edgnodes[2] = points[1]; edgnodes[3] = points[2];
3342  edgnodes[4] = points[2]; edgnodes[5] = points[3];
3343  edgnodes[6] = points[3]; edgnodes[7] = points[0];
3344  return 2;
3345 }
3347 long Quadrangle :: give_face_nodes_edges (const Point **&facnodes, const Edge **&facedges) const
3348 {
3349  if (elemAttribs()->give_ord() != -4) errol; // musim vratit i pocet uzlu, to uz budu muset pres parametry
3350  facnodes = new const Point* [4];
3351  facedges = new const Edge* [4];
3352 
3353  facnodes[0] = points[0]; facnodes[1] = points[1]; facnodes[2] = points[2]; facnodes[3] = points[3];
3354  facedges[0] = edges[0]; facedges[1] = edges[1]; facedges[2] = edges[2]; facedges[3] = edges[3];
3355  return 4;
3356 }
3357 
3360 {
3361  double d1 = points[0]->give_coords()->dist2_to(points[2]->give_coords());
3362  double d2 = points[1]->give_coords()->dist2_to(points[3]->give_coords());
3363  if (d1 < d2) return true;
3364  return false;
3365 }
3366 
3368 void Quadrangle :: read_input (const char *&str, femFileFormat fff)
3369 {
3370  if (fff == FFF_SIFEL) {
3371  FiniteElementTypeSet fets;
3372  if (FETSet_set2e (this->elemAttribs()->give_FETS(&fets), SOL_SIFEL, Pd->give_analgroup()) == FET_SIFEL_planeelementlq) {
3373  int sst;
3374  SP_scan_number (str, sst);
3376  }
3377  }
3378 
3379  FElement :: read_input (str, fff);
3380 }
3381 
3383 void Quadrangle :: read_output_OOFEM (FILE *stream, long step)
3384 {
3385  const char *str;
3386  char LINE[1023];
3387  Dmtrx *strain = new Dmtrx;
3388  Dmtrx *stress = new Dmtrx;
3389 
3391  IntPointSet ips = this->give_IPset_rslts(SOL_OOFEM);
3392  int NIP = IntPointSet_give_number_ips (ips);
3393  if (NIP != 4) errol;
3394 
3395  FiniteElementTypeSet fets;
3396  this->elemAttribs()->give_FETS(&fets);
3398 
3399  switch (feto) {
3402  int i, j, ipid;
3403  double vald[6];
3404  strain->resize_ignore_vals(NIP, 3);
3405  stress->resize_ignore_vals(NIP, 3);
3406 
3408  fgets (LINE, 1023, stream); str=LINE;
3409  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, false);
3410 
3412  for (i=0; i<NIP; i++) {
3413  ipid = ECN_convert_ips_quadrangle (false, i, FFF_OOFEM, ips); // id of ip; mapping oofem ipid to midas ipid
3414 
3416  fgets (LINE, 1023, stream); str=LINE;
3417  OOFEM_output_scan_GP (str, i+1);
3418  SP_scan_expected_word_exit (str, "strains", "Invalid structure of OOFEM output file", CASE);
3419  if (!SP_scan_array (str, 6, vald)) _errorr ("Invalid structure of OOFEM output file");
3420 #ifdef DEBUG
3421  if (! isZero(1e-10, vald[2]+vald[3]+vald[4])) _errorr ("Invalid structure of OOFEM output file");
3422 #endif
3423  (*strain)(ipid,0) = vald[0];
3424  (*strain)(ipid,1) = vald[1];
3425  (*strain)(ipid,2) = vald[5] / 2.0;
3426 
3428  fgets (LINE, 1023, stream); str=LINE;
3429  SP_scan_expected_word_exit (str, "stresses", "Invalid structure of OOFEM output file", CASE);
3430  if (!SP_scan_array (str, 6, vald)) _errorr ("Invalid structure of OOFEM output file");
3431 #ifdef DEBUG
3432  if (fets.sst == SST_plstrain) vald[2] = 0.0;
3433  if (! isZero(1e-10, vald[2]+vald[3]+vald[4])) _errorr ("Invalid structure of OOFEM output file");
3434 #endif
3435  if (1) {
3436  (*stress)(ipid,0) = vald[0];
3437  (*stress)(ipid,1) = vald[1];
3438  (*stress)(ipid,2) = vald[5];
3439  }
3440  else {
3441  (*stress)(ipid,0) = vald[0] * elemAttribs()->give_cs()->give_thickness();
3442  (*stress)(ipid,1) = vald[1] * elemAttribs()->give_cs()->give_thickness();
3443  (*stress)(ipid,2) = vald[5] * elemAttribs()->give_cs()->give_thickness();
3444  }
3445 
3447  if (elemAttribs()->give_mat()->isOOFEMplast()) {
3448  if (! FP_skip_expected_string (stream, "status { ", true)) _errorr("Invalid structure of OOFEM output file");
3449  if (FP_skip_expected_string (stream, " Yielding, plastic strains", true)) {
3450  if (!this->give_results(step, RTE_plaststrain)) {
3451  this->add_result(new Dmtrx(NIP, 5), step, RTE_plaststrain);
3452  ((Dmtrx*)this->give_results_dm(step, RTE_plaststrain))->zero();
3453  }
3454  for (j=0; j<4; j++) fscanf (stream, "%lf", &(((Dmtrx*)this->give_results_dm(step, RTE_plaststrain))[0](ipid,j)) );
3456  // if (! FP_skip_expected_string (stream, ", strain space hardening vars", true)) _errorr3("Invalid structure of OOFEM output file, step %ld, element %ld", step+1, ID+1);
3457  // ; fscanf (stream, "%lf", &(((Dmtrx*)this->give_results_dm(step, RTE_plaststrain))[0](ipid,4)) );
3458  }
3459  FP_skip_line (stream);
3460  }
3461  }
3462  break;
3463  }
3464  default: _errorr("unsupported type of brick element");
3465  }
3466 
3467  this->add_result(strain, step, RTE_global_strain);
3468  this->add_result(stress, step, RTE_global_stress);
3469 }
3470 
3472 double Quadrangle :: give_ssstate (Dvctr *data, SStype SST, RVType rvtype, char type, long step, const Node *node)
3473 {
3474  if (this->elemAttribs()->give_sst() != SST) return this->fillupbyzero (data, SST);
3475 
3476  if ( Msh()->give_rslts_solver() == SOL_OOFEM ) {
3477  if (node && this->give_rslt_NIP(SOL_OOFEM) !=1) errol;
3478 
3479  if (SST == SST_plstrain || SST == SST_plstress) {
3480  if (rvtype == RVTstrn_displ) { check_rslts(step, RTE_global_strain); data->be_mean_of(this->give_results_dm(step, RTE_global_strain)); }
3481  else if (rvtype == RVTstrs_displ) { check_rslts(step, RTE_global_stress); data->be_mean_of(this->give_results_dm(step, RTE_global_stress)); }
3482  else errol;
3483  }
3484  else errol;
3485  }
3486  else errol;
3487 
3489  if (type != 'g') errol;
3490  //this->rotate2local(data);
3491 
3492  return this->give_GeomWeight1deg();
3493 }
3494 
3497 {
3498  PoinT ncoords; // local coords
3499 
3500  IPS_give_ip_coord_native (i, ips, ncoords);
3501 
3502  double l[4];
3503 
3504  l[0] = 0.25 * (1 + ncoords[0]) * (1 + ncoords[1]);
3505  l[1] = 0.25 * (1 - ncoords[0]) * (1 + ncoords[1]);
3506  l[2] = 0.25 * (1 - ncoords[0]) * (1 - ncoords[1]);
3507  l[3] = 0.25 * (1 + ncoords[0]) * (1 - ncoords[1]);
3508 
3509  coords.x = l[0] * points[0]->give_coord(0) + l[1] * points[1]->give_coord(0) + l[2] * points[2]->give_coord(0) + l[3] * points[3]->give_coord(0);
3510  coords.y = l[0] * points[0]->give_coord(1) + l[1] * points[1]->give_coord(1) + l[2] * points[2]->give_coord(1) + l[3] * points[3]->give_coord(1);
3511  coords.z = 0.0;
3512 }
3513 
3514 
3515 //* ********************************************************************************************
3516 //* *** *** *** *** CLASS TETRA *** *** *** ***
3517 //* ********************************************************************************************
3519 void Tetra :: checkConsistency (void) const
3520 {
3522 
3523  DOFsPerNode dpn = this->elemAttribs()->give_dpn();
3524 
3525  if (dpn != DPN_DxyzR___) errol;
3526 }
3527 
3530 {
3531  switch (Pd->give_DOFspnod()) {
3532  case DPN_DxyzR___: return DPN_DxyzR___; break;
3533  default: errol;
3534  }
3535  return DPN_Void;
3536 }
3539 {
3540  switch (this->elemAttribs()->give_dpn()) {
3541  case DPN_DxyzR___: return SST_3d; break;
3542  default: errol;
3543  }
3544  return SST_Void;
3545 }
3546 
3547 
3548 // ///
3549 // FiniteElementType Tetra :: give_fe (Solver sol) const
3550 // {
3551 // if (elemAttribs()->give_ord() != -4 || elemAttribs()->give_rot()) errol;
3552 // if (elemAttribs()->give_sst() == SST_3d) return FET_TetraHedra;
3553 // else errol; return FET_Void;
3554 // }
3555 
3557 void Tetra :: print_row_VTX (char *str) const
3558 {
3559  sprintf (str, " %ld %ld %ld %ld",
3560  ((Node*)points[0])->give_lid_id(0),
3561  ((Node*)points[1])->give_lid_id(0),
3562  ((Node*)points[2])->give_lid_id(0),
3563  ((Node*)points[3])->give_lid_id(0));
3564 }
3565 
3567 long Tetra :: give_edge_nodes (const Point **&edgnodes) const
3568 {
3569  if (elemAttribs()->give_ord() != -4) errol;
3570  edgnodes = new const Point*[12];
3571 
3572  edgnodes[ 0] = points[0]; edgnodes[ 1] = points[1];
3573  edgnodes[ 2] = points[1]; edgnodes[ 3] = points[2];
3574  edgnodes[ 4] = points[2]; edgnodes[ 5] = points[0];
3575 
3576  edgnodes[ 6] = points[0]; edgnodes[ 7] = points[3];
3577  edgnodes[ 8] = points[1]; edgnodes[ 9] = points[3];
3578  edgnodes[10] = points[2]; edgnodes[11] = points[3];
3579 
3580  return 2;
3581 }
3583 long Tetra :: give_face_nodes_edges (const Point **&facnodes, const Edge **&facedges) const
3584 {
3585  if (elemAttribs()->give_ord() != -4) errol; // musim vratit i pocet uzlu, to uz budu muset pres parametry
3586  facnodes = new const Point* [12];
3587  facedges = new const Edge* [12];
3588 
3589  facnodes[ 0] = points[0]; facnodes[ 1] = points[1]; facnodes[ 2] = points[2];
3590  facnodes[ 3] = points[0]; facnodes[ 4] = points[1]; facnodes[ 5] = points[3];
3591  facnodes[ 6] = points[1]; facnodes[ 7] = points[2]; facnodes[ 8] = points[3];
3592  facnodes[ 9] = points[2]; facnodes[10] = points[0]; facnodes[11] = points[3];
3593 
3594  facedges[ 0] = edges[0]; facedges[ 1] = edges[1]; facedges[ 2] = edges[2];
3595  facedges[ 3] = edges[0]; facedges[ 4] = edges[4]; facedges[ 5] = edges[3];
3596  facedges[ 6] = edges[1]; facedges[ 7] = edges[5]; facedges[ 8] = edges[4];
3597  facedges[ 9] = edges[2]; facedges[10] = edges[3]; facedges[11] = edges[5];
3598 
3599  return 3;
3600 }
3601 
3602 
3603 //* ********************************************************************************************
3604 //* *** *** *** *** CLASS BRICK *** *** *** ***
3605 //* ********************************************************************************************
3607 void Brick :: checkConsistency (void) const
3608 {
3610 
3611  if (Pd->give_fulldata()) {
3612  DOFsPerNode dpn = this->elemAttribs()->give_dpn();
3613 
3614  if (dpn != DPN_DxyzR___) errol;
3615  }
3616 }
3617 
3620 {
3621  switch (Pd->give_DOFspnod()) {
3622  case DPN_DxyzR___: return DPN_DxyzR___; break;
3623  default: errol;
3624  }
3625  return DPN_Void;
3626 }
3629 {
3630  switch (this->elemAttribs()->give_dpn()) {
3631  case DPN_DxyzR___: return SST_3d; break;
3632  default: errol;
3633  }
3634  return SST_Void;
3635 }
3636 
3637 
3638 // ///
3639 // FiniteElementType Brick :: give_fe (Solver sol) const
3640 // {
3641 // if (elemAttribs()->give_ord() != -4 || elemAttribs()->give_rot()) errol;
3642 // if (elemAttribs()->give_sst() == SST_3d) return FET_HexaHedra;
3643 // else errol; return FET_Void; //return FET_QSpace; //return FET_LSpaceRot;
3644 // }
3645 
3647 long Brick :: give_edge_nodes (const Point **&edgnodes) const
3648 {
3649  if (elemAttribs()->give_ord() != -4) errol;
3650  edgnodes = new const Point*[24];
3651 
3652  edgnodes[ 0] = points[0]; edgnodes[ 1] = points[1];
3653  edgnodes[ 2] = points[1]; edgnodes[ 3] = points[2];
3654  edgnodes[ 4] = points[2]; edgnodes[ 5] = points[3];
3655  edgnodes[ 6] = points[3]; edgnodes[ 7] = points[0];
3656 
3657  edgnodes[ 8] = points[4]; edgnodes[ 9] = points[5];
3658  edgnodes[10] = points[5]; edgnodes[11] = points[6];
3659  edgnodes[12] = points[6]; edgnodes[13] = points[7];
3660  edgnodes[14] = points[7]; edgnodes[15] = points[4];
3661 
3662  edgnodes[16] = points[0]; edgnodes[17] = points[4];
3663  edgnodes[18] = points[1]; edgnodes[19] = points[5];
3664  edgnodes[20] = points[2]; edgnodes[21] = points[6];
3665  edgnodes[22] = points[3]; edgnodes[23] = points[7];
3666  return 2;
3667 }
3669 long Brick :: give_face_nodes_edges (const Point **&facnodes, const Edge **&facedges) const
3670 {
3671  if (elemAttribs()->give_ord() != -4) errol; // musim vratit i pocet uzlu, to uz budu muset pres parametry
3672  facnodes = new const Point* [24];
3673  facedges = new const Edge* [24];
3674 
3675  facnodes[ 0] = points[0]; facnodes[ 1] = points[1]; facnodes[ 2] = points[2]; facnodes[ 3] = points[3];
3676  facnodes[ 4] = points[4]; facnodes[ 5] = points[5]; facnodes[ 6] = points[6]; facnodes[ 7] = points[7];
3677  facnodes[ 8] = points[0]; facnodes[ 9] = points[1]; facnodes[10] = points[5]; facnodes[11] = points[4];
3678  facnodes[12] = points[1]; facnodes[13] = points[2]; facnodes[14] = points[6]; facnodes[15] = points[5];
3679  facnodes[16] = points[2]; facnodes[17] = points[3]; facnodes[18] = points[7]; facnodes[19] = points[6];
3680  facnodes[20] = points[3]; facnodes[21] = points[0]; facnodes[22] = points[4]; facnodes[23] = points[7];
3681 
3682  facedges[ 0] = edges[0]; facedges[ 1] = edges[ 1]; facedges[ 2] = edges[2]; facedges[ 3] = edges[ 3];
3683  facedges[ 4] = edges[4]; facedges[ 5] = edges[ 5]; facedges[ 6] = edges[6]; facedges[ 7] = edges[ 7];
3684  facedges[ 8] = edges[0]; facedges[ 9] = edges[ 9]; facedges[10] = edges[4]; facedges[11] = edges[ 8];
3685  facedges[12] = edges[1]; facedges[13] = edges[10]; facedges[14] = edges[5]; facedges[15] = edges[ 9];
3686  facedges[16] = edges[2]; facedges[17] = edges[11]; facedges[18] = edges[6]; facedges[19] = edges[10];
3687  facedges[20] = edges[3]; facedges[21] = edges[ 8]; facedges[22] = edges[7]; facedges[23] = edges[11];
3688  return 4;
3689 }
3690 
3692 void Brick :: read_output_OOFEM (FILE *stream, long step)
3693 {
3694  const char *str;
3695  char LINE[1023];
3696  Dmtrx *strain = new Dmtrx;
3697  Dmtrx *stress = new Dmtrx;
3698 
3700  IntPointSet ips = this->give_IPset_rslts(SOL_OOFEM);
3701  int NIP = IntPointSet_give_number_ips (ips);
3702  if (NIP != 8) errol;
3703 
3704  FiniteElementTypeSet fets;
3705  FiniteElementType feto = FETSet_set2e (this->elemAttribs()->give_FETS(&fets), SOL_OOFEM, Pd->give_analgroup());
3706 
3707  switch (feto) {
3708  case FET_OOFEM_LSpace: {
3709  int i, ipid;
3710  strain->resize_ignore_vals(NIP, 6);
3711  stress->resize_ignore_vals(NIP, 6);
3712 
3713  int ver = Pd->give_P_OOFEM_ver();
3714 
3716  fgets (LINE, 1023, stream); str=LINE;
3717  OOFEM_output_scan_elem_head (str, origid+1, this->ID+1, ver >= 18);
3718 
3720  for (i=0; i<NIP; i++) {
3721  ipid = ECN_convert_ips_brick (false, i, FFF_OOFEM, ips); // id of ip; mapping oofem ipid to midas ipid
3722 
3724  fgets (LINE, 1023, stream); str=LINE;
3725  OOFEM_output_scan_GP (str, i+1, ver < 18);
3726  SP_scan_expected_word_exit (str, "strains", "Invalid structure of OOFEM output file", CASE);
3727  if (!SP_scan_array (str, 6, strain->give_ptr2val(ipid, 0))) _errorr ("Invalid structure of OOFEM output file");
3728  strain->give_ptr2val(ipid, 0)[3] = strain->give_ptr2val(ipid, 0)[3] / 2.0;
3729  strain->give_ptr2val(ipid, 0)[4] = strain->give_ptr2val(ipid, 0)[4] / 2.0;
3730  strain->give_ptr2val(ipid, 0)[5] = strain->give_ptr2val(ipid, 0)[5] / 2.0;
3731 
3733  fgets (LINE, 1023, stream); str=LINE;
3734  SP_scan_expected_word_exit (str, "stresses", "Invalid structure of OOFEM output file", CASE);
3735  if (!SP_scan_array (str, 6, stress->give_ptr2val(ipid, 0))) _errorr ("Invalid structure of OOFEM output file");
3736  }
3737  break;
3738  }
3739  default: _errorr("unsupported type of brick element");
3740  }
3741 
3742  this->add_result(strain, step, RTE_global_strain);
3743  this->add_result(stress, step, RTE_global_stress);
3744 }
3745 
3747 void Brick :: read_output_SIFEL (FILE *stream, long step, ResultTypesAtElem rt)
3748 {
3749  const char *str;
3750  char LINE[1023], msg[60];
3751 
3752  sprintf (msg, "Invalid structure of SIFEL output file, element %ld", origid+1);
3753 
3755  int NIP = this->give_rslt_NIP(SOL_SIFEL);
3756  if (NIP != 8) errol; // toto je zde natvrdo
3757  int NIPa = 8; // ...
3758 
3760  fgets (LINE, 1023, stream); str=LINE;
3761  SP_scan_expected_word_exit (str, "Element", msg, CASE);
3762  SP_scan_expected_number_exit (str, origid+1, msg);
3763  SP_scan_expected_word_exit (str, ", integration points", msg, CASE);
3764  long ip1, ip2;
3765  SP_scan_number (str, ip1);
3766  SP_scan_expected_word_exit (str, "-", msg, CASE);
3767  SP_scan_number (str, ip2);
3768  if (ip2-ip1+1 != NIPa) _errorr(msg);
3769 
3770  int nstrcomp = 6;
3772  if (Pd->give_analgroup() == PAG_mechanics) {
3773  int j;
3774  Dmtrx *values = new Dmtrx(NIP, nstrcomp);
3775 
3776  // loop over NIP
3777  for (int i=0; i<NIP; i++) {
3779  // ipid = ECN_convert_ips_quadrangle (false, i, FFF_OOFEM); // id of ip; mapping oofem ipid to midas ipid
3780 
3781  fgets (LINE, 1023, stream); str=LINE;
3782 
3783  char r[15];
3784  for (j=0; j<nstrcomp; j++) {
3785  if (rt == RTE_global_strain) sprintf(r, "eps_%d=", j+1);
3786  else if (rt == RTE_global_stress) sprintf(r, "sig_%d=", j+1);
3787  else errol;
3788  SP_scan_expected_word_exit (str, r, msg, CASE);
3789  SP_scan_number (str, (*values)(i,j));
3790  }
3791  }
3792 
3793  FP_skip_line (stream, NIPa-NIP);
3794 
3795  this->add_result (values, step, rt);
3796  }
3797  else errol;
3798 }
3799 
3801 void Brick :: read_input (const char *&str, femFileFormat fff)
3802 {
3803  FElement :: read_input (str, fff);
3804 }
3805 
3807 double Brick :: give_ssstate (Dvctr *data, SStype SST, RVType rvtype, char type, long step, const Node *node)
3808 {
3809  if (this->elemAttribs()->give_sst() != SST) return this->fillupbyzero (data, SST);
3810  //if ( Msh()->give_rslts_solver() != SOL_OOFEM ) errol;
3811 
3812  if (node && this->give_rslt_NIP(SOL_OOFEM) !=1) errol;
3813 
3814  if (SST == SST_3d) {
3815  switch (rvtype) {
3816  case RVTstrn_displ: check_rslts(step, RTE_global_strain); data->beCopyOf(this->give_results_dm(step, RTE_global_strain)->give_ptr2val(), 6); break;
3817  case RVTstrs_displ: check_rslts(step, RTE_global_stress); data->beCopyOf(this->give_results_dm(step, RTE_global_stress)->give_ptr2val(), 6); break;
3818  default: errol;
3819  }
3820  }
3821  else errol;
3822 
3823  if (!node) return 0;
3824 
3825  //return this->give_weight();
3826  _warningg ("volume of brick is approximated");
3827 
3828  return this->give_centercoords()->dist2_to(node->give_coords());
3829 }
3830 
3831 void Brick :: print_row_VTX (char *str) const
3832 {
3833  sprintf (str, " %ld %ld %ld %ld %ld %ld %ld %ld",
3834  ((Node*)points[0])->give_lid_id(0),
3835  ((Node*)points[1])->give_lid_id(0),
3836  ((Node*)points[2])->give_lid_id(0),
3837  ((Node*)points[3])->give_lid_id(0),
3838  ((Node*)points[4])->give_lid_id(0),
3839  ((Node*)points[5])->give_lid_id(0),
3840  ((Node*)points[6])->give_lid_id(0),
3841  ((Node*)points[7])->give_lid_id(0));
3842 // sprintf (str, " %ld %ld %ld %ld %ld %ld %ld %ld",
3843 // ((Node*)points[3])->give_lid_id(0),
3844 // ((Node*)points[2])->give_lid_id(0),
3845 // ((Node*)points[1])->give_lid_id(0),
3846 // ((Node*)points[0])->give_lid_id(0),
3847 // ((Node*)points[7])->give_lid_id(0),
3848 // ((Node*)points[6])->give_lid_id(0),
3849 // ((Node*)points[5])->give_lid_id(0),
3850 // ((Node*)points[4])->give_lid_id(0));
3851 }
3852 
3853 
3854 } // namespace midaspace
const GPA< const Element > * give_superelems(void) const
Definition: cell.h:189
const Face * give_Face(long i) const
Definition: geometry.h:70
bool has_same_geom_with(Cell *slave) const
ASSORTED check same geometry.
Definition: cell.cpp:231
const GPA< const Gelement > * give_fixedGelements(void) const
Definition: cell.h:477
void compute_rotMg2l(void)
activate rotMg2l
Definition: cell.cpp:2715
virtual SStype give_SSType_default(void) const
give default type of stress state
Definition: cell.cpp:2639
GPA< const Element > superelems
CONNECTIVITY - full connectivity initiated only when Geom->connectivity_is_assembled() == true...
Definition: cell.h:157
void read_input(const char *&str, femFileFormat fff)
Definition: cell.cpp:2768
femFileFormat
Definition: alias.h:632
virtual SStype give_SSType_default(void) const
give default type of stress state
Definition: cell.cpp:3538
virtual double give_ssstate(Dvctr *data, SStype SST, RVType rvtype, char type, long step, const Node *node=NULL)
give stress-strain state
Definition: cell.cpp:3807
#define _warningg(_1)
Definition: gelib.h:154
VTKPDtopology give_VTKPDtopology(void) const
Definition: cell.cpp:814
int cross_abscissa_face(const PoinT *a1, const PoinT *a2, long cunf, const Face **unfac, const Cell *&comp, PoinT *nc, PoinT *cp)
Function finds out whether abscissa intersects any face.
Definition: cell.cpp:280
GPA< const Face > superfaces
CONNECTIVITY - full connectivity initiated only when Geom->connectivity_is_assembled() == true these ...
Definition: cell.h:240
bool give_PDBO(ProbDescBoolOpt pdbo) const
Definition: problem.h:187
const GPA< PointDOFsCondense > * give_conDOFs(void) const
Definition: attribute.h:830
VectoR * normalize(void)
Definition: arrays.h:185
IntPointSet IntPointSet_fet2e_rslts(IntPointSet IPset, FiniteElementType fet)
FET to IPS for results.
Definition: alias.h:1441
virtual void print_row(FILE *stream, femFileFormat fff, bool endline=true, long did=0) const
*** PRINT ***
Definition: cell.cpp:702
virtual void switch_node_pointer(Point *slave, Point *master, bool duplcheck)
switch node pointer form slave to master
Definition: cell.cpp:686
Solver
Solver.
Definition: alias.h:188
virtual void checkConsistency(void) const
Checks data consistency.
Definition: cell.cpp:1165
void read_output_OOFEM(FILE *stream, long step)
Definition: cell.cpp:3383
double dist2_to(const PoinT *p) const
Definition: arrays.h:102
virtual void compute_maxSigmaEq(void)
Definition: cell.cpp:2482
virtual void initialize(void)
initiate/sets data
Definition: cell.cpp:1473
void read_output_OOFEM(FILE *stream, long step)
Definition: cell.cpp:2783
PAGroup give_analgroup(void) const
Definition: problem.cpp:179
const Array * give_results(long step, ResultTypesAtElem rt) const
Definition: cell.h:692
PolyLine * generate_mesh_RFbyHN(Mesh *pm, GPA< const Node > &hnodes) const
Definition: cell.cpp:1221
DOFsPerNode
Definition: alias.h:700
virtual long give_edge_nodes(const Point **&edgnodes) const
Definition: cell.cpp:1512
virtual double give_ssstate(Dvctr *data, SStype SST, RVType rvtype, char type, long step, const Node *node=NULL)
give stress-strain state
Definition: cell.cpp:3139
long give_NumDomains(void) const
Definition: geometry.h:319
bool connectivity_assembled
Definition: cell.h:51
virtual DOFsPerNode give_DOFsPerNode_default(void) const
give default DOFs per node
Definition: cell.cpp:3529
long give_domain(void) const
Definition: cell.h:642
bool same_array_elements_asym(long nx, const ArgType *x, long ny, const ArgType *y, bool same_dim=false)
Function finds out whether every element of the array 'x' is in the array 'y'.
Definition: gelib.h:333
void transform_nc(const Point *t1, const Point *t2, double &ksi)
Definition: cell.cpp:468
#define ZERO
Definition: alias.h:51
void add_another_Element(FElement *elem, long dom)
adds elem to the end of array Elements
Definition: geometry.cpp:1398
General functions.
void allocate_results(void)
RESULTS.
Definition: cell.cpp:1694
IntPointSet give_IPset_comp(Solver sol) const
basic set = for displacement computation
Definition: cell.cpp:1635
#define SP_scan_expected_word_exit(_1, _2, _3, _4)
Definition: librw.h:201
const Edge * give_superedge(long i) const
Definition: point.h:111
virtual long give_edge_nodes(const Point **&edgnodes) const
Definition: cell.cpp:1489
const GPA< const Face > * give_superfaces(void) const
Definition: cell.h:271
virtual void checkConsistency(void) const
Checks data consistency.
Definition: cell.h:71
sifel i/o native ff
Definition: alias.h:644
Cell(classID mecg, long gid, long oid, long prop, const Geometry *mg, long nn, long ne, long nf)
CONSTRUCTOR.
Definition: cell.cpp:34
const PoinT * give_centercoords(void) const
Definition: cell.h:33
DOFsPerNode give_dpn(void) const
Definition: attribute.h:837
virtual double give_ssstate(Dvctr *data, SStype SST, RVType rvtype, char type, long step, const Node *node=NULL)
give stress-strain state
Definition: cell.cpp:2388
const Face * give_face(long i) const
Definition: cell.h:95
long give_dimMC(void) const
Definition: attribute.h:1187
long give_Nels(void) const
Definition: geometry.h:67
const Element * give_superelem(long i) const
Definition: point.h:113
bool is_equal_to(const FiniteElementTypeSet fets) const
equality
Definition: alias.h:1034
GPA< const Point > points
Definition: cell.h:46
double fillupbyzero(Dvctr *data, SStype SST) const
Definition: cell.cpp:1785
Point.
void print_row_VTK(FILE *stream) const
print element row output for VTK
Definition: cell.cpp:1091
long give_rslts_nsteps(void) const
Definition: geometry.h:328
int give_dimension(void) const
return type of element geometry, is identical with class derived from FElement
Definition: cell.h:32
#define SP_scan_expected_number_exit(_1, _2, _3)
Definition: librw.h:229
Cell * last_duplicity_master(void) const
return the last one in the duplicity master chain
Definition: cell.cpp:102
long give_mproperty_cnt(void) const
Definition: geomcomp.h:133
const Material * give_mat(void) const
Definition: attribute.h:846
void deallocateCheckUno(ArgType *p, bool check=true)
Definition: gelib.h:197
void check_connectivity(void) const
Definition: geomcomp.h:146
void set_face(long i, const Face *val)
Definition: cell.h:87
double give_Ry(void) const
Definition: attribute.h:279
IntPointSet IntPointSet_fet2e_comp(FiniteElementType fet)
FET to IPS for displacement computation (integration of stiffness matrix)
Definition: alias.h:1414
void read_input(const char *&str, femFileFormat fff)
Definition: cell.cpp:3368
virtual void checkConsistency(void) const
Checks data consistency.
Definition: cell.cpp:1594
bool SP_skip_word(const char *&src, int n)
... word and space before
Definition: librw.cpp:472
long give_nfa(void) const
Definition: cell.h:91
virtual void switch_node_pointer(Point *slave, Point *master, bool duplcheck)
switch node pointer form slave to master
Definition: cell.cpp:501
ElemAttribs * elemAttribs()
Gives attribute attributes, data type changed to ElemAttribs*.
Definition: cell.h:380
bool checkset_mprop(long val)
Definition: geomcomp.h:113
virtual void read_input(const char *&str, femFileFormat fff)
Definition: cell.cpp:1816
double give_CSusage_elast_rel(void)
Definition: cell.cpp:1757
long nc_brick_3d(double zero, double x[], double y[], double z[], const PoinT *point, PoinT *answer)
Function computes natural coordinates of 'point' on 'element', 'point' is entered in cartesian coordi...
virtual void print_row(FILE *stream, femFileFormat fff, bool endline=true, long did=0) const
*** PRINT ***
Definition: cell.cpp:517
virtual void integrate_duplicated_cell(const Element *slave)
DUPLICITY.
Definition: cell.cpp:990
void set_node(long i, long nid)
ATRIBUTES.
Definition: cell.h:649
void connectivity_assembling(bool re=false)
Function assembles connectivity between face and its nodes and edges.
Definition: cell.cpp:598
const Cell * give_MC(void) const
Definition: attribute.h:1186
int CellGeometry_e2i_VTK(CellGeometry cg)
Definition: alias.h:911
long ID
(global) identification number == position in list of members; zero-based numbering.
Definition: subject.h:22
Geometry functions.
int give_CSusage_elast_bool(void)
Definition: cell.cpp:1778
long give_ID() const
Definition: subject.h:45
double give_thickness(void) const
Definition: attribute.h:222
void set_new(const FacedgeAttribs *src)
Definition: attribute.cpp:903
virtual void checkConsistency(void) const
Checks data consistency.
Definition: cell.cpp:2124
void bePointAtAbscissa(const PoinT *p1, const PoinT *p2, double ksi)
receiver will be point at abscissa p1p2 with natural coord ksi
Definition: arrays.h:107
void connectivity_assembling(bool re=false)
Function assembles connectivity between element and its nodes, edges and faces (which are allocated i...
Definition: cell.cpp:852
virtual ~FElement()
DESTRUCTOR.
Definition: cell.cpp:1571
virtual void compute_maxSigmaEq(void)
Definition: cell.cpp:3189
void set_owner(Cell *val)
*** SET ***
Definition: compgeom.h:60
GPA< const Gelement > * fixedGelements
Definition: cell.h:456
#define errol
Definition: gelib.h:142
GPA< const Face > faces
Definition: cell.h:48
void connectivity_removing(void)
Function removes connectivity between element and its components == nodes, edges and faces...
Definition: cell.cpp:939
long give_numsuperedge(void) const
Definition: point.h:108
oofem i/o native ff
Definition: alias.h:643
void switch_node_pointer_in_all_components(Point *slave, Point *master, bool duplcheck)
switch node pointer from oldnode/slave to newnode/master on this and all components (edges...
Definition: cell.cpp:1001
int ECN_convert_ips_triangle(bool i2e, int id, femFileFormat fff, IntPointSet ips)
Definition: alias.h:1651
virtual void switch_node_pointer(Point *slave, Point *master, bool duplcheck)
switch node pointer form slave to master
Definition: cell.cpp:140
#define _errorr2(_1, _2)
Definition: gelib.h:145
long give_numsuperface(void) const
Definition: cell.h:269
Attributes * attributes
ATTRIBUTES.
Definition: geomcomp.h:73
GPA< const Vertex > * fixedVertices
Definition: cell.h:455
double give_elemSize(void) const
Definition: cell.cpp:784
CellGeometry give_cellGeom(void) const
Definition: cell.h:31
virtual void print_row(FILE *stream, femFileFormat fff, long did) const =0
print row to solver input file
SStype SStype_i2e_SIFEL(int val)
bar=1,plbeam=2,spacebeam=5,,plate=15,axisymm=20,shell=25,spacestress=30
Definition: alias.h:971
void connectivity_removing(void)
Function removes connectivity between edge and its nodes.
Definition: cell.cpp:405
long give_ned(void) const
Definition: cell.h:90
Classes Cell, Facedge, Edge, Face, Element, Gelement, PolyLine, Line, PolygonMdl, FElement...
virtual void print_row(FILE *stream, femFileFormat fff, bool endline=true, long did=0) const
print element row output in fff format
Definition: cell.cpp:2531
Elem3D * zero(void)
Definition: arrays.h:64
void resize_ignore_vals(long r, long c)
print yourself
Definition: arrays.cpp:711
double IPS_give_ip_coord_native(int i, IntPointSet ips, PoinT &coords)
Definition: alias.h:1332
void initialize_hn(const PoinT *cartcoord, const Cell *mc, long dimMC, long ordMC, long countMN, const Node **nodes, const PoinT *natcoord)
initialize hanging node
Definition: point.cpp:1130
void switch_dpn_Line(void)
Definition: attribute.cpp:1348
ComponentGeometry * cg
Definition: cell.h:28
virtual void rotate2local(Dvctr *data)
Definition: cell.cpp:2740
void setup_duplicity_master(Cell *val)
Definition: cell.cpp:159
bool is_cmfr(void)
Definition: cell.cpp:2039
int ECN_convert_e2i(int id, int compdim, int ord, CellGeometry cg, femFileFormat fff)
External to Internal conversion.
Definition: alias.h:1539
virtual void set_model_prop(long val, const Model *model, bool flag=false)
Definition: cell.cpp:627
IntPointSet
Definition: alias.h:1248
bool Parallel(void) const
*** FEMesh ***
Definition: geomcomp.h:144
virtual void integrate_duplicated_cell(const Element *slave)
DUPLICITY.
Definition: cell.cpp:1665
Attributes.
virtual void set_model_prop(long val, const Model *model, bool flag=false)
Definition: cell.cpp:1620
const Point * give_point(long i) const
Definition: cell.h:93
void transform_nc(const Edge *t1, const Edge *t2, PoinT *nc) const
Definition: cell.cpp:668
Structs Elem3D, PoinT and VectoR; classes Array, Array1d, Xscal, Dscal, Xvctr, Lvctr, Dvctr, Xmtrx, Lmtrx and Dmtrx.
const GPA< const Vertex > * give_fixedVertices(void) const
Definition: cell.h:476
void zero(void)
Definition: arrays.h:630
const Element * give_main_masterel_uniq(void) const
main masterel is Element (not Facedge) with same dimension as face/edge
Definition: cell.cpp:367
virtual void print_row_VTX(char *str) const
Definition: cell.cpp:3557
bool isZero(double zero, double a)
Definition: mathlib.cpp:308
virtual bool initialize_from(const char *&str, femFileFormat ff, bool all=true)
initialize form input string
Definition: attribute.cpp:1030
void give_vector(VectoR *v) const
Definition: cell.cpp:2199
Dvctr * resize_ignore_vals(long newsize)
Definition: arrays.h:595
t3d i/o native ff
Definition: alias.h:641
void read_output_SIFEL(FILE *stream, long step, ResultTypesAtElem rt)
Definition: cell.cpp:2336
double * maxSigmaEq
Definition: cell.h:673
virtual void give_ip_coords_global(IntPointSet ips, int i, PoinT &coords) const
Definition: cell.cpp:2756
void beCopyOf(const PoinT &src)
Definition: arrays.h:632
GelemAttribs * give_gelemAttribs(void)
Definition: cell.h:467
void allocNnNe(int n)
Definition: cell.cpp:1504
PointAttribs * give_pointAttribs(void)
Definition: point.h:93
void add_result(Array *rslt, long step, ResultTypesAtElem rt)
Definition: cell.cpp:1708
void OOFEM_output_scan_GP(const char *&str, int i, bool old=false)
Definition: cell.cpp:2098
const Face * give_superface(long i) const
Definition: cell.h:270
void add_property(int dim, long val)
Definition: point.cpp:303
const Dmtrx * give_results_dm(long step, ResultTypesAtElem rt) const
Definition: cell.cpp:1716
double give_elemSize(void) const
Definition: cell.cpp:559
long give_prop(void) const
Definition: attribute.h:593
const Edge * give_edge(long i) const
Definition: cell.h:94
*** *** *** *** CLASS ComponentGeometry 1D *** *** *** ***
Definition: compgeom.h:76
long intersec_rectangle3d_line(double zero, double norm, const PoinT *A, const PoinT *B, const PoinT *C, const PoinT *D, const PoinT *U, const PoinT *V, double *ksi, double *eta, double *t, PoinT *I1, PoinT *I2)
ZDROJE http://softsurfer.com/algorithm_archive.htm.
Definition: geometrylib.cpp:70
const Lvctr * give_mproperty_ptr(void) const
Definition: geomcomp.h:131
virtual classID give_classid() const
Returns classID - class identification.
Definition: compgeom.h:45
void connectivity_removing(void)
Function removes connectivity between face and its nodes and edges.
Definition: cell.cpp:608
virtual void print_row_VTX(char *str) const
Definition: cell.cpp:3831
virtual void give_ip_coords_global(IntPointSet ips, int i, PoinT &coords) const
activate rotMg2l
Definition: cell.cpp:3496
const Problem * Pd
Pointer to owner = parent problem.
Definition: subject.h:24
void init_point_on(Mesh *pm, GPA< const Node > &hnodes, const PoinT *point, const GeometryComponent *comp, const PoinT *nc, const Point *parentpoint) const
RFbyHN.
Definition: cell.cpp:1183
const Mesh * Msh(void) const
Definition: cell.h:615
virtual long give_ord(void) const =0
int ECN_convert_ips_brick(bool i2e, int id, femFileFormat fff, IntPointSet ips)
Definition: alias.h:1869
virtual long give_face_nodes_edges(const Point **&facnodes, const Edge **&facedges) const
Definition: cell.cpp:3669
bool cross_abscissa_node(const PoinT *a1, const PoinT *a2, long cunn, const Point **unnod, const Point *&nod, double &ksi, PoinT *cp) const
Function finds out whether some element node lays on abscissa.
Definition: cell.cpp:251
virtual void checkConsistency(void) const
Checks data consistency.
Definition: cell.cpp:2604
virtual void checkConsistency(void) const
Checks data consistency.
Definition: cell.cpp:3607
int give_P_OOFEM_ver(void) const
Definition: problem.h:198
virtual void read_input(const char *&str, femFileFormat fff)
Definition: cell.cpp:3801
virtual long give_edge_nodes(const Point **&edgnodes) const
Definition: cell.cpp:2668
#define _warningg2(_1, _2)
Definition: gelib.h:157
void assure_duplicity_master(void)
DUPLICITY.
Definition: cell.cpp:77
Geometry description.
Definition: geometry.h:29
virtual CellGeometry give_elemGeom(void) const =0
VectoR * beVectProduct(const VectoR *v1, const VectoR *v2)
vector product v1 x v2 (cross product)
Definition: arrays.h:160
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:167
virtual void connectivity_removing(void)=0
Function removes connectivity of element and its components == nodes, edges and faces; re == reassemb...
virtual void checkConsistency(void) const
Checks data consistency.
Definition: cell.cpp:3519
virtual ~Cell()
DESTRUCTOR.
Definition: cell.cpp:67
void setadd_masterel(const Element *comp)
Set master element if it is.
Definition: cell.cpp:352
virtual double give_quality(void) const
compute quality of element
Definition: cell.cpp:2691
void read_output_OOFEM(FILE *stream, long step)
Definition: cell.cpp:2206
const Edge * give_Edge(long i) const
Definition: geometry.h:69
void check_rslts(long step, ResultTypesAtElem rt) const
Definition: cell.h:709
double give_Iz(void) const
Definition: attribute.h:224
virtual void print_row_VTX(char *str) const
Definition: cell.cpp:1100
void set_load(int i, int indx=-1)
Definition: cell.cpp:956
GPA< const Element > masterels
Definition: cell.h:161
const Material * give_mat(int i) const
Definition: attribute.h:226
long give_mproperty() const
*** GET ***
Definition: geomcomp.h:126
CrossSectType give_loctype_or_type(void) const
Definition: attribute.h:217
void integrate_duplicated_one(const ElemAttribs *slv)
Definition: attribute.cpp:1237
ElemAttribs * give_elemAttribs(void)
Definition: cell.h:402
virtual void set_mprop(long val)
*** SET ***
Definition: geomcomp.h:111
void read_output_SIFEL(FILE *stream, long step, ResultTypesAtElem rt)
Definition: cell.cpp:3747
const char * FETSet_set2s_OOFEM(const FiniteElementTypeSet *set, PAGroup pg)
Definition: alias.h:1232
void switch_myself_at_connectivity(Cell *master)
switch receiver to master in connectivity system
Definition: cell.cpp:415
bool is_point_in_sphere(const PoinT *point) const
Definition: cell.h:37
FacedgeAttribs * give_facedgeAttribs(void)
Definition: cell.h:198
void copy_row(long r, const Dvctr &v)
Definition: arrays.h:802
const GPA< const Point > * give_points(void) const
Definition: cell.h:97
const Geometry * Geom
Pointer to owner == parent geometry.
Definition: subject.h:59
BoundaryCond * give_BC(long i) const
Definition: problem.h:322
const GPA< const Edge > * give_edges(void) const
Definition: cell.h:98
GPA - Generic Pointer Array, template class manages 1d array of pointers to objects of type T...
Definition: gpa.h:23
virtual DOFsPerNode give_DOFsPerNode_default(void) const
give default DOFs per node
Definition: cell.cpp:2627
const Face * give_superface(long i) const
Definition: point.h:112
#define FP_scan_expected_line_exit(_1, _2, _3, _4)
Definition: librw.h:110
const Dvctr * give_results_dv(long step, ResultTypesAtElem rt) const
Definition: cell.cpp:1715
FiniteElementType
Definition: alias.h:995
#define _errorr(_1)
Definition: gelib.h:151
void set_elemCount(double val)
Definition: cell.cpp:1143
void divide(Mesh *pm, GPA< const Node > &hnodes) const
Function splits polyline segments up subsegments, one subsegment belongs to one element.
Definition: cell.cpp:1299
GPA< const Edge > edges
Definition: cell.h:47
SStype
type of stress/strain state of element; especially results depends on this variable => described at M...
Definition: alias.h:954
PolyLine(long gid, long oid, const Geometry *mg, int nv, classID mecg=classVoid)
CONSTRUCTOR.
Definition: cell.h:498
#define _errorr3(_1, _2, _3)
Definition: gelib.h:146
const HNAttribs * give_HNattrb(void) const
Definition: point.h:343
ComponentGeometry * allocComponentGeometry(classID cid, Cell *owner, ComponentGeometry *src=NULL)
Definition: cell.cpp:16
const Gelement * give_mdl_masterel(void) const
Definition: cell.h:645
virtual double give_ssstate(Dvctr *data, SStype SST, RVType rvtype, char type, long step, const Node *node=NULL)
give stress-strain state
Definition: cell.cpp:3472
virtual long give_face_nodes_edges(const Point **&facnodes, const Edge **&facedges) const
Definition: cell.cpp:3347
FiniteElementType FETSet_set2e(const FiniteElementTypeSet *set, Solver sol, PAGroup pg)
FETset to FET.
Definition: alias.h:1145
bool give_fulldata(void) const
Definition: problem.h:206
Mathematic functions.
double give_area(void) const
Definition: attribute.h:219
SStype give_sst(void) const
Definition: attribute.h:838
BCType give_loctype(void) const
Definition: attribute.h:369
bool is_nod_on(double norm, const PoinT *point, double &ksi) const
Function finds out mutual position of node and edge.
Definition: cell.cpp:484
void set_prop_node_inher(bool everynode)
inherit property from element to nodes, only if node has one superelem
Definition: cell.cpp:977
virtual long give_face_nodes_edges(const Point **&facnodes, const Edge **&facedges) const
Definition: cell.cpp:1526
bool give_virtual(void) const
Definition: attribute.h:969
const Gelement * mdl_masterel
Definition: cell.h:595
long give_numsuperface(void) const
Definition: point.h:109
ansys i/o native ff
Definition: alias.h:642
void be_mean_of(const Dmtrx *src)
Definition: arrays.cpp:350
virtual DOFsPerNode give_DOFsPerNode_default(void) const
give default DOFs per node
Definition: cell.cpp:3297
void read_output_OOFEM(FILE *stream, long step)
Definition: cell.cpp:3692
bool FP_skip_expected_string(FILE *src, const char *expctd, bool cs)
... word and compare with expected one
Definition: librw.cpp:376
virtual long give_edge_nodes(const Point **&edgnodes) const
return type of element for OOFEM solver
Definition: cell.cpp:3567
bool switch_edge_pointer(Edge *slave, Edge *master)
switch pointer to component edge - slave is replaced be master
Definition: cell.cpp:147
#define CASE
Definition: alias.h:43
virtual void switch_node_pointer(Point *slave, Point *master, bool duplcheck)
switch node pointer form slave to master
Definition: cell.cpp:1010
bool give_delete_flag() const
Definition: geomcomp.h:137
int give_ord(void) const
Definition: cell.h:639
Dmtrx * rotMg2l
Definition: cell.h:806
DOFsPerNode give_DOFspnod(void) const
Definition: problem.h:256
double give_circum(void) const
Definition: cell.h:34
void tnsrRotAxisZangle(double a)
rotate coord system around axis z by angle
Definition: arrays.cpp:442
double give_GeomWeight1deg(void) const
Definition: cell.h:36
const Dscal * give_results_ds(long step, ResultTypesAtElem rt) const
Definition: cell.cpp:1714
ResultTypesAtElem
Result type at element.
Definition: alias.h:240
bool check_collapse(void)
check any two nodes are same = element is collapsed
Definition: cell.h:138
double * give_ptr2val(long r=0, long c=0)
Definition: arrays.h:793
void connectivity_assembling(bool re=false)
Function assembles connectivity between edge and its nodes.
Definition: cell.cpp:396
long give_result_ncomp(long time_step, ResultTypesAtElem rte) const
Definition: cell.cpp:1803
virtual DOFsPerNode give_DOFsPerNode_default(void) const
give default DOFs per node
Definition: cell.cpp:2149
void read_output_SIFEL(FILE *stream, long step, ResultTypesAtElem rt)
Definition: cell.cpp:3086
bool give_3Delement_with_point_inside(const PoinT *coords, const GeometryComponent *&comp, PoinT *nc) const
Function finds location of point indide of which 3d element is.
Definition: geometry.cpp:863
void set_edge(long i, const Edge *val)
Definition: cell.h:86
bool give_Parallel(void) const
Definition: geometry.h:318
void del_points_down(long val)
Definition: cell.h:515
const Facedge * give_same_dimension_facedge(void) const
Returns edge/face/volume of same dimension as receiver (Beam returns edge, etc.)
Definition: cell.cpp:836
Triangle(long gid, long oid, const Geometry *mg, bool aa, long dom, long lid)
CONSTRUCTOR ord nn ne nf.
Definition: cell.h:810
const Element * give_Elem(long i) const
Definition: geometry.h:71
void findout_segment_domain(Mesh *pm, GPA< const Node > &hnodes) const
Definition: cell.cpp:1438
int FETSet_set2i_SIFEL(const FiniteElementTypeSet *set, PAGroup pg)
Definition: alias.h:1237
bool SP_scan_array(const char *&src, int n, ArgType *a)
... array of numbers
Definition: librw.h:233
virtual void switch_myself_at_connectivity(Cell *master)
switch receiver to master in connectivity system
Definition: cell.cpp:217
VectoR * beP2P(const PoinT *p1, const PoinT *p2)
Receiver is set to vector from p1 to p2, i.e. 'this = p2 - p1'.
Definition: arrays.h:153
bool SP_scan_number(const char *&src, int &dest)
... number of type int/long/double
Definition: librw.cpp:595
long give_numsuperelem(void) const
Definition: point.h:110
T * last(void) const
Definition: gpa.h:228
*** *** *** *** CLASS COMPONENT *** *** *** ***
Definition: geomcomp.h:22
tato struktura by mela obsahovat vsechny potrebne informace pro urceni konkretni implementace konecne...
Definition: alias.h:1019
quadrilateral convex hexahedron
Definition: compgeom.h:246
FiniteElementTypeSet * give_FETS(FiniteElementTypeSet *set) const
GLOBAL, EAL_direct only.
Definition: attribute.cpp:1295
virtual long give_face_nodes_edges(const Point **&facnodes, const Edge **&facedges) const
Definition: cell.cpp:2679
virtual void print_row(FILE *stream, femFileFormat fff, bool endline=true, long did=0) const
print element row output for OOFEM
Definition: cell.cpp:1935
IntPointSet give_IPset_rslts(Solver sol) const
basic set = for results
Definition: cell.cpp:1647
long give_nno(void) const
Definition: cell.h:89
bool is_point_on(const PoinT *point, const GeometryComponent *&comp, PoinT *nc) const
Function finds out mutual position of point with coords and 'element'.
Definition: cell.cpp:1028
void set_mprop(long val)
*** SET ***
Definition: cell.cpp:971
virtual long give_edge_nodes(const Point **&edgnodes) const
Definition: cell.cpp:3335
virtual DOFsPerNode give_DOFsPerNode_default(void) const
give default DOFs per node
Definition: cell.cpp:3619
virtual void compute_maxSigmaEq(void)
Definition: cell.h:697
void switch_myself_at_connectivity(Cell *master)
switch receiver to master in connectivity system
Definition: cell.cpp:619
bool isTruss(void) const
Definition: cell.h:439
virtual void checkConsistency(void) const
Checks data consistency.
Definition: cell.cpp:3277
void set_result(long s, double *rslt, long step, ResultTypesAtElem rt)
Definition: cell.cpp:1709
#define _errorr4(_1, _2, _3, _4)
Definition: gelib.h:147
int masterel_dim
MASTER ELEMENT.
Definition: cell.h:160
*** *** *** *** CLASS ComponentGeometry *** *** *** ***
Definition: compgeom.h:22
double SigmaEq(VectoR &s, VectoR &t)
Definition: cell.cpp:2473
bool switch_face_pointer(Face *slave, Face *master)
switch pointer to component face - slave is replaced be master
Definition: cell.cpp:152
Cell * duplmaster
Definition: cell.h:59
int give_global_nDOFs(void) const
Definition: problem.h:257
#define FP_scan_expected_word_exit(_1, _2, _3, _4)
Definition: librw.h:107
int CellGeometry_e2i_JKTK(CellGeometry cg)
Definition: alias.h:880
T * add(T *val)
add (assign) new pointer to the end; enlarge the receiver if too small
Definition: gpa.h:157
double give_lav(void) const
Definition: cell.h:35
bool is_first_diag_short(void)
if the first diagonal is shorter then the second
Definition: cell.cpp:3359
double give_Iy(void) const
Definition: attribute.h:223
double give_width(void) const
Definition: attribute.h:220
bool isOOFEMplast(void) const
Definition: attribute.h:281
virtual void integrate_duplicated_cell(const Facedge *slave)
DUPLICITY.
Definition: cell.cpp:382
virtual long give_edge_nodes(const Point **&edgnodes) const
return type of element for OOFEM solver
Definition: cell.cpp:3647
double give_characteristic_size(void) const
Definition: cell.h:38
virtual SStype give_SSType_default(void) const
give default type of stress state
Definition: cell.cpp:2159
const GPA< const Element > * give_superelems(void) const
Definition: point.h:116
RVType
Result variable type.
Definition: alias.h:194
void setup_maxSigmaEq(void)
Definition: cell.cpp:1719
virtual void initialize(void)
initiate/sets data
Definition: geomcomp.h:94
const CrossSection * give_cs(void) const
Definition: attribute.h:845
void read_nodes(const char *&str, femFileFormat fff)
print element row output for VTK
Definition: cell.cpp:2027
virtual SStype give_SSType_default(void) const
give default type of stress state
Definition: cell.cpp:3628
virtual long give_face_nodes_edges(const Point **&facnodes, const Edge **&facedges) const
Definition: cell.h:103
virtual long give_edge_nodes(const Point **&edgnodes) const
return type of element for OOFEM solver
Definition: cell.cpp:2189
void set_sst(SStype val)
Definition: attribute.h:785
FElement(classID mecg, long gid, long oid, const Geometry *mg, long ord, long nn, long ne, long nf, bool aa, long dom, long lid)
CONSTRUCTOR.
Definition: cell.cpp:1544
long give_mpropertyORzero(void) const
Definition: geomcomp.h:132
classID
Type introduced to distinguish between classes.
Definition: alias.h:142
int IntPointSet_give_number_ips(IntPointSet ips)
give number of int. points
Definition: alias.h:1316
virtual void integrate_duplicated_cell(const Cell *slave)
Definition: cell.cpp:118
Array *** results
2d array of pointers to Array (Xvctr or Xmtrx)
Definition: cell.h:670
virtual void integrate_duplicated_cell(const Edge *slave)
DUPLICITY.
Definition: cell.cpp:453
PoinT * copy(const PoinT *p)
Definition: arrays.h:99
long give_ccols(void) const
Definition: arrays.h:729
virtual SStype give_SSType_default(void) const
give default type of stress state
Definition: cell.cpp:3308
VTKPDtopology
VTK type of cell topology for POLYDATA.
Definition: alias.h:931
virtual void set_model_prop(long val, const Model *model, bool flag=false)
flag==1 master is element, flag==0 master is facedge
Definition: cell.cpp:424
jktk i/o
Definition: alias.h:639
virtual classID give_classid() const
Returns classID - class identification.
Definition: subject.h:35
double give_CSusage_elast(void)
Definition: cell.cpp:1737
double give_height(void) const
Definition: attribute.h:221
int give_rslt_NIP(Solver sol) const
Definition: cell.h:631
int give_nlayers(void) const
Definition: attribute.h:225
*** *** *** *** CLASS ComponentGeometry 2D *** *** *** ***
Definition: compgeom.h:138
bool invisible_duplicated(char flag='a')
make invisible if duplicated
Definition: cell.cpp:192
const GPA< const Face > * give_superfaces(void) const
Definition: point.h:115
void attributes_allocation(const GelemAttribs *masterat)
Definition: cell.cpp:1578
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:214
const PoinT * give_coords(void) const
Definition: point.h:89
Gelement(classID mecg, long gid, long oid, const Geometry *mg, long nn, long ne, long nf)
CONSTRUCTOR.
Definition: cell.cpp:1114
IntPointSet give_IPset(void) const
Definition: attribute.h:842
virtual void initialize(void)
initiate/sets data
Definition: cell.cpp:1588
void OOFEM_output_scan_elem_head(const char *str, long o, long i, bool oid)
Definition: cell.cpp:2090
virtual long give_face_nodes_edges(const Point **&facnodes, const Edge **&facedges) const
Definition: cell.cpp:3583
MaterialType give_type(void) const
Definition: attribute.h:277
void assign_fixed_entities_by_ID(bool node, long ncn, const long *icn)
Definition: cell.cpp:1151
virtual long give_edge_nodes(const Point **&edgnodes) const
Definition: cell.h:411
void setadd_superelem(const Element *comp, bool uniquecheck)
Returns classID - class identification.
Definition: cell.h:181
double give_coord(int i) const
Definition: point.h:90
int ECN_convert_ips_quadrangle(bool i2e, int id, femFileFormat fff, IntPointSet ips)
Definition: alias.h:1733
bool give_ksiAtAbscissa(double zero, double norm, const PoinT *p1, const PoinT *p2, double &ksi) const
compute natural coordinate ksi of receiver at abscissa p1p2 answer: 1(0) = point lays on(out of) absc...
Definition: arrays.h:116
void set_elemSize(double val)
Definition: cell.cpp:1128
long give_numsuperelem(void) const
Definition: cell.h:187