OOFEM 3.0
Loading...
Searching...
No Matches
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 - 2025 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
43namespace oofem {
45
46double RotatingBoundary :: give(Dof *dof, ValueModeType mode, double time)
47{
48 DofIDItem id = dof->giveDofID();
49 const auto &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.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
128void
129RotatingBoundary :: initializeFrom(InputRecord &ir)
130{
131 GeneralBoundaryCondition :: initializeFrom(ir);
132
134 axis.normalize();
135
137}
138
139void
140RotatingBoundary :: giveInputRecord(DynamicInputRecord &input)
141{
142 GeneralBoundaryCondition :: giveInputRecord(input);
145}
146} // end namespace oofem
#define REGISTER_BoundaryCondition(class)
const FloatArray & giveCoordinates() const
Definition dofmanager.h:390
DofIDItem giveDofID() const
Definition dof.h:276
DofManager * giveDofManager() const
Definition dof.h:123
void setField(int item, InputFieldType id)
double & at(Index i)
Definition floatarray.h:202
void beDifferenceOf(const FloatArray &a, const FloatArray &b)
Definition floatarray.C:403
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Definition floatarray.C:689
void add(const FloatArray &src)
Definition floatarray.C:218
void subtract(const FloatArray &src)
Definition floatarray.C:320
FloatArray axis
Axis and center of rotation.
FloatMatrix R
Rotation matrix.
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
#define _IFT_RotatingBoundary_center
#define _IFT_RotatingBoundary_axis

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011