// all cells and much of the setup of operations will be done outside this
// class, so all we have to provide are these three operations. They will
// then work on intermediate objects for which first, we here define
- // typedefs to the info objects handed to the local integration functions
+ // alias to the info objects handed to the local integration functions
// in order to make our life easier below.
- typedef MeshWorker::DoFInfo<dim> DoFInfo;
- typedef MeshWorker::IntegrationInfo<dim> CellInfo;
+ using DoFInfo = MeshWorker::DoFInfo<dim>;
+ using CellInfo = MeshWorker::IntegrationInfo<dim>;
// The following three functions are then the ones that get called inside
// the generic loop over all cells and faces. They are the ones doing the
// Now solve the problem on the present grid, and run the evaluators
// on it. The long type name of iterators into the list is a little
- // annoying, but could be shortened by a typedef, if so desired.
+ // annoying, but could be shortened by an alias, if so desired.
solver.solve_problem();
for (typename std::list<
{
// We need a class to denote the boundary values of the problem. In this
// case, this is simple: it's the zero function, so don't even declare a
- // class, just a typedef:
- typedef Functions::ZeroFunction<dim> BoundaryValues;
+ // class, just an alias:
+ using BoundaryValues = Functions::ZeroFunction<dim>;
// Second, a class that denotes the right hand side. Since they are
// constant, just subclass the corresponding class of the library and be
// Then declare abbreviations for active cell iterators, to avoid that
// we have to write this lengthy name over and over again:
- typedef
- typename DoFHandler<dim>::active_cell_iterator active_cell_iterator;
+ using active_cell_iterator =
+ typename DoFHandler<dim>::active_cell_iterator;
// Next, declare a data type that we will us to store the contribution
// of faces to the error estimator. The idea is that we can compute the
// cells a second time and grabbing the values from the map.
//
// The data type of this map is declared here:
- typedef typename std::map<typename DoFHandler<dim>::face_iterator, double>
- FaceIntegrals;
+ using FaceIntegrals =
+ typename std::map<typename DoFHandler<dim>::face_iterator, double>;
// In the computation of the error estimates on cells and faces, we need
// a number of helper objects, such as <code>FEValues</code> and
public:
// First, we declare two abbreviations for simple use of the respective
// data types:
- typedef Evaluation::EvaluationBase<dim> Evaluator;
- typedef std::list<Evaluator *> EvaluatorList;
+ using Evaluator = Evaluation::EvaluationBase<dim>;
+ using EvaluatorList = std::list<Evaluator *>;
// Then we have the structure which declares all the parameters that may
// (such as CG or GMRES). The mg::SmootherRelaxation and
// MGSmootherPrecondition classes provide support for these two kinds of
// smoothers. Here, we opt for the application of a single SOR
- // iteration. To this end, we define an appropriate <code>typedef</code>
- // and then setup a smoother object.
+ // iteration. To this end, we define an appropriate alias and then setup a
+ // smoother object.
//
// The last step is to initialize the smoother object with our level
// matrices and to set some smoothing parameters. The
// iteration (which requires a symmetric preconditioner) below, we need to
// let the multilevel preconditioner make sure that we get a symmetric
// operator even for nonsymmetric smoothers:
- typedef PreconditionSOR<SparseMatrix<double>> Smoother;
+ using Smoother = PreconditionSOR<SparseMatrix<double>>;
mg::SmootherRelaxation<Smoother, Vector<double>> mg_smoother;
mg_smoother.initialize(mg_matrices);
mg_smoother.set_steps(2);
template <>
struct InnerPreconditioner<2>
{
- typedef SparseDirectUMFPACK type;
+ using type = SparseDirectUMFPACK;
};
template <>
struct InnerPreconditioner<3>
{
- typedef SparseILU<double> type;
+ using type = SparseILU<double>;
};
@endcode
// distinguish between them by the use of the spatial dimension as a
// template parameter. See step-4 for details on templates. We are not going
// to create any preconditioner object here, all we do is to create class
- // that holds a local typedef determining the preconditioner class so we can
+ // that holds a local alias determining the preconditioner class so we can
// write our program in a dimension-independent way.
template <int dim>
struct InnerPreconditioner;
template <>
struct InnerPreconditioner<2>
{
- typedef SparseDirectUMFPACK type;
+ using type = SparseDirectUMFPACK;
};
// And the ILU preconditioning in 3D, called by SparseILU:
template <>
struct InnerPreconditioner<3>
{
- typedef SparseILU<double> type;
+ using type = SparseILU<double>;
};
// preconditioner for the velocity-velocity matrix, i.e.,
// <code>block(0,0)</code> in the system matrix. As mentioned above, this
// depends on the spatial dimension. Since the two classes described by
- // the <code>InnerPreconditioner::type</code> typedef have the same
+ // the <code>InnerPreconditioner::type</code> alias have the same
// interface, we do not have to do anything different whether we want to
// use a sparse direct solver or an ILU:
std::cout << " Computing preconditioner..." << std::endl << std::flush;
<h3> A note on types </h3>
-deal.II defines a number of integral %types via <code>typedef</code>s in
-namespace types. In particular, in this program you will see
-types::global_dof_index in a couple of places: an integer type that is used to
-denote the <i>global</i> index of a degree of freedom, i.e., the index of a
-particular degree of freedom within the DoFHandler object that is defined on
-top of a triangulation (as opposed to the index of a particular degree of
-freedom within a particular cell). For the current program
-(as well as almost all of the tutorial programs), you will have a few thousand
-to maybe a few million unknowns globally (and, for $Q_1$ elements, you will
-have 4 <i>locally on each cell</i> in 2d and 8 in 3d). Consequently, a data
-type that allows to store sufficiently large numbers for global DoF indices is
-<code>unsigned int</code> given that it allows to store numbers between 0 and
-slightly more than 4 billion (on most systems, where integers are 32-bit). In
-fact, this is what types::global_dof_index is.
+deal.II defines a number of integral %types via alias in namespace types. In
+particular, in this program you will see types::global_dof_index in a couple of
+places: an integer type that is used to denote the <i>global</i> index of a
+degree of freedom, i.e., the index of a particular degree of freedom within the
+DoFHandler object that is defined on top of a triangulation (as opposed to the
+index of a particular degree of freedom within a particular cell). For the
+current program (as well as almost all of the tutorial programs), you will have
+a few thousand to maybe a few million unknowns globally (and, for $Q_1$
+elements, you will have 4 <i>locally on each cell</i> in 2d and 8 in 3d).
+Consequently, a data type that allows to store sufficiently large numbers for
+global DoF indices is <code>unsigned int</code> given that it allows to store
+numbers between 0 and slightly more than 4 billion (on most systems, where
+integers are 32-bit). In fact, this is what types::global_dof_index is.
So, why not just use <code>unsigned int</code> right away? deal.II used to do
this until version 7.3. However, deal.II supports very large computations (via
cell" -- but variables that hold this information are universally named this
way throughout the library.
-@note types::global_dof_index is not the only type defined in this
-namespace. Rather, there is a whole family, including types::subdomain_id,
-types::boundary_id, and types::material_id. All of these are
-<code>typedef</code>s for integer data types but, as explained above, they are
-used throughout the library so that (i) the intent of a variable becomes more
-easily discerned, and (ii) so that it becomes possible to change the actual
-type to a larger one if necessary without having to go through the entire
-library and figure out whether a particular use of <code>unsigned int</code>
-corresponds to, say, a material indicator.
+@note types::global_dof_index is not the only type defined in this namespace.
+Rather, there is a whole family, including types::subdomain_id,
+types::boundary_id, and types::material_id. All of these are alias for integer
+data types but, as explained above, they are used throughout the library so that
+(i) the intent of a variable becomes more easily discerned, and (ii) so that it
+becomes possible to change the actual type to a larger one if necessary without
+having to go through the entire library and figure out whether a particular use
+of <code>unsigned int</code> corresponds to, say, a material indicator.
const QGauss<dim> quadrature_formula(parameters.stokes_velocity_degree + 1);
- typedef FilteredIterator<typename DoFHandler<dim>::active_cell_iterator>
- CellFilter;
+ using CellFilter =
+ FilteredIterator<typename DoFHandler<2>::active_cell_iterator>;
WorkStream::run(
CellFilter(IteratorFilters::LocallyOwnedCell(),
const QGauss<dim> quadrature_formula(parameters.stokes_velocity_degree + 1);
- typedef FilteredIterator<typename DoFHandler<dim>::active_cell_iterator>
- CellFilter;
+ using CellFilter =
+ FilteredIterator<typename DoFHandler<2>::active_cell_iterator>;
WorkStream::run(
CellFilter(IteratorFilters::LocallyOwnedCell(),
const QGauss<dim> quadrature_formula(parameters.temperature_degree + 2);
- typedef FilteredIterator<typename DoFHandler<dim>::active_cell_iterator>
- CellFilter;
+ using CellFilter =
+ FilteredIterator<typename DoFHandler<2>::active_cell_iterator>;
WorkStream::run(
CellFilter(IteratorFilters::LocallyOwnedCell(),
const double global_entropy_variation =
get_entropy_variation(average_temperature);
- typedef FilteredIterator<typename DoFHandler<dim>::active_cell_iterator>
- CellFilter;
+ using CellFilter =
+ FilteredIterator<typename DoFHandler<2>::active_cell_iterator>;
WorkStream::run(
CellFilter(IteratorFilters::LocallyOwnedCell(),
#include <Sacado.hpp>
#include <iostream>
-typedef Sacado::Fad::DFad<double> fad_double;
+using fad_double = Sacado::Fad::DFad<double>;
main() {
// and compressing it. It is important to notice here that the gradient
// operator acts from the pressure space into the velocity space, so we have
// to deal with two different finite element spaces. To keep the loops
- // synchronized, we use the <code>typedef</code>'s that we have defined
- // before, namely <code>PairedIterators</code> and <code>IteratorPair</code>.
+ // synchronized, we use the alias that we have defined before, namely
+ // <code>PairedIterators</code> and <code>IteratorPair</code>.
template <int dim>
void NavierStokesProjection<dim>::initialize_gradient_operator()
{
Base<dim, LinearAlgebra::distributed::Vector<number>>
{
public:
- typedef number value_type;
+ using value_type = number;
LaplaceOperator();
DoFHandler<dim> dof_handler;
ConstraintMatrix constraints;
- typedef LaplaceOperator<dim, degree_finite_element, double>
- SystemMatrixType;
+ using SystemMatrixType =
+ LaplaceOperator<dim, degree_finite_element, double>;
SystemMatrixType system_matrix;
MGConstrainedDoFs mg_constrained_dofs;
- typedef LaplaceOperator<dim, degree_finite_element, float> LevelMatrixType;
- MGLevelObject<LevelMatrixType> mg_matrices;
+ using LevelMatrixType = LaplaceOperator<dim, degree_finite_element, float>;
+ MGLevelObject<LevelMatrixType> mg_matrices;
LinearAlgebra::distributed::Vector<double> solution;
LinearAlgebra::distributed::Vector<double> system_rhs;
// methods. The former involves only local communication between neighbors
// in the (coarse) mesh, whereas the latter requires global communication
// over all processors.
- typedef PreconditionChebyshev<LevelMatrixType,
- LinearAlgebra::distributed::Vector<float>>
- SmootherType;
+ using SmootherType =
+ PreconditionChebyshev<LevelMatrixType,
+ LinearAlgebra::distributed::Vector<float>>;
mg::SmootherRelaxation<SmootherType,
LinearAlgebra::distributed::Vector<float>>
mg_smoother;
class InteriorPenaltyProblem
{
public:
- typedef MeshWorker::IntegrationInfo<dim> CellInfo;
+ using CellInfo = MeshWorker::IntegrationInfo<dim>;
InteriorPenaltyProblem(const FiniteElement<dim> &fe);
// While transfer and coarse grid solver are pretty much generic, more
// flexibility is offered for the smoother. First, we choose Gauss-Seidel
// as our smoothing method.
- GrowingVectorMemory<Vector<double>> mem;
- typedef PreconditionSOR<SparseMatrix<double>> RELAXATION;
+ GrowingVectorMemory<Vector<double>> mem;
+ using RELAXATION = PreconditionSOR<SparseMatrix<double>>;
mg::SmootherRelaxation<RELAXATION, Vector<double>> mg_smoother;
RELAXATION::AdditionalData smoother_data(1.);
mg_smoother.initialize(mg_matrix, smoother_data);
to throw at it, and for as large a problem as you have the memory and patience
to solve. However, there <i>is</i> a limit: the number of unknowns can not
exceed the largest number that can be stored with an object of type
-types::global_dof_index. By default, this is a typedef for <code>unsigned
+types::global_dof_index. By default, this is an alias for <code>unsigned
int</code>, which on most machines today is a 32-bit integer, limiting you to
some 4 billion (in reality, since this program uses PETSc, you will be limited
to half that as PETSc uses signed integers). However, this can be changed
FE_Q<dim> fe;
DoFHandler<dim> mg_dof_handler;
- typedef LA::MPI::SparseMatrix matrix_t;
- typedef LA::MPI::Vector vector_t;
+ using matrix_t = LA::MPI::SparseMatrix;
+ using vector_t = LA::MPI::Vector;
matrix_t system_matrix;
// SOR, Jacobi or Richardson method). The MGSmootherPrecondition
// class provides support for this kind of smoother. Here, we opt
// for the application of a single SOR iteration. To this end, we
- // define an appropriate <code>typedef</code> and then setup a
- // smoother object.
+ // define an appropriate alias and then setup a smoother object.
//
// The last step is to initialize the smoother object with our
// level matrices and to set some smoothing parameters. The
// preconditioner make sure that we get a
// symmetric operator even for nonsymmetric
// smoothers:
- typedef LA::MPI::PreconditionJacobi Smoother;
+ using Smoother = LA::MPI::PreconditionJacobi;
MGSmootherPrecondition<matrix_t, Smoother, vector_t> mg_smoother;
mg_smoother.initialize(mg_matrices, Smoother::AdditionalData(0.5));
mg_smoother.set_steps(2);
}
// The InverseMatrix is used to solve for the mass matrix:
- typedef LinearSolvers::InverseMatrix<LA::MPI::SparseMatrix,
- LA::MPI::PreconditionAMG>
- mp_inverse_t;
+ using mp_inverse_t = LinearSolvers::InverseMatrix<LA::MPI::SparseMatrix,
+ LA::MPI::PreconditionAMG>;
const mp_inverse_t mp_inverse(preconditioner_matrix.block(1, 1), prec_S);
// This constructs the block preconditioner based on the preconditioners
MGCoarseGridHouseholder<> coarse_grid_solver;
coarse_grid_solver.initialize(coarse_matrix);
- typedef PreconditionSOR<SparseMatrix<double>> Smoother;
+ using Smoother = PreconditionSOR<SparseMatrix<double>>;
mg::SmootherRelaxation<Smoother, Vector<double>> mg_smoother;
mg_smoother.initialize(mg_matrices);
mg_smoother.set_steps(2);
class LaplaceOperator : public Subscriptor
{
public:
- typedef number value_type;
+ using value_type = number;
LaplaceOperator() = default;
class PreconditionBlockJacobi
{
public:
- typedef number value_type;
+ using value_type = number;
void clear()
{
FE_DGQHermite<dim> fe;
DoFHandler<dim> dof_handler;
- typedef LaplaceOperator<dim, fe_degree, double> SystemMatrixType;
- SystemMatrixType system_matrix;
+ using SystemMatrixType = LaplaceOperator<dim, fe_degree, double>;
+ SystemMatrixType system_matrix;
- typedef LaplaceOperator<dim, fe_degree, float> LevelMatrixType;
- MGLevelObject<LevelMatrixType> mg_matrices;
+ using LevelMatrixType = LaplaceOperator<dim, fe_degree, float>;
+ MGLevelObject<LevelMatrixType> mg_matrices;
LinearAlgebra::distributed::Vector<double> solution;
LinearAlgebra::distributed::Vector<double> system_rhs;
<< " s\n";
time.restart();
- typedef PreconditionChebyshev<
- LevelMatrixType,
- LinearAlgebra::distributed::Vector<float>,
- PreconditionBlockJacobi<dim, fe_degree, float>>
- SmootherType;
+ using SmootherType =
+ PreconditionChebyshev<LevelMatrixType,
+ LinearAlgebra::distributed::Vector<float>,
+ PreconditionBlockJacobi<dim, fe_degree, float>>;
mg::SmootherRelaxation<SmootherType,
LinearAlgebra::distributed::Vector<float>>
mg_smoother;