constraints.clear();
constraints.reinit(locally_relevant_dofs);
VectorTools::interpolate_boundary_values(dof_handler, BOUNDARY_NUM, BoundaryValues_T<dim>(),constraints);
constraints.close();
VectorTools::project (dof_handler, constraints, QGauss<dim>(degree),
InitialValues_T<dim>(),
old_solution_T_cal);
www: http://www.math.colostate.edu/~bangerth/
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/5hC7jODg-7k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
SolverControl solver_control (dof_handler.n_dofs(),1e-12)
SolverControl solver_control (5*system_rhs.size(),1e-12*system_rhs.l2_norm())
In general, using MatrixTools::apply_boundary_values() is not the way to go
with MPI programs. Rather, use a ConstraintMatrix and incorporate the boundary
values into the same object as you do with hanging node constraints.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
mass_matrix_T.vmult (system_rhs, old_solution_T_cal);
//---------------------------------------
//Updating of T in time domain------the old way, working in non-mpi version
//---------------------------------------
//
//time dependent
//assign right hand side
mass_matrix_T.vmult (system_rhs, old_solution_T_cal);
laplace_matrix_T.vmult (tmp, old_solution_T_cal);
system_rhs.add (-time_step * (1-theta), tmp);
assemble_rhs_T (time);
forcing_terms = dynamic_rhs_T;
forcing_terms *= time_step * theta;
assemble_rhs_T (time - time_step);
tmp = dynamic_rhs_T;
forcing_terms.add (time_step*(1-theta),tmp);
system_rhs.add (1,forcing_terms);
//assign system matrix
system_matrix.copy_from (mass_matrix_T);
system_matrix.add (time_step * theta, laplace_matrix_T);
On 10/15/2017 12:41 PM, Mark Ma wrote:
>
> Now the projection of initial values (rewrite the code by manually assemble
> the matrix and system_rhs and calculate) run OK, but the time updating of T is
> not correct, same phenomenon appears. I believe this may arise from the fact
> that direct using matrix vmult (i.e.
> |
> mass_matrix_T.vmult (system_rhs,old_solution_T_cal);
> |
>
> ) instead of assembling and distribute_local_to_global again may ignore
> eliminating the constraint points in matrix or vector, when using
> constriantMatrix and interporate_boundary_values to apply the boundary
> condition, I am now checking of this.
So when you visualize the solution, the error is at the boundary but it looks
correct in the interior?
> Is there a simple way to update the RHS of old value using something simple
> like vmult?
What is the equation you are trying to implement?
> So when you visualize the solution, the error is at the boundary but it looks
> correct in the interior?
>
> Yes, it is. Thereafter, the error at boundaries does propagate and then
> interfere with the interior.
From the pictures you posted in a follow-up, it looks like the boundary
values are actually correct, but that the problem starts one layer of cells
into the domain. Do I see this correctly?
> > Is there a simple way to update the RHS of old value using something
> simple
> > like vmult?
>
> What is the equation you are trying to implement?
>
> I am trying just the Heat equation,
> rho * C * dT/dt = nabla *(kappba nalbaT) + f(x,y,t);
> Boundary condition is,
> T(x,y,z,t) = 300K, at boundaries.
I meant the "update the RHS of old value" equation.
On 10/16/2017 08:55 AM, Mark Ma wrote:
>
> > So when you visualize the solution, the error is at the boundary
> but it looks
> > correct in the interior?
> >
> > Yes, it is. Thereafter, the error at boundaries does propagate and then
> > interfere with the interior.
>
> From the pictures you posted in a follow-up, it looks like the boundary
> values are actually correct, but that the problem starts one layer of cells
> into the domain. Do I see this correctly?
>
>
> Yes, exactly. And if I use the BC values as 0, then it seems OK now (see figs
> below). What if I want to apply some value other than 0, this problem seems
> annoying.
Yes, bugs are highly annoying indeed :-)
It almost looks to me like you're applying both Dirichlet values (via the
ConstraintMatrix) and Neumann boundary values (via a boundary integral). But
then I haven't taken a look at the code, so I can't really say for sure.
On 10/16/2017 09:23 AM, Mark Ma wrote:
>
> It almost looks to me like you're applying both Dirichlet values (via
> the ConstraintMatrix) and Neumann boundary values (via a boundary
> integral). But then I haven't taken a look at the code, so I can't
> really say for sure.
>
>
> I think I only applied Dirichlet values via ConstraintMatrix. There
> is no boundary integrals, so I believe Neumann BC is not
> implemented.
My guess came from the fact that a Neumann boundary condition would act
like a boundary heat source. It looks like you have a heat source in the
last layer of cells around the boundary.
I don't know whether that is true, but it's a place I'd try to
investigate in debugging.
//
//time dependent
//assign right hand side
mass_matrix_T.vmult (system_rhs, old_solution_T_cal);
laplace_matrix_T.vmult (tmp, old_solution_T_cal);
system_rhs.add (-time_step * (1-theta), tmp);
/*
assemble_rhs_T (time);
forcing_terms = dynamic_rhs_T;
forcing_terms *= time_step * theta;
assemble_rhs_T (time - time_step);
tmp = dynamic_rhs_T;
forcing_terms.add (time_step*(1-theta),tmp);
system_rhs.add (1,forcing_terms);
*/
//assign system matrix
system_matrix.copy_from (mass_matrix_T);
system_matrix.add (time_step * theta, laplace_matrix_T);
> But may be you are right since for most of the case, heat equations
> are solved assuming an adiabatic process, that is dT/dx = 0 at
> boundaries. This zero values is automatically satisfied.
That's a different question. Whether one may *physically* want a
different equation is besides the point -- you have chosen one equation
you'd like to solve, but the numerical solution is wrong. It's
worthwhile trying to understand why that is before thinking about
*other* equations.
> I think the problem comes from the way of setting Boundary values
> using constraint method, which in dealii it makes some kind of
> constraints at vertex of boundaries, i.e. x22 = x1/2 + x2/2,
Hm, that would be the constraint of a hanging node. Do you have hanging
nodes in your problem? If you do, may I suggest to simplify the problem
and see if you have the same problem on uniform meshes?
local_rho_c_T_matrix(i,j) += (rho_C_fun_T.value(fe_values.quadrature_point(q)) *
phi_i_u *
phi_j_u *
fe_values.JxW (q))
+
time_step_00 * (1-theta) *
(kappa_fun_T.value(fe_values.quadrature_point(q)) *
div_phi_i_u *
div_phi_j_u *
fe_values.JxW (q));
local_kappa_T_matrix(i,j) += (rho_C_fun_T.value(fe_values.quadrature_point(q)) *
phi_i_u *
phi_j_u *
fe_values.JxW (q))
+
time_step_00 * (theta) *
(kappa_fun_T.value(fe_values.quadrature_point(q)) *
div_phi_i_u *
div_phi_j_u *
fe_values.JxW (q));
.....
--------------------------------------------------------------------------
constraints.distribute_local_to_global(local_rho_c_T_matrix,
local_dof_indices,
mass_matrix_T);
constraints.distribute_local_to_global(local_kappa_T_matrix,
local_dof_indices,
laplace_matrix_T);
for (timestep_number=1, time=time_step;
time<= global_simulation_end_time;
time+=time_step, ++timestep_number)
{
pcout << "Time step " << timestep_number
<< " at t=" << time
<< std::endl;
mass_matrix_T.vmult (system_rhs_T, old_solution_T_cal);
assemble_rhs_T (time);
forcing_terms = dynamic_rhs_T;
forcing_terms *= time_step * theta;
assemble_rhs_T (time - time_step);
tmp = dynamic_rhs_T;
forcing_terms.add (time_step*(1-theta),tmp);
system_rhs_T.add(1,forcing_terms);
system_matrix_T.copy_from (laplace_matrix_T);
solve_T_run (); // solve and store solution to new_solution_T
//
old_solution_T = new_solution_T; // used for output, GHOST CELLS
old_solution_T_cal = new_solution_T;
local_rho_c_T_matrix(i,j) += (rho_C_fun_T.value(fe_values.quadrature_point(q)) *
phi_i_u *
phi_j_u *
fe_values.JxW (q));
local_kappa_T_matrix(i,j) += (kappa_fun_T.value(fe_values.quadrature_point(q)) *
div_phi_i_u *
div_phi_j_u *
fe_values.JxW (q));
.....
--------------------------------------------------------------------------
constraints.distribute_local_to_global(local_rho_c_T_matrix,
local_dof_indices,
mass_matrix_T);
constraints.distribute_local_to_global(local_kappa_T_matrix,
local_dof_indices,
laplace_matrix_T);
for (timestep_number=1, time=time_step;
time<= global_simulation_end_time;
time+=time_step, ++timestep_number)
{
pcout << "Time step " << timestep_number
<< " at t=" << time
<< std::endl;
mass_matrix_T.vmult (system_rhs_T, old_solution_T_cal);
laplace_matrix_T.vmult (tmp,old_solution_T_cal);
system_rhs_T.add(-time_step * (1-theta),tmp);
assemble_rhs_T (time);
forcing_terms = dynamic_rhs_T;
forcing_terms *= time_step * theta;
assemble_rhs_T (time - time_step);
tmp = dynamic_rhs_T;
forcing_terms.add (time_step*(1-theta),tmp);
system_rhs_T.add(1,forcing_terms);
// system_matrix_T
system_matrix_T.copy_from (mass_matrix_T);
system_matrix_T.add (time_step * theta, laplace_matrix_T);
solve_T_run (); // solve and store solution to new_solution_T
//
old_solution_T = new_solution_T; // used for output, GHOST CELLS
old_solution_T_cal = new_solution_T;
output_results (timestep_number);
}
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/5hC7jODg-7k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+unsubscribe@googlegroups.com.
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/1e09ca9d-c53d-605b-069d-26d35ea0c25a%40colostate.edu.
You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/5hC7jODg-7k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CANaEQub-80n7v-4wDArz_6EyHfzs_8XzxTZvXc3CncNxbBmMWg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CANwa5smXTP_vK5Tb0jBg_zwnC_hBe6PeHkgGLR%2B2KMJX-d-xyA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CANaEQuYhXp1KWb4bxinrS8PqGtKSQdgdNO%2BduHXwDBWUw-kJLw%40mail.gmail.com.