A Navaei wrote:
> The following minimal test for Function in c++ reveals some bugs. I
> guess this example can help me with dealing with the current issues of
> ImageFunction.
> 
> (1) interpolate.py does not work when a Function is created in c++ and
> wrapped (see comment [2]). It seems that the bug is originated from
> the copy constructor (see comment [3])
> 
> (2) In order to perform the interpolation, why is it necessary to
> create another Function and then copy it?
> 
> (3) Signature checkes seem not working properly (see comment [1]). The
> signature-based assignments are error-prone anyway, why the
> object-oriented approach is not used?
> 

Signatures are used to permit reading/writing Functions to a file. They 
are indeed error prone, so I believe that we reached a consensus a short 
while ago that we would remove pre-compiled elements.

Garth

> 
> -Ali
> 
> -----------------------
> // FunctionTest.cpp
> 
> #include <dolfin/function/Function.h>
> #include <dolfin/function/FunctionSpace.h>
> #include <dolfin/mesh/Mesh.h>
> #include <dolfin/fem/FiniteElement.h>
> #include <dolfin/fem/DofMap.h>
> #include <dolfin/mesh/UnitSquare.h>
> 
> #include <boost/shared_ptr.hpp>
> 
> using namespace dolfin;
> 
> int main()
> {
>       typedef boost::shared_ptr< const Mesh > MeshConstPointerType;
>       typedef boost::shared_ptr< const FiniteElement > 
> ElementConstPointerType;
>       typedef boost::shared_ptr< const DofMap > DofMapConstPointerType;
>       
>       std::cout << "- Creating mesh...";
>       int msize[2];
>       msize[0] = 9; msize[1] = 9;
>       UnitSquare mesh(msize[0], msize[1]);
>       std::cout << "done." << std::endl;
>       
>       std::string elemSig("FiniteElement('Lagrange', 'triangle', 1)");
> //    std::string elemSig("dummy"); // [1] This gives segmentation fault.
>       std::string dofSig("FFC dof map for FiniteElement('Lagrange', 
> 'triangle', 1)");
>       
>       std::cout << "- Creating FunctionSpace...";
>       FunctionSpace V(MeshConstPointerType(&mesh, NoDeleter<const 
> dolfin::Mesh>()),
>                               ElementConstPointerType(new 
> dolfin::FiniteElement(elemSig)),
>                               DofMapConstPointerType(new 
> dolfin::DofMap(dofSig, mesh)));
>       std::cout << "done." << std::endl;
>                       
>       std::cout << "- Creating Function...";
>       Function v(V);
>       std::cout << "done." << std::endl;
>       
> /*    
>       // [2] This gives segmentation fault.
>       std::cout << "- Interpolating as interpolate.py...";
>       Function Pv(v); // [3] The copy ctor doesn't work.
>       v.interpolate(Pv.vector(), v.function_space());
>       std::cout << "done." << std::endl;
> */    
>       // [4] This seems to work fine.
>       std::cout << "- Interpolating...";
>       v.interpolate(v.vector(), v.function_space());
>       std::cout << "done." << std::endl;
> };
> -----------------------
> _______________________________________________
> DOLFIN-dev mailing list
> [email protected]
> http://www.fenics.org/mailman/listinfo/dolfin-dev


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

Reply via email to