OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
node.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 /*
36  * The original idea for this class comes from
37  * Dubois-Pelerin, Y.: "Object-Oriented Finite Elements: Programming concepts and Implementation",
38  * PhD Thesis, EPFL, Lausanne, 1992.
39  */
40 
41 #include "node.h"
42 #include "dof.h"
43 #include "slavedof.h"
44 #include "simpleslavedof.h"
45 #include "nodalload.h"
46 #include "timestep.h"
47 #include "floatarray.h"
48 #include "floatmatrix.h"
49 #include "intarray.h"
50 #include "verbose.h"
51 #include "datastream.h"
52 #include "contextioerr.h"
53 #include "mathfem.h"
54 #include "classfactory.h"
55 #include "dynamicinputrecord.h"
56 #include "domain.h"
57 #include "engngm.h"
58 
59 #ifdef __OOFEG
60  #include "oofeggraphiccontext.h"
61  #include "xfem/enrichmentitem.h"
62  #include "xfem/xfemmanager.h"
63 #endif
64 
65 namespace oofem {
67 
68 Node :: Node(int n, Domain *aDomain) :
69  DofManager(n, aDomain), coordinates()
70 {
71  localCoordinateSystem = NULL;
72 }
73 
74 
76 {
77  delete localCoordinateSystem;
78 }
79 
80 
81 double
83 // Returns the i-th coordinate of the receiver.
84 {
85  if ( i > coordinates.giveSize() ) {
86  return 0.;
87  }
88 
89  return coordinates.at(i);
90 }
91 
92 
94 // Gets from the source line from the data file all the data of the receiver.
95 {
96  IRResultType result; // Required by IR_GIVE_FIELD macro
97 
98  int size;
99 
100 # ifdef VERBOSE
101  // VERBOSE_PRINT1("Instanciating node ",number)
102 # endif
103 
104  result = DofManager :: initializeFrom(ir);
105  if ( result != IRRT_OK ) {
106  return result;
107  }
108 
110 
111  //
112  // scaling of coordinates if necessary
113  //
115  double lscale = domain->giveEngngModel()->giveVariableScale(VST_Length);
116  this->coordinates.times(1. / lscale);
117  }
118 
119 
120  // Read if available local coordinate system in this node
121  if ( ir->hasField(_IFT_Node_lcs) ) {
122  FloatArray triplets;
123  IR_GIVE_FIELD(ir, triplets, _IFT_Node_lcs);
124  size = triplets.giveSize();
125  if ( size != 6 ) {
126  OOFEM_WARNING("lcs in node %d is not properly defined, will be ignored", this->giveNumber() );
127  }
128 
129  double n1 = 0.0, n2 = 0.0;
131 
132  for ( int j = 1; j <= 3; j++ ) {
133  localCoordinateSystem->at(1, j) = triplets.at(j);
134  n1 += triplets.at(j) * triplets.at(j);
135  localCoordinateSystem->at(2, j) = triplets.at(j + 3);
136  n2 += triplets.at(j + 3) * triplets.at(j + 3);
137  }
138 
139  n1 = sqrt(n1);
140  n2 = sqrt(n2);
141  if ( ( n1 <= 1.e-6 ) || ( n2 <= 1.e-6 ) ) {
142  OOFEM_ERROR("lcs input error");
143  }
144 
145  for ( int j = 1; j <= 3; j++ ) { // normalize e1' e2'
146  localCoordinateSystem->at(1, j) /= n1;
147  localCoordinateSystem->at(2, j) /= n2;
148  }
149 
150  // vector e3' computed from vector product of e1', e2'
151  localCoordinateSystem->at(3, 1) =
154  localCoordinateSystem->at(3, 2) =
157  localCoordinateSystem->at(3, 3) =
160  }
161 
162  return IRRT_OK;
163 }
164 
166 {
168 
170 
171  if ( localCoordinateSystem != NULL ) {
173  }
174 }
175 
176 
177 void
179 {
180  answer.clear();
181  if ( type != ExternalForcesVector ) {
182  return;
183  }
184 
185  NodalLoad *loadN = dynamic_cast< NodalLoad * >(load);
186  if ( !loadN ) {
187  OOFEM_ERROR("incompatible load");
188  }
189 
190  if ( loadN->giveBCGeoType() != NodalLoadBGT ) {
191  OOFEM_ERROR("incompatible load type applied");
192  }
193 
194  load->computeComponentArrayAt(answer, tStep, mode);
195 
196  // Transform from Global to Local c.s.
197  if ( loadN->giveCoordSystMode() == NodalLoad :: CST_Global ) {
198  FloatMatrix L2G;
199  if ( this->computeL2GTransformation(L2G, loadN->giveDofIDs()) ) {
200  answer.rotatedWith(L2G, 't');
201  }
202  }
203 }
204 
205 
206 void
208 // Prints the receiver on screen.
209 {
210  printf("Node %d coord : x %f y %f z %f\n", number, this->giveCoordinate(1), this->giveCoordinate(2), this->giveCoordinate(3));
211  for ( Dof *dof: *this ) {
212  dof->printYourself();
213  }
214 
215  printf("load array : ");
217  printf("\n");
218 }
219 
220 
221 void
223 // Updates the receiver at end of step.
224 {
226 
228 
229  if ( mode == AL ) { // updated Lagrange
230  for ( Dof *d: *this ) {
231  DofIDItem id = d->giveDofID();
232  if ( id == D_u || id == D_v || id == D_w ) {
233  int ic = id - D_u + 1;
234  coordinates.at(ic) += d->giveUnknown(VM_Incremental, tStep);
235  } else if ( id == V_u || id == V_v || id == V_w ) {
236  int ic = id - V_u + 1;
237  coordinates.at(ic) += d->giveUnknown(VM_Total, tStep) * tStep->giveTimeIncrement();
238  }
239  }
240  }
241 }
242 
243 
244 double
245 Node :: giveUpdatedCoordinate(int ic, TimeStep *tStep, double scale)
246 //
247 // returns coordinate + scale * displacement
248 //
249 {
250 #ifdef DEBUG
251  if ( ( ic < 1 ) || ( ic > 3 ) ) {
252  OOFEM_ERROR("Can't return non-existing coordinate (index not in range 1..3)");
253  return 0.;
254  }
255 #endif
256 
257  if ( tStep->isTheCurrentTimeStep() ) {
258  double coordinate = this->giveCoordinate(ic);
259  if ( !this->hasLocalCS() ) {
260  // this has no local cs.
261  for ( Dof *d: *this ) {
262  DofIDItem id = d->giveDofID();
263  if ( id == ic ) {
264  coordinate += scale * d->giveUnknown(VM_Total, tStep);
265  break;
266  } else if ( id - V_u + 1 == ic ) {
267  coordinate += scale * d->giveUnknown(VM_Total, tStep) * tStep->giveTimeIncrement();
268  break;
269  }
270  }
271  } else {
272  //
273  // this has local cs.
274  // We must perform transformation of displacements DOFs
275  // in to global c.s and then to add them to global coordinates.
276  //
278  FloatArray displacements( T->giveNumberOfRows() );
279  displacements.zero();
280 
281  for ( Dof *d: *this ) {
282  DofIDItem id = d->giveDofID();
283  if ( id == D_u || id == D_v || id == D_w ) {
284  int ic2 = id - D_u + 1;
285  displacements.at(ic2) = scale * d->giveUnknown(VM_Total, tStep);
286  } else if ( id == V_u || id == V_v || id == V_w ) {
287  int ic2 = id - V_u + 1;
288  displacements.at(ic2) = scale * d->giveUnknown(VM_Total, tStep) * tStep->giveTimeIncrement();
289  }
290  }
291 
292  // perform transformation for desired displacement
293  for ( int i = 1; i <= 3; i++ ) {
294  coordinate += displacements.at(i) * T->at(i, ic);
295  }
296  }
297 
298  return coordinate;
299  } else {
300  OOFEM_ERROR("Can't return updatedCoordinate for non-current timestep");
301  }
302 
303  return 0.;
304 }
305 
306 
307 void
309 //
310 // returns coordinate + scale * displacement
311 //
312 {
313  if ( tStep->isTheCurrentTimeStep() ) {
314  FloatArray vec;
315  coord = this->coordinates;
316  this->giveUnknownVectorOfType(vec, DisplacementVector, VM_Total, tStep);
317  for ( int i = 1; i <= coord.giveSize(); i++ ) {
318  coord.at(i) += scale * vec.at(i);
319  }
320  }
321 }
322 
323 
324 int
326 {
327  /*
328  * Checks internal data consistency in node.
329  * Current implementation checks (when receiver has slave dofs) if receiver has the same
330  * coordinate system as master dofManager of slave dof.
331  */
332  int result;
333  int nslaves = 0;
334 
336 
337  for ( Dof *dof: *this ) {
338  if ( dynamic_cast< SimpleSlaveDof * >( dof ) ) {
339  nslaves++;
340  }
341  }
342 
343  if ( nslaves == 0 ) {
344  return result; // return o.k. if no slaves exists
345  }
346 
347  IntArray masterDofManagers(nslaves);
348  int numberOfMDM = 0; // counter of different master dofManagers
349  int master, alreadyFound = 0;
350  Node *masterNode;
351 
352  for ( Dof *dof: *this ) {
353  SimpleSlaveDof *sdof = dynamic_cast< SimpleSlaveDof * >( dof );
354  if ( sdof ) {
355  alreadyFound = 0;
356  master = sdof->giveMasterDofManagerNum();
357  for ( int j = 1; j <= numberOfMDM; j++ ) {
358  if ( masterDofManagers.at(j) == master ) {
359  alreadyFound = 1;
360  break;
361  }
362  }
363 
364  if ( alreadyFound == 0 ) {
365  // check master for same coordinate system
366  // first mark master as checked
367  numberOfMDM++;
368  masterDofManagers.at(numberOfMDM) = master;
369  // compare coordinate systems
370  masterNode = dynamic_cast< Node * >( domain->giveDofManager(master) );
371  if ( !masterNode ) {
372  OOFEM_WARNING("master dofManager is not compatible", 1);
373  result = 0;
374  } else if ( !this->hasSameLCS(masterNode) ) {
375  OOFEM_WARNING("different lcs for master/slave nodes", 1);
376  result = 0;
377  }
378  }
379  }
380  }
381 
382  return result;
383 }
384 
385 
386 bool
388 {
389  FloatMatrix *thisLcs, *masterLcs;
390  thisLcs = this->giveLocalCoordinateTriplet();
391  masterLcs = remote->giveLocalCoordinateTriplet();
392 
393  if ( ( this->hasLocalCS() ) && ( remote->hasLocalCS() ) ) {
394  for ( int k = 1; k <= 3; k++ ) {
395  for ( int l = 1; l <= 3; l++ ) {
396  if ( fabs( thisLcs->at(k, l) - masterLcs->at(k, l) ) > 1.e-4 ) {
397  return false;
398  }
399  }
400  }
401  } else if ( this->hasLocalCS() ) {
402  for ( int k = 1; k <= 3; k++ ) {
403  for ( int l = 1; l <= 3; l++ ) {
404  if ( fabs( thisLcs->at(k, l) - ( k == l ) ) > 1.e-4 ) {
405  return false;
406  }
407  }
408  }
409  } else if ( remote->hasLocalCS() ) {
410  for ( int k = 1; k <= 3; k++ ) {
411  for ( int l = 1; l <= 3; l++ ) {
412  if ( fabs( masterLcs->at(k, l) - ( k == l ) ) > 1.e-4 ) {
413  return false;
414  }
415  }
416  }
417  }
418 
419  return true;
420 }
421 
422 
423 bool
425 {
426  //
427  // computes transformation of receiver from global cs to nodal (user-defined) cs.
428  // Note: implementation rely on D_u, D_v and D_w (R_u, R_v, R_w) order in cltypes.h
429  // file. Do not change their order and do not insert any values between these values.
430  //
431  DofIDItem id;
432 
433  if ( localCoordinateSystem == NULL ) {
434  answer.clear();
435  return false;
436  } else {
438  if ( dofIDArry.isEmpty() ) {
439  // response for all local dofs is computed
440 
441  int numberOfDofs = this->giveNumberOfDofs();
442  answer.resize(numberOfDofs, numberOfDofs);
443  answer.zero();
444 
445  int i = 0;
446  for ( Dof *dof: *this ) {
447  // test for vector quantities
448  i++;
449  int j = 0;
450  switch ( id = dof->giveDofID() ) {
451  case D_u:
452  case D_v:
453  case D_w:
454  for ( Dof *dof2: *this ) {
455  DofIDItem id2 = dof2->giveDofID();
456  j++;
457  if ( ( id2 == D_u ) || ( id2 == D_v ) || ( id2 == D_w ) ) {
458  answer.at(j, i) = localCoordinateSystem->at( ( int ) ( id ) - ( int ) ( D_u ) + 1,
459  ( int ) ( id2 ) - ( int ) ( D_u ) + 1 );
460  }
461  }
462 
463  break;
464 
465  case V_u:
466  case V_v:
467  case V_w:
468  for ( Dof *dof2: *this ) {
469  DofIDItem id2 = dof2->giveDofID();
470  j++;
471  if ( ( id2 == V_u ) || ( id2 == V_v ) || ( id2 == V_w ) ) {
472  answer.at(j, i) = localCoordinateSystem->at( ( int ) ( id ) - ( int ) ( V_u ) + 1,
473  ( int ) ( id2 ) - ( int ) ( V_u ) + 1 );
474  }
475  }
476 
477  break;
478 
479  case R_u:
480  case R_v:
481  case R_w:
482  for ( Dof *dof2: *this ) {
483  DofIDItem id2 = dof2->giveDofID();
484  j++;
485  if ( ( id2 == R_u ) || ( id2 == R_v ) || ( id2 == R_w ) ) {
486  answer.at(j, i) = localCoordinateSystem->at( ( int ) ( id ) - ( int ) ( R_u ) + 1,
487  ( int ) ( id2 ) - ( int ) ( R_u ) + 1 );
488  }
489  }
490 
491  break;
492 
493  case T_f:
494  case P_f:
495  // scalar quantities
496  answer.at(i, i) = 1.0;
497  break;
498 
499  default:
500  OOFEM_ERROR("unknown dofID (%s)", __DofIDItemToString(id).c_str());
501  }
502  }
503  } else { // end if (dofIDArry.isEmpty())
504  // map is provided -> assemble for requested dofs
505  int size = dofIDArry.giveSize();
506  answer.resize(size, size);
507  answer.zero();
508 
509  for ( int i = 1; i <= size; i++ ) {
510  // test for vector quantities
511  switch ( id = ( DofIDItem ) dofIDArry.at(i) ) {
512  case D_u:
513  case D_v:
514  case D_w:
515  for ( int j = 1; j <= size; j++ ) {
516  DofIDItem id2 = ( DofIDItem ) dofIDArry.at(j);
517  if ( ( id2 == D_u ) || ( id2 == D_v ) || ( id2 == D_w ) ) {
518  answer.at(j, i) = localCoordinateSystem->at( ( int ) ( id ) - ( int ) ( D_u ) + 1, ( int ) ( id2 ) - ( int ) ( D_u ) + 1 );
519  }
520  }
521 
522  break;
523 
524  case V_u:
525  case V_v:
526  case V_w:
527  for ( int j = 1; j <= size; j++ ) {
528  DofIDItem id2 = ( DofIDItem ) dofIDArry.at(j);
529  if ( ( id2 == V_u ) || ( id2 == V_v ) || ( id2 == V_w ) ) {
530  answer.at(j, i) = localCoordinateSystem->at( ( int ) ( id ) - ( int ) ( V_u ) + 1, ( int ) ( id2 ) - ( int ) ( V_u ) + 1 );
531  }
532  }
533 
534  break;
535 
536  case R_u:
537  case R_v:
538  case R_w:
539  for ( int j = 1; j <= size; j++ ) {
540  DofIDItem id2 = ( DofIDItem ) dofIDArry.at(j);
541  if ( ( id2 == R_u ) || ( id2 == R_v ) || ( id2 == R_w ) ) {
542  answer.at(j, i) = localCoordinateSystem->at( ( int ) ( id ) - ( int ) ( R_u ) + 1, ( int ) ( id2 ) - ( int ) ( R_u ) + 1 );
543  }
544  }
545 
546  break;
547 
548  case T_f:
549  case P_f:
550  // scalar quantities
551  answer.at(i, i) = 1.0;
552  break;
553 
554  default:
555  OOFEM_ERROR("unknown dofID (%s)", __DofIDItemToString(id).c_str());
556  }
557  }
558  } // end map is provided -> assemble for requested dofs
559  } // end localCoordinateSystem defined
560  return true;
561 }
562 
563 
565 Node :: saveContext(DataStream &stream, ContextMode mode, void *obj)
566 //
567 // saves full node context (saves state variables, that completely describe
568 // current state)
569 //
570 {
571  contextIOResultType iores;
572 
573  if ( ( iores = DofManager :: saveContext(stream, mode, obj) ) != CIO_OK ) {
574  THROW_CIOERR(iores);
575  }
576 
577  if ( mode & CM_Definition ) {
578  int _haslcs = hasLocalCS();
579  if ( ( iores = coordinates.storeYourself(stream) ) != CIO_OK ) {
580  THROW_CIOERR(iores);
581  }
582 
583  if ( !stream.write(_haslcs) ) {
585  }
586 
587  if ( _haslcs ) {
588  if ( ( iores = localCoordinateSystem->storeYourself(stream) ) != CIO_OK ) {
589  THROW_CIOERR(iores);
590  }
591  }
592  }
593 
594  return CIO_OK;
595 }
596 
597 
600 //
601 // restores full node context (saves state variables, that completely describe
602 // current state)
603 //
604 {
605  contextIOResultType iores;
606 
607  if ( ( iores = DofManager :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
608  THROW_CIOERR(iores);
609  }
610 
611  if ( mode & CM_Definition ) {
612  int _haslcs;
613  if ( ( iores = coordinates.restoreYourself(stream) ) != CIO_OK ) {
614  THROW_CIOERR(iores);
615  }
616 
617  if ( !stream.read(_haslcs) ) {
619  }
620 
621  if ( _haslcs ) {
622  if ( localCoordinateSystem == NULL ) {
624  }
625 
626  if ( ( iores = localCoordinateSystem->restoreYourself(stream) ) != CIO_OK ) {
627  THROW_CIOERR(iores);
628  }
629  } else {
630  localCoordinateSystem = NULL;
631  }
632  }
633 
634  return CIO_OK;
635 }
636 
637 
638 #ifdef __OOFEG
639 void
641 //
642 // draws graphics representation of receiver
643 //
644 {
645  GraphicObj *go;
647 
648  if ( ( mode == OGC_nodeGeometry ) || ( mode == OGC_nodeAnnotation ) ) {
649  WCRec p [ 1 ]; /* point */
650  p [ 0 ].x = ( FPNum ) this->giveCoordinate(1);
651  p [ 0 ].y = ( FPNum ) this->giveCoordinate(2);
652  p [ 0 ].z = ( FPNum ) this->giveCoordinate(3);
653 
654  EASValsSetLayer(OOFEG_NODE_ANNOTATION_LAYER);
655  EASValsSetMType(FILLED_CIRCLE_MARKER);
656  #if 1
657  if ( this->giveDomain()->hasXfemManager() ) {
658  XfemManager *xf = this->giveDomain()->giveXfemManager();
659  for ( int i = 1; i <= xf->giveNumberOfEnrichmentItems(); i++ ) {
660  if ( xf->giveEnrichmentItem(i)->isDofManEnriched(* this) ) {
661  EASValsSetMType(SQUARE_MARKER);
662  }
663  }
664  }
665 
666  #endif
667 
668  if ( this->giveParallelMode() == DofManager_local ) {
669  EASValsSetColor( gc.getNodeColor() );
670  } else if ( this->giveParallelMode() == DofManager_shared ) {
671  EASValsSetColor( gc.getDeformedElementColor() );
672  } else {
673  EASValsSetColor( gc.getCrackPatternColor() );
674  }
675 
676  bool ordinary = true;
677 
678  for ( Dof *dof: *this ) {
679  if ( dof->isPrimaryDof() ) {
680  ordinary = false;
681  break;
682  }
683  }
684 
685  if ( !ordinary ) {
686  EASValsSetColor( gc.getBcIcColor() );
687  }
688 
689  EASValsSetMSize(8);
690  go = CreateMarker3D(p);
691  EGWithMaskChangeAttributes(COLOR_MASK | LAYER_MASK | MTYPE_MASK | MSIZE_MASK, go);
692  EMAddGraphicsToModel(ESIModel(), go);
693  }
694 
695  if ( mode == OGC_nodeAnnotation ) {
696  char num [ 30 ];
697  WCRec p [ 1 ]; /* point */
698  EASValsSetColor( gc.getNodeColor() );
699  EASValsSetLayer(OOFEG_NODE_ANNOTATION_LAYER);
700  p [ 0 ].x = ( FPNum ) this->giveCoordinate(1);
701  p [ 0 ].y = ( FPNum ) this->giveCoordinate(2);
702  p [ 0 ].z = ( FPNum ) this->giveCoordinate(3);
703 
704  sprintf( num, "%d(%d)", this->giveNumber(), this->giveGlobalNumber() );
705  go = CreateAnnText3D(p, num);
706  EGWithMaskChangeAttributes(COLOR_MASK | LAYER_MASK, go);
707  EMAddGraphicsToModel(ESIModel(), go);
708  } else if ( mode == OGC_essentialBC ) {
709  int i, hasDisplSupport [ 3 ], hasRotSupport [ 3 ], hasAny = 0;
710  if ( !tStep ) {
711  TimeStep __temp( domain->giveEngngModel() );
712  tStep = & __temp;
713  }
714 
715  WCRec pp [ 2 ];
716 
717  for ( i = 0; i < 3; i++ ) {
718  hasDisplSupport [ i ] = 0;
719  hasRotSupport [ i ] = 0;
720  }
721 
722  for ( Dof *dof: *this ) {
723  if ( dof->hasBc(tStep) ) {
724  hasAny = 1;
725  switch ( dof->giveDofID() ) {
726  case D_u: hasDisplSupport [ 0 ] = 1;
727  break;
728  case D_v: hasDisplSupport [ 1 ] = 1;
729  break;
730  case D_w: hasDisplSupport [ 2 ] = 1;
731  break;
732  case R_u: hasRotSupport [ 0 ] = 1;
733  break;
734  case R_v: hasRotSupport [ 1 ] = 1;
735  break;
736  case R_w: hasRotSupport [ 2 ] = 1;
737  break;
738  default: break;
739  }
740  }
741  }
742 
743  if ( hasAny != 0 ) {
744  EASValsSetColor( gc.getBcIcColor() );
745  EASValsSetLayer(OOFEG_BCIC_ANNOTATION_LAYER);
746  pp [ 0 ].x = ( FPNum ) this->giveCoordinate(1);
747  pp [ 0 ].y = ( FPNum ) this->giveCoordinate(2);
748  pp [ 0 ].z = ( FPNum ) this->giveCoordinate(3);
749 
750  /* primary bc */
751  for ( i = 0; i < 3; i++ ) {
752  if ( hasDisplSupport [ i ] || hasRotSupport [ i ] ) {
753  pp [ 1 ].x = 0.;
754  pp [ 1 ].y = 0.;
755  pp [ 1 ].z = 0.;
756 
757  if ( !this->hasLocalCS() ) {
758  if ( i == 0 ) {
759  pp [ 1 ].x = 1.0;
760  }
761 
762  if ( i == 1 ) {
763  pp [ 1 ].y = 1.0;
764  }
765 
766  if ( i == 2 ) {
767  pp [ 1 ].z = 1.0;
768  }
769  } else {
771  ;
772  pp [ 1 ].x = T->at(i + 1, 1);
773  pp [ 1 ].y = T->at(i + 1, 2);
774  pp [ 1 ].z = T->at(i + 1, 3);
775  }
776 
777 
778  if ( hasDisplSupport [ i ] && hasRotSupport [ i ] ) {
779  EASValsSetVecMType(TRIPLE_ARROW_VECMARKER);
780  }
781 
782  if ( hasDisplSupport [ i ] ) {
783  EASValsSetVecMType(ARROW_VECMARKER);
784  }
785 
786  if ( hasRotSupport [ i ] ) {
787  EASValsSetVecMType(DOUBLE_ARROW_VECMARKER);
788  }
789 
790  go = CreateVecMarker3D(pp);
791  EGWithMaskChangeAttributes(COLOR_MASK | LAYER_MASK | VECMTYPE_MASK, go);
792  EMAddGraphicsToModel(ESIModel(), go);
793  }
794  }
795  }
796  } else if ( mode == OGC_naturalBC ) {
797  if ( !tStep ) {
798  TimeStep __temp( domain->giveEngngModel() );
799  tStep = & __temp;
800  }
801 
802  WCRec pp [ 2 ];
803  /* load */
804  if ( !this->giveLoadArray()->isEmpty() ) {
805  double defScale = gc.getDefScale();
806  pp [ 0 ].x = ( FPNum ) this->giveCoordinate(1);
807  pp [ 0 ].y = ( FPNum ) this->giveCoordinate(2);
808  pp [ 0 ].z = ( FPNum ) this->giveCoordinate(3);
809  pp [ 1 ].x = pp [ 1 ].y = pp [ 1 ].z = 0.0;
810 
811  FloatArray load, f;
812  FloatMatrix t;
813  IntArray dofIDArry(0);
814 
815  load.clear();
816  for ( int iload : *this->giveLoadArray() ) { // to more than one load
817  Load *loadN = domain->giveLoad(iload);
818  this->computeLoadVector(f, loadN, ExternalForcesVector, tStep, VM_Total);
819  load.add(f);
820  }
821  if ( computeL2GTransformation(t, dofIDArry) ) {
822  load.rotatedWith(t, 'n');
823  }
824 
825  FloatArray force(3), momentum(3);
826  int i = 0;
827  for ( Dof *dof: *this ) {
828  i++;
829  switch ( dof->giveDofID() ) {
830  case D_u: force.at(1) = defScale * load.at(i);
831  break;
832  case D_v: force.at(2) = defScale * load.at(i);
833  break;
834  case D_w: force.at(3) = defScale * load.at(i);
835  break;
836  case R_u: momentum.at(1) = defScale * load.at(i);
837  break;
838  case R_v: momentum.at(2) = defScale * load.at(i);
839  break;
840  case R_w: momentum.at(3) = defScale * load.at(i);
841  break;
842  default: break;
843  }
844  }
845 
846  EASValsSetColor( gc.getBcForceColor() );
847  EASValsSetLayer(OOFEG_NATURALBC_LAYER);
848 
849  // draw force
850  EASValsSetVecMType(ARROW_VECMARKER);
851  pp [ 1 ].x = force.at(1);
852  pp [ 1 ].y = force.at(2);
853  pp [ 1 ].z = force.at(3);
854  go = CreateVector3D(pp);
855  EGWithMaskChangeAttributes(COLOR_MASK | LAYER_MASK | VECMTYPE_MASK, go);
856  EMAddGraphicsToModel(ESIModel(), go);
857  // draw moment
858  EASValsSetVecMType(DOUBLE_ARROW_VECMARKER);
859  pp [ 1 ].x = momentum.at(1);
860  pp [ 1 ].y = momentum.at(2);
861  pp [ 1 ].z = momentum.at(3);
862  go = CreateVector3D(pp);
863  EGWithMaskChangeAttributes(COLOR_MASK | LAYER_MASK | VECMTYPE_MASK, go);
864  EMAddGraphicsToModel(ESIModel(), go);
865  }
866  } else if ( mode == OGC_nodeVectorPlot ) {
867  GraphicObj *go;
868 
869  if ( gc.giveIntVarType() == IST_Velocity ) {
870  WCRec p [ 2 ]; /* point */
871  double defScale = gc.getDefScale();
872 
873  p [ 0 ].x = p [ 1 ].x = ( FPNum ) this->giveCoordinate(1);
874  p [ 0 ].y = p [ 1 ].y = ( FPNum ) this->giveCoordinate(2);
875  p [ 0 ].z = p [ 1 ].z = ( FPNum ) this->giveCoordinate(3);
876 
877  //p[1].x = p[1].y = p[1].z = 0.0;
878  for ( Dof *dof: *this ) {
879  if ( dof->giveDofID() == V_u ) {
880  p [ 1 ].x = defScale * dof->giveUnknown(VM_Total, tStep);
881  } else if ( dof->giveDofID() == V_v ) {
882  p [ 1 ].y = defScale * dof->giveUnknown(VM_Total, tStep);
883  } else if ( dof->giveDofID() == V_w ) {
884  p [ 1 ].z = defScale * dof->giveUnknown(VM_Total, tStep);
885  }
886  }
887 
888  EASValsSetColor( gc.getDeformedElementColor() );
889  EASValsSetLayer(OOFEG_DEFORMED_GEOMETRY_LAYER);
890  go = CreateVector3D(p);
891  EGWithMaskChangeAttributes(COLOR_MASK | LAYER_MASK, go);
892  EMAddGraphicsToModel(ESIModel(), go);
893  }
894  }
895 }
896 
897 #endif
898 } // end namespace oofem
Class implementing a concentrated load (force, moment,...) that acts directly on a dof manager (node ...
Definition: nodalload.h:67
void setField(int item, InputFieldType id)
int number
Component number.
Definition: femcmpnn.h:80
void printYourself() const
Prints receiver on stdout.
Definition: intarray.C:225
Class and object Domain.
Definition: domain.h:115
bool isDofManEnriched(const DofManager &iDMan) const
bool hasLocalCS()
Returns nonzero if node has prescribed local coordinate system.
Definition: node.h:150
int giveGlobalNumber() const
Definition: dofmanager.h:501
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition: femcmpnn.h:82
virtual CoordSystType giveCoordSystMode()
Returns receiver&#39;s coordinate system.
Definition: nodalload.h:88
FloatMatrix * localCoordinateSystem
Triplet defining the local coordinate system in node.
Definition: node.h:98
FloatMatrix * giveLocalCoordinateTriplet()
Returns pointer to local coordinate triplet in node.
Definition: node.h:158
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
Definition: intarray.h:208
Load is specified in global c.s.
Definition: load.h:70
contextIOResultType storeYourself(DataStream &stream) const
Definition: floatarray.C:872
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Definition: valuemodetype.h:78
virtual int checkConsistency()
Allows programmer to test some internal data, before computation begins.
Definition: node.C:325
virtual const IntArray & giveDofIDs() const
Array with default dofs which b.c.
Updated Lagrange.
Definition: fmode.h:45
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Definition: dofmanager.C:458
void clear()
Clears receiver (zero size).
Definition: floatarray.h:206
virtual void computeLoadVector(FloatArray &answer, Load *load, CharType type, TimeStep *tStep, ValueModeType mode)
Computes the load vector for given load.
Definition: node.C:178
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)=0
The key method of class Dof.
EngngModel * giveEngngModel()
Returns engineering model to which receiver is associated.
Definition: domain.C:433
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: node.C:599
virtual void giveUpdatedCoordinates(FloatArray &answer, TimeStep *tStep, double scale=1.)
Returns updated coordinate of receiver.
Definition: node.C:308
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
Base class for dof managers.
Definition: dofmanager.h:113
General IO error.
virtual void drawYourself(oofegGraphicContext &gc, TimeStep *tStep)
Definition: node.C:640
virtual void computeComponentArrayAt(FloatArray &answer, TimeStep *tStep, ValueModeType mode)
Computes boundary condition value - its components values at given time.
Definition: load.C:82
virtual double giveCoordinate(int i)
Definition: node.C:82
virtual void printYourself()
Prints the receiver state on stdout.
Definition: dof.C:107
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Definition: node.C:165
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: node.C:93
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
virtual int read(int *data, int count)=0
Reads count integer values into array pointed by data.
XfemManager * giveXfemManager()
Definition: domain.C:375
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
#define OOFEG_DEFORMED_GEOMETRY_LAYER
bool hasSameLCS(Node *remote)
Returns true, if the local coordinate systems of receiver and given node are the same.
Definition: node.C:387
contextIOResultType storeYourself(DataStream &stream) const
Definition: floatmatrix.C:1852
void rotatedWith(FloatMatrix &r, char mode)
Returns the receiver a rotated according the change-of-base matrix r.
Definition: floatarray.C:799
virtual void printYourself()
Prints receiver state on stdout. Useful for debugging.
Definition: node.C:207
double giveTimeIncrement()
Returns solution step associated time increment.
Definition: timestep.h:150
int giveNumberOfEnrichmentItems() const
Definition: xfemmanager.h:185
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: dofmanager.C:326
virtual int write(const int *data, int count)=0
Writes count integer values from array pointed by data.
int giveMasterDofManagerNum() const
Returns Master Dof Manager Number.
InternalStateType giveIntVarType()
Concentrated nodal load.
Definition: bcgeomtype.h:42
virtual bcGeomType giveBCGeoType() const
Returns geometry character of boundary condition.
Definition: nodalload.h:93
int giveNumberOfDofs() const
Definition: dofmanager.C:279
void giveUnknownVectorOfType(FloatArray &answer, UnknownType ut, ValueModeType mode, TimeStep *tStep)
Constructs the requested vector by assembling e.g.
Definition: dofmanager.C:766
virtual int checkConsistency()
Allows programmer to test some internal data, before computation begins.
Definition: femcmpnn.C:94
virtual void updateYourself(TimeStep *tStep)
Updates receiver at end of time step (i.e.
Definition: node.C:222
REGISTER_DofManager(ElementSide)
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual double giveVariableScale(VarScaleType varId)
Returns the scale factor for given variable type.
Definition: engngm.h:1087
DofIDItem
Type representing particular dof type.
Definition: dofiditem.h:86
virtual ~Node()
Destructor.
Definition: node.C:75
contextIOResultType restoreYourself(DataStream &stream)
Definition: floatarray.C:895
DofIDItem giveDofID() const
Returns DofID value of receiver, which determines type of of unknown connected to receiver (e...
Definition: dof.h:276
virtual bool isPrimaryDof()
Tests if receiver is primary DOF.
Definition: dof.h:287
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Definition: node.C:565
virtual fMode giveFormulation()
Indicates type of non linear computation (total or updated formulation).
Definition: engngm.h:1069
virtual double giveUpdatedCoordinate(int ic, TimeStep *tStep, double scale=1.)
Returns updated ic-th coordinate of receiver.
Definition: node.C:245
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
Node(int n, Domain *aDomain)
Constructor.
Definition: node.C:68
IntArray loadArray
List of applied loads.
Definition: dofmanager.h:119
FloatArray coordinates
Array storing nodal coordinates.
Definition: node.h:91
contextIOResultType restoreYourself(DataStream &stream)
Definition: floatmatrix.C:1877
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Definition: dofmanager.C:543
bool isTheCurrentTimeStep()
Check if receiver is current solution step.
Definition: timestep.C:155
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
This class manages the xfem part.
Definition: xfemmanager.h:109
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
#define OOFEG_NODE_ANNOTATION_LAYER
Class representing "slave" degree of freedom.
CharType
Definition: chartype.h:87
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
Class representing the general Input Record.
Definition: inputrecord.h:101
virtual bool giveEquationScalingFlag()
Returns the Equation scaling flag, which is used to indicate that governing equation(s) are scaled...
Definition: engngm.h:1085
fMode
Type representing the type of formulation (total or updated) of non-linear computation.
Definition: fmode.h:42
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
Class representing the a dynamic Input Record.
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
#define _IFT_Node_coords
Definition: node.h:50
EnrichmentItem * giveEnrichmentItem(int n)
Definition: xfemmanager.h:184
std::string __DofIDItemToString(DofIDItem _value)
Definition: cltypes.C:330
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
#define CM_Definition
Definition: contextmode.h:47
IntArray * giveLoadArray()
Returns the array containing applied loadings of the receiver.
Definition: dofmanager.C:82
void zero()
Zeroes all coefficient of receiver.
Definition: floatmatrix.C:1326
virtual bool hasBc(TimeStep *tStep)=0
Test if Dof has active boundary condition.
Domain * giveDomain() const
Definition: femcmpnn.h:100
Load is base abstract class for all loads.
Definition: load.h:61
int giveSize() const
Definition: intarray.h:203
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
virtual bool computeL2GTransformation(FloatMatrix &answer, const IntArray &dofIDArry)
Computes transformation matrix from global c.s.
Definition: node.C:424
the oofem namespace is to define a context or scope in which all oofem names are defined.
void clear()
Sets size of receiver to be an empty matrix. It will have zero rows and zero columns size...
Definition: floatmatrix.h:516
Class implementing node in finite element mesh.
Definition: node.h:87
#define OOFEG_NATURALBC_LAYER
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
int giveNumber() const
Definition: femcmpnn.h:107
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:314
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition: floatmatrix.h:156
Load * giveLoad(int n)
Service for accessing particular domain load.
Definition: domain.C:222
DofManager is local, there are no contribution from other domains to this DofManager.
Definition: dofmanager.h:81
virtual void updateYourself(TimeStep *tStep)
Updates receiver after equilibrium in time step has been reached.
Definition: dofmanager.C:534
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: dofmanager.C:611
#define OOFEM_WARNING(...)
Definition: error.h:62
Class representing solution step.
Definition: timestep.h:80
DofManager is shared by neighboring partitions, it is necessary to sum contributions from all contrib...
Definition: dofmanager.h:82
dofManagerParallelMode giveParallelMode() const
Return dofManagerParallelMode of receiver.
Definition: dofmanager.h:512
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
#define _IFT_Node_lcs
Definition: node.h:51
#define OOFEG_BCIC_ANNOTATION_LAYER
OGC_PlotModeType giveIntVarPlotMode()

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011