Irregular surface and Gmsh2D

33 views
Skip to first unread message

Fausto Arinos de A. Barbuto

unread,
Jan 28, 2021, 2:45:41 PM1/28/21
to Fipy

Hi,

Is it OK to define the contour of an irregular shape based on its (X,Y)
coordinates only, e.g.:

    X, Y = mesh.faceCenters

    L1 = (X == 0.000) & (Y <= 0.025)
    L2 = (X == 0.025) & (Y >= 0.025)
    T1 = (X <= 0.025) & (Y == 0.025)
    T2 = (X >= 0.025) & (Y == 0.200)
    B1 = (X <= 0.300) & (Y == 0.000)
    B2 = (X >= 0.300) & (Y == 0.050)
    R1 = (X == 0.300) & (Y <= 0.050)
    R2 = (X == 0.500) & (Y >= 0.050)

that is, without caring about mesh.facesLeft, mesh.facesBottom etc? I 
find it easier (albeit sillier, too) this way, sometimes.

A comment about FiPy's mesh generator function Gmsh2D. It allows one to 
define line labels such as:

Physical Line("L1") = {8};
Physical Line("B1") = {1};
Physical Line("B2") = {3};
...

Yet I wasn't able to use those line label definitions directly, like:

    phi = CellVariable(name="phi(x,y)", mesh=mesh, value=0.0, hasOld=True)

    phi.constrain(10.0, L1)
    phi.constrain(0.0, L2)
    phi.faceGrad.constrain(0.0, R1)

and so on and so forth? Do I still have to define the contour as shown 
at the beginning of this message? I get error messages saying that L1,
L2, etc, weren't defined.


Thanks,

Fausto


Guyer, Jonathan E. Dr. (Fed)

unread,
Jan 28, 2021, 5:46:51 PM1/28/21
to FIPY
On Jan 28, 2021, at 2:45 PM, 'Fausto Arinos de A. Barbuto' via fipy <fi...@list.nist.gov> wrote:


Hi,

Is it OK to define the contour of an irregular shape based on its (X,Y)
coordinates only, e.g.:

    X, Y = mesh.faceCenters

    L1 = (X == 0.000) & (Y <= 0.025)
    L2 = (X == 0.025) & (Y >= 0.025)
    T1 = (X <= 0.025) & (Y == 0.025)
    T2 = (X >= 0.025) & (Y == 0.200)
    B1 = (X <= 0.300) & (Y == 0.000)
    B2 = (X >= 0.300) & (Y == 0.050)
    R1 = (X == 0.300) & (Y <= 0.050)
    R2 = (X == 0.500) & (Y >= 0.050)

that is, without caring about mesh.facesLeft, mesh.facesBottom etc? I 
find it easier (albeit sillier, too) this way, sometimes.

You absolutely can do this. Internally, that’s all that FiPy is doing, e.g.,



A comment about FiPy's mesh generator function Gmsh2D. It allows one to 
define line labels such as:

Physical Line("L1") = {8};
Physical Line("B1") = {1};
Physical Line("B2") = {3};
...

Yet I wasn't able to use those line label definitions directly, like:

    phi = CellVariable(name="phi(x,y)", mesh=mesh, value=0.0, hasOld=True)

    phi.constrain(10.0, L1)
    phi.constrain(0.0, L2)
    phi.faceGrad.constrain(0.0, R1)

and so on and so forth? Do I still have to define the contour as shown 
at the beginning of this message? I get error messages saying that L1,
L2, etc, weren't defined.

You need to write:

    phi.constrain(10.0, mesh.physicalFaces["L1"])
    phi.constrain(0.0, mesh.physicalFaces["L2"])
    phi.faceGrad.constrain(0.0, mesh.physicalFaces["R1"])

See the example at

Fausto Arinos de A. Barbuto

unread,
Jan 28, 2021, 7:20:05 PM1/28/21
to FIPY

On Thursday, January 28, 2021, 07:46:53 p.m. GMT-3, 'Guyer, Jonathan E. Dr. (Fed)' via fipy <fi...@list.nist.gov> wrote:

> You need to write:

    phi.constrain(10.0, mesh.physicalFaces["L1"])
    phi.constrain(0.0, mesh.physicalFaces["L2"])
    phi.faceGrad.constrain(0.0, mesh.physicalFaces["R1"])

> See the example at


Thanks. I tried mesh.L1 and it obviously didn't work.

Fausto


Reply all
Reply to author
Forward
0 new messages