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

How To simulate a pulsating flow in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 15, 2008, 15:22
Default Hi everyone, I am trying to
  #1
Member
 
feng wang
Join Date: Mar 2009
Posts: 67
Rep Power: 17
fw407 is on a distinguished road
Hi everyone,

I am trying to modify icoFoam so that it can simulate a pulsating flow in a straight flexible pipe. the flow velocity at the inlet is uniformly distributed but the velocity magnitude changs with time:

U = U_0 + U_A*sin(wt)

I have noticed the "timeVaryingUniformFixedValueFvPatchField " may be what I want, but it needs to read the data from a data file. Actually I prefer to implement it in the code somthing like:

U.boundaryField()[patchI] == U_0 + U_A * sin (wt)

and read the "w", "U_0" and "U_A" in a dictionary.

So far I haven't got an idea of how to do that, Could anyone give me some hints?

Kind regards

feng
fw407 is offline   Reply With Quote

Old   July 15, 2008, 16:12
Default Hi ! Take a look at the osc
  #2
Member
 
Mathieu Olivier
Join Date: Mar 2009
Location: Quebec City, Canada
Posts: 77
Rep Power: 17
mathieu is on a distinguished road
Hi !

Take a look at the oscillatingFixedValueFvPatchField, I think it is exactly what you need.

Mathieu
mathieu is offline   Reply With Quote

Old   July 15, 2008, 16:28
Default Hi Feng As a start, assume
  #3
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Feng

As a start, assume you know w, U_0 and U_A, then simply do this, which you have already done:

U.boundaryField()[patchI] == U_0 + U_A * sin (wt);

and add the line:

U.correctBoundaryConditions();

It should to the trick.

With respect to be reading from a dictionary, look for instance at

OpenFOAM/OpenFOAM-1.4.1/applications/solvers/DNSandLES/dnsFoam

and search for IOdictionary.

Have fun,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   July 16, 2008, 06:23
Default Hi Mathieu, Thanks for your
  #4
Member
 
feng wang
Join Date: Mar 2009
Posts: 67
Rep Power: 17
fw407 is on a distinguished road
Hi Mathieu,

Thanks for your help, I really appreciate it. oscillatingFixedValueFvPatchField is working fine with me.

Kind regards

feng
fw407 is offline   Reply With Quote

Old   July 16, 2008, 06:27
Default Hi Niels, I really apprecia
  #5
Member
 
feng wang
Join Date: Mar 2009
Posts: 67
Rep Power: 17
fw407 is on a distinguished road
Hi Niels,

I really appreciate your help. I will try more complex functions with your method.

Kind regards

feng
fw407 is offline   Reply With Quote

Old   August 13, 2008, 04:57
Default Hi, I also work on pulsatil
  #6
Member
 
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17
woody is on a distinguished road
Hi,

I also work on pulsatile flows. I am especially interested in heat transfer effects, that occur in turbulent problems containing flow reversal.

So far I tried to simulate my very long (l/D=120) channel with a constant wall temperature, pulsating velocity and oscillatory temperature BC at the inlet. I introduced a special turbulence Model (Wang & Zhang: "Numerical analysis of heat transfer in pulsating turbulent flow in a pipe", Heat and Mass Transfer, 2005) containing wallfunctions. As compressible fluids should be considered, the rhoTurbFoam solver seemed to be the best fitting choice.

When run my computations, the temperature cant follow the backflow conditions, and is increased non-physical.

Scanning the tutorials, I found some other remarks, that backflow causes instabilities and some suggestions, which are not commented to have been worked out or taken to be valid.

Is anybody out there who handled similar problems and has some information, hints etc.???

Thanks Tobias
__________________
Tobias Holzinger

Chair of Thermodynamics, TU München
woody is offline   Reply With Quote

Old   August 13, 2008, 05:08
Default Sorry, I scanned the forum
  #7
Member
 
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17
woody is on a distinguished road
Sorry,

I scanned the forum ... and not the tutorial...

;-)

Tobias
__________________
Tobias Holzinger

Chair of Thermodynamics, TU München
woody is offline   Reply With Quote

Old   September 28, 2016, 02:27
Default Pulsating Blood Flow in arteries
  #8
Member
 
Viraj Belekar
Join Date: Jun 2016
Posts: 68
Rep Power: 9
viraj20feb is on a distinguished road
Greetings,

