Skip to content

Commit c89a297

Browse files
centerPoint enhanced & DEMsystem modified for id
- center points enhanced to select particle ids based on the particles located in box, sphere and cylinder - readme.md modified - DEMsystem is modified to pass id
1 parent 832d1fb commit c89a297

File tree

10 files changed

+80
-21
lines changed

10 files changed

+80
-21
lines changed

DEMSystems/DEMSystem/DEMSystem.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ pFlow::uniquePtr<pFlow::DEMSystem>
6666
word demSystemName,
6767
const std::vector<box>& domains,
6868
int argc,
69-
char* argv[]
69+
char* argv[],
70+
bool requireRVel
7071
)
7172
{
7273
if( wordvCtorSelector_.search(demSystemName) )
7374
{
74-
return wordvCtorSelector_[demSystemName] (demSystemName, domains, argc, argv);
75+
return wordvCtorSelector_[demSystemName] (demSystemName, domains, argc, argv, requireRVel);
7576
}
7677
else
7778
{

DEMSystems/DEMSystem/DEMSystem.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ class DEMSystem
7171
word demSystemName,
7272
const std::vector<box>& domains,
7373
int argc,
74-
char* argv[]
74+
char* argv[],
75+
bool requireRVel
7576
),
7677
(
7778
demSystemName,
7879
domains,
7980
argc,
80-
argv
81+
argv,
82+
requireRVel
8183
));
8284

8385
realx3 g()const
@@ -119,7 +121,10 @@ class DEMSystem
119121
span<const int32> parIndexInDomain(int32 domIndx)const = 0;
120122

121123
virtual
122-
span<real> diameter() = 0;
124+
span<real> diameter() = 0;
125+
126+
virtual
127+
span<uint32> particleId() = 0;
123128

124129
virtual
125130
span<real> courseGrainFactor() = 0;
@@ -176,7 +181,8 @@ class DEMSystem
176181
word demSystemName,
177182
const std::vector<box>& domains,
178183
int argc,
179-
char* argv[]);
184+
char* argv[],
185+
bool requireRVel=false);
180186

181187
};
182188

DEMSystems/grainDEMSystem/grainDEMSystem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ pFlow::grainDEMSystem::parIndexInDomain(int32 di)const
163163
return particleDistribution_->particlesInDomain(di);
164164
}
165165

166+
pFlow::span<pFlow::uint32> pFlow::grainDEMSystem::particleId()
167+
{
168+
return span<uint32>(particleIdHost_.data(), particleIdHost_.size());
169+
}
170+
171+
166172
pFlow::span<pFlow::real> pFlow::grainDEMSystem::diameter()
167173
{
168174
return span<real>(diameterHost_.data(), diameterHost_.size());
@@ -233,6 +239,7 @@ bool pFlow::grainDEMSystem::beforeIteration()
233239
velocityHost_ = std::as_const(particles_()).velocity().hostView();
234240
positionHost_ = std::as_const(particles_()).pointPosition().hostView();
235241
diameterHost_ = particles_->diameter().hostView();
242+
particleIdHost_ = particles_->particleId().hostView();
236243

237244
if(requireRVel_)
238245
rVelocityHost_ = std::as_const(particles_()).rVelocity().hostView();

DEMSystems/grainDEMSystem/grainDEMSystem.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class grainDEMSystem
6363

6464
ViewType1D<real, HostSpace> diameterHost_;
6565

66+
ViewType1D<uint32, HostSpace> particleIdHost_;
67+
6668
bool requireRVel_ = false;
6769

6870
ViewType1D<realx3, HostSpace> rVelocityHost_;
@@ -122,6 +124,8 @@ class grainDEMSystem
122124

123125
span<const int32> parIndexInDomain(int32 di)const override;
124126

127+
span<uint32> particleId() override;
128+
125129
span<real> diameter() override;
126130

127131
span<real> courseGrainFactor() override;

DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ pFlow::sphereDEMSystem::parIndexInDomain(int32 di)const
165165
return particleDistribution_->particlesInDomain(di);
166166
}
167167

168+
pFlow::span<pFlow::uint32> pFlow::sphereDEMSystem::particleId()
169+
{
170+
return span<uint32>();
171+
}
172+
168173
pFlow::span<pFlow::real> pFlow::sphereDEMSystem::diameter()
169174
{
170175
return span<real>(diameterHost_.data(), diameterHost_.size());
@@ -235,6 +240,7 @@ bool pFlow::sphereDEMSystem::beforeIteration()
235240
velocityHost_ = std::as_const(particles_()).velocity().hostView();
236241
positionHost_ = std::as_const(particles_()).pointPosition().hostView();
237242
diameterHost_ = particles_->diameter().hostView();
243+
particleIdHost_ = particles_->particleId().hostView();
238244

239245
if(requireRVel_)
240246
rVelocityHost_ = std::as_const(particles_()).rVelocity().hostView();

DEMSystems/sphereDEMSystem/sphereDEMSystem.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class sphereDEMSystem
6363

6464
ViewType1D<real, HostSpace> diameterHost_;
6565

66+
ViewType1D<uint32, HostSpace> particleIdHost_;
67+
6668
bool requireRVel_ = false;
6769

6870
ViewType1D<realx3, HostSpace> rVelocityHost_;
@@ -122,6 +124,8 @@ class sphereDEMSystem
122124

123125
span<const int32> parIndexInDomain(int32 di)const override;
124126

127+
span<uint32> particleId() override;
128+
125129
span<real> diameter() override;
126130

127131
span<real> courseGrainFactor() override;

src/Particles/particles/particles.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,18 @@ class particles
185185
return contactTorque_;
186186
}
187187

