CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to apply an external forces on a moving body in interDyMFoam? (https://www.cfd-online.com/Forums/openfoam-solving/154918-how-apply-external-forces-moving-body-interdymfoam.html)

Larsa June 22, 2015 08:58

How to apply an external forces on a moving body in interDyMFoam?
 
Hi, is is possible to apply an explicit point force to a moving object in interDyMFoam? I imagine this could be useful when modelling a marine craft with small wings/flaps attach. If the lift force of the appendege is known, one could just apply the force without explicitly mesh and model the details.

I cannot figure out how to specify this force or if it is even possible? Does anyone have an idea?

Regards
Lars

JNSN June 23, 2015 07:50

Hi Lars,

not possible at the moment. You must somehow change the sixDoFRigidBodyMotion library. One possibility would may be to modify the memberfunction "solve()" in sixDoFRigidBodyMotionSolver.C, where motion_.updateAcceleration(...) is called, similar how the mass forces are accounted for.

Good luck!
Jan

Larsa June 25, 2015 02:41

Hi Jan, thank you for clarifying this and thanks for you suggestions.

Have a nice day!
Lars

federicabi May 11, 2016 10:51

Hi Lars, hi Jan

I'm very interested in this argument, did you find a way to add an external force in interDyMFoam solver? any suggestion?

Best regards

Federica

JNSN May 12, 2016 02:12

Hi Frederica,

I think the easiest way is to create your own restraint. Have a look at the existing restraints, e.g. the linearSpring. There a force porportional to the velocity is computed and applied to the sixDoF Body. Copy an existing, rename and modify should be straight forward.

Best regards,
Jan

federicabi May 13, 2016 05:49

Hi Jan, thank you very much for your answer :)

Federica

federicabi May 20, 2016 09:45

Quote:

Originally Posted by JNSN (Post 599731)
Hi Frederica,

I think the easiest way is to create your own restraint. Have a look at the existing restraints, e.g. the linearSpring. There a force porportional to the velocity is computed and applied to the sixDoF Body. Copy an existing, rename and modify should be straight forward.

Best regards,
Jan

Hi!
I'm stuck on this problem, because I'm new in programming in openFOAM. I took a look at the .H and .c files of linearSpring restraint and I need to modify the restraintForce term with a time varying force composed like this: (Fx,0,Fx*tan(alpha)).


void Foam::sixDoFRigidBodyMotionRestraints::linearSprin g::restrain
(
const sixDoFRigidBodyMotion& motion,
vector& restraintPosition,
vector& restraintForce,
vector& restraintMoment
) const
{
restraintPosition = motion.transform(refAttachmentPt_);

vector r = restraintPosition - anchor_;

scalar magR = mag(r);
r /= (magR + VSMALL);

vector v = motion.velocity(restraintPosition);

restraintForce =

restraintMoment = vector::zero;

if (motion.report())
{
Info<< " attachmentPt - anchor " << r*magR
<< " spring length " << magR
<< " force " << restraintForce
<< endl;
}
}


Fx is the sum of Fx pressure and Fx viscous and it needs to be extract each time step from the forces.dat file. alpha is the angle between the initial position of the x-axis of the system and the new position, I think it can be extract from the motion.orientation() tensor each time step. The problem is that I don't know how to extract these data to put them into the linearSpring library.

Do you know how can I do that?
Your help would be very appreciated.

Regards

Federica

sachinthakre September 5, 2016 04:37

Quote:

Originally Posted by federicabi (Post 600963)
Hi!
I'm stuck on this problem, because I'm new in programming in openFOAM. I took a look at the .H and .c files of linearSpring restraint and I need to modify the restraintForce term with a time varying force composed like this: (Fx,0,Fx*tan(alpha)).


void Foam::sixDoFRigidBodyMotionRestraints::linearSprin g::restrain
(
const sixDoFRigidBodyMotion& motion,
vector& restraintPosition,
vector& restraintForce,
vector& restraintMoment
) const
{
restraintPosition = motion.transform(refAttachmentPt_);

vector r = restraintPosition - anchor_;

scalar magR = mag(r);
r /= (magR + VSMALL);

vector v = motion.velocity(restraintPosition);

restraintForce =

restraintMoment = vector::zero;

if (motion.report())
{
Info<< " attachmentPt - anchor " << r*magR
<< " spring length " << magR
<< " force " << restraintForce
<< endl;
}
}


