Hi everybody,
>
>> I'm attempting to create a program to implement a time-dependant problem
>> using a DG method and in calculating the exact error I need to calculate
>> the H^1 semi-norm on each cell. I was wondering whether
>> integrate_difference using the H^1 semi-norm can do this for DG - the
>> reason I ask is because while the rest of my error goes to zero as I
>> refine the mesh-size and the time-step, this portion of the error goes to
>> infinity if I use integrate_difference, which is clearly not correct.
>
>I believe the function should work -- it just does integration of the gradient
>on a particular cell, without regard for the element in use. Of course what
>you get is the broken H1 seminorm for each cell since your finite element
>solution is not in H1 when you use discontinuous elements.
>
>In other words, if your error goes to infinity, there must be a problem
>somewhere in computing the solution.
>
>W.
>
I had the same problem with the H1-norm or H1-seminorm when using Q1-elements
for a stabilized scheme of the dual mixed formulation of Laplace's equation.
But I did not figure out the mistake. Therefore I programmed the error
computation by hand. But I am still interested in the solution.
This is the code of the exact solution and integrate_difference() I tried to
use, it comes from step-20:
template <int dim>
class ExactSolution : public Function<dim> {
public:
ExactSolution() : Function<dim>(dim + 1) {
}
virtual void vector_value(const Point<dim> &p,
Vector<double> &value) const;
virtual void vector_gradient(const Point<dim> &p,
std::vector< Tensor < 1, dim > > & gradients) const;
};
template <int dim>
void ExactSolution<dim>::vector_value(const Point<dim> &p,
Vector<double> &values) const {
Assert(values.size() == dim + 1,
ExcDimensionMismatch(values.size(), dim + 1));
double pi;
pi = 3.14159265;
values(0) = 1.2 * pi * std::cos(pi * p[0]) * std::sin(pi * p[1]); //Sigma_x
values(1) = 1.2 * pi * std::sin(pi * p[0]) * std::cos(pi * p[1]); //Sigma_Y
values(2) = 1.2 * std::sin(pi * p[0]) * std::sin(pi * p[1]); //u
}
template <int dim>
void ExactSolution<dim>::vector_gradient(const Point<dim> &p,
std::vector< Tensor < 1, dim > > & gradients) const {
double pi;
pi = 3.14159265;
gradients[0][0] = -1.2 * pi * pi * std::sin(pi * p[0]) * std::sin(pi *
p[1]); //s_xx
gradients[0][1] = 1.2 * pi * pi * std::cos(pi * p[0]) * std::cos(pi *
p[1]); //s_xy
gradients[1][0] = 1.2 * pi * pi * std::cos(pi * p[0]) * std::cos(pi *
p[1]); //s_yx
gradients[1][1] = -1.2 * pi * pi * std::sin(pi * p[0]) * std::sin(pi *
p[1]); //s_yy
gradients[2][0] = 1.2 * pi * std::cos(pi * p[0]) * std::sin(pi * p[1]);
//u_x
gradients[2][1] = 1.2 * pi * std::sin(pi * p[0]) * std::cos(pi * p[1]);
//u_y
}
//in the compute_errors():
const ComponentSelectFunction<dim>
displacement_mask(dim, dim + 1); //dim=selected=2, dim+1=number
components=3
const ComponentSelectFunction<dim>
stress_mask(std::make_pair(0, dim), dim + 1);
Vector<double> cellwise_errors(triangulation.n_active_cells());
VectorTools::integrate_difference(dof_handler, solution, ExactSolution<dim
> (),
cellwise_errors, quadrature,
VectorTools::H1_norm,
&displacement_mask);
const double u_h1_error = cellwise_errors.l2_norm();
Maybe there is a mistake in the ExactSolution's definition?!
Nicole
___________________________________________________________
Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die
Toolbar eingebaut! http://produkte.web.de/go/toolbar
_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii