non-equidistant grid spacing

Asked by Martin Hess

Hello,

when generating a mesh on a Box, I would like to able to set the coordinates manually,
for example in

  Box mesh(0,0,0,80,50,50,10,15,15);

I need the x-coordinates at say [0, 20, 30, 34, 38, 42, 46, 50, 60, 80].

Is there some way to achieve this?

Thanks for any help,

Martin

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Johan Hake
Solved:
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Tue, Nov 15, 2011 at 04:05:49PM -0000, Martin Hess wrote:
> New question #178877 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/178877
>
>
>
> Hello,
>
> when generating a mesh on a Box, I would like to able to set the coordinates manually,
> for example in
>
> Box mesh(0,0,0,80,50,50,10,15,15);
>
> I need the x-coordinates at say [0, 20, 30, 34, 38, 42, 46, 50, 60, 80].
>
> Is there some way to achieve this?

No. Either use the MeshEditor class to construct the mesh manually, or
modify the existing Box class to handle it.

--
Anders

Revision history for this message
Best Johan Hake (johan-hake) said :
#2

On Tuesday November 15 2011 08:20:53 Anders Logg wrote:
> Question #178877 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/178877
>
> Status: Open => Answered
>
> Anders Logg proposed the following answer:
>
> On Tue, Nov 15, 2011 at 04:05:49PM -0000, Martin Hess wrote:
> > New question #178877 on DOLFIN:
> > https://answers.launchpad.net/dolfin/+question/178877
> >
> >
> >
> > Hello,
> >
> > when generating a mesh on a Box, I would like to able to set the
> > coordinates manually, for example in
> >
> > Box mesh(0,0,0,80,50,50,10,15,15);
> >
> > I need the x-coordinates at say [0, 20, 30, 34, 38, 42, 46, 50, 60, 80].
> >
> > Is there some way to achieve this?
>
> No. Either use the MeshEditor class to construct the mesh manually, or
> modify the existing Box class to handle it.

Or just change the coordinates after the mesh is instantiated. The above can
be accomplished in Python with:

  mesh = Box(something)
  mesh.coordinates()[:, 0] = numpy.array([0, 20, 30, 34, 38, 42, 46, \
                                  50, 60, 80])

Johan

Revision history for this message
Anders Logg (logg) said :
#3

On Tue, Nov 15, 2011 at 04:45:42PM -0000, Johan Hake wrote:
> Question #178877 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/178877
>
> Johan Hake proposed the following answer:
> On Tuesday November 15 2011 08:20:53 Anders Logg wrote:
> > Question #178877 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/178877
> >
> > Status: Open => Answered
> >
> > Anders Logg proposed the following answer:
> >
> > On Tue, Nov 15, 2011 at 04:05:49PM -0000, Martin Hess wrote:
> > > New question #178877 on DOLFIN:
> > > https://answers.launchpad.net/dolfin/+question/178877
> > >
> > >
> > >
> > > Hello,
> > >
> > > when generating a mesh on a Box, I would like to able to set the
> > > coordinates manually, for example in
> > >
> > > Box mesh(0,0,0,80,50,50,10,15,15);
> > >
> > > I need the x-coordinates at say [0, 20, 30, 34, 38, 42, 46, 50, 60, 80].
> > >
> > > Is there some way to achieve this?
> >
> > No. Either use the MeshEditor class to construct the mesh manually, or
> > modify the existing Box class to handle it.
>
> Or just change the coordinates after the mesh is instantiated. The above can
> be accomplished in Python with:
>
> mesh = Box(something)
> mesh.coordinates()[:, 0] = numpy.array([0, 20, 30, 34, 38, 42, 46, \
> 50, 60, 80])

Clever!

--
Anders

Revision history for this message
Martin Hess (hessm) said :
#4

Thanks Johan Hake, that solved my question.