Skip to content

Commit d0c76e2

Browse files
updates for rectMesh in postprocess
1 parent c90f775 commit d0c76e2

File tree

6 files changed

+239
-55
lines changed

6 files changed

+239
-55
lines changed

src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponentGaussian.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class PostprocessComponentGaussian
4848
PostprocessComponent<RegionType,GaussianDistribution>(dict, fieldsDB, defaultTimeControl)
4949
{
5050

51-
this->regPoints().setRegionExtension(2);
51+
this->regPoints().applyRegionExtension();
5252
auto d = this->regPoints().eqDiameters();
5353
auto c = this->regPoints().centers();
5454
auto& regs = this->regionProecessMethod();

src/PostprocessData/readme.md

Lines changed: 157 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
The `PostprocessData` module in phasicFlow provides powerful tools for analyzing particle-based simulations both during runtime (in-simulation) and after simulation completion (post-simulation). This document explains how to configure and use the postprocessing features through the dictionary-based input system.
44

5-
- in-simulation: this is postprocessing that is active during simulation. When running a solver, it allows for real-time data analysis and adjustments based on the simulation's current state. See below to see how you can activate in-simulation postprocessing.
6-
- post-simulation: this is postprocessing that is done after the simulation is completed. It allows for detailed analysis of the simulation results, including data extraction and visualization based on the results that are stored in time-folders. If you want to use post-simulation, you need to run utility `postprocessPhasicFlow` in terminal (in the simulation case setup folder) to run the postprocessing. This utility reads the `postprocessDataDict` file and performs the specified operations on the simulation data.
7-
5+
- **In-simulation**: This is postprocessing that is active during simulation. When running a solver, it allows for real-time data analysis and adjustments based on the simulation's current state. See below to learn how you can activate in-simulation postprocessing.
6+
- **Post-simulation**: This is postprocessing that is done after the simulation is completed. It allows for detailed analysis of the simulation results, including data extraction and visualization based on the results stored in time folders. If you want to use post-simulation, you need to run the utility `postprocessPhasicFlow` in the terminal (in the simulation case setup folder) to execute the postprocessing. This utility reads the `postprocessDataDict` file and performs the specified operations on the simulation data.
87

98
### Important Notes
109

11-
* **NOTE 1:**
12-
postprocessing for in-simulation, is not implemented for MPI execution. So, do not use it when using MPI execution. For post-simulation postprocessing, you can use the `postprocessPhasicFlow` utility without MPI, even though the actual simulation has been done using MPI.
10+
* **NOTE 1:**
11+
Postprocessing for in-simulation is not implemented for MPI execution. So, do not use it when using MPI execution. For post-simulation postprocessing, you can use the `postprocessPhasicFlow` utility without MPI, even though the actual simulation has been done using MPI.
1312

14-
* **NOTE 2:**
15-
In post-simulation mode, all timeControl settings are ignored. The postprocessing will be done for all the time folders that are available in the case directory or if you specify the time range in the command line, the postprocessing will be done for the time folders that are in the specified range of command line.
13+
* **NOTE 2:**
14+
In post-simulation mode, all `timeControl` settings are ignored. The postprocessing will be done for all the time folders that are available in the case directory, or if you specify the time range in the command line, the postprocessing will be done for the time folders within the specified range.
1615

1716
## Table of Contents
1817

@@ -32,12 +31,14 @@ In post-simulation mode, all timeControl settings are ignored. The postprocessin
3231
- [7.1. Example 1: Probing Individual Particles](#71-example-1-probing-individual-particles)
3332
- [7.2. Example 2: Processing in a Spherical Region](#72-example-2-processing-in-a-spherical-region)
3433
- [7.3. Example 3: Processing Along a Line](#73-example-3-processing-along-a-line)
34+
- [7.4. Example 4: Processing in a Rectangular Mesh](#74-example-4-processing-in-a-rectangular-mesh)
35+
- [7.5. Example 5: Tracking particles](#75-example-5-tracking-particles)
3536
- [8. Advanced Features](#8-advanced-features)
36-
- [8.1. Special functions applied on fields](#81-special-functions-applied-on-fields)
37-
- [8.2. Particle Filtering with includeMask](#82-particle-filtering-with-includemask)
37+
- [8.1. Special Functions Applied on Fields](#81-special-functions-applied-on-fields)
38+
- [8.2. Particle Filtering with IncludeMask](#82-particle-filtering-with-includemask)
3839
- [8.3. Implementation Notes](#83-implementation-notes)
3940
- [9. Mathematical Formulations](#9-mathematical-formulations)
40-
- [10. A complete dictionary file (postprocessDataDict)](#10-a-complete-dictionary-file-postprocessdatadict)
41+
- [10. A Complete Dictionary File (postprocessDataDict)](#10-a-complete-dictionary-file-postprocessdatadict)
4142

4243
## 1. Overview
4344

@@ -46,12 +47,12 @@ Postprocessing in phasicFlow allows you to:
4647
- Extract information about particles in specific regions of the domain
4748
- Calculate statistical properties such as averages and sums of particle attributes
4849
- Track specific particles throughout the simulation
49-
- Apply different weighing methods when calculating statistics
50+
- Apply different weighting methods when calculating statistics
5051
- Perform postprocessing at specific time intervals
5152

5253
## 2. Setting Up Postprocessing
5354

54-
Postprocessing is configured through a dictionary file named `postprocessDataDict` which should be placed in the `settings` directory. Below is a detailed explanation of the configuration options.
55+
Postprocessing is configured through a dictionary file named `postprocessDataDict`, which should be placed in the `settings` directory. Below is a detailed explanation of the configuration options.
5556

5657
### 2.1. Basic Configuration
5758

@@ -60,7 +61,6 @@ The input dictionary, **settings/postprocessDataDict**, may look like this:
6061
```cpp
6162
// PostprocessData dictionary
6263

63-
6464
// Enable/disable postprocessing during simulation
6565
runTimeActive yes; // Options: yes, no
6666

@@ -70,7 +70,7 @@ shapeType sphere; // Options depend on the simulation type: sphere, grain, etc
7070
// Default time control for postprocessing components
7171
defaultTimeControl
7272
{
73-
timeControl timeStep; // Options: timeStep, simulationTime, settings
73+
timeControl timeStep; // Options: timeStep, simulationTime, settingsDict
7474
startTime 0; // Start time for postprocessing
7575
endTime 1000; // End time for postprocessing
7676
executionInterval 150; // How frequently to run postprocessing
@@ -83,7 +83,6 @@ components
8383
);
8484
```
8585

86-
8786
If you want to activate in-simulation postprocessing, you need to add these lines to the `settings/settingsDict` file:
8887

8988
```cpp
@@ -92,7 +91,7 @@ libs ("libPostprocessData.so");
9291
auxFunctions postprocessData;
9392
```
9493
95-
This will link the postprocessing library to your simulation, allowing you to use its features. Note that, anytime you want to deactivate the in-simulation postprocessing, you can simply change the `runTimeActive` option to `no` in `postprocessDataDict` file.
94+
This will link the postprocessing library to your simulation, allowing you to use its features. Note that anytime you want to deactivate the in-simulation postprocessing, you can simply change the `runTimeActive` option to `no` in the `postprocessDataDict` file.
9695
9796
## 3. Time Control Options
9897
@@ -102,23 +101,23 @@ Each postprocessing component can either use the default time control settings o
102101
|--------|-------------|---------------------|
103102
| `timeStep` | Controls execution based on simulation time steps | `startTime`, `endTime`, `executionInterval` |
104103
| `simulationTime` | Controls execution based on simulation time | `startTime`, `endTime`, `executionInterval` |
105-
| `settings` | Uses parameters from settingsDict file | None (defined elsewhere) |
106-
| `default` | Uses the default time control settings (uses `defaultTimeControl` settings)| None (uses default) |
104+
| `settingsDict` | Uses parameters from settingsDict file | None (defined elsewhere) |
105+
| `default` | Uses the default time control settings (uses `defaultTimeControl` settings) | None (uses default) |
107106
108107
If no time control is specified, the `default` option is used automatically.
109108
110109
## 4. Processing Methods
111110
112111
The postprocessing module provides several methods for processing particle data. They are categorized into two main groups: bulk and individual methods.
113112
114-
- **Bulk Methods**: Operate on all particles that are located in a specified locations/regions (cells, spheres, etc.).
113+
- **Bulk Methods**: Operate on all particles that are located in specified locations/regions (cells, spheres, etc.).
115114
- **Individual Methods**: Operate on specific particles, allowing for targeted particle property extraction.
116115
117-
| Method | Property type | Description | Formula |
118-
|--------|------------------|-------------|---------|
116+
| Method | Property Type | Description | Formula |
117+
|--------|---------------|-------------|---------|
119118
| `arithmetic` | bulk | Simple arithmetic mean/sum with equal weights | Each particle contributes equally |
120119
| `uniformDistribution` | bulk | Each particle contributes inversely proportional to the total number of particles | $w_i = 1/n$ where $n$ is the number of particles |
121-
| `GaussianDistribution` | bulk | Weight contribution based on distance from center with Gaussian falloff | $w_i = \exp(-\|x_i - c\|^2/(2\sigma^2))/\sqrt{2\pi\sigma^2}$ |
120+
| `GaussianDistribution` | bulk | Weight contribution based on distance from the center with Gaussian falloff | $w_i = \exp(-\|x_i - c\|^2/(2\sigma^2))/\sqrt{2\pi\sigma^2}$ |
122121
| `particleProbe` | individual | Extracts values from specific particles | Direct access to particle properties |
123122
124123
## 5. Region Types
@@ -131,11 +130,13 @@ Regions define where in the domain the postprocessing operations are applied:
131130
| `multipleSpheres` | Multiple spherical regions | `centers`, `radii` defined in `multiplSpheresInfo` dict | bulk |
132131
| `line` | Spheres along a line with specified radius | `p1`, `p2`, `nSpheres`, `radius` defined in `lineInfo` dict| bulk |
133132
| `box`| A cuboid region | `min`, `max` defined in `boxInfo` dict | bulk |
134-
| `centerPoints`* | Specific particles selected by ID | `ids` | individual |
135-
| `centerPoints`* | Specific particles selected by center points located in a box | `boxInfo` | individual |
136-
| `centerPoints`* | Specific particles selected by center points located in a sphere | `sphereInfo` | individual |
137-
| `centerPoints`* | Specific particles selected by center points located in a cylinder | `cylinderInfo` | individual |
138-
| <td colspan="4">\* Particles selection is done when simulation reaches the time that is specified by `startTime` of the post-process component and this selection remains intact up to the end of simulation. This is very good for particle tracking purposes or when you want to analyze specific particles behavior over time.</td> |
133+
| `rectMesh`** | creates a rectangular mesh and each direction is divided into equal spaces| corner points of mesh, and `nx`, `ny`, `nz`: number of divisions in each direction | bulk |
134+
| `centerPoints`* | if `selector` is set to `id`, particles selected by ID list | `ids`: a list of particle ids | individual |
135+
| `centerPoints`* | if `selector` is set to `box`, particles are selected by center points located in a box | corner points of the box are given in `boxInfo` sub-dict | individual |
136+
| `centerPoints`* | if `selector` is set to `sphere`, particles are selected by center points located in a sphere | center and radius of a sphere given in `sphereInfo` sub-dict | individual |
137+
| `centerPoints`* | if `selector` is set to `cylinder`, particles are selected by center points located in a cylinder | axis info and radius of cylinder at end points that are given in `cylinderInfo` sub-dict | individual |
138+
| <td colspan="3">\* Particles selection is done when simulation reaches the time that is specified by `startTime` of the post-process component and this selection remains intact up to the end of simulation. This is very good for particle tracking purposes or when you want to analyze specific particles behavior over time.</td> |
139+
| <td colspan="3">\** This region creates a rectangular mesh and particles are located into cells according to their center points. When using `GaussianDistribution` as `processMethod`, a larger neighbor radius is considered for each cell and particles inside this neighbor radius are included in the calculations.</td> |
139140
140141
## 6. Processing Operations for Bulk Properties
141142
@@ -166,7 +167,7 @@ where:
166167
167168
### 6.2. About fluctuation2 in average function
168169
169-
Fluctuation2 is an optional parameter that can be used to account for fluctuations in the particle field values with respect to mean value of the field.
170+
`fluctuation2` is an optional parameter that can be used to account for fluctuations in the particle field values with respect to mean value of the field.
170171
It is used in the `average` function to calculate the fluctuation of the field values around the mean. The formula for fluctuation2 is:
171172
172173
$$\text{fluctuation}^2 = \frac{\sum_j w_j \cdot \phi_j \cdot (\text{field}_j - \text{mean})^2}{\sum_i w_i \cdot \phi_i}$$
@@ -349,6 +350,90 @@ along_a_line
349350

350351
This example creates 10 spherical regions along a line from (0,0,0) to (0,0.15,0.15) and calculates the bulk density and volume density in each region.
351352

353+
### 7.4 Example 4: Processing in a Rectangular Mesh
354+
355+
In this example, a rectangular mesh is defined. The `rectMeshInfo` section specifies the minimum and maximum corner points of the box, the number of divisions in each direction, and an optional cell extension factor which is effective for GaussianDistribution only. In the `operations` section, two operations are defined: one for calculating the average velocity and another for calculating the solid volume fraction.
356+
357+
```cpp
358+
on_a_rectMesh
359+
{
360+
processMethod GaussianDistribution;
361+
processRegion rectMesh;
362+
363+
timeControl settingsDict; // uses settings from settingsDict file
364+
365+
rectMeshInfo
366+
{
367+
min (-0.12 -0.12 0.00); // lower corner point of the box
368+
max (0.12 0.12 0.11); // upper corner point of the box
369+
370+
nx 30; // number of divisions in x direction
371+
ny 30; // number of divisions in y direction
372+
nz 15; // number of divisions in z direction
373+
374+
// optional (default is 2.0)
375+
// for each cell, a neighbor radius is considered. This neighbor radius is equal to
376+
// cellExtension * equivalent diameter of the cell.
377+
// cell extension is only effective when using GaussianDistribution as processMethod.
378+
cellExtension 3;
379+
}
380+
381+
operations
382+
(
383+
avVelocity
384+
{
385+
function average;
386+
field velocity;
387+
fluctuation2 yes;
388+
threshold 4;
389+
phi mass;
390+
}
391+
392+
solidVolumeFraction
393+
{
394+
function sum;
395+
field volume;
396+
divideByVolume yes;
397+
}
398+
);
399+
}
400+
```
401+
402+
### 7.5 Example 5: Tracking particles
403+
404+
Suppose we want to mark and track the position of particles that are located inside a box region at t = 1 s. All particles that are inside the box at t = 1 s will be marked/selected and then the position of them are recorded along the simulation time. The following example shows how to do this. Note that marking/selecting of particles is done at the instance that is defined by `startTime`.
405+
406+
```C++
407+
particlesTrack
408+
{
409+
processMethod particleProbe;
410+
411+
processRegion centerPoints;
412+
413+
// all particles whose ceters are located inside this box
414+
// are selected. Selection occurs at startTime: particles
415+
// that are inside the box at t = startTime.
416+
selector box;
417+
boxInfo
418+
{
419+
min (0 0 0);
420+
max (0.1 0.05 0.05);
421+
}
422+
423+
// center position of selected particles are processed
424+
field position;
425+
426+
timeControl simulationTime;
427+
// execution starts at 1.0 s
428+
startTime 1.0;
429+
// execution ends at 100 s
430+
endTime 100;
431+
// execution interval of this compoenent
432+
executionInterval 0.02;
433+
434+
}
435+
```
436+
352437
## 8. Advanced Features
353438

354439
### 8.1. Special functions applied on fields
@@ -464,7 +549,7 @@ components
464549
field component(velocity,y);
465550
ids (0 10 100);
466551
timeControl default; // other options are settings, timeStep, simulationTime
467-
// settings: uses parameters from settingsDict file
552+
// settingsDict: uses parameters from settingsDict file
468553
// timeStep: uses the time step of the simulation controlling the execution of postprocessing
469554
// simulationTime: uses the simulation time of the simulation controlling the execution of postprocessing
470555
// default: uses the default time control (defined in defaultTimeControl).
@@ -499,6 +584,49 @@ components
499584
executionInterval 0.02;
500585

501586
}
587+
588+
on_a_rectMesh
589+
{
590+
processMethod GaussianDistribution;
591+
processRegion rectMesh;
592+
593+
timeControl settingsDict; // uses settings from settingsDict file
594+
595+
rectMeshInfo
596+
{
597+
min (-0.12 -0.12 0.00); // lower corner point of the box
598+
max (0.12 0.12 0.11); // upper corner point of the box
599+
600+
nx 30; // number of divisions in x direction
601+
ny 30; // number of divisions in y direction
602+
nz 15; // number of divisions in z direction
603+
604+
// optional (default is 2.0)
605+
// for each cell, a neighbor radius is considered. This neighbor radius is equal to
606+
// cellExtension * equivalent diameter of the cell.
607+
// cell extension is only effective when using GaussianDistribution as processMethod.
608+
cellExtension 3;
609+
}
610+
611+
operations
612+
(
613+
avVelocity
614+
{
615+
function average;
616+
field velocity;
617+
fluctuation2 yes;
618+
threshold 4;
619+
phi mass;
620+
}
621+
622+
solidVolumeFraction
623+
{
624+
function sum;
625+
field volume;
626+
divideByVolume yes;
627+
}
628+
);
629+
}
502630

503631
on_single_sphere
504632
{

src/PostprocessData/region/regionPoints/rectMeshRegionPoints/rectMeshRegionPoints.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,12 @@ pFlow::postprocessData::rectMeshRegionPoints::rectMeshRegionPoints
8585
:
8686
regionPoints(dict, fieldsDataBase),
8787
boxRegion_(dict.subDict("rectMeshInfo")),
88+
cellExtension_(dict.subDict("rectMeshInfo").getValOrSet<real>("cellExtension", 2.0)),
8889
pointsOnCells_("selectedPoints"),
8990
selectedPoints_(pointsOnCells_)
9091
{
92+
cellExtension_ = max(cellExtension_, one);
93+
9194
const auto& rectMeshInfo = dict.subDict("rectMeshInfo");
9295

9396
auto nx = rectMeshInfo.getValMax<uint32>("nx", 1);
@@ -124,18 +127,20 @@ pFlow::postprocessData::rectMeshRegionPoints::rectMeshRegionPoints
124127
}
125128
}
126129

127-
void pFlow::postprocessData::rectMeshRegionPoints::setRegionExtension(real ext)
130+
void pFlow::postprocessData::rectMeshRegionPoints::applyRegionExtension()
128131
{
129-
regionExtension_ = max(one, ext);
130-
real vf = pow(regionExtension_, 3);
132+
// it cannot be lower than 1
133+
cellExtension_ = max(one, cellExtension_);
134+
135+
real vf = pow(cellExtension_, 3);
131136
for(auto& v:volumes_)
132137
{
133138
v *= vf;
134139
}
135140

136141
for(auto& d:diameter_)
137142
{
138-
d *= regionExtension_;
143+
d *= cellExtension_;
139144
}
140145
}
141146

@@ -163,7 +168,7 @@ bool pFlow::postprocessData::rectMeshRegionPoints::update()
163168
}
164169

165170
// search beyound cells is not required
166-
if( equal(regionExtension_,one))
171+
if( equal(cellExtension_,one))
167172
{
168173
selectedPoints_ = pointsOnCells_;
169174
return true;

0 commit comments

Comments
 (0)