Re: FW: how to set up data transfer between two adjacent nonuniform meshs

2016-10-25 Thread Zhekai Deng
Thank you. I implemented as you suggested and it works very good now. This
approach seems also applicable for the mesh that are not aligned in the
interface.

Best,

Zhekai

On Mon, Oct 24, 2016 at 9:00 AM, Daniel Wheeler 
wrote:

> On Mon, Oct 24, 2016 at 12:20 AM, Zhekai Deng
>  wrote:
> >
> > This is not a issue if mesh system is 1D, and boundary cell is just 1. Or
> > maybe on the rectangular mesh system. However, does any one has any idea
> to
> > how to transfer it properly ?
>
> Hi Zhekai; I haven't read through everything but I would guess that
> you need to interpolate from one mesh to another. To do that you can
> use one of Scipy's inerpolation functions such as
>
> https://docs.scipy.org/doc/scipy-0.14.0/reference/
> generated/scipy.interpolate.griddata.html
>
> We also built that capability into FiPy, but it's probably better to
> use Scipy's interpolation at this point.
>
> https://github.com/usnistgov/fipy/blob/develop/fipy/
> variables/cellVariable.py#L167
>
> If the mesh points are aligned, it is still a good idea to use the
> interpolation approach as it removes the issue of worrying about mesh
> ordering.
>
> --
> Daniel Wheeler
> ___
> 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: FW: how to set up data transfer between two adjacent nonuniform meshs

2016-10-25 Thread Daniel Wheeler
On Tue, Oct 25, 2016 at 12:34 PM, Zhekai Deng
 wrote:
> Thank you. I implemented as you suggested and it works very good now. This
> approach seems also applicable for the mesh that are not aligned in the
> interface.

Exactly. One thing though, it is probably a good idea to cache the
mapping from one grid to the other as this is expensive to calculate
(especially of you do this at every time step or sweep). We provided
this functionality in FiPY, I'm not sure if Scipy lets you do that.

-- 
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: FW: how to set up data transfer between two adjacent nonuniform meshs

2016-10-25 Thread Zhekai Deng
Thanks for the tip. Right now, my code looks like following, where
Outlet_BC_value_new is being updated every time,  so does the
Outlet_BC_value. It is my understanding that every timestep,
Outlet_BC_value_new is being over-write with new interpolated value, and
being assign to the Variable, which automatically update it with the phi
constrain. Is this somewhat similar to what you are suggesting for the
cache the memory space ?


Outlet_BC_value = Variable(value = 0.5, array = numerix.zeros((1,102)))

phi.constrain(Outlet_BC_value, where = mesh_2.exteriorFaces &
mesh_2.physicalFaces["Right"])


if for step in range(steps):

 Outlet_BC_value_new = scipy.interpolate.griddata(points, values,
(xFace_2[a], yFace_2[a]), method='nearest')

 Outlet_BC_value.setValue(Outlet_BC_value_new)

 #Then solve equation


Best,


Zhekai

On Tue, Oct 25, 2016 at 11:44 AM, Daniel Wheeler 
wrote:

> On Tue, Oct 25, 2016 at 12:34 PM, Zhekai Deng
>  wrote:
> > Thank you. I implemented as you suggested and it works very good now.
> This
> > approach seems also applicable for the mesh that are not aligned in the
> > interface.
>
> Exactly. One thing though, it is probably a good idea to cache the
> mapping from one grid to the other as this is expensive to calculate
> (especially of you do this at every time step or sweep). We provided
> this functionality in FiPY, I'm not sure if Scipy lets you do that.
>
> --
> Daniel Wheeler
> ___
> 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: FW: how to set up data transfer between two adjacent nonuniform meshs

2016-10-25 Thread Daniel Wheeler
On Tue, Oct 25, 2016 at 12:59 PM, Zhekai Deng
 wrote:
> Thanks for the tip. Right now, my code looks like following, where
> Outlet_BC_value_new is being updated every time,  so does the
> Outlet_BC_value. It is my understanding that every timestep,
> Outlet_BC_value_new is being over-write with new interpolated value, and
> being assign to the Variable, which automatically update it with the phi
> constrain. Is this somewhat similar to what you are suggesting for the cache
> the memory space ?

Yes, however, profile first to see if it is relevant in your case.

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