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-2025 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"
27 #include "rigidBodyMeshMotion.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 {
83  const rigidBodyMeshMotion& mover =
84  refCast<const rigidBodyMeshMotion>(model_);
85 
86  const fvMesh& mesh = refCast<const fvMesh>(mover.mesh());
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<< " location " << propPtr->centre()
130  << " force " << force
131  << " moment " << moment
132  << endl;
133  }
134 
135  // Accumulate the force for the restrained body
136  fx[masterBodyIndex_] += spatialVector(moment, force);
137 }
138 
139 
141 (
142  const dictionary& dict
143 )
144 {
146 
147  return true;
148 }
149 
150 
152 (
153  Ostream& os
154 ) const
155 {
156  restraint::write(os);
157 }
158 
159 
160 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Macros for easy insertion into run-time selection tables.
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
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
Definition: dictionaryIO.C:103
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Finite volume models.
Definition: fvModels.H:65
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 & mesh() const
Return reference to mesh.
Definition: motionSolver.H:133
Rigid-body mesh motion solver for fvMesh.
A class for handling words, derived from string.
Definition: word.H:62
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)
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:258
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
dictionary dict