21 #include <vtkCPDataDescription.h>
22 #include <vtkCPInputDataDescription.h>
24 #include <vtkPointData.h>
25 #include <vtkPoints.h>
28 #include <TClassTable.h>
29 #include <TDataMember.h>
45 vtkCPDataDescription* data_description) {
48 if (param->export_visualization) {
49 data_.resize(tinfo->GetMaxThreads());
53 #pragma omp parallel for schedule(static, 1)
54 for (uint64_t i = 0; i <
data_.size(); ++i) {
55 data_[i] = vtkUnstructuredGrid::New();
59 if (!param->export_visualization) {
60 data_description->AddInput(type_name);
61 data_description->GetInputDescriptionByName(type_name)->SetGrid(
data_[0]);
65 auto* tmp_instance =
static_cast<Agent*
>(
tclass_->New());
66 shape_ = tmp_instance->GetShape();
67 std::vector<std::string> data_members;
71 tclass_, data_members,
"CreateVtkDataArrays",
72 [](
const std::string& functor_name,
73 const std::vector<TDataMember*>& tdata_members) {
74 std::stringstream sstr;
75 sstr <<
"namespace bdm {\n\n"
76 <<
"struct R__CLING_PTRCHECK(off) " << functor_name
77 <<
" : public Functor<void, VtkAgents*, int> {\n"
78 <<
" void operator()(VtkAgents* agent_grid, int tid) {\n";
80 for (
auto* tdm : tdata_members) {
84 sstr <<
"{ CreateVtkDataArray<" << tdm->GetClass()->GetName() <<
", "
85 << tdm->GetTypeName() <<
">f; f("
86 <<
"tid, \"" << tdm->GetName() <<
"\", " << tdm->GetOffset()
87 <<
", agent_grid); }\n";
92 sstr <<
"} // namespace bdm\n";
98 for (uint64_t i = 0; i <
data_.size(); ++i) {
99 (*create_functor)(
this, i);
101 delete create_functor;
107 for (
auto& el :
data_) {
125 if (param->export_visualization) {
129 auto tid = tinfo->GetMyThreadId();
130 auto max_threads = tinfo->GetMaxThreads();
133 auto correction = agents->size() % max_threads == 0 ? 0 : 1;
134 auto chunk = agents->size() / max_threads + correction;
135 auto start = tid * chunk;
136 auto end = std::min(agents->size(), start + chunk);
151 writer(sim->GetOutputDir(), filename_prefix,
data_);
156 const std::vector<Agent*>* agents,
157 uint64_t start, uint64_t end) {
159 data_[tid]->GetPoints()->GetData());
160 parray->
Update(agents, start, end);
161 auto* point_data =
data_[tid]->GetPointData();
162 for (
int i = 0; i < point_data->GetNumberOfArrays(); i++) {
165 array->
Update(agents, start, end);
172 if (tclass_vector.size() == 0) {
175 }
else if (tclass_vector.size() == 0) {
176 std::stringstream str;
177 for (
auto& tc : tclass_vector) {
178 str << tc->GetName() << std::endl;
181 Concat(
"Found multiple classes with name : ",
name_,
182 ". See list below. Fix this issue by adding a namespace "
187 return tclass_vector[0];
192 const Agent* agent, std::vector<std::string>* data_members)
const {
195 for (
auto& dm : param->visualize_agents.at(
name_)) {
198 data_members->resize(dm_set.size());
199 std::copy(dm_set.begin(), dm_set.end(), data_members->begin());