Merge commit '751a876460d1e24cef150eb8048bd726833b3196' into nextRelease

This commit is contained in:
Hrvoje Jasak 2018-06-18 11:26:44 +01:00
commit 8e00ea5e5e
6 changed files with 394 additions and 2 deletions

View file

@ -26,6 +26,7 @@ $(sixDOF)/sixDOFODE/restraints/translationalRestraints/translationalRestraint/tr
$(sixDOF)/sixDOFODE/restraints/translationalRestraints/linearSpringDamper/linearSpringDamper.C
$(sixDOF)/sixDOFODE/restraints/rotationalRestraints/rotationalRestraint/rotationalRestraint.C
$(sixDOF)/sixDOFODE/restraints/rotationalRestraints/angularDamper/angularDamper.C
$(sixDOF)/sixDOFODE/restraints/combinedRestraints/combinedRestraint/combinedRestraint.C
$(sixDOF)/sixDOFODE/sixDOFODE.C
$(sixDOF)/sixDOFODE/newSixDOFODE.C

View file

@ -6,5 +6,6 @@
#include "translationalRestraint.H"
#include "rotationalRestraint.H"
#include "combinedRestraint.H"
#endif

View file

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.1
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "combinedRestraint.H"
#include "sixDOFODE.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(combinedRestraint, 0);
defineRunTimeSelectionTable(combinedRestraint, word);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::combinedRestraint::combinedRestraint
(
const word& name,
const dictionary& dict,
const sixDOFODE& sixDOF
)
:
name_(name),
sixDOF_(sixDOF)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::combinedRestraint::~combinedRestraint()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::combinedRestraint::name() const
{
return name_;
}
const Foam::sixDOFODE& Foam::combinedRestraint::sixDOF() const
{
return sixDOF_;
}
Foam::autoPtr<Foam::combinedRestraint> Foam::combinedRestraint::New
(
const word& name,
const dictionary& dict,
const sixDOFODE& sixDOF
)
{
const word restraintType(dict.lookup("type"));
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(restraintType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"combinedRestraint::New"
"\n("
"\n const word& name,"
"\n const dictionary& dict"
"\n)"
) << "Unknown combined restraint type: " << restraintType
<< endl << endl
<< "Valid combined restraint types are: " << endl
<< wordConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<combinedRestraint>
(
cstrIter()
(
name,
dict,
sixDOF
)
);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const combinedRestraint& tr
)
{
os << tr.name_ << nl << token::BEGIN_BLOCK << nl;
tr.write(os);
os << token::END_BLOCK << endl;
os.check("Ostream& operator<<(Ostream&, const combinedRestraint&");
return os;
}
// ************************************************************************* //

View file

