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

Customize linearSpring restraint

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 23, 2016, 09:50
Default Customize linearSpring restraint
  #1
Member
 
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10
federicabi is on a distinguished road
Hi everyone!
I'm stuck on a problem, because I'm new in programming in openFOAM. I need to compile a new restraint similar to linearSpring, so 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)).
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.

I tried to modify the library like below


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 = vector(Fx,0,Fx*tan(alpha))

restraintMoment = vector::zero;

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

Now I need to build a new function in this dictionary to extract Fx and alpha.
Anyone knows how can I do that?
Your help would be very appreciated.

Best regards

Federica
federicabi is offline   Reply With Quote

Old   May 30, 2016, 06:21
Default
  #2
Member
 
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10
federicabi is on a distinguished road
Hi,
I have tried to write the code and then to compile it, but openFOAM gives me errors. In particular I'm worried about this error

In file included from linearSpringFede1.C:26:0:
linearSpringFede1.H: In member function ‘virtual Foam::autoPtr<Foam::sixDoFRigidBodyMotionRestraint > Foam::sixDoFRigidBodyMotionRestraints::linearSprin gFede1::clone() const’:
linearSpringFede1.H:104:44: error: cannot allocate an object of abstract type ‘Foam::sixDoFRigidBodyMotionRestraints::linearSpri ngFede1’
new linearSpringFede1(*this)
^
linearSpringFede1.H:56:7: note: because the following virtual functions are pure within ‘Foam::sixDoFRigidBodyMotionRestraints::linearSpri ngFede1’:
class linearSpringFede1
^

I haven't modified this part, except for the name of the restraint.
Do you know how can I fix it?

Best regards

Federica
Attached Files
File Type: h linearSpringFede1.H (4.0 KB, 10 views)
File Type: c linearSpringFede1.C (4.8 KB, 14 views)

Last edited by federicabi; June 9, 2016 at 10:25.
federicabi is offline   Reply With Quote

Old   June 9, 2016, 10:42
Thumbs up Solved
  #3
Member
 
Federica Biano
Join Date: Feb 2016
Location: Genova, Italy
Posts: 39
Rep Power: 10
federicabi is on a distinguished road
Solved.

I added 3 more variables to a function argument, into the header file, instead defining them into the function itself.
federicabi is offline   Reply With Quote

Old   March 28, 2019, 07:18
Default
  #4
New Member
 
Mohamad
Join Date: Apr 2017
Location: Oxford, UK
Posts: 10
Rep Power: 9
mhasif02 is on a distinguished road
Hi Federica,

I'm having the same error when compiling this linearSpring restraint. How did you fix it? what did you add inside the .H file?

Mohamad
mhasif02 is offline   Reply With Quote

Reply

Tags
forces, linearspring


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
SixDoFRigidBodyMotion under OF2.3 ( self oscillating cylinder) Scabbard OpenFOAM Running, Solving & CFD 1 July 22, 2014 05:50
how to customize the initial velocity and temperature field? gdtiaozi FLOW-3D 1 December 3, 2013 08:13
How to customize FLOW-3D in Windows? therockyy FLOW-3D 1 December 9, 2010 17:43
Customize Heat Flux Distribution Using UDF Ken Adams FLUENT 0 May 25, 2007 16:25
Can I Customize Fluent Environment venugopal FLUENT 0 June 16, 2004 13:15


All times are GMT -4. The time now is 15:56.