Thanks for posting your realization about .faceNormals.

For completeness, I would approach your problem by constructing your patch of 
spherical shell in 3D space, rather than trying to change the coefficients. See 
examples/cahnHilliard/sphere.py where we do exactly that. The key is to extrude 
the cells of your 2D mesh into prisms that splay a bit as a result of the 
curvature of the surface. You end up with a 3D mesh that is only one cell deep 
and the splaying of the prisms causes the divergence and gradient operators to 
have the appropriate spherical character.

> On Jul 1, 2016, at 4:02 PM, James Pringle <[email protected]> wrote:
> 
> Please ignore -- I just realized I am being a dolt. For those of you who 
> stumble across this thread and would like avoid making the same mistake, I 
> believe that 
> 
>      psi.faceGrad.constrain(1.0*mesh.faceNormals,faceMask)
> 
> constrains the faceGrad to some value, here 1.0*mesh.faceNormals, where 
> faceMask is true. If I want to set it the gradient to some value which is 
> normal in my coordinate system, I just have to provide a (2,numberOfFaces) 
> array with the appropriate values of the derivatives of psi in it. There is 
> nothing magical about the mesh.faceNormals other than that it gives you 
> useful information about the orientation of the face in your variable space. 
> 
> Sorry to waste everyones time. 
> Jamie
> 
> On Fri, Jul 1, 2016 at 10:35 AM, Pringle, James <[email protected]> wrote:
> Dear fipy folks -- 
> 
> I am solving a problem of ocean circulation on a thin spherical shell; the 
> domain is too large to ignore the spherical nature of the earth. The problem 
> is of the form 
> 
>        eq = 
> (DiffusionTerm(var=Psi,coeff=DiffCoeff)+ExponentialConvectionTerm(var=Psi,coeff=convCoeff))
> 
> And I have incorporated all the of the appropriate metric terms for a 
> spherical shell into the coefficients above. My problem comes as I strive to 
> make the solution more realistic by applying Neumann BC's to some parts of 
> the problem. The usual formulation for setting \Del\dot\Psi \dot normal = 1  
> 
>        psi.faceGrad.constrain(1.0*mesh.faceNormals,faceMask)
> 
> will not work because on a spherical shell the gradient is equal to 
> 
>        \Del f = (1/r) dF/d(lat)*(unit vector latitude) + 
> (1/(r*cos(lat)))*dF/d(long)*(unit vector longitude)
> 
> Is there any easy way to constrain the faceGrad to something like 
> 
>         constant = A*dPsi/dx+B*dPsi/dy
> 
> where x and y are the spatial coordinates, and A and B are arbitrary factors? 
>  That way I could easily include the metrics...
> 
> Thanks,
> Jamie Pringle
> University of New Hampshire
> 
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to