Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/GMGPolar/gmgpolar.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ class GMGPolar : public IGMGPolar
/* Visualization */
public: // Public due to cuda restrictions
void writeToVTK(const std::filesystem::path& file_path, const PolarGrid& grid);

private:
void writeToVTK(const std::filesystem::path& file_path, const LevelType& level,
HostConstVector<double> grid_function);
};
Expand Down
26 changes: 19 additions & 7 deletions include/GMGPolar/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::writeToVTK(const std:
Fx(index) = domain_geometry.Fx(r, theta);
Fy(index) = domain_geometry.Fy(r, theta);
});
HostVector<double> Fx_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), Fx);
Comment thread
julianlitz marked this conversation as resolved.
HostVector<double> Fy_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), Fy);
for (int index = 0; index < grid.numberOfNodes(); index++) {
file << Fx(index) << " " << Fy(index) << " " << 0 << "\n";
file << Fx_h(index) << " " << Fy_h(index) << " " << 0 << "\n";
}
file << "</DataArray>\n"
<< "</Points>\n";
Expand Down Expand Up @@ -280,13 +282,23 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::writeToVTK(const std:
// Write points
file << "<Points>\n"
<< "<DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">\n";
int i_r, i_theta;
double r, theta;
Vector<double> Fx("Fx", grid.numberOfNodes());
Vector<double> Fy("Fy", grid.numberOfNodes());
const DomainGeometry& domain_geometry = domain_geometry_;
Kokkos::parallel_for(
"collect Fx,Fy", Kokkos::RangePolicy<Kokkos::DefaultExecutionSpace>(0, grid.numberOfNodes()),
KOKKOS_LAMBDA(int index) {
int i_r, i_theta;
grid.multiIndex(index, i_r, i_theta);
double r = grid.radius(i_r);
double theta = grid.theta(i_theta);
Fx(index) = domain_geometry.Fx(r, theta);
Fy(index) = domain_geometry.Fy(r, theta);
});
HostVector<double> Fx_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), Fx);
HostVector<double> Fy_h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), Fy);
for (int index = 0; index < grid.numberOfNodes(); index++) {
grid.multiIndex(index, i_r, i_theta);
r = grid.radius(i_r);
theta = grid.theta(i_theta);
file << domain_geometry_.Fx(r, theta) << " " << domain_geometry_.Fy(r, theta) << " " << 0 << "\n";
file << Fx_h(index) << " " << Fy_h(index) << " " << 0 << "\n";
}

file << "</DataArray>\n"
Expand Down
Loading