I just realized I din't do reply to all... 

L. 

Begin forwarded message:

> From: Luca Heltai <[email protected]>
> Date: 02 settembre 2010 13.11.14 GMT+02.00
> To: Svyatoslav Gladkov <[email protected]>
> Subject: Re: [deal.II] Automatic differentiation with Sacado in deal.II
> 
>> I  have  rather  naive  question about automatic differentiation in
>>  deal.II:
>> Suppose I have a scalar function derived from Function<dim>. How can I
>> compute  derivative  (gradient)  of  this  function  in all quadrature
>> points with Sacado?
> 
> 
> I think you will have to implement it...
> 
> I'd proceed in the following way:
> 
> add your favorite sacado type (e.g.,  Sacado::Fad::DFad but also  
> Sacado::Fad::SFad would do in your case) as a member of your function, which 
> will store the function value (say it is called f_value)
> 
> When you evaluate f(p), you should do it in this way:
> 
> double MyFunction::value(Point<dim> &p) {
>       Sacado::Fad::SFad sacadop[dim];
>       for(unsigned int d=0; d<dim; ++d) {
>               sacadop[d].diff(d, dim);
>               sacadop[d] = p[d];
>       }
>       
>       f_value = your function of sacadop
>       return f_value.val;
> }
> 
> and in your grad you will have to first call value(p), and then access the 
> derivatives with respect to x, y and z as
> 
> f_value.derivative(d) with d=0,1,2
> 
> hope this helps. 
> 
> Luca.
> 
> 
> --
> Luca Heltai <[email protected]>
> http://people.sissa.it/~heltai/
> Scuola Internazionale Superiore di Studi Avanzati
> Phone:  +39 040 3787 449, Office: 732
> --
> There are no answers, only cross references.
> 
> 
> 
> 
> 
> 
> 

_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii

Reply via email to