CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Including run time as variable in dynamicMeshDict

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 14, 2017, 10:04
Default Including run time as variable in dynamicMeshDict
  #1
New Member
 
R Kyle
Join Date: Feb 2017
Location: Scotland
Posts: 11
Rep Power: 9
RKyle is on a distinguished road
Hi there,

I'm looking to include a dynamic motion as a function of time in my dynamicMeshDict but now sure how to. I basically need to change the rotation axis depending on the run time. Does anyone have any idea or has done this before?

I saw one post using "scalar t=runTime.value();" but I'm probably using it wrongly (I've been fiddling with a simple case to see if it works). I get an error message saying '$t was not declared in this scope'. I've attached a snippet of my dynamicMeshDict to show how I've used it mainly to see if it can work first.



/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dynamicFvMesh solidBodyMotionFvMesh;

motionSolverLibs ( "libfvMotionSolvers.so" );


scalar t=runTime.value();

solidBodyMotionFvMeshCoeffs
{

solidBodyMotionFunction multiMotion;
multiMotionCoeffs

{

Rotation
{
cellZone RotorCylinder;
solidBodyMotionFunction rotatingMotion;
rotatingMotionCoeffs
{

origin (0 0 0);
axis (1 0 0);
omega #calc "3.5*$t"; // rad/s
}
}

.....

Any tips and pointers would be greatly appreciated!


Kind regards,

Ryan
RKyle is offline   Reply With Quote

Old   September 27, 2017, 16:50
Default rotation as a function of time
  #2
Senior Member
 
Jon Elvar Wallevik
Join Date: Nov 2010
Location: Reykjavik, ICELAND
Posts: 103
Rep Power: 20
JonW will become famous soon enough
cd $HOME/OpenFOAM/OpenFOAM-2.3.1/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/

cd rotatingMotion

gedit rotatingMotion.C

in the function (line 73)
Foam::septernion
Foam::solidBodyMotionFunctions::rotatingMotion::tr ansformation() const
you can do your stuff

I added ...

const scalar PI = constant::mathematical:i;

// scalar angle = omega_->integrate(0, t);
scalar angle = Foam::sin(1.0*PI*t)*omega_->integrate(0, t);

Now you have sinus type of rotation. You can add other functions, like atan if you want a steady increase and then steady state rotation.
---------------------------------------------------------------------------

In ./constant/dynamicMeshDict

dynamicFvMesh solidBodyMotionFvMesh;

solidBodyMotionFvMeshCoeffs
{
cellZone none; // none => the whole mesh rotates.
// if you want only part of it to rotate, you have to define
// that region. see examples in openfoam wiki
solidBodyMotionFunction rotatingMotion;

rotatingMotionCoeffs
{
origin ( 0 0 0 );
axis ( 0 0 1 );
omega 1.4451; // rad/s // omega = 2*pi*(0.23 rps)
}
}
JonW is offline   Reply With Quote

Old   October 4, 2017, 07:59
Default
  #3
New Member
 
R Kyle
Join Date: Feb 2017
Location: Scotland
Posts: 11
Rep Power: 9
RKyle is on a distinguished road
Thanks for the reply, JonW! This is helpful, it seems relatively straightforward to tweak the code to do something like this.

However (and this is my fault) I should have given the example code more in line with that I am aiming to do; there I was trying to change omega as a way of playing around with the time value but that's not what my goal is. What I actually need to do is move the origin (centre of rotation) with time. Imagine a pendulum moving, I'm trying to keep the centre of rotation at the tip of it.

I've discovered the tabulated6DoFMotion option, which seems good. It reads the rotation/translation in the form of a table so that there's a rotation/translation in terms of degrees and metres for each time step. If I could do the same with the CofG (origin) that would be ideal! It's like this in the dynamicMeshDict:


Pitching
{
cellZone "Rotor.*";
solidBodyMotionFunction tabulated6DoFMotion;
tabulated6DoFMotionCoeffs
{
CofG (-0.2 -0.2818 0);
timeDataFileName "$FOAM_CASE/constant/6DoF.dat";
}
}


The rotation/translation table listed in the 6DoF.dat file within the /constant folder looks like this, for example:


//(time ((x trans, y trans, z trans) (x rot y rot z rot))) about CofG
5001 //number of entries
(
(0.0 ((0 0 0) (0.144977489506 0 0)))
(0.002 ((0 0 0) (0.289958382958 0 0)))
(0.004 ((0 0 0) (0.434942669873 0 0)))
(0.006 ((0 0 0) (0.579930339763 0 0)))
(0.008 ((0 0 0) (0.724921382128 0 0)))
(0.01 ((0 0 0) (0.869915786463 0 0)))
(0.012 ((0 0 0) (1.01491354225 0 0)))
(0.014 ((0 0 0) (1.15991463898 0 0)))
...

Again, any help in doing the same with the CofG would be great! In the mean time, I'm doing my C++ homework..


Thanks again,

Ryan
RKyle is offline   Reply With Quote

Old   October 4, 2017, 13:07
Default
  #4
Senior Member
 
Jon Elvar Wallevik
Join Date: Nov 2010
Location: Reykjavik, ICELAND
Posts: 103
Rep Power: 20
JonW will become famous soon enough
Hi Ryan
This is very interesting what you are trying to do. Unfortunately, I don't have an answer. I have been reading (when I have time) about the dynamicMesh thingi for the past weeks, when I have time (which is not much). But I am not where you are now in this. Hopefully, I will be there soon enough. If I come across ideas, I will let you know.
Good luck (to both of us)
J.
JonW is offline   Reply With Quote

Old   March 26, 2023, 01:39
Default
  #5
New Member
 
Bakhshi Mehul
Join Date: Mar 2023
Posts: 5
Rep Power: 3
Bakhshi is on a distinguished road
Quote:
Originally Posted by RKyle View Post
Thanks for the reply, JonW! This is helpful, it seems relatively straightforward to tweak the code to do something like this.

However (and this is my fault) I should have given the example code more in line with that I am aiming to do; there I was trying to change omega as a way of playing around with the time value but that's not what my goal is. What I actually need to do is move the origin (centre of rotation) with time. Imagine a pendulum moving, I'm trying to keep the centre of rotation at the tip of it.

I've discovered the tabulated6DoFMotion option, which seems good. It reads the rotation/translation in the form of a table so that there's a rotation/translation in terms of degrees and metres for each time step. If I could do the same with the CofG (origin) that would be ideal! It's like this in the dynamicMeshDict:


Pitching
{
cellZone "Rotor.*";
solidBodyMotionFunction tabulated6DoFMotion;
tabulated6DoFMotionCoeffs
{
CofG (-0.2 -0.2818 0);
timeDataFileName "$FOAM_CASE/constant/6DoF.dat";
}
}


The rotation/translation table listed in the 6DoF.dat file within the /constant folder looks like this, for example:


//(time ((x trans, y trans, z trans) (x rot y rot z rot))) about CofG
5001 //number of entries
(
(0.0 ((0 0 0) (0.144977489506 0 0)))
(0.002 ((0 0 0) (0.289958382958 0 0)))
(0.004 ((0 0 0) (0.434942669873 0 0)))
(0.006 ((0 0 0) (0.579930339763 0 0)))
(0.008 ((0 0 0) (0.724921382128 0 0)))
(0.01 ((0 0 0) (0.869915786463 0 0)))
(0.012 ((0 0 0) (1.01491354225 0 0)))
(0.014 ((0 0 0) (1.15991463898 0 0)))
...

Again, any help in doing the same with the CofG would be great! In the mean time, I'm doing my C++ homework..


Thanks again,

Ryan
Hey RKyle!

Were you able to figure out how to move origin with time? I am working on a similar case where I have to rotate a cylindrical domain in dynamicMeshDict file whose's origin is changing with time.
Bakhshi is offline   Reply With Quote

Reply


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
Elastic or Plastic Deformations in OpenFOAM NickolasPl OpenFOAM Pre-Processing 36 September 23, 2023 09:22
courant number increases to rather large values 6863523 OpenFOAM Running, Solving & CFD 22 July 6, 2023 00:48
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 03:36
AMI speed performance danny123 OpenFOAM 21 October 24, 2020 05:13
Star cd es-ice solver error ernarasimman STAR-CD 2 September 12, 2014 01:01


All times are GMT -4. The time now is 02:32.