188+
inline
189+
uint32PointField_D& particleId()
190+
{
191+
return idHandler_();
192+
}
193+
194+
inline
195+
const uint32PointField_D& particleId() const
196+
{
197+
return idHandler_();
198+
}
199+
188200
inline
189201
uint32 maxId()const
190202
{

src/PostprocessData/readme.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ The `PostprocessData` module in phasicFlow provides powerful tools for analyzing
55
- 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.
66
- 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.
77

8+
<div style="border: 1px solid black; padding: 10px; margin-bottom: 10px; background-color: gray;">
9+
10+
**IMPORTANT NOTE**
11+
12+
in-simulation postprocessing is not implemented for MPI execution. For post-simulation postprocessing, you can use the `postprocessPhasicFlow` utility without MPI, even though the actual simulation has been done using MPI.
13+
14+
</div>
15+
816
## 1. Overview
917

1018
Postprocessing in phasicFlow allows you to:
@@ -118,12 +126,17 @@ Regions define where in the domain the postprocessing operations are applied:
118126
119127
| Region Type | Description | Required Parameters | Compatible with |
120128
|-------------|-------------|---------------------|-----------------|
121-
| `sphere` | A spherical region | `radius`, `center` | bulk |
122-
| `multipleSpheres` | Multiple spherical regions | `centers`, `radii` | bulk |
123-
| `line` | Spheres along a line with specified radius | `p1`, `p2`, `nSpheres`, `radius` | bulk |
124-
| `centerPoints` | Specific particles selected by ID | `ids` | individual |
125-
126-
## 6. Processing Operations
129+
| `sphere` | A spherical region | `radius`, `center` defined in `sphereInfo` dict| bulk |
130+
| `multipleSpheres` | Multiple spherical regions | `centers`, `radii` defined in `multiplSpheresInfo` dict | bulk |
131+
| `line` | Spheres along a line with specified radius | `p1`, `p2`, `nSpheres`, `radius` defined in `lineInfo` dict| bulk |
132+
| `box`| A cuboid region | `min`, `max` defined in `boxInfo` dict | bulk |
133+
| `centerPoints`* | Specific particles selected by ID | `ids` | individual |
134+
| `centerPoints`* | Specific particles selected by center points located in a box | `boxInfo` | individual |
135+
| `centerPoints`* | Specific particles selected by center points located in a sphere | `sphereInfo` | individual |
136+
| `centerPoints`* | Specific particles selected by center points located in a cylinder | `cylinderInfo` | individual |
137+
| <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> |
138+
139+
## 6. Processing Operations for Bulk Properties
127140
128141
Within each processing region of type `bulk`, you can define multiple operations to be performed:
129142
@@ -565,5 +578,4 @@ components
565578
}
566579

567580
);
568-
569581
```

src/PostprocessData/region/regionPoints/boxRegionPoints/boxRegionPoints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ boxRegionPoints::boxRegionPoints
1919
(boxRegion_.maxPoint().y() - boxRegion_.minPoint().y()) *
2020
(boxRegion_.maxPoint().z() - boxRegion_.minPoint().z())
2121
),
22-
diameter_(pow(3 * volume_ / 4.0 / Pi, 1.0 / 3.0)),
22+
diameter_(2 * pow(3 * volume_ / 4.0 / Pi, 1.0 / 3.0)),
2323
selectedPoints_("selectedPoints")
2424
{
2525
}

src/PostprocessData/region/regionPoints/centerPointsRegionPoints/centerPointsRegionPoints.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace pFlow::postprocessData
88

99
bool centerPointsRegionPoints::selectIds()
1010
{
11+
// check if it is already found the ids of particles
12+
// if not, then find the ids of particles
1113
if(!firstTimeUpdate_) return true;
1214
firstTimeUpdate_ = false;
1315

@@ -26,16 +28,20 @@ bool centerPointsRegionPoints::selectIds()
2628
}
2729
}
2830
else
29-
// TODO: this should be corrected to select ids of particles
30-
// that are selected based on the selector (this is visa versa)
3131
{
3232
auto selectorPtr = pStructSelector::create(
3333
selector,
3434
database().pStruct(),
3535
probDict_.subDict(selector+"Info"));
3636
auto selectedPoints = selectorPtr->selectedPoints();
37-
ids_.resize(selectedPoints.size());
38-
ids_.assign(selectedPoints.begin(), selectedPoints.end());
37+
const auto& idField = database().updateFieldUint32(idName_);
38+
39+
ids_.clear();
40+
ids_.reserve(selectedPoints.size());
41+
for( auto& pntIndex: selectedPoints)
42+
{
43+
ids_.push_back(idField[pntIndex]);
44+
}
3945
}
4046

4147
volume_.resize(ids_.size(),1.0);
@@ -62,11 +68,12 @@ bool centerPointsRegionPoints::update()
6268
const auto& idField = database().updateFieldUint32(idName_);
6369
selectedPoints_.fill(-1);
6470

65-
for(uint32 i = 0; i < idField.size(); ++i)
71+
for( uint32 j=0; j< ids_.size(); ++j)
6672
{
67-
for( uint32 j=0; j< ids_.size(); ++j)
73+
auto id = ids_[j];
74+
for( uint32 i=0; i< idField.size(); i++)
6875
{
69-
if(idField[i] == ids_[j])
76+
if(idField[i] == id)
7077
{
7178
selectedPoints_[j] = i;
7279
break;

0 commit comments

Comments
 (0)