# How to get geometry from existing mesh

Hi,

I have read a mesh file (opencarp format) using

meshname = "myMeshPath"

But when I want to define an electrode for a stimulation, the code was something like

electrode = mesh.block_region(geom,'stimulus', 0, E1_lower_bound, E1_upper_bound, False)

geom should be the geometry of the mesh, but how could I get the geometry from the mesh model I just read?

Thanks

by (12.1k points)

The method you are using only works on block meshes. Details are given in the documentation:

https://opencarp.org/documentation/carputils-documentation#master/classcarputils_1_1mesh_1_1block_1_1Block.html

For more complex methods, the stimulus class provides more flexibility:

https://opencarp.org/documentation/carputils-documentation#master/classcarputils_1_1model_1_1stimulus_1_1Stimulus.html

by (380 points)
If possible, could you provide an example on how to use it?
by (380 points)
But in the reentry induction example, isn't the sinus node still defined by this block_boundary_condition function that only works with block meshes? How could I set the electrode or the sinus node on non-block meshes?
by (12.1k points)
Yes, it is.
You can set almost arbitrary stimuli by directly using openCARP's Stim parameter group as done on the part of the reentry example referred to above:
https://git.opencarp.org/openCARP/carputils/-/blob/master/carputils/model/induceReentry.py#L602

Stim is described in Section 23.3 of the openCARP manual:
https://opencarp.org/documentation/user-manual

by (380 points)
I tied to use the Stim parameter group parameters yet I still received the error L5 : error: Empty stimulus[0] electrode def! Aborting!

stim = ['-num_stim', 1,
'-stimulus[0].stimtype', 0,
'-stimulus[0].strength', 120.0,
'-stimulus[0].duration', 2.0,
'-stimulus[0].start', 0,
'-stimulus[0].x0', 2100,
'-stimulus[0].xd', 32000,
'-stimulus[0].y0', 2100,
'-stimulus[0].yd', 310,
'-stimulus[0].z0', 2100,
'-stimulus[0].zd', 4200,
'-stimulus[0].npls', 1,
'-stimulus[0].ctr_def',1,
'-stim[0].elec.dump_vtx_file',0,
'-stim[0].elec.geom_type',5,
'-stim[0].elec.geomID', 0,
'-stim[0].elec.p0[0]', 1,
'-stim[0].elec.p0[1]', 1,
'-stim[0].elec.p0[2]', 1,
'-floating_ground', 1]

Would you mind letting me know where this error message was defined so I could check what exactly is wrong with it? Or perhaps if you have any suggestions on how to fix such problem?

I saw on another q&a posts that this error message could have something to do with ExtraTags and IntraTags, but not sure how it was relevant, could you help me clear that up? Thanks