RE: casting implicit Boundary Conditions in FiPy

2016-06-08 Thread Gopalakrishnan, Krishnakumar
Hi Raymond,

Sorry, it was a typo.

Yes, It is indeed d (phi)/dx,  the spatial derivative BC.  I shall try setting 
phi.faceGrad.constrain([k*phi], mesh.facesRight), and see if it will work.

Thanks for pointing this out.


Krishna

From: fipy-boun...@nist.gov [mailto:fipy-boun...@nist.gov] On Behalf Of Raymond 
Smith
Sent: 08 June 2016 23:36
To: fipy@nist.gov
Subject: Re: casting implicit Boundary Conditions in FiPy

Hi, Krishna.
Just to make sure, do you mean that the boundary condition is a derivative with 
respect to the spatial variable or with respect to time as-written? If you mean 
spatial, such that d\phi/dx = k*phi, have you tried
phi.faceGrad.constrain(k*phi) and that didn't work?
If you mean that its value is prescribed by its rate of change, then I'm not 
sure the best way to do it. Could you maybe do it explicitly?
 - Store the values from the last time step with hasOld set to True in the 
creation of the cell variable
 - In each time step, calculate the backward-Euler time derivative manually and 
then set the value of phi with the phi.constrain method.

Ray

On Wed, Jun 8, 2016 at 6:26 PM, Gopalakrishnan, Krishnakumar 
mailto:k.gopalakrishna...@imperial.ac.uk>> 
wrote:
I am trying to solve the standard fickean diffusion equation on a 1D uniform 
mesh in (0,1)

$$\frac{\partial \phi}{\partial t} = \nabla.(D \nabla\phi)$$

with a suitable initial value for $\phi(x,t)$.

The problem is that, one of my boundary conditions is implicit, i.e. is a 
function of the field variable being solved for.

$ \frac{\partial\phi}{\partial t} = k \phi $ , at the right boundary edge, k = 
constant

The left BC is not a problem, it is just a standard no-flux BC.

How do I cast this implicit BC in FiPy ? Any help/pointers will be much 
appreciated.


Best regards

Krishna
Imperial College London

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

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


Re: casting implicit Boundary Conditions in FiPy

2016-06-08 Thread Raymond Smith
Hi, Krishna.

Just to make sure, do you mean that the boundary condition is a derivative
with respect to the spatial variable or with respect to time as-written? If
you mean spatial, such that d\phi/dx = k*phi, have you tried
phi.faceGrad.constrain(k*phi) and that didn't work?
If you mean that its value is prescribed by its rate of change, then I'm
not sure the best way to do it. Could you maybe do it explicitly?
 - Store the values from the last time step with hasOld set to True in the
creation of the cell variable
 - In each time step, calculate the backward-Euler time derivative manually
and then set the value of phi with the phi.constrain method.

Ray

On Wed, Jun 8, 2016 at 6:26 PM, Gopalakrishnan, Krishnakumar <
k.gopalakrishna...@imperial.ac.uk> wrote:

> I am trying to solve the standard fickean diffusion equation on a 1D
> uniform mesh in (0,1)
>
>
>
> $$\frac{\partial \phi}{\partial t} = \nabla.(D \nabla\phi)$$
>
>
>
> with a suitable initial value for $\phi(x,t)$.
>
>
>
> The problem is that, one of my boundary conditions is *implicit*, i.e. is
> a function of the field variable being solved for.
>
>
>
> $ \frac{\partial\phi}{\partial t} = k \phi $ , at the right boundary edge,
> k = constant
>
>
>
> The left BC is not a problem, it is just a standard no-flux BC.
>
>
>
> How do I cast this *implicit BC* in FiPy ? Any help/pointers will be much
> appreciated.
>
>
>
>
>
> Best regards
>
>
>
> Krishna
>
> Imperial College London
>
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>
>
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


casting implicit Boundary Conditions in FiPy

2016-06-08 Thread Gopalakrishnan, Krishnakumar
I am trying to solve the standard fickean diffusion equation on a 1D uniform 
mesh in (0,1)

