<commit_before>// The libMesh Finite Element Library.
// Copyright (C) 2002-2020 <NAME>, <NAME>, <NAME>

// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



// <h1>Introduction Example 5 - Run-Time Quadrature Rule Selection</h1>
// \author <NAME>
// \date 2003
//
// This is the fifth example program.  It builds on
// the previous two examples, and extends the use
// of the std::unique_ptr as a convenient build method to
// determine the quadrature rule at run time.


// C++ include files that we need
#include <iostream>
#include <sstream>
#include <algorithm>
#include <math.h>

// Basic include file needed for the mesh functionality.
#include "libmesh/libmesh.h"
#include "libmesh/mesh.h"
#include "libmesh/mesh_generation.h"
#include "libmesh/exodusII_io.h"
#include "libmesh/linear_implicit_system.h"
#include "libmesh/equation_systems.h"

// Define the Finite Element object.
#include "libmesh/fe.h"

// Define the base quadrature class, with which
// specialized quadrature rules will be built.
#include "libmesh/quadrature.h"

// Define useful datatypes for finite element
// matrix and vector components.
#include "libmesh/sparse_matrix.h"
#include "libmesh/numeric_vector.h"
#include "libmesh/dense_matrix.h"
#include "libmesh/dense_vector.h"

// Define the DofMap, which handles degree of freedom
// indexing.
#include "libmesh/dof_map.h"

// To impose Dirichlet boundary conditions
#include "libmesh/dirichlet_boundaries.h"
#include "libmesh/analytic_function.h"

// The definition of a geometric element
#include "libmesh/elem.h"
#include "libmesh/enum_solver_package.h"
#include "libmesh/enum_quadrature_type.h"

// Bring in everything from the libMesh namespace
using namespace libMesh;



// Function prototype, as before.
void assemble_poisson(EquationSystems & es,
                      const std::string & system_name);

// Exact solution function prototype, as before.
Real exact_solution (const Real x,
                     const Real y,
                     const Real z = 0.);

// Define a wrapper for exact_solution that will be needed below
void exact_solution_wrapper (DenseVector<Number> & output,
                             const Point & p,
                             const Real)
{
  output(0) = exact_solution(p(0), p(1), p(2));
}


// The quadrature type the user requests.
QuadratureType quad_type=INVALID_Q_RULE;



