CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

How to apply an external forces on a moving body in interDyMFoam?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Larsa
  • 1 Post By JNSN

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 22, 2015, 08:58
Default How to apply an external forces on a moving body in interDyMFoam?
  #1
New Member
 
Lars Jonasson
Join Date: Oct 2014
Location: Sweden
Posts: 2
Rep Power: 0
Larsa is on a distinguished road
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
federicabi likes this.
Larsa is offline   Reply With Quote

Old   June 23, 2015, 07:50
Default
  #2
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 137
Rep Power: 19
JNSN is on a distinguished road
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
federicabi likes this.
JNSN is offline   Reply With Quote

Old   June 25, 2015, 02:41
Default
  #3
New Member
 
Lars Jonasson
Join Date: Oct 2014
Location: Sweden
Posts: 2
Rep Power: 0
Larsa is on a distinguished road
Hi Jan, thank you for clarifying this and thanks for you suggestions.

Have a nice day!
Lars
Larsa is offline   Reply With Quote

Old   May 11, 2016, 10:51
Default
  #4
Member
 
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10
federicabi is on a distinguished road
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
federicabi is offline   Reply With Quote

Old   May 12, 2016, 02:12
Default
  #5
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 137
Rep Power: 19
JNSN is on a distinguished road
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
JNSN is offline   Reply With Quote

Old   May 13, 2016, 05:49
Default
  #6
Member
 
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10
federicabi is on a distinguished road
Hi Jan, thank you very much for your answer

Federica
federicabi is offline   Reply With Quote

Old   May 20, 2016, 09:45
Default
  #7
Member
 
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10
federicabi is on a distinguished road
Quote:
Originally Posted by JNSN View Post
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
federicabi is offline   Reply With Quote

Old   September 5, 2016, 04:37
Default
  #8
New Member
 
Sachin Thakre
Join Date: Jun 2009
Location: Sweden
Posts: 25
Rep Power: 16
sachinthakre is on a distinguished road
Send a message via Skype™ to sachinthakre
Quote:
Originally Posted by federicabi View Post
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
sachinthakre is offline   Reply With Quote

Old   September 12, 2016, 09:27
Default
  #9
Member
 
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10
federicabi is on a distinguished road
Quote:
Originally Posted by sachinthakre View Post
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
federicabi is offline   Reply With Quote

Old   September 13, 2016, 05:15
Default
  #10
New Member
 
Sachin Thakre
Join Date: Jun 2009
Location: Sweden
Posts: 25
Rep Power: 16
sachinthakre is on a distinguished road
Send a message via Skype™ to sachinthakre
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
sachinthakre is offline   Reply With Quote

Old   September 14, 2016, 08:30
Default
  #11
Member
 
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10
federicabi is on a distinguished road
Quote:
Originally Posted by sachinthakre View Post
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
federicabi is offline   Reply With Quote

Old   September 20, 2016, 07:30
Default
  #12
New Member
 
Sachin Thakre
Join Date: Jun 2009
Location: Sweden
Posts: 25
Rep Power: 16
sachinthakre is on a distinguished road
Send a message via Skype™ to sachinthakre
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

Best,
Sachin
sachinthakre is offline   Reply With Quote

Old   October 7, 2016, 00:05
Default Same Issue Here
  #13
New Member
 
Deepak Saagar
Join Date: Jul 2013
Location: Cincinnati
Posts: 6
Rep Power: 12
deepaksaagar is on a distinguished road
Actually runTime.value() worked very well in OF 2. But the same code is giving problems in OF 4. Did you figure it out?
deepaksaagar is offline   Reply With Quote

Old   December 7, 2017, 05:21
Default explicit point force
  #14
New Member
 
jingyuanli
Join Date: Nov 2017
Posts: 4
Rep Power: 8
beishannmuyu is on a distinguished road
Quote:
Originally Posted by Larsa View Post
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
beishannmuyu is offline   Reply With Quote

Old   July 31, 2018, 10:41
Default
  #15
New Member
 
Mohamad
Join Date: Apr 2017
Location: Oxford, UK
Posts: 10
Rep Power: 9
mhasif02 is on a distinguished road
Quote:
Originally Posted by federicabi View Post
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
mhasif02 is offline   Reply With Quote

Reply

Tags
external force, interdymfoam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to perform a simulation of body moving in a sinusodial path underwater in STARCCM VinayKS STAR-CCM+ 3 May 4, 2022 11:40
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 19:43
CGNS Compiling Diego Main CFD Forum 17 December 21, 2014 01:40
how to apply pressure at only one side of a moving wall achyutan OpenFOAM Pre-Processing 2 January 8, 2014 05:45
Applying Body Forces in CFX MJ55 CFX 14 May 25, 2012 06:15


All times are GMT -4. The time now is 07:24.