Merge pull request #102 from PhasicFlow/develop
pointStruture selectors refactored
This commit is contained in:
commit
edcf2907e6
|
@ -90,9 +90,10 @@ structuredData/boundaries/boundaryReflective/boundaryReflective.cpp
|
|||
structuredData/boundaries/boundaryList.cpp
|
||||
structuredData/pointStructure/pointStructure/pointStructure.cpp
|
||||
structuredData/pointStructure/selectors/pStructSelector/pStructSelector.cpp
|
||||
structuredData/pointStructure/selectors/selectRange/selectRange.cpp
|
||||
structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp
|
||||
structuredData/pointStructure/selectors/selectorStridedRange/selectorStridedRange.cpp
|
||||
structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.cpp
|
||||
structuredData/pointStructure/selectors/selectBox/selectBox.cpp
|
||||
structuredData/pointStructure/selectors/selectorGeometric/selectorGeometrics.cpp
|
||||
|
||||
triSurface/subSurface.cpp
|
||||
triSurface/triSurface.cpp
|
||||
|
|
|
@ -458,9 +458,6 @@ bool pFlow::internalPoints::read
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool pFlow::internalPoints::write
|
||||
(
|
||||
iOstream& os,
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
#ifndef __fieldSelector_hpp__
|
||||
#define __fieldSelector_hpp__
|
||||
|
||||
#include "pStructSelector.hpp"
|
||||
#include "pointFields.hpp"
|
||||
#include "Time.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
inline
|
||||
Vector<T> selectedFieldVals(const pStructSelector& selector, const word& name)
|
||||
{
|
||||
using FieldType = pointField_D<T>;
|
||||
|
||||
if(selector.selectedPoints().empty() )
|
||||
{
|
||||
return Vector<T>("selected-"+name);
|
||||
}
|
||||
|
||||
if(!selector.pStruct().time().lookupObjectName(name))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Field "<< name << " does not exist in time repository"<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if(
|
||||
selector.pStruct().time().lookupObjectTypeName(name) !=
|
||||
FieldType::TYPENAME())
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Type of field "<< name << " in time repository does not match with"<<
|
||||
FieldType::TYEPANME()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
const FieldType& field = selector.pStruct().time().lookupObject<FieldType>(name);
|
||||
|
||||
auto fieldH = field.hostView();
|
||||
const auto& selected = selector.selectedPoints();
|
||||
Vector<T> selectedField(
|
||||
"selected-"+name,
|
||||
selected.size(),
|
||||
selected.size(),
|
||||
RESERVE());
|
||||
|
||||
for(uint32 i=0; i<selected.size(); i++)
|
||||
{
|
||||
selectedField[i] = fieldH[selected[i]];
|
||||
}
|
||||
|
||||
return selectedField;
|
||||
}
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__fieldSelector_hpp__
|
|
@ -37,11 +37,34 @@ const pFlow::pointStructure& pFlow::pStructSelector::pStruct()const
|
|||
return pStruct_;
|
||||
}
|
||||
|
||||
pFlow::realx3Vector
|
||||
pFlow::pStructSelector::selectedPointPositions() const
|
||||
{
|
||||
|
||||
const auto& slctd = selectedPoints();
|
||||
|
||||
if(slctd.empty()) return realx3Vector("selectedPointPositions");
|
||||
|
||||
realx3Vector slctdPoints("selectedPointPositions", slctd.size());
|
||||
|
||||
auto pPos = pStruct().pointPositionHost();
|
||||
|
||||
for(uint32 i=0; i<slctd.size(); i++)
|
||||
{
|
||||
slctdPoints[i] = pPos[slctd[i]];
|
||||
}
|
||||
|
||||
return slctdPoints;
|
||||
}
|
||||
|
||||
pFlow::uniquePtr<pFlow::pStructSelector>
|
||||
pFlow::pStructSelector::create(const pointStructure& pStruct, const dictionary& dict)
|
||||
pFlow::pStructSelector::create(
|
||||
const pointStructure& pStruct,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
word selectorMethod = dict.getVal<word>("selector");
|
||||
|
||||
word selectorMethod = angleBracketsNames("selector", dict.getVal<word>("selector"));
|
||||
|
||||
if( dictionaryvCtorSelector_.search(selectorMethod) )
|
||||
{
|
||||
|
|
|
@ -18,7 +18,6 @@ Licence:
|
|||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef __pStructSelector_hpp__
|
||||
#define __pStructSelector_hpp__
|
||||
|
||||
|
@ -26,6 +25,7 @@ Licence:
|
|||
#include "Vectors.hpp"
|
||||
#include "virtualConstructor.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
@ -62,16 +62,19 @@ public:
|
|||
const pointStructure& pStruct()const;
|
||||
|
||||
|
||||
virtual const uint32Vector& selectedPoinsts()const = 0;
|
||||
virtual const uint32Vector& selectedPoints()const = 0;
|
||||
|
||||
virtual uint32Vector& selectedPoinsts() = 0;
|
||||
virtual uint32Vector& selectedPoints() = 0;
|
||||
|
||||
realx3Vector selectedPointPositions()const;
|
||||
|
||||
static
|
||||
uniquePtr<pStructSelector> create(const pointStructure& pStruct, const dictionary& dict);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
|
|
|
@ -63,12 +63,12 @@ public:
|
|||
|
||||
//// - Methods
|
||||
|
||||
virtual const uint32Vector& selectedPoinsts()const override
|
||||
const uint32Vector& selectedPoints()const override
|
||||
{
|
||||
return selectedPoints_;
|
||||
}
|
||||
|
||||
virtual uint32Vector& selectedPoinsts() override
|
||||
uint32Vector& selectedPoints() override
|
||||
{
|
||||
return selectedPoints_;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
|
||||
|
||||
template<typename GeomType>
|
||||
bool
|
||||
pFlow::selectorGeometric<GeomType>::selectPoints()
|
||||
{
|
||||
|
||||
selectedPoints_.clear();
|
||||
|
||||
auto maskH = pStruct().activePointsMaskHost();
|
||||
const auto aRange = maskH.activeRange();
|
||||
auto pPos = pStruct().pointPositionHost();
|
||||
|
||||
for(uint32 i=aRange.start(); i<aRange.end();i++)
|
||||
{
|
||||
if(maskH.isActive(i)&& pRegion_.isInside( pPos[i] ))
|
||||
{
|
||||
selectedPoints_.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename GeomType>
|
||||
pFlow::selectorGeometric<GeomType>::selectorGeometric(
|
||||
const pointStructure& pStruct,
|
||||
const dictionary& dict
|
||||
)
|
||||
: pStructSelector(pStruct, dict),
|
||||
type_(dict.getVal<word>("selector")),
|
||||
pRegion_(type_, dict.subDict(type_ + "Info"))
|
||||
{
|
||||
|
||||
if(!selectPoints())
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*------------------------------- 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 __selectorGeometric_hpp__
|
||||
#define __selectorGeometric_hpp__
|
||||
|
||||
#include "pStructSelector.hpp"
|
||||
#include "PeakableRegion.hpp"
|
||||
#include "pointStructure.hpp"
|
||||
#include "dictionary.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename GeomType>
|
||||
class selectorGeometric
|
||||
:
|
||||
public pStructSelector
|
||||
{
|
||||
private:
|
||||
|
||||
word type_;
|
||||
|
||||
PeakableRegion<GeomType> pRegion_;
|
||||
|
||||
uint32Vector selectedPoints_{"selectedPoints"};
|
||||
|
||||
bool selectPoints();
|
||||
|
||||
public:
|
||||
|
||||
TypeInfoTemplate11("selector", GeomType);
|
||||
|
||||
selectorGeometric(const pointStructure& pStruct, const dictionary& dict);
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
pStructSelector,
|
||||
selectorGeometric,
|
||||
dictionary
|
||||
);
|
||||
|
||||
~selectorGeometric() override = default;
|
||||
|
||||
const uint32Vector& selectedPoints()const override
|
||||
{
|
||||
return selectedPoints_;
|
||||
}
|
||||
|
||||
uint32Vector& selectedPoints() override
|
||||
{
|
||||
return selectedPoints_;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include "selectorGeometric.cpp"
|
||||
|
||||
#endif //__selectorGeometric_hpp__
|
|
@ -0,0 +1,28 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "selectorGeometric.hpp"
|
||||
#include "box.hpp"
|
||||
#include "sphere.hpp"
|
||||
#include "cylinder.hpp"
|
||||
|
||||
template class pFlow::selectorGeometric<pFlow::box>;
|
||||
template class pFlow::selectorGeometric<pFlow::sphere>;
|
||||
template class pFlow::selectorGeometric<pFlow::cylinder>;
|
|
@ -19,13 +19,13 @@ Licence:
|
|||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "selectRandom.hpp"
|
||||
#include "selectorRandomPoints.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "uniformRandomUint32.hpp"
|
||||
#include "Set.hpp"
|
||||
|
||||
|
||||
bool pFlow::selectRandom::selectAllPointsInRange()
|
||||
bool pFlow::selectorRandomPoints::selectAllPointsInRange()
|
||||
{
|
||||
// to reduct allocations
|
||||
uint32 maxNum = number_+1;
|
||||
|
@ -79,7 +79,7 @@ bool pFlow::selectRandom::selectAllPointsInRange()
|
|||
|
||||
}
|
||||
|
||||
pFlow::selectRandom::selectRandom
|
||||
pFlow::selectorRandomPoints::selectorRandomPoints
|
||||
(
|
||||
const pointStructure& pStruct,
|
||||
const dictionary& dict
|
||||
|
@ -91,15 +91,15 @@ pFlow::selectRandom::selectRandom
|
|||
),
|
||||
begin_
|
||||
(
|
||||
dict.subDict("selectRandomInfo").getVal<uint32>("begin")
|
||||
dict.subDict("randomPointsInfo").getVal<uint32>("begin")
|
||||
),
|
||||
end_
|
||||
(
|
||||
dict.subDict("selectRandomInfo").getValOrSet("end", pStruct.size())
|
||||
dict.subDict("randomPointsInfo").getValOrSet("end", pStruct.size())
|
||||
),
|
||||
number_
|
||||
(
|
||||
dict.subDict("selectRandomInfo").getValOrSet("number", 1)
|
||||
dict.subDict("randomPointsInfo").getValOrSet("number", 1)
|
||||
)
|
||||
{
|
||||
begin_ = max(begin_,1u);
|
|
@ -31,11 +31,11 @@ namespace pFlow
|
|||
|
||||
class dictionary;
|
||||
|
||||
class selectRandom
|
||||
class selectorRandomPoints
|
||||
:
|
||||
public pStructSelector
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
uint32Vector selectedPoints_;
|
||||
|
||||
|
@ -53,28 +53,28 @@ protected:
|
|||
public:
|
||||
|
||||
// - type info
|
||||
TypeInfo("selectRandom");
|
||||
TypeInfo("selector<randomPoints>");
|
||||
|
||||
|
||||
selectRandom(const pointStructure& pStruct, const dictionary& dict);
|
||||
selectorRandomPoints(const pointStructure& pStruct, const dictionary& dict);
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
pStructSelector,
|
||||
selectRandom,
|
||||
selectorRandomPoints,
|
||||
dictionary
|
||||
);
|
||||
|
||||
virtual ~selectRandom() = default;
|
||||
~selectorRandomPoints() final = default;
|
||||
|
||||
//// - Methods
|
||||
|
||||
virtual const uint32Vector& selectedPoinsts()const override
|
||||
const uint32Vector& selectedPoints()const final
|
||||
{
|
||||
return selectedPoints_;
|
||||
}
|
||||
|
||||
virtual uint32Vector& selectedPoinsts() override
|
||||
uint32Vector& selectedPoints() final
|
||||
{
|
||||
return selectedPoints_;
|
||||
}
|
|
@ -19,10 +19,10 @@ Licence:
|
|||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "selectRange.hpp"
|
||||
#include "selectorStridedRange.hpp"
|
||||
#include "dictionary.hpp"
|
||||
|
||||
void pFlow::selectRange::selectAllPointsInRange()
|
||||
void pFlow::selectorStridedRange::selectAllPointsInRange()
|
||||
{
|
||||
// to reduct allocations
|
||||
uint32 maxNum = (end_ - begin_)/stride_+2;
|
||||
|
@ -37,7 +37,7 @@ void pFlow::selectRange::selectAllPointsInRange()
|
|||
}
|
||||
}
|
||||
|
||||
pFlow::selectRange::selectRange
|
||||
pFlow::selectorStridedRange::selectorStridedRange
|
||||
(
|
||||
const pointStructure& pStruct,
|
||||
const dictionary& dict
|
||||
|
@ -49,15 +49,15 @@ pFlow::selectRange::selectRange
|
|||
),
|
||||
begin_
|
||||
(
|
||||
dict.subDict("selectRangeInfo").getVal<uint32>("begin")
|
||||
dict.subDict("stridedRangeInfo").getVal<uint32>("begin")
|
||||
),
|
||||
end_
|
||||
(
|
||||
dict.subDict("selectRangeInfo").getValOrSet<uint32>("end", pStruct.size())
|
||||
dict.subDict("stridedRangeInfo").getValOrSet<uint32>("end", pStruct.size())
|
||||
),
|
||||
stride_
|
||||
(
|
||||
dict.subDict("selectRangeInfo").getValOrSet<uint32>("stride", 1u)
|
||||
dict.subDict("stridedRangeInfo").getValOrSet<uint32>("stride", 1u)
|
||||
)
|
||||
{
|
||||
begin_ = max(begin_,1u);
|
|
@ -31,11 +31,11 @@ namespace pFlow
|
|||
|
||||
class dictionary;
|
||||
|
||||
class selectRange
|
||||
class selectorStridedRange
|
||||
:
|
||||
public pStructSelector
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
uint32Vector selectedPoints_;
|
||||
|
||||
|
@ -53,28 +53,28 @@ protected:
|
|||
public:
|
||||
|
||||
// - type info
|
||||
TypeInfo("selectRange");
|
||||
TypeInfo("selector<stridedRange>");
|
||||
|
||||
|
||||
selectRange(const pointStructure& pStruct, const dictionary& dict);
|
||||
selectorStridedRange(const pointStructure& pStruct, const dictionary& dict);
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
pStructSelector,
|
||||
selectRange,
|
||||
selectorStridedRange,
|
||||
dictionary
|
||||
);
|
||||
|
||||
virtual ~selectRange() = default;
|
||||
~selectorStridedRange() final = default;
|
||||
|
||||
//// - Methods
|
||||
|
||||
virtual const uint32Vector& selectedPoinsts()const override
|
||||
const uint32Vector& selectedPoints()const final
|
||||
{
|
||||
return selectedPoints_;
|
||||
}
|
||||
|
||||
virtual uint32Vector& selectedPoinsts() override
|
||||
uint32Vector& selectedPoints() final
|
||||
{
|
||||
return selectedPoints_;
|
||||
}
|
|
@ -37,7 +37,7 @@ bool applySelector(systemControl& control, const pointStructure& pStruct, const
|
|||
|
||||
auto selector = pStructSelector::create(pStruct, selDict);
|
||||
|
||||
auto& selected = selector().selectedPoinsts();
|
||||
auto& selected = selector().selectedPoints();
|
||||
|
||||
uint32IndexContainer selIndex(selected.data(), selected.size());
|
||||
|
||||
|
|
Loading…
Reference in New Issue