|
[Sponsors] |
Integrate volVectorField over cross section / cutting plane |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6 ![]() |
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); } } 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 |
|
![]() |
![]() |
![]() |
![]() |
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 ![]() ![]() |
Quote:
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
__________________
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 |
||
![]() |
![]() |
![]() |
![]() |
#3 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6 ![]() |
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() } 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. |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6 ![]() |
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); } } ); // ************************************************************************* // Code:
topoSet After that use the command line tool: Code:
setsToZones -noFlipMap 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?? } } } // ************************************************************************* // Code:
createBaffles 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 and the flip map effects / need for it in: Code:
setsToZones -noFlipMap |
|
![]() |
![]() |
![]() |
![]() |
#5 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 ![]() ![]() |
Quote:
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
__________________
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 |
||
![]() |
![]() |
![]() |
![]() |
#6 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6 ![]() |
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.
|
|
![]() |
![]() |
![]() |
![]() |
#7 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 ![]() ![]() |
Yeah. But also for these a faceZone is sufficient
__________________
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 |
|
![]() |
![]() |
![]() |
![]() |
#8 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6 ![]() |
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?
|
|
![]() |
![]() |
![]() |
![]() |
#9 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 6 ![]() |
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; } } ); // ************************************************************************* // |
|
![]() |
![]() |
![]() |
![]() |
#10 | |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 7 ![]() |
Many thanks for putting all these threads here, I have a similar problem which I am going to read them.
Thanks, Farzad Quote:
|
||
![]() |
![]() |
![]() |
Tags |
cross section, cutting plane, integrate |
|
|
![]() |
||||
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 01:06 |
Cross Section mean value | Adriana Correia | OpenFOAM | 0 | September 26, 2018 12:18 |
Round cross section simply supported beam | Rajmahendra | Structural Mechanics | 0 | September 19, 2018 05:01 |
Monitor flow through a cross section inside domain | Kushagra Mittal | CFX | 4 | August 5, 2008 22:40 |
Cross section and surface area factor | Fabiana | CFX | 0 | January 9, 2006 23:51 |