From 4ff044e2ba8d04607e7138cea309cadf2d3e260d Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 26 Oct 2023 14:50:58 -0400 Subject: [PATCH] curve_to_vtk now accept additional data. added a print method for Weights --- src/simsopt/geo/curve.py | 8 ++++++-- src/simsopt/objectives/utilities.py | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/simsopt/geo/curve.py b/src/simsopt/geo/curve.py index 69b0d3da5..4e65abb2f 100644 --- a/src/simsopt/geo/curve.py +++ b/src/simsopt/geo/curve.py @@ -817,7 +817,7 @@ def flip(self): return True if self.rotmat[2][2] == -1 else False -def curves_to_vtk(curves, filename, close=False): +def curves_to_vtk(curves, filename, close=False, pointData=None): """ Export a list of Curve objects in VTK format, so they can be viewed using Paraview. This function requires the python package ``pyevtk``, @@ -844,7 +844,11 @@ def wrap(data): z = np.concatenate([c.gamma()[:, 2] for c in curves]) ppl = np.asarray([c.gamma().shape[0] for c in curves]) data = np.concatenate([i*np.ones((ppl[i], )) for i in range(len(curves))]) - polyLinesToVTK(str(filename), x, y, z, pointsPerLine=ppl, pointData={'idx': data}) + + if pointData is None: + pointData=dict() + pointData['idx'] = data + polyLinesToVTK(str(filename), x, y, z, pointsPerLine=ppl, pointData=pointData) def create_equally_spaced_curves(ncurves, nfp, stellsym, R0=1.0, R1=0.5, order=6, numquadpoints=None): diff --git a/src/simsopt/objectives/utilities.py b/src/simsopt/objectives/utilities.py index 8e63954ff..7556e02c6 100644 --- a/src/simsopt/objectives/utilities.py +++ b/src/simsopt/objectives/utilities.py @@ -151,3 +151,6 @@ def __float__(self): def __imul__(self, alpha): self.value *= alpha return self + + def __str__(self): + return f"{self.value}"