mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
The main structure is tested. functons like execute and write are added and tested.
other components are left
This commit is contained in:
110
src/PostprocessData/region/regionFields/regionField.hpp
Normal file
110
src/PostprocessData/region/regionFields/regionField.hpp
Normal file
@ -0,0 +1,110 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __regionField_hpp__
|
||||
#define __regionField_hpp__
|
||||
|
||||
#include "types.hpp"
|
||||
#include "regionPoints.hpp"
|
||||
#include "Field.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
class regionField
|
||||
{
|
||||
private:
|
||||
|
||||
/// the field value
|
||||
Field<T, HostSpace> field_;
|
||||
|
||||
/// the region points
|
||||
const regionPoints& regionPoints_;
|
||||
public:
|
||||
|
||||
TypeInfoTemplateNV11("regionField", T);
|
||||
|
||||
regionField(
|
||||
const word& name,
|
||||
const regionPoints& rPoints,
|
||||
const T defaultVal);
|
||||
|
||||
regionField(const regionField&) = default;
|
||||
|
||||
regionField(regionField&&) = default;
|
||||
|
||||
regionField& operator=(const regionField&) = default;
|
||||
|
||||
regionField& operator=(regionField&&) = default;
|
||||
|
||||
~regionField() = default;
|
||||
|
||||
const regionPoints& regPoints() const
|
||||
{
|
||||
return regionPoints_;
|
||||
}
|
||||
|
||||
/// get the field value
|
||||
T& operator[] (const uint32 i)
|
||||
{
|
||||
return field_[i];
|
||||
}
|
||||
|
||||
/// get the field value
|
||||
const T& operator[] (const uint32 i)const
|
||||
{
|
||||
return field_[i];
|
||||
}
|
||||
|
||||
/// get field name
|
||||
word name()const
|
||||
{
|
||||
return field_.name();
|
||||
}
|
||||
|
||||
auto size()const
|
||||
{
|
||||
return field_.size();
|
||||
}
|
||||
|
||||
bool empty()const
|
||||
{
|
||||
return field_.empty();
|
||||
}
|
||||
|
||||
/// @brief write the field to a file
|
||||
/// @param os output file stream
|
||||
/// @return true if successful and false if fails
|
||||
bool writeFieldToFile(iOstream& os)const;
|
||||
|
||||
/// @brief write the field to vtk format (cell based)
|
||||
/// @param os output file stream
|
||||
/// @return true if successful and false if fails
|
||||
bool writeFieldToVtk(iOstream& os)const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace pFlow
|
||||
|
||||
#include "regionFieldTemplate.cpp"
|
||||
|
||||
#endif // __regionField_hpp__
|
@ -0,0 +1,10 @@
|
||||
|
||||
template<typename T>
|
||||
pFlow::regionField<T>::regionField(
|
||||
const word& name,
|
||||
const regionPoints& rPoints,
|
||||
const T defaultVal)
|
||||
:
|
||||
field_(name, "regionFieldValue", rPoints.size(), rPoints.size(), defaultVal),
|
||||
regionPoints_(rPoints)
|
||||
{}
|
@ -0,0 +1,95 @@
|
||||
#include "centerPointsRegionPoints.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
#include "Set.hpp"
|
||||
#include "pStructSelector.hpp"
|
||||
|
||||
bool pFlow::centerPointsRegionPoints::selectIds()
|
||||
{
|
||||
if(!firstTimeUpdate_) return true;
|
||||
firstTimeUpdate_ = false;
|
||||
|
||||
word selector = probDict_.getVal<word>("selector");
|
||||
|
||||
if(selector == "id")
|
||||
{
|
||||
auto idList = probDict_.getVal<uint32List>("ids");
|
||||
Set<uint32> uniqueIds;
|
||||
|
||||
uniqueIds.insert(idList.begin(), idList.end());
|
||||
|
||||
for(auto& id:uniqueIds)
|
||||
{
|
||||
ids_.push_back(id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto selectorPtr = pStructSelector::create(
|
||||
selector,
|
||||
database().pStruct(),
|
||||
probDict_);
|
||||
auto selectedPoints = selectorPtr->selectedPoints();
|
||||
ids_.resize(selectedPoints.size());
|
||||
ids_.assign(selectedPoints.begin(), selectedPoints.end());
|
||||
}
|
||||
|
||||
volume_.resize(ids_.size(),1.0);
|
||||
diameter_.resize(ids_.size(),1.0);
|
||||
center_.resize(ids_.size(), realx3(0,0,0));
|
||||
selectedPoints_.resize(ids_.size(), -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::centerPointsRegionPoints::centerPointsRegionPoints(
|
||||
const dictionary &dict,
|
||||
fieldsDataBase &fieldsDataBase)
|
||||
: regionPoints(dict, fieldsDataBase),
|
||||
idName_(dict.getValOrSet<word>("idName", "id")),
|
||||
probDict_(dict)
|
||||
{}
|
||||
|
||||
bool pFlow::centerPointsRegionPoints::update()
|
||||
{
|
||||
if(!selectIds()) return false;
|
||||
|
||||
if(ids_.empty()) return true;
|
||||
|
||||
const auto& idField = database().updateFieldUint32(idName_);
|
||||
selectedPoints_.fill(-1);
|
||||
|
||||
for(uint32 i = 0; i < idField.size(); ++i)
|
||||
{
|
||||
for( uint32 j=0; j< ids_.size(); ++j)
|
||||
{
|
||||
if(idField[i] == ids_[j])
|
||||
{
|
||||
selectedPoints_[j] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::centerPointsRegionPoints::write(iOstream &os) const
|
||||
{
|
||||
if(firstTimeUpdate_)
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<<"Write operation should be done before executing the update. \n";
|
||||
return false;
|
||||
}
|
||||
os <<"# Probing particles for selected ids\n";
|
||||
|
||||
os << "# SelectedId: ";
|
||||
|
||||
for(auto& id: ids_)
|
||||
{
|
||||
os << id << tab;
|
||||
}
|
||||
os << endl;
|
||||
os << "time"<<endl;
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __centerPointsRegionPoints_hpp__
|
||||
#define __centerPointsRegionPoints_hpp__
|
||||
|
||||
#include "regionPoints.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class centerPointsRegionPoints
|
||||
:
|
||||
public regionPoints
|
||||
{
|
||||
private:
|
||||
|
||||
bool firstTimeUpdate_ = true;
|
||||
|
||||
/// the ids provided in the dictionary
|
||||
uint32Vector ids_;
|
||||
|
||||
/// the volume of region
|
||||
realVector volume_ {"volume"};
|
||||
|
||||
realVector diameter_{"diameter"};
|
||||
/// center point of the region
|
||||
/// this is not used in the idSelection region
|
||||
realx3Vector center_ {"center"};
|
||||
|
||||
/// the point indices that are selected by this region
|
||||
uint32Vector selectedPoints_{"selectedPoints"};
|
||||
|
||||
/// the name of the id field
|
||||
word idName_= "id";
|
||||
|
||||
/// keeps the dictionary for first update use
|
||||
dictionary probDict_;
|
||||
|
||||
|
||||
bool selectIds();
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("centerPoints");
|
||||
|
||||
centerPointsRegionPoints(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);
|
||||
|
||||
~centerPointsRegionPoints() override = default;
|
||||
|
||||
uint32 size()const override
|
||||
{
|
||||
return selectedPoints_.size();
|
||||
}
|
||||
|
||||
bool empty()const override
|
||||
{
|
||||
return selectedPoints_.empty();
|
||||
}
|
||||
|
||||
span<const real> volumes()const override
|
||||
{
|
||||
return span<const real>(volume_.data(), volume_.size());
|
||||
}
|
||||
|
||||
span<const real> eqDiameters()const override
|
||||
{
|
||||
return span<const real>(diameter_.data(), diameter_.size());
|
||||
}
|
||||
|
||||
span<const realx3> centers()const override
|
||||
{
|
||||
return span<const realx3>(center_.data(), center_.size());
|
||||
}
|
||||
|
||||
span<const uint32> indices(uint32 elem)const override
|
||||
{
|
||||
return span<const uint32>(selectedPoints_.data(), selectedPoints_.size());
|
||||
}
|
||||
|
||||
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
|
||||
bool update() override;
|
||||
|
||||
bool writeToSameTimeFile()const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write(iOstream& os)const override;
|
||||
|
||||
}; // class centerPointsRegionPoints
|
||||
|
||||
} // namespace pFlow
|
||||
|
||||
|
||||
|
||||
#endif // __centerPointsRegionPoints_hpp__
|
@ -0,0 +1,100 @@
|
||||
#include "lineRegionPoints.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
|
||||
pFlow::lineRegionPoints::lineRegionPoints
|
||||
(
|
||||
const dictionary &dict,
|
||||
fieldsDataBase &fieldsDataBase
|
||||
)
|
||||
:
|
||||
regionPoints(dict, fieldsDataBase),
|
||||
line_(dict.subDict("lineInfo")),
|
||||
centerPoints_("centerPoints"),
|
||||
volumes_("volumes"),
|
||||
selectedPoints_("selectedPoints")
|
||||
{
|
||||
const auto& lDict = dict.subDict("lineInfo");
|
||||
uint32 nPoints = lDict.getValMax<uint32>("numPoints",2);
|
||||
realList raddi;
|
||||
|
||||
if( lDict.containsDataEntry("radii"))
|
||||
{
|
||||
raddi = lDict.getVal<realList>("radii");
|
||||
}
|
||||
else
|
||||
{
|
||||
auto r = lDict.getVal<real>("radius");
|
||||
raddi = realList(nPoints, r);
|
||||
}
|
||||
|
||||
if(raddi.size() != nPoints)
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<< "The number elements in of radii list should be equal to the number of points"<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
sphereRegions_.resize(nPoints, sphere(realx3(0,0,0),1));
|
||||
centerPoints_.resize(nPoints);
|
||||
volumes_.resize(nPoints);
|
||||
selectedPoints_.resize(nPoints);
|
||||
real dt = 1.0/(nPoints-1);
|
||||
for(uint32 i = 0; i < nPoints; ++i)
|
||||
{
|
||||
centerPoints_[i] = line_.point(i*dt);
|
||||
sphereRegions_[i] = pFlow::sphere(centerPoints_[i], raddi[i]);
|
||||
volumes_[i] = sphereRegions_[i].volume();
|
||||
diameters_[i] = 2*sphereRegions_[i].radius();
|
||||
}
|
||||
}
|
||||
|
||||
pFlow::span<const pFlow::uint32> pFlow::lineRegionPoints::indices(uint32 elem) const
|
||||
{
|
||||
if(elem>=size())
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<< "The element index is out of range. elem: " << elem
|
||||
<< " size: " << size() << endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
return span<const uint32>(selectedPoints_[elem].data(), selectedPoints_[elem].size());
|
||||
}
|
||||
|
||||
bool pFlow::lineRegionPoints::update()
|
||||
{
|
||||
const auto points = database().updatePoints();
|
||||
for(auto& elem:selectedPoints_)
|
||||
{
|
||||
elem.clear();
|
||||
}
|
||||
|
||||
for(uint32 i = 0; i < points.size(); ++i)
|
||||
{
|
||||
for(uint32 j = 0; j < sphereRegions_.size(); ++j)
|
||||
{
|
||||
if( sphereRegions_[j].isInside(points[i]))
|
||||
{
|
||||
selectedPoints_[j].push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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 <<"# "<<i<<tab<<sphereRegions_[i].center() << tab <<diameters_[i] << '\n';
|
||||
}
|
||||
os<<"time/No. ";
|
||||
for(uint32 i=0; i< sphereRegions_.size(); ++i)
|
||||
{
|
||||
os <<i<<tab;
|
||||
}
|
||||
os <<endl;
|
||||
return true;
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __lineRegionPoints_hpp__
|
||||
#define __lineRegionPoints_hpp__
|
||||
|
||||
#include "regionPoints.hpp"
|
||||
#include "line.hpp"
|
||||
#include "sphere.hpp"
|
||||
#include "Vectors.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class lineRegionPoints
|
||||
:
|
||||
public regionPoints
|
||||
{
|
||||
private:
|
||||
|
||||
/// line region for selecting points
|
||||
line line_;
|
||||
|
||||
/// all sphere regions
|
||||
Vector<sphere> sphereRegions_;
|
||||
|
||||
/// center poitns of regions/elements
|
||||
realx3Vector centerPoints_;
|
||||
|
||||
/// volumes of all elements/regions
|
||||
realVector volumes_;
|
||||
|
||||
realVector diameters_;
|
||||
|
||||
/// the point indices that are selected by this region
|
||||
Vector<uint32Vector> selectedPoints_;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo(line::TYPENAME());
|
||||
|
||||
lineRegionPoints(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);
|
||||
|
||||
~lineRegionPoints() override = default;
|
||||
|
||||
uint32 size()const override
|
||||
{
|
||||
return sphereRegions_.size();
|
||||
}
|
||||
|
||||
bool empty()const override
|
||||
{
|
||||
return sphereRegions_.empty();
|
||||
}
|
||||
|
||||
span<const real> volumes()const override
|
||||
{
|
||||
return span<const real>(volumes_.data(), volumes_.size());
|
||||
}
|
||||
|
||||
span<const real> eqDiameters()const override
|
||||
{
|
||||
return span<const real>(diameters_.data(), diameters_.size());
|
||||
}
|
||||
|
||||
span<const realx3> centers()const override
|
||||
{
|
||||
return span<const realx3>(centerPoints_.data(), centerPoints_.size());
|
||||
}
|
||||
|
||||
span<const uint32> indices(uint32 elem)const override;
|
||||
|
||||
|
||||
bool update() override;
|
||||
|
||||
bool writeToSameTimeFile()const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write(iOstream& os) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // __lineRegionPoints_hpp__
|
@ -0,0 +1,28 @@
|
||||
#include "regionPoints.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
#include "Time.hpp"
|
||||
|
||||
pFlow::regionPoints::regionPoints
|
||||
(
|
||||
const dictionary &dict,
|
||||
fieldsDataBase &fieldsDataBase
|
||||
)
|
||||
:
|
||||
fieldsDataBase_(fieldsDataBase)
|
||||
{}
|
||||
|
||||
const pFlow::Time& pFlow::regionPoints::time() const
|
||||
{
|
||||
return fieldsDataBase_.time();
|
||||
}
|
||||
|
||||
const pFlow::fieldsDataBase & pFlow::regionPoints::database() const
|
||||
{
|
||||
return fieldsDataBase_;
|
||||
}
|
||||
|
||||
pFlow::fieldsDataBase& pFlow::regionPoints::database()
|
||||
{
|
||||
return fieldsDataBase_;
|
||||
}
|
||||
|
@ -0,0 +1,107 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __regionPoints_hpp__
|
||||
#define __regionPoints_hpp__
|
||||
|
||||
#include "iOstream.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "pointStructure.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class fieldsDataBase;
|
||||
class Time;
|
||||
|
||||
class regionPoints
|
||||
{
|
||||
using PointsTypeHost = typename pointStructure::PointsTypeHost;
|
||||
|
||||
fieldsDataBase& fieldsDataBase_;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("regionPoints");
|
||||
|
||||
|
||||
regionPoints(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);
|
||||
|
||||
virtual ~regionPoints() = default;
|
||||
|
||||
const Time& time()const;
|
||||
|
||||
const fieldsDataBase& database()const;
|
||||
|
||||
fieldsDataBase& database();
|
||||
|
||||
/// @brief size of elements
|
||||
virtual
|
||||
uint32 size()const = 0;
|
||||
|
||||
/// @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;*/
|
||||
|
||||
|
||||
/// @brief volume of elements
|
||||
/// @return sapn for accessing the volume of elements
|
||||
virtual
|
||||
span<const real> volumes()const =0;
|
||||
|
||||
virtual
|
||||
span<const real> eqDiameters()const = 0;
|
||||
|
||||
/// center points of elements
|
||||
virtual
|
||||
span<const realx3> centers()const = 0;
|
||||
|
||||
/// indices of particles inside the element @var elem
|
||||
virtual
|
||||
span<const uint32> indices(uint32 elem)const = 0;
|
||||
|
||||
virtual
|
||||
span<uint32> indices(uint32 elem) = 0;
|
||||
|
||||
virtual
|
||||
bool update() = 0;
|
||||
|
||||
virtual
|
||||
bool writeToSameTimeFile()const = 0;
|
||||
|
||||
virtual
|
||||
bool write(iOstream& os)const=0;
|
||||
|
||||
/*static
|
||||
uniquePtr<regionPoints> create(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);*/
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __regionPoints_hpp__
|
@ -0,0 +1,41 @@
|
||||
#include "sphereRegionPoints.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
|
||||
pFlow::sphereRegionPoints::sphereRegionPoints
|
||||
(
|
||||
const dictionary &dict,
|
||||
fieldsDataBase &fieldsDataBase
|
||||
)
|
||||
:
|
||||
regionPoints(dict, fieldsDataBase),
|
||||
sphereRegion_(dict.subDict("sphereInfo")),
|
||||
volume_(sphereRegion_.volume()),
|
||||
diameter_(2*sphereRegion_.radius()),
|
||||
selectedPoints_("selectedPoints")
|
||||
{
|
||||
}
|
||||
|
||||
bool pFlow::sphereRegionPoints::update()
|
||||
{
|
||||
const auto points = database().updatePoints();
|
||||
selectedPoints_.clear();
|
||||
for(uint32 i = 0; i < points.size(); ++i)
|
||||
{
|
||||
if( sphereRegion_.isInside(points[i]))
|
||||
{
|
||||
selectedPoints_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::sphereRegionPoints::write(iOstream &os) const
|
||||
{
|
||||
os <<"# Single sphere\n";
|
||||
os <<"# center point: "<<sphereRegion_.center()<<endl;
|
||||
os <<"# diameter: "<< diameter_ << endl;
|
||||
os <<"time"<< tab <<"value"<<endl;
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __sphereRegionPoints_hpp__
|
||||
#define __sphereRegionPoints_hpp__
|
||||
|
||||
#include "regionPoints.hpp"
|
||||
#include "sphere.hpp"
|
||||
#include "Vectors.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
class sphereRegionPoints
|
||||
:
|
||||
public regionPoints
|
||||
{
|
||||
private:
|
||||
|
||||
/// spehre region for selecting points
|
||||
sphere sphereRegion_;
|
||||
|
||||
/// the volume of region
|
||||
real volume_;
|
||||
|
||||
real diameter_;
|
||||
|
||||
/// the point indices that are selected by this region
|
||||
uint32Vector selectedPoints_;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo(sphere::TYPENAME());
|
||||
|
||||
sphereRegionPoints(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldsDataBase);
|
||||
|
||||
~sphereRegionPoints() override = default;
|
||||
|
||||
uint32 size()const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool empty()const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
span<const real> volumes()const override
|
||||
{
|
||||
return span<const real>(&volume_, 1);
|
||||
}
|
||||
|
||||
span<const real> eqDiameters()const override
|
||||
{
|
||||
return span<const real>(&diameter_, 1);
|
||||
}
|
||||
|
||||
span<const realx3> centers()const override
|
||||
{
|
||||
return span<const realx3>(&sphereRegion_.center(), 1);
|
||||
}
|
||||
|
||||
span<const uint32> indices(uint32 elem)const override
|
||||
{
|
||||
return span<const uint32>(selectedPoints_.data(), selectedPoints_.size());
|
||||
}
|
||||
|
||||
span<uint32> indices(uint32 elem) override
|
||||
{
|
||||
return span<uint32>(selectedPoints_.data(), selectedPoints_.size());
|
||||
}
|
||||
|
||||
bool update()override;
|
||||
|
||||
bool writeToSameTimeFile()const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write(iOstream& os)const override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __sphereRegionPoints_hpp__
|
Reference in New Issue
Block a user