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

Imposing an oscillating linear motion with a sudden stop through the dynamicMeshDict

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 21, 2019, 15:28
Default Imposing an oscillating linear motion with a sudden stop through the dynamicMeshDict
  #1
New Member
 
Élio Pereira
Join Date: Dec 2017
Location: Lisbon
Posts: 5
Rep Power: 9
eliocpereira is on a distinguished road
I would like to know how to impose an oscillating linear motion with a sudden stop to a body. I know how to impose an oscillating linear motion. I wrote the following lines in the dynamicMeshDict:

Code:
dynamicFvMesh   dynamicMotionSolverFvMesh;

motionSolver    solidBody;

solidBodyMotionFunction multiMotion;

oscillation
{
    solidBodyMotionFunction oscillatingLinearMotion; //Sinusoidal translation motion 
    oscillatingLinearMotionCoeffs  
    {
        amplitude     (0.02 0 0);  //amplitude vector of the sinusoidal translation [m]
        omega         21.9838;     //angular frequency of the sinusoidal translation [rad/s]
    }
}
Let us consider now a sudden stop at instant t=t_s. How could I express this in this code? For example, is it possible to use a step function at the amplitude entry, so that it goes zero when t=t_s?
eliocpereira is offline   Reply With Quote

Old   February 22, 2019, 09:28
Default
  #2
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!


What if you try the timeActivatedFIleUpdate function object:
https://cpp.openfoam.org/v6/timeActi...8H_source.html
Just create 2 dynamicMeshDicts, and at the given time just copy the 2nd one.
I'm not sure if OF reads the dynamicMeshDict if it is modified. If not, the much easier way is to run the simulation to the time when the motion should stop, manually (through a script) change the dynMesDict file, and the end time of the simulation. And continue the run. I think this is not a professional move, but simple and working.
simrego is offline   Reply With Quote

Old   February 23, 2019, 15:57
Default
  #3
New Member
 
Élio Pereira
Join Date: Dec 2017
Location: Lisbon
Posts: 5
Rep Power: 9
eliocpereira is on a distinguished road
I added this code to my controlDict file inside "functions":

Code:
    fileUpdate1                  //substitute a file at a given instant
    {
        type              timeActivatedFileUpdate;
        libs ("libutilityFunctionObjects.so");
        writeControl     timeStep;
        writeInterval    1;
        fileToUpdate      "$FOAM_CASE/constant/dynamicMeshDict"; //file to be substituted
        timeVsFile
        (
            (-1  "$FOAM_CASE/constant/dynamicMeshDict.1")        //substitution at t=0s
            (0.3 "$FOAM_CASE/constant/dynamicMeshDict.2")        //substituition at t=0.3s
        );
    }
I also placed my dynamicMeshDict.1 and dynamicMeshDict.2 files in the "constant" paste. I found out that the dynamicMeshDict file isn't re-read after the changes. Is there any option that needs to be added to the fileUpdate1 function so that OpenFOAM could read again the dynamicMeshDict file?

Last edited by eliocpereira; February 25, 2019 at 05:46.
eliocpereira is offline   Reply With Quote

Old   February 24, 2019, 21:37
Default
  #4
New Member
 
Élio Pereira
Join Date: Dec 2017
Location: Lisbon
Posts: 5
Rep Power: 9
eliocpereira is on a distinguished road
I now tried to change the oscillatingLinearMotion.C and oscillatingLinearMotion.H files, so that they could do what I desired. I defined a new SBMFCoeffs variable: ts, which is the stopping instant of the oscillation. I changed the formula for the oscillation, using comparison operators:

Code:
const vector displacement = amplitude_*sin(omega_*t)*(t<ts_) + amplitude_*sin(omega_*ts_)*(t>=ts_);
You can see the new oscillatingLinearMotion.C and oscillatingLinearMotion.H files here ( and the dynamicMeshDict file as well):https://www.dropbox.com/sh/9mueknp5y...zBWamXcEa?dl=0

I discovered that the changes to the files actually didn't change anything. It felt like OpenFOAM used the old files instead of the new ones, although the old were substituted. I even tried a simple change: only putting a factor 2 multiplying the frequency in the sine function, so that I could expect a two times faster oscillation. Still, the results were the same as before, nothing changed. Why isn't OpenFOAM reading my changes?.
eliocpereira is offline   Reply With Quote

Old   February 25, 2019, 08:39
Default
  #5
New Member
 
Élio Pereira
Join Date: Dec 2017
Location: Lisbon
Posts: 5
Rep Power: 9
eliocpereira is on a distinguished road
I eventually made OpenFOAM recognize the changes that I did to the .C and .H files, by running the related makefile after. Basically I changed directory to where the "Make" folder lives, then I logged in as root and ran the makefile. To do this, I wrote the following commands at the terminal:

Code:
cd  /opt/openfoam6/src/dynamicMesh
sudo bash
wmake
eliocpereira is offline   Reply With Quote

Old   February 25, 2019, 08:52
Default
  #6
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Sorry for the late answer. So yes. That's why I told you in this case you can try to simply stop the simulation and the continua with the changed motion.
The next approach would be the new dynMesh solver, or a more better one if you use a coded one.
You should NOT modify the original code. You can do it, but next time you forget that, you use this motion solver, and you will have no idea what the hack is happening. :/
In this case it is better if you create a new library for yourself. (copy paste original, rename, rewrite, you can use.)
simrego is offline   Reply With Quote

Reply

Tags
dynamicmeshdict, motion dynamicmesh, openfoam, oscillating


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
AMI with linear translation motion macti OpenFOAM 2 June 27, 2017 12:05
solution diverges when linear upwind interpolation scheme is used subash OpenFOAM 0 May 29, 2010 02:23
IdeasUnvToFoam Bug amp Fix benru OpenFOAM Bugs 42 November 13, 2009 08:59
rotation and linear motion Chroko CFX 5 August 26, 2009 19:34
Is linear motion possible to model in CFX? abe CFX 0 January 10, 2006 01:05


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