All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sixDoFRigidBodyControl.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018 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 
26 #include "sixDoFRigidBodyControl.H"
27 #include "Time.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
36  defineTypeNameAndDebug(sixDoFRigidBodyControl, 0);
37 
39  (
40  functionObject,
41  sixDoFRigidBodyControl,
42  dictionary
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const word& name,
53  const Time& runTime,
54  const dictionary& dict
55 )
56 :
57  sixDoFRigidBodyState(name, runTime, dict),
58  time_(runTime),
59  meanVelocity_(Zero),
60  meanAngularVelocity_(Zero)
61 {
62  read(dict);
63  resetName(typeName);
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
68 
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
76 {
78 
79  dict.lookup("window") >> w_;
80  dict.lookup("convergedVelocity") >> convergedVelocity_;
81  dict.lookup("convergedAngularVelocity") >> convergedAngularVelocity_;
82 
83  return true;
84 }
85 
86 
88 {
89  if (time_.timeIndex() <= time_.startTimeIndex() + 1)
90  {
91  meanVelocity_ = cmptMag(velocity());
92  meanAngularVelocity_ = cmptMag(angularVelocity());
93  }
94  else
95  {
96  const scalar dt = time_.deltaTValue();
97  const scalar beta = min(dt/w_, 1);
98 
99  meanVelocity_ = (1 - beta)*meanVelocity_ + beta*cmptMag(velocity());
100 
101  meanAngularVelocity_ =
102  (1 - beta)*meanAngularVelocity_ + beta*cmptMag(angularVelocity());
103  }
104 
105  if
106  (
107  time_.value() - time_.startTime().value() > w_
108  && meanVelocity_ < convergedVelocity_
109  && meanAngularVelocity_ < convergedAngularVelocity_
110  )
111  {
112  time_.stopAt(Time::stopAtControl::writeNow);
113  }
114 
115  return true;
116 }
117 
118 
119 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
set endTime to stop immediately w/ writing
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Macros for easy insertion into run-time selection tables.
virtual bool read(const dictionary &)
Read the sixDoFRigidBodyState data.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read(const dictionary &)
Read the sixDoFRigidBodyControl data.
static const zero Zero
Definition: zero.H:97
sixDoFRigidBodyControl(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
defineTypeNameAndDebug(Qdot, 0)
virtual bool execute()
Execute, currently does nothing.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812