$$\frac{\partial \phi}{\partial t} = \nabla.(D \nabla\phi)$$

with a suitable initial value for $\phi(x,t)$.

The problem is that, one of my boundary conditions is implicit, i.e. is a 
function of the field variable being solved for.

$ \frac{\partial\phi}{\partial t} = k \phi $ , at the right boundary edge, k = 
constant

The left BC is not a problem, it is just a standard no-flux BC.

How do I cast this implicit BC in FiPy ? Any help/pointers will be much 
appreciated.


Best regards

Krishna
Imperial College London
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: how to create large grid with holes and odd geometry

2016-06-08 Thread James Pringle
Thank you. Because of the regular nature of the original data, it is easy
to make it all triangles.

Cheers,
Jamie

On Wed, Jun 8, 2016 at 2:10 PM, Guyer, Jonathan E. Dr. (Fed) <
jonathan.gu...@nist.gov> wrote:

> Meshes with holes are not a problem for FiPy. Daniel will be happy to help
> you create a Mesh2D from the output of the triangle package. Basically, you
> need a list of vertex coordinates, a list of vertex IDs that make up faces,
> and a list of faces that make up cells. Having all triangles should be
> pretty easy; it gets messy when you've got mixes of different cell
> topologies.
>
> > On Jun 8, 2016, at 10:57 AM, James Pringle  wrote:
> >
> > Thank you; the axes were indeed in grid spacing, and your back of the
> envelope calculation of sparsity was exactly correct.
> >
> > I am now playing around with the python triangle package to create a
> triangular mesh with the appropriate holes and boundary defined. (e.g.
> https://urldefense.proofpoint.com/v2/url?u=http-3A__dzhelil.info_triangle__data-2D4.png&d=CwICAg&c=c6MrceVCY5m5A_KAUkrdoA&r=oMf1-WHpUHeD7kN3S7612CDdF2TDPqDF9R-n-71Ks1Y&m=k71WczOQwQx8_RK9cU8wRK_X2spChhXjIrj5C0zWgw4&s=Qk6jAmccEUMVpP5TFa_gtI6T1b4bSBcRfmUOVIkzC-s&e=
> ) .
> >
> > What is the best way to covert the triangle data (similar in form to
> scipy.spatial.Delaunay output) into the form fipy likes -- or what is the
> best documentation of the fipy mesh data structure?
> >
> > Does FiPy have the capability to deal with holes in a triangle mesh, and
> have BC's on them? I did see the trick that Danial Wheeler mentioned.
> Thanks!
> >
> > After I get the mesh, I was planing to reverse engineer the output of
> fipy.meshes.gmshMesh.Gmsh2D to figure out how to get my mesh into fipy if
> you don't mention something better.
> >
> > Thanks a bunch,
> > Jamie
> >
> > On Wed, Jun 8, 2016 at 1:46 PM, Guyer, Jonathan E. Dr. (Fed) <
> jonathan.gu...@nist.gov> wrote:
> > If the domain were not so large and so sparse, I'd be inclined to create
> a simple, rectilinear Grid2D of the full extent and then use known
> coefficients to mask out (set B to zero?) the solution where you don't
> know/care.
> >
> > Assuming the axes are labeled in grid spacings (?), then your mesh would
> have around 5 million elements in it, with fewer than 1 million actually
> being solved (although it looks like even less than 20% of the domain is
> active). I don't think that would perform very well.
> >
> > I'm not thinking of anything clever with Gmsh off the top of my head.
> >
> > You could break the total domain into sub-grids, only instantiate the
> corresponding Grid2D's if they're not empty, and then concatenate them
> together. Sketching:
> >
> > A B C D
> >  +-+-+-+-+
> > 1| | **  | | |
> >  | |  ** | | |
> >  +-+-+-+-+
> > 2| |*|**   | |
> >  | | |* *  | |
> >  +-+-+-+-+
> > 3| | | *** | |
> >  | | |  ***| |
> >  +-+-+-+-+
> > 4| | |   **|*|
> >  | | |*| *   |
> >  +-+-+-+-+
> >
> >
> > mesh = gridB1 + gridB2 + gridC2 + gridC3 + gridC4 + gridD4
> >
> >
> >
> >
> > > On Jun 7, 2016, at 10:46 AM, James Pringle  wrote:
> > >
> > > Dear mailing list & developers --
> > >
> > > I am looking for hints on the best way to proceed in creating a
> grid/mesh for a rather complex geometry. I am just looking for which method
> (Gmsh or something else?) to start with, so I can most efficiently start
> coding without exploring blind alleys.
> > >
> > > I am solving an elliptic/advective problem of the form
> > >
> > > 0=J(Psi,A(x,y)) + \Del(B(x,y)*\Del Psi)
> > >
> > > where Psi is the variable to solve for, and A(x,y) and B(x,y) are
> coefficients known on a set of discrete points shown as black in
> https://urldefense.proofpoint.com/v2/url?u=https-3A__dl.dropboxusercontent.com_u_382250_Grid01.png&d=CwICAg&c=c6MrceVCY5m5A_KAUkrdoA&r=oMf1-WHpUHeD7kN3S7612CDdF2TDPqDF9R-n-71Ks1Y&m=pa2VS0gonWbqlcwLDzR4QyP-iFHDpvnSHIqg-fk0QD4&s=ctz2HUgelmtveB6M5tJgv57BV8OqeCl3-MMJoIQOtmk&e=
> . The black appears solid because the grid is dense.
> > >
> > > The locations of the points where the coefficients are known define
> the grid. The number of points is large (911130 points) and they are evenly
> spaced where they exist. Note that there are holes in the domain that
> represent actual islands in the ocean.
> > >
> > > I am happy to keep the resolution of the grid/mesh equal to the
> spacing of the points where the coefficients are known.
> > >
> > > What is the best way to approach creating a grid for this problem? I
> would love code, of course, but would be very happy with suggestions of the
> best way to start.
> > >
> > > Thanks
> > > Jamie Pringle
> > > University of New Hampshire
> > > ___
> > > fipy mailing list
> > ___
> > fipy mailing list
> >

