0

I create a mesh using Grid2D as follows

L = 2.
N = 50
dL = L/N
mesh = Grid2D(nx=N, ny=N, dx=dL, dy=dL)

but when I try to get the cell to face distance vector:

mesh.cellToFaceDistanceVectors

the following error appears:

AttributeError                            Traceback (most recent call last)

<ipython-input-7-9ab623a3d90d> in <module>()
----> 1 mesh.cellToFaceDistanceVectors

/usr/local/lib/python3.6/dist-packages/fipy/meshes/abstractMesh.py in <lambda>(s)
     96                             rank=1)
     97 
---> 98     cellToFaceDistanceVectors  = property(lambda s: s._cellToFaceDistanceVectors)
     99     cellDistanceVectors        = property(lambda s: s._cellDistanceVectors)
    100     cellVolumes                = property(lambda s: s._scaledCellVolumes)

AttributeError: 'UniformGrid2D' object has no attribute '_cellToFaceDistanceVectors'

It happens the same for other attributes such as:

mesh.cellDistanceVectors

Does anybody know how can I get the face to cell distance vectors?

  • What's your use case? We may be able to get you a different solution. – jeguyer Feb 05 '20 at 16:49
  • I wanted to implement the Robin conditions as it is in the link [link] (ctcms.nist.gov/fipy/documentation/USAGE.html) and I need the distance vector `dPf = FaceVariable(mesh=mesh, ... value=mesh._faceToCellDistanceRatio * mesh.cellDistanceVectors)`. I replaced it with `dPf = FaceVariable(mesh=mesh, value=- mesh.faceNormals * mesh._faceToCellDistances)` and it gives a reasonable solution. However, when I integrate the gradient of the variable at the boundaries the value is not correct. – Juan Blanco Feb 05 '20 at 20:37
  • The value of the current proportional to the gradient * normal at the boundaries is very important for my calculations (I've also tried with the laplacian volumetric integral without success) – Juan Blanco Feb 05 '20 at 20:40
  • Indeed. Thanks for pointing this out. – jeguyer Feb 06 '20 at 20:31

1 Answers1

0

It doesn't look like we ever implemented that for Grids and it looks like I never did much testing of the Robin discussion. I've filed an issue.

As a workaround, you can do

from fipy.tools import numerix
MA = numerix.MA

tmp = MA.repeat(mesh._faceCenters[..., numerix.NewAxis,:], 2, 1)
cellToFaceDistanceVectors = tmp - numerix.take(mesh._cellCenters, mesh.faceCellIDs, axis=1)

tmp = numerix.take(mesh._cellCenters, mesh.faceCellIDs, axis=1)
tmp = tmp[..., 1,:] - tmp[..., 0,:]
cellDistanceVectors = MA.filled(MA.where(MA.getmaskarray(tmp), cellToFaceDistanceVectors[:, 0], tmp))
jeguyer
  • 2,379
  • 1
  • 11
  • 15
  • Actually, the mesh.cellDistanceVectors is used in the website https://www.ctcms.nist.gov/fipy/documentation/USAGE.html when trying to implement Robin conditions ("Applying Robin boundary conditions" is the title) and it appears when trying to get the face to cell distance vector as: dPf = FaceVariable(mesh=mesh, ... value=mesh._faceToCellDistanceRatio * mesh.cellDistanceVectors) – Juan Blanco Feb 05 '20 at 18:48