mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-28 03:27:05 +00:00
first commit for post-processing
- the whole structure is ready. - next step whould be execute methods and then write methods - post-processing after simulation is not started yet.
This commit is contained in:
@ -0,0 +1,86 @@
|
||||
#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 false;
|
||||
}
|
||||
|
||||
pFlow::centerPointsRegionPoints::centerPointsRegionPoints(
|
||||
const dictionary &dict,
|
||||
fieldsDataBase &fieldsDataBase)
|
||||
: regionPoints(dict, fieldsDataBase),
|
||||
idName_(dict.getValOrSet<word>("idName", "id")),
|
||||
probDict_(dict)
|
||||
{
|
||||
auto idList = dict.getVal<uint32List>("ids");
|
||||
Set<uint32> uniqueIds;
|
||||
|
||||
uniqueIds.insert(idList.begin(), idList.end());
|
||||
|
||||
for(auto& id:uniqueIds)
|
||||
{
|
||||
ids_.push_back(id);
|
||||
}
|
||||
|
||||
selectedPoints_.resize(ids_.size());
|
||||
}
|
||||
|
||||
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 false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user