sixDoFRigidBodyMotionLineConstraint.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) 2011-2015 OpenFOAM Foundation
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 
28 #include "sixDoFRigidBodyMotion.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace sixDoFRigidBodyMotionConstraints
35 {
36  defineTypeNameAndDebug(line, 0);
37 
39  (
40  sixDoFRigidBodyMotionConstraint,
41  line,
42  dictionary
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const word& name,
53  const dictionary& sDoFRBMCDict,
54  const sixDoFRigidBodyMotion& motion
55 )
56 :
57  sixDoFRigidBodyMotionConstraint(name, sDoFRBMCDict, motion)
58 {
59  read(sDoFRBMCDict);
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
64 
66 {}
67 
68 
69 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
70 
72 (
73  point& CofR
74 ) const
75 {
76  CofR = centreOfRotation_;
77 }
78 
79 
81 (
82  pointConstraint& pc
83 ) const
84 {
85  pc.combine(pointConstraint(Tuple2<label, vector>(2, direction_)));
86 }
87 
88 
90 (
91  pointConstraint& pc
92 ) const
93 {}
94 
95 
97 (
98  const dictionary& sDoFRBMCDict
99 )
100 {
102 
103  centreOfRotation_ = sDoFRBMCCoeffs_.lookupOrDefault
104  (
105  "centreOfRotation",
106  motion_.initialCentreOfMass()
107  );
108 
109  sDoFRBMCCoeffs_.lookup("direction") >> direction_;
110 
111  scalar magDir(mag(direction_));
112 
113  if (magDir > VSMALL)
114  {
115  direction_ /= magDir;
116  }
117  else
118  {
120  (
121  "Foam::sixDoFRigidBodyMotionConstraints::line::read"
122  "("
123  "const dictionary& sDoFRBMCDict"
124  ")"
125  )
126  << "line direction has zero length"
127  << abort(FatalError);
128  }
129 
130  return true;
131 }
132 
133 
135 (
136  Ostream& os
137 ) const
138 {
139  os.writeKeyword("centreOfRotation")
140  << centreOfRotation_ << token::END_STATEMENT << nl;
141  os.writeKeyword("direction")
142  << direction_ << token::END_STATEMENT << nl;
143 }
144 
145 // ************************************************************************* //
virtual void constrainTranslation(pointConstraint &) const
Apply and accumulate translational constraints.
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual bool read(const dictionary &sDoFRBMCCoeff)
Update properties from given dictionary.
virtual void constrainRotation(pointConstraint &) const
Apply and accumulate rotational constraints.
Translation constraint on the centre of rotation: fixed in space.
A class for handling words, derived from string.
Definition: word.H:59
Accumulates point constraints through successive applications of the applyConstraint function...
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
line(const word &name, const dictionary &sDoFRBMCDict, const sixDoFRigidBodyMotion &motion)
Construct from components.
virtual bool read(const dictionary &sDoFRBMCDict)
Update properties from given dictionary.
static const char nl
Definition: Ostream.H:260
virtual void setCentreOfRotation(point &) const
Set the centre of rotation to the projection of the.
Macros for easy insertion into run-time selection tables.
Base class for defining constraints for sixDoF motions.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
addToRunTimeSelectionTable(sixDoFRigidBodyMotionConstraint, axis, dictionary)
error FatalError
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Six degree of freedom motion for a rigid body.
void combine(const pointConstraint &)
Combine constraints.