Re: [deal.II] Understanding slightly cryptic warnings from modified Step-52 code

2020-06-24 Thread Krishnakumar Gopalakrishnan
Dear Prof Bangerth,

Ah. That now was helpful. Thank you! A scrolling screenful of warnings
which wrap across multiple lines is pretty intimidating for those not so
comfortable with C++.

Hi all,
Is there a tutorial or general online resource that folks here would
recommend for debugging?

Regards,
Krishna


On Wed, 24 Jun 2020 at 23:54, Wolfgang Bangerth 
wrote:

> On 6/24/20 3:14 PM, Krishnakumar Gopalakrishnan wrote:
> > Hi,
> >
> > I am solving the basic diffusion equation using the direct method (based
> on
> > Step-52).
> >
> > I have made the following changes from Step-52 tutorial
> >
> > 1. The domain is now 1D (as opposed to 2D in step-52)
> > 2. We have Neumann BCs on both ends (left NeumannBC = 0.5, right
> NeumannBC= 0)
> > 3. Removes the code for MMS validation (i.e. no source term S(t)) so
> that we
> > solve for the unknown field variable, instead of verifying whether the
> > pre-formulated analytical solution is retrieved)
> > 4. Sets the absorpotion coefficient, Sigma_a = 0
> > 5. Sets a non-zero initial condition (but a spatially constant value).
> >
> > The C++ source code & Cmakelists.txt files are attached herewith. The
> solution
> > is indeed correct and is as expected, and I have visualised this in
> Paraview.
> > However, I'd like to understand the compilation warnings.
> >
> > Some of them have to do with "unused variables", which are somewhat
> > straightforward to get rid of. But the other warnings which all have the
> > string  "required from here" is not so clear to me.
>
> Read the error/warning message in its entirety. For example, the first one
> says
>
> /home/bangerth/p/deal.II/1/install/examples/step-1/step-1.cc: In
> instantiation
> of ‘void DiffusionEqn::SolidDiffusion::run() [with int dim = 1]’:
> /home/bangerth/p/deal.II/1/install/examples/step-1/step-1.cc:441:26:
> required from here
> /home/bangerth/p/deal.II/1/install/examples/step-1/step-1.cc:420:24:
> warning:
> variable ‘n_steps’ set but not used [-Wunused-but-set-variable]
>   unsigned int   n_steps  = 0;
>  ^~~
>
> If you strip the details, it says:
>
> In instantiation of function b() // i.e., while compiling a()
> required from here   // i.e., we got to a() while
> compiling b()
> warning: variable unused
>
> In other words, the compiler isn't just telling you where (in which
> function
> and line of code) the problem happened, but also *why* it is compiling
> this
> function (because it's called from some other place) and with which
> template
> arguments.
>
> Best
>   W.
>
> >
> > Can someone please explain what these warnings mean, and what is the
> best
> > practice for refactoring it to avoid such warnings.
> >
> > Thanks!
> > Krishna
> >
> > --
> > The deal.II project is located at http://www.dealii.org/
> > <
> https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cfd8a27c47f9a45cc323908d818838c1f%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637286300568833692&sdata=D5TEoM8Dk11JtvV6qM7o79260F%2BztbJpQw5M%2FVghgaU%3D&reserved=0
> >
> > For mailing list/forum options, see
> > https://groups.google.com/d/forum/dealii?hl=en
> > <
> https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cfd8a27c47f9a45cc323908d818838c1f%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637286300568843686&sdata=XWXhcdeMs1Poa%2BSLIqCZH73Wh1wqlvqLyz%2BTXB%2FMvBo%3D&reserved=0
> >
> > ---
> > 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+unsubscr...@googlegroups.com
> > .
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/dealii/d6aaa13b-5325-4f4a-9493-23859a5bcb9co%40googlegroups.com
> > <
> https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2Fd6aaa13b-5325-4f4a-9493-23859a5bcb9co%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cfd8a27c47f9a45cc323908d818838c1f%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637286300568843686&sdata=4eiKv3%2FUh9%2Bx5zjYczkUfN%2F%2Fwn8M8zpGx%2Fvccf%2FIhjs%3D&reserved=0
> >.
>
>
> --
> 
> Wolfgang Bangerth  email: bange...@colostate.edu
> 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 r

Re: [deal.II] Understanding slightly cryptic warnings from modified Step-52 code

2020-06-24 Thread Wolfgang Bangerth

On 6/24/20 3:14 PM, Krishnakumar Gopalakrishnan wrote:

Hi,

I am solving the basic diffusion equation using the direct method (based on 
Step-52).


I have made the following changes from Step-52 tutorial

1. The domain is now 1D (as opposed to 2D in step-52)
2. We have Neumann BCs on both ends (left NeumannBC = 0.5, right NeumannBC= 0)
3. Removes the code for MMS validation (i.e. no source term S(t)) so that we 
solve for the unknown field variable, instead of verifying whether the 
pre-formulated analytical solution is retrieved)

4. Sets the absorpotion coefficient, Sigma_a = 0
5. Sets a non-zero initial condition (but a spatially constant value).

The C++ source code & Cmakelists.txt files are attached herewith. The solution 
is indeed correct and is as expected, and I have visualised this in Paraview. 
However, I'd like to understand the compilation warnings.


Some of them have to do with "unused variables", which are somewhat 
straightforward to get rid of. But the other warnings which all have the 
string  "required from here" is not so clear to me.


Read the error/warning message in its entirety. For example, the first one says

