← Back to team overview

dolfin team mailing list archive

Re: [Fwd: Re: Image to Function data structure conversion]

 

On Mon, Feb 09, 2009 at 12:57:10PM +0000, A Navaei wrote:
> > > > > Anders Logg wrote:
> > > > > > How about adding ImageFunction to SpecialFunctions.h/cpp.
> > > > > >
> > > > > > It would require using the ITK C++ interface (I assume there is one),
> > > > > > adding a check for ITK to the build system and a flag HAS_ITK.
> > > > > >
> > > > >
> > > > > An ITK dependency sounds a bit specialised for DOLFIN to me. A good
> > > > > candidate for a fenics-apps perhaps?
> > > > >
> > > > Garth
> > > >
> > > > Yes maybe, but it would be fun to be able to do things like
> > > >
> > > > f = ImageFunction("dolfin.jpg")
> > > >
> > > > and use as a right-hand side.
> > >
> > > I guess the data structure conversion will be much more comprehensive
> > > than the discussed prototype sample for real world applications.
> > > Having the itk-dolfin interface as a wrapitk module, and encapsulating
> > > the itk dependencies as much as possible, would make life easier.
> > > Don't forget that itk, and the family, are cmake-based, hopefully that
> > > wouldn't be a problem for scons-oriented dolfin?
> >
> > That shouldn't be a problem as the two are built separately.
> 
> The interface includes headers from both libraries and has to be
> linked to both. It seems configuring dolfin in cmake for itk is easier
> than configuring itk in scons for dolfin, as the latter will require
> setting many parameters already implemented in cmake.

You should be able to just link against DOLFIN. All the information
you need is provided by pkg-config:

  pkg-config --cflags dolfin
  pkg-config --libs dolfin

> Once this is
> compiled as a python module, you can have something like
> 
> f = itk.ImageToDolfinFunction("dolfin.jpg")
> 
> as you mentioned previously. Obviously, it you want to call this from
> c++ you will need linking to both libraries again. It would be helpful
> if you could have a look at my dofmap question.

I'm not very keen on using it from C++, but if you want to initialize
a function in C++, you need to have a function space. The simplest way
would be to create a very simple form file and then compile it with
FFC (using -l dolfin). For example

  element = FiniteElement("Lagrange", "triangle", 1)
  v = TestFunction(element)
  u = TrialFunction(element)
  a = v*u*dx

If you store this in say a file named "P12D.form" you can then use the
generated class named

  P12DFunctionSpace

from C++. Instantiate the function space with a mesh and then use it
as argument to the constructor of your Function. No need to think
about DofMaps and FiniteElements.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References