Adding interface for restraints

Abstract base classes translationalRestraint and rotationalRestraint are laid
out. Need to use them in sixDOFODE class and write basic restraints.
This commit is contained in:
Vuko Vukcevic 2017-03-10 09:59:56 +01:00 committed by Hrvoje Jasak
parent 8de41a7ae4
commit c63d6b76a8
19 changed files with 674 additions and 13 deletions

View file

@ -16,12 +16,14 @@ sixDOF = sixDOF
$(sixDOF)/finiteRotation/finiteRotation.C
$(sixDOF)/sixDOFqODE/sixDOFqODE.C
$(sixDOF)/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.C
$(sixDOF)/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.C
$(sixDOF)/sixDOFODE/constraints/rotationalConstraints/rotationalConstraint/rotationalConstraint.C
$(sixDOF)/sixDOFODE/constraints/rotationalConstraints/constantAngularAcceleration/constantAngularAcceleration.C
$(sixDOF)/sixDOFODE/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C
$(sixDOF)/sixDOFODE/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C
$(sixDOF)/sixDOFODE/constraints/translationalConstraints/periodicOscillation/periodicOscillation.C
$(sixDOF)/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C
$(sixDOF)/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C
$(sixDOF)/constraints/translationalConstraints/periodicOscillation/periodicOscillation.C
$(sixDOF)/sixDOFODE/restraints/translationalRestraints/translationalRestraint/translationalRestraint.C
$(sixDOF)/sixDOFODE/restraints/rotationalRestraints/rotationalRestraint/rotationalRestraint.C
$(sixDOF)/sixDOFODE/sixDOFODE.C
$(sixDOF)/sixDOFODE/newSixDOFODE.C

View file

@ -0,0 +1,10 @@
#ifndef constraintsAndRestraints_H
#define constraintsAndRestraints_H
#include "translationalConstraint.H"
#include "rotationalConstraint.H"
#include "translationalRestraint.H"
#include "rotationalRestraint.H"
#endif

View file

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / 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 "rotationalRestraint.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(rotationalRestraint, 0);
defineRunTimeSelectionTable(rotationalRestraint, word);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::rotationalRestraint::rotationalRestraint
(
const word& name,
const dictionary& dict
)
:
name_(name)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::rotationalRestraint::~rotationalRestraint()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::rotationalRestraint> Foam::rotationalRestraint::New
(
const word& name,
const dictionary& dict
)
{
const word restraintType(dict.lookup("type"));
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(restraintType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"rotationalRestraint::New"
"\n("
"\n const word& name,"
"\n const dictionary& dict"
"\n)"
) << "Unknown translation restraint type: " << restraintType
<< endl << endl
<< "Valid translation restraint types are: " << endl
<< wordConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<rotationalRestraint>
(
cstrIter()
(
name,
dict
)
);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const rotationalRestraint& rr
)
{
os << rr.name_ << nl << token::BEGIN_BLOCK << nl;
rr.write(os);
os << token::END_BLOCK << endl;
os.check("Ostream& operator<<(Ostream&, const rotationalRestraint&");
return os;
}
// ************************************************************************* //

View file

