Пример #1
0
void   ad_f(DERIV_TYPE  *ad_var_ret,DERIV_TYPE  x) {
DERIV_TYPE  y;
    double  ad_loc_0;
    double  ad_loc_1;
    double  ad_loc_2;
    double  ad_adj_0;
    {
        ad_loc_0 = 2 * DERIV_val(x);
        ad_loc_1 = ad_loc_0 * DERIV_val(x);
        ad_loc_2 = ad_loc_1 - 3.12;
        ad_adj_0 = 2 * DERIV_val(x);
        ad_grad_axpy_2(&(y), ad_adj_0, &(x), ad_loc_0, &(x));
        DERIV_val(y) = ad_loc_2;
    }
    {
        ad_grad_axpy_copy(&(*ad_var_ret), &(y));
        DERIV_val(*ad_var_ret) = DERIV_val(y);
    }
    return;
}
Пример #2
0
void   adic_element_fill(ElemData  *e,unsigned int  neqn,const DERIV_TYPE  *x,DERIV_TYPE  *u,DERIV_TYPE  *du,DERIV_TYPE  *f) {
unsigned int  var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7, var_8;
DERIV_TYPE  var_9;
double  adji_0;
    double  loc_0;
    double  loc_1;
    double  loc_2;
    double  loc_3;
    double  loc_4;
    double  loc_5;
    double  loc_6;
    double  loc_7;
    double  loc_8;
    double  loc_9;
    double  loc_10;
    double  loc_11;
    double  adj_0;
    double  adj_1;
    double  adj_2;
    double  adj_3;
    double  adj_4;

        static int g_filenum = 0;
        if (g_filenum == 0) {
            adintr_ehsfid(&g_filenum, __FILE__, "adic_element_fill");
        }
            for (unsigned int  qp = 0;     qp < e->nqp;     )    {
        for (unsigned int  eqn = 0;         eqn < neqn;         )        {
            {
                ad_grad_axpy_0(&(u[qp * neqn + eqn]));
                DERIV_val(u[qp * neqn + eqn]) = 0.0;
            }
            {
                ad_grad_axpy_0(&(du[qp * neqn + eqn]));
                DERIV_val(du[qp * neqn + eqn]) = 0.0;
            }
            for (unsigned int  node = 0;             node < e->nnode;             )            {
                {
                    loc_0 = DERIV_val(x[node * neqn + eqn]) * e->phi[qp][node];
                    loc_1 = DERIV_val(u[qp * neqn + eqn]) + loc_0;
                    ad_grad_axpy_2(&(u[qp * neqn + eqn]), 1.000000000000000e+00, &(u[qp * neqn + eqn]), e->phi[qp][node], &(x[node * neqn + eqn]));
                    DERIV_val(u[qp * neqn + eqn]) = loc_1;
                }
                {
                    loc_0 = DERIV_val(x[node * neqn + eqn]) * e->dphi[qp][node];
                    loc_1 = DERIV_val(du[qp * neqn + eqn]) + loc_0;
                    ad_grad_axpy_2(&(du[qp * neqn + eqn]), 1.000000000000000e+00, &(du[qp * neqn + eqn]), e->dphi[qp][node], &(x[node * neqn + eqn]));
                    DERIV_val(du[qp * neqn + eqn]) = loc_1;
                }
                var_2 = node++;
            }
            var_1 = eqn++;
        }
        var_0 = qp++;
    }
DERIV_TYPE  *s = malloc((e->nqp * neqn) *  sizeof (DERIV_TYPE ));
    for (unsigned int  qp = 0;     qp < e->nqp;     )    {
        for (unsigned int  eqn = 0;         eqn < neqn;         )        {
            {
                ad_grad_axpy_0(&(s[qp * neqn + eqn]));
                DERIV_val(s[qp * neqn + eqn]) = 0.0;
            }
            for (unsigned int  j = 0;             j < neqn;             )            {
                if (j != eqn)                 {
                    {
                        loc_0 = DERIV_val(s[qp * neqn + eqn]) + DERIV_val(u[qp * neqn + j]);
                        ad_grad_axpy_2(&(s[qp * neqn + eqn]), 1.000000000000000e+00, &(s[qp * neqn + eqn]), 1.000000000000000e+00, &(u[qp * neqn + j]));
                        DERIV_val(s[qp * neqn + eqn]) = loc_0;
                    }
                }
                var_5 = j++;
            }
            var_4 = eqn++;
        }
        var_3 = qp++;
    }
    for (unsigned int  node = 0;     node < e->nnode;     )    {
        for (unsigned int  eqn = 0;         eqn < neqn;         )        {
unsigned int  row = node * neqn + eqn;
            {
                ad_grad_axpy_0(&(f[row]));
                DERIV_val(f[row]) = 0.0;
            }
            for (unsigned int  qp = 0;             qp < e->nqp;             )            {
     DERIV_val(var_9) = exp(( DERIV_val(u[qp * neqn + eqn])));  /*exp*/
      adji_0 = DERIV_val(var_9);
                {
                    ad_grad_axpy_1(&(var_9), adji_0, &(u[qp * neqn + eqn]));
                }
                {
                    loc_0 = e->w[qp] * e->jac[qp];
                    loc_1 = e->jac[qp] * e->jac[qp];
                    loc_2 = 1.0 / loc_1;
                    loc_3 =  -loc_2;
                    loc_4 = loc_3 * DERIV_val(du[qp * neqn + eqn]);
                    loc_5 = loc_4 * e->dphi[qp][node];
                    loc_6 = DERIV_val(u[qp * neqn + eqn]) * DERIV_val(s[qp * neqn + eqn]);
                    loc_7 = DERIV_val(var_9) + loc_6;
                    loc_8 = e->phi[qp][node] * loc_7;
                    loc_9 = loc_5 + loc_8;
                    loc_10 = loc_0 * loc_9;
                    loc_11 = DERIV_val(f[row]) + loc_10;
                    adj_0 = e->phi[qp][node] * loc_0;
                    adj_1 = DERIV_val(u[qp * neqn + eqn]) * adj_0;
                    adj_2 = DERIV_val(s[qp * neqn + eqn]) * adj_0;
                    adj_3 = e->dphi[qp][node] * loc_0;
                    adj_4 = loc_3 * adj_3;
                    ad_grad_axpy_5(&(f[row]), 1.000000000000000e+00, &(f[row]), adj_4, &(du[qp * neqn + eqn]), adj_0, &(var_9), adj_2, &(u[qp * neqn + eqn]), adj_1, &(s[qp * neqn + eqn]));
                    DERIV_val(f[row]) = loc_11;
                }
                var_8 = qp++;
            }
            var_7 = eqn++;
        }
        var_6 = node++;
    }
    free(s);
}