|
[Sponsors] |
How to apply an external forces on a moving body in interDyMFoam? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 22, 2015, 09:58 |
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 |
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 |
|
June 23, 2015, 08:50 |
|
#2 |
Senior Member
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 144
Rep Power: 20 |
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 |
|
June 25, 2015, 03:41 |
|
#3 |
New Member
Lars Jonasson
Join Date: Oct 2014
Location: Sweden
Posts: 2
Rep Power: 0 |
Hi Jan, thank you for clarifying this and thanks for you suggestions.
Have a nice day! Lars |
|
May 11, 2016, 11:51 |
|
#4 |
Member
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10 |
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 |
|
May 12, 2016, 03:12 |
|
#5 |
Senior Member
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 144
Rep Power: 20 |
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 |
|
May 13, 2016, 06:49 |
|
#6 |
Member
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10 |
Hi Jan, thank you very much for your answer
Federica |
|
May 20, 2016, 10:45 |
|
#7 | |
Member
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10 |
Quote:
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 |
||
September 5, 2016, 05:37 |
|
#8 | |
New Member
|
Quote:
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 |
||
September 12, 2016, 10:27 |
|
#9 | |
Member
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10 |
Quote:
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))", ×tep, &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; } 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 // ************************************************************************* // Best regards Federica |
||
September 13, 2016, 06:15 |
|
#10 |
New Member
|
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 |
|
September 14, 2016, 09:30 |
|
#11 | |
Member
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10 |
Quote:
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 |
||
September 20, 2016, 08:30 |
|
#12 |
New Member
|
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 |
|
October 7, 2016, 01:05 |
Same Issue Here
|
#13 |
New Member
Deepak Saagar
Join Date: Jul 2013
Location: Cincinnati
Posts: 6
Rep Power: 13 |
Actually runTime.value() worked very well in OF 2. But the same code is giving problems in OF 4. Did you figure it out?
|
|
December 7, 2017, 06:21 |
explicit point force
|
#14 | |
New Member
jingyuanli
Join Date: Nov 2017
Posts: 4
Rep Power: 9 |
Quote:
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 |
||
July 31, 2018, 11:41 |
|
#15 | |
New Member
Mohamad
Join Date: Apr 2017
Location: Oxford, UK
Posts: 10
Rep Power: 9 |
Quote:
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 |
||
Tags |
external force, interdymfoam |
|
|
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 12:40 |
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch | gschaider | OpenFOAM Installation | 225 | August 25, 2015 20:43 |
CGNS Compiling | Diego | Main CFD Forum | 17 | December 21, 2014 02:40 |
how to apply pressure at only one side of a moving wall | achyutan | OpenFOAM Pre-Processing | 2 | January 8, 2014 06:45 |
Applying Body Forces in CFX | MJ55 | CFX | 14 | May 25, 2012 07:15 |