// Begin the main program.
int main (int argc, char ** argv)
{
  // Initialize libMesh and any dependent libraries, like in example 2.
  LibMeshInit init (argc, argv);

  // This example requires a linear solver package.
  libmesh_example_requires(libMesh::default_solver_package() != INVALID_SOLVER_PACKAGE,
                           "--enable-petsc, --enable-trilinos, or --enable-eigen");

  // Check for proper usage.  The quadrature rule
  // must be given at run time.
  if (argc < 3)
    {
      libmesh_error_msg("Usage: " << argv[0] << " -q <rule>\n"          \
                        << "  where <rule> is one of QGAUSS, QSIMPSON, or QTRAP.");
    }


  // Tell the user what we are doing.
  else
    {
      libMesh::out << "Running " << argv[0];

      for (int i=1; i<argc; i++)
        libMesh::out << " " << argv[i];

      libMesh::out << std::endl << std::endl;
    }


  // Set the quadrature rule type that the user wants from argv[2]
  quad_type = static_cast<QuadratureType>(std::atoi(argv[2]));

  // Skip this 3D example if libMesh was compiled as 1D-only.
  libmesh_example_requires(3 <= LIBMESH_DIM, "3D support");

  // We use Dirichlet boundary conditions here
#ifndef LIBMESH_ENABLE_DIRICHLET
  libmesh_example_requires(false, "--enable-dirichlet");
#endif

  // The following is identical to example 4, and therefore
  // not commented.  Differences are mentioned when present.
  Mesh mesh(init.comm());

  // We will use a linear approximation space in this example,
  // hence 8-noded hexahedral elements are sufficient.  This
  // is different than example 4 where we used 27-noded
  // hexahedral elements to support a second-order approximation
  // space.
  MeshTools::Generation::build_cube (mesh,
                                     16, 16, 16,
                                     -1., 1.,
                                     -1., 1.,
                                     -1., 1.,
                                     HEX8);

  mesh.print_info();

  EquationSystems equation_systems (mesh);

  equation_systems.add_system<LinearImplicitSystem> ("Poisson");

  unsigned int u_var = equation_systems.get_system("Poisson").add_variable("u", FIRST);

  equation_systems.get_system("Poisson").attach_assemble_function (assemble_poisson);

  // Construct a Dirichlet boundary condition object

  // Indicate which boundary IDs we impose the BC on
  // We either build a line, a square or a cube, and
  // here we indicate the boundaries IDs in each case
  std::set<boundary_id_type> boundary_ids;<commit_msg>Revert "Revert "Demonstrate use of Eigen GMRES solver in introduction_ex5.""<commit_after>// The libMesh Finite Element Library.
// Copyright (C) 2002-2020 <NAME>, <NAME>, <NAME>

// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



// <h1>Introduction Example 5 - Run-Time Quadrature Rule Selection</h1>
// \author <NAME>
// \date 2003
//
// This is the fifth example program.  It builds on
// the previous two examples, and extends the use
// of the std::unique_ptr as a convenient build method to
// determine the quadrature rule at run time.


// C++ include files that we need
#include <iostream>
#include <sstream>
#include <algorithm>
#include <math.h>

// Basic include file needed for the mesh functionality.
#include "libmesh/libmesh.h"
#include "libmesh/mesh.h"
#include "libmesh/mesh_generation.h"
#include "libmesh/exodusII_io.h"
#include "libmesh/linear_implicit_system.h"
#include "libmesh/equation_systems.h"
#include "libmesh/linear_solver.h"
#include "libmesh/solver_configuration.h"
#include "libmesh/enum_solver_type.h"

// Define the Finite Element object.
#include "libmesh/fe.h"

// Define the base quadrature class, with which
// specialized quadrature rules will be built.
#include "libmesh/quadrature.h"

// Define useful datatypes for finite element
// matrix and vector components.
#include "libmesh/sparse_matrix.h"
#include "libmesh/numeric_vector.h"
#include "libmesh/dense_matrix.h"
#include "libmesh/dense_vector.h"

// Define the DofMap, which handles degree of freedom
// indexing.
#include "libmesh/dof_map.h"

// To impose Dirichlet boundary conditions
#include "libmesh/dirichlet_boundaries.h"
#include "libmesh/analytic_function.h"

// The definition of a geometric element
#include "libmesh/elem.h"
#include "libmesh/enum_solver_package.h"
#include "libmesh/enum_quadrature_type.h"

// Bring in everything from the libMesh namespace
using namespace libMesh;



// Function prototype, as before.
void assemble_poisson(EquationSystems & es,
                      const std::string & system_name);

// Exact solution function prototype, as before.
Real exact_solution (const Real x,
                     const Real y,
                     const Real z = 0.);

// Define a wrapper for exact_solution that will be needed below
void exact_solution_wrapper (DenseVector<Number> & output,
                             const Point & p,
                             const Real)
{
  output(0) = exact_solution(p(0), p(1), p(2));
}


// The quadrature type the user requests.
QuadratureType quad_type=INVALID_Q_RULE;



class MySolverConfiguration : public SolverConfiguration
{
public:
  MySolverConfiguration() {}

  // We have to override this pure virtual function, but in this case
  // it does nothing.
  virtual void configure_solver() {}
};



// Begin the main program.
int main (int argc, char ** argv)
{
  // Initialize libMesh and any dependent libraries, like in example 2.
  LibMeshInit init (argc, argv);

  // This example requires a linear solver package.
  libmesh_example_requires(libMesh::default_solver_package() != INVALID_SOLVER_PACKAGE,
                           "--enable-petsc, --enable-trilinos, or --enable-eigen");

  // Check for proper usage.  The quadrature rule
  // must be given at run time.
  if (argc < 3)
    {
      libmesh_error_msg("Usage: " << argv[0] << " -q <rule>\n"          \
                        << "  where <rule> is one of QGAUSS, QSIMPSON, or QTRAP.");
    }


  // Tell the user what we are doing.
  else
    {
      libMesh::out << "Running " << argv[0];

      for (int i=1; i<argc; i++)
        libMesh::out << " " << argv[i];

      libMesh::out << std::endl << std::endl;
    }


  // Set the quadrature rule type that the user wants from argv[2]
  quad_type = static_cast<QuadratureType>(std::atoi(argv[2]));

  // Skip this 3D example if libMesh was compiled as 1D-only.
  libmesh_example_requires(3 <= LIBMESH_DIM, "3D support");

  // We use Dirichlet boundary conditions here
#ifndef LIBMESH_ENABLE_DIRICHLET
  libmesh_example_requires(false, "--enable-dirichlet");
#endif

  // The following is identical to example 4, and therefore
  // not commented.  Differences are mentioned when present.
  Mesh mesh(init.comm());

  // We will use a linear approximation space in this example,
  // hence 8-noded hexahedral elements are sufficient.  This
  // is different than example 4 where we used 27-noded
  // hexahedral elements to support a second-order approximation
  // space.
  MeshTools::Generation::build_cube (mesh,
                                     16, 16, 16,
                                     -1., 1.,
                                     -1., 1.,
                                     -1., 1.,
                                     HEX8);

  mesh.print_info();

  EquationSystems equation_systems (mesh);


  LinearImplicitSystem & system =
    equation_systems.add_system<LinearImplicitSystem> ("Poisson");

  unsigned int u_var = equation_systems.get_system("Poisson").add_variable("u", FIRST);

  equation_systems.get_system("Poisson").attach_assemble_function (assemble_poisson);

  // Create a SolverConfiguration object for passing values to the LinearSolver.
  MySolverConfiguration msc;
  msc.int_valued_data["gmres_restart"] = 4;
  system.get_linear_solver()->set_solver_configuration(msc);

  // Set more standard options through the appropriate interfaces.
  system.get_linear_solver()->set_solver_type(GMRES);

  // Construct a Dirichlet boundary condition object

  // Indicate which boundary IDs we impose the BC on
  // We either build a line, a square or a cube, and
  // here we indicate the boundaries IDs in each case
  std::set<boundary_id_type> boundary_ids;
{'fraction_non_alphanumeric': 0.09980757968710784, 'fraction_numerical': 0.011043252739897933, 'mean_word_length': 2.97406914893617, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6984377', 'n_tokens_mistral': 3649, 'n_tokens_neox': 3391, 'n_words': 1236}