|
[Sponsors] |
March 2, 2023, 12:44 |
cellValues within a cellZone
|
#1 |
Member
Ben Simpson
Join Date: Dec 2019
Location: UK
Posts: 32
Rep Power: 6 |
Hi,
I am using OpenFOAM-8. I want to get a file printed out at the writeTime containing specific field values for every cell within a cellZone. I specifically want to get the CO2 concentrations of each cell within the zone to use in a performance metric. I have the cellZone and the CO2 source defined and I am able to get the average CO2 concentration for the cellZone but I am unable to get the CO2 values for each cell. Does anyone know how to achieve this? Is there a functionObject that allows me to print out the cellValues for certain fields for each cell in a cellZone? Kind regards, Ben |
|
March 9, 2023, 07:15 |
|
#2 |
Senior Member
Alain Islas
Join Date: Nov 2019
Location: Mexico
Posts: 142
Rep Power: 7 |
Hi Ben Simpson,
Here is a piece of code that can help you Code:
BenSimpsonFunction { type coded; libs ("libutilityFunctionObjects.so"); name cellValues_within_a_cellZone; codeExecute #{ //Access mesh cells, can use any vector or scalar field const volVectorField& U_ = mesh().lookupObject<volVectorField>("U"); //Access cellZone const fvMesh& mesh = U_.mesh(); word cellSetName = "myCellZone"; label zoneID = mesh.cellZones().findZoneID(cellSetName); const labelList& cells = mesh.cellZones()[zoneID]; forAll(cells, i) { do whatever you want here } #}; } |
|
Tags |
cell value, cellzone, openfoam-8 |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
fvOptions - fix cellValues in cellZone with different values | Tobi | OpenFOAM Pre-Processing | 6 | July 11, 2022 05:45 |
[snappyHexMesh] Error when setting locationsInMesh | elonesampaio | OpenFOAM Meshing & Mesh Conversion | 1 | April 3, 2021 18:44 |
decomposePar problem: Cell 0contains face labels out of range | vaina74 | OpenFOAM Pre-Processing | 37 | July 20, 2020 06:38 |
cellZone not taking all the cells inside | rahulksoni | OpenFOAM Running, Solving & CFD | 6 | January 25, 2019 01:11 |
cellZone not taking all the cells inside | rahulksoni | OpenFOAM | 0 | January 16, 2019 02:16 |