1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "fixedPoint.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "sixDoFRigidBodyMotion.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace sixDoFRigidBodyMotionConstraints
37 defineTypeNameAndDebug(fixedPoint, 0);
38 addToRunTimeSelectionTable
40 sixDoFRigidBodyMotionConstraint,
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::fixedPoint
52 const dictionary& sDoFRBMCDict
55 sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
62 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
64 Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::~fixedPoint()
68 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
70 bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::constrain
72 const sixDoFRigidBodyMotion& motion,
73 const vector& existingConstraintForce,
74 const vector& existingConstraintMoment,
76 vector& constraintPosition,
77 vector& constraintForceIncrement,
78 vector& constraintMomentIncrement
81 point predictedPosition = motion.predictedPosition
84 existingConstraintForce,
85 existingConstraintMoment,
89 constraintPosition = motion.currentPosition(fixedPoint_);
91 // Info<< "current position " << constraintPosition << nl
92 // << "next predictedPosition " << predictedPosition
95 vector error = predictedPosition - fixedPoint_;
97 // Info<< "error " << error << endl;
99 // Correction force derived from Lagrange multiplier:
100 // G = -lambda*grad(sigma)
102 // sigma = mag(error) = 0
104 // grad(sigma) = error/mag(error)
105 // Solving for lambda using the SHAKE methodology gives
106 // lambda = mass*mag(error)/sqr(deltaT)
107 // This is only strictly applicable (i.e. will converge in one
108 // iteration) to constraints at the centre of mass. Everything
109 // else will need to iterate, and may need under-relaxed to be
112 constraintForceIncrement =
113 -relaxationFactor_*error*motion.mass()/sqr(deltaT);
115 constraintMomentIncrement = vector::zero;
117 bool converged(mag(error) < tolerance_);
121 Info<< " error " << error
122 << " force " << constraintForceIncrement
123 << " moment " << constraintMomentIncrement;
131 Info<< " not converged";
141 bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::read
143 const dictionary& sDoFRBMCDict
146 sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
148 sDoFRBMCCoeffs_.lookup("fixedPoint") >> fixedPoint_;
154 void Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::write
159 os.writeKeyword("fixedPoint")
160 << fixedPoint_ << token::END_STATEMENT << nl;
163 // ************************************************************************* //