Skip to content

Commit

Permalink
curve_to_vtk now accept additional data. added a print method for Wei…
Browse files Browse the repository at this point in the history
…ghts
  • Loading branch information
abaillod committed Oct 26, 2023
1 parent cc03e2b commit 4ff044e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/simsopt/geo/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``,
Expand All @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions src/simsopt/objectives/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,6 @@ def __float__(self):
def __imul__(self, alpha):
self.value *= alpha
return self

def __str__(self):
return f"{self.value}"

0 comments on commit 4ff044e

Please sign in to comment.