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

cellValues within a cellZone

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alainislas

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 2, 2023, 12:44
Default cellValues within a cellZone
  #1
Member
 
Ben Simpson
Join Date: Dec 2019
Location: UK
Posts: 32
Rep Power: 6
b.simpson is on a distinguished road
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
b.simpson is offline   Reply With Quote

Old   March 9, 2023, 07:15
Default
  #2
Senior Member
 
alainislas's Avatar
 
Alain Islas
Join Date: Nov 2019
Location: Mexico
Posts: 142
Rep Power: 7
alainislas is on a distinguished road
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
	}

     #};

}
Then you simply call this function in your controlDict.
wht likes this.
alainislas is offline   Reply With Quote

Reply

Tags
cell value, cellzone, openfoam-8


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
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


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