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:
-
outside sphere/circle (polycarbonate)
-
inside sphere/circle (water)
-
several spheres/circles inside (polycarbonate)
-
inside these spheres, water sphere/circle again
-
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”![]()
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 :).

