FreeFOAM The Cross-Platform CFD Toolkit
fixedOrientation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fixedOrientation.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace sixDoFRigidBodyMotionConstraints
35 {
36  defineTypeNameAndDebug(fixedOrientation, 0);
38  (
39  sixDoFRigidBodyMotionConstraint,
40  fixedOrientation,
41  dictionary
42  );
43 };
44 };
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const dictionary& sDoFRBMCDict
52 )
53 :
55 {
56  read(sDoFRBMCDict);
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
61 
63 {}
64 
65 
66 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
67 
69 (
70  const sixDoFRigidBodyMotion& motion,
71  const vector& existingConstraintForce,
72  const vector& existingConstraintMoment,
73  scalar deltaT,
74  vector& constraintPosition,
75  vector& constraintForceIncrement,
76  vector& constraintMomentIncrement
77 ) const
78 {
79  constraintMomentIncrement = vector::zero;
80 
81  scalar maxTheta = -SMALL;
82 
83  for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
84  {
85  vector axis = vector::zero;
86 
87  axis[cmpt] = 1;
88 
89  vector refDir = vector::zero;
90 
91  refDir[(cmpt + 1) % 3] = 1;
92 
93  vector predictedDir = motion.predictedOrientation
94  (
95  refDir,
96  existingConstraintMoment,
97  deltaT
98  );
99 
100  // Removing any axis component from predictedDir
101  predictedDir -= (axis & predictedDir)*axis;
102 
103  scalar theta = GREAT;
104 
105  scalar magPredictedDir = mag(predictedDir);
106 
107  if (magPredictedDir > VSMALL)
108  {
109  predictedDir /= magPredictedDir;
110 
111  theta = acos(min(predictedDir & refDir, 1.0));
112 
113  // Recalculating axis to give correct sign to angle
114  axis = (refDir ^ predictedDir);
115 
116  scalar magAxis = mag(axis);
117 
118  if (magAxis > VSMALL)
119  {
120  axis /= magAxis;
121  }
122  else
123  {
124  axis = vector::zero;
125  }
126  }
127 
128  if (theta > maxTheta)
129  {
130  maxTheta = theta;
131  }
132 
133  constraintMomentIncrement +=
134  -relaxationFactor_
135  *theta*axis
136  *motion.momentOfInertia()[cmpt]/sqr(deltaT);
137  }
138 
139  constraintPosition = motion.centreOfMass();
140 
141  constraintForceIncrement = vector::zero;
142 
143  bool converged(mag(maxTheta) < tolerance_);
144 
145  if (sixDoFRigidBodyMotionConstraint::debug)
146  {
147  Info<< " max angle " << maxTheta
148  << " force " << constraintForceIncrement
149  << " moment " << constraintMomentIncrement;
150 
151  if (converged)
152  {
153  Info<< " converged";
154  }
155  else
156  {
157  Info<< " not converged";
158  }
159 
160  Info<< endl;
161  }
162 
163  return converged;
164 }
165 
166 
168 (
169  const dictionary& sDoFRBMCDict
170 )
171 {
173 
174  return true;
175 }
176 
177 
179 (
180  Ostream& os
181 ) const
182 {
183 }
184 
185 // ************************ vim: set sw=4 sts=4 et: ************************ //