First time here? Checkout the FAQ!
x
0 votes
by (140 points)

I generated my own paraboloid mesh using a python script [1] and saving it in .vtk format. I checked the shape of the mesh in Paraview and all seems correct.

Now I want to run a simulation on this mesh, so I converted it to carp_txt using meshtool:

meshtool convert -imsh=surface_mesh -ifmt=vtk -omsh=surface_mesh -ofmt=carp_txt

When I check the output .pts file, I notice that new vertices are created, that are far out of the original bounds of the mesh. the original mesh was situated in (x,y,z) \in [0,40]x[0,40]x[-0.05,20,05]. Some points however have the following coordinate:

0.000000 1.573437 272009238956254653579264.000000
0.000000 1.721875 272007851847569423466496.000000
0.000000 1.924219 -107374232.000000
0.000000 2.090625 -107374160.000000

...

So the z-coordinate is very far off for these points. I additionally do not manage to visualize the output mesh using meshalyzer.

My question is thus:

a) Why does this happen?
b) When trying to run a simulation [2] on this mesh, I get the error
L5 : error: Empty stimulus[0] electrode def! Aborting!
Would this be related to this weird effect in the carp_txt mesh or is something else going on?

For reference, here is

[1] the python script I used to generate the mesh

""" Creates paraboloid surface mesh with small thickness """

import numpy as np
import pyvista as pv

# Define the function for the surface
def surface_func(x, y):
    return -0.025*(x-20)**2 - 0.025*(y-20)**2 + 20

# Define grid points
x = np.arange(0, 40.1, 0.25)
y = np.arange(0, 40.1, 0.25)
X, Y = np.meshgrid(x, y)

# Calculate Z coordinates using the surface function
Z_top = surface_func(X, Y) + 0.05
Z_bottom = surface_func(X, Y) - 0.05

# Create PyVista meshes for the top and bottom surfaces
top_surface = pv.StructuredGrid(X, Y, Z_top)
bottom_surface = pv.StructuredGrid(X, Y, Z_bottom)

# Merge the two surfaces to create a thickened mesh
thickened_mesh = top_surface + bottom_surface

# Write the mesh to a VTK file
thickened_mesh.save('surface_mesh.vtk')

 

[2] the parameters of the stimulus

stim[0].name = "S1"
stim[0].crct.type = 0
stim[0].elec.geom_type = 2
stim[0].elec.p0[0] = 0.
stim[0].elec.p0[1] = 0.
stim[0].elec.p0[2] = 0.
stim[0].elec.p1[0] = 4.
stim[0].elec.p1[1] = 40.
stim[0].elec.p1[2] = 20.
stim[0].elec.dump_vtx_file = 1
stim[0].ptcl.stimlist = 0
stim[0].ptcl.duration = 1.0
stim[0].pulse.strength = 100.0

3 Answers

0 votes
ago by (3.6k points)
Hi Marie,

Could you please check whether your vtk file is ascii or binary? Meshtool support both type of files and you can specify it using -ifmt vtk (for ascii files) or -ifmt vtk_binary (for binary files).

Cheers,

Jorge
0 votes
ago by (180 points)
Dear Marie, meshtool has only very rudimentary VTK support, the VTK versions supported by meshtool are 3 and 5. The file written by pyvista is of version 5.1, that's why the meshtool convert call fails. Is it possible to specify the version of the output in pyvista?

Cheers, Matthias.
0 votes
ago by (180 points)
Dear Marie, I checked the VTK file written by pyvista. The version was not the problem, it was the data type of the points. We implicitly assume single precision values, but the data type of the values in the file written by pyvista was of double precision. I changed the code in meshtool accordingly.

Cheers, Matthias.
Welcome to openCARP Q&A. Ask questions and receive answers from other members of the community. For best support, please use appropriate TAGS!
architecture, carputils, documentation, experiments, installation-containers-packages, limpet, slimfem, website, governance
...