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

Integrate volVectorField over cross section / cutting plane

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

Like Tree5Likes
  • 1 Post By gschaider
  • 1 Post By superkelle
  • 1 Post By gschaider
  • 1 Post By gschaider
  • 1 Post By superkelle

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 7, 2020, 14:17
Question Integrate volVectorField over cross section / cutting plane
  #1
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
Hi I try to calculate the total flux (it will be the total current by an E field over a cross-section in a plasma, but for sake of simplicity I refer to a dummy "flux") over a cut of my mesh. For that I would need to integrate a vectorField over a cross-section of my domain. I do not want it for postprocessing I need the value inside my solver as a dimensioned scalar. I can not use boundary patches for that, it has to be internal faces at a cross section.
What I am essentially trying is to use is the function object: surfaceFieldValue
https://www.openfoam.com/documentati...t.html#details

like:

Code:
functions{
current
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");

    log             true;
    writeControl    writeTime;
    writeFields     true;

    surfaceFormat   none;
    regionType     sampledSurface;

        sampledSurfaceDict
        {
                type cuttingPlane;
                planeType           pointAndNormal;
                pointAndNormalDict
                {
                        basePoint       (0 0 0);  
                        normalVector    (0 0 1);
                }
                source cells; // sample cells or boundaryFaces
                interpolate true;
        }

    operation       areaNormalIntegrate;
    fields          (U);
}
}
but it is should be located in the solver not in the controlDict and I want to use the flux for other calculations. I already found some threads that seemed similar, but they were not exactly what I looked for or I was not able to implement it the way described. I post all what I found so far below, maybe it is helpful for someone who faces the same problem. If I find a good solution I will be glad to share it .

average over cutting plane during runtime

Mass Flow rate through a plane

Sampling a limited size cutting plane

Write cells and data intersecting a plane cuttingPlane

Use flow rate calculated from an function object in an injection model
superkelle is offline   Reply With Quote

Old   May 7, 2020, 19:27
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,227
Rep Power: 50
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by superkelle View Post
Hi I try to calculate the total flux (it will be the total current by an E field over a cross-section in a plasma, but for sake of simplicity I refer to a dummy "flux") over a cut of my mesh. For that I would need to integrate a vectorField over a cross-section of my domain. I do not want it for postprocessing I need the value inside my solver as a dimensioned scalar. I can not use boundary patches for that, it has to be internal faces at a cross section.
What I am essentially trying is to use is the function object: surfaceFieldValue
https://www.openfoam.com/documentati...t.html#details

like:

Code:
functions{
current
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");

    log             true;
    writeControl    writeTime;
    writeFields     true;

    surfaceFormat   none;
    regionType     sampledSurface;

        sampledSurfaceDict
        {
                type cuttingPlane;
                planeType           pointAndNormal;
                pointAndNormalDict
                {
                        basePoint       (0 0 0);  
                        normalVector    (0 0 1);
                }
                source cells; // sample cells or boundaryFaces
                interpolate true;
        }

    operation       areaNormalIntegrate;
    fields          (U);
}
}
but it is should be located in the solver not in the controlDict and I want to use the flux for other calculations. I already found some threads that seemed similar, but they were not exactly what I looked for or I was not able to implement it the way described. I post all what I found so far below, maybe it is helpful for someone who faces the same problem. If I find a good solution I will be glad to share it .

average over cutting plane during runtime

Mass Flow rate through a plane

Sampling a limited size cutting plane

Write cells and data intersecting a plane cuttingPlane

Use flow rate calculated from an function object in an injection model

Just some remarks:
- putting your post-processing into the solver is rarely a good idea (even if - what I suspect - you need it to drive a boundary condition)

- if possible (and your meshing workflow allows it) produce face sets (or zones) where you want to calculate the fluxes and calculate them on these. It is a) faster (because there is no interpolation) b) more accurate (because you get to use phi instead of interpolated U)
- calculation on a sampledSurface can be done in swak4Foam
superkelle likes this.
__________________
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

Old   May 8, 2020, 05:07
Default
  #3
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
Thank you, ok do you maybe have a good advice how to get such an faceZone (faceSet?) over that I can simply add the values manually in the solver? Something like
Code:
forAll(myFaceZone, facei)
{
   current += sigma[facei]*E [facei]& facei.Sf()
}
(Syntax maybe a littlebit false but it should be understandable)
I got it working in a blockmesh with an "empty" boundary patch that connects two blocks, but for more complicated geometrys and snappyhexmesh it is not so obviouse for me. Maybe an additional stl surface, so something like a baffle in other examples ? Isn't there a good option to get a faceZone of a cross section after meshing? I would maybe even want to change the position of the cross section and to mesh always again would be a pain.
superkelle is offline   Reply With Quote

