CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Average of specified volume

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By scfd

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 27, 2023, 07:19
Post Average of specified volume
  #1
New Member
 
george
Join Date: Feb 2021
Posts: 10
Rep Power: 5
scfd is on a distinguished road
Hi,

I need to calculate average velocity components and temperature of a specified volume in a container at every time-step. It is the same thing that averaging specific volume fraction inside a pipe. I couldn't find which utilites I should use.
  • How can I define a custom volume inside the container? (setSet, topoSet?)
  • How can I calculate the average of this volume in each time step? (volFieldValue?)
regards,
scfd.
Attached Images
File Type: png figure.png (7.0 KB, 13 views)
scfd is offline   Reply With Quote

Old   February 27, 2023, 07:48
Default
  #2
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,086
Rep Power: 26
Yann will become famous soon enough
Hello scfd,

You seem to already have the answers to your questions!

You can indeed use volFieldValue to compute average values in a volume.
Your volume can be a cellZone, and you can create this cellZone right from snappyHexMesh when meshing (assuming you are meshing with snappy) or on an existing mesh using topoSet.

In topoSet you can use a source such as boxToCell or cylinderToCell to select the cells inside the volume you want to average. This will create a cellSet, then you can use setToCellZone to convert your cellSet into a cellZone.

Regards,
Yann
Yann is offline   Reply With Quote

Old   February 27, 2023, 11:27
Post
  #3
New Member
 
george
Join Date: Feb 2021
Posts: 10
Rep Power: 5
scfd is on a distinguished road
Quote:
Originally Posted by Yann View Post
Hello scfd,

You seem to already have the answers to your questions!

You can indeed use volFieldValue to compute average values in a volume.
Your volume can be a cellZone, and you can create this cellZone right from snappyHexMesh when meshing (assuming you are meshing with snappy) or on an existing mesh using topoSet.

In topoSet you can use a source such as boxToCell or cylinderToCell to select the cells inside the volume you want to average. This will create a cellSet, then you can use setToCellZone to convert your cellSet into a cellZone.

Regards,
Yann
Dear Yann,

Thanks for your quick reply. I followed your suggestion and nearly reach what I want. Here is the topoSet file and fucntion:

Code:
actions
(
    {
        name        packVolume;
        type        cellSet;
        action      new;
        source      cylinderToCell;
        point1      (0 0 30);
        point2      (0 0 70);
        radius      30;
    }
    {
        name    volpack;
        type    cellZoneSet;
        action  new;
        source  setToCellZone;
        set     packVolume;
    }
);
Code:
functions
{   

	vfv1
	{
		type            volFieldValue;
		libs            (fieldFunctionObjects);
		fields          (T U);
		operation       average;
		regionType     cellZone;
		name            volpack;
		writeFields     true;
		writeToFile     true;
		writeControl    writeTime;
	}
}
Case running smoothly but I get the following line and vfv1 returns empty output:

Code:
--> FOAM Warning : 
cellZone(volpack):
    Region has no cells


    From void Foam::functionObjects::volRegion::calculateCache()
    in file functionObjects/volRegion/volRegion.C at line 122.
--> loading function object 'vfv1'
Where could I have made a mistake?

regards,
scfd.
scfd is offline   Reply With Quote

Old   February 27, 2023, 12:07
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,086
Rep Power: 26
Yann will become famous soon enough
Looks like volPak is empty, what is the output when executing topoSet?

Regards,
Yann
Yann is offline   Reply With Quote

Old   February 27, 2023, 12:24
Default
  #5
New Member
 
george
Join Date: Feb 2021
Posts: 10
Rep Power: 5
scfd is on a distinguished road
Quote:
Originally Posted by Yann View Post
Looks like volPak is empty, what is the output when executing topoSet?

Regards,
Yann
Here:

Code:
Reading topoSetDict

Time = 0
    mesh not changed.
Created cellSet packVolume
    Applying source cylinderToCell
    Adding cells with centres within cylinder, with point1 = (0 0 30), point2 = (0 0 70), radius = 30
    cellSet packVolume now size 22935
Created cellZoneSet volpack
    Applying source setToCellZone
    Adding all cells from cellSet packVolume ...
    cellZoneSet volpack now size 22935

End
regards,
scfd
scfd is offline   Reply With Quote

Old   February 28, 2023, 03:12
Default
  #6
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,086
Rep Power: 26
Yann will become famous soon enough
This is uncanny, since your cellZone seems to be properly created during topoSet.
Just a question: do you run your case in parallel? If you do, have you run topoSet in parallel too?

Regards,
Yann
Yann is offline   Reply With Quote

Old   February 28, 2023, 07:54
Post
  #7
New Member
 
