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 * * * * * * * * * * * * * //
34
35namespace Foam
36{
37namespace RBD
38{
39namespace restraints
40{
42
44 (
48 );
49}
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)
64{
65 read(dict);
66}
67
68
69// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
70
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;
123 }
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.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
virtual bool read()
Re-read model coefficients if they have changed.
Base class for defining restraints for rigid-body dynamics.
Soft wall is a Damper-Linear spring restraint. Acts as a "soft" wall when the distance between 'ancho...
Definition: softWall.H:66
virtual ~softWall()
Destructor.
Definition: softWall.C:71
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
Definition: softWall.C:131
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:78
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 keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual bool write()
Write the output fields.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:50
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
A non-counting (dummy) refCount.
Definition: refCount.H:59