Can anyone please share the code for proper pulsating blood flow ? I have been trying to do that for a long time.

Thanks a lot
viraj20feb is offline   Reply With Quote

Old   September 28, 2016, 03:15
Default
  #9
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
Quote:
Originally Posted by viraj20feb View Post
Greetings,

Can anyone please share the code for proper pulsating blood flow ? I have been trying to do that for a long time. See the example below. (Evidently, the precise BC depend on what effect you like to achieve.)

Thanks a lot
You can achieve what you want using "groovyBC" which comes with swak4foam.

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.4.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{

    walls
    {
        type            zeroGradient;
    }


    cycLeft // p~sin(t)
    {
        type            groovyBC;
        patchType       cyclic;
        valueExpression "-2.6780625E-4*(1 + 0.7*sin(2*3.145926*1*time()))";
    }

    cycRight // p=0
    {
        type            groovyBC;
        patchType       cyclic;
    }
}
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.4.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 -2E-2);

boundaryField
{
    walls
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }

    cycLeft
    {
        type            cyclic;
    }
    cycRight
    {
        type            cyclic;
    }
}

// ************************************************************************* //
floquation is offline   Reply With Quote

Old   September 29, 2016, 00:51
Default
  #10
Member
 
Viraj Belekar
Join Date: Jun 2016
Posts: 68
Rep Power: 9
viraj20feb is on a distinguished road
Quote:
Originally Posted by floquation View Post
You can achieve what you want using "groovyBC" which comes with swak4foam.

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.4.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{

    walls
    {
        type            zeroGradient;
    }


    cycLeft // p~sin(t)
    {
        type            groovyBC;
        patchType       cyclic;
        valueExpression "-2.6780625E-4*(1 + 0.7*sin(2*3.145926*1*time()))";
    }

    cycRight // p=0
    {
        type            groovyBC;
        patchType       cyclic;
    }
}
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.4.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 -2E-2);

boundaryField
{
    walls
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }

    cycLeft
    {
        type            cyclic;
    }
    cycRight
    {
        type            cyclic;
    }
}

// ************************************************************************* //

Hello floqution,

Thanks for your quick reply. Unfortunately, there is some error with this. When I run simulation, I get the following error:
Code:
--> FOAM FATAL ERROR: 
Attempt to cast type patch to type lduInterface

    From function refCast<To>(From&)
    in file /home/fossee/foam/foam-extend-3.2/src/foam/lnInclude/typeInfo.H at line 114.

FOAM aborting

Aborted (core dumped)
Can you please help?
viraj20feb is offline   Reply With Quote

Old   September 29, 2016, 02:43
Default
  #11
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
Quote:
Originally Posted by viraj20feb View Post
Hello floqution,

Thanks for your quick reply. Unfortunately, there is some error with this. When I run simulation, I get the following error:
Code:
--> FOAM FATAL ERROR: 
Attempt to cast type patch to type lduInterface

    From function refCast<To>(From&)
    in file /home/fossee/foam/foam-extend-3.2/src/foam/lnInclude/typeInfo.H at line 114.

FOAM aborting

Aborted (core dumped)
Can you please help?
I do not know what that error means, but I can troubleshoot you.
Reading the error, I anticipate it has to do with what boundary type was set.
  1. OpenFoam version?
  2. What boundaries did you specify in your blockMeshDict? That is, are they cyclic (like required by the code I showed you), or did you set something else?
  3. What solver are you using?
floquation is offline   Reply With Quote

Old   September 29, 2016, 02:51
Default
  #12
Member
 
Viraj Belekar
Join Date: Jun 2016
Posts: 68
Rep Power: 9
viraj20feb is on a distinguished road
Quote:
Originally Posted by floquation View Post
I do not know what that error means, but I can troubleshoot you.
Reading the error, I anticipate it has to do with what boundary type was set.
  1. OpenFoam version?
  2. What boundaries did you specify in your blockMeshDict? That is, are they cyclic (like required by the code I showed you), or did you set something else?
  3. What solver are you using?

Hi floquation,

