<commit_before>#ifndef _pidoums_compressible_neo_hookean_h_
#define _pidoums_compressible_neo_hookean_h_

#include "interface.h"

#include <deal.II/lac/linear_operator.h>
#include <deal.II/lac/block_linear_operator.h>
#include <deal.II/lac/packaged_operation.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/solver_gmres.h>

//typedef LATrilinos LAC;

template <int dim, int spacedim, typename LAC=LATrilinos>
class ScalarReactionDiffusionConvection : public Interface<dim,spacedim, ScalarReactionDiffusionConvection<dim,spacedim,LAC>, LAC>
{

public:
  ~ScalarReactionDiffusionConvection () {};
  ScalarReactionDiffusionConvection ();

  void declare_parameters (ParameterHandler &prm);

  // interface with the Interface :)


  template <typename EnergyType, typename ResidualType>
  void energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iterator &cell,
                              FEValuesCache<dim,spacedim> &scratch,
                              std::vector<EnergyType> &energies,
                              std::vector<std::vector<ResidualType> > &local_residuals,
                              bool compute_only_system_terms) const;


  void compute_system_operators(const DoFHandler<dim,spacedim> &,
                                const std::vector<shared_ptr<LATrilinos::BlockMatrix> >,
                                LinearOperator<LATrilinos::VectorType> &,
                                LinearOperator<LATrilinos::VectorType> &) const;

private:
  double nu;

  mutable shared_ptr<TrilinosWrappers::PreconditionJacobi> preconditioner;

  ParsedFunction<dim> convection;

};

template <int dim, int spacedim, typename LAC>
ScalarReactionDiffusionConvection<dim,spacedim, LAC>::
ScalarReactionDiffusionConvection():
  Interface<dim,spacedim,ScalarReactionDiffusionConvection<dim,spacedim,LAC>, LAC >("Scalar Reaction Diffusion Convection",
      1,1,
      "FE_Q(2)",
      "u", "1"),
  convection("Convection parameter", dim, "cos(pi*x)*sin(pi*y); -sin(pi*x)*cos(pi*y)")
{
  this->init();
}


template <int dim, int spacedim, typename LAC>
void ScalarReactionDiffusionConvection<dim,spacedim,LAC>::declare_parameters (ParameterHandler &prm)
{
  Interface<dim,spacedim, ScalarReactionDiffusionConvection<dim,spacedim,LAC>,LAC >::declare_parameters(prm);
  this->add_parameter(prm, &nu, "Diffusion coefficient", "1.0", Patterns::Double(0.0));
}