@ -0,0 +1,171 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / 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::rotationalRestraint
Description
Abstract base class containing interface for rotational restraints used
within sixDOFODE classes.
Interface provides restraining moment to the rotational equations of
motion via moment() member function.
Author
Vuko Vukcevic, FSB Zagreb. All rights reserved.
SourceFiles
rotationalRestraint.C
\*---------------------------------------------------------------------------*/
#ifndef rotationalRestraint_H
#define rotationalRestraint_H
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "dimensionedTypes.H"
#include "dictionary.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rotationalRestraint Declaration
\*---------------------------------------------------------------------------*/
class rotationalRestraint
{
// Private Data
//- Name of the restraint
word name_;
public:
//- Runtime type information
TypeName("rotationalRestraint");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
rotationalRestraint,
word,
(
const word& name,
const dictionary& dict
),
(name, dict)
);
//- Class used for the read-construction of
// PtrLists of rotationalRestraint
class iNew
{
public:
iNew()
{}
autoPtr<rotationalRestraint> operator()(Istream& is) const
{
word name(is);
dictionary dict(is);
return rotationalRestraint::New(name, dict);
}
};
// Constructors
//- Construct from dictionary
rotationalRestraint
(
const word& name,
const dictionary& dict
);
//- Construct and return a clone
virtual autoPtr<rotationalRestraint> clone() const = 0;
// Selectors
//- Return a reference to the selected rotationalRestraint
static autoPtr<rotationalRestraint> New
(
const word& name,
const dictionary& dict
);
// Destructor
virtual ~rotationalRestraint();
// Member Functions
// Restraint specific functions
//- Return restraining force (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 rotationalRestraint& rr
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / 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 "translationalRestraint.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(translationalRestraint, 0);
defineRunTimeSelectionTable(translationalRestraint, word);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::translationalRestraint::translationalRestraint
(
const word& name,
const dictionary& dict
)
:
name_(name)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::translationalRestraint::~translationalRestraint()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::translationalRestraint> Foam::translationalRestraint::New
(
const word& name,
const dictionary& dict
)
{
const word restraintType(dict.lookup("type"));
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(restraintType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"translationalRestraint::New"
"\n("
"\n const word& name,"
"\n const dictionary& dict"
"\n)"
) << "Unknown translation restraint type: " << restraintType
<< endl << endl
<< "Valid translation restraint types are: " << endl
<< wordConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<translationalRestraint>
(
cstrIter()
(
name,
dict
)
);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const translationalRestraint& tr
)
{
os << tr.name_ << nl << token::BEGIN_BLOCK << nl;
tr.write(os);
os << token::END_BLOCK << endl;
os.check("Ostream& operator<<(Ostream&, const translationalRestraint&");
return os;
}
// ************************************************************************* //

View file

