22// it under the terms of the GNU General Public License as published by
33// the Free Software Foundation, either version 3 of the License, or
44// (at your option) any later version.
5-
65// This program is distributed in the hope that it will be useful,
76// but WITHOUT ANY WARRANTY; without even the implied warranty of
87// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98// GNU General Public License for more details.
10-
119// You should have received a copy of the GNU General Public License
1210// along with this program. If not, see <http://www.gnu.org/licenses/>.
1311
@@ -28,8 +26,14 @@ inline void SaveVTK(const std::vector<Particle>& p, const std::string& filename)
2826 out << " ASCII\n " ;
2927 out << " DATASET POLYDATA\n " ;
3028
29+ #ifdef NEXT_FP64
30+ constexpr const char * vtkType = " double" ;
31+ #elif defined(NEXT_FP32)
32+ constexpr const char * vtkType = " float" ;
33+ #endif
34+
3135 // draw points
32- out << " POINTS " << N << " float \n " ;
36+ out << " POINTS " << N << " " << vtkType << " \n " ;
3337 for (const auto & a : p)
3438 out << a.x << " " << a.y << " " << a.z << " \n " ;
3539
@@ -40,12 +44,14 @@ inline void SaveVTK(const std::vector<Particle>& p, const std::string& filename)
4044
4145 // that too
4246 out << " POINT_DATA " << N << " \n " ;
43- out << " VECTORS velocity float \n " ;
47+ out << " VECTORS velocity " << vtkType << " \n " ;
4448 for (const auto & a : p)
4549 out << a.vx << " " << a.vy << " " << a.vz << " \n " ;
4650
47- out << " SCALARS mass float 1\n " ;
51+ out << " SCALARS mass " << vtkType << " 1\n " ;
4852 out << " LOOKUP_TABLE default\n " ;
4953 for (const auto & a : p)
5054 out << a.m << " \n " ;
55+
56+ out.close ();
5157}
0 commit comments