First time here? Checkout the FAQ!
x
0 votes
by (150 points)
I'm guessing it's because my mesh might not be correctly defined as a Block. It throws an assertion error. I'm just trying to run the example experiments using my own mesh. How can I make this work?

This is the error - Traceback (most recent call last):
  File "/home/diya/Documents/openCARP/external/experiments/tutorials/02_EP_tissue/00_simple/./run.py", line 179, in <module>
    run()
  File "/usr/local/lib/python3.10/dist-packages/carputils/tools.py", line 547, in wrapped
    ret = run(args, job)
  File "/home/diya/Documents/openCARP/external/experiments/tutorials/02_EP_tissue/00_simple/./run.py", line 101, in run
    geom = mesh.generate(meshname)
  File "/usr/local/lib/python3.10/dist-packages/carputils/mesh/generate.py", line 65, in generate
    assert isinstance(geom, Block), 'generate only works with Block for now'
AssertionError: generate only works with Block for now.

1 Answer

+1 vote
by (19.1k points)

Lines 89 to 98 of the basic example are only relevant if you want to generate a simple block mesh on the fly: https://git.opencarp.org/openCARP/experiments/-/blob/master/tutorials/02_EP_tissue/00_simple/run.py#L86

If you want to load an existing mesh instead, remove those lines and load it by just passing the meshname parameter to the simulator as for example done here: https://git.opencarp.org/openCARP/experiments/-/blob/master/tutorials/02_EP_tissue/21_reentry_induction/run.py#L516

by (150 points)
edited by
I really appreciate the quick response. This is my code.
def run(args, job):
    # Path to your mesh file
    meshname = "/home/diya/Documents/openCARP/external/experiments/tutorials/02_EP_tissue/00_simple/atrial"
    

    # Load the mesh
    #geom = mesh.load(meshname)

    # Get basic command line, including solver options from external .par file
    cmd = tools.carp_cmd(tools.simfile_path(os.path.join(EXAMPLE_DIR, 'simple.par')))
    
    # Attach electrophysiology physics (monodomain) to mesh region with tag 1
    cmd += tools.gen_physics_opts(IntraTags=[1])

    cmd += ['-simID',    job.ID,
            '-meshname', meshname,
            '-tend',     args.tend]

    # Set monodomain conductivities
    cmd += ['-num_gregions',         1,
            '-gregion[0].name',     "myocardium",
            '-gregion[0].num_IDs',  1,
            '-gregion[0].ID',       "1",
            '-gregion[0].g_el',     0.625,
            '-gregion[0].g_et',     0.236,
            '-gregion[0].g_en',     0.236,
            '-gregion[0].g_il',     0.174,
            '-gregion[0].g_it',     0.019,
            '-gregion[0].g_in',     0.019,
            '-gregion[0].g_mult',   0.5]

    # Define the ionic model to use
    cmd += ['num_imp_regions',      1,
            'imp_region[0].im',     'Courtemanche',
            'imp_region[0].num_IDs',1,
            'imp_region[0].ID[0]',  1]

    # Define the geometry of the stimulus directly in the command line
    # Replace with your specific stimulus location and parameters
    cmd += ['-stimulus', 'x', '0', '100', '0', '1']

    if args.visualize:
        cmd += ['-gridout_i', 3]    # output both surface & volumetric mesh for visualization

    # Run simulation
    job.carp(cmd)

    # Do visualization
    if args.visualize and not settings.platform.BATCH:
        geom = os.path.join(job.ID, os.path.basename(meshname)+'_i')
        data = os.path.join(job.ID, 'vm.igb.gz')
        view = tools.simfile_path(os.path.join(EXAMPLE_DIR, 'simple.mshz'))
        job.meshalyzer(geom, data, view)
I have converted my vtk file into .elem,.pts,.lon files. But it wont open on my meshalyzer. Could you please help me out?
This is the error I'm getting -
*** Unrecognized keyword stim[0].num_IDs

 
*** Error reading parameters

Error: 2024-07-01_simple_100.0_petsc_np1/vm.igb.gz does not exist!
#-------------------------------------------------------------------------------
#                             Launching Meshalyzer
#-------------------------------------------------------------------------------

/usr/local/bin/meshalyzer/meshalyzer \
  2024-07-01_simple_100.0_petsc_np1/atrial_i \
  2024-07-01_simple_100.0_petsc_np1/vm.igb.gz \
  /home/diya/Documents/openCARP/external/experiments/tutorials/02_EP_tissue/00_simple/./simple.mshz

Error: could not open /home/diya/Documents/openCARP/external/experiments/tutorials/02_EP_tissue/00_simple/atrial.elem.pts for reading! Reason:
No such file or directory
Unable to read proper points file
/usr/local/bin/meshalyzer/meshalyzer failed with error code 1
by (19.1k points)
We can probably have a look if you add a link to your original and converted mesh files
by (19.1k points)
There are unsupported elements in your mesh. How did you create it?
by (150 points)
I had a vtk file that I converted into elem,pts,lion files using the meshtool command.
by (19.1k points)
My guess is that the VTK file did not only contain triangles and tetrahedra but also other types of elements
by (150 points)
Ah makes sense. How can I go forward with this?
by (150 points)
Also, are there any atrial meshes available that I could use?  
Does opencarp not support other types of elements?
by (19.1k points)
This depends on your meshing tool etc. While unrelated to openCARP, you can for example have a look at the Tetrahedralize and Triangulate filters in ParaView.

For meshes etc., the collection of community-sourced modeling resources can be a good starting point: https://opencarp.org/community/modeling-resources
by (150 points)
edited by
Got the mesh working. Thanks so much!
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
MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], config: ["MMLorHTML.js"], jax: ["input/TeX"], processEscapes: true } }); MathJax.Hub.Config({ "HTML-CSS": { linebreaks: { automatic: true } } });
...