← Back to team overview

dolfin team mailing list archive

Re: Vector type casting

 

Circular dependencies... But we could put templated functions in Generic*.

F.ex.:
Foo & v = vector_cast<Foo>(genericvector);

Templates must be renamed in the python interface though.

-- 
Martin


2008/4/11, Garth N. Wells <gnw20@xxxxxxxxx>:
> Would it be better to put the functions for casting in GenericVector (or
> perhaps even better in GenericTensor)?
>
>  Garth
>
>
>  Martin Sandve Alnæs wrote:
>
> > I think I'm done, but I'm not able to run the tests even on an
> > unmodified dolfin...
> > There's something fishy with the system I'm on now.
> >
> > If you can pull from
> >  hg pull
> ssh://yourname@xxxxxxxxxx//home/martinal/hg/dolfin
> > run the tests and push if it works, that would be great.
> >
> > I have to run now, so I'll have to finish this later if there's anything
> wrong.
> >
> > --
> > Martin
> >
> >
> > 2008/4/11, Ilmar Wilbers <ilmarw@xxxxxxxxx>:
> >
> > > OK, let me know when you are done.
> > >
> > >  ilmar
> > >
> > >
> > > Edit: sending to list
> > >
> > >
> > >  Martin Sandve Alnæs wrote:
> > >  > Wait... I got into a merge...
> > >  >
> > >  > 2008/4/11, Martin Sandve Alnæs <martinal@xxxxxxxxx>:
> > >  >
> > >  >> Can someone with a petsc installation pull from
> > >  >>     hg pull
> ssh://yourname@xxxxxxxxxx//home/martinal/hg/dolfin
> > >  >>  and check that it compiles, that the tests run, and then push it?
> > >  >>  I've done changes to uBlasVector and PETScVector but don't have
> petsc here...
> > >  >>
> > >  >>
> > >  >>  I've implemented type casting with only references in the user
> > >  >>  interface, which works like this:
> > >  >>
> > >  >>  void foo(GenericVector & gv)
> > >  >>  {
> > >  >>   uBlasVector & v = as_uBlasVector(gv);
> > >  >>   ublas_vector & w = v.vec();
> > >  >>
> > >  >>   // or:
> > >  >>
> > >  >>   ublas_vector & u = as_ublas_vector(gv);
> > >  >>   ...
> > >  >>  }
> > >  >>
> > >  >>  The as_* functions assumes that the input is of the correct
> underlying
> > >  >>  type and triggers a dolfin error on failure. There's also an is_*
> > >  >>  function:
> > >  >>
> > >  >>   if(is_uBlasVector(gv))
> > >  >>     trigger_ublas_solver_for_example(gv);
> > >  >>
> > >  >>  I've implemented similar functions for PETScVector, but I didn't
> have
> > >  >>  petsc installed here so I haven't tried to compile them.
> > >  >>
> > >  >>  Selecting good names for these are tricky, since we're dealing with
> > >  >>  names like uBlasVector, ublas_vector, PETScVector, and (PETSc) Vec,
> > >  >>  consistency is futile... Suggestions for better names?
> > >  >>
> > >  >>  --
> > >  >>
> > >  >> Martin
> > >  >>
> > >  >>
> > >  >
> > >  >
> > >  >
> > >
> > > _______________________________________________
> > >  DOLFIN-dev mailing list
> > >  DOLFIN-dev@xxxxxxxxxx
> > >  http://www.fenics.org/mailman/listinfo/dolfin-dev
> > >
> > >
> > _______________________________________________
> > DOLFIN-dev mailing list
> > DOLFIN-dev@xxxxxxxxxx
> > http://www.fenics.org/mailman/listinfo/dolfin-dev
> >
>
>


Follow ups

References