CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] adding an interpolated graph to groovyBC

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Taataa

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 26, 2017, 07:05
Default adding an interpolated graph to groovyBC
  #1
Senior Member
 
mohsen kh
Join Date: Jan 2013
Location: Iran
Posts: 125
Rep Power: 14
m5m5kh is on a distinguished road
Dear Foamers

I want to simulate a real blood flow in an aortic aneurysm. I used the paper done by Khanafer et al. entitled "Modeling pulsatile flow in aortic aneurysms:
Effect of non-Newtonian properties of blood"
they used an inlet velocity profile which contains a term of U(t) (please see the attached picture)
Using groovyBC, it is possible to add a parabolic velocity inlet but I don't have any idea how to add a velocity profile term created from interpolation of 350 points. Is there anyone who can help me with this issue?
I will be grateful if you help me with your advice.

Br,
Mohsen
Attached Images
File Type: png Untitled.png (32.1 KB, 52 views)

Last edited by m5m5kh; September 26, 2017 at 08:41.
m5m5kh is offline   Reply With Quote

Old   October 2, 2017, 00:57
Default
  #2
Senior Member
 
mohsen kh
Join Date: Jan 2013
Location: Iran
Posts: 125
Rep Power: 14
m5m5kh is on a distinguished road
Please share your knowledge with me
m5m5kh is offline   Reply With Quote

Old   October 2, 2017, 02:45
Default
  #3
Senior Member
 
sheaker's Avatar
 
Oskar
Join Date: Nov 2015
Location: Poland
Posts: 184
Rep Power: 10
sheaker is on a distinguished road
I believe You need to use some tool (excel or something like that) to approximate a formula of Your inlet profile then follow this tutorial
https://www.youtube.com/watch?v=K-nAF3qAPTc
sheaker is offline   Reply With Quote

Old   October 2, 2017, 04:38
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

in OpenFOAM there is a boundary called timeVaryingMappedFixedValue which can handle tables and makes interpolation inbetween the timesteps. The header file of the class states:

Code:
Description
    This boundary conditions interpolates the values from a set of supplied
    points in space and time.

    Supplied data should be specified in constant/boundaryData/\<patchname\>/
      - points             : pointField of locations
      - \<time\>/\<field\> : field of values at time \<time\>

    The default mode of operation (mapMethod planarInterpolation) is to project
    the points onto a plane (constructed from the first threee points) and
    construct a 2D triangulation and finds for the face centres the triangle it
    is in and the weights to the 3 vertices.

    The optional mapMethod nearest will avoid all projection and triangulation
    and just use the value at the nearest vertex.

    Values are interpolated linearly between times.

Usage
    \table
        Property     | Description                | Required    | Default value
        setAverage   | Switch to activate setting of average value | no | false
        perturb      | Perturb points for regular geometries | no | 1e-5
        fieldTableName | Alternative field name to sample | no| this field name
        mapMethod    | Type of mapping            | no | planarInterpolation
        offset       | Offset to mapped values    | no | Zero
    \endtable

    \verbatim
    <patchName>
    {
        type            timeVaryingMappedFixedValue;
    }
    \endverbatim
An example is given in $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDailyExptInlet

Good luck,
Tobi
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   October 2, 2017, 08:40
Default
  #5
Senior Member
 
mohsen kh
Join Date: Jan 2013
Location: Iran
Posts: 125
Rep Power: 14
m5m5kh is on a distinguished road
Dear Tobias and Oskar
Thanks for your help.I will follow your hints.

Kind regards,
Mohsen
m5m5kh is offline   Reply With Quote

Old   October 4, 2017, 13:35
Default
  #6
Senior Member
 
mohsen kh
Join Date: Jan 2013
Location: Iran
Posts: 125
Rep Power: 14
m5m5kh is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Hi all,

in OpenFOAM there is a boundary called timeVaryingMappedFixedValue which can handle tables and makes interpolation inbetween the timesteps. The header file of the class states:

