Regions creation issue + using regions question

Hi.

I’m starting to use FreeFem and I’ve been trying to model using the freefem mesh generator.

I’ve got two questions/issues:

A.I’m running into issues with the geometry/mesh definitions when having multiple regions/borders

B. how can I use regions, in order to use them in a function in order to differentiate physics/equations between water and polycarbonate in this case (no convection in PC, no SAR heating in PC for example).

A. Intended geometry:

  1. outside sphere/circle (polycarbonate)

  2. inside sphere/circle (water)

  3. several spheres/circles inside (polycarbonate)

  4. inside these spheres, water sphere/circle again

  5. in between these spheres some slabs.

The goal is to perform a simulation for temperature evolution, with outside air (21 °C for example) and the initial sphere at 14 °C; but also combining MR radiofrequent heating later on.

I ran into quite some mesh issues. The current mesh, enclosed (geom_only.edp), does not result in correct region definition when plotting: the outside region is combined with the water region, and not all spheres seem correct regions

When commenting some regions out, I get more correct definition.

However, when adding more regions, it seems the definition no longer seems coherent. In the script I tried to differentiate everything, creating more mesh points, enlarging distances, using or not using labels, but I don’t seem to get it work, no overlap… Seperately, each region seems coherent, but when adding them all in, at a certain point it becomes incoherent.

(I tried to model also using gmsh; however, both the GMSH and INRIA import resulted in border definition problems, which I abandoned currently.)

B) My second question is using regions in a created mesh to differentiate between materials during equation solving (see second file, “sphere_only_with_physics.edp”:slight_smile:

I’m using currently a form like:

func isWater = (Th(x, y).region == 0) || (Th(x, y).region == 2) ;

(I would like to use for example, but using “region” did not seem to work)

func isWater = (region == 0) || (region == 2);

To know if it is a Water or PC region, to be able to use later on:

func kappa = isWater * kWater + isPC * kPC;
func rhoCp = isWater * (rhoWater * cpWater) + isPC * (rhoPC * cpPC);

func nuEff = isWater * nu + isPC * 1e6*nu;

In order to be able to use in a stokes and heat equation

problem heat(T, vT) =
// Transient term
int2d(Th)(rhoCp/dt * T * vT)

-int2d(Th)(rhoCp/dt * Told * vT)
// Diffusion

+int2d(Th)(kappa * (dx(T)*dx(vT) + dy(T)*dy(vT)) )

// Advection (only in water)

-int2d(Th)( isWater * rhoWater * cpWater * (uxdx(T) + uydy(T)) * vT )

// + int2d(Th)( Qrf * vT )
Convective boundary condition at outer surface

+int1d(Th, 1)(h * T * vT)

-int1d(Th, 1)(h * Tair * vT);

Is this a logic way to differentiate? My current idea was to define the borders well in order to have correct boundary conditions and using the region numbers to differentiate materials. Or should I rather use geometrical functions to define what is water/PC and just have a large mesh? (such as:

func isWater = (x^2 + y^2 <= Rw^2 );

func isPMMA = (x^2 + y^2 > Rw^2);

(I cannot upload files currently to the forum, but they are in the following drive link, the first file is the full geometry, the second one a solver with only the outer spheres)

I’m only starting to use FreeFem, so still learning a lot, thanks in advance for helping me further :).

Please have a look at, e.g., Initialisation in different regions (you should use an fespace function, not a func).

Thanks! I’ll try that approach.

Considering my first question: I think it is just a visualization issue lacking colors. The mesh also has this issue with overlapping or the same color and I was probably assuming a real issue. When checking the region in detail, I get different numbers, so I think it is ok:

(I think the issue is that there are only 12 color levels representing the last regions, and all others are using red).

plot(Th, value=region, fill=true, wait=1);

plot(Th, wait=true, cmm=“Mesh with boundaries”);

Right, don’t use ffglut to check for correctness of your results…