Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
adic_element_fill.c
Go to the documentation of this file.
1 #include <math.h>
2 #include <stdlib.h>
3 
4 typedef struct {
5  int nqp;
6  int nnode;
7  InactiveDouble *w, *jac, **phi, **dphi;
8  int *gid;
9 } ElemData;
10 
12  unsigned int neqn,
13  const double* x,
14  double* u,
15  double* du,
16  double* f) {
17  /* Construct element solution, derivative */
18  for (unsigned int qp=0; qp<e->nqp; qp++) {
19  for (unsigned int eqn=0; eqn<neqn; eqn++) {
20  u[qp*neqn+eqn] = 0.0;
21  du[qp*neqn+eqn] = 0.0;
22  for (unsigned int node=0; node<e->nnode; node++) {
23  u[qp*neqn+eqn] += x[node*neqn+eqn] * e->phi[qp][node];
24  du[qp*neqn+eqn] += x[node*neqn+eqn] * e->dphi[qp][node];
25  }
26  }
27  }
28 
29  /* Compute sum of equations for coupling */
30  double *s = malloc(e->nqp*sizeof(double));
31  for (unsigned int qp=0; qp<e->nqp; qp++) {
32  s[qp] = 0.0;
33  for (unsigned int eqn=0; eqn<neqn; eqn++)
34  s[qp] += u[qp*neqn+eqn]*u[qp*neqn+eqn];
35  }
36 
37  /* Evaluate element residual */
38  for (unsigned int node=0; node<e->nnode; node++) {
39  for (unsigned int eqn=0; eqn<neqn; eqn++) {
40  unsigned int row = node*neqn+eqn;
41  f[row] = 0.0;
42  for (unsigned int qp=0; qp<e->nqp; qp++) {
43  f[row] +=
44  e->w[qp]*e->jac[qp]*(-e->dphi[qp][node]/(e->jac[qp]*e->jac[qp])*du[qp*neqn+eqn] + e->phi[qp][node]*s[qp]*exp(u[qp*neqn+eqn]));
45  }
46  }
47  }
48 
49  free(s);
50 }
InactiveDouble * jac
InactiveDouble * w
void adic_element_fill(ElemData *e, unsigned int neqn, const DERIV_TYPE *x, DERIV_TYPE *u, DERIV_TYPE *du, DERIV_TYPE *f)
double InactiveDouble
Definition: ad_deriv.h:20
InactiveDouble ** phi
InactiveDouble ** dphi
exp(expr.val())