Hi, all.
I wonder if it is possible to pass solution vector to refined-meshed....
I am solving non-linear problem with iterative method.
I'd like to use coarse mesh solution as a initial solution to find accurate
solution fast.
However, my present code sets up system again on every refinement cycle.
So, I lose all solution that I had in coarse mesh.
I think it is really helpful for me if I knew a way to pass the previous
solution to as a initial solution for next iterative method.
I think it might be complicated... first vector size of solution might
different when mesh is refined....
is there anyone who has idea on this ?
Thanks,
Jaekwang Kim
template <int dim>
void nonlinear<dim>::run ()
{
unsigned int cycle_control=4;
for (unsigned int cycle=0; cycle<cycle_control; ++cycle)
{
std::cout << "Cycle " << cycle << ':' << std::endl;
if (cycle == 0)
{
GridGenerator::hyper_cube (triangulation, 0.0, 1.0);
triangulation.refine_global (1);
for (typename Triangulation<dim>::active_cell_iterator
cell=triangulation.begin_active();
cell!=triangulation.end(); ++cell)
{
for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell;
++f)
{
if (cell->face(f)->at_boundary() == true)
{
if ( std::abs(cell->face(f)->center()[0]-0.5)< 1e-12
)
{
cell->face(f)->set_boundary_id(10);
}
// Boundary faces
static const double tol = 1e-12;
if ( std::abs(cell->face(f)->center()[0]-0.0)< tol )
{
cell->face(f)->set_boundary_id(1);
}
if ( std::abs(cell->face(f)->center()[0]-1.0)< tol )
{
cell->face(f)->set_boundary_id(1);
}
if ( std::abs(cell->face(f)->center()[1]-0.0)< tol )
{
cell->face(f)->set_boundary_id(1);
}
if ( std::abs(cell->face(f)->center()[1]-1.0)< tol )
{
cell->face(f)->set_boundary_id(1);
}
}
}
}
std::ofstream out ("grid-1.ucd");
GridOut grid_out;
grid_out.write_ucd (triangulation, out);
}
else
refine_grid ();
std::cout << " Number of active cells: "<<
triangulation.n_active_cells() << std::endl;
setup_system ();
int iteration=0;
assemble_system ();
solve ();
Vector<double> difference(dof_handler.n_dofs());
Vector<double> temp_vector(dof_handler.n_dofs());
Vector<double> temp_difference(dof_handler.n_dofs());
difference=solution; // std::cout << " ||u_k-u_{k-1}||" <<
difference.l2_norm() << std::endl;
previous_solution = solution ;
double omega = 0.5; //relxation control number
int success_step=0 ;
do{
assemble_system();
solve();
difference = solution;
difference -= previous_solution; //This is temporary step
temp_vector=solution;
temp_vector.add(omega,difference);
temp_difference = temp_vector;
temp_difference -= solution; //Calculate different again
if (temp_difference.l2_norm()< difference.l2_norm())
//temp_difference
= temp_vector - solution , difference=solution-previous_solution
{
success_step+=1;
difference=temp_vector;
difference-=solution ;
solution=temp_vector;
}
previous_solution=solution ;
iteration+=1;
std::ofstream outerror2("iter_error.dat",std::ios::app);
outerror2 << degree << " " << triangulation.n_active_cells() << "
" << iteration << " " << difference.l2_norm() << " " << error << std::endl;
}while (difference.l2_norm() > 0.00001);
std::cout << " ||u_k-u_{k-1}|| = " << difference.l2_norm() << "
Iteration Number: " << iteration << std::endl;
error_evaluation();
std::ofstream outerror("error.dat",std::ios::app);
outerror << degree << " " << triangulation.n_active_cells() << " "
<< iteration << " " << error << std::endl;
output_results ();
}
}
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.