CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How To simulate a pulsating flow in OpenFOAM (https://www.cfd-online.com/Forums/openfoam-solving/58655-how-simulate-pulsating-flow-openfoam.html)

fw407 July 15, 2008 15:22

Hi everyone, I am trying to
 
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

mathieu July 15, 2008 16:12

Hi ! Take a look at the osc
 
Hi !

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

Mathieu

ngj July 15, 2008 16:28

Hi Feng As a start, assume
 
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

fw407 July 16, 2008 06:23

Hi Mathieu, Thanks for your
 
Hi Mathieu,

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

Kind regards

feng

fw407 July 16, 2008 06:27

Hi Niels, I really apprecia
 
Hi Niels,

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

Kind regards

feng

woody August 13, 2008 04:57

Hi, I also work on pulsatil
 
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

woody August 13, 2008 05:08

Sorry, I scanned the forum
 
Sorry,

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

;-)

Tobias

viraj20feb September 28, 2016 02:27

Pulsating Blood Flow in arteries
 
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

floquation September 28, 2016 03:15

Quote:

Originally Posted by viraj20feb (Post 619541)
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;
    }
}

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


viraj20feb September 29, 2016 00:51

Quote:

Originally Posted by floquation (Post 619547)
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?

floquation September 29, 2016 02:43

Quote:

Originally Posted by viraj20feb (Post 619666)
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?

viraj20feb September 29, 2016 02:51

1 Attachment(s)
Quote:

Originally Posted by floquation (Post 619684)
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

floquation September 29, 2016 04:29

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.

viraj20feb September 29, 2016 05:39

Quote:

Originally Posted by floquation (Post 619701)
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.

floquation September 29, 2016 07:29

Quote:

Originally Posted by viraj20feb (Post 619708)
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.

viraj20feb October 4, 2016 08:30

1 Attachment(s)
Quote:

Originally Posted by floquation (Post 619730)
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

floquation October 5, 2016 03:19

Quote:

Originally Posted by viraj20feb (Post 620248)
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.
http://i63.tinypic.com/1fd5if.png

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.

viraj20feb October 5, 2016 05:22

1 Attachment(s)
Quote:

Originally Posted by floquation (Post 620323)
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.
http://i63.tinypic.com/1fd5if.png

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


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