Re: how to create large grid with holes and odd geometry

2016-06-08 Thread Guyer, Jonathan E. Dr. (Fed)
Meshes with holes are not a problem for FiPy. Daniel will be happy to help you 
create a Mesh2D from the output of the triangle package. Basically, you need a 
list of vertex coordinates, a list of vertex IDs that make up faces, and a list 
of faces that make up cells. Having all triangles should be pretty easy; it 
gets messy when you've got mixes of different cell topologies.

> On Jun 8, 2016, at 10:57 AM, James Pringle  wrote:
> 
> Thank you; the axes were indeed in grid spacing, and your back of the 
> envelope calculation of sparsity was exactly correct. 
> 
> I am now playing around with the python triangle package to create a 
> triangular mesh with the appropriate holes and boundary defined. (e.g. 
> http://dzhelil.info/triangle//data-4.png ) . 
> 
> What is the best way to covert the triangle data (similar in form to 
> scipy.spatial.Delaunay output) into the form fipy likes -- or what is the 
> best documentation of the fipy mesh data structure?
> 
> Does FiPy have the capability to deal with holes in a triangle mesh, and have 
> BC's on them? I did see the trick that Danial Wheeler mentioned. Thanks!
> 
> After I get the mesh, I was planing to reverse engineer the output of 
> fipy.meshes.gmshMesh.Gmsh2D to figure out how to get my mesh into fipy if you 
> don't mention something better. 
> 
> Thanks a bunch,
> Jamie
> 
> On Wed, Jun 8, 2016 at 1:46 PM, Guyer, Jonathan E. Dr. (Fed) 
>  wrote:
> If the domain were not so large and so sparse, I'd be inclined to create a 
> simple, rectilinear Grid2D of the full extent and then use known coefficients 
> to mask out (set B to zero?) the solution where you don't know/care.
> 
> Assuming the axes are labeled in grid spacings (?), then your mesh would have 
> around 5 million elements in it, with fewer than 1 million actually being 
> solved (although it looks like even less than 20% of the domain is active). I 
> don't think that would perform very well.
> 
> I'm not thinking of anything clever with Gmsh off the top of my head.
> 
> You could break the total domain into sub-grids, only instantiate the 
> corresponding Grid2D's if they're not empty, and then concatenate them 
> together. Sketching:
> 
> A B C D
>  +-+-+-+-+
> 1| | **  | | |
>  | |  ** | | |
>  +-+-+-+-+
> 2| |*|**   | |
>  | | |* *  | |
>  +-+-+-+-+
> 3| | | *** | |
>  | | |  ***| |
>  +-+-+-+-+
> 4| | |   **|*|
>  | | |*| *   |
>  +-+-+-+-+
> 
> 
> mesh = gridB1 + gridB2 + gridC2 + gridC3 + gridC4 + gridD4
> 
> 
> 
> 
> > On Jun 7, 2016, at 10:46 AM, James Pringle  wrote:
> >
> > Dear mailing list & developers --
> >
> > I am looking for hints on the best way to proceed in creating a 
> > grid/mesh for a rather complex geometry. I am just looking for which method 
> > (Gmsh or something else?) to start with, so I can most efficiently start 
> > coding without exploring blind alleys.
> >
> > I am solving an elliptic/advective problem of the form
> >
> > 0=J(Psi,A(x,y)) + \Del(B(x,y)*\Del Psi)
> >
> > where Psi is the variable to solve for, and A(x,y) and B(x,y) are 
> > coefficients known on a set of discrete points shown as black in 
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__dl.dropboxusercontent.com_u_382250_Grid01.png&d=CwICAg&c=c6MrceVCY5m5A_KAUkrdoA&r=oMf1-WHpUHeD7kN3S7612CDdF2TDPqDF9R-n-71Ks1Y&m=pa2VS0gonWbqlcwLDzR4QyP-iFHDpvnSHIqg-fk0QD4&s=ctz2HUgelmtveB6M5tJgv57BV8OqeCl3-MMJoIQOtmk&e=
> >   . The black appears solid because the grid is dense.
> >
> > The locations of the points where the coefficients are known define the 
> > grid. The number of points is large (911130 points) and they are evenly 
> > spaced where they exist. Note that there are holes in the domain that 
> > represent actual islands in the ocean.
> >
> > I am happy to keep the resolution of the grid/mesh equal to the spacing of 
> > the points where the coefficients are known.
> >
> > What is the best way to approach creating a grid for this problem? I would 
> > love code, of course, but would be very happy with suggestions of the best 
> > way to start.
> >
> > Thanks
> > Jamie Pringle
> > University of New Hampshire
> > ___
> > fipy mailing list
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


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


Re: how to create large grid with holes and odd geometry

2016-06-08 Thread James Pringle
Thank you; the axes were indeed in grid spacing, and your back of the
envelope calculation of sparsity was exactly correct.

I am now playing around with the python triangle package to create a
triangular mesh with the appropriate holes and boundary defined. (e.g.
http://dzhelil.info/triangle//data-4.png ) .

What is the best way to covert the triangle data (similar in form to
scipy.spatial.Delaunay output) into the form fipy likes -- or what is the
best documentation of the fipy mesh data structure?

Does FiPy have the capability to deal with holes in a triangle mesh, and
have BC's on them? I did see the trick that Danial Wheeler mentioned.
Thanks!

After I get the mesh, I was planing to reverse engineer the output of
fipy.meshes.gmshMesh.Gmsh2D to figure out how to get my mesh into fipy if
you don't mention something better.

Thanks a bunch,
Jamie

On Wed, Jun 8, 2016 at 1:46 PM, Guyer, Jonathan E. Dr. (Fed) <
jonathan.gu...@nist.gov> wrote:

> If the domain were not so large and so sparse, I'd be inclined to create a
> simple, rectilinear Grid2D of the full extent and then use known
> coefficients to mask out (set B to zero?) the solution where you don't
> know/care.
>
> Assuming the axes are labeled in grid spacings (?), then your mesh would
> have around 5 million elements in it, with fewer than 1 million actually
> being solved (although it looks like even less than 20% of the domain is
> active). I don't think that would perform very well.
>
> I'm not thinking of anything clever with Gmsh off the top of my head.
>
> You could break the total domain into sub-grids, only instantiate the
> corresponding Grid2D's if they're not empty, and then concatenate them
> together. Sketching:
>
> A B C D
>  +-+-+-+-+
> 1| | **  | | |
>  | |  ** | | |
>  +-+-+-+-+
> 2| |*|**   | |
>  | | |* *  | |
>  +-+-+-+-+
> 3| | | *** | |
>  | | |  ***| |
>  +-+-+-+-+
> 4| | |   **|*|
>  | | |*| *   |
>  +-+-+-+-+
>
>
> mesh = gridB1 + gridB2 + gridC2 + gridC3 + gridC4 + gridD4
>
>
>
>
> > On Jun 7, 2016, at 10:46 AM, James Pringle  wrote:
> >
> > Dear mailing list & developers --
> >
> > I am looking for hints on the best way to proceed in creating a
> grid/mesh for a rather complex geometry. I am just looking for which method
> (Gmsh or something else?) to start with, so I can most efficiently start
> coding without exploring blind alleys.
> >
> > I am solving an elliptic/advective problem of the form
> >
> > 0=J(Psi,A(x,y)) + \Del(B(x,y)*\Del Psi)
> >
> > where Psi is the variable to solve for, and A(x,y) and B(x,y) are
> coefficients known on a set of discrete points shown as black in
> https://urldefense.proofpoint.com/v2/url?u=https-3A__dl.dropboxusercontent.com_u_382250_Grid01.png&d=CwICAg&c=c6MrceVCY5m5A_KAUkrdoA&r=oMf1-WHpUHeD7kN3S7612CDdF2TDPqDF9R-n-71Ks1Y&m=pa2VS0gonWbqlcwLDzR4QyP-iFHDpvnSHIqg-fk0QD4&s=ctz2HUgelmtveB6M5tJgv57BV8OqeCl3-MMJoIQOtmk&e=
> . The black appears solid because the grid is dense.
> >
> > The locations of the points where the coefficients are known define the
> grid. The number of points is large (911130 points) and they are evenly
> spaced where they exist. Note that there are holes in the domain that
> represent actual islands in the ocean.
> >
> > I am happy to keep the resolution of the grid/mesh equal to the spacing
> of the points where the coefficients are known.
> >
> > What is the best way to approach creating a grid for this problem? I
> would love code, of course, but would be very happy with suggestions of the
> best way to start.
> >
> > Thanks
> > Jamie Pringle
> > University of New Hampshire
> > ___
> > fipy mailing list
>
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: how to create large grid with holes and odd geometry

2016-06-08 Thread Daniel Wheeler
On Wed, Jun 8, 2016 at 1:46 PM, Guyer, Jonathan E. Dr. (Fed)
 wrote:

>
> A B C D
>  +-+-+-+-+
> 1| | **  | | |
>  | |  ** | | |
>  +-+-+-+-+
> 2| |*|**   | |
>  | | |* *  | |
>  +-+-+-+-+
> 3| | | *** | |
>  | | |  ***| |
>  +-+-+-+-+
> 4| | |   **|*|
>  | | |*| *   |
>  +-+-+-+-+
>

Jamie, this is nice. If you use this approach and interpolate the
values of A and B then you will have two grid parameters. One for the
subgrid density and one for the internal subgrid spacing. Remember
that the meshes need to be joined (not via a diagonal). There must be
a way to write a simple algorithm to do this.


-- 
Daniel Wheeler
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: how to create large grid with holes and odd geometry

2016-06-08 Thread Daniel Wheeler
Hi Jamie,

The simplest way might be just to take a basic grid and just "switch
off" the simulation outside of the black zone. This can be achieved by
including a transient term in the equation and setting the coefficient
to be large in the white zone and zero or something small in the black
zone. That would be an easy first attempt to solve the problem. Of
course this approach has a lot of redundancy, but would be a good
first step. You may have to interpolate the A and B values to a
coarser grid for this approach to be feasible.

It is possible in FiPy to combine grid's into odd shaped
non-rectangular grids. You could do this with say 20 or 30 smaller
grids to better isolate the black region. I still think that you want
to interpolate the values of A and B so you have control over the grid
density. You don't necessarily need a grid density at the sample
density. Also, you will still need the trick with the Transient Term.
Furthermore, the grids must align and not overlap. It will take quite
a bit of programming to set this up so that you have control over the
grid density and the number of subgrids to isolate the black region.

Gmsh will probably be happy meshing the black region, but will
probably use triangles rather than a grid.

To summarize use the first approach to make things work right and then
refine with the second approach.

Hope it helps.

On Tue, Jun 7, 2016 at 1:46 PM, James Pringle  wrote:
> Dear mailing list & developers --
>
> I am looking for hints on the best way to proceed in creating a
> grid/mesh for a rather complex geometry. I am just looking for which method
> (Gmsh or something else?) to start with, so I can most efficiently start
> coding without exploring blind alleys.
>
> I am solving an elliptic/advective problem of the form
>
> 0=J(Psi,A(x,y)) + \Del(B(x,y)*\Del Psi)
>
> where Psi is the variable to solve for, and A(x,y) and B(x,y) are
> coefficients known on a set of discrete points shown as black in
> https://dl.dropboxusercontent.com/u/382250/Grid01.png . The black appears
> solid because the grid is dense.
>
> The locations of the points where the coefficients are known define the
> grid. The number of points is large (911130 points) and they are evenly
> spaced where they exist. Note that there are holes in the domain that
> represent actual islands in the ocean.
>
> I am happy to keep the resolution of the grid/mesh equal to the spacing of
> the points where the coefficients are known.
>
> What is the best way to approach creating a grid for this problem? I would
> love code, of course, but would be very happy with suggestions of the best
> way to start.
>
> Thanks
> Jamie Pringle
> University of New Hampshire
>
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>   [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
>



-- 
Daniel Wheeler
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


Re: how to create large grid with holes and odd geometry

2016-06-08 Thread Guyer, Jonathan E. Dr. (Fed)
If the domain were not so large and so sparse, I'd be inclined to create a 
simple, rectilinear Grid2D of the full extent and then use known coefficients 
to mask out (set B to zero?) the solution where you don't know/care.

Assuming the axes are labeled in grid spacings (?), then your mesh would have 
around 5 million elements in it, with fewer than 1 million actually being 
solved (although it looks like even less than 20% of the domain is active). I 
don't think that would perform very well.

I'm not thinking of anything clever with Gmsh off the top of my head.

You could break the total domain into sub-grids, only instantiate the 
corresponding Grid2D's if they're not empty, and then concatenate them 
together. Sketching:

A B C D
 +-+-+-+-+
1| | **  | | |
 | |  ** | | |
 +-+-+-+-+
2| |*|**   | |
 | | |* *  | |
 +-+-+-+-+
3| | | *** | |
 | | |  ***| |
 +-+-+-+-+
4| | |   **|*|
 | | |*| *   |
 +-+-+-+-+


mesh = gridB1 + gridB2 + gridC2 + gridC3 + gridC4 + gridD4




> On Jun 7, 2016, at 10:46 AM, James Pringle  wrote:
> 
> Dear mailing list & developers -- 
> 
> I am looking for hints on the best way to proceed in creating a grid/mesh 
> for a rather complex geometry. I am just looking for which method (Gmsh or 
> something else?) to start with, so I can most efficiently start coding 
> without exploring blind alleys. 
> 
> I am solving an elliptic/advective problem of the form 
> 
> 0=J(Psi,A(x,y)) + \Del(B(x,y)*\Del Psi)
> 
> where Psi is the variable to solve for, and A(x,y) and B(x,y) are 
> coefficients known on a set of discrete points shown as black in 
> https://dl.dropboxusercontent.com/u/382250/Grid01.png . The black appears 
> solid because the grid is dense. 
> 
> The locations of the points where the coefficients are known define the grid. 
> The number of points is large (911130 points) and they are evenly spaced 
> where they exist. Note that there are holes in the domain that represent 
> actual islands in the ocean.
> 
> I am happy to keep the resolution of the grid/mesh equal to the spacing of 
> the points where the coefficients are known. 
> 
> What is the best way to approach creating a grid for this problem? I would 
> love code, of course, but would be very happy with suggestions of the best 
> way to start. 
> 
> Thanks 
> Jamie Pringle
> University of New Hampshire
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


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


RE: Matrix coefficient for FiPy Transient Term

2016-06-08 Thread Gopalakrishnan, Krishnakumar
Thank you very much. Indeed that worked ! 

-Original Message-
From: fipy-boun...@nist.gov [mailto:fipy-boun...@nist.gov] On Behalf Of Guyer, 
Jonathan E. Dr. (Fed)
Sent: 08 June 2016 18:31
To: FIPY 
Subject: Re: Matrix coefficient for FiPy Transient Term

There's no need to create, extract, and reshape the result. Just use the mesh's 
y coordinates:

  TransientTerm(coeff=mesh.y**2) == DiffusionTerm(coeff=D)

should work.


> On Jun 8, 2016, at 9:01 AM, Gopalakrishnan, Krishnakumar 
>  wrote:
> 
>  src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js";>
> Hello, 
>  
> The following PDE is defined in a non-square 2D (x-y) cartesian grid (20 x 
> 10) domain
>  
> $$ \frac{\partial}{\partial t} (y^2 \phi(x,y,t)) = D \nabla^2 \phi(x,y,t) $$
>  
> wherein $y^2$ is the 'y' co-ordinate of my 2D domain.
>  
> The FiPy representation of an analogous type of equation is as follows:
>  
> $$ \frac{\partial}{\partial t} (\rho \phi(x,y,t)) = D \nabla^2 \phi(x,y,t) $$
>  
> TransientTerm(coeff=rho) == DiffusionTerm(coeff=D)
>  
> By matching coefficients, we can see that my $\rho = y^2$
>  
> I am quite confused about setting up this problem in FiPy.
>  
> a. Are these types of non-linear coefficients allowed for the transient-term ?
> b. All the examples that I have seen thus far, use constant/scalar 
> coefficients. In my case, I have a coefficient-matrix which depends on the 
> spatial variable in the y-direction.
> c. If coefficient-matrix is indeed allowed, what must be the data-type ?
>  
>  
> The following is my general approach thus far,
>  
> · Construct a 'temporary' 1D mesh using the dy and ny parameters of 
> the original 2D mesh, and extract it's node-values using Cellcenters method. 
> This should correspond to the original nodes in the y-direction (am I right 
> ?).
> · Convert this to 'ndarray' datatype using numerix.ndarray.
> · Transpose this, such as the result is a column vector.
>  
> The one-liner code that (potentially) implements this is shown below:
>  
> discretised_y_vector = numerix.array((Grid1D(dx = dy_2D_original , nx = 
> ny_2D_original)).cellCenters[0]).transpose()
>  
> Repeat (replicate) the column vector 'nx' times (in my case, 20 times) to 
> obtain the coefficient matrix for the transient term.
>  
> discretised_y_matrix = numerix.repeat(discretised_y_vector, nx)
>  
> Is this approach correct ? I am a beginner to FiPy and numerical PDE solving 
> in general. Any pointers in this direction shall be much appreciated.
>  
>  
> Regards
>  
> Krishna
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


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

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


Re: Matrix coefficient for FiPy Transient Term

2016-06-08 Thread Guyer, Jonathan E. Dr. (Fed)
There's no need to create, extract, and reshape the result. Just use the mesh's 
y coordinates:

  TransientTerm(coeff=mesh.y**2) == DiffusionTerm(coeff=D)

should work.


> On Jun 8, 2016, at 9:01 AM, Gopalakrishnan, Krishnakumar 
>  wrote:
> 
>  src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js";>
> Hello, 
>  
> The following PDE is defined in a non-square 2D (x-y) cartesian grid (20 x 
> 10) domain
>  
> $$ \frac{\partial}{\partial t} (y^2 \phi(x,y,t)) = D \nabla^2 \phi(x,y,t) $$
>  
> wherein $y^2$ is the 'y' co-ordinate of my 2D domain.
>  
> The FiPy representation of an analogous type of equation is as follows:
>  
> $$ \frac{\partial}{\partial t} (\rho \phi(x,y,t)) = D \nabla^2 \phi(x,y,t) $$
>  
> TransientTerm(coeff=rho) == DiffusionTerm(coeff=D)
>  
> By matching coefficients, we can see that my $\rho = y^2$
>  
> I am quite confused about setting up this problem in FiPy.
>  
> a. Are these types of non-linear coefficients allowed for the transient-term ?
> b. All the examples that I have seen thus far, use constant/scalar 
> coefficients. In my case, I have a coefficient-matrix which depends on the 
> spatial variable in the y-direction.
> c. If coefficient-matrix is indeed allowed, what must be the data-type ?
>  
>  
> The following is my general approach thus far,
>  
> · Construct a 'temporary' 1D mesh using the dy and ny parameters of 
> the original 2D mesh, and extract it's node-values using Cellcenters method. 
> This should correspond to the original nodes in the y-direction (am I right 
> ?).
> · Convert this to 'ndarray' datatype using numerix.ndarray.
> · Transpose this, such as the result is a column vector.
>  
> The one-liner code that (potentially) implements this is shown below:
>  
> discretised_y_vector = numerix.array((Grid1D(dx = dy_2D_original , nx = 
> ny_2D_original)).cellCenters[0]).transpose()
>  
> Repeat (replicate) the column vector 'nx' times (in my case, 20 times) to 
> obtain the coefficient matrix for the transient term.
>  
> discretised_y_matrix = numerix.repeat(discretised_y_vector, nx)
>  
> Is this approach correct ? I am a beginner to FiPy and numerical PDE solving 
> in general. Any pointers in this direction shall be much appreciated.
>  
>  
> Regards
>  
> Krishna
> ___
> fipy mailing list
> fipy@nist.gov
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


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


Matrix coefficient for FiPy Transient Term

2016-06-08 Thread Gopalakrishnan, Krishnakumar
https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js";>
Hello,

The following PDE is defined in a non-square 2D (x-y) cartesian grid (20 x 10) 
domain

$$ \frac{\partial}{\partial t} (y^2 \phi(x,y,t)) = D \nabla^2 \phi(x,y,t) $$

wherein $y^2$ is the 'y' co-ordinate of my 2D domain.

The FiPy representation of an analogous type of equation is as follows:

$$ \frac{\partial}{\partial t} (\rho \phi(x,y,t)) = D \nabla^2 \phi(x,y,t) $$

TransientTerm(coeff=rho) == DiffusionTerm(coeff=D)

By matching coefficients, we can see that my $\rho = y^2$

I am quite confused about setting up this problem in FiPy.

a. Are these types of non-linear coefficients allowed for the transient-term ?
b. All the examples that I have seen thus far, use constant/scalar 
coefficients. In my case, I have a coefficient-matrix which depends on the 
spatial variable in the y-direction.
c. If coefficient-matrix is indeed allowed, what must be the data-type ?


The following is my general approach thus far,


* Construct a 'temporary' 1D mesh using the dy and ny parameters of the 
original 2D mesh, and extract it's node-values using Cellcenters method. This 
should correspond to the original nodes in the y-direction (am I right ?).

* Convert this to 'ndarray' datatype using numerix.ndarray.

* Transpose this, such as the result is a column vector.

The one-liner code that (potentially) implements this is shown below:

discretised_y_vector = numerix.array((Grid1D(dx = dy_2D_original , nx = 
ny_2D_original)).cellCenters[0]).transpose()

Repeat (replicate) the column vector 'nx' times (in my case, 20 times) to 
obtain the coefficient matrix for the transient term.

discretised_y_matrix = numerix.repeat(discretised_y_vector, nx)

Is this approach correct ? I am a beginner to FiPy and numerical PDE solving in 
general. Any pointers in this direction shall be much appreciated.


Regards

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