FreeFOAM The Cross-Platform CFD Toolkit
fixedPlane.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 "fixedPlane.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace sixDoFRigidBodyMotionConstraints
35 {
36  defineTypeNameAndDebug(fixedPlane, 0);
38  (
39  sixDoFRigidBodyMotionConstraint,
40  fixedPlane,
41  dictionary
42  );
43 };
44 };
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const dictionary& sDoFRBMCDict
52 )
53 :
54  sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
55  fixedPlane_(vector::one)
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  const point& refPt = fixedPlane_.refPoint();
81 
82  const vector& n = fixedPlane_.normal();
83 
84  point predictedPosition = motion.predictedPosition
85  (
86  refPt,
87  existingConstraintForce,
88  existingConstraintMoment,
89  deltaT
90  );
91 
92  constraintPosition = motion.currentPosition(refPt);
93 
94  // Info<< "current position " << constraintPosition << nl
95  // << "next predictedPosition " << predictedPosition
96  // << endl;
97 
98  vector error = ((predictedPosition - refPt) & n)*n;
99 
100  // Info<< "error " << error << endl;
101 
102  constraintForceIncrement =
103  -relaxationFactor_*error*motion.mass()/sqr(deltaT);
104 
105  constraintMomentIncrement = vector::zero;
106 
107  bool converged(mag(error) < tolerance_);
108 
109  if (sixDoFRigidBodyMotionConstraint::debug)
110  {
111  Info<< " error " << error
112  << " force " << constraintForceIncrement
113  << " moment " << constraintMomentIncrement;
114 
115  if (converged)
116  {
117  Info<< " converged";
118  }
119  else
120  {
121  Info<< " not converged";
122  }
123 
124  Info<< endl;
125  }
126 
127  return converged;
128 }
129 
130 
132 (
133  const dictionary& sDoFRBMCDict
134 )
135 {
137 
138  point refPt = sDoFRBMCCoeffs_.lookup("refPoint");
139 
140  vector normal = sDoFRBMCCoeffs_.lookup("normal");
141 
142  fixedPlane_ = plane(refPt, normal);
143 
144  return true;
145 }
146 
147 
149 (
150  Ostream& os
151 ) const
152 {
153  os.writeKeyword("refPoint")
154  << fixedPlane_.refPoint() << token::END_STATEMENT << nl;
155 
156  os.writeKeyword("normal")
157  << fixedPlane_.normal() << token::END_STATEMENT << nl;
158 }
159 
160 // ************************ vim: set sw=4 sts=4 et: ************************ //