@ -0,0 +1,200 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.1
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::combinedRestraint
Description
Abstract base class containing interface for translational and rotational
restraints used within sixDOFODE classes.
Interface provides restraining forces and moments to the translational and
rotational equations of motion via force() and moment() member function.
Author
Inno Gatin, FSB Zagreb. All rights reserved.
SourceFiles
combinedRestraint.C
\*---------------------------------------------------------------------------*/
#ifndef combinedRestraint_H
#define combinedRestraint_H
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "dimensionedTypes.H"
#include "dictionary.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class sixDOFODE;
/*---------------------------------------------------------------------------*\
Class combinedRestraint Declaration
\*---------------------------------------------------------------------------*/
class combinedRestraint
{
// Private Data
//- Name of the restraint
word name_;
//- Reference to underlying sixDOFODE
const sixDOFODE& sixDOF_;
public:
//- Runtime type information
TypeName("combinedRestraint");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
combinedRestraint,
word,
(
const word& name,
const dictionary& dict,
const sixDOFODE& sixDOF
),
(name, dict, sixDOF)
);
//- Class used for the read-construction of
// PtrLists of combinedRestraint
class iNew
{
const sixDOFODE& sixDOF_;
public:
iNew(const sixDOFODE& sixDOF)
:
sixDOF_(sixDOF)
{}
autoPtr<combinedRestraint> operator()(Istream& is) const
{
word name(is);
dictionary dict(is);
return combinedRestraint::New(name, dict, sixDOF_);
}
};
// Constructors
//- Construct from dictionary
combinedRestraint
(
const word& name,
const dictionary& dict,
const sixDOFODE& sixDOF
);
//- Construct and return a clone
virtual autoPtr<combinedRestraint> clone() const = 0;
// Selectors
//- Return a reference to the selected combinedRestraint
static autoPtr<combinedRestraint> New
(
const word& name,
const dictionary& dict,
const sixDOFODE& sixDOF
);
// Destructor
virtual ~combinedRestraint();
// Member Functions
// Access functions
//- Return name
const word& name() const;
//- Return underlying sixDOFODE object
const sixDOFODE& sixDOF() const;
// Restraint specific functions
//- Return restraining force (in the global coordinate system)
virtual vector restrainingForce
(
const scalar t,
const tensor& toRelative,
const vector& x,
const vector& u
) const = 0;
//- Return restraining moment (in the local coordinate system)
virtual vector restrainingMoment
(
const scalar t,
const tensor& toRelative,
const vector& omega
) const = 0;
// I-O Functions and Operators
//- Virtual write function
virtual void write(Ostream& os) const = 0;
//- Ostream operator implemented in terms of write operator
friend Ostream& operator<<
(
Ostream& os,
const combinedRestraint& tr
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -244,6 +244,17 @@ void Foam::sixDOFODE::setState(const sixDOFODE& sd)
sd.rotationalRestraints_[rrI].clone()
);
}
// Combined restraints
combinedRestraints_.setSize(sd.combinedRestraints_.size());
forAll(sd.combinedRestraints_, rrI)
{
combinedRestraints_.set
(
rrI,
sd.combinedRestraints_[rrI].clone()
);
}
}
@ -272,6 +283,17 @@ Foam::dimensionedVector Foam::sixDOFODE::force
);
}
forAll(combinedRestraints_, trI)
{
rForce.value() += combinedRestraints_[trI].restrainingForce
(
t, // Time
toRelative, // Transformation tensor
x, // Position in the global c.s.
u // Velocity in the global c.s.
);
}
// Return linearly interpolated external force with restraining force
return (alpha*oldStatePtr_->force() + (1 - alpha)*force()) + rForce;
}
@ -300,6 +322,16 @@ Foam::dimensionedVector Foam::sixDOFODE::moment
);
}
forAll(combinedRestraints_, rrI)
{
rMoment.value() += combinedRestraints_[rrI].restrainingMoment
(
t, // Time
toRelative, // Transformation tensor
omega // Angular velocity in local c.s.
);
}
// Return linearly interpolated external moment with restraining moment
return (alpha*oldStatePtr_->moment() + (1 - alpha)*moment() + rMoment);
}
@ -344,7 +376,8 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
rotationalConstraints_(),
translationalRestraints_(),
rotationalRestraints_()
rotationalRestraints_(),
combinedRestraints_()
{
// Sanity checks
if (mass_.value() < SMALL)
@ -431,6 +464,17 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
);
rotationalRestraints_.transfer(rcList);
}
// Read rotation restraints if they are present
if (dict().found("combinedRestraints"))
{
PtrList<combinedRestraint> rcList
(
dict().lookup("combinedRestraints"),
combinedRestraint::iNew(*this)
);
combinedRestraints_.transfer(rcList);
}
}
@ -468,7 +512,8 @@ Foam::sixDOFODE::sixDOFODE(const word& name, const sixDOFODE& sd)
rotationalConstraints_(sd.rotationalConstraints_),
translationalRestraints_(sd.translationalRestraints_),
rotationalRestraints_(sd.rotationalRestraints_)
rotationalRestraints_(sd.rotationalRestraints_),
combinedRestraints_(sd.combinedRestraints_)
{}
@ -536,6 +581,13 @@ bool Foam::sixDOFODE::writeData(Ostream& os) const
<< token::END_STATEMENT << endl;
}
if (!combinedRestraints_.empty())
{
os.writeKeyword("combinedRestraints")
<< combinedRestraints_
<< token::END_STATEMENT << endl;
}
return os.good();
}

View file

@ -166,6 +166,9 @@ class sixDOFODE
//- List of rotational restraints
PtrList<rotationalRestraint> rotationalRestraints_;
//- List of combined trans and rot restraints
PtrList<combinedRestraint> combinedRestraints_;
// Private Member Functions
@ -345,6 +348,10 @@ public:
inline const PtrList<rotationalRestraint>&
rotationalRestraints() const;
//- Return const reference to combined restraints
inline const PtrList<combinedRestraint>&
combinedRestraints() const;
// Virtual interface for 6DOF motion state