diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index 6bf9c3ee..4449aa88 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -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 diff --git a/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp b/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp index 3bc1fa66..6155a33d 100644 --- a/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp +++ b/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp @@ -457,9 +457,6 @@ bool pFlow::internalPoints::read return true; } - - - bool pFlow::internalPoints::write ( diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/pStructSelector/fieldSelector.hpp b/src/phasicFlow/structuredData/pointStructure/selectors/pStructSelector/fieldSelector.hpp new file mode 100644 index 00000000..f69025dc --- /dev/null +++ b/src/phasicFlow/structuredData/pointStructure/selectors/pStructSelector/fieldSelector.hpp @@ -0,0 +1,60 @@ + +#ifndef __fieldSelector_hpp__ +#define __fieldSelector_hpp__ + +#include "pStructSelector.hpp" +#include "pointFields.hpp" +#include "Time.hpp" + +namespace pFlow +{ + +template +inline +Vector selectedFieldVals(const pStructSelector& selector, const word& name) +{ + using FieldType = pointField_D; + + if(selector.selectedPoints().empty() ) + { + return Vector("selected-"+name); + } + + if(!selector.pStruct().time().lookupObjectName(name)) + { + fatalErrorInFunction<< + "Field "<< name << " does not exist in time repository"<(name); + + auto fieldH = field.hostView(); + const auto& selected = selector.selectedPoints(); + Vector selectedField( + "selected-"+name, + selected.size(), + selected.size(), + RESERVE()); + + for(uint32 i=0; i - pFlow::pStructSelector::create(const pointStructure& pStruct, const dictionary& dict) +pFlow::pStructSelector::create( + const pointStructure& pStruct, + const dictionary& dict +) { - word selectorMethod = dict.getVal("selector"); + + word selectorMethod = angleBracketsNames("selector", dict.getVal("selector")); if( dictionaryvCtorSelector_.search(selectorMethod) ) { diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/pStructSelector/pStructSelector.hpp b/src/phasicFlow/structuredData/pointStructure/selectors/pStructSelector/pStructSelector.hpp index a3ce07cc..ef0882f1 100644 --- a/src/phasicFlow/structuredData/pointStructure/selectors/pStructSelector/pStructSelector.hpp +++ b/src/phasicFlow/structuredData/pointStructure/selectors/pStructSelector/pStructSelector.hpp @@ -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 create(const pointStructure& pStruct, const dictionary& dict); }; + + } // pFlow diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectBox/selectBox.hpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectBox/selectBox.hpp index 88c5a5b2..89faad6f 100644 --- a/src/phasicFlow/structuredData/pointStructure/selectors/selectBox/selectBox.hpp +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectBox/selectBox.hpp @@ -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_; } diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometric.cpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometric.cpp new file mode 100644 index 00000000..652a55cb --- /dev/null +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometric.cpp @@ -0,0 +1,41 @@ + + + +template +bool +pFlow::selectorGeometric::selectPoints() +{ + + selectedPoints_.clear(); + + auto maskH = pStruct().activePointsMaskHost(); + const auto aRange = maskH.activeRange(); + auto pPos = pStruct().pointPositionHost(); + + for(uint32 i=aRange.start(); i +pFlow::selectorGeometric::selectorGeometric( + const pointStructure& pStruct, + const dictionary& dict +) + : pStructSelector(pStruct, dict), + type_(dict.getVal("selector")), + pRegion_(type_, dict.subDict(type_ + "Info")) +{ + + if(!selectPoints()) + { + fatalExit; + } +} + diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometric.hpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometric.hpp new file mode 100644 index 00000000..feb69d3f --- /dev/null +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometric.hpp @@ -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 +class selectorGeometric +: + public pStructSelector +{ +private: + + word type_; + + PeakableRegion 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__ \ No newline at end of file diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometrics.cpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometrics.cpp new file mode 100644 index 00000000..990e8cca --- /dev/null +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectorGeometric/selectorGeometrics.cpp @@ -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; +template class pFlow::selectorGeometric; +template class pFlow::selectorGeometric; diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.cpp similarity index 87% rename from src/phasicFlow/structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp rename to src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.cpp index 0963220b..a0556a09 100644 --- a/src/phasicFlow/structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.cpp @@ -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("begin") + dict.subDict("randomPointsInfo").getVal("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); diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectRandom/selectRandom.hpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.hpp similarity index 83% rename from src/phasicFlow/structuredData/pointStructure/selectors/selectRandom/selectRandom.hpp rename to src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.hpp index b132e9ee..22ddd4f3 100644 --- a/src/phasicFlow/structuredData/pointStructure/selectors/selectRandom/selectRandom.hpp +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.hpp @@ -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"); - 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_; } diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectRange/selectRange.cpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectorStridedRange/selectorStridedRange.cpp similarity index 81% rename from src/phasicFlow/structuredData/pointStructure/selectors/selectRange/selectRange.cpp rename to src/phasicFlow/structuredData/pointStructure/selectors/selectorStridedRange/selectorStridedRange.cpp index ad7079e9..60c3c8fc 100644 --- a/src/phasicFlow/structuredData/pointStructure/selectors/selectRange/selectRange.cpp +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectorStridedRange/selectorStridedRange.cpp @@ -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("begin") + dict.subDict("stridedRangeInfo").getVal("begin") ), end_ ( - dict.subDict("selectRangeInfo").getValOrSet("end", pStruct.size()) + dict.subDict("stridedRangeInfo").getValOrSet("end", pStruct.size()) ), stride_ ( - dict.subDict("selectRangeInfo").getValOrSet("stride", 1u) + dict.subDict("stridedRangeInfo").getValOrSet("stride", 1u) ) { begin_ = max(begin_,1u); diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectRange/selectRange.hpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectorStridedRange/selectorStridedRange.hpp similarity index 83% rename from src/phasicFlow/structuredData/pointStructure/selectors/selectRange/selectRange.hpp rename to src/phasicFlow/structuredData/pointStructure/selectors/selectorStridedRange/selectorStridedRange.hpp index 9c86625a..23e36684 100644 --- a/src/phasicFlow/structuredData/pointStructure/selectors/selectRange/selectRange.hpp +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectorStridedRange/selectorStridedRange.hpp @@ -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"); - 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_; } diff --git a/utilities/particlesPhasicFlow/setFields.hpp b/utilities/particlesPhasicFlow/setFields.hpp index 0eb56745..48b19c4d 100755 --- a/utilities/particlesPhasicFlow/setFields.hpp +++ b/utilities/particlesPhasicFlow/setFields.hpp @@ -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());