@ -0,0 +1,172 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / 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::translationalRestraint
Description
Abstract base class containing interface for translational restraints used
within sixDOFODE classes.
Interface provides restraining forces to the translational equations of
motion via force() member function.
Author
Vuko Vukcevic, FSB Zagreb. All rights reserved.
SourceFiles
translationalRestraint.C
\*---------------------------------------------------------------------------*/
#ifndef translationalRestraint_H
#define translationalRestraint_H
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "dimensionedTypes.H"
#include "dictionary.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class translationalRestraint Declaration
\*---------------------------------------------------------------------------*/
class translationalRestraint
{
// Private Data
//- Name of the restraint
word name_;
public:
//- Runtime type information
TypeName("translationalRestraint");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
translationalRestraint,
word,
(
const word& name,
const dictionary& dict
),
(name, dict)
);
//- Class used for the read-construction of
// PtrLists of translationalRestraint
class iNew
{
public:
iNew()
{}
autoPtr<translationalRestraint> operator()(Istream& is) const
{
word name(is);
dictionary dict(is);
return translationalRestraint::New(name, dict);
}
};
// Constructors
//- Construct from dictionary
translationalRestraint
(
const word& name,
const dictionary& dict
);
//- Construct and return a clone
virtual autoPtr<translationalRestraint> clone() const = 0;
// Selectors
//- Return a reference to the selected translationalRestraint
static autoPtr<translationalRestraint> New
(
const word& name,
const dictionary& dict
);
// Destructor
virtual ~translationalRestraint();
// Member Functions
// 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;
// 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 translationalRestraint& tr
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -200,6 +200,10 @@ void Foam::sixDOFODE::setState(const sixDOFODE& sd)
// Copy constraints
translationalConstraints_ = sd.translationalConstraints_;
rotationalConstraints_ = sd.rotationalConstraints_;
// Copy restraints
translationalRestraints_ = sd.translationalRestraints_;
rotationalRestraints_ = sd.rotationalRestraints_;
}
@ -261,7 +265,10 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
oldStatePtr_(),
translationalConstraints_(),
rotationalConstraints_()
rotationalConstraints_(),
translationalRestraints_(),
rotationalRestraints_()
{
// Sanity checks
if (mass_.value() < SMALL)
@ -281,7 +288,7 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
<< exit(FatalError);
}
// Read and construct constraints
// Read and construct constraints and restraints
// Read translation constraints if they are present
if (dict().found("translationalConstraints"))
@ -304,6 +311,28 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
);
rotationalConstraints_.transfer(rcList);
}
// Read translation restraints if they are present
if (dict().found("translationalRestraints"))
{
PtrList<translationalRestraint> tcList
(
dict().lookup("translationalRestraints"),
translationalRestraint::iNew()
);
translationalRestraints_.transfer(tcList);
}
// Read rotation restraints if they are present
if (dict().found("rotationalRestraints"))
{
PtrList<rotationalRestraint> rcList
(
dict().lookup("rotationalRestraints"),
rotationalRestraint::iNew()
);
rotationalRestraints_.transfer(rcList);
}
}
@ -340,7 +369,10 @@ Foam::sixDOFODE::sixDOFODE(const word& name, const sixDOFODE& sd)
oldStatePtr_(),
translationalConstraints_(sd.translationalConstraints_),
rotationalConstraints_(sd.rotationalConstraints_)
rotationalConstraints_(sd.rotationalConstraints_),
translationalRestraints_(sd.translationalRestraints_),
rotationalRestraints_(sd.rotationalRestraints_)
{}
@ -398,6 +430,20 @@ bool Foam::sixDOFODE::writeData(Ostream& os) const
<< token::END_STATEMENT << endl;
}
if (!translationalRestraints_.empty())
{
os.writeKeyword("translationalRestraints")
<< translationalRestraints_
<< token::END_STATEMENT << nl << endl;
}
if (!rotationalRestraints_.empty())
{
os.writeKeyword("rotationalRestraints")
<< rotationalRestraints_
<< token::END_STATEMENT << endl;
}
return os.good();
}

View file

@ -28,8 +28,8 @@ Description
Abstract base class for six-degrees-of-freedom (6DOF) ordinary differential
equations with necessary interface for two-way coupling with CFD solvers.
Holds list of translational and rotational constraints to be used in derived
classes.
Holds list of translational and rotational constraints and restraings to be
used in derived classes.
Author
Dubravko Matijasevic, FSB Zagreb. All rights reserved.
@ -56,9 +56,7 @@ SourceFiles
#include "runTimeSelectionTables.H"
#include "Switch.H"
#include "foamTime.H"
#include "translationalConstraint.H"
#include "rotationalConstraint.H"
#include "PtrList.H"
#include "constraintsAndRestraints.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -166,6 +164,15 @@ class sixDOFODE
PtrList<rotationalConstraint> rotationalConstraints_;
// Motion restraints
//- List of translational restraints
PtrList<translationalRestraint> translationalRestraints_;
//- List of rotational restraints
PtrList<rotationalRestraint> rotationalRestraints_;
// Private Member Functions
// Copy control
@ -318,6 +325,17 @@ public:
rotationalConstraints() const;
// Access to motion restraints
//- Return const reference to translational restraints
inline const PtrList<translationalRestraint>&
translationalRestraints() const;
//- Return const reference to rotational restraints
inline const PtrList<rotationalRestraint>&
rotationalRestraints() const;
// Virtual interface for 6DOF motion state
// Variables in relative coordinate system

View file

@ -139,4 +139,18 @@ Foam::sixDOFODE::rotationalConstraints() const
return rotationalConstraints_;
}
const Foam::PtrList<Foam::translationalRestraint>&
Foam::sixDOFODE::translationalRestraints() const
{
return translationalRestraints_;
}
const Foam::PtrList<Foam::rotationalRestraint>&
Foam::sixDOFODE::rotationalRestraints() const
{
return rotationalRestraints_;
}
// ************************************************************************* //