FreeFOAM The Cross-Platform CFD Toolkit
fixedPoint.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 "fixedPoint.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace sixDoFRigidBodyMotionConstraints
35 {
36  defineTypeNameAndDebug(fixedPoint, 0);
38  (
39  sixDoFRigidBodyMotionConstraint,
40  fixedPoint,
41  dictionary
42  );
43 };
44 };
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const dictionary& sDoFRBMCDict
52 )
53 :
54  sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
55  fixedPoint_()
56 {
57  read(sDoFRBMCDict);
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
62 
64 {}
65 
66 
67 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
68 
70 (
71  const sixDoFRigidBodyMotion& motion,
72  const vector& existingConstraintForce,
73  const vector& existingConstraintMoment,
74  scalar deltaT,
75  vector& constraintPosition,
76  vector& constraintForceIncrement,
77  vector& constraintMomentIncrement
78 ) const
79 {
80  point predictedPosition = motion.predictedPosition
81  (
82  fixedPoint_,
83  existingConstraintForce,
84  existingConstraintMoment,
85  deltaT
86  );
87 
88  constraintPosition = motion.currentPosition(fixedPoint_);
89 
90  // Info<< "current position " << constraintPosition << nl
91  // << "next predictedPosition " << predictedPosition
92  // << endl;
93 
94  vector error = predictedPosition - fixedPoint_;
95 
96  // Info<< "error " << error << endl;
97 
98  // Correction force derived from Lagrange multiplier:
99  // G = -lambda*grad(sigma)
100  // where
101  // sigma = mag(error) = 0
102  // so
103  // grad(sigma) = error/mag(error)
104  // Solving for lambda using the SHAKE methodology gives
105  // lambda = mass*mag(error)/sqr(deltaT)
106  // This is only strictly applicable (i.e. will converge in one
107  // iteration) to constraints at the centre of mass. Everything
108  // else will need to iterate, and may need under-relaxed to be
109  // stable.
110 
111  constraintForceIncrement =
112  -relaxationFactor_*error*motion.mass()/sqr(deltaT);
113 
114  constraintMomentIncrement = vector::zero;
115 
116  bool converged(mag(error) < tolerance_);
117 
118  if (sixDoFRigidBodyMotionConstraint::debug)
119  {
120  Info<< " error " << error
121  << " force " << constraintForceIncrement
122  << " moment " << constraintMomentIncrement;
123 
124  if (converged)
125  {
126  Info<< " converged";
127  }
128  else
129  {
130  Info<< " not converged";
131  }
132 
133  Info<< endl;
134  }
135 
136  return converged;
137 }
138 
139 
141 (
142  const dictionary& sDoFRBMCDict
143 )
144 {
146 
147  sDoFRBMCCoeffs_.lookup("fixedPoint") >> fixedPoint_;
148 
149  return true;
150 }
151 
152 
154 (
155  Ostream& os
156 ) const
157 {
158  os.writeKeyword("fixedPoint")
159  << fixedPoint_ << token::END_STATEMENT << nl;
160 }
161 
162 // ************************ vim: set sw=4 sts=4 et: ************************ //