george
Join Date: Feb 2021
Posts: 10
Rep Power: 5
scfd is on a distinguished road
Quote:
Originally Posted by Yann View Post
This is uncanny, since your cellZone seems to be properly created during topoSet.
Just a question: do you run your case in parallel? If you do, have you run topoSet in parallel too?

Regards,
Yann
Dear Yann,

This is the workflow:
Code:
runApplication blockMesh
runApplication snappyHexMesh -overwrite
runApplication topoSet
runApplication checkMesh 
transformPoints -scale "(0.001)"
runApplication createPatch -overwrite
runApplication renumberMesh -overwrite
restore0Dir
runApplication changeDictionary
runApplication decomposePar
#runParallel $(getApplication)
#runApplication reconstructPar
checkMesh detect the cellZone:
Code:
Checking basic cellZone addressing...
                CellZone        Cells       Points       VolumeBoundingBox
                 square        21285        28654     92044.29 (-16.240871 -16.24087 0) (16.24087 16.240869 100)
            innerCircle        21000        24480     195490.6 (-30.458205 -30.458205 0) (30.458204 30.458205 100)
                volpack        22935        29794    112415.39 (-30.458205 -30.458205 30.005496) (30.458204 30.458205 69.994475)
But some strange things happens when I run createPatch:
Code:
--> FOAM Warning : 
    From void Foam::polyTopoChange::addMesh(const Foam::polyMesh&, const labelUList&, const labelUList&, const labelUList&, const labelUList&)
    in file polyTopoChange/polyTopoChange.C at line 2346
    Cell:42283 centre:(-0.0055351021 0.0060833295 0.056633843) is in two zones:square and volpack
    This is not supported. Continuing with first zone only.
--> FOAM Warning : 
    From void Foam::polyTopoChange::addMesh(const Foam::polyMesh&, const labelUList&, const labelUList&, const labelUList&, const labelUList&)
    in file polyTopoChange/polyTopoChange.C at line 2346
    Cell:42284 centre:(-0.0060848722 0.0060845366 0.056656412) is in two zones:square and volpack
    This is not supported. Continuing with first zone only.
Moving faces from patch z_min_0 to patch 4
Moving faces from patch z_max_0 to patch 5
Moving faces from patch wall_0 to patch 6
Moving faces from patch STL_spheres_0 to patch 7
Doing topology modification to order faces.
Not synchronising points.
Removing patches with no faces in them.
Removed zero-sized patch wall_0 type wall at position 0
Removed zero-sized patch z_min_0 type wall at position 1
Removed zero-sized patch z_max_0 type wall at position 2
Removed zero-sized patch STL_spheres_0 type wall at position 3

Writing repatched mesh region0 to 0

End
Maybe this step is the problem.

regards,
scfd
scfd is offline   Reply With Quote

Old   February 28, 2023, 08:37
Default
  #8
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,086
Rep Power: 26
Yann will become famous soon enough
I'm not sure why createPatch would mess with the cellZone, but you can try to run topoSet after createPatch or even right before running decomposePar, just to be sure there is nothing else messing with the cellZone definition.
(And if it still doesn't solve the issue, you can ultimately run it after decomposing the case with runParallel topoSet)

Yann
Yann is offline   Reply With Quote

Old   February 28, 2023, 08:54
Post
  #9
New Member
 
george
Join Date: Feb 2021
Posts: 10
Rep Power: 5
scfd is on a distinguished road
Quote:
Originally Posted by Yann View Post
I'm not sure why createPatch would mess with the cellZone, but you can try to run topoSet after createPatch or even right before running decomposePar, just to be sure there is nothing else messing with the cellZone definition.
(And if it still doesn't solve the issue, you can ultimately run it after decomposing the case with runParallel topoSet)

Yann
...right before running decomposePar
That solved the problem. Many thanks Yann.

Code:
runApplication blockMesh
runApplication snappyHexMesh -overwrite
runApplication checkMesh 
runApplication transformPoints -scale "(0.001)"
runApplication createPatch -overwrite
runApplication renumberMesh -overwrite
restore0Dir
runApplication changeDictionary
runApplication topoSet
runApplication decomposePar
runParallel $(getApplication)
runApplication reconstructPar
regards,
scfd
Yann likes this.
scfd is offline   Reply With Quote

Reply

Tags
average cell, post procesing, searchablecylinder, volume


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
Calculating source term total cell-zone volume parallel computation RobV Fluent UDF and Scheme Programming 2 May 30, 2022 03:46
how to set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 06:09
Problem of simulating of small droplet with radius of 2mm liguifan OpenFOAM Running, Solving & CFD 5 June 3, 2014 02:53
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 05:42
channelFoam for a 3D pipe AlmostSurelyRob OpenFOAM 3 June 24, 2011 13:06


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