Code:
Description
    This boundary conditions interpolates the values from a set of supplied
    points in space and time.

    Supplied data should be specified in constant/boundaryData/\<patchname\>/
      - points             : pointField of locations
      - \<time\>/\<field\> : field of values at time \<time\>

    The default mode of operation (mapMethod planarInterpolation) is to project
    the points onto a plane (constructed from the first threee points) and
    construct a 2D triangulation and finds for the face centres the triangle it
    is in and the weights to the 3 vertices.

    The optional mapMethod nearest will avoid all projection and triangulation
    and just use the value at the nearest vertex.

    Values are interpolated linearly between times.

Usage
    \table
        Property     | Description                | Required    | Default value
        setAverage   | Switch to activate setting of average value | no | false
        perturb      | Perturb points for regular geometries | no | 1e-5
        fieldTableName | Alternative field name to sample | no| this field name
        mapMethod    | Type of mapping            | no | planarInterpolation
        offset       | Offset to mapped values    | no | Zero
    \endtable

    \verbatim
    <patchName>
    {
        type            timeVaryingMappedFixedValue;
    }
    \endverbatim
An example is given in $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDailyExptInlet

Good luck,
Tobi
Thanks For your help Tobias, but who should I enter the (1-(r/d)^2) to my boundary condition?
Is there any possibility to use groovyBC?
m5m5kh is offline   Reply With Quote

Old   October 16, 2017, 14:26
Default
  #7
Senior Member
 
mohsen kh
Join Date: Jan 2013
Location: Iran
Posts: 125
Rep Power: 14
m5m5kh is on a distinguished road
No one faced such problem??? any similar experience?
your help is really needed.

Regards,
Mohsen
m5m5kh is offline   Reply With Quote

Old   December 29, 2017, 16:37
Default
  #8
New Member
 
Qihao Jiang
Join Date: Dec 2017
Posts: 20
Rep Power: 8
Qihao is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Hi all,

in OpenFOAM there is a boundary called timeVaryingMappedFixedValue which can handle tables and makes interpolation inbetween the timesteps. The header file of the class states:

Code:
Description
    This boundary conditions interpolates the values from a set of supplied
    points in space and time.

    Supplied data should be specified in constant/boundaryData/\<patchname\>/
      - points             : pointField of locations
      - \<time\>/\<field\> : field of values at time \<time\>

    The default mode of operation (mapMethod planarInterpolation) is to project
    the points onto a plane (constructed from the first threee points) and
    construct a 2D triangulation and finds for the face centres the triangle it
    is in and the weights to the 3 vertices.

    The optional mapMethod nearest will avoid all projection and triangulation
    and just use the value at the nearest vertex.

    Values are interpolated linearly between times.

Usage
    \table
        Property     | Description                | Required    | Default value
        setAverage   | Switch to activate setting of average value | no | false
        perturb      | Perturb points for regular geometries | no | 1e-5
        fieldTableName | Alternative field name to sample | no| this field name
        mapMethod    | Type of mapping            | no | planarInterpolation
        offset       | Offset to mapped values    | no | Zero
    \endtable

    \verbatim
    <patchName>
    {
        type            timeVaryingMappedFixedValue;
    }
    \endverbatim
An example is given in $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDailyExptInlet

Good luck,
Tobi
Hi, can this boundary condition be used as the file which pressure varied with location in x direction, while the time is constant?
Qihao is offline   Reply With Quote

Old   December 29, 2017, 17:03
Default
  #9
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
No. The only way is that you make a derivative of that boundary condition and modify it to your needs.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   December 29, 2017, 18:52
Default
  #10
Senior Member
 
Taher Chegini
Join Date: Nov 2014
Location: Houston, Texas
Posts: 125
Rep Power: 12
Taataa is on a distinguished road
A while ago I needed a parabolic BC for U and here's the way I did it:

Code:
inlet
    {
        type            codedFixedValue;
        value           uniform (0 0 0);
        redirectType    parabolaProfile;   

        code
        #{
            const fvPatch& boundaryPatch = patch();
            const vectorField& Cf = boundaryPatch.Cf();

            vectorField& field = *this; 
            scalar uave = 10;
            scalar h = 5e-3;
            
            scalar vel;

            forAll(Cf, faceI)
            {
                vel = 6 * uave / (h*h) * (h * Cf[faceI].y() - Cf[faceI].y() * Cf[faceI].y());
                field[faceI] = vector(vel, 0, 0);
            }
        #};
    }
