propellerDiskForce.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-2026 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 "propellerDiskForce.H"
28 #include "fvModels.H"
29 #include "rigidBodyPropellerDisk.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace RBD
37 {
38 namespace restraints
39 {
41 
43  (
44  restraint,
47  );
48 }
49 }
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
56 (
57  const word& name,
58  const dictionary& dict,
59  const rigidBodyModel& model
60 )
61 :
62  restraint(name, dict, model)
63 {
64  read(dict);
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
69 
71 {}
72 
73 
74 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
75 
77 (
80  const rigidBodyModelState& state
81 ) const
82 {
84  refCast<const pointMeshMovers::rigidBodyMotion>(model_);
85 
86  const fvMesh& mesh = refCast<const fvMesh>(mover.poly());
87 
88  // Lookup the fvModels for this mesh
90 
91  // Search for the rigidBodyPropellerDisk fvModel
92  // for the body this restraint is attached to
93  const fv::rigidBodyPropellerDisk* propPtr = nullptr;
94  forAll(fvModels, i)
95  {
96  if (isType<fv::rigidBodyPropellerDisk>(fvModels[i]))
97  {
98  const fv::rigidBodyPropellerDisk& prop
99  (
100  refCast<const fv::rigidBodyPropellerDisk>(fvModels[i])
101  );
102 
103  if (bodyIndex_ == prop.bodyID())
104  {
105  propPtr = &prop;
106  }
107  }
108  }
109 
110  if (!propPtr)
111  {
113  << "Cannot find " << fv::rigidBodyPropellerDisk::typeName
114  << " fvModel for body "
115  << model_.name(bodyIndex_)
116  << exit(FatalError);
117  }
118 
119  // Lookup the propeller force and moment
120  const vector force(propPtr->force());
121  const vector moment
122  (
123  propPtr->moment()
124  + ((propPtr->centre() - model_.X0(bodyIndex_).r()) ^ force)
125  );
126 
127  if (model_.debug)
128  {
129  Info<< indent
130  << "location " << propPtr->centre()
131  << " force " << force
132  << " moment " << moment
133  << endl;
134  }
135 
136  // Accumulate the force for the restrained body
137  fx[masterBodyIndex_] += spatialVector(moment, force);
138 }
139 
140 
142 (
143  const dictionary& dict
144 )
145 {
147 
148  return true;
149 }
150 
151 
153 (
154  Ostream& os
155 ) const
156 {
157  restraint::write(os);
158 }
159 
160 
161 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
static fvModels & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Base class for defining restraints for rigid-body dynamics.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
virtual void write(Ostream &) const =0
Write.
rigidBodyPropellerDisk force restraint.
virtual void write(Ostream &) const
Write.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const
Accumulate the retraint internal joint forces into the tau field and.
propellerDiskForce(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from components.
Holds the motion state of rigid-body model.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Finite volume models.
Definition: fvModels.H:69
vector force() const
Return the current force of the fluid on the propeller.
vector moment() const
Return the current moment of the fluid on the propeller.
Disk momentum source derived from Foam::fv::propellerDisk with support for motion of the body the pro...
virtual vector centre() const
Return the current propeller centre.
const polyMesh & poly() const
Return reference to mesh.
Multiple rigid body mesh motion in which movement of the bodies is generated by RBD::rigidBodyMotion.
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const vector tau
defineTypeNameAndDebug(propellerDiskForce, 0)
addToRunTimeSelectionTable(restraint, propellerDiskForce, dictionary)
const dimensionSet force
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
messageStream Info
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:47
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:243
dictionary dict