Dear Colleagues,
I am working on thermal analysis where deal.ii Step-26 is being considered. In my case the thermal diffusivity (Coefficient being multiplied with Laplace Matrix) is temperature dependent and hence varying in every cell (or node). That is why I want to make the current Step-26 code flexible to cater this feature.
I have two questions regarding this:
1) Instead of directly creating the global Mass and Laplace matrices, I am making the cell_matrix as well as the cell_rhs as per following simple code (where to keep it simple, so far source term and diffusivity values are not yet present) :
for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
{
for (unsigned int i = 0; i < dofs_per_cell; ++i)
{
for (unsigned int j = 0; j < dofs_per_cell; ++j)
{
VectorTools::point_value(dof_handler_temperature, old_solution_thermal, cell_temperature->vertex(j), temperature_old_solution_spatial_point);
cell_matrix(i, j) += ( fe_values_temperature.shape_value(i , q_point) * fe_values_temperature.shape_value(j , q_point) +
time_step * theta *
fe_values_temperature.shape_grad(i , q_point) * fe_values_temperature.shape_grad(j , q_point) )
* fe_values_temperature.JxW(q_point);
cell_rhs(i) += (
temperature_old_solution_spatial_point[0] *
( fe_values_temperature.shape_value(i , q_point) * fe_values_temperature.shape_value(j , q_point) -
time_step * (1 - theta) *
fe_values_temperature.shape_grad(i , q_point) * fe_values_temperature.shape_grad(j , q_point) )
) * fe_values_temperature.JxW(q_point);
}
}
}
The issue is that it is taking very long time to run VectorTools::point_value(dof_handler_temperature,
old_solution_thermal, cell_temperature->vertex(j), temperature_old_solution_spatial_point); function for evaluating the temperature_old_solution_spatial_point. But the results match with the original Step-26 code.
However as an efficient alternative, I tried to use the temperature_old_solution_qpoint in cell_rhs instead of temperature_old_solution_spatial_point which is very fast to compute but gives me the correct solution only at first time step after that the difference between this new and the old solution (from original Step-26 code) starts increasing i.e. new modified code solution kind of lags behind the original code (old) solution as per shared in the result snap shots in attachment.
Any suggestion to improve the efficiency of current approach or any correction (in case I am mistaking or missing something) would be more than welcomed.
2) Rather than making and assembling the local cell matrix and cell rhs, Is it more efficient and flexible way in deal.ii to directly modify the global Laplace matrix and system rhs in Step-26 for variable diffusivity coefficients at different corresponding dof entries? (Hopefully the dynamic sparsity pattern and preconditioning etc. might not disturb the indexing of dofs in this case)
Looking forward for guiding response. Thanks in advance for time and attention!
Best regards,
Muhammad Mashhood