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

Creating relative fluid-velocityfield in pimpleDyMFoam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 19, 2013, 05:22
Default Creating relative fluid-velocityfield in pimpleDyMFoam
  #1
New Member
 
David J.
Join Date: Jun 2013
Location: Magdeburg
Posts: 2
Rep Power: 0
jFoam is on a distinguished road
Dear Foamers,

first of all I'd like to say that this is a really nice forum. It already helped me in several situations before my registration, but now my problems got too specific, so it was time to create my first thread. :)

In my bachelor thesis I have to solve a case with an angular accelerated cooling circuit.
In order to do so I have to work with the solvers pimpleDyMFoam / interDyMFoam (OpenFOAM version 2.2.0) for dynamic mesh simulation.
So at first I started with a generic 2D-case of a water circuit which is moved with a constant angular velocity.

Unfortunately, when I took a look at the velocity field of the solution I noticed that the velocity field was absolute.
Now I would like to visualise the pipe-relative movement of the fluid.
My idea is to generate field data of the mesh velocity and subtract it from the absolute U-field so that just the relative movement remains.

So I would like to create a custom solver which:

A - reads the cellCentres of each timestep-folder
B - moves the cellCentres by vector addition (because the center of gravity is not located in the origin)
C - transforms the cellCentre vectors into a velocity field with an angular rotation tensor like "RotationTensor*cellCentres=Meshvelocity"
D - subtracts the meshveolcity field from the original U-field and creates new URelative-field files in every time step folder


I am new both to OpenFOAM and C++ code and therefore encounter many problems creating a custom solver/utility that realises my idea described above.

My costumization is strongly based on page 18-21 from this tutorial http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2009/programmingTutorial.pdf
and this site
http://www.foamcfd.org/Nabla/guides/...sGuidese4.html

Problem 1:
I implemented code from the writeCellCentres utility in the createFields.H code, but the custom solver just writes the 0-mesh cellCentres in all the
time-step folders. Here is the code piece:

Quote:
// Check for new mesh
mesh.readUpdate();

Info<< "Writing field cellCentres\n" << endl;
volVectorField cc
(
IOobject
(
"cellCentres",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
1.0*mesh.C()
);
So my first question would be: How do I get the solver not to write initial cellCentre data in every timestep-folder?


Secondly, I would like to ask how to implement a vector/tensor operation in the solver code (step B,C) in general?
Maybe someone knows some literature/tutorials which give an introduction to this?

Heres the code I tried (which is obviously wrong because of compilation errors):

- Excerpt from file "uRelEqn.H":
Quote:
scalar omegaZ 0.555555556;

tensor TRot
(
0, -1.0*omegaZ, 0,
1.0*omegaZ, 0, 0,
0, 0, 0
);

vector cofgv
(1 0.04 0);

solve
(
U
- TRot*(mesh.C()-cofgv)
);
- Corresponding excerpt from "createFields.H":

Quote:
Info<< "Reading field uRel\n" << endl;
volVectorField uRel
(
IOobject
(
"uRel",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh
);
Many thanks in advance for every helpful answer!

And sorry if my questions are dumb, but as I said I am very new to this...

Kind regards,
David
jFoam is offline   Reply With Quote

Old   October 23, 2013, 10:26
Default piece of code for relative velocity in rotating domain
  #2
Member
 
Bas Nieuwboer
Join Date: Mar 2013
Posts: 32
Rep Power: 13
bjnieuwboer is on a distinguished road
Dear JFoam,

I needed the relative velocity as well and wrote a piece of code. It is far from perfect, but hopefully it may point you in the right direction. In this code you still need to define the rotational axis, -velocity and origin. This should be obtained from other global variables inside OpenFoam. However, I didn't figure out how.

In pimpleDyMFoam.C I changed "runTime.write();" to "#include "write.H" ", and wrote the following write.H-file:

Code:
volVectorField mesh2D(mesh.C()); //initialise mesh
mesh2D.component(2) = 0 * mesh.C().component(2);
//set z dimension (along axis) to zero. I don't know if this is really needed.

dimensionedVector origin
(
    "origin",
    dimensionSet(0, 1, 0, 0, 0, 0, 0),
    vector(0,0,0) // set the point of the origin
);

vector axis(0, 0, 1); // set the rotational axis

dimensionedScalar omega
(
    "omega",
    dimensionSet(0, 0, -1, 0, 0, 0, 0),
    6.2832 //set the rotational velocity in rad/s.
);
volVectorField Urel
(
    IOobject
    (
        "Urel",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    U - ((omega * axis) ^ (mesh2D - origin))
//computes the relative velocity. The second part is the cross product of
//the rotational vector with the vector from the origin to the mesh position.
);
runTime.write();
bjnieuwboer is offline   Reply With Quote

Reply

Tags
cellcentres, custom solver, pimpledymfoam, relative velocity


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
Fluid Structure Interaction Apollo Main CFD Forum 5 July 4, 2011 16:15
Creating fluid zone within Fluent Suresh Main CFD Forum 1 November 25, 2002 07:36
Intl Conf Computational Methods in Fluid Power Jacek Stecki Main CFD Forum 0 November 10, 2002 05:49
My Revised "Time Vs Energy" Article For Review Abhi Main CFD Forum 2 July 9, 2002 09:08
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


All times are GMT -4. The time now is 21:22.