template <int dim, int spacedim, typename LAC>
template <typename EnergyType, typename ResidualType>
void
ScalarReactionDiffusionConvection<dim,spacedim,LAC>::
energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iterator &cell,
                       FEValuesCache<dim,spacedim> &fe_cache,
                       std::vector<EnergyType> &energies,
                       std::vector<std::vector<ResidualType> > &residuals,
                       bool compute_only_system_terms) const
{
  const FEValuesExtractors::Scalar concentration(0);

  ////////// conservative section
  //
  ResidualType et = 0; // dummy number to define the type of variables
  this->reinit (et, cell, fe_cache);
  auto &us = fe_cache.get_values("solution", "u", concentration, et);
  auto &gradus = fe_cache.get_gradients("solution", "gradu", concentration, et);

  const unsigned int n_q_points = us.size();
  auto &JxW = fe_cache.get_JxW_values();

  std::vector<Vector<double> > convection_values(n_q_points, Vector<double>(dim));

  auto &fev = fe_cache.get_current_fe_values();
  convection.vector_value_list(fev.get_quadrature_points(), convection_values);

  for (unsigned int i=0; i<residuals[0].size(); ++i)
    {
      for (unsigned int q=0; q<n_q_points; ++q)
        {
          ///////////////////////// energetic contribution
          auto &u = us[q];
          auto &gradu = gradus[q];

          auto &b = convection_values[q];

          // test functions:
          const auto &v = fev[concentration].value(i,q);
          const auto &gradv = fev[concentration].gradient(i,q);
<commit_msg>Tried first attempt for time dependence.<commit_after>#ifndef _pidoums_compressible_neo_hookean_h_
#define _pidoums_compressible_neo_hookean_h_

#include "interface.h"

#include <deal.II/lac/linear_operator.h>
#include <deal.II/lac/block_linear_operator.h>
#include <deal.II/lac/packaged_operation.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/solver_gmres.h>

//typedef LATrilinos LAC;

template <int dim, int spacedim, typename LAC=LATrilinos>
class ScalarReactionDiffusionConvection : public Interface<dim,spacedim, ScalarReactionDiffusionConvection<dim,spacedim,LAC>, LAC>
{

public:
  ~ScalarReactionDiffusionConvection () {};
  ScalarReactionDiffusionConvection ();

  void declare_parameters (ParameterHandler &prm);

  // interface with the Interface :)


  template <typename EnergyType, typename ResidualType>
  void energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iterator &cell,
                              FEValuesCache<dim,spacedim> &scratch,
                              std::vector<EnergyType> &energies,
                              std::vector<std::vector<ResidualType> > &local_residuals,
                              bool compute_only_system_terms) const;


  void compute_system_operators(const DoFHandler<dim,spacedim> &,
                                const std::vector<shared_ptr<LATrilinos::BlockMatrix> >,
                                LinearOperator<LATrilinos::VectorType> &,
                                LinearOperator<LATrilinos::VectorType> &) const;

private:
  double nu;

  mutable shared_ptr<TrilinosWrappers::PreconditionJacobi> preconditioner;

  ParsedFunction<dim> convection;

};

template <int dim, int spacedim, typename LAC>
ScalarReactionDiffusionConvection<dim,spacedim, LAC>::
ScalarReactionDiffusionConvection():
  Interface<dim,spacedim,ScalarReactionDiffusionConvection<dim,spacedim,LAC>, LAC >("Scalar Reaction Diffusion Convection",
      1,1,
      "FE_Q(2)",
      "u", "1"),
  convection("Convection parameter", dim, "cos(pi*x)*sin(pi*y); -sin(pi*x)*cos(pi*y)")
{
  this->init();
}


template <int dim, int spacedim, typename LAC>
void ScalarReactionDiffusionConvection<dim,spacedim,LAC>::declare_parameters (ParameterHandler &prm)
{
  Interface<dim,spacedim, ScalarReactionDiffusionConvection<dim,spacedim,LAC>,LAC >::declare_parameters(prm);
  this->add_parameter(prm, &nu, "Diffusion coefficient", "1.0", Patterns::Double(0.0));
}


template <int dim, int spacedim, typename LAC>
template <typename EnergyType, typename ResidualType>
void
ScalarReactionDiffusionConvection<dim,spacedim,LAC>::
energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iterator &cell,
                       FEValuesCache<dim,spacedim> &fe_cache,
                       std::vector<EnergyType> &energies,
                       std::vector<std::vector<ResidualType> > &residuals,
                       bool compute_only_system_terms) const
{
  const FEValuesExtractors::Scalar concentration(0);

  ////////// conservative section
  //
  ResidualType et = 0; // dummy number to define the type of variables
  this->reinit (et, cell, fe_cache);
  auto &us = fe_cache.get_values("solution", "u", concentration, et);
  auto &uts = fe_cache.get_values("solution_dot", "ut", concentration, et);
  auto &gradus = fe_cache.get_gradients("solution", "gradu", concentration, et);

  const unsigned int n_q_points = us.size();
  auto &JxW = fe_cache.get_JxW_values();

  std::vector<Vector<double> > convection_values(n_q_points, Vector<double>(dim));

  auto &fev = fe_cache.get_current_fe_values();
  convection.vector_value_list(fev.get_quadrature_points(), convection_values);

  for (unsigned int i=0; i<residuals[0].size(); ++i)
    {
      for (unsigned int q=0; q<n_q_points; ++q)
        {
          ///////////////////////// energetic contribution
          auto &u = us[q];
          auto &ut = uts[q];
          auto &gradu = gradus[q];

          auto &b = convection_values[q];

          // test functions:
          const auto &v = fev[concentration].value(i,q);
          const auto &gradv = fev[concentration].gradient(i,q);

{'fraction_non_alphanumeric': 0.12398822663723326, 'fraction_numerical': 0.003188619082658818, 'mean_word_length': 3.716599190283401, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6740680', 'n_tokens_mistral': 2750, 'n_tokens_neox': 2598, 'n_words': 478}