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 "fixedPlane.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "sixDoFRigidBodyMotion.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace sixDoFRigidBodyMotionConstraints
37 defineTypeNameAndDebug(fixedPlane, 0);
38 addToRunTimeSelectionTable
40 sixDoFRigidBodyMotionConstraint,
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::fixedPlane
52 const dictionary& sDoFRBMCDict
55 sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
56 fixedPlane_(vector::one)
62 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
64 Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::~fixedPlane()
68 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
70 bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::constrain
72 const sixDoFRigidBodyMotion& motion,
73 const vector& existingConstraintForce,
74 const vector& existingConstraintMoment,
76 vector& constraintPosition,
77 vector& constraintForceIncrement,
78 vector& constraintMomentIncrement
81 const point& refPt = fixedPlane_.refPoint();
83 const vector& n = fixedPlane_.normal();
85 point predictedPosition = motion.predictedPosition
88 existingConstraintForce,
89 existingConstraintMoment,
93 constraintPosition = motion.currentPosition(refPt);
95 // Info<< "current position " << constraintPosition << nl
96 // << "next predictedPosition " << predictedPosition
99 vector error = ((predictedPosition - refPt) & n)*n;
101 // Info<< "error " << error << endl;
103 constraintForceIncrement =
104 -relaxationFactor_*error*motion.mass()/sqr(deltaT);
106 constraintMomentIncrement = vector::zero;
108 bool converged(mag(error) < tolerance_);
110 if (sixDoFRigidBodyMotionConstraint::debug)
112 Info<< " error " << error
113 << " force " << constraintForceIncrement
114 << " moment " << constraintMomentIncrement;
122 Info<< " not converged";
132 bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::read
134 const dictionary& sDoFRBMCDict
137 sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
139 point refPt = sDoFRBMCCoeffs_.lookup("refPoint");
141 vector normal = sDoFRBMCCoeffs_.lookup("normal");
143 fixedPlane_ = plane(refPt, normal);
149 void Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::write
154 os.writeKeyword("refPoint")
155 << fixedPlane_.refPoint() << token::END_STATEMENT << nl;
157 os.writeKeyword("normal")
158 << fixedPlane_.normal() << token::END_STATEMENT << nl;
161 // ************************************************************************* //