OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
rotatingboundary.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 "rotatingboundary.h"
36 #include "dofmanager.h"
37 #include "dof.h"
38 #include "mathfem.h"
39 #include "function.h"
40 #include "classfactory.h"
41 #include "dynamicinputrecord.h"
42 
43 namespace oofem {
44 REGISTER_BoundaryCondition(RotatingBoundary);
45 
46 double RotatingBoundary :: give(Dof *dof, ValueModeType mode, double time)
47 {
48  DofIDItem id = dof->giveDofID();
49  FloatArray *coords = dof->giveDofManager()->giveCoordinates();
50  FloatArray answer, newcoords;
51  double theta = 0.;
52 
53  if ( mode == VM_Total ) {
54  theta = this->giveTimeFunction()->evaluateAtTime(time);
55  } else if ( mode == VM_Velocity ) {
56  theta = this->giveTimeFunction()->evaluateVelocityAtTime(time);
57  } else if ( mode == VM_Acceleration ) {
58  theta = this->giveTimeFunction()->evaluateAccelerationAtTime(time);
59  } else {
60  OOFEM_ERROR("Should not be called for value mode type then total, velocity, or acceleration.");
61  }
62 
63  if ( axis.giveSize() != 3 ) {
64  OOFEM_ERROR("Size of rotation axis != 3.");
65  }
66 
67  if ( center.giveSize() == 0 ) {
68  center.resize( coords->giveSize() );
69  center.zero();
70  }
71 
72  if ( coords == NULL || coords->giveSize() != center.giveSize() ) {
73  OOFEM_ERROR("Size of coordinate system different from center of rotation.");
74  }
75 
76  double &nx = axis.at(1);
77  double &ny = axis.at(2);
78  double &nz = axis.at(3);
79 
80  if ( coords->giveSize() == 1 ) {
81  R.resize(1, 1);
82  R.at(1, 1) = cos(theta) + nx * nx * ( 1 - cos(theta) );
83  }
84  if ( coords->giveSize() == 2 ) {
85  R.resize(2, 2);
86  R.at(1, 1) = cos(theta) + nx * nx * ( 1 - cos(theta) );
87  R.at(1, 2) = nx * ny * ( 1 - cos(theta) ) - nz *sin(theta);
88  R.at(2, 1) = ny * nx * ( 1 - cos(theta) ) + nz *sin(theta);
89  R.at(2, 2) = cos(theta) + ny * ny * ( 1 - cos(theta) );
90  } else if ( coords->giveSize() == 3 ) {
91  R.resize(3, 3);
92 
93  R.at(1, 1) = cos(theta) + nx * nx * ( 1 - cos(theta) );
94  R.at(1, 2) = nx * ny * ( 1 - cos(theta) ) - nz *sin(theta);
95  R.at(1, 3) = nx * nz * ( 1 - cos(theta) ) + ny *sin(theta);
96 
97  R.at(2, 1) = ny * nx * ( 1 - cos(theta) ) + nz *sin(theta);
98  R.at(2, 2) = cos(theta) + ny * ny * ( 1 - cos(theta) );
99  R.at(2, 3) = ny * nz * ( 1 - cos(theta) ) - nx *sin(theta);
100 
101  R.at(3, 1) = nz * nx * ( 1 - cos(theta) ) - ny *sin(theta);
102  R.at(3, 2) = nz * ny * ( 1 - cos(theta) ) + nx *sin(theta);
103  R.at(3, 3) = cos(theta) + nz * nz * ( 1 - cos(theta) );
104  } else {
105  OOFEM_ERROR("Size of coordinate system has to be 1, 2 or 3.");
106  }
107 
108  newcoords.beDifferenceOf(center, *coords);
109  answer.beProductOf(R, newcoords);
110  answer.add(center);
111  answer.subtract(* coords);
112 
113  switch ( id ) {
114  case D_u:
115  return answer.at(1);
116 
117  case D_v:
118  return answer.at(2);
119 
120  case D_w:
121  return answer.at(3);
122 
123  default:
124  return 0.0;
125  }
126 }
127 
130 {
131  IRResultType result; // Required by IR_GIVE_FIELD macro
132 
134  axis.normalize();
135 
137 
139 }
140 
141 void
143 {
147 }
148 } // end namespace oofem
void setField(int item, InputFieldType id)
void subtract(const FloatArray &src)
Subtracts array src to receiver.
Definition: floatarray.C:258
REGISTER_BoundaryCondition(BoundaryCondition)
virtual double evaluateAccelerationAtTime(double t)=0
Returns the second time derivative of the function at given time.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
FloatMatrix R
Rotation matrix.
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Definition: valuemodetype.h:78
#define _IFT_RotatingBoundary_center
virtual FloatArray * giveCoordinates()
Definition: dofmanager.h:382
void beDifferenceOf(const FloatArray &a, const FloatArray &b)
Sets receiver to be a - b.
Definition: floatarray.C:341
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
#define OOFEM_ERROR(...)
Definition: error.h:61
DofIDItem
Type representing particular dof type.
Definition: dofiditem.h:86
DofIDItem giveDofID() const
Returns DofID value of receiver, which determines type of of unknown connected to receiver (e...
Definition: dof.h:276
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Receiver becomes the result of the product of aMatrix and anArray.
Definition: floatarray.C:676
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
FloatArray axis
Axis and center of rotation.
virtual double evaluateVelocityAtTime(double t)=0
Returns the first time derivative of the function at given time.
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Class representing the general Input Record.
Definition: inputrecord.h:101
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
Class representing the a dynamic Input Record.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
DofManager * giveDofManager() const
Definition: dof.h:123
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
#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
double normalize()
Normalizes receiver.
Definition: floatarray.C:828
#define _IFT_RotatingBoundary_axis
virtual double evaluateAtTime(double t)
Returns the value of the function at given time.
Definition: function.C:76
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
virtual double give(Dof *dof, ValueModeType mode, double time)
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

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:31 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011