integration on boundary error

49 views
Skip to first unread message

Pearl Flath

unread,
Oct 8, 2012, 6:37:27 PM10/8/12
to dealii
Dear Deal II,
I have a gradient vector formed by integrating the control, the
derivative of the state solution, the derivative of the adjoint, and a
shape function. In the attached picture, it is the bottom right. This
is a 1D problem, and the boundary nodes are off by 1/2. I can't figure
out why. Is there something obvious in deal II that I've left out? The
adjoint and state and control are all smooth, so I cannot figure out
why combining them would produce the error. Note that I also see the
problem if I drop the other coefficents and try to integrate only the
adjoint_gradient or state_gradient.



typename DoFHandler<dim>::active_cell_iterator cell =
dof_handler.begin_active(),
end_cell = dof_handler.end();
// loop over all cells
for (;cell!=end_cell; ++cell)
{

fe_values.reinit (cell);
cell_vector = 0;

fe_values.get_function_values(control, control_values);
fe_values.get_function_gradients(state_solution, state_gradient);
fe_values.get_function_gradients(adjoint_solution, adjoint_gradient);
fe_values.get_function_values(adjoint_solution, adjoint_values);

for (unsigned int q_point=0; q_point<n_q_points; ++q_point){
for (unsigned int i=0; i<dofs_per_cell; ++i){

cell_vector(i) += fe_values.shape_value(i,q_point) *
exp(control_values[q_point]) *
(adjoint_gradient[q_point] *
state_gradient[q_point]) *
fe_values.JxW(q_point);
}
}

//add cell matrix to global matrix
cell->get_dof_indices (local_dof_indices);
for (unsigned int i=0; i<dofs_per_cell; ++i)
{
solution_vector(local_dof_indices[i])+= cell_vector(i);
}
}
badtest.png

Wolfgang Bangerth

unread,
Oct 8, 2012, 10:54:06 PM10/8/12
to dea...@googlegroups.com, Pearl Flath, dealii

> I have a gradient vector formed by integrating the control, the
> derivative of the state solution, the derivative of the adjoint, and a
> shape function. In the attached picture, it is the bottom right. This
> is a 1D problem, and the boundary nodes are off by 1/2. I can't figure
> out why. Is there something obvious in deal II that I've left out?

While you plot the vector as if it is function (by connecting dots with
straight lines), the thing you compute is in fact an element of the dual
space. To wit:
- A vector in primal space is a vector of nodal values so that
sum_i U_i phi_i(x)
is a reasonable function. Solution vectors are examples of elements
of primal space.
- A vector in dual space is a vector W formed from the integration of
an object in primal space against the shape functions, e.g.
W_i = int f(x) phi_i(x)
Examples of dual vectors are right hand sides. Your vector is another
some such.

For vectors in dual space, it doesn't make sense to plot them as
functions of the form
sum_i W_i phi_i(x)
The reason is that the values of the coefficients W_i are not of
*amplitude* kind. Rather, the W_i are of kind amplitude (e.g. f(x))
times integration volume (the integral * dx over the support of shape
functions phi_i). In other words, the sizes of cells comes into play for
W_i, as does whether a shape function lies in the interior or at the
boundary. In your case, the area of the integral when you integrate
against shape functions at the boundary happens to be half the size of
the integration area for shape functions in the interior.

Best
W.

PS: I've made this mistake myself a number of times over the years, so
I've put a variant of this answer on the (new google code) wiki as well.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/

Reply all
Reply to author
Forward
0 new messages