OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
qplanstrss.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 #include "../sm/Elements/PlaneStress/qplanstrss.h"
36 #include "fei2dquadquad.h"
37 #include "crosssection.h"
38 #include "gausspoint.h"
39 #include "gaussintegrationrule.h"
40 #include "floatmatrix.h"
41 #include "floatarray.h"
42 #include "intarray.h"
43 #include "mathfem.h"
44 #include "classfactory.h"
45 
46 #ifdef __OOFEG
47  #include "oofeggraphiccontext.h"
48 #endif
49 
50 namespace oofem {
51 REGISTER_Element(QPlaneStress2d);
52 
53 FEI2dQuadQuad QPlaneStress2d :: interpolation(1, 2);
54 
57  // Constructor.
58 {
59  numberOfDofMans = 8;
61 }
62 
63 Interface *
65 {
66  if ( interface == ZZNodalRecoveryModelInterfaceType ) {
67  return static_cast< ZZNodalRecoveryModelInterface * >(this);
68  } else if ( interface == NodalAveragingRecoveryModelInterfaceType ) {
69  return static_cast< NodalAveragingRecoveryModelInterface * >(this);
70  }
71 
72  return NULL;
73 }
74 
76 
77 
78 
79 #ifdef __OOFEG
81 {
82  WCRec p [ 4 ];
83  GraphicObj *go;
84 
85  if ( !gc.testElementGraphicActivity(this) ) {
86  return;
87  }
88 
89  EASValsSetLineWidth(OOFEG_RAW_GEOMETRY_WIDTH);
90  EASValsSetColor( gc.getElementColor() );
91  EASValsSetEdgeColor( gc.getElementEdgeColor() );
92  EASValsSetEdgeFlag(true);
93  EASValsSetLayer(OOFEG_RAW_GEOMETRY_LAYER);
94  EASValsSetFillStyle(FILL_HOLLOW);
95  p [ 0 ].x = ( FPNum ) this->giveNode(1)->giveCoordinate(1);
96  p [ 0 ].y = ( FPNum ) this->giveNode(1)->giveCoordinate(2);
97  p [ 0 ].z = 0.;
98  p [ 1 ].x = ( FPNum ) this->giveNode(2)->giveCoordinate(1);
99  p [ 1 ].y = ( FPNum ) this->giveNode(2)->giveCoordinate(2);
100  p [ 1 ].z = 0.;
101  p [ 2 ].x = ( FPNum ) this->giveNode(3)->giveCoordinate(1);
102  p [ 2 ].y = ( FPNum ) this->giveNode(3)->giveCoordinate(2);
103  p [ 2 ].z = 0.;
104  p [ 3 ].x = ( FPNum ) this->giveNode(4)->giveCoordinate(1);
105  p [ 3 ].y = ( FPNum ) this->giveNode(4)->giveCoordinate(2);
106  p [ 3 ].z = 0.;
107 
108  go = CreateQuad3D(p);
109  EGWithMaskChangeAttributes(WIDTH_MASK | FILL_MASK | COLOR_MASK | EDGE_COLOR_MASK | EDGE_FLAG_MASK | LAYER_MASK, go);
110  EGAttachObject(go, ( EObjectP ) this);
111  EMAddGraphicsToModel(ESIModel(), go);
112 }
113 
114 
116 {
117  WCRec p [ 4 ];
118  GraphicObj *go;
119  double defScale = gc.getDefScale();
120 
121  if ( !gc.testElementGraphicActivity(this) ) {
122  return;
123  }
124 
125  EASValsSetLineWidth(OOFEG_DEFORMED_GEOMETRY_WIDTH);
126  EASValsSetColor( gc.getDeformedElementColor() );
127  EASValsSetEdgeColor( gc.getElementEdgeColor() );
128  EASValsSetEdgeFlag(true);
129  EASValsSetLayer(OOFEG_DEFORMED_GEOMETRY_LAYER);
130  EASValsSetFillStyle(FILL_HOLLOW);
131  p [ 0 ].x = ( FPNum ) this->giveNode(1)->giveUpdatedCoordinate(1, tStep, defScale);
132  p [ 0 ].y = ( FPNum ) this->giveNode(1)->giveUpdatedCoordinate(2, tStep, defScale);
133  p [ 0 ].z = 0.;
134  p [ 1 ].x = ( FPNum ) this->giveNode(2)->giveUpdatedCoordinate(1, tStep, defScale);
135  p [ 1 ].y = ( FPNum ) this->giveNode(2)->giveUpdatedCoordinate(2, tStep, defScale);
136  p [ 1 ].z = 0.;
137  p [ 2 ].x = ( FPNum ) this->giveNode(3)->giveUpdatedCoordinate(1, tStep, defScale);
138  p [ 2 ].y = ( FPNum ) this->giveNode(3)->giveUpdatedCoordinate(2, tStep, defScale);
139  p [ 2 ].z = 0.;
140  p [ 3 ].x = ( FPNum ) this->giveNode(4)->giveUpdatedCoordinate(1, tStep, defScale);
141  p [ 3 ].y = ( FPNum ) this->giveNode(4)->giveUpdatedCoordinate(2, tStep, defScale);
142  p [ 3 ].z = 0.;
143 
144  go = CreateQuad3D(p);
145  EGWithMaskChangeAttributes(WIDTH_MASK | FILL_MASK | COLOR_MASK | EDGE_COLOR_MASK | EDGE_FLAG_MASK | LAYER_MASK, go);
146  EMAddGraphicsToModel(ESIModel(), go);
147 }
148 
149 
151 {
152  int i, indx, n [ 4 ], result = 0;
153  WCRec p [ 4 ], pp [ 9 ];
154  GraphicObj *tr;
155  FloatArray v [ 8 ];
156  double s [ 9 ], ss [ 4 ], defScale;
157 
158  if ( !gc.testElementGraphicActivity(this) ) {
159  return;
160  }
161 
162  EASValsSetLayer(OOFEG_VARPLOT_PATTERN_LAYER);
163  if ( gc.giveIntVarMode() == ISM_recovered ) {
164  // ============ plot the recovered values (smoothed data) ===============
165  for ( i = 1; i <= 8; i++ ) {
166  result += this->giveInternalStateAtNode(v [ i - 1 ], gc.giveIntVarType(), gc.giveIntVarMode(), i, tStep);
167  }
168 
169  if ( result != 8 ) {
170  return;
171  }
172 
173  indx = gc.giveIntVarIndx();
174 
175  for ( i = 1; i <= 8; i++ ) {
176  s [ i - 1 ] = v [ i - 1 ].at(indx);
177  }
178 
179  // auxiliary value at an added central node
180  // computed as average of the values at all Gauss points
181 
182  s [ 8 ] = 0.;
183  for ( GaussPoint *gp: *this->giveDefaultIntegrationRulePtr() ) {
184  if ( giveIPValue(v [ 0 ], gp, gc.giveIntVarType(), tStep) == 0 ) {
185  return;
186  }
187 
188  s [ 8 ] += v [ 0 ].at(indx);
189  }
190 
191  s [ 8 ] /= integrationRulesArray [ 0 ]->giveNumberOfIntegrationPoints();
192  //s[8] = (s[4]+s[5]+s[6]+s[7])/4.;
193 
194  for ( i = 0; i < 8; i++ ) {
195  if ( gc.getInternalVarsDefGeoFlag() ) {
196  // use deformed geometry
197  defScale = gc.getDefScale();
198  pp [ i ].x = ( FPNum ) this->giveNode(i + 1)->giveUpdatedCoordinate(1, tStep, defScale);
199  pp [ i ].y = ( FPNum ) this->giveNode(i + 1)->giveUpdatedCoordinate(2, tStep, defScale);
200  pp [ i ].z = 0.;
201  } else {
202  // use initial geometry
203  pp [ i ].x = ( FPNum ) this->giveNode(i + 1)->giveCoordinate(1);
204  pp [ i ].y = ( FPNum ) this->giveNode(i + 1)->giveCoordinate(2);
205  pp [ i ].z = 0.;
206  }
207  }
208 
209  pp [ 8 ].x = ( pp [ 4 ].x + pp [ 5 ].x + pp [ 6 ].x + pp [ 7 ].x ) / 4.;
210  pp [ 8 ].y = ( pp [ 4 ].y + pp [ 5 ].y + pp [ 6 ].y + pp [ 7 ].y ) / 4.;
211  pp [ 8 ].z = 0.;
212 
213 
214  for ( int t = 1; t <= 4; t++ ) {
215  if ( t == 1 ) {
216  n [ 0 ] = 0;
217  n [ 1 ] = 4;
218  n [ 2 ] = 8;
219  n [ 3 ] = 7;
220  } else if ( t == 2 ) {
221  n [ 0 ] = 4;
222  n [ 1 ] = 1;
223  n [ 2 ] = 5;
224  n [ 3 ] = 8;
225  } else if ( t == 3 ) {
226  n [ 0 ] = 5;
227  n [ 1 ] = 2;
228  n [ 2 ] = 6;
229  n [ 3 ] = 8;
230  } else {
231  n [ 0 ] = 6;
232  n [ 1 ] = 3;
233  n [ 2 ] = 7;
234  n [ 3 ] = 8;
235  }
236 
237  ss [ 0 ] = s [ n [ 0 ] ];
238  ss [ 1 ] = s [ n [ 1 ] ];
239  ss [ 2 ] = s [ n [ 2 ] ];
240  ss [ 3 ] = s [ n [ 3 ] ];
241 
242 
243  for ( i = 0; i < 4; i++ ) {
244  p [ i ].x = pp [ n [ i ] ].x;
245  p [ i ].y = pp [ n [ i ] ].y;
246  p [ i ].z = 0.;
247  }
248 
249  if ( gc.getScalarAlgo() == SA_ISO_SURF ) {
250  /*
251  * for ( i = 0; i < 4; i++ ) {
252  * if ( gc.getInternalVarsDefGeoFlag() ) {
253  * // use deformed geometry
254  * defScale = gc.getDefScale();
255  * p [ i ].x = ( FPNum ) this->giveNode(n[i] + 1)->giveUpdatedCoordinate(1, tStep, defScale);
256  * p [ i ].y = ( FPNum ) this->giveNode(n[i] + 1)->giveUpdatedCoordinate(2, tStep, defScale);
257  * p [ i ].z = 0.;
258  * } else {
259  * // use initial geometry
260  * p [ i ].x = ( FPNum ) this->giveNode(n[i] + 1)->giveCoordinate(1);
261  * p [ i ].y = ( FPNum ) this->giveNode(n[i] + 1)->giveCoordinate(2);
262  * p [ i ].z = 0.;
263  * }
264  * }
265  */
266  //EASValsSetColor(gc.getYieldPlotColor(ratio));
267  gc.updateFringeTableMinMax(ss, 4);
268  tr = CreateQuadWD3D(p, ss [ 0 ], ss [ 1 ], ss [ 2 ], ss [ 3 ]);
269  EGWithMaskChangeAttributes(LAYER_MASK, tr);
270  EMAddGraphicsToModel(ESIModel(), tr);
271  } else if ( ( gc.getScalarAlgo() == SA_ZPROFILE ) || ( gc.getScalarAlgo() == SA_COLORZPROFILE ) ) {
272  //double landScale = gc.getLandScale();
273 
274  for ( i = 0; i < 4; i++ ) {
275  /*
276  * if ( gc.getInternalVarsDefGeoFlag() ) {
277  * // use deformed geometry
278  * defScale = gc.getDefScale();
279  * p [ i ].x = ( FPNum ) this->giveNode(i + 1)->giveUpdatedCoordinate(1, tStep, defScale);
280  * p [ i ].y = ( FPNum ) this->giveNode(i + 1)->giveUpdatedCoordinate(2, tStep, defScale);
281  * p [ i ].z = ss [ i ] * landScale;
282  * } else {
283  * // use initial geometry
284  * p [ i ].x = ( FPNum ) this->giveNode(i + 1)->giveCoordinate(1);
285  * p [ i ].y = ( FPNum ) this->giveNode(i + 1)->giveCoordinate(2);
286  * p [ i ].z = ss [ i ] * landScale;
287  * }
288  */
289 
290  // this fixes a bug in ELIXIR
291  if ( fabs(ss [ i ]) < 1.0e-6 ) {
292  ss [ i ] = 1.0e-6;
293  }
294  }
295 
296  if ( gc.getScalarAlgo() == SA_ZPROFILE ) {
297  EASValsSetColor( gc.getDeformedElementColor() );
298  EASValsSetLineWidth(OOFEG_DEFORMED_GEOMETRY_WIDTH);
299  tr = CreateQuad3D(p);
300  EGWithMaskChangeAttributes(WIDTH_MASK | COLOR_MASK | LAYER_MASK, tr);
301  } else {
302  gc.updateFringeTableMinMax(s, 4);
303  tr = CreateQuadWD3D(p, ss [ 0 ], ss [ 1 ], ss [ 2 ], ss [ 3 ]);
304  EGWithMaskChangeAttributes(LAYER_MASK, tr);
305  }
306 
307  EMAddGraphicsToModel(ESIModel(), tr);
308  }
309  }
310  } else if ( gc.giveIntVarMode() == ISM_local ) {
311  // ========== plot the local values (raw data) =====================
312  if ( numberOfGaussPoints != 4 ) {
313  return;
314  }
315 
316  IntArray ind(4);
317  WCRec pp [ 9 ];
318 
319  for ( i = 0; i < 8; i++ ) {
320  if ( gc.getInternalVarsDefGeoFlag() ) {
321  // use deformed geometry
322  defScale = gc.getDefScale();
323  pp [ i ].x = ( FPNum ) this->giveNode(i + 1)->giveUpdatedCoordinate(1, tStep, defScale);
324  pp [ i ].y = ( FPNum ) this->giveNode(i + 1)->giveUpdatedCoordinate(2, tStep, defScale);
325  pp [ i ].z = 0.;
326  } else {
327  pp [ i ].x = ( FPNum ) this->giveNode(i + 1)->giveCoordinate(1);
328  pp [ i ].y = ( FPNum ) this->giveNode(i + 1)->giveCoordinate(2);
329  pp [ i ].z = 0.;
330  }
331  }
332 
333  pp [ 8 ].x = 0.25 * ( pp [ 0 ].x + pp [ 1 ].x + pp [ 2 ].x + pp [ 3 ].x );
334  pp [ 8 ].y = 0.25 * ( pp [ 0 ].y + pp [ 1 ].y + pp [ 2 ].y + pp [ 3 ].y );
335  pp [ 8 ].z = 0.;
336 
337  for ( GaussPoint *gp: *this->giveDefaultIntegrationRulePtr() ) {
338  const FloatArray& gpCoords = gp->giveNaturalCoordinates();
339  if ( ( gpCoords.at(1) > 0. ) && ( gpCoords.at(2) > 0. ) ) {
340  ind.at(1) = 0;
341  ind.at(2) = 4;
342  ind.at(3) = 8;
343  ind.at(4) = 7;
344  } else if ( ( gpCoords.at(1) < 0. ) && ( gpCoords.at(2) > 0. ) ) {
345  ind.at(1) = 4;
346  ind.at(2) = 1;
347  ind.at(3) = 5;
348  ind.at(4) = 8;
349  } else if ( ( gpCoords.at(1) < 0. ) && ( gpCoords.at(2) < 0. ) ) {
350  ind.at(1) = 5;
351  ind.at(2) = 2;
352  ind.at(3) = 6;
353  ind.at(4) = 8;
354  } else {
355  ind.at(1) = 6;
356  ind.at(2) = 3;
357  ind.at(3) = 7;
358  ind.at(4) = 8;
359  }
360 
361  if ( giveIPValue(v [ 0 ], gp, gc.giveIntVarType(), tStep) == 0 ) {
362  return;
363  }
364 
365  indx = gc.giveIntVarIndx();
366 
367  for ( i = 1; i <= 4; i++ ) {
368  s [ i - 1 ] = v [ 0 ].at(indx);
369  }
370 
371  for ( i = 0; i < 4; i++ ) {
372  p [ i ].x = pp [ ind.at(i + 1) ].x;
373  p [ i ].y = pp [ ind.at(i + 1) ].y;
374  p [ i ].z = pp [ ind.at(i + 1) ].z;
375  }
376 
377  gc.updateFringeTableMinMax(s, 4);
378  tr = CreateQuadWD3D(p, s [ 0 ], s [ 1 ], s [ 2 ], s [ 3 ]);
379  EGWithMaskChangeAttributes(LAYER_MASK, tr);
380  EMAddGraphicsToModel(ESIModel(), tr);
381  }
382  }
383 }
384 #endif
385 
386 void
388  InternalStateType type, TimeStep *tStep)
389 {
390  if ( numberOfGaussPoints != 4 ) {
391  return;
392  }
393 
394  GaussPoint *gp;
395 
396  if ( node < 5 ) {
397  int i = 0;
398  switch ( node ) {
399  case 1: i = 4;
400  break;
401  case 2: i = 2;
402  break;
403  case 3: i = 1;
404  break;
405  case 4: i = 3;
406  break;
407  }
408 
409  gp = integrationRulesArray [ 0 ]->getIntegrationPoint(i - 1);
410  this->giveIPValue(answer, gp, type, tStep);
411  } else {
412  int i1 = 0, i2 = 0;
413  switch ( node ) {
414  case 5: i1 = 4;
415  i2 = 2;
416  break;
417  case 6: i1 = 2;
418  i2 = 1;
419  break;
420  case 7: i1 = 1;
421  i2 = 3;
422  break;
423  case 8: i1 = 3;
424  i2 = 4;
425  break;
426  }
427 
428  FloatArray contrib;
429  gp = integrationRulesArray [ 0 ]->getIntegrationPoint(i1 - 1);
430  this->giveIPValue(contrib, gp, type, tStep);
431  gp = integrationRulesArray [ 0 ]->getIntegrationPoint(i2 - 1);
432  this->giveIPValue(answer, gp, type, tStep);
433  answer.add(contrib);
434  answer.times(0.5);
435  }
436 }
437 
438 
439 } // end namespace oofem
int testElementGraphicActivity(Element *)
Test if particular element passed fulfills various filtering criteria for its graphics output...
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
The element interface required by NodalAvergagingRecoveryModel.
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in full form.
Class and object Domain.
Definition: domain.h:115
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Access method for default integration rule.
Definition: element.h:822
ScalarAlgorithmType getScalarAlgo()
The element interface required by ZZNodalRecoveryModel.
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
virtual int giveInternalStateAtNode(FloatArray &answer, InternalStateType type, InternalStateMode mode, int node, TimeStep *tStep)
Returns internal state variable (like stress,strain) at node of element in Reduced form...
virtual Interface * giveInterface(InterfaceType it)
Interface requesting service.
Definition: qplanstrss.C:64
#define OOFEG_RAW_GEOMETRY_LAYER
virtual void drawRawGeometry(oofegGraphicContext &gc, TimeStep *tStep)
Definition: qplanstrss.C:80
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]
virtual double giveCoordinate(int i)
Definition: node.C:82
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
#define OOFEG_DEFORMED_GEOMETRY_LAYER
Class representing a general abstraction for finite element interpolation class.
Definition: feinterpol.h:132
InternalStateType giveIntVarType()
virtual void drawScalar(oofegGraphicContext &gc, TimeStep *tStep)
Definition: qplanstrss.C:150
virtual FEInterpolation * giveInterpolation() const
Definition: qplanstrss.C:75
REGISTER_Element(LSpace)
#define OOFEG_RAW_GEOMETRY_WIDTH
UnknownType
Type representing particular unknown (its physical meaning).
Definition: unknowntype.h:55
virtual double giveUpdatedCoordinate(int ic, TimeStep *tStep, double scale=1.)
Returns updated ic-th coordinate of receiver.
Definition: node.C:245
virtual void drawDeformedGeometry(oofegGraphicContext &gc, TimeStep *tStep, UnknownType)
Definition: qplanstrss.C:115
int numberOfGaussPoints
Number of integration points as specified by nip.
Definition: element.h:188
InternalStateMode giveIntVarMode()
Class representing vector of real numbers.
Definition: floatarray.h:82
Class Interface.
Definition: interface.h:82
#define OOFEG_DEFORMED_GEOMETRY_WIDTH
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
std::vector< std::unique_ptr< IntegrationRule > > integrationRulesArray
List of integration rules of receiver (each integration rule contains associated integration points a...
Definition: element.h:170
static FEI2dQuadQuad interpolation
Definition: qplanstrss.h:55
InterfaceType
Enumerative type, used to identify interface type.
Definition: interfacetype.h:43
void updateFringeTableMinMax(double *s, int size)
the oofem namespace is to define a context or scope in which all oofem names are defined.
Node * giveNode(int i) const
Returns reference to the i-th node of element.
Definition: element.h:610
#define OOFEG_VARPLOT_PATTERN_LAYER
Class representing integration point in finite element program.
Definition: gausspoint.h:93
QPlaneStress2d(int n, Domain *d)
Definition: qplanstrss.C:55
Class representing solution step.
Definition: timestep.h:80
int numberOfDofMans
Number of dofmanagers.
Definition: element.h:149
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
virtual void NodalAveragingRecoveryMI_computeNodalValue(FloatArray &answer, int node, InternalStateType type, TimeStep *tStep)
Computes the element value in given node.
Definition: qplanstrss.C:387

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