Fx is the sum of Fx pressure and Fx viscous and it needs to be extract each time step from the forces.dat file. alpha is the angle between the initial position of the x-axis of the system and the new position, I think it can be extract from the motion.orientation() tensor each time step. The problem is that I don't know how to extract these data to put them into the linearSpring library.

Do you know how can I do that?
Your help would be very appreciated.

Regards

Federica


Dear Federica,

Did you get success in adding the external force in linearSpring.C file ?
I need a similar modification in linearSpring.C file, but I am still wondering how to do it. If you have already managed to do, it will be great if you could share the idea.

Apparently, in OpenFOAM 4 release, they have made a provision to add external forces, in rigid body Dynamics/rigidBodyMeshMotion

http://openfoam.org/release/4-0/

However, I don't know how to use it.

Thanks and regards,
Sachin

federicabi September 12, 2016 09:27

Quote:

Originally Posted by sachinthakre (Post 616586)
Dear Federica,

Did you get success in adding the external force in linearSpring.C file ?
I need a similar modification in linearSpring.C file, but I am still wondering how to do it. If you have already managed to do, it will be great if you could share the idea.

Apparently, in OpenFOAM 4 release, they have made a provision to add external forces, in rigid body Dynamics/rigidBodyMeshMotion

http://openfoam.org/release/4-0/

However, I don't know how to use it.

Thanks and regards,
Sachin

Hello Sachin,

I compiled without errors this customized linearSpring, but I haven't tried it yet because I'm still stuck on the convergence of 0DoF cases.
However here is my solution

variableLinearSpring.C

Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    |
    \\  /    A nd          | Copyright (C) 2011-2015 OpenFOAM Foundation
    \\/    M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM 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.

    OpenFOAM 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 OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "variableLinearSpring.H"
#include "addToRunTimeSelectionTable.H"
#include "sixDoFRigidBodyMotion.H"

#include "forces.H"
#include "IOobject.H"
#include "dictionary.H"
#include "Time.H"
#include "IOmanip.H"
#include "Pstream.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace sixDoFRigidBodyMotionRestraints
{
    defineTypeNameAndDebug(variableLinearSpring, 0);

    addToRunTimeSelectionTable
    (
        sixDoFRigidBodyMotionRestraint,
        variableLinearSpring,
        dictionary
    );
}
}


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::variableLinearSpring
(
    const word& name,
    const dictionary& sDoFRBMRDict 
)
:
    sixDoFRigidBodyMotionRestraint(name, sDoFRBMRDict),
    refAttachmentPt_(),
    alfaini_(),
    forzaxini_()
   
{
    read(sDoFRBMRDict);
}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::~variableLinearSpring()
{}


// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //

void Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::restrain
(
    const sixDoFRigidBodyMotion& motion,
    vector& restraintPosition,
    vector& restraintForce,
    vector& restraintMoment
 
) const
{
    static bool firstIt_ = true;
    scalar alfa;
    scalar forzax;
    scalar forzaxPrevIter;
    scalar alfaPrevIter;
   
 
    if (firstIt_)
    {
    alfa = alfaini_;
    forzax = forzaxini_;
    }
    else
    {
      FILE *forze;
      scalar timestep;
      scalar fxp;
      scalar fyp;
      scalar fzp;
      scalar fxv;
      scalar fyv;
      scalar fzv;
      scalar fxpo;
      scalar fypo;
      scalar fzpo;
      scalar mxp;
      scalar myp;
      scalar mzp;
      scalar mxv;
      scalar myv;
      scalar mzv;
      scalar mxpo;
      scalar mypo;
      scalar mzpo;
      forze = fopen("postProcessing/forces/0.3/forces.dat", "r");

      scanf("%*[^\n]");  /* Skip to the End of the Line */
   
      for (int i = 1; i <= 3; i++)
      {
      scanf("%*1[\n]");  /* Skip Three Newline */
      }

      fscanf(forze, "%le    ((%le %le %le) (%le %le %le) (%le %le %le)) ((%le %le %le) (%le %le %le) (%le %le %le))", &timestep, &fxp, &fyp, &fzp, &fxv, &fyv, &fzv, &fxpo, &fypo, &fzpo, &mxp, &myp, &mzp, &mxv, &myv, &mzv, &mxpo, &mypo, &mzpo);

      fclose(forze);
     
      forzaxPrevIter = fxp + fxv + fxpo;
     
      alfaPrevIter = asin(motion.orientation()[7]);
     
      alfa = alfaPrevIter;
      forzax = forzaxPrevIter;
    }
   
    restraintPosition = motion.transform(refAttachmentPt_);

    vector v = motion.velocity(restraintPosition);

    restraintForce = vector(forzax,0,forzax*tan(alfa));

    restraintMoment = vector::zero;

    if (motion.report())
    {
        Info<< " attachmentPt" << restraintPosition
            << " force " << restraintForce
            << endl;
    }
       
    firstIt_ = false;
}

     
bool Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::read
(
    const dictionary& sDoFRBMRDict
)
{
    sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);

    sDoFRBMRCoeffs_.lookup("refAttachmentPt") >> refAttachmentPt_;
    sDoFRBMRCoeffs_.lookup("alfaini") >> alfaini_;
    sDoFRBMRCoeffs_.lookup("forzaxini") >> forzaxini_;
   

    return true;
}


void Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::write
(
    Ostream& os
) const
{
    os.writeKeyword("refAttachmentPt")
        << refAttachmentPt_ << token::END_STATEMENT << nl;

    os.writeKeyword("alfaini")
        << alfaini_ << token::END_STATEMENT << nl;

    os.writeKeyword("forzaxini")
        << forzaxini_ << token::END_STATEMENT << nl;
   
   
}

variableLinearSpring.H

Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    |
    \\  /    A nd          | Copyright (C) 2011-2013 OpenFOAM Foundation
    \\/    M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM 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.

    OpenFOAM 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 OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
    Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring

Description
    sixDoFRigidBodyMotionRestraints model. Variable Linear spring.

SourceFiles
    variableLinearSpring.C

\*---------------------------------------------------------------------------*/

#ifndef variableLinearSpring_H
#define variableLinearSpring_H

#include "sixDoFRigidBodyMotionRestraint.H"
#include "point.H"


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

namespace sixDoFRigidBodyMotionRestraints
{

/*---------------------------------------------------------------------------*\
                          Class variableLinearSpring Declaration
\*---------------------------------------------------------------------------*/

class variableLinearSpring
:
    public sixDoFRigidBodyMotionRestraint
{
    // Private data

        //- Punto di applicazione del traino (punto elica)
        point refAttachmentPt_;

        //- Angolo di inclinazione della linea d'assi
    scalar alfaini_;
   
    //- Forza di resistenza iniziale
    scalar forzaxini_;
   
   
public:

    //- Runtime type information
    TypeName("variableLinearSpring");


    // Constructors

        //- Construct from components
        variableLinearSpring
        (
            const word& name,
            const dictionary& sDoFRBMRDict
        );

        //- Construct and return a clone
        virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const
        {
            return autoPtr<sixDoFRigidBodyMotionRestraint>
            (
                new variableLinearSpring(*this)
            );
        }


    //- Destructor
    virtual ~variableLinearSpring();


    // Member Functions

        //- Calculate the restraint position, force and moment.
        //  Global reference frame vectors.
        virtual void restrain
        (
            const sixDoFRigidBodyMotion& motion,
            vector& restraintPosition,
            vector& restraintForce,
            vector& restraintMoment
       
        ) const;
   
       
        //- Update properties from given dictionary
        virtual bool read(const dictionary& sDoFRBMRCoeff);

        //- Write
        virtual void write(Ostream&) const;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace solidBodyMotionFunctions
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //

If you try it, please let me know your results.

Best regards

Federica

sachinthakre September 13, 2016 05:15

Dear Federica,

Thank you very much for your modified file! I had a look at it. It is interesting. I will try if I could do some Changes according to my need.

Actually, in my case, I want to modify the restraintForce equation by adding the external force term in the following way.

restraintForce = -stiffness_*(magR - restLength_)*r - damping_*(r & v)*r + F;

where, F = F0*sin(Omega*time)

I want to put in the "time" there, which I couldn't when I tried. Do you think, it can be done easily?

Best regards,
Sachin

federicabi September 14, 2016 08:30

Quote:

Originally Posted by sachinthakre (Post 617705)
Dear Federica,

Thank you very much for your modified file! I had a look at it. It is interesting. I will try if I could do some Changes according to my need.

Actually, in my case, I want to modify the restraintForce equation by adding the external force term in the following way.

restraintForce = -stiffness_*(magR - restLength_)*r - damping_*(r & v)*r + F;

where, F = F0*sin(Omega*time)

I want to put in the "time" there, which I couldn't when I tried. Do you think, it can be done easily?

Best regards,
Sachin

Hi Sachin,

I understand your issue, I'm not good at programming in OpenFOAM but I found in the forum this post http://www.cfd-online.com/Forums/ope...vity-time.html where Alberto suggests to use runTime.timeName() as time variable, check it out!

Best regards

Federica

sachinthakre September 20, 2016 07:30

Dear Federica,

Thank you very much for this input! It certainly gave me some room to think about time implementation in linearSpring.C.

I actually, tried the runTime.timeName() and also, runTime.value(), but it didn't work in my case. :(

It seems, I need to find some other way:confused:

Best,
Sachin

deepaksaagar October 7, 2016 00:05

Same Issue Here
 
Actually runTime.value() worked very well in OF 2. But the same code is giving problems in OF 4. Did you figure it out?:confused:

beishannmuyu December 7, 2017 05:21

explicit point force
 
Quote:

Originally Posted by Larsa (Post 551528)
Hi, is is possible to apply an explicit point force to a moving object in interDyMFoam? I imagine this could be useful when modelling a marine craft with small wings/flaps attach. If the lift force of the appendege is known, one could just apply the force without explicitly mesh and model the details.

I cannot figure out how to specify this force or if it is even possible? Does anyone have an idea?

Regards
Lars


hi Lars
Has your problem been solved? Do you solve your problem by using new version V1706 ? I have a question ask you ,Whether this external force can make an object in the water along a uniform linear motion?
Do not use this LingeSpring, you know what better way or simple method achieve a sphere in the water uniform linear motion it?
thanks

mhasif02 July 31, 2018 10:41

Quote:

Originally Posted by federicabi (Post 617591)
Hello Sachin,

I compiled without errors this customized linearSpring, but I haven't tried it yet because I'm still stuck on the convergence of 0DoF cases.
However here is my solution

variableLinearSpring.C

Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    |
    \\  /    A nd          | Copyright (C) 2011-2015 OpenFOAM Foundation
    \\/    M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM 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.

    OpenFOAM 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 OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "variableLinearSpring.H"
#include "addToRunTimeSelectionTable.H"
#include "sixDoFRigidBodyMotion.H"

#include "forces.H"
#include "IOobject.H"
#include "dictionary.H"
#include "Time.H"
#include "IOmanip.H"
#include "Pstream.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace sixDoFRigidBodyMotionRestraints
{
    defineTypeNameAndDebug(variableLinearSpring, 0);

    addToRunTimeSelectionTable
    (
        sixDoFRigidBodyMotionRestraint,
        variableLinearSpring,
        dictionary
    );
}
}


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::variableLinearSpring
(
    const word& name,
    const dictionary& sDoFRBMRDict 
)
:
    sixDoFRigidBodyMotionRestraint(name, sDoFRBMRDict),
    refAttachmentPt_(),
    alfaini_(),
    forzaxini_()
   
{
    read(sDoFRBMRDict);
}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::~variableLinearSpring()
{}


// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //

void Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::restrain
(
    const sixDoFRigidBodyMotion& motion,
    vector& restraintPosition,
    vector& restraintForce,
    vector& restraintMoment
 
) const
{
    static bool firstIt_ = true;
    scalar alfa;
    scalar forzax;
    scalar forzaxPrevIter;
    scalar alfaPrevIter;
   
 
    if (firstIt_)
    {
    alfa = alfaini_;
    forzax = forzaxini_;
    }
    else
    {
      FILE *forze;
      scalar timestep;
      scalar fxp;
      scalar fyp;
      scalar fzp;
      scalar fxv;
      scalar fyv;
      scalar fzv;
      scalar fxpo;
      scalar fypo;
      scalar fzpo;
      scalar mxp;
      scalar myp;
      scalar mzp;
      scalar mxv;
      scalar myv;
      scalar mzv;
      scalar mxpo;
      scalar mypo;
      scalar mzpo;
      forze = fopen("postProcessing/forces/0.3/forces.dat", "r");

      scanf("%*[^\n]");  /* Skip to the End of the Line */
   
      for (int i = 1; i <= 3; i++)
      {
      scanf("%*1[\n]");  /* Skip Three Newline */
      }

      fscanf(forze, "%le    ((%le %le %le) (%le %le %le) (%le %le %le)) ((%le %le %le) (%le %le %le) (%le %le %le))", &timestep, &fxp, &fyp, &fzp, &fxv, &fyv, &fzv, &fxpo, &fypo, &fzpo, &mxp, &myp, &mzp, &mxv, &myv, &mzv, &mxpo, &mypo, &mzpo);

      fclose(forze);
     
      forzaxPrevIter = fxp + fxv + fxpo;
     
      alfaPrevIter = asin(motion.orientation()[7]);
     
      alfa = alfaPrevIter;
      forzax = forzaxPrevIter;
    }
   
    restraintPosition = motion.transform(refAttachmentPt_);

    vector v = motion.velocity(restraintPosition);

    restraintForce = vector(forzax,0,forzax*tan(alfa));

    restraintMoment = vector::zero;

    if (motion.report())
    {
        Info<< " attachmentPt" << restraintPosition
            << " force " << restraintForce
            << endl;
    }
       
    firstIt_ = false;
}

     
bool Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::read
(
    const dictionary& sDoFRBMRDict
)
{
    sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);

