|
@@ -176,7 +176,7 @@ struct VTUData {
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
-template <class Real, Integer DIM> class Tree {
|
|
|
|
|
|
+template <Integer DIM> class Tree {
|
|
public:
|
|
public:
|
|
|
|
|
|
struct NodeAttr {
|
|
struct NodeAttr {
|
|
@@ -194,12 +194,11 @@ template <class Real, Integer DIM> class Tree {
|
|
return DIM;
|
|
return DIM;
|
|
}
|
|
}
|
|
|
|
|
|
- Tree(const Comm& comm_ = Comm::Self()) {
|
|
|
|
- comm = comm_;
|
|
|
|
|
|
+ Tree(const Comm& comm_ = Comm::Self()) : comm(comm_) {
|
|
Integer rank = comm.Rank();
|
|
Integer rank = comm.Rank();
|
|
Integer np = comm.Size();
|
|
Integer np = comm.Size();
|
|
|
|
|
|
- Vector<Real> coord;
|
|
|
|
|
|
+ Vector<double> coord;
|
|
{ // Set coord
|
|
{ // Set coord
|
|
Long N0 = 1;
|
|
Long N0 = 1;
|
|
while (sctl::pow<DIM,Long>(N0) < np) N0++;
|
|
while (sctl::pow<DIM,Long>(N0) < np) N0++;
|
|
@@ -210,7 +209,7 @@ template <class Real, Integer DIM> class Tree {
|
|
for (Long i = start; i < end; i++) {
|
|
for (Long i = start; i < end; i++) {
|
|
Long idx = i;
|
|
Long idx = i;
|
|
for (Integer k = 0; k < DIM; k++) {
|
|
for (Integer k = 0; k < DIM; k++) {
|
|
- coord[(i-start)*DIM+k] = (idx % N0) / (Real)N0;
|
|
|
|
|
|
+ coord[(i-start)*DIM+k] = (idx % N0) / (double)N0;
|
|
idx /= N0;
|
|
idx /= N0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -242,7 +241,7 @@ template <class Real, Integer DIM> class Tree {
|
|
return comm;
|
|
return comm;
|
|
}
|
|
}
|
|
|
|
|
|
- void UpdateRefinement(const Vector<Real>& coord, Long M = 1, bool balance21 = 0, bool periodic = 0) {
|
|
|
|
|
|
+ template <class Real> void UpdateRefinement(const Vector<Real>& coord, Long M = 1, bool balance21 = 0, bool periodic = 0) {
|
|
Integer np = comm.Size();
|
|
Integer np = comm.Size();
|
|
Integer rank = comm.Rank();
|
|
Integer rank = comm.Rank();
|
|
|
|
|
|
@@ -503,7 +502,7 @@ template <class Real, Integer DIM> class Tree {
|
|
child_cnt[depth] = 0;
|
|
child_cnt[depth] = 0;
|
|
if (depth) {
|
|
if (depth) {
|
|
Long p = ancestors[depth-1];
|
|
Long p = ancestors[depth-1];
|
|
- Integer& c = child_cnt[depth-1];
|
|
|
|
|
|
+ Long& c = child_cnt[depth-1];
|
|
node_lst[i].parent = p;
|
|
node_lst[i].parent = p;
|
|
node_lst[p].child[c] = i;
|
|
node_lst[p].child[c] = i;
|
|
node_lst[p].p2n = c;
|
|
node_lst[p].p2n = c;
|
|
@@ -552,14 +551,14 @@ template <class Real, Integer DIM> class Tree {
|
|
}
|
|
}
|
|
|
|
|
|
Vector<Long> cnt_tmp;
|
|
Vector<Long> cnt_tmp;
|
|
- Vector<Real> data_tmp;
|
|
|
|
|
|
+ Vector<char> data_tmp;
|
|
for (const auto& pair : node_data) {
|
|
for (const auto& pair : node_data) {
|
|
const std::string& data_name = pair.first;
|
|
const std::string& data_name = pair.first;
|
|
|
|
|
|
Long dof;
|
|
Long dof;
|
|
- Iterator<Vector<Real>> data_;
|
|
|
|
|
|
+ Iterator<Vector<char>> data_;
|
|
Iterator<Vector<Long>> cnt_;
|
|
Iterator<Vector<Long>> cnt_;
|
|
- GetData(data_, cnt_, data_name);
|
|
|
|
|
|
+ GetData_(data_, cnt_, data_name);
|
|
{ // Set dof
|
|
{ // Set dof
|
|
StaticArray<Long,2> Nl, Ng;
|
|
StaticArray<Long,2> Nl, Ng;
|
|
Nl[0] = data_->Dim();
|
|
Nl[0] = data_->Dim();
|
|
@@ -595,7 +594,7 @@ template <class Real, Integer DIM> class Tree {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void AddData(const std::string& name, const Vector<Real>& data, const Vector<Long>& cnt) {
|
|
|
|
|
|
+ template <class ValueType> void AddData(const std::string& name, const Vector<ValueType>& data, const Vector<Long>& cnt) {
|
|
Long dof;
|
|
Long dof;
|
|
{ // Check dof
|
|
{ // Check dof
|
|
StaticArray<Long,2> Nl, Ng;
|
|
StaticArray<Long,2> Nl, Ng;
|
|
@@ -609,36 +608,29 @@ template <class Real, Integer DIM> class Tree {
|
|
if (dof) SCTL_ASSERT(cnt.Dim() == node_mid.Dim());
|
|
if (dof) SCTL_ASSERT(cnt.Dim() == node_mid.Dim());
|
|
|
|
|
|
SCTL_ASSERT(node_data.find(name) == node_data.end());
|
|
SCTL_ASSERT(node_data.find(name) == node_data.end());
|
|
- node_data[name] = data;
|
|
|
|
- node_cnt [name] = cnt;
|
|
|
|
|
|
+ node_data[name].ReInit(data.Dim()*sizeof(ValueType), (Iterator<char>)data.begin(), true);
|
|
|
|
+ node_cnt [name] = cnt;
|
|
}
|
|
}
|
|
|
|
|
|
- void GetData(Iterator<Vector<Real>>& data, ConstIterator<Vector<Long>>& cnt, const std::string& name) {
|
|
|
|
- auto data_ = node_data.find(name);
|
|
|
|
- const auto cnt_ = node_cnt.find(name);
|
|
|
|
- SCTL_ASSERT(data_ != node_data.end());
|
|
|
|
- SCTL_ASSERT( cnt_ != node_cnt .end());
|
|
|
|
- data = Ptr2Itr<Vector<Real>>(&data_->second,1);
|
|
|
|
- cnt = Ptr2ConstItr<Vector<Long>>(& cnt_->second,1);
|
|
|
|
- }
|
|
|
|
- void GetData(ConstIterator<Vector<Real>>& data, ConstIterator<Vector<Long>>& cnt, const std::string& name) const {
|
|
|
|
|
|
+ template <class ValueType> void GetData(Vector<ValueType>& data, Vector<Long>& cnt, const std::string& name) const {
|
|
const auto data_ = node_data.find(name);
|
|
const auto data_ = node_data.find(name);
|
|
const auto cnt_ = node_cnt.find(name);
|
|
const auto cnt_ = node_cnt.find(name);
|
|
SCTL_ASSERT(data_ != node_data.end());
|
|
SCTL_ASSERT(data_ != node_data.end());
|
|
SCTL_ASSERT( cnt_ != node_cnt .end());
|
|
SCTL_ASSERT( cnt_ != node_cnt .end());
|
|
- data = Ptr2ConstItr<Vector<Real>>(&data_->second,1);
|
|
|
|
- cnt = Ptr2ConstItr<Vector<Long>>(& cnt_->second,1);
|
|
|
|
|
|
+ data.ReInit(data_->second.Dim()/sizeof(ValueType), (Iterator<ValueType>)data_->second.begin(), false);
|
|
|
|
+ SCTL_ASSERT(data.Dim()*(Long)sizeof(ValueType) == data_->second.Dim());
|
|
|
|
+ cnt .ReInit( cnt_->second.Dim(), (Iterator<Long>)cnt_->second.begin(), false);
|
|
}
|
|
}
|
|
|
|
|
|
- void ReduceBroadcast(const std::string& name) {
|
|
|
|
|
|
+ template <class ValueType> void ReduceBroadcast(const std::string& name) {
|
|
Integer np = comm.Size();
|
|
Integer np = comm.Size();
|
|
Integer rank = comm.Rank();
|
|
Integer rank = comm.Rank();
|
|
|
|
|
|
Vector<Long> dsp;
|
|
Vector<Long> dsp;
|
|
- Iterator<Vector<Real>> data_;
|
|
|
|
|
|
+ Iterator<Vector<char>> data_;
|
|
Iterator<Vector<Long>> cnt_;
|
|
Iterator<Vector<Long>> cnt_;
|
|
- GetData(data_, cnt_, name);
|
|
|
|
- Vector<Real>& data = *data_;
|
|
|
|
|
|
+ GetData_(data_, cnt_, name);
|
|
|
|
+ Vector<ValueType> data(data_->Dim()/sizeof(ValueType), (Iterator<ValueType>)data_->begin(), false);
|
|
Vector<Long>& cnt = *cnt_;
|
|
Vector<Long>& cnt = *cnt_;
|
|
scan(dsp, cnt);
|
|
scan(dsp, cnt);
|
|
|
|
|
|
@@ -693,7 +685,7 @@ template <class Real, Integer DIM> class Tree {
|
|
scan(recv_data_dsp, recv_data_cnt);
|
|
scan(recv_data_dsp, recv_data_cnt);
|
|
}
|
|
}
|
|
|
|
|
|
- Vector<Real> send_buff, recv_buff;
|
|
|
|
|
|
+ Vector<ValueType> send_buff, recv_buff;
|
|
Vector<Long> send_buff_cnt(np), send_buff_dsp(np);
|
|
Vector<Long> send_buff_cnt(np), send_buff_dsp(np);
|
|
Vector<Long> recv_buff_cnt(np), recv_buff_dsp(np);
|
|
Vector<Long> recv_buff_cnt(np), recv_buff_dsp(np);
|
|
{ // Set send_buff, send_buff_cnt, send_buff_dsp, recv_buff, recv_buff_cnt, recv_buff_dsp
|
|
{ // Set send_buff, send_buff_cnt, send_buff_dsp, recv_buff, recv_buff_cnt, recv_buff_dsp
|
|
@@ -782,7 +774,7 @@ template <class Real, Integer DIM> class Tree {
|
|
scan(recv_data_dsp, recv_data_cnt);
|
|
scan(recv_data_dsp, recv_data_cnt);
|
|
}
|
|
}
|
|
|
|
|
|
- Vector<Real> send_buff, recv_buff;
|
|
|
|
|
|
+ Vector<ValueType> send_buff, recv_buff;
|
|
Vector<Long> send_buff_cnt(np), send_buff_dsp(np);
|
|
Vector<Long> send_buff_cnt(np), send_buff_dsp(np);
|
|
Vector<Long> recv_buff_cnt(np), recv_buff_dsp(np);
|
|
Vector<Long> recv_buff_cnt(np), recv_buff_dsp(np);
|
|
{ // Set send_buff, send_buff_cnt, send_buff_dsp, recv_buff, recv_buff_cnt, recv_buff_dsp
|
|
{ // Set send_buff, send_buff_cnt, send_buff_dsp, recv_buff, recv_buff_cnt, recv_buff_dsp
|
|
@@ -837,9 +829,10 @@ template <class Real, Integer DIM> class Tree {
|
|
Long N1 = (end_idx ? dsp[end_idx-1] + cnt[end_idx-1] : 0) * dof;
|
|
Long N1 = (end_idx ? dsp[end_idx-1] + cnt[end_idx-1] : 0) * dof;
|
|
Long Ns = (Nsplit ? recv_data_dsp[Nsplit-1] + recv_data_cnt[Nsplit-1] : 0) * dof;
|
|
Long Ns = (Nsplit ? recv_data_dsp[Nsplit-1] + recv_data_cnt[Nsplit-1] : 0) * dof;
|
|
if (N0 != Ns || recv_buff.Dim() != N0+data.Dim()-N1) { // resize data and preserve non-ghost data
|
|
if (N0 != Ns || recv_buff.Dim() != N0+data.Dim()-N1) { // resize data and preserve non-ghost data
|
|
- Vector<Real> data_new(recv_buff.Dim() + N1-N0);
|
|
|
|
- memcopy(data_new.begin() + Ns, data.begin() + N0, N1-N0);
|
|
|
|
- data.Swap(data_new);
|
|
|
|
|
|
+ Vector<char> data_new((recv_buff.Dim() + N1-N0) * sizeof(ValueType));
|
|
|
|
+ memcopy(data_new.begin() + Ns * sizeof(ValueType), data_->begin() + N0 * sizeof(ValueType), (N1-N0) * sizeof(ValueType));
|
|
|
|
+ data_->Swap(data_new);
|
|
|
|
+ data.ReInit(data_->Dim()/sizeof(ValueType), (Iterator<ValueType>)data_->begin(), false);
|
|
}
|
|
}
|
|
|
|
|
|
memcopy(cnt.begin(), recv_data_cnt.begin(), start_idx);
|
|
memcopy(cnt.begin(), recv_data_cnt.begin(), start_idx);
|
|
@@ -903,12 +896,12 @@ template <class Real, Integer DIM> class Tree {
|
|
|
|
|
|
protected:
|
|
protected:
|
|
|
|
|
|
- void GetData(Iterator<Vector<Real>>& data, Iterator<Vector<Long>>& cnt, const std::string& name) {
|
|
|
|
|
|
+ void GetData_(Iterator<Vector<char>>& data, Iterator<Vector<Long>>& cnt, const std::string& name) {
|
|
auto data_ = node_data.find(name);
|
|
auto data_ = node_data.find(name);
|
|
const auto cnt_ = node_cnt.find(name);
|
|
const auto cnt_ = node_cnt.find(name);
|
|
SCTL_ASSERT(data_ != node_data.end());
|
|
SCTL_ASSERT(data_ != node_data.end());
|
|
SCTL_ASSERT( cnt_ != node_cnt .end());
|
|
SCTL_ASSERT( cnt_ != node_cnt .end());
|
|
- data = Ptr2Itr<Vector<Real>>(&data_->second,1);
|
|
|
|
|
|
+ data = Ptr2Itr<Vector<char>>(&data_->second,1);
|
|
cnt = Ptr2Itr<Vector<Long>>(& cnt_->second,1);
|
|
cnt = Ptr2Itr<Vector<Long>>(& cnt_->second,1);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -931,7 +924,7 @@ template <class Real, Integer DIM> class Tree {
|
|
Vector<NodeAttr> node_attr;
|
|
Vector<NodeAttr> node_attr;
|
|
Vector<NodeLists> node_lst;
|
|
Vector<NodeLists> node_lst;
|
|
|
|
|
|
- std::map<std::string, Vector<Real>> node_data;
|
|
|
|
|
|
+ std::map<std::string, Vector<char>> node_data;
|
|
std::map<std::string, Vector<Long>> node_cnt;
|
|
std::map<std::string, Vector<Long>> node_cnt;
|
|
|
|
|
|
Vector<Morton<DIM>> user_mid;
|
|
Vector<Morton<DIM>> user_mid;
|
|
@@ -940,7 +933,7 @@ template <class Real, Integer DIM> class Tree {
|
|
Comm comm;
|
|
Comm comm;
|
|
};
|
|
};
|
|
|
|
|
|
-template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree : public BaseTree {
|
|
|
|
|
|
+template <class Real, Integer DIM, class BaseTree = Tree<DIM>> class PtTree : public BaseTree {
|
|
public:
|
|
public:
|
|
|
|
|
|
PtTree(const Comm& comm = Comm::Self()) : BaseTree(comm) {}
|
|
PtTree(const Comm& comm = Comm::Self()) : BaseTree(comm) {}
|
|
@@ -948,8 +941,8 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
~PtTree() {
|
|
~PtTree() {
|
|
#ifdef SCTL_MEMDEBUG
|
|
#ifdef SCTL_MEMDEBUG
|
|
for (auto& pair : data_pt_name) {
|
|
for (auto& pair : data_pt_name) {
|
|
- ConstIterator<Vector<Real>> data;
|
|
|
|
- ConstIterator<Vector<Long>> cnt;
|
|
|
|
|
|
+ Vector<Real> data;
|
|
|
|
+ Vector<Long> cnt;
|
|
this->GetData(data, cnt, pair.second);
|
|
this->GetData(data, cnt, pair.second);
|
|
SCTL_ASSERT(scatter_idx.find(pair.second) != scatter_idx.end());
|
|
SCTL_ASSERT(scatter_idx.find(pair.second) != scatter_idx.end());
|
|
}
|
|
}
|
|
@@ -992,9 +985,9 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
if (pair.second == pt_name) {
|
|
if (pair.second == pt_name) {
|
|
const auto& data_name = pair.first;
|
|
const auto& data_name = pair.first;
|
|
|
|
|
|
- Iterator<Vector<Real>> data;
|
|
|
|
|
|
+ Iterator<Vector<char>> data;
|
|
Iterator<Vector<Long>> cnt;
|
|
Iterator<Vector<Long>> cnt;
|
|
- this->GetData(data, cnt, data_name);
|
|
|
|
|
|
+ this->GetData_(data, cnt, data_name);
|
|
|
|
|
|
{ // Update data
|
|
{ // Update data
|
|
Long dof = 0;
|
|
Long dof = 0;
|
|
@@ -1014,7 +1007,7 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
offset *= dof;
|
|
offset *= dof;
|
|
count *= dof;
|
|
count *= dof;
|
|
|
|
|
|
- Vector<Real> data_(count, data->begin() + offset);
|
|
|
|
|
|
+ Vector<char> data_(count, data->begin() + offset);
|
|
comm.PartitionN(data_, pt_mid_.Dim());
|
|
comm.PartitionN(data_, pt_mid_.Dim());
|
|
data->Swap(data_);
|
|
data->Swap(data_);
|
|
}
|
|
}
|
|
@@ -1046,9 +1039,9 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
AddParticleData(name, name, coord);
|
|
AddParticleData(name, name, coord);
|
|
|
|
|
|
{ // Set node_cnt
|
|
{ // Set node_cnt
|
|
- Iterator<Vector<Real>> data_;
|
|
|
|
|
|
+ Iterator<Vector<char>> data_;
|
|
Iterator<Vector<Long>> cnt_;
|
|
Iterator<Vector<Long>> cnt_;
|
|
- this->GetData(data_,cnt_,name);
|
|
|
|
|
|
+ this->GetData_(data_,cnt_,name);
|
|
cnt_[0].ReInit(node_mid.Dim());
|
|
cnt_[0].ReInit(node_mid.Dim());
|
|
for (Long i = 0; i < node_mid.Dim(); i++) {
|
|
for (Long i = 0; i < node_mid.Dim(); i++) {
|
|
Long start = std::lower_bound(pt_mid_.begin(), pt_mid_.end(), node_mid[i]) - pt_mid_.begin();
|
|
Long start = std::lower_bound(pt_mid_.begin(), pt_mid_.end(), node_mid[i]) - pt_mid_.begin();
|
|
@@ -1065,19 +1058,19 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
SCTL_ASSERT(data_pt_name.find(data_name) == data_pt_name.end());
|
|
SCTL_ASSERT(data_pt_name.find(data_name) == data_pt_name.end());
|
|
data_pt_name[data_name] = particle_name;
|
|
data_pt_name[data_name] = particle_name;
|
|
|
|
|
|
- Iterator<Vector<Real>> data_;
|
|
|
|
|
|
+ Iterator<Vector<char>> data_;
|
|
Iterator<Vector<Long>> cnt_;
|
|
Iterator<Vector<Long>> cnt_;
|
|
this->AddData(data_name, Vector<Real>(), Vector<Long>());
|
|
this->AddData(data_name, Vector<Real>(), Vector<Long>());
|
|
- this->GetData(data_,cnt_,data_name);
|
|
|
|
|
|
+ this->GetData_(data_,cnt_,data_name);
|
|
{ // Set data_[0]
|
|
{ // Set data_[0]
|
|
- data_[0] = data;
|
|
|
|
|
|
+ data_[0].ReInit(data.Dim()*sizeof(Real), (Iterator<char>)data.begin(), true);
|
|
this->GetComm().ScatterForward(data_[0], scatter_idx[particle_name]);
|
|
this->GetComm().ScatterForward(data_[0], scatter_idx[particle_name]);
|
|
}
|
|
}
|
|
if (data_name != particle_name) { // Set cnt_[0]
|
|
if (data_name != particle_name) { // Set cnt_[0]
|
|
- Iterator<Vector<Real>> pt_coord;
|
|
|
|
- Iterator<Vector<Long>> pt_cnt;
|
|
|
|
|
|
+ Vector<Real> pt_coord;
|
|
|
|
+ Vector<Long> pt_cnt;
|
|
this->GetData(pt_coord, pt_cnt, particle_name);
|
|
this->GetData(pt_coord, pt_cnt, particle_name);
|
|
- cnt_[0] = pt_cnt[0];
|
|
|
|
|
|
+ cnt_[0] = pt_cnt;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1094,14 +1087,14 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
|
|
|
|
Long dof;
|
|
Long dof;
|
|
Vector<Long> dsp;
|
|
Vector<Long> dsp;
|
|
- ConstIterator<Vector<Long>> cnt_;
|
|
|
|
- ConstIterator<Vector<Real>> data_;
|
|
|
|
|
|
+ Vector<Long> cnt_;
|
|
|
|
+ Vector<Real> data_;
|
|
this->GetData(data_, cnt_, data_name);
|
|
this->GetData(data_, cnt_, data_name);
|
|
- SCTL_ASSERT(cnt_->Dim() == node_mid.Dim());
|
|
|
|
- BaseTree::scan(dsp, cnt_[0]);
|
|
|
|
|
|
+ SCTL_ASSERT(cnt_.Dim() == node_mid.Dim());
|
|
|
|
+ BaseTree::scan(dsp, cnt_);
|
|
{ // Set dof
|
|
{ // Set dof
|
|
Long Nn = node_mid.Dim();
|
|
Long Nn = node_mid.Dim();
|
|
- StaticArray<Long,2> Ng, Nl = {data_->Dim(), dsp[Nn-1]+cnt_[0][Nn-1]};
|
|
|
|
|
|
+ StaticArray<Long,2> Ng, Nl = {data_.Dim(), dsp[Nn-1]+cnt_[Nn-1]};
|
|
comm.Allreduce((ConstIterator<Long>)Nl, (Iterator<Long>)Ng, 2, Comm::CommOp::SUM);
|
|
comm.Allreduce((ConstIterator<Long>)Nl, (Iterator<Long>)Ng, 2, Comm::CommOp::SUM);
|
|
dof = Ng[0] / std::max<Long>(Ng[1],1);
|
|
dof = Ng[0] / std::max<Long>(Ng[1],1);
|
|
}
|
|
}
|
|
@@ -1111,8 +1104,8 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
Long N0 = std::lower_bound(node_mid.begin(), node_mid.end(), mins[rank]) - node_mid.begin();
|
|
Long N0 = std::lower_bound(node_mid.begin(), node_mid.end(), mins[rank]) - node_mid.begin();
|
|
Long N1 = std::lower_bound(node_mid.begin(), node_mid.end(), (rank+1==np ? Morton<DIM>().Next() : mins[rank+1])) - node_mid.begin();
|
|
Long N1 = std::lower_bound(node_mid.begin(), node_mid.end(), (rank+1==np ? Morton<DIM>().Next() : mins[rank+1])) - node_mid.begin();
|
|
Long start = dsp[N0] * dof;
|
|
Long start = dsp[N0] * dof;
|
|
- Long end = (N1<dsp.Dim() ? dsp[N1] : dsp[N1-1]+cnt_[0][N1-1]) * dof;
|
|
|
|
- data.ReInit(end-start, (Iterator<Real>)data_->begin()+start, true);
|
|
|
|
|
|
+ Long end = (N1<dsp.Dim() ? dsp[N1] : dsp[N1-1]+cnt_[N1-1]) * dof;
|
|
|
|
+ data.ReInit(end-start, data_.begin()+start, true);
|
|
comm.ScatterReverse(data, scatter_idx_, Nlocal_ * dof);
|
|
comm.ScatterReverse(data, scatter_idx_, Nlocal_ * dof);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1148,20 +1141,20 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
SCTL_ASSERT(data_pt_name.find(data_name) != data_pt_name.end());
|
|
SCTL_ASSERT(data_pt_name.find(data_name) != data_pt_name.end());
|
|
std::string particle_name = data_pt_name.find(data_name)->second;
|
|
std::string particle_name = data_pt_name.find(data_name)->second;
|
|
|
|
|
|
- ConstIterator<Vector<Real>> pt_coord = NullIterator<Vector<Real>>();
|
|
|
|
- ConstIterator<Vector<Real>> pt_value = NullIterator<Vector<Real>>();
|
|
|
|
- ConstIterator<Vector<Long>> pt_cnt = NullIterator<Vector<Long>>();
|
|
|
|
|
|
+ Vector<Real> pt_coord;
|
|
|
|
+ Vector<Real> pt_value;
|
|
|
|
+ Vector<Long> pt_cnt;
|
|
Vector<Long> pt_dsp;
|
|
Vector<Long> pt_dsp;
|
|
Long value_dof = 0;
|
|
Long value_dof = 0;
|
|
{ // Set pt_coord, pt_cnt, pt_dsp
|
|
{ // Set pt_coord, pt_cnt, pt_dsp
|
|
this->GetData(pt_coord, pt_cnt, particle_name);
|
|
this->GetData(pt_coord, pt_cnt, particle_name);
|
|
- Tree<Real,DIM>::scan(pt_dsp, pt_cnt[0]);
|
|
|
|
|
|
+ Tree<DIM>::scan(pt_dsp, pt_cnt);
|
|
}
|
|
}
|
|
if (particle_name != data_name) { // Set pt_value, value_dof
|
|
if (particle_name != data_name) { // Set pt_value, value_dof
|
|
- ConstIterator<Vector<Long>> pt_cnt = NullIterator<Vector<Long>>();
|
|
|
|
|
|
+ Vector<Long> pt_cnt;
|
|
this->GetData(pt_value, pt_cnt, data_name);
|
|
this->GetData(pt_value, pt_cnt, data_name);
|
|
- Long Npt = omp_par::reduce(pt_cnt->begin(), pt_cnt->Dim());
|
|
|
|
- value_dof = pt_value->Dim() / std::max<Long>(Npt,1);
|
|
|
|
|
|
+ Long Npt = omp_par::reduce(pt_cnt.begin(), pt_cnt.Dim());
|
|
|
|
+ value_dof = pt_value.Dim() / std::max<Long>(Npt,1);
|
|
}
|
|
}
|
|
|
|
|
|
Vector<VTKReal> &coord = vtu_data.coord;
|
|
Vector<VTKReal> &coord = vtu_data.coord;
|
|
@@ -1177,14 +1170,14 @@ template <class Real, Integer DIM, class BaseTree = Tree<Real,DIM>> class PtTree
|
|
value.SetZero();
|
|
value.SetZero();
|
|
|
|
|
|
SCTL_ASSERT(node_mid.Dim() == node_attr.Dim());
|
|
SCTL_ASSERT(node_mid.Dim() == node_attr.Dim());
|
|
- SCTL_ASSERT(node_mid.Dim() == pt_cnt->Dim());
|
|
|
|
|
|
+ SCTL_ASSERT(node_mid.Dim() == pt_cnt.Dim());
|
|
for (Long i = 0; i < node_mid.Dim(); i++) {
|
|
for (Long i = 0; i < node_mid.Dim(); i++) {
|
|
if (!show_ghost && node_attr[i].Ghost) continue;
|
|
if (!show_ghost && node_attr[i].Ghost) continue;
|
|
if (!node_attr[i].Leaf) continue;
|
|
if (!node_attr[i].Leaf) continue;
|
|
|
|
|
|
- for (Long j = 0; j < pt_cnt[0][i]; j++) {
|
|
|
|
- ConstIterator<Real> pt_coord_ = pt_coord->begin() + (pt_dsp[i] + j) * DIM;
|
|
|
|
- ConstIterator<Real> pt_value_ = (value_dof ? pt_value->begin() + (pt_dsp[i] + j) * value_dof : NullIterator<Real>());
|
|
|
|
|
|
+ for (Long j = 0; j < pt_cnt[i]; j++) {
|
|
|
|
+ ConstIterator<Real> pt_coord_ = pt_coord.begin() + (pt_dsp[i] + j) * DIM;
|
|
|
|
+ ConstIterator<Real> pt_value_ = (value_dof ? pt_value.begin() + (pt_dsp[i] + j) * value_dof : NullIterator<Real>());
|
|
|
|
|
|
for (Integer k = 0; k < DIM; k++) coord.PushBack((VTKReal)pt_coord_[k]);
|
|
for (Integer k = 0; k < DIM; k++) coord.PushBack((VTKReal)pt_coord_[k]);
|
|
for (Integer k = DIM; k < 3; k++) coord.PushBack(0);
|
|
for (Integer k = DIM; k < 3; k++) coord.PushBack(0);
|