On Mon, Feb 09, 2009 at 02:24:46PM +0000, A Navaei wrote:
> >
> > 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
> 
> Is this approach platform-independent or are there solutions for other
> platforms?

Yes, pkg-config works on many platforms.

> >> 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.
> 
> Me neither, but there is no choice: we need a way for data conversion
> without going through numpy everytime.
> 
> > 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
> 
> I would like the user to have the option of specifying the finite
> element corresponded to the image function space. Is there a more
> dynamic way of doing this? I guess the following would work if we can
> assign the right signature for dofmap, it hides Mesh and DofMap
> dependencies in the cunstructor:
> 
> 
> class ImageFunctionSpace : public FunctionSpace
> {
> public:
>       ImageFunctionSpace(const ImageType* & imageData, const FiniteElement& 
> element)
>       {
>               PixelType * buffer = const_cast<PixelType *>
> (imageData->GetBufferPointer()); // imageData is an itk image type
> instance
>               m_ImageData = (double *) (buffer);
> 
>               m_ImageSize = image->GetBufferedRegion().GetSize();
> 
>               dolfin::Mesh mesh;
>               if(ImageDimension == 2)
>               {
>                       mesh = UnitSquare(m_ImageSize[0], m_ImageSize[1]);
>               }
>               else if(ImageDimension == 3)
>               {
>                       mesh = UnitCube(m_ImageSize[0], m_ImageSize[1], 
> m_ImageSize[2]);
>               }
> 
>               dolfin::DofMap dofmap("?", mesh); // <-- what's the right 
> signature?
>       
>               FunctionSpace(mesh, element, dofmap);
>       };
> 
>       void eval(double* values, const double* x, const Function& v) const;
>       {
>               if(ImageDimension == 2)
>               {
>                       int i = int((m_ImageSize[0] - 1) * x[0]);
>                       int j = int((m_ImageSize[1] - 1) * x[1]);
>                       int index = i + (m_ImageSize[0] * j);
>                       values[0] = m_ImageData[index];
>               }
>               else if(ImageDimension == 3)
>               {
>                       int i = int((m_ImageSize[0] - 1) * x[0]);
>                       int j = int((m_ImageSize[1] - 1) * x[1]);
>                       int k = int((m_ImageSize[2] - 1) * x[2]);
>                       int index = i + (m_ImageSize[0] * j) + (m_ImageSize[0] 
> * m_ImageSize[1] * k);
>                       values[0] = m_ImageData[index];
>               }
>       }
> 
> protected:
>       double *m_ImageData;
>       int[ImageDimension] m_ImageSize;
> };

Try looking at the functions

  ElementLibrary::create_finite_element(std::string signature);
  ElementLibrary::create_dof_map(std::string signature);

They are defined in dolfin/elements/ElementLibrary.h/cpp.

-- 
Anders

Attachment: signature.asc
Description: Digital signature

_______________________________________________
DOLFIN-dev mailing list
[email protected]
http://www.fenics.org/mailman/listinfo/dolfin-dev

Reply via email to