    sDoFRBMRCoeffs_.lookup("refAttachmentPt") >> refAttachmentPt_;
    sDoFRBMRCoeffs_.lookup("alfaini") >> alfaini_;
    sDoFRBMRCoeffs_.lookup("forzaxini") >> forzaxini_;
   

    return true;
}


void Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring::write
(
    Ostream& os
) const
{
    os.writeKeyword("refAttachmentPt")
        << refAttachmentPt_ << token::END_STATEMENT << nl;

    os.writeKeyword("alfaini")
        << alfaini_ << token::END_STATEMENT << nl;

    os.writeKeyword("forzaxini")
        << forzaxini_ << token::END_STATEMENT << nl;
   
   
}

variableLinearSpring.H

Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    |
    \\  /    A nd          | Copyright (C) 2011-2013 OpenFOAM Foundation
    \\/    M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM 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.

    OpenFOAM 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 OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
    Foam::sixDoFRigidBodyMotionRestraints::variableLinearSpring

Description
    sixDoFRigidBodyMotionRestraints model. Variable Linear spring.

SourceFiles
    variableLinearSpring.C

\*---------------------------------------------------------------------------*/

#ifndef variableLinearSpring_H
#define variableLinearSpring_H

#include "sixDoFRigidBodyMotionRestraint.H"
#include "point.H"


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

