Hi everybody:

In a previous email about calculating the Laplacian of a scalar field named  
"phi", you have told me to use:
/
/

/FETools::compute_projection_from_quadrature_points_matrix / /(/ /const FiniteElement <http://www.dealii.org/6.1.0/doxygen/deal.II/classFiniteElement.html>< dim > & / //fe/, /
/
/       /
/ /const Quadrature <http://www.dealii.org/6.1.0/doxygen/deal.II/classQuadrature.html>< dim > & / //lhs_quadrature/, /
/
/       /
/ /const Quadrature <http://www.dealii.org/6.1.0/doxygen/deal.II/classQuadrature.html>< dim > & / //rhs_quadrature/, /
/
/       /
/ /FullMatrix <http://www.dealii.org/6.1.0/doxygen/deal.II/classFullMatrix.html>< double <http://www.dealii.org/6.1.0/doxygen/deal.II/classdouble.html> > & / //X// / /
/
/       /)/     /
/


So I want to calculate "rho(x,y,z)=-div(grad(phi))".

And I have:

/QGauss<DIMENSION> quadrature_formula(3);
const unsigned int n_q_points = quadrature_formula.n_quadrature_points; FEValues<DIMENSION> fe_values (fe_fc, quadrature_formula, UpdateFlags(update_values | update_gradients | update_q_points | update_normal_vectors | update_second_derivatives|
                                                       //update_hessians|
                                                       update_JxW_values));

std::vector< Tensor< 2, DIMENSION > > values;
values.resize(n_q_points);

std::vector<double > values2;
values2.resize(n_q_points);/

/.
.
.
/

/for (; cell_p!=endc; ++cell_p)
 {
 cell_rhs=0.0;
 fe_values.reinit (cell_p);
fe_values.get_function_2nd_derivatives (phi, values); for (unsigned int q_point=0;q_point<n_q_points;q_point++)
          
values2[q_point]=(values[q_point][0][0]+values[q_point][1][1]+values[q_point][2][2]);

//.
.
.
}
/
It is clear that "fe_fc" is the variable "fe" in method
FETools::compute_projection_from_quadrature_points_matrix()


But, how should I take the variables "lhs_quadrature", "rhs_quadrature" and the matrix "X". All of them are the variables inside the previous method.

Or perhaps there is an easier way to calculate the Laplacian of a known scalar field.

Thanks in advace.
My best.
Isa


Andrew McBride escribió:
Sorry, I meant the trace of the Hessian. You only need the Jacobian determinant if you performing an integration and need to transform the limits of integration. The value of the interpolation function at the quadrature points on the reference cell and the actual cell are the same.

You would need to divide by the volume of the cell to get the average value on the cell.

Andrew

Am 17 May 2010 um 11:56 AM schrieb Isabel Gil:

Hi!

Thanks for your answer.

Andrew McBride escribió:
Hi Isabel

I'm confused by a couple of things.

You want to determine the trace of the Laplacian of Phi at the quadrature points and then extrapolate the calculated values back to the nodes? Why are you multiplying the value at the quadrature point by fe_values.JxW(q_point)? This implies that you are doing integration based on nodal values as opposed to extrapolation. What you want to do is just extrapolate the quadrature point data back to the nodes without integrating. The function you need to do this FETools::compute_projection_from_quadrature_points_matrix The projection is on an element so the result will be globally discontinuous.
What I want to calculate is the Laplacian of Phi over the nodes of my mesh.

When I use the loop "for (unsigned int q_point=0;q_point<n_q_points;q_point++)", I always multiply by "fe_values.JxW(q_point)" to get the transformation from reference to real cell.
In calculating the integral why are you using the 
fe_face_values.get_function_values (rho,values)? I would extrapolate the values 
at the nodes to the quadrature points and then integrate them using a sum over 
the quadrature points and multiplying each  quadrature point contribution by 
fe_values.JxW(q_point). There may even be a deal function that does this?
Sorry, I made a mistake :-[ . What I wanted to use (and indeed I use) was "fe_values.get_function_values (rho,values);" But, once I have the "integral" value, should I divide it by the volume to get the average or does the "integral" value itself contain the avarage?

Thanks again.
Best.
Isa
Cheers
Andrew



Am 17 May 2010 um 10:58 AM schrieb Isabel Gil:

Hi!

I have the value of the scalar phi(x,y,z) and I would like to calculate 
rho(x,y,z)=- const*div(grad(phi)), so I do:
.
.
.
for (; cell_p!=endc; ++cell_p)
  {
  cell_rhs=0.0;
  fe_values.reinit (cell_p);
fe_values.get_function_2nd_derivatives (phi, values); for (unsigned int i=0; i<dofs_per_cell; ++i) cell_rhs(i)-=const*fe_values.shape_value(i,q_point)*
                          
(values[q_point][0][0]+values[q_point][1][1]+values[q_point][2][2])*fe_values.JxW(q_point);

  cell_p-> get_dof_indices(local_dof_indices);
  for (unsigned int i=0;i<dofs_per_cell;++i)
        rho(local_dof_indices[i]) += cell_rhs(i);          }

Secondly, I would like to calculate the average rho, so I do:

double integral=0.0;

for (; cell_p!=endc; ++cell_p)
  {
  fe_values.reinit (cell_p);
  fe_face_values.get_function_values (rho,values);

        for (unsigned int q_point=0;q_point<n_q_points;q_point++)
               integral += values[q] * fe_face_values.JxW(q);
  }

Are both pieces of code all right?

Does the value of integral correspond to {(1/Volume)*integral (rho)} or only to 
{integral(rho)}?

Thanks in advance.
Best
Isa

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



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


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

Reply via email to