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

Adding acceleration term in icoDyMFoam

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 31, 2010, 10:51
Default Adding acceleration term in icoDyMFoam
  #1
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
Hey guys, real simple question. My moving reference frame is accelerating -0.5*pi*A*T*sin(2*pi*t/T) in x-dirn and -sqrt(3)/2*pi*A*T*sin(2*pi*t/T) in y-dirn. A, T, pi are constants, t is time. I'm trying to add these to the momentum equation but it doesn't compile. Here's what I've got:

Ueqn.H
Code:
volScalarField pi = 3.1415926535897932384626433832795028841971693993751;
volVectorField acc = -pi*0.1091911*sin(2*pi*runtime.time().value()/1.091911)*(0.5*vector(1,0,0)+pow(3,0.5)*vector(0,1,0));
    
fvVectorMatrix UEqn
    (
        fvm::ddt(U)
      + fvm::div(phi, U)
      - fvm::laplacian(nu, U)
      - acc
    );

    if (momentumPredictor)
    {
        solve(UEqn == -fvc::grad(p));
    }
What's wrong with it??
rieuk is offline   Reply With Quote

Old   September 1, 2010, 11:32
Default
  #2
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
Ok....put it this way,

1. How can I create an empty volScalarField with dimensions acceleration?
2. How do I introduce the runtime class into Ueqn.H? (What header file do I need to introduce)

I couldn't find any of this basic stuff in the programmer's guide...
rieuk is offline   Reply With Quote

Old   September 1, 2010, 16:41
Default
  #3
New Member
 
Ozgur Kirlangic
Join Date: May 2009
Location: Istanbul
Posts: 16
Rep Power: 8
ozgur is on a distinguished road
Hi Pavan,

I am not expert but if I make some comments on your code, I can say that:

1. I wouldn't define pi as volScalarField, because it is a constant scalar, not a field variable which has different values in time and space. So I think,
Code:
scalar pi 3.1415926535897932;
would be sufficient.

There might (/or not) also be an already defined macro for the number pi in OpenFOAM but I haven't used it before.

2. I wouldn't define acc as volVectorField neither (if I won't need to use it over and over, or do other calculations with it). Because, if you want to define a volVectorField, then (as far as I understood up to now) then also you will need to construct an IOobjet and make mesh association, defining the dimensions etc., such as:

Code:
    volVectorField acc
    (
        IOobject
        (
            "acc",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
So the code gets more complicated, extra memory is used etc, etc...

What can be done may be writing the acc formula directly into the Ueqn.

However, I am not sure about how will the expressions like 0.5*vector(1,0,0) compiled. They might need to be verified separately.

3. I haven't used icoDyMFoam so I don't know anything about it, however, I have been using interDyMFoam for a while and I guess the "DyM" stands for dynamic mesh (and it maybe the same in icoDyMFoam). In interDyMFoam the mesh movement is imposed by an additional utility called gen6DoF, which is in turn equivalent to an extra acceleration term to UEqn. Since your acceleration term is also only a function of time, and is independent of space, use of gen6DoF explicitly might also be considered.

Regards,

Ozgur
ozgur is offline   Reply With Quote

Old   September 1, 2010, 17:43
Default
  #4
Member
 
Simon Lapointe
Join Date: May 2009
Location: Québec, Qc, Canada
Posts: 33
Rep Power: 8
Simon Lapointe is on a distinguished road
Hi Pavan,

Since your source term is constant in space you don't need to define a volVectorField, a simple vector would do it.

You could try something like:

Code:
dimensionedVector accX
(
"accX",dimensionSet(0, 1, -2, 0, 0),vector(1, 0, 0)
);

dimensionedVector accY
(
"accY",dimensionSet(0, 1, -2, 0, 0),vector(0, 1, 0)
);

scalar Pi = mathematicalConstant::pi;

dimensionedVector acc = -Pi*0.1091911*sin(2*Pi*runTime.value()/1.091911)*(0.5*accX+pow(3,0.5)*accY);
Simon Lapointe is offline   Reply With Quote

Old   September 1, 2010, 18:37
Default
  #5
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
Thanks, Ozgur!

1. Agreed about the scalar pi thing.

2. I don't know I was referring to this thread: Rotating Reference Frame (3rd post by Henry) where Fcent is defined as a volVectorField without being a field variable.

3. Yeah icoDyMFoam is just the dynamic mesh version of icoFoam, the incompressible fluid solver with no turbulence.
rieuk is offline   Reply With Quote

Old   September 1, 2010, 18:41
Default
  #6
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
Also, thanks Simon! Will try this asap
rieuk is offline   Reply With Quote

Old   September 4, 2010, 12:18
Default
  #7
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
Well, with the extra help of an experienced OF user I got the following to compile:

Code:
scalar Pi = mathematicalConstant::pi;
dimensionedScalar accCt("accCt",dimensionSet(0,1,-2,0,0,0,0),10000*Foam::cos(2*Pi*runTime.value()/0.5));
dimensionedVector acc("acc",dimensionSet(0,1,-2,0,0,0,0), vector::zero);

acc.component(vector::X) = 0.5 * accCt;
acc.component(vector::Y) = 0.5 * Foam::sqrt(3.0) * accCt;

        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        );


        solve(UEqn == acc-fvc::grad(p));
However the acceleration term added does not seem to have any effect whatsoever on the solution. I just start with a stationary 2d cylinder in a rectangular domain with no flow. Solution stays zero the whole time even with the sinusoidally varying acceleration term -- why?? Is there some part of the PISO loop I have to edit?
rieuk is offline   Reply With Quote

Old   September 18, 2010, 23:07
Default
  #8
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
I notice in dnsFoam the force term is implemented like so:

Code:
        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
    ==
      acc
        );

        solve(UEqn == -fvc::grad(p));
As opposed to:
Code:
        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        );


        solve(UEqn == (acc-fvc::grad(p)));
What is the difference? They give vastly differing results...
rieuk is offline   Reply With Quote

Old   September 18, 2010, 23:54
Default
  #9
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 10
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
They are different.
In the first, acc is introduced to momentum equation, and in the second acc was introduced into pressure equation and pressure equation should also be altered accordingly (if you don't include acc relative term in pressure, the results should differ much). If acc has effect on the velocity, doing in the second way is more implicit.
please see derivation of pressure equation in Henrik Rusche's phd thesis.

regards, Junwei
su_junwei is offline   Reply With Quote

Old   September 20, 2010, 11:43
Default
  #10
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
Thanks for the reply Su Junwei! So I take it the first approach is valid but not as implicit as the second approach (with modification to the pressure equation)?
rieuk is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 15:45
Adding implicit source term to momentum equation fs82 OpenFOAM 6 September 23, 2009 03:29
Adding a momentum source term segersson OpenFOAM Running, Solving & CFD 5 March 3, 2006 00:06
adding souce term cfp CFX 0 July 14, 2002 10:43
adding source term confusion tedmcc CFX 4 September 27, 2001 05:05


All times are GMT -4. The time now is 10:25.