/home/bangerth/p/deal.II/1/install/examples/step-1/step-1.cc: In instantiation 
of ‘void DiffusionEqn::SolidDiffusion::run() [with int dim = 1]’:
/home/bangerth/p/deal.II/1/install/examples/step-1/step-1.cc:441:26: 
required from here
/home/bangerth/p/deal.II/1/install/examples/step-1/step-1.cc:420:24: warning: 
variable ‘n_steps’ set but not used [-Wunused-but-set-variable]

 unsigned int   n_steps  = 0;
^~~

If you strip the details, it says:

   In instantiation of function b() // i.e., while compiling a()
   required from here   // i.e., we got to a() while compiling b()
   warning: variable unused

In other words, the compiler isn't just telling you where (in which function 
and line of code) the problem happened, but also *why* it is compiling this 
function (because it's called from some other place) and with which template 
arguments.


Best
 W.



Can someone please explain what these warnings mean, and what is the best 
practice for refactoring it to avoid such warnings.


Thanks!
Krishna

--
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+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/d6aaa13b-5325-4f4a-9493-23859a5bcb9co%40googlegroups.com 
.



--

Wolfgang Bangerth  email: bange...@colostate.edu
   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 dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/3d8d3b4d-0fd9-83e0-5457-34dc7e9c612f%40colostate.edu.


[deal.II] Understanding slightly cryptic warnings from modified Step-52 code

2020-06-24 Thread Krishnakumar Gopalakrishnan
Hi,

I am solving the basic diffusion equation using the direct method (based on 
Step-52).

I have made the following changes from Step-52 tutorial

1. The domain is now 1D (as opposed to 2D in step-52)
2. We have Neumann BCs on both ends (left NeumannBC = 0.5, right NeumannBC= 
0)
3. Removes the code for MMS validation (i.e. no source term S(t)) so that 
we solve for the unknown field variable, instead of verifying whether the 
pre-formulated analytical solution is retrieved)
4. Sets the absorpotion coefficient, Sigma_a = 0
5. Sets a non-zero initial condition (but a spatially constant value).

The C++ source code & Cmakelists.txt files are attached herewith. The 
solution is indeed correct and is as expected, and I have visualised this 
in Paraview. However, I'd like to understand the compilation warnings. 

Some of them have to do with "unused variables", which are somewhat 
straightforward to get rid of.  But the other warnings which all have the 
string  "required from here" is not so clear to me. 

Can someone please explain what these warnings mean, and what is the best 
practice for refactoring it to avoid such warnings.

Thanks!
Krishna

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/d6aaa13b-5325-4f4a-9493-23859a5bcb9co%40googlegroups.com.
#include 
#include 
#include 

#include 
#include 
#include 

#include 
#include 

#include 
#include 
#include 
#include 
#include 

#include 
#include 

#include 
#include 

#include 
#include 
#include 
#include 

namespace DiffusionEqn
{
  using namespace dealii;


  template 
  class SolidDiffusion
  {
  public:
SolidDiffusion();

void run();

  private:
void setup_system();

void assemble_system(); // Assembles all components of matrix i.e. those
// multiplying U(t)

// This gives the numerical value of the BC (at left boundary in 1D case)
double get_boundary_neumann_value(const double time) const;

// The 'evaluate_diffusion' function below evaluates RHS of weak form of
// spatially discretised PDE (M^-1  (-Dy-Ay+S + 𝛽(t) 𝜓(0)) ). Do not forget
// that this function's return value already accounts for M^-1.

Vector evaluate_diffusion(const double  time,
  const Vector &y) const;

void output_results(const double time,
const unsigned int   time_step,
TimeStepping::runge_kutta_method method) const;

unsigned int
embedded_explicit_method(const TimeStepping::runge_kutta_method method,
 const unsigned int n_time_steps,
 const double   initial_time,
 const double   final_time);


const unsigned int fe_degree;

const double diffusion_coefficient;
const double absorption_cross_section;

Triangulation triangulation;

const FE_Q fe;

DoFHandler dof_handler;

AffineConstraints constraint_matrix;

SparsityPattern sparsity_pattern;

SparseMatrix system_matrix; // - \mathcal{D} - \mathcal{A}
SparseMatrix mass_matrix;

SparseDirectUMFPACK inverse_mass_matrix;

Vector solution;

const double b; // length of the hypercube domain in each dimension
  };


  template 
  SolidDiffusion::SolidDiffusion()
: fe_degree(3)
, diffusion_coefficient(1. / 25.) // value of D
// , diffusion_coefficient(1. / 30.) // value of D
, absorption_cross_section(0.) // value of \Sigma_a
, fe(fe_degree)
, dof_handler(triangulation)
, b(5.0)
  {}


  template 
  void SolidDiffusion::setup_system()
  {
dof_handler.distribute_dofs(fe);

constraint_matrix.close();

DynamicSparsityPattern dsp(dof_handler.n_dofs());
DoFTools::make_sparsity_pattern(dof_handler, dsp, constraint_matrix);
sparsity_pattern.copy_from(dsp);

system_matrix.reinit(sparsity_pattern);
mass_matrix.reinit(sparsity_pattern);
solution.reinit(dof_handler.n_dofs());
  }


  template 
  void SolidDiffusion::assemble_system() // Assembles all matrix components
  // i.e. those multiplying U(t)
  {
system_matrix = 0.;
mass_matrix   = 0.;

const QGauss quadrature_formula(fe_degree + 1);

FEValues fe_values(fe,
quadrature_formula,
update_values | update_gradients |
  update_JxW_values);

const unsigned int dofs_per_cell = fe.dofs_per_cell;
const unsigned int n_q_points= quadrature_formula.size();

FullMatrix cell_matrix(dofs_per_cell, dofs_per_cell