1) I am using foam-extend-3.2
2) I did set it correctly. Please find the attached case directory
3) I am using fsiFoam solver (https://openfoamwiki.net/index.php/E...re_interaction)

Please take a look
Attached Files
File Type: gz 2.tar.gz (5.0 KB, 21 views)
viraj20feb is offline   Reply With Quote

Old   September 29, 2016, 04:29
Default
  #13
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
I am not familiar with your solver, and it might be related to the way it works:

What is pointMotionU?

In 0/pointMotionU you have set "fixedValue" for the otherwise cyclic boundary. I suspect that this might be the source of the error.
floquation is offline   Reply With Quote

Old   September 29, 2016, 05:39
Default
  #14
Member
 
Viraj Belekar
Join Date: Jun 2016
Posts: 68
Rep Power: 9
viraj20feb is on a distinguished road
Quote:
Originally Posted by floquation View Post
I am not familiar with your solver, and it might be related to the way it works:

What is pointMotionU?

In 0/pointMotionU you have set "fixedValue" for the otherwise cyclic boundary. I suspect that this might be the source of the error.
Hey,

This solver is for Fluid Structure Interaction study which I want to implement for blood flow in arteries. I changed the 0/pointMotionU but had to change back the content of the blockMeshDict file(i.e inlet and outlet to type patch, because I was getting a wierd error and blockMesh command was not working).
Code:
--> FOAM FATAL ERROR: 

face 0 area does not match neighbour 1 by 82.5642% -- possible face ordering problem. patch:outlet my area:9.65479e-06 neighbour area:4.0126e-06 matching tolerance:0.001 Mesh face:3 vertices:4((0 0.003414 0.05) (0.002828 0.002828 0.05) (0.003414 0 0.05) (0 0 0.05)) Neighbour face:4 vertices:4((0 0.005 0.05) (0.003536 0.003536 0.05) (0.002828 0.002828 0.05) (0 0.003414 0.05)) Other errors also exist, only the largest is reported. Please rerun with cyclic debug flag set for more information. From function cyclicPolyPatch::calcTransforms() in file meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C at line 293.
Now when I have changed back to the original blockMeshDict file, the earlier error still persists.
viraj20feb is offline   Reply With Quote

Old   September 29, 2016, 07:29
Default
  #15
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
Quote:
Originally Posted by viraj20feb View Post
Hey,

This solver is for Fluid Structure Interaction study which I want to implement for blood flow in arteries. I changed the 0/pointMotionU but had to change back the content of the blockMeshDict file(i.e inlet and outlet to type patch, because I was getting a wierd error and blockMesh command was not working).
Code:
--> FOAM FATAL ERROR: 

face 0 area does not match neighbour 1 by 82.5642% -- possible face ordering problem. patch:outlet my area:9.65479e-06 neighbour area:4.0126e-06 matching tolerance:0.001 Mesh face:3 vertices:4((0 0.003414 0.05) (0.002828 0.002828 0.05) (0.003414 0 0.05) (0 0 0.05)) Neighbour face:4 vertices:4((0 0.005 0.05) (0.003536 0.003536 0.05) (0.002828 0.002828 0.05) (0 0.003414 0.05)) Other errors also exist, only the largest is reported. Please rerun with cyclic debug flag set for more information. From function cyclicPolyPatch::calcTransforms() in file meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C at line 293.
Now when I have changed back to the original blockMeshDict file, the earlier error still persists.
This new error is actually a 'better' error, as it occurs later inside the source code. That is, your change made the first error disappear.
And this error I know: it means that your inlet boundary is not of the same size as your outlet boundary. Therefore, OF cannot match the inlet with the outlet for the cyclic BC.
This may have two causes: (1) you made a mistake in your blockMeshDict, or (2) your inlet and outlet were not intended to be of the same size.
- If the first is the case, carefully inspect your mesh.
- If the second is the case, then perhaps you shouldn't be using cyclic at all? My code above was using cyclic BC, as that was the kind of artery we were interested in. If you do not want to have an "infinite" (=periodic) artery, then you must change my code above to be consistent with your boundary. That basically means still using groovyBC, but changing the patchType from "cyclic" to whatever is appropriate for your case.
floquation is offline   Reply With Quote

Old   October 4, 2016, 08:30
Default
  #16
Member
 
Viraj Belekar
Join Date: Jun 2016
Posts: 68
Rep Power: 9
viraj20feb is on a distinguished road
Quote:
Originally Posted by floquation View Post
This new error is actually a 'better' error, as it occurs later inside the source code. That is, your change made the first error disappear.
And this error I know: it means that your inlet boundary is not of the same size as your outlet boundary. Therefore, OF cannot match the inlet with the outlet for the cyclic BC.
This may have two causes: (1) you made a mistake in your blockMeshDict, or (2) your inlet and outlet were not intended to be of the same size.
- If the first is the case, carefully inspect your mesh.
- If the second is the case, then perhaps you shouldn't be using cyclic at all? My code above was using cyclic BC, as that was the kind of artery we were interested in. If you do not want to have an "infinite" (=periodic) artery, then you must change my code above to be consistent with your boundary. That basically means still using groovyBC, but changing the patchType from "cyclic" to whatever is appropriate for your case.
Hi floquation,

I have been trying what was suggested by you but I was not able to make it work. Can you please try it once on your system? Please find my attached test case.

Thanks a lot
Attached Files
File Type: gz 2.tar.gz (5.0 KB, 13 views)
viraj20feb is offline   Reply With Quote

Old   October 5, 2016, 03:19
Default
  #17
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
Quote:
Originally Posted by viraj20feb View Post
Can you please try it once on your system?
I'm sorry, but no, I'm not going through the hassle of installing your solver without admin rights.

However, I did look at your blockMesh in ParaView, and it has two problems:
  1. http://cfd.direct/openfoam/user-guide/blockmesh/
    Firstly, you should define your normals outwards (using the right-hand rule), whereas yours are pointing inwards. For example:
    Code:
        patch outlet
        (
            (7 8 9 10) //(10 9 8 7)
     (...)
  2. Secondly, you specify your faces in the incorrect order for cyclic to work. All faces must be specified in the same order for both cyclic patches:
    Code:
        patch outlet
        (
            (10 9 8 7)
            (12 11 8 9) //(13 12 9 10)
            (13 12 9 10) //(12 11 8 9)
        )
        patch inlet
        (
            (0 1 2 3)
            (1 4 5 2)
            (3 2 5 6)
        )
    Which is probably the reason why you got the "area does not match"-error earlier.


Then, you again have to correct your zero directory, cf. my first post. So, put U and pointMotionU back to cyclic (not groovyBC) and leave pressure on groovyBC.
floquation is offline   Reply With Quote

Old   October 5, 2016, 05:22
Default
  #18
Member
 
Viraj Belekar
Join Date: Jun 2016
Posts: 68
Rep Power: 9
viraj20feb is on a distinguished road
Quote:
Originally Posted by floquation View Post
I'm sorry, but no, I'm not going through the hassle of installing your solver without admin rights.

However, I did look at your blockMesh in ParaView, and it has two problems:
  1. http://cfd.direct/openfoam/user-guide/blockmesh/
    Firstly, you should define your normals outwards (using the right-hand rule), whereas yours are pointing inwards. For example:
    Code:
        patch outlet
        (
            (7 8 9 10) //(10 9 8 7)
     (...)
  2. Secondly, you specify your faces in the incorrect order for cyclic to work. All faces must be specified in the same order for both cyclic patches:
    Code:
        patch outlet
        (
            (10 9 8 7)
            (12 11 8 9) //(13 12 9 10)
            (13 12 9 10) //(12 11 8 9)
        )
        patch inlet
        (
            (0 1 2 3)
            (1 4 5 2)
            (3 2 5 6)
        )
    Which is probably the reason why you got the "area does not match"-error earlier.


Then, you again have to correct your zero directory, cf. my first post. So, put U and pointMotionU back to cyclic (not groovyBC) and leave pressure on groovyBC.
Hi floquation,

Thanks for your quick reply. I tried what you suggested but it didn't work out. Apparently we need to use createPatchDict to set a patchfield as cyclic ( Use of createPatchDict and createPatch ). But when I use it also I get an error, "keyword 'patchInfo' not defined" (PFA).
Attached Files
File Type: gz createPatchDict.tar.gz (565 Bytes, 10 views)
viraj20feb 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
What kind of computer is needed to simulate with OpenFoam anita OpenFOAM Running, Solving & CFD 8 February 21, 2008 11:25
UDF for pulsating flow Bing FLUENT 0 October 7, 2006 11:16
pulsating static pressure around zero at pipe flow David Kim FLUENT 0 May 16, 2006 13:47
Pulsating flow in Fluent Ryan FLUENT 0 December 8, 2005 23:32
pulsating flow Pete Main CFD Forum 2 December 9, 2003 11:39


All times are GMT -4. The time now is 15:47.