tsimulation.c: set float format for VTK export in header - granular - granular … | |
git clone git://src.adamsgaard.dk/granular | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 30537b9a4c16e1f9607e2f95a106420e0452c93a | |
parent ec6f6cd1eda3c204e5ea43df9f48d2ccc612bd17 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 25 Mar 2021 19:44:12 +0100 | |
simulation.c: set float format for VTK export in header | |
Diffstat: | |
M simulation.c | 42 ++++++++++++++++-------------… | |
1 file changed, 22 insertions(+), 20 deletions(-) | |
--- | |
diff --git a/simulation.c b/simulation.c | |
t@@ -7,6 +7,8 @@ | |
#include "arrays.h" | |
#include "util.h" | |
+#define VTK_FLOAT_FMT "%.17g" | |
+ | |
#define VTK_XML_SCALAR(M, N, T, F) \ | |
fprintf(stream,\ | |
"\t\t\t\t<DataArray type=\"" T "\" Name=\"" N "\" "\ | |
t@@ -100,7 +102,7 @@ print_grains_vtk(FILE *stream, const struct grain *grains,… | |
"NumberOfComponents=\"3\" format=\"ascii\">\n"); | |
for (i = 0; i < n; i++) | |
for (d = 0; d < 3; d++) | |
- fprintf(stream, "%.17g ", grains[i].pos[d]); | |
+ fprintf(stream, VTK_FLOAT_FMT, grains[i].pos[d]); | |
fprintf(stream, "\n"); | |
fprintf(stream, | |
"\t\t\t\t</DataArray>\n" | |
t@@ -124,34 +126,34 @@ print_grains_vtk(FILE *stream, const struct grain *grain… | |
"\t\t\t\t<DataArray type=\"Float64\" Name=\"Diameter [m]\" " | |
"NumberOfComponents=\"1\" format=\"ascii\">\n"); | |
for (i = 0; i < n; i++) | |
- fprintf(stream, "%.17g ", grains[i].radius * 2.0); | |
+ fprintf(stream, VTK_FLOAT_FMT, grains[i].radius * 2.0); | |
fprintf(stream, | |
"\n" | |
"\t\t\t\t</DataArray>\n"); | |
- VTK_XML_VECTOR(vel, "Velocity [m/s]", "Float64", "%.17g "); | |
- VTK_XML_VECTOR(acc, "Acceleration [m/s^2]", "Float64", "%.17g "); | |
- VTK_XML_VECTOR(force, "Force [N]", "Float64", "%.17g "); | |
- VTK_XML_VECTOR(angpos, "Angular position [rad]", "Float64", "%.17g "); | |
- VTK_XML_VECTOR(angvel, "Angular velocity [rad/s]", "Float64", "%.17g "… | |
- VTK_XML_VECTOR(angacc, "Angular acceleration [rad/s^2]", "Float64", "%… | |
- VTK_XML_VECTOR(torque, "Torque [N/m]", "Float64", "%.17g "); | |
- VTK_XML_VECTOR(disp, "Displacement [m]", "Float64", "%.17g "); | |
- VTK_XML_VECTOR(forceext, "External body force [N]", "Float64", "%.17g … | |
- VTK_XML_SCALAR(density, "Density [kg/m^3]", "Float64", "%.17g "); | |
+ VTK_XML_VECTOR(vel, "Velocity [m/s]", "Float64", VTK_FLOAT_FMT); | |
+ VTK_XML_VECTOR(acc, "Acceleration [m/s^2]", "Float64", VTK_FLOAT_FMT); | |
+ VTK_XML_VECTOR(force, "Force [N]", "Float64", VTK_FLOAT_FMT); | |
+ VTK_XML_VECTOR(angpos, "Angular position [rad]", "Float64", VTK_FLOAT_… | |
+ VTK_XML_VECTOR(angvel, "Angular velocity [rad/s]", "Float64", VTK_FLOA… | |
+ VTK_XML_VECTOR(angacc, "Angular acceleration [rad/s^2]", "Float64", VT… | |
+ VTK_XML_VECTOR(torque, "Torque [N/m]", "Float64", VTK_FLOAT_FMT); | |
+ VTK_XML_VECTOR(disp, "Displacement [m]", "Float64", VTK_FLOAT_FMT); | |
+ VTK_XML_VECTOR(forceext, "External body force [N]", "Float64", VTK_FLO… | |
+ VTK_XML_SCALAR(density, "Density [kg/m^3]", "Float64", VTK_FLOAT_FMT); | |
VTK_XML_SCALAR(fixed, "Fixed [-]", "Int64", "%d "); | |
VTK_XML_SCALAR(rotating, "Rotating [-]", "Int64", "%d "); | |
VTK_XML_SCALAR(enabled, "Enabled [-]", "Int64", "%d "); | |
- VTK_XML_SCALAR(youngs_modulus, "Young's modulus [Pa]", "Float64", "%.1… | |
- VTK_XML_SCALAR(poissons_ratio, "Poisson's ratio [-]", "Float64", "%.17… | |
- VTK_XML_SCALAR(friction_coeff, "Friction coefficient [-]", "Float64", … | |
- VTK_XML_SCALAR(tensile_strength, "Tensile strength [Pa]", "Float64", "… | |
- VTK_XML_SCALAR(shear_strength, "Shear strength [Pa]", "Float64", "%.17… | |
- VTK_XML_SCALAR(fracture_toughness, "Fracture toughness [Pa]", "Float64… | |
+ VTK_XML_SCALAR(youngs_modulus, "Young's modulus [Pa]", "Float64", VTK_… | |
+ VTK_XML_SCALAR(poissons_ratio, "Poisson's ratio [-]", "Float64", VTK_F… | |
+ VTK_XML_SCALAR(friction_coeff, "Friction coefficient [-]", "Float64", … | |
+ VTK_XML_SCALAR(tensile_strength, "Tensile strength [Pa]", "Float64", V… | |
+ VTK_XML_SCALAR(shear_strength, "Shear strength [Pa]", "Float64", VTK_F… | |
+ VTK_XML_SCALAR(fracture_toughness, "Fracture toughness [Pa]", "Float64… | |
VTK_XML_VECTOR(gridpos, "Grid position [-]", "UInt64", "%zu "); | |
VTK_XML_SCALAR(ncontacts, "Number of contacts [-]", "UInt64", "%zu "); | |
- VTK_XML_VECTOR(contact_stress, "Contact stress [Pa]", "Float64", "%.17… | |
- VTK_XML_SCALAR(thermal_energy, "Thermal energy [J]", "Float64", "%.17g… | |
+ VTK_XML_VECTOR(contact_stress, "Contact stress [Pa]", "Float64", VTK_F… | |
+ VTK_XML_SCALAR(thermal_energy, "Thermal energy [J]", "Float64", VTK_FL… | |
VTK_XML_SCALAR(color, "Color [-]", "Int64", "%d "); | |
fprintf(stream, "\t\t\t</PointData>\n"); |