Loading...
Searching...
No Matches
softWall.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2019 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "softWall.H"
29#include "rigidBodyModel.H"
31#include "Time.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35namespace Foam
37namespace RBD
38{
39namespace restraints
40{
42
44 (
48 );
50}
51}
52
53
54// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55
57(
58 const word& name,
59 const dictionary& dict,
60 const rigidBodyModel& model
61)
62:
63 restraint(name, dict, model)
65 read(dict);
66}
67
68
69// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72{}
73
74
75// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
76
78(
79 scalarField& tau,
81 const rigidBodyModelState& state
82) const
83{
84
85 point p = bodyPoint(refAttachmentPt_);
86
87 // Current axis of the spring
88 vector r = p - anchor_;
89
90 vector force = vector::zero;
91 vector moment = vector::zero;
92
93 vector v = bodyPointVelocity(refAttachmentPt_).l();
94
95 scalar m = model_.bodies()[bodyID_].m();
96
97 scalar d = (wallNormal_/mag(wallNormal_)) & r;
98
99 vector rDir = r/(mag(r) + VSMALL);
100
101 scalar wn = 3.14/C_;
102 scalar damping = psi_*2*m*wn;
103 scalar stiffness = sqr(wn)*m;
104
105 if (d < 0)
106 {
107 force =
108 (-damping*(rDir & v) + stiffness*d)*rDir;
109
110 moment = (p ^ force);
111 }
112
113 if (model_.debug)
114 {
115 Info<< " stiffness :" << stiffness*d << nl
116 << " damping :" << -damping*mag(rDir & v) << nl
117 << " force : " << force << nl
118 << " d : " << d << nl
119 << " r : " << r << nl
120 << " p : " << p << nl
121 << " velocity : " << v
122 << endl;
124
125 // Accumulate the force for the restrained body
126 fx[bodyIndex_] += spatialVector(moment, force);
127}
128
129
131(
132 const dictionary& dict
133)
134{
136
137 coeffs_.readEntry("anchor", anchor_);
138 coeffs_.readEntry("refAttachmentPt", refAttachmentPt_);
139 coeffs_.readEntry("psi", psi_);
140 coeffs_.readEntry("C", C_);
141 coeffs_.readEntry("wallNormal", wallNormal_);
142
143 return true;
144}
145
146
148(
149 Ostream& os
150) const
151{
153
154 os.writeEntry("anchor", anchor_);
155 os.writeEntry("refAttachmentPt", refAttachmentPt_);
156 os.writeEntry("psi", psi_);
157 os.writeEntry("C", C_);
158 os.writeEntry("wallNormal", wallNormal_);
159
160}
161
162
163// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Base class for defining restraints for rigid-body dynamics.
label bodyID_
ID of the body the restraint is applied to.
restraint(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from the dict dictionary and Time.
const word & name() const
Return the name.
label bodyIndex_
Index of the body the force is applied to.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
dictionary coeffs_
Restraint model specific coefficient dictionary.
point bodyPoint(const point &p) const
Transform the given point on the restrained body to the global frame.
spatialVector bodyPointVelocity(const point &p) const
Transform the velocity of the given point on the restrained body.
virtual void write(Ostream &) const =0
Write.
const rigidBodyModel & model_
Reference to the model.
Soft wall is a Damper-Linear spring restraint. Acts as a "soft" wall when the distance between 'ancho...
Definition softWall.H:62
virtual void write(Ostream &) const
Write.
Definition softWall.C:141
virtual ~softWall()
Destructor.
Definition softWall.C:64
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
Definition softWall.C:124
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const
Accumulate the restraint internal joint forces into the tau field and.
Definition softWall.C:71
softWall(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from components.
Definition softWall.C:50
Holds the motion state of rigid-body model.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
static const Form zero
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Namespace for rigid-body dynamics restraints.
Namespace for OpenFOAM.
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vector point
Point is a vector.
Definition point.H:37
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
Vector< scalar > vector
Definition vector.H:57
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict