Pratoori:

I am running a code to study phase transformations in metals. The code runs without any problem in release mode, but gives nan when outputting stress values using the same code snippet as in Step-18.

When I run the same code in debug mode, it gives the following error:

If your program generates an error in debug mode, nothing you compute in release mode can be trusted. In other words, it is not worth thinking about the NaN issue until you have figured this out.


It points to a problem in defining constraints in setup_system.

Actually, it states that the error happens in building the sparsity pattern. which appears to reference constrained degrees of freedom that aren't stored in the AffineConstraints object. Why this is so, I can't say -- we'd need to see the full code, or even better a reduced test case that has everything not necessary to recreate the code removed.


As for the code snippet, I don't see anything specific that looks wrong 
except...

template <int dim>
     void Solid<dim>::setup_system()
     {
         TimerOutput::Scope t(computing_timer, "setup");

         dof_handler.distribute_dofs(fe);
         dof_handler_c.distribute_dofs(fe_c);
         history_dof_handler.distribute_dofs(history_fe);

         // DoFRenumbering::Cuthill_McKee(dof_handler);

         const unsigned int n_dofs   = dof_handler.n_dofs();
         const unsigned int n_dofs_c = dof_handler_c.n_dofs();

         // Number of active cells and DoFs
         pcout   << "   Number of active cells: "
                 << triangulation.n_active_cells()
                 << std::endl
                 << "   Number of degrees of freedom: "
                 << n_dofs + n_dofs_c
                 << " (" << n_dofs << '+' << n_dofs_c << ')'
                 << std::endl;

         locally_owned_dofs = dof_handler.locally_owned_dofs();
        DoFTools::extract_locally_relevant_dofs(dof_handler,  locally_relevant_dofs);

         constraints.clear();
         constraints.reinit(locally_relevant_dofs);
         {
            DoFTools::make_periodicity_constraints(dof_handler, 0, 1, 0, constraints);             DoFTools::make_periodicity_constraints(dof_handler, 2, 3, 1, constraints);             DoFTools::make_periodicity_constraints(dof_handler, 4, 5, 2, constraints);
         }
         constraints.close();
         // constraints.print(std::cout);

         DynamicSparsityPattern dsp(locally_relevant_dofs);
         DoFTools::make_sparsity_pattern(dof_handler, dsp, constraints, false);
        Utilities::MPI::all_gather(mpi_communicator, dof_handler.locally_owned_dofs());

...this line: Utilities::MPI::all_gather() returns the combined results of the operation as a vector. Calling the function without capturing the return does nothing useful and only serves to burn CPU time.


         locally_owned_dofs_c = dof_handler_c.locally_owned_dofs();
        DoFTools::extract_locally_relevant_dofs(dof_handler_c,  locally_relevant_dofs_c);

         constraints_c.clear();
         constraints_c.reinit(locally_relevant_dofs);

And this looks wrong too: You want to initialize constraints_c with locally_relevant_dofs_c, not locally_relevant_dofs.

Best
 W.

--
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 [email protected]
                           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 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/a9949752-0e83-3ccc-bcec-994c1f1bf087%40colostate.edu.

Reply via email to