# controlling mesh density with netgen

Hi Everybody,

I am using netgen quite extensively for my work.

I am using the similar following script for generation of my model.

algebraic3d

# cube dimension

solid cube = plane (0, 0, 0; 0, 0, -1)
and plane (0, 0, 0; 0, -1, 0)
and plane (0, 0, 0; -1, 0, 0)
and plane (10, 10, 10; 0, 0, 1)
and plane (10, 10, 10; 0, 1, 0)
and plane (10, 10, 10; 1, 0, 0);

# sphere arrangement

solid sph = sphere (5.0, 5.0, 5.0; 2.0);

solid rest = cube and not sph;

tlo rest -transparent -col=[1,0,0] -maxh=0.52;
tlo sph -col=[0,0,1] -maxh=0.52;

#tlo cube -transparent -col=[1,0,0];
#tlo sph -col=[1,1,1];

Here, I can control mesh density globally by setting maxh value…
Now my question is that how can we control the mesh density at different region say at interface?
Any help would be appreciated. Thank you

Hi,

if you look at the documentation Netgen Tutorial: Mesh size, csg primitives can be given a local mesh size, e.g.,

[code]

# Set the mesh size on the sphere surface to 0.1

sphere = Sphere(Pnt(0,0,0),1).maxh(0.1)[/code]

Best wishes,
Henry

some more possibilities you find here:
https://ngsolve.org/docu/latest/i-tutorials/unit-4.2-csg/csg.html#Setting-the-mesh-size
Joachim

problem is I am only using netgen for generating mesh, not ngsolve. Can you suggest me some *-msz file example which I can use for sphereincube.geo file example (which I put for the main question), please?

Thanks

thank you but any idea of how I can do the same without ngsolve but simply netgen. What the syntax there for controlling local mesh density

its not a question of Netgen or NGSolve, but how to do it in pre-Python times:

have a look into Section 4.1:

Joachim

## 1 0.0 0.0 0.0 0.1 1 0.0 0.0 0.0 1.0 1.0 1.0 0.1

my np is 1 and my nl is also 1. This I used with the following *.geo file:

algebraic3d

# cube consisting of 6 planes:

solid cube = plane (0, 0, 0; 0, 0, -1)
and plane (0, 0, 0; 0, -1, 0)
and plane (0, 0, 0; -1, 0, 0)
and plane (1, 1, 1; 0, 0, 1)
and plane (1, 1, 1; 0, 1, 0)
and plane (1, 1, 1; 1, 0, 0);

tlo cube -transparent;

But I get the error message as following:
Mesh-size file error: Number of line definitions don’t match specified list size

What am I doing wrong here? BTW, thank you for developing such a nice open and powerful software. It helps me a lot for my thesis

Your example is working for me. I guess you miss the return after the last line.

Joachim