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

Hello,

I am trying to generate a high resolution mesh (dx = 2 um) with mesher, but the terminal output shows a negative number of tetrahedra. When I run it in a simulation, I get "std::bad_array_new_length" errors. Is there anything that can be done to get around this? 

This is my mesher script:

/u1/jav630/Jan10_openCARP-Actors/openCARP-Actors/environment_setup/openCARP/_build/bin/mesher \
-size[0] 0.1444 \
-size[1] 0.2604 \
-size[2] 0.159 \
-bath[0] -0.0 \
-bath[1] -0.0 \
-bath[2] -0.0 \
-center[0] 0.0722 \
-center[1] 0.1302 \
-center[2] 0.0795 \
-resolution[0] 2.0 \
-resolution[1] 2.0 \
-resolution[2] 2.0 \
-mesh 2024-08-01_Fine/block \
-Elem3D 0 \
-fibers.rotEndo 0.0 \
-fibers.rotEpi 0.0 \
-fibers.sheetEndo 90.0 \
-fibers.sheetEpi 90.0 \
-periodic 0 \
-periodic_tag 1234 \
-perturb 0.0

Please let me know if further information is required.

Thank you!

Joyce 

1 Answer

0 votes
by (19.2k points)
Mesher is a rather simple tool for generating small meshes on the fly. I don't think it's suitable for generating meshes with >3 billion elements.

https://gmsh.info might be a good option here.
by (120 points)
Hi Moritz, thank you for your reply. In your testing did you try --dx 2 yet? If not, could you please try this value? The mesh and stimulus do work for all dx values greater than this, but I am interested in a resolution of 0.002 mm.
by (120 points)
However, since I can't get any resolution working from an external mesh, I guess either way it makes sense to share the opencarp mesh files with you. Where can I send it?
by (220 points)
Sorry for the delayed response. The problem is within the conversion of gmsh to openCARP readable mesh.

There are two ways which fixed the issue for me you could try:
1) you open the file with gmsh and add a volume "Physical groups" -> "Geometry" -> "Physical groups" -> "Add" -> "Volume" by clicking on the volume before you safe the mesh as vtk-file.

2) use a short bash script:
GMSH="/opt/homebrew/bin/gmsh"
$GMSH -parse_and_exit bidomain_005cm3.geo
sed -i 's/CellEntityIds/elemTags/g' bidomain_005cm3.vtk
meshtool convert -imsh=bidomain_005cm3.vtk -omsh=bidomain_005cm3 -ofmt=carp_txt

The mesh name is given by the path to your mesh files:
meshname = 'meshes/test/bidomain_005cm3'

After the conversion of the gmsh file you need to adjust your run.py and set the:
IntraTags = [27] and ExtraTags = [27]. This is the default, which is set if you add a volume the gmsh geometry.

I hope this solves the problem.
by (120 points)
Hi Moritz, thank you for the response. After following those two steps, the test mesh (dx 100um) is working with openCARP now!

I am unfortunately having issues now with generating my original mesh in Gmsh, which has a dx of 2um.  At the start of this thread, Axel had suggested I use Gmsh because Mesher could not handle large meshes, however, despite using Gmsh, the process keeps getting killed. I am not sure if you can help with this as Gmsh is outside of your domain. If you happen to have any suggestions though, please let me know!

Either way, thanks again for your help.
by (120 points)

Hi Moritz and all,

I have been working on this problem again recently, and was able to get the mesh generated with Gmsh and converted to VTK format, but am now having troubles with the last step involving meshtool (i.e. the bash script that was recommended a few comments back). A standard mesh res works fine with the suggested method, but when I switch to a fine resolution (dx=2um), the script gives me this error:

Reading vtk file v.2.0 (3):                            [====        ] 00h:00m:39s ETA terminate called after throwing an instance of 'std::bad_array_new_length'

  what():  std::bad_array_new_length

Aborted (core dumped)

As an example, here is my .geo file

//bidomain_001cm3.geo
//Dimensions all in micrometres
lc = 2; //dx = 100um
Lx = 872;
Ly = 1308;
Lz = 892;
 
Point(1) = {-Lx/2, -Ly/2, -Lz/2, lc};
Point(2) = {-Lx/2, Ly/2, -Lz/2, lc};
Point(3) = {Lx/2, Ly/2, -Lz/2, lc};
Point(4) = {Lx/2, -Ly/2, -Lz/2, lc};
 
Point(5) = {-Lx/2, -Ly/2, Lz/2, lc};
Point(6) = {-Lx/2, Ly/2, Lz/2, lc};
Point(7) = {Lx/2, Ly/2, Lz/2, lc};
Point(8) = {Lx/2, -Ly/2, Lz/2, lc};
 
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
 
Curve Loop(1) = {1, 2, 3, 4};
 
Plane Surface(1) = {1};
 
Extrude {0,0,Lz} {Surface{1};}
 
Physical Volume(27) = {1}; //Ensure IntraTags = [27] and ExtraTags = [27] in openCARP script

which I convert to msh form with 

gmsh -3 bidomain_001cm3.geo 

and then to vtk with 

gmsh - bidomain_001cm3.msh -o bidomain_001cm3.vtk -format vtk -save

and then run the suggested bash script to get a mesh in the final openCARP format. I am using Gmsh version 4.8.4.

Any ideas or advice you have are greatly appreciated! 

Thank you,

Joyce

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
...