namespace sixDoFRigidBodyMotionRestraints
{

/*---------------------------------------------------------------------------*\
                          Class variableLinearSpring Declaration
\*---------------------------------------------------------------------------*/

class variableLinearSpring
:
    public sixDoFRigidBodyMotionRestraint
{
    // Private data

        //- Punto di applicazione del traino (punto elica)
        point refAttachmentPt_;

        //- Angolo di inclinazione della linea d'assi
    scalar alfaini_;
   
    //- Forza di resistenza iniziale
    scalar forzaxini_;
   
   
public:

    //- Runtime type information
    TypeName("variableLinearSpring");


    // Constructors

        //- Construct from components
        variableLinearSpring
        (
            const word& name,
            const dictionary& sDoFRBMRDict
        );

        //- Construct and return a clone
        virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const
        {
            return autoPtr<sixDoFRigidBodyMotionRestraint>
            (
                new variableLinearSpring(*this)
            );
        }


    //- Destructor
    virtual ~variableLinearSpring();


    // Member Functions

        //- Calculate the restraint position, force and moment.
        //  Global reference frame vectors.
        virtual void restrain
        (
            const sixDoFRigidBodyMotion& motion,
            vector& restraintPosition,
            vector& restraintForce,
            vector& restraintMoment
       
        ) const;
   
       
        //- Update properties from given dictionary
        virtual bool read(const dictionary& sDoFRBMRCoeff);

        //- Write
        virtual void write(Ostream&) const;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace solidBodyMotionFunctions
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //

If you try it, please let me know your results.

Best regards

Federica





Hi Federica,

I tried modifying the linearSpring based on your variableLinearSpring.C and .H files. It does not show any error during compilation. But when I test it, the force shows 0 value at every timestep. Have you tried it yourself and does it work?

Regards,
Mohamad


All times are GMT -4. The time now is 06:38.