CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Creating relative fluid-velocityfield in pimpleDyMFoam (https://www.cfd-online.com/Forums/openfoam-solving/119525-creating-relative-fluid-velocityfield-pimpledymfoam.html)

 jFoam June 19, 2013 05:22

Creating relative fluid-velocityfield in pimpleDyMFoam

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 );

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

Kind regards,
David

 bjnieuwboer October 23, 2013 10:26

piece of code for relative velocity in rotating domain

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,