Regarding interpolation using tableFile is an option which you can find some info here. I haven't used it myself so you need to explore and let us know if you find any useful info.

Edit: I meant that you can use tableFile inside the code. Since this is a C++ code, you can do all sorts of things without relying on OF classes and functions. You can use C++ capabilities to read from files and do operations though it's more convenient to use OF classes and functions. Also, if you want to include any header you can use codeInclude directive like this:

Code:
inlet
    {
        type            codedFixedValue;
        value           uniform (0 0 0);
        redirectType    parabolaProfile;   
        
        codeInclude 
        #{ 
            #include ”someHeaderFile” 
        #}; 

        code
        #{
            const fvPatch& boundaryPatch = patch();
            const vectorField& Cf = boundaryPatch.Cf();

            vectorField& field = *this; 
            scalar uave = 10;
            scalar h = 5e-3;
            
            scalar vel;

            forAll(Cf, faceI)
            {
                vel = 6 * uave / (h*h) * (h * Cf[faceI].y() - Cf[faceI].y() * Cf[faceI].y());
                field[faceI] = vector(vel, 0, 0);
            }
        #};
    }
Tobi likes this.
Taataa is offline   Reply With Quote

Old   December 29, 2017, 18:59
Default
  #11
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
The solution you mentioned is working if one has a mathematical formula that can be implemented. If one can do this, it is easy as you demonstrated (by the way there exist a parabolic BC). If one has a table that cannot be fit to a polynomial or other function, one has to modify the varying bc. I guess it is not a big deal or there are already other ways to do it
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   December 29, 2017, 19:07
Default
  #12
Senior Member
 
Taher Chegini
Join Date: Nov 2014
Location: Houston, Texas
Posts: 125
Rep Power: 12
Taataa is on a distinguished road
Quote:
Originally Posted by Tobi View Post
The solution you mentioned is working if one has a mathematical formula that can be implemented. If one can do this, it is easy as you demonstrated (by the way there exist a parabolic BC). If one has a table that cannot be fit to a polynomial or other function, one has to modify the varying bc. I guess it is not a big deal or there are already other ways to do it
True. I added some additional points for more clarity.
Taataa is offline   Reply With Quote

Old   December 31, 2017, 06:12
Default
  #13
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by m5m5kh View Post
Dear Foamers

I want to simulate a real blood flow in an aortic aneurysm. I used the paper done by Khanafer et al. entitled "Modeling pulsatile flow in aortic aneurysms:
Effect of non-Newtonian properties of blood"
they used an inlet velocity profile which contains a term of U(t) (please see the attached picture)
Using groovyBC, it is possible to add a parabolic velocity inlet but I don't have any idea how to add a velocity profile term created from interpolation of 350 points. Is there anyone who can help me with this issue?
I will be grateful if you help me with your advice.

Br,
Mohsen
That would work with the "timelines" or "lookuptables" where you can specify a data-file in swak and let it use as a function (or a value that depends on the current time) to be read from a file (with (t,f(t))-pairs). For an example look at Examples/groovyBC/wobbler/0.org/D in the swak4faom-sources
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider 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
How I can introduce my power heat (W) in chtMultiRegionFoam? aminem OpenFOAM Pre-Processing 32 August 29, 2019 02:23
chtMultiRegionSimpleFoam: crash on parallel run student666 OpenFOAM Running, Solving & CFD 3 April 20, 2017 11:05
conjugateHeatFoam + interFoam farhagim OpenFOAM Programming & Development 15 July 19, 2016 07:55
chtMultiRegionSimpleFoam 3D problem Lucie OpenFOAM Pre-Processing 2 June 21, 2016 05:23
chtMultiRegionSimpleFoam samiam1000 OpenFOAM Running, Solving & CFD 39 March 31, 2016 08:43


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