dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #12544
Re: recompute& evaluate a function/vector
On Thu, Mar 05, 2009 at 04:55:38PM +0100, Patrick Riesen wrote:
> hi all
>
> i'm stuck on the following problem:
>
> i'd like to compute a term as
>
> eta = (gamma)^(-2/3), or general eta = gamma^(n) and n is real
>
>
> in my code, gamma is dependent on a velocity function from a previous
> interation, so gamma = gamma(u0), and how to compute gamma stems from a
> form-file, so i do:
>
> _M_gamma = new gammaFunctional(u0);
>
> Function f_gamma(&mesh, *M_gamma, 0);
>
>
> my question is now
>
> how can i create the other function f_eta = f_gamma^(2/3) in a nice way?
>
> what i thought about is to create a derived function class Eta where
> overload the evaluation function in a way as
>
> double eval(const double* x) const
> {
> return (gamma.eval(x)*gamma.eval(x))^(-1/3)
> }
>
> please tell me if this is a possible approach, or else advise me how to
> handle this :-)
>
>
> thanks a lot for the support,
>
> patrick
>
> (btw i do this together with dolfin-grade2 so i use dolfin0.8.1 )
I'd suggest operating on the vectors of dofs. Send in the gamma
function to the constructor of your Function subclass, pick out the
vector of dofs, iterate over the dofs and just insert the values into
the vector using pow(x[i], 2.0/3.0).
Use the get/set methods in Vector to first pick out arrays, operate on
the arrays and then put them back.
--
Anders
Attachment:
signature.asc
Description: Digital signature
Follow ups
References