mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-28 03:27:05 +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:
@ -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__
|
Reference in New Issue
Block a user