Old   May 16, 2020, 10:05
Default
  #4
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
so how I solved it with an internal "imaginary" baffle with two internal boundary patches that have "cyclic" BC :

first you have to know a plane where all faces you want to integrate over lie in. It has to be a flat plane over the whole cut.

Then write a topoSetDict with a very thin box that only includes your wanted faces in the plane that you know, like:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  7
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
	{
        name    internalOne;
        type      faceSet;
        action   new;
        source  boxToFace;
        sourceInfo
        {
            box (-1E-10 -1 -1) (1E-10 1 1);
        }
    }   
);
// ************************************************************************* //
Use the command line tool:

Code:
topoSet
you will get a faceSet over all Faces in the wanted cut.
After that use the command line tool:
Code:
setsToZones -noFlipMap
it will create a faceZone from your faceSet (I did not get the real difference between both, maybe only the orientation in the Zones is a reason that Sets do not have ?? Maybe someone knows more?)

Then you create a createBafflesDict

Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  dev
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      createBafflesDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
internalFacesOnly true; 

fields true; //false??

baffles
{
    internalOne
    {
        type               faceZone;
        zoneName    internalOne;

        patchPairs
        {
		type	cyclic; //not empty??
        }
    }
}
// ************************************************************************* //
Use the command line tool:
Code:
createBaffles
You will get TWO new internal boundary patches over that you can do actions with the faces in the solver. They are called "yourChoosenPatchName"_master "yourChoosenPatchName"_slave .

If you want you can have a look at the screenshots to see the position of the baffle in the mesh. Hopefully it will help someone.

If someone could explain:
Code:
fields true; //false
in createBafflesDict
and the flip map effects / need for it in:
Code:
 
setsToZones -noFlipMap
I would be very thankful.
Attached Images
File Type: png internal.png (40.3 KB, 18 views)
File Type: png internal2.png (175.2 KB, 20 views)
davcrisp likes this.
superkelle is offline   Reply With Quote

Old   May 17, 2020, 15:18
Default
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,227
Rep Power: 50
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by superkelle View Post
so how I solved it with an internal "imaginary" baffle with two internal boundary patches that have "cyclic" BC :

first you have to know a plane where all faces you want to integrate over lie in. It has to be a flat plane over the whole cut.

Then write a topoSetDict with a very thin box that only includes your wanted faces in the plane that you know, like:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  7
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
    {
        name    internalOne;
        type      faceSet;
        action   new;
        source  boxToFace;
        sourceInfo
        {
            box (-1E-10 -1 -1) (1E-10 1 1);
        }
    }   
);
// ************************************************************************* //
Use the command line tool:

Code:
topoSet
you will get a faceSet over all Faces in the wanted cut.
After that use the command line tool:
Code:
setsToZones -noFlipMap
it will create a faceZone from your faceSet (I did not get the real difference between both, maybe only the orientation in the Zones is a reason that Sets do not have ?? Maybe someone knows more?)

Then you create a createBafflesDict

Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  dev
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      createBafflesDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
internalFacesOnly true; 

fields true; //false??

baffles
{
    internalOne
    {
        type               faceZone;
        zoneName    internalOne;

        patchPairs
        {
        type    cyclic; //not empty??
        }
    }
}
// ************************************************************************* //
Use the command line tool:
Code:
createBaffles
You will get TWO new internal boundary patches over that you can do actions with the faces in the solver. They are called "yourChoosenPatchName"_master "yourChoosenPatchName"_slave .

If you want you can have a look at the screenshots to see the position of the baffle in the mesh. Hopefully it will help someone.

If someone could explain:
Code:
fields true; //false
in createBafflesDict
and the flip map effects / need for it in:
Code:
 
setsToZones -noFlipMap
I would be very thankful.

For post-processing baffles are an overkill. You can generate those in one go in the topoSetDict with this (copied from the "documentation" topoSetDict)

Code:
//    source setsToFaceZone;
//    sourceInfo
//    {
//        faceSet f0;       // name of faceSet
//        cellSet c0;       // name of cellSet of slave side
//        flip    false;    // optional: flip the faceZone (so now the cellSet
//                          //           is the master side)
//    }


