# CGX on Windows can not generate tetrahedral

**URL:** <https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757>\
**Category:** CalculiX GraphiX\
**Created:** [August 8, 2023, 12:02am UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757 "2023-08-08T00:02:34Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 8, 2023, 12:02am UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/1 "2023-08-08T00:02:34Z")

</div>

hi,

i receive some error messages when using Tetgen mesher in CGX, try add path to environmental variable still did not work.

any hints and suggestion?

```auto
 Tet-mesh body:B052

+surf:S038
+surf:S040
+surf:S046
-surf:S048
-surf:S034
+surf:S044
The system cannot find the batch label specified - tetgen
 Try to read TG file

 reading Tetgen format
 MODEL NAME: mesh.1ERROR: The input file "mesh.1.node" could not be opened.

```

---

<div class="post-metadata">

**Author:** ![rsmith](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/rsmith/32/1684_2.png) [@rsmith](https://calculix.discourse.group/u/rsmith)\
**Post date:** [August 9, 2023, 10:21pm UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/2 "2023-08-09T22:21:48Z")

</div>

> [@xyont](#):
>
> `The input file "mesh.1.node" could not be opened.`

Has this file actually been created in the directory you’re calling `cgx` from?

---

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 10, 2023, 7:58am UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/3 "2023-08-10T07:58:45Z")

</div>

thank you for looking into my problems, no file is created.

input of \*fbd file,

```auto

valu ldiv 10

pnt P01 0.00 100.00 0.00
pnt P02 0.00 0.00 0.00
pnt P03 100.00 100.00 0.00
pnt P04 100.00 0.00 0.00
pnt P05 0.00 100.00 100.00
pnt P06 0.00 0.00 100.00
pnt P07 100.00 0.00 100.00
pnt P08 100.00 100.00 100.00

line L01 P01 P02 ldiv
line L02 P03 P01 ldiv
line L03 P04 P03 ldiv
line L04 P02 P04 ldiv
line L05 P05 P06 ldiv
line L06 P06 P07 ldiv
line L07 P07 P08 ldiv
line L08 P08 P05 ldiv
line L09 P02 P06 ldiv
line L010 P01 P05 ldiv
line L011 P03 P08 ldiv
line L012 P04 P07 ldiv

seta A013 l L01 L02 L03 L04 
surf S014 A013 
seta A015 l L05 L06 L07 L08 
surf S016 A015 
seta A017 l L01 L09 L05 L010 
surf S018 A017 
seta A019 l L02 L010 L08 L011 
surf S020 A019 
seta A021 l L03 L011 L07 L012 
surf S022 A021 
seta A023 l L04 L012 L06 L09 
surf S024 A023 

seta V025 s S014 S016 S018 S020 S022 S024 
body B026 V025 

plot ba all

elty all te10
mesh all

```

CGX output logs reported,

```auto
>"C:\PROGRA~2\BCONVE~1\CalculiX\bin\cgx.bat" -b "04exp.fbd"
on a Windows 7 machine, nodename USER-PC, release 6, version 6.1 Service Pack 1 7601, machine 601 
 The win HOME was detected:C:\Users\user
parameters:3 arguments:2
GL_MAX_EVAL_ORDER:32, mesh threads:1
 04exp.fbd opened

 reading file
create surf: S014 + BLEND + L01 + L02 + L03 + L04
create surf: S016 + BLEND + L05 + L06 + L07 + L08
create surf: S018 + BLEND + L01 + L05 + L09 + L010
create surf: S020 + BLEND + L02 + L08 + L010 + L011
create surf: S022 + BLEND + L03 + L07 + L011 + L012
create surf: S024 + BLEND + L04 + L06 + L09 + L012
 please wait for 'ready'

shape:H001 H001 0
shape:H002 H002 2
shape:H003 H003 4
shape:H004 H004 6
shape:H005 H005 8
shape:H006 H006 10

surf:S014 NURBS:N001 patch0
surf:S016 NURBS:N002 patch0
surf:S018 NURBS:N003 patch0
surf:S020 NURBS:N004 patch0
surf:S022 NURBS:N005 patch0
surf:S024 NURBS:N006 patch0

 Tet-mesh body:B026

+surf:S014
+surf:S016
+surf:S022
-surf:S024
+surf:S018
+surf:S020
 Try to read TG file

 reading Tetgen format
 MODEL NAME: mesh.1ERROR: The input file "mesh.1.node" could not be opened.

-surf:S014
-surf:S016
-surf:S022
+surf:S024
-surf:S018
-surf:S020
 Try to read TG file

 reading Tetgen format
 MODEL NAME: mesh.1ERROR: The input file "mesh.1.node" could not be opened.

ERROR: No mesh-file found

 ERROR: No tet-mesh could be created for body:B026
  The temporary surface mesh is not deleted and can be used for debugging.
 The files nodnr_ng_cgx.out elemnr_ng_cgx.out provide the link between ng and cgx entity numbers.
 makeSurfaces
 getElemNormalen
 realloc_colNr
 add the faces
 updateDispLists
 delSet
 ready
 done 

gtol calculated:1.000000e-03

```

---

<div class="post-metadata">

**Author:** ![rsmith](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/rsmith/32/1684_2.png) [@rsmith](https://calculix.discourse.group/u/rsmith)\
**Post date:** [August 11, 2023, 12:12pm UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/4 "2023-08-11T12:12:51Z")

</div>

**Tl;dr:**

1. Locate the `tetgen` binary. (I suspect it is in `C:\PROGRA~2\BCONVE~1\CalculiX\bin`)
2. Edit the environment variable `Path`, and add the location of the `tetgen` binary.

* * *

On my machine (FreeBSD 13.2, CalculiX 2.21) I could run your `fbd` file just fine.

So I looked into what `cgx` was doing using the `truss(1)` program that tells me what system calls are being used. What I saw was that `cgx` reads the input, writes some files and searches for and then calls the `tetgen` program. Now `tetgen` produces a bunch of output. Later `cgx` writes its own output.

When I run your example, I see the output from `tetgen` that is missing from your output;

> Opening mesh.smesh.  
> Delaunizing vertices…  
> Delaunay seconds: 0  
> Creating surface mesh …  
> Surface mesh seconds: 0  
> Recovering boundaries…  
> Boundary recovery seconds: 0  
> Removing exterior tetrahedra …  
> Exterior tets removal seconds: 0  
> Recovering Delaunayness…  
> Delaunay recovery seconds: 0  
> Refining mesh…  
> Refinement seconds: 0  
> Optimizing mesh…  
> Optimization seconds: 0
> 
> Writing mesh.1.node.  
> Writing mesh.1.ele.  
> Writing mesh.1.face.  
> Writing mesh.1.edge.
> 
> Output seconds: 0  
> Total running seconds: 0
> 
> Statistics:
> 
> Input points: 128  
> Input facets: 252  
> Input segments: 378  
> Input holes: 0  
> Input regions: 0
> 
> Mesh points: 129  
> Mesh tetrahedra: 303  
> Mesh faces: 732  
> Mesh faces on exterior boundary: 252  
> Mesh faces on input facets: 252  
> Mesh edges on input segments: 378  
> Steiner points inside domain: 1

Since your `cgx` run cannot find the _output file_ that `tetgen` should have produced, and since the output from `tetgen` isn’t shown, I suspect that (a) `cgx` either did not find `tetgen` or (b) that the `tetgen` run failed in some way.  
Since there is no `tetgen` output at all, (a) seems more likely.

Looking at the source code of `cgx`, the way it calls `tetgen` _requires_ that the directory where the `tetgen` binary can be found in the `Path` environment variable.

So;

1. Locate the `tetgen` binary. (I suspect it is in `C:\PROGRA~2\BCONVE~1\CalculiX\bin`)
2. Edit the environment variable `Path`, and add the location of the `tetgen` binary.

---

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 11, 2023, 12:58pm UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/5 "2023-08-11T12:58:48Z")

</div>

thanks for test and reporting, it seems another possible reason in `tetgen` not working properly since both steps you suggested still not work.

prpbably in \*.bat file of cmdStartup files setting by bConverged need to modify, but i did not know how.

```auto
@echo off

rem Modify this file to change your startup settings for the CalculiX command window.

set CYGWIN=nodosfilewarning
set PRINTF_EXPONENT_DIGITS=2
set VERSION=2.21
set HOME=C:\Users\user\DOWNLO~1
set CALCULIX_ROOT=C:\PROGRA~2\BCONVE~1
set PATH=%CALCULIX_ROOT%\CalculiX\bin;%CALCULIX_ROOT%\translation\bin;%CALCULIX_ROOT%\common\Python;%CALCULIX_ROOT%\gnuplot\bin;%PATH%

set CCX_NPROC_STIFFNESS=2
set CCXDOCS=ms-its:%CALCULIX_ROOT%\common\help\bConverged.chm::/ccx.pdf
set CGXDOCS=ms-its:%CALCULIX_ROOT%\common\help\bConverged.chm::/cgx.pdf
set CGXTERMVIEWER=start ""
set BROWSER=start "" hh.exe

set "arg=%~1"
if not defined arg goto startup
if /i %1==ccx goto ccx
if /i %1==cgx goto cgx
goto end

:ccx
:cgx
  "%CALCULIX_ROOT%\CalculiX\%~1\%~1.exe" %2 %3 %4 %5 %6
  goto end

:startup
  cd /d %HOME% ..
  cls
  advise usage
  goto end

:end

```

---

<div class="post-metadata">

**Author:** ![rsmith](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/rsmith/32/1684_2.png) [@rsmith](https://calculix.discourse.group/u/rsmith)\
**Post date:** [August 11, 2023, 8:48pm UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/6 "2023-08-11T20:48:53Z")

</div>

> [@xyont](#):
>
> it seems another possible reason in `tetgen` not working properly since both steps you suggested still not work.

Some questions;

1. Did you locate `tetgen.exe`?
2. And you put the location where it is in your `Path`?

Then open a `cmd` window, and type `tetgen -h<enter>`.

You should see the online help for `tetgen`. For me that starts like this:

> TetGen  
> A Quality Tetrahedral Mesh Generator and 3D Delaunay Triangulator  
> Version 1.5  
> August 18, 2018

If you get a message like this:

> ‘tetgen’ is not recognized as an internal or external command, operable program or batch file.

Then you did not put the correct location in the `Path`.  
Make sure that there are e.g. no extra spaces in the string that you added to the path!

If you get another error message, please report back what it is.

---

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 11, 2023, 9:40pm UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/7 "2023-08-11T21:40:58Z")

</div>

it seems the path was properly defined, but i still not known why TetGen failed to run in CGX

 ![2023-08-12 04_36_04-C__Windows_system32_cmd.exe](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/7/75f4cab6bd3a1058a96ebfbada95061b00a36a59.png)

---

<div class="post-metadata">

**Author:** ![rsmith](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/rsmith/32/1684_2.png) [@rsmith](https://calculix.discourse.group/u/rsmith)\
**Post date:** [August 11, 2023, 11:25pm UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/8 "2023-08-11T23:25:14Z")

</div>

You will probably have to close the `cmd` window from which you were running `cgx` and open a new one for it to pick up any change in `Path`.

If that doesn’t solve the problem, you will probably have to run `cgx` under some kind of debugger/system call tracer so you can see what happens when it tries to run `tetgen`. Since I’m not a windows user I cannot really advise you what to use here.

---

<div class="post-metadata">

**Author:** ![klaus.wittig](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@klaus.wittig](https://calculix.discourse.group/u/klaus.wittig)\
**Post date:** [August 12, 2023, 9:02am UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/9 "2023-08-12T09:02:03Z")

</div>

xyont, I just copied your code and run it. It worked on my (Linux) side. So it is indeed just an access problem. As a quick fix you could copy the tetgen program into your working folder (And maybe also cgx). And you could contact Rafal Brzegowy. His mail should be either written on [www.dhondt.de](http://www.dhondt.de) or in the README in his calculix\_for\_win package.

---

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 12, 2023, 2:49pm UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/10 "2023-08-12T14:49:01Z")

</div>

ok, I’ll try to contact It’s clearly shown related to specific Windows and predefined setting since not a problem on Linux.

---

<div class="post-metadata">

**Author:** ![klaus.wittig](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@klaus.wittig](https://calculix.discourse.group/u/klaus.wittig)\
**Post date:** [August 12, 2023, 7:36pm UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/11 "2023-08-12T19:36:32Z")

</div>

The call to tetgen happens in generateTet.cpp. It is a system call to ‘tetgen’ with some arguments:

sprintf(buffer, “tetgen -qYO%da%e mesh.smesh”,5, (teth/scale-\>w)_(teth/scale-\>w)_(teth/scale-\>w)/5.);  
system(buffer);

---

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 16, 2023, 7:57am UTC](https://calculix.discourse.group/t/cgx-on-windows-can-not-generate-tetrahedral/1757/12 "2023-08-16T07:57:29Z")

</div>

> [@klaus.wittig](#):
>
> As a quick fix you could copy the tetgen program into your working folder

Many thanks, it seems to be working. Some permission did not pass, but not a problem.

 ![2023-08-16 14_55_56-CalculiX GraphiX](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/d/d830cec92225bd0566ae6120809dddcab64e9e74.png)

```auto
prnt se
1 all stat:o n:682 e:299 f:252 p:0 l:0 c:0 s:0 b:0 L:0 S:0 se:0 sh:0 v:0
3 Nall stat:c n:682 e:0 f:0 p:0 l:0 c:0 s:0 b:0 L:0 S:0 se:0 sh:0 v:0
4 Eall stat:c n:0 e:299 f:0 p:0 l:0 c:0 s:0 b:0 L:0 S:0 se:0 sh:0 v:0
5 +C3D10 stat:c n:0 e:299 f:0 p:0 l:0 c:0 s:0 b:0 L:0 S:0 se:0 sh:0 v:0

```
