rigidBodyForces.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) 2024 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 "rigidBodyForces.H"
27 #include "rigidBodyMotion.H"
29 #include "motionSolver.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace functionObjects
37 {
39 
41 }
42 }
43 
44 
45 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
46 
48 {
49  const fvMeshMovers::motionSolver& mover =
50  refCast<const fvMeshMovers::motionSolver>(mesh_.mover());
51 
52  const RBD::rigidBodyMotion& motion =
53  refCast<const RBD::rigidBodyMotion>(mover.motion());
54 
55  const label bodyID = motion.bodyIndex(body_);
56 
57  return motion.X0(bodyID).r();
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
62 
64 (
65  const word& name,
66  const Time& runTime,
67  const dictionary& dict
68 )
69 :
70  forcesBase(name, runTime, dict)
71 {
72  read(dict);
73 }
74 
75 
77 (
78  const word& name,
79  const objectRegistry& obr,
80  const dictionary& dict
81 )
82 :
83  forcesBase(name, obr, dict)
84 {
85  read(dict);
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
90 
92 {}
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
98 {
100 
101  // Centre of rotation for moment calculations
102  body_ = dict.lookup<word>("body");
103 
104  return true;
105 }
106 
107 
108 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
label bodyIndex(const word &name) const
Return the ID of the body with the given name.
spatialTransform X0(const label bodyId) const
Return the current transform to the global frame for the given body.
Six degree of freedom motion for a rigid body.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base-class for Time/database functionObjects.
Calculates the forces and moments by integrating the pressure and skin-friction forces over a given l...
Definition: forcesBase.H:64
virtual bool read(const dictionary &)
Read the forces data.
Definition: forcesBase.C:653
const fvMesh & mesh_
Reference to the fvMesh.
Calculates the forces and moments by integrating the pressure and skin-friction forces over a given l...
rigidBodyForces(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual vector CofR() const
Return the current centre of the rigid body.
virtual bool read(const dictionary &)
Read the forces data.
const Foam::motionSolver & motion() const
Return the motionSolver.
const fvMeshMover & mover() const
Return the mover function class.
Definition: fvMesh.C:1050
Registry of regIOobjects.
const vector & r() const
Return the translation vector.
A class for handling words, derived from string.
Definition: word.H:62
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
dictionary dict