← Back to team overview

dolfin team mailing list archive

Re: Vector type casting

 

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
>


-- 
Martin


Follow ups

References