|
[Sponsors] |
Integrate volVectorField over cross section / cutting plane |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 7, 2020, 14:17 |
Integrate volVectorField over cross section / cutting plane
|
#1 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7 |
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 |
|
May 7, 2020, 19:27 |
|
#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 |
||
May 8, 2020, 05:07 |
|
#3 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7 |
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. |
|
May 16, 2020, 10:05 |
|
#4 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7 |
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 |
|
May 17, 2020, 15:18 |
|
#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 |
||
May 17, 2020, 16:09 |
|
#6 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7 |
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.
|
|
May 17, 2020, 19:29 |
|
#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 |
|
May 18, 2020, 03:59 |
|
#8 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7 |
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?
|
|
May 21, 2020, 09:46 |
|
#9 |
Member
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7 |
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; } } ); // ************************************************************************* // |
|
September 23, 2023, 23:27 |
|
#10 | |
Senior Member
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8 |
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 |
|
|
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 |