c0 should be consistent with the f0 (cells on one side. just use a similar boxToCell) then you get the proper flip-map
superkelle likes this.
__________________
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

Old   May 17, 2020, 16:09
Default
  #6
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
Ok, thank you for your reply. I dont need the values for post processing, I have to use them in the solver for calculations and for changing the BC.
superkelle is offline   Reply With Quote

Old   May 17, 2020, 19:29
Default
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,227
Rep Power: 50
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by superkelle View Post
Ok, thank you for your reply. I dont need the values for post processing, I have to use them in the solver for calculations and for changing the BC.
Yeah. But also for these a faceZone is sufficient
superkelle likes this.
__________________
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

Old   May 18, 2020, 03:59
Default
  #8
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
So my baffle does the same, but has the addition that I can apply BC to it, is that correct? And since I do not want to apply any BC, it is just superfluous right?
superkelle is offline   Reply With Quote

Old   May 21, 2020, 09:46
Default
  #9
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6
superkelle is on a distinguished road
Only for sake of completeness, here the topoSet file:


Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
    {
        name    internalOneFaces;
        type    faceSet;
        action  new;
        source  boxToFace;
        sourceInfo
        {
            box (-1E-10 -1 -1) (1E-10 1 1);
        }
    }   
        
    {
        name    internalOneCells;
        type    cellSet;
        action  new;
        source  boxToCell;
        sourceInfo
        {
            box (-1 -1 -1) (-1E-10 1 1);
        }
       }
        
    {
        name    internalOneZone;
        type    faceZoneSet;
        action    new;
        source    setsToFaceZone;
        sourceInfo
        {
            faceSet    internalOneFaces;
            cellSet    internalOneCells;
            flip    false;    
        }
    }
   
);
// ************************************************************************* //
gschaider likes this.
superkelle is offline   Reply With Quote

Old   September 23, 2023, 23:27
Default
  #10
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 204
Rep Power: 7
farzadmech is on a distinguished road
Many thanks for putting all these threads here, I have a similar problem which I am going to read them.

Thanks,
Farzad

Quote:
Originally Posted by superkelle View Post
Hi I try to calculate the total flux (it will be the total current by an E field over a cross-section in a plasma, but for sake of simplicity I refer to a dummy "flux") over a cut of my mesh. For that I would need to integrate a vectorField over a cross-section of my domain. I do not want it for postprocessing I need the value inside my solver as a dimensioned scalar. I can not use boundary patches for that, it has to be internal faces at a cross section.
What I am essentially trying is to use is the function object: surfaceFieldValue
https://www.openfoam.com/documentati...t.html#details

like:

Code:
functions{
current
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");

    log             true;
    writeControl    writeTime;
    writeFields     true;

    surfaceFormat   none;
    regionType     sampledSurface;

        sampledSurfaceDict
        {
                type cuttingPlane;
                planeType           pointAndNormal;
                pointAndNormalDict
                {
                        basePoint       (0 0 0);  
                        normalVector    (0 0 1);
                }
                source cells; // sample cells or boundaryFaces
                interpolate true;
        }

    operation       areaNormalIntegrate;
    fields          (U);
}
}
but it is should be located in the solver not in the controlDict and I want to use the flux for other calculations. I already found some threads that seemed similar, but they were not exactly what I looked for or I was not able to implement it the way described. I post all what I found so far below, maybe it is helpful for someone who faces the same problem. If I find a good solution I will be glad to share it .

average over cutting plane during runtime

Mass Flow rate through a plane

Sampling a limited size cutting plane

Write cells and data intersecting a plane cuttingPlane

Use flow rate calculated from an function object in an injection model
farzadmech is offline   Reply With Quote

Reply

Tags
cross section, cutting plane, integrate

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[General] Average Temperature at each cross section plotted along the axis of a Cylinder mathartist ParaView 1 September 6, 2022 02:06
Cross Section mean value Adriana Correia OpenFOAM 0 September 26, 2018 13:18
Round cross section simply supported beam Rajmahendra Structural Mechanics 0 September 19, 2018 06:01
Monitor flow through a cross section inside domain Kushagra Mittal CFX 4 August 5, 2008 23:40
Cross section and surface area factor Fabiana CFX 0 January 10, 2006 00:51


All times are GMT -4. The time now is 00:39.