add box region
This commit is contained in:
parent
90a8fff673
commit
51c6f925d8
|
@ -9,6 +9,7 @@ set(SourceFiles
|
|||
# Regions
|
||||
region/regionPoints/regionPoints/regionPoints.cpp
|
||||
region/regionPoints/sphereRegionPoints/sphereRegionPoints.cpp
|
||||
region/regionPoints/boxRegionPoints/boxRegionPoints.cpp
|
||||
region/regionPoints/lineRegionPoints/lineRegionPoints.cpp
|
||||
region/regionPoints/centerPointsRegionPoints/centerPointsRegionPoints.cpp
|
||||
region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.cpp
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
#include "boxRegionPoints.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
#include "numericConstants.hpp"
|
||||
|
||||
namespace pFlow::postprocessData
|
||||
{
|
||||
|
||||
boxRegionPoints::boxRegionPoints
|
||||
(
|
||||
const dictionary &dict,
|
||||
fieldsDataBase &fieldsDataBase
|
||||
)
|
||||
:
|
||||
regionPoints(dict, fieldsDataBase),
|
||||
boxRegion_(dict.subDict("boxInfo")),
|
||||
volume_((boxRegion_.maxPoint().x() - boxRegion_.minPoint().x()) * (boxRegion_.maxPoint().y() - boxRegion_.minPoint().y()) * (boxRegion_.maxPoint().z() - boxRegion_.minPoint().z())),
|
||||
diameter_(pow(3 * volume_ / 4.0 / Pi, 1.0 / 3.0)),
|
||||
selectedPoints_("selectedPoints")
|
||||
{
|
||||
}
|
||||
|
||||
bool boxRegionPoints::update()
|
||||
{
|
||||
const auto points = database().updatePoints();
|
||||
selectedPoints_.clear();
|
||||
for(uint32 i = 0; i < points.size(); ++i)
|
||||
{
|
||||
if( boxRegion_.isInside(points[i]))
|
||||
{
|
||||
selectedPoints_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool boxRegionPoints::write(iOstream &os) const
|
||||
{
|
||||
os <<"# Single box\n";
|
||||
os <<"# min point: "<< boxRegion_.minPoint() <<endl;
|
||||
os <<"# max point: "<< boxRegion_.maxPoint() << endl;
|
||||
os <<"time"<< tab <<"value"<<endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End namespace pFlow::postprocessData
|
|
@ -0,0 +1,171 @@
|
|||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
O O M ultiscale modeling of
|
||||
OOOOOOO F luid flow
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C): www.cemf.ir
|
||||
email: hamid.r.norouzi AT gmail.com
|
||||
------------------------------------------------------------------------------
|
||||
Licence:
|
||||
This file is part of phasicFlow code. It is a free software for simulating
|
||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||
the terms of GNU General Public License v3 or any other later versions.
|
||||
|
||||
phasicFlow is distributed to help others in their research in the field of
|
||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @file boxRegionPoints.hpp
|
||||
* @brief A class representing a box region for point selection
|
||||
*
|
||||
* This class provides functionality to select points within a box 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 box
|
||||
* @see fieldsDataBase
|
||||
*/
|
||||
|
||||
#ifndef __boxRegionPoints_hpp__
|
||||
#define __boxRegionPoints_hpp__
|
||||
|
||||
#include "regionPoints.hpp"
|
||||
#include "box.hpp"
|
||||
#include "Vectors.hpp"
|
||||
|
||||
namespace pFlow::postprocessData
|
||||
{
|
||||
|
||||
class boxRegionPoints
|
||||
:
|
||||
public regionPoints
|
||||
{
|
||||
private:
|
||||
|
||||
/// box object defining the region for point selection
|
||||
box boxRegion_;
|
||||
|
||||
/// Volume of the box region
|
||||
real volume_;
|
||||
|
||||
/// Diameter of the box region
|
||||
real diameter_;
|
||||
|
||||
/// Indices of points that are selected by this region
|
||||
uint32Vector selectedPoints_;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo(box::TYPENAME());
|
||||
|
||||
/**
|
||||
* @brief Construct a box region for point selection
|
||||
*
|
||||
* @param dict Dictionary containing boxInfo dictionary
|
||||
* @param fieldsDataBase Database containing fields data
|
||||
*/
|
||||
boxRegionPoints(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);
|
||||
|
||||
/// Destructor
|
||||
~boxRegionPoints() override = default;
|
||||
|
||||
/**
|
||||
* @brief Get the number of regions (always 1 for box)
|
||||
* @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 box 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 box 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 box region
|
||||
* @return A span containing the center point of the region
|
||||
*/
|
||||
span<const realx3> centers()const override
|
||||
{
|
||||
realx3 center = 0.5 * (boxRegion_.minPoint() + boxRegion_.maxPoint());
|
||||
return span<const realx3>(¢er, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the indices of points within the region (const version)
|
||||
* @param elem Element index (ignored as there's only one box)
|
||||
* @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 box)
|
||||
* @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;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __boxRegionPoints_hpp__
|
Loading…
Reference in New Issue