mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
Postprocess framework
- Executed has been completed and testd. - regions multipleSpheres are compelete - Docs for regions is comelete.
This commit is contained in:
@ -31,6 +31,22 @@ namespace pFlow
|
||||
template<typename T>
|
||||
class regionField
|
||||
{
|
||||
public:
|
||||
using FieldType = Field<T, HostSpace>;
|
||||
|
||||
using iterator = typename FieldType::iterator;
|
||||
|
||||
using const_iterator = typename FieldType::const_iterator;
|
||||
|
||||
using reference = typename FieldType::reference;
|
||||
|
||||
using const_reference = typename FieldType::const_reference;
|
||||
|
||||
using value_type = typename FieldType::value_type;
|
||||
|
||||
using pointer = typename FieldType::pointer;
|
||||
|
||||
using const_pointer = typename FieldType::const_pointer;
|
||||
private:
|
||||
|
||||
/// the field value
|
||||
|
@ -26,6 +26,34 @@ Licence:
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
/**
|
||||
* @class centerPointsRegionPoints
|
||||
* @brief A region points implementation that selects particles based on their IDs
|
||||
*
|
||||
* This class is responsible for selecting points (particles) by their IDs from
|
||||
* a simulation database and tracking their properties. It maintains information
|
||||
* about the selected particles including their positions, volumes, and diameters.
|
||||
*
|
||||
* The selection is performed based on IDs provided in the input dictionary.
|
||||
* Once selected, the particles' properties can be accessed through various
|
||||
* methods. The update method allows refreshing the selection when particle data
|
||||
* changes. The selection occurs at startTime defined in the time control, and
|
||||
* there are some methods for selecting ids:
|
||||
* - specifying ids
|
||||
* - using selectors specified in pStructSelector class, which includes:
|
||||
* - box: selects particles within a box region
|
||||
* - sphere: selects particles within a spherical region
|
||||
* - cylinder: selects particles within a cylindrical region
|
||||
* - random: randomly selects a specified number of particles
|
||||
* - strided: selects particles with a specified stride pattern
|
||||
*
|
||||
* This class is useful for tracking specific particles of interest throughout
|
||||
* a simulation and analyzing their behavior.
|
||||
*
|
||||
* @see regionPoints Base class providing the interface for different region
|
||||
* point selections
|
||||
* @see pStructSelector Class providing different particle selection methods
|
||||
*/
|
||||
class centerPointsRegionPoints
|
||||
:
|
||||
public regionPoints
|
||||
@ -59,6 +87,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
/// Type info
|
||||
TypeInfo("centerPoints");
|
||||
|
||||
centerPointsRegionPoints(
|
||||
@ -67,50 +96,69 @@ public:
|
||||
|
||||
~centerPointsRegionPoints() override = default;
|
||||
|
||||
/// @brief Returns the number of selected points/particles
|
||||
/// @return Number of selected points/particles
|
||||
uint32 size()const override
|
||||
{
|
||||
return selectedPoints_.size();
|
||||
}
|
||||
|
||||
/// @brief Checks if there are no selected points
|
||||
/// @return True if no points are selected, false otherwise
|
||||
bool empty()const override
|
||||
{
|
||||
return selectedPoints_.empty();
|
||||
}
|
||||
|
||||
/// @brief Returns the volumes of the selected points (this is normally not used)
|
||||
span<const real> volumes()const override
|
||||
{
|
||||
return span<const real>(volume_.data(), volume_.size());
|
||||
}
|
||||
|
||||
span<const real> eqDiameters()const override
|
||||
/// @brief Returns the equivalent diameters of the regions (this is normally not used )
|
||||
span<const real> eqDiameters()const override
|
||||
{
|
||||
return span<const real>(diameter_.data(), diameter_.size());
|
||||
}
|
||||
|
||||
/// @brief Returns the center positions of the selected points
|
||||
/// @return Span containing the center positions of all selected points
|
||||
span<const realx3> centers()const override
|
||||
{
|
||||
return span<const realx3>(center_.data(), center_.size());
|
||||
}
|
||||
|
||||
/// @brief Returns the indices of the selected points (const version)
|
||||
/// @param elem Element index (not used in this implementation)
|
||||
/// @return Span containing the indices of all selected points
|
||||
span<const uint32> indices(uint32 elem)const override
|
||||
{
|
||||
return span<const uint32>(selectedPoints_.data(), selectedPoints_.size());
|
||||
}
|
||||
|
||||
/// @brief Returns the indices of the selected points (non-const version)
|
||||
/// @param elem Element index (not used in this implementation)
|
||||
/// @return Span containing the indices of all selected points
|
||||
span<uint32> indices(uint32 elem) override
|
||||
{
|
||||
return span<uint32>(selectedPoints_.data(), selectedPoints_.size());
|
||||
}
|
||||
|
||||
/// @brief update the selected points based on the ids
|
||||
/// @return true if the operation is successful
|
||||
/// @brief Updates the selected points based on the particle IDs
|
||||
/// @return True if the operation is successful, false otherwise
|
||||
bool update() override;
|
||||
|
||||
/// @brief Checks if the data should be written to the same time file
|
||||
/// @return True if data should be written to the same time file, false otherwise
|
||||
bool writeToSameTimeFile()const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @brief Writes the data to the output stream
|
||||
/// @param os Output stream
|
||||
/// @return True if the operation is successful, false otherwise
|
||||
bool write(iOstream& os)const override;
|
||||
|
||||
}; // class centerPointsRegionPoints
|
||||
|
@ -30,7 +30,8 @@ pFlow::lineRegionPoints::lineRegionPoints
|
||||
if(raddi.size() != nPoints)
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<< "The number elements in of radii list should be equal to the number of points"<<endl;
|
||||
<< "The number elements in of radii list should be equal to the "
|
||||
<< "number of points"<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
@ -50,7 +51,7 @@ pFlow::lineRegionPoints::lineRegionPoints
|
||||
|
||||
pFlow::span<const pFlow::uint32> pFlow::lineRegionPoints::indices(uint32 elem) const
|
||||
{
|
||||
if(elem>=size())
|
||||
if(elem >= size())
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<< "The element index is out of range. elem: " << elem
|
||||
@ -58,13 +59,15 @@ pFlow::span<const pFlow::uint32> pFlow::lineRegionPoints::indices(uint32 elem) c
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
return span<const uint32>(selectedPoints_[elem].data(), selectedPoints_[elem].size());
|
||||
return span<const uint32>(
|
||||
selectedPoints_[elem].data(),
|
||||
selectedPoints_[elem].size());
|
||||
}
|
||||
|
||||
bool pFlow::lineRegionPoints::update()
|
||||
{
|
||||
const auto points = database().updatePoints();
|
||||
for(auto& elem:selectedPoints_)
|
||||
for(auto& elem : selectedPoints_)
|
||||
{
|
||||
elem.clear();
|
||||
}
|
||||
@ -84,17 +87,18 @@ bool pFlow::lineRegionPoints::update()
|
||||
|
||||
bool pFlow::lineRegionPoints::write(iOstream &os) const
|
||||
{
|
||||
os <<"# Spheres along a straight line \n";
|
||||
os <<"# No."<<tab <<"centerPoint" << tab <<"diameter"<<endl;
|
||||
for(uint32 i=0; i< sphereRegions_.size(); ++i)
|
||||
os << "# Spheres along a straight line \n";
|
||||
os << "# No." << tab << "centerPoint" << tab << "diameter" << endl;
|
||||
for(uint32 i=0; i < sphereRegions_.size(); ++i)
|
||||
{
|
||||
os <<"# "<<i<<tab<<sphereRegions_[i].center() << tab <<diameters_[i] << '\n';
|
||||
os << "# " << i << tab << sphereRegions_[i].center()
|
||||
<< tab << diameters_[i] << '\n';
|
||||
}
|
||||
os<<"time/No. ";
|
||||
for(uint32 i=0; i< sphereRegions_.size(); ++i)
|
||||
os << "time/No. ";
|
||||
for(uint32 i=0; i < sphereRegions_.size(); ++i)
|
||||
{
|
||||
os <<i<<tab;
|
||||
os << i << tab;
|
||||
}
|
||||
os <<endl;
|
||||
os << endl;
|
||||
return true;
|
||||
}
|
||||
|
@ -18,14 +18,42 @@ Licence:
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @class lineRegionPoints
|
||||
* @brief Spherical regions along a line for selecting points/particles
|
||||
*
|
||||
* The lineRegionPoints class is responsible for selecting points/particles along a
|
||||
* specified line and creating sphere regions around those points. It partitions
|
||||
* the line into multiple sphere regions (equally spaced) and keeps track of
|
||||
* which points/particles in the simulation fall into each region.
|
||||
*
|
||||
* This class is used for post-processing data by analyzing distributions of
|
||||
* particles along a linear path through the simulation domain. It maintains:
|
||||
* - A line defining the sampling path
|
||||
* - Spherical regions along this line that include particles
|
||||
* - Center points for each region
|
||||
* - Volumes and diameters of regions
|
||||
* - Indices of points/particles contained in each region
|
||||
*
|
||||
* The regions can be updated as the simulation progresses, and the data
|
||||
* can be written to output for analysis.
|
||||
*
|
||||
* @see regionPoints
|
||||
* @see line
|
||||
* @see sphere
|
||||
* @see fieldsDataBase
|
||||
*/
|
||||
|
||||
#ifndef __lineRegionPoints_hpp__
|
||||
#define __lineRegionPoints_hpp__
|
||||
|
||||
|
||||
#include "regionPoints.hpp"
|
||||
#include "line.hpp"
|
||||
#include "sphere.hpp"
|
||||
#include "Vectors.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
@ -35,68 +63,80 @@ class lineRegionPoints
|
||||
{
|
||||
private:
|
||||
|
||||
/// line region for selecting points
|
||||
/// Line path defining the axis of the spherical regions
|
||||
line line_;
|
||||
|
||||
/// all sphere regions
|
||||
/// Collection of sphere regions along the line
|
||||
Vector<sphere> sphereRegions_;
|
||||
|
||||
/// center poitns of regions/elements
|
||||
/// Center points of all spherical regions
|
||||
realx3Vector centerPoints_;
|
||||
|
||||
/// volumes of all elements/regions
|
||||
/// Volumes of all spherical regions
|
||||
realVector volumes_;
|
||||
|
||||
/// Diameters of all spherical regions
|
||||
realVector diameters_;
|
||||
|
||||
/// the point indices that are selected by this region
|
||||
/// Point/particles indices selected by each region
|
||||
Vector<uint32Vector> selectedPoints_;
|
||||
|
||||
public:
|
||||
|
||||
/// Type information for runtime type identification
|
||||
TypeInfo(line::TYPENAME());
|
||||
|
||||
/// Construct from dictionary that contains lineInfo and fields database
|
||||
lineRegionPoints(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);
|
||||
|
||||
/// Default destructor
|
||||
~lineRegionPoints() override = default;
|
||||
|
||||
/// Return number of regions
|
||||
uint32 size()const override
|
||||
{
|
||||
return sphereRegions_.size();
|
||||
}
|
||||
|
||||
/// Check if regions list is empty
|
||||
bool empty()const override
|
||||
{
|
||||
return sphereRegions_.empty();
|
||||
}
|
||||
|
||||
/// Return volumes of all regions
|
||||
span<const real> volumes()const override
|
||||
{
|
||||
return span<const real>(volumes_.data(), volumes_.size());
|
||||
}
|
||||
|
||||
/// Return equivalent diameters of all regions
|
||||
span<const real> eqDiameters()const override
|
||||
{
|
||||
return span<const real>(diameters_.data(), diameters_.size());
|
||||
}
|
||||
|
||||
/// Return center points of all regions
|
||||
span<const realx3> centers()const override
|
||||
{
|
||||
return span<const realx3>(centerPoints_.data(), centerPoints_.size());
|
||||
}
|
||||
|
||||
/// Return indices of points in the specified element/region
|
||||
span<const uint32> indices(uint32 elem)const override;
|
||||
|
||||
|
||||
/// Update regions based on current particle positions
|
||||
bool update() override;
|
||||
|
||||
/// Whether to write all data to the same time file
|
||||
bool writeToSameTimeFile()const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Write data to output stream
|
||||
bool write(iOstream& os) const override;
|
||||
};
|
||||
|
||||
|
@ -32,27 +32,43 @@ namespace pFlow
|
||||
class fieldsDataBase;
|
||||
class Time;
|
||||
|
||||
/**
|
||||
* @class regionPoints
|
||||
* @brief Abstract base class for managing and processing volumetric regions
|
||||
* in the simulation. Particles are selected based on their positions within
|
||||
* these defined regions.
|
||||
*
|
||||
* This class provides an interface for accessing and manipulating data
|
||||
* related to regions of points (particles), including their volumes, equivalent
|
||||
* diameters, center points, and particle indices that they contain. It interacts with the
|
||||
* fieldsDataBase and Time classes to retrieve simulation data.
|
||||
*/
|
||||
class regionPoints
|
||||
{
|
||||
using PointsTypeHost = typename pointStructure::PointsTypeHost;
|
||||
using PointsTypeHost = typename pointStructure::PointsTypeHost;
|
||||
|
||||
/// Reference to the fields database containing simulation data
|
||||
fieldsDataBase& fieldsDataBase_;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("regionPoints");
|
||||
|
||||
|
||||
/// Constructor with dictionary and fields database reference
|
||||
regionPoints(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);
|
||||
|
||||
/// Default virtual destructor
|
||||
virtual ~regionPoints() = default;
|
||||
|
||||
/// Returns reference to the time object from the database
|
||||
const Time& time()const;
|
||||
|
||||
/// Returns const reference to the fields database
|
||||
const fieldsDataBase& database()const;
|
||||
|
||||
/// Returns non-const reference to the fields database
|
||||
fieldsDataBase& database();
|
||||
|
||||
/// @brief size of elements
|
||||
@ -61,11 +77,7 @@ public:
|
||||
|
||||
/// @brief check if the region is empty
|
||||
virtual
|
||||
bool empty()const = 0;
|
||||
|
||||
/*/// @brief return the type of the region
|
||||
virtual const word& type()const = 0;*/
|
||||
|
||||
bool empty()const = 0;
|
||||
|
||||
/// @brief volume of elements
|
||||
/// @return sapn for accessing the volume of elements
|
||||
@ -75,30 +87,29 @@ public:
|
||||
virtual
|
||||
span<const real> eqDiameters()const = 0;
|
||||
|
||||
/// center points of elements
|
||||
/// center points of elements
|
||||
virtual
|
||||
span<const realx3> centers()const = 0;
|
||||
|
||||
/// indices of particles inside the element @var elem
|
||||
/// Returns const span of particle indices inside the specified element region
|
||||
virtual
|
||||
span<const uint32> indices(uint32 elem)const = 0;
|
||||
|
||||
/// Returns non-const span of particle indices inside the specified element region
|
||||
virtual
|
||||
span<uint32> indices(uint32 elem) = 0;
|
||||
|
||||
/// Updates the points (particles) inside regions based on current particle positions
|
||||
virtual
|
||||
bool update() = 0;
|
||||
|
||||
/// Returns true if the region should be written to the same time file
|
||||
virtual
|
||||
bool writeToSameTimeFile()const = 0;
|
||||
|
||||
/// Writes region data to the output stream
|
||||
virtual
|
||||
bool write(iOstream& os)const=0;
|
||||
|
||||
/*static
|
||||
uniquePtr<regionPoints> create(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);*/
|
||||
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,19 @@ Licence:
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @file sphereRegionPoints.hpp
|
||||
* @brief A class representing a spherical region for point selection
|
||||
*
|
||||
* This class provides functionality to select points within a spherical region
|
||||
* and to compute related properties such as volume and equivalent diameter.
|
||||
* It inherits from regionPoints and implements all required virtual methods.
|
||||
*
|
||||
* @see regionPoints
|
||||
* @see sphere
|
||||
* @see fieldsDataBase
|
||||
*/
|
||||
|
||||
#ifndef __sphereRegionPoints_hpp__
|
||||
#define __sphereRegionPoints_hpp__
|
||||
|
||||
@ -27,75 +40,127 @@ Licence:
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class sphereRegionPoints
|
||||
:
|
||||
public regionPoints
|
||||
{
|
||||
private:
|
||||
|
||||
/// spehre region for selecting points
|
||||
/// Sphere object defining the region for point selection
|
||||
sphere sphereRegion_;
|
||||
|
||||
/// the volume of region
|
||||
/// Volume of the spherical region
|
||||
real volume_;
|
||||
|
||||
/// Diameter of the spherical region
|
||||
real diameter_;
|
||||
|
||||
/// the point indices that are selected by this region
|
||||
/// Indices of points that are selected by this region
|
||||
uint32Vector selectedPoints_;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo(sphere::TYPENAME());
|
||||
|
||||
/**
|
||||
* @brief Construct a spherical region for point selection
|
||||
*
|
||||
* @param dict Dictionary containing sphereInfo dictionary
|
||||
* @param fieldsDataBase Database containing fields data
|
||||
*/
|
||||
sphereRegionPoints(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);
|
||||
|
||||
/// Destructor
|
||||
~sphereRegionPoints() override = default;
|
||||
|
||||
/**
|
||||
* @brief Get the number of regions (always 1 for sphere)
|
||||
* @return Always returns 1
|
||||
*/
|
||||
uint32 size()const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the region is empty
|
||||
* @return Always returns false
|
||||
*/
|
||||
bool empty()const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the volume of the spherical region
|
||||
* @return A span containing the volume of the region
|
||||
*/
|
||||
span<const real> volumes()const override
|
||||
{
|
||||
return span<const real>(&volume_, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the equivalent diameter of the spherical region
|
||||
* @return A span containing the diameter of the region
|
||||
*/
|
||||
span<const real> eqDiameters()const override
|
||||
{
|
||||
return span<const real>(&diameter_, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the center of the spherical region
|
||||
* @return A span containing the center point of the region
|
||||
*/
|
||||
span<const realx3> centers()const override
|
||||
{
|
||||
return span<const realx3>(&sphereRegion_.center(), 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the indices of points within the region (const version)
|
||||
* @param elem Element index (ignored as there's only one sphere)
|
||||
* @return A span containing indices of points within the region
|
||||
*/
|
||||
span<const uint32> indices(uint32 elem)const override
|
||||
{
|
||||
return span<const uint32>(selectedPoints_.data(), selectedPoints_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the indices of points within the region (non-const version)
|
||||
* @param elem Element index (ignored as there's only one sphere)
|
||||
* @return A span containing indices of points within the region
|
||||
*/
|
||||
span<uint32> indices(uint32 elem) override
|
||||
{
|
||||
return span<uint32>(selectedPoints_.data(), selectedPoints_.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update the points selected by this region
|
||||
* @return True if update was successful
|
||||
*/
|
||||
bool update()override;
|
||||
|
||||
/**
|
||||
* @brief Determine if data should be written to the same time file
|
||||
* @return Always returns true
|
||||
*/
|
||||
bool writeToSameTimeFile()const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write region data to output stream
|
||||
* @param os Output stream to write to
|
||||
* @return True if write was successful
|
||||
*/
|
||||
bool write(iOstream& os)const override;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user