* Vector, BlockVector, but also std::vector@<bool@>, std::vector@<int@>,
* and std::vector@<double@>.
*/
- template <typename Vector>
- void fill_binary_vector (Vector &vector) const;
+ template <typename VectorType>
+ void fill_binary_vector (VectorType &vector) const;
/**
* Outputs a text representation of this IndexSet to the given stream. Used
*
* The same is true for the fraction of cells that is coarsened.
*/
- template <int dim, class Vector, int spacedim>
+ template <int dim, class VectorType, int spacedim>
void
- refine_and_coarsen_fixed_number (
- parallel::distributed::Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double top_fraction_of_cells,
- const double bottom_fraction_of_cells,
- const unsigned int max_n_cells = std::numeric_limits<unsigned int>::max());
+ refine_and_coarsen_fixed_number
+ (parallel::distributed::Triangulation<dim,spacedim> &tria,
+ const VectorType &criteria,
+ const double top_fraction_of_cells,
+ const double bottom_fraction_of_cells,
+ const unsigned int max_n_cells = std::numeric_limits<unsigned int>::max());
/**
* Like dealii::GridRefinement::refine_and_coarsen_fixed_fraction, but
*
* The same is true for the fraction of cells that is coarsened.
*/
- template <int dim, class Vector, int spacedim>
+ template <int dim, class VectorType, int spacedim>
void
- refine_and_coarsen_fixed_fraction (
- parallel::distributed::Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double top_fraction_of_error,
- const double bottom_fraction_of_error);
+ refine_and_coarsen_fixed_fraction
+ (parallel::distributed::Triangulation<dim,spacedim> &tria,
+ const VectorType &criteria,
+ const double top_fraction_of_error,
+ const double bottom_fraction_of_error);
}
}
}
* indicator. The default value of this argument is to impose no limit on
* the number of cells.
*/
- template <int dim, class Vector, int spacedim>
+ template <int dim, class VectorType, int spacedim>
void
- refine_and_coarsen_fixed_number (
- Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double top_fraction_of_cells,
- const double bottom_fraction_of_cells,
- const unsigned int max_n_cells = std::numeric_limits<unsigned int>::max());
+ refine_and_coarsen_fixed_number
+ (Triangulation<dim,spacedim> &tria,
+ const VectorType &criteria,
+ const double top_fraction_of_cells,
+ const double bottom_fraction_of_cells,
+ const unsigned int max_n_cells = std::numeric_limits<unsigned int>::max());
/**
* This function provides a refinement strategy controlling the reduction of
* indicator. The default value of this argument is to impose no limit on
* the number of cells.
*/
- template <int dim, class Vector, int spacedim>
+ template <int dim, class VectorType, int spacedim>
void
- refine_and_coarsen_fixed_fraction (
- Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double top_fraction,
- const double bottom_fraction,
- const unsigned int max_n_cells = std::numeric_limits<unsigned int>::max());
+ refine_and_coarsen_fixed_fraction
+ (Triangulation<dim,spacedim> &tria,
+ const VectorType &criteria,
+ const double top_fraction,
+ const double bottom_fraction,
+ const unsigned int max_n_cells = std::numeric_limits<unsigned int>::max());
* thesis, University of Heidelberg, 2005. See in particular Section 4.3,
* pp. 42-43.
*/
- template <int dim, class Vector, int spacedim>
+ template <int dim, class VectorType, int spacedim>
void
refine_and_coarsen_optimize (Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const unsigned int order=2);
+ const VectorType &criteria,
+ const unsigned int order=2);
/**
* Flag all mesh cells for which the value in @p criteria exceeds @p
* This function does not implement a refinement strategy, it is more a
* helper function for the actual strategies.
*/
- template <int dim, class Vector, int spacedim>
+ template <int dim, class VectorType, int spacedim>
void refine (Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
+ const VectorType &criteria,
const double threshold,
- const unsigned int max_to_mark = numbers::invalid_unsigned_int);
+ const unsigned int max_to_mark = numbers::invalid_unsigned_int);
/**
* Flag all mesh cells for which the value in @p criteria is less than @p
* This function does not implement a refinement strategy, it is more a
* helper function for the actual strategies.
*/
- template <int dim, class Vector, int spacedim>
+ template <int dim, class VectorType, int spacedim>
void coarsen (Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
+ const VectorType &criteria,
const double threshold);
/**
template <int dim, int spacedim,
template <int,int> class DH,
- class Vector>
+ class VectorType>
void
interpolate_to_different_mesh (const DH<dim, spacedim> &dof1,
- const Vector &u1,
+ const VectorType &u1,
const DH<dim, spacedim> &dof2,
- Vector &u2)
+ VectorType &u2)
{
Assert(GridTools::have_same_coarse_mesh(dof1, dof2),
ExcMessage ("The two containers must represent triangulations that "
template <int dim, int spacedim,
template <int,int> class DH,
- class Vector>
+ class VectorType>
void
interpolate_to_different_mesh (const DH<dim, spacedim> &dof1,
- const Vector &u1,
+ const VectorType &u1,
const DH<dim, spacedim> &dof2,
const ConstraintMatrix &constraints,
- Vector &u2)
+ VectorType &u2)
{
Assert(GridTools::have_same_coarse_mesh(dof1, dof2),
ExcMessage ("The two containers must represent triangulations that "
template <int dim, int spacedim,
template <int,int> class DH,
- class Vector>
+ class VectorType>
void
interpolate_to_different_mesh (const InterGridMap<DH<dim, spacedim> > &intergridmap,
- const Vector &u1,
+ const VectorType &u1,
const ConstraintMatrix &constraints,
- Vector &u2)
+ VectorType &u2)
{
const DH<dim, spacedim> &dof1 = intergridmap.get_source_grid();
const DH<dim, spacedim> &dof2 = intergridmap.get_destination_grid();
* Generic implementation of the project() function
*/
template <int dim, int spacedim,
- class Vector,
+ class VectorType,
template <int,int> class DH,
template <int,int> class M_or_MC,
template <int> class Q_or_QC>
const ConstraintMatrix &constraints,
const Q_or_QC<dim> &quadrature,
const Function<spacedim> &function,
- Vector &vec_result,
+ VectorType &vec_result,
const bool enforce_zero_boundary,
const Q_or_QC<dim-1> &q_boundary,
const bool project_to_boundary_first)
* or not), extract those that pertain to
* locally owned cells.
*/
- template <int dim, int spacedim, class Vector>
+ template <int dim, int spacedim, typename VectorType>
void
get_locally_owned_indicators (const parallel::distributed::Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- dealii::Vector<typename Vector::value_type> &locally_owned_indicators)
+ const VectorType &criteria,
+ dealii::Vector<typename VectorType::value_type> &locally_owned_indicators)
{
Assert (locally_owned_indicators.size() == tria.n_locally_owned_active_cells(),
ExcInternalError());
* locally own as appropriate for
* coarsening or refinement.
*/
- template <int dim, int spacedim, class Vector>
+ template <int dim, int spacedim, typename VectorType>
void
mark_cells (parallel::distributed::Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double top_threshold,
- const double bottom_threshold)
+ const VectorType &criteria,
+ const double top_threshold,
+ const double bottom_threshold)
{
dealii::GridRefinement::refine (tria, criteria, top_threshold);
dealii::GridRefinement::coarsen (tria, criteria, bottom_threshold);
{
namespace GridRefinement
{
- template <int dim, class Vector, int spacedim>
+ template <int dim, typename VectorType, int spacedim>
void
- refine_and_coarsen_fixed_number (
- parallel::distributed::Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double top_fraction_of_cells,
- const double bottom_fraction_of_cells,
- const unsigned int max_n_cells)
+ refine_and_coarsen_fixed_number
+ (parallel::distributed::Triangulation<dim,spacedim> &tria,
+ const VectorType &criteria,
+ const double top_fraction_of_cells,
+ const double bottom_fraction_of_cells,
+ const unsigned int max_n_cells)
{
Assert (criteria.size() == tria.n_active_cells(),
ExcDimensionMismatch (criteria.size(), tria.n_active_cells()));
// vector of indicators the
// ones that correspond to
// cells that we locally own
- dealii::Vector<typename Vector::value_type>
+ dealii::Vector<typename VectorType::value_type>
locally_owned_indicators (tria.n_locally_owned_active_cells());
get_locally_owned_indicators (tria,
criteria,
// need it here, but it's a
// collective communication
// call
- const std::pair<typename Vector::value_type,typename Vector::value_type> global_min_and_max
+ const std::pair<typename VectorType::value_type,typename VectorType::value_type> global_min_and_max
= compute_global_min_and_max_at_root (locally_owned_indicators,
mpi_communicator);
}
- template <int dim, class Vector, int spacedim>
+ template <int dim, typename VectorType, int spacedim>
void
- refine_and_coarsen_fixed_fraction (
- parallel::distributed::Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double top_fraction_of_error,
- const double bottom_fraction_of_error)
+ refine_and_coarsen_fixed_fraction
+ (parallel::distributed::Triangulation<dim,spacedim> &tria,
+ const VectorType &criteria,
+ const double top_fraction_of_error,
+ const double bottom_fraction_of_error)
{
Assert (criteria.size() == tria.n_active_cells(),
ExcDimensionMismatch (criteria.size(), tria.n_active_cells()));
// vector of indicators the
// ones that correspond to
// cells that we locally own
- dealii::Vector<typename Vector::value_type>
+ dealii::Vector<typename VectorType::value_type>
locally_owned_indicators (tria.n_locally_owned_active_cells());
get_locally_owned_indicators (tria,
criteria,
} /* namespace internal */
- template <typename Vector>
- typename constraint_and_return_value<!IsBlockVector<Vector>::value,
- typename Vector::value_type>::type
- min_element (const Vector &criteria)
+ template <typename VectorType>
+ typename constraint_and_return_value<!IsBlockVector<VectorType>::value,
+ typename VectorType::value_type>::type
+ min_element (const VectorType &criteria)
{
return internal::min_element (criteria);
}
- template <typename Vector>
- typename constraint_and_return_value<!IsBlockVector<Vector>::value,
- typename Vector::value_type>::type
- max_element (const Vector &criteria)
+ template <typename VectorType>
+ typename constraint_and_return_value<!IsBlockVector<VectorType>::value,
+ typename VectorType::value_type>::type
+ max_element (const VectorType &criteria)
{
return internal::max_element (criteria);
}
- template <typename Vector>
- typename constraint_and_return_value<IsBlockVector<Vector>::value,
- typename Vector::value_type>::type
- min_element (const Vector &criteria)
+ template <typename VectorType>
+ typename constraint_and_return_value<IsBlockVector<VectorType>::value,
+ typename VectorType::value_type>::type
+ min_element (const VectorType &criteria)
{
- typename Vector::value_type t = internal::min_element(criteria.block(0));
+ typename VectorType::value_type t = internal::min_element(criteria.block(0));
for (unsigned int b=1; b<criteria.n_blocks(); ++b)
t = std::min (t, internal::min_element(criteria.block(b)));
}
- template <typename Vector>
- typename constraint_and_return_value<IsBlockVector<Vector>::value,
- typename Vector::value_type>::type
- max_element (const Vector &criteria)
+ template <typename VectorType>
+ typename constraint_and_return_value<IsBlockVector<VectorType>::value,
+ typename VectorType::value_type>::type
+ max_element (const VectorType &criteria)
{
- typename Vector::value_type t = internal::max_element(criteria.block(0));
+ typename VectorType::value_type t = internal::max_element(criteria.block(0));
for (unsigned int b=1; b<criteria.n_blocks(); ++b)
t = std::max (t, internal::max_element(criteria.block(b)));
* library version and is needed in @p refine_and_coarsen_optimize.
*/
- template <class Vector>
- void qsort_index (const Vector &a,
+ template <class VectorType>
+ void qsort_index (const VectorType &a,
std::vector<unsigned int> &ind,
int l,
int r)
{
int i,j;
- typename Vector::value_type v;
+ typename VectorType::value_type v;
if (r<=l)
return;
-template <int dim, class Vector, int spacedim>
+template <int dim, class VectorType, int spacedim>
void GridRefinement::refine (Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
+ const VectorType &criteria,
const double threshold,
const unsigned int max_to_mark)
{
-template <int dim, class Vector, int spacedim>
+template <int dim, class VectorType, int spacedim>
void GridRefinement::coarsen (Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double threshold)
+ const VectorType &criteria,
+ const double threshold)
{
Assert (criteria.size() == tria.n_active_cells(),
ExcDimensionMismatch(criteria.size(), tria.n_active_cells()));
return (adjusted_fractions);
}
-template <int dim, class Vector, int spacedim>
+template <int dim, class VectorType, int spacedim>
void
GridRefinement::refine_and_coarsen_fixed_number (Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const double top_fraction,
- const double bottom_fraction,
- const unsigned int max_n_cells)
+ const VectorType &criteria,
+ const double top_fraction,
+ const double bottom_fraction,
+ const unsigned int max_n_cells)
{
// correct number of cells is
// checked in @p{refine}
if (refine_cells || coarsen_cells)
{
- dealii::Vector<typename Vector::value_type> tmp (criteria);
+ dealii::Vector<typename VectorType::value_type> tmp (criteria);
if (refine_cells)
{
std::nth_element (tmp.begin(), tmp.begin()+refine_cells,
-template <int dim, class Vector, int spacedim>
+template <int dim, typename VectorType, int spacedim>
void
GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
+ const VectorType &criteria,
const double top_fraction,
const double bottom_fraction,
const unsigned int max_n_cells)
// error, which is what we have to sum
// up and compare with
// @p{fraction_of_error*total_error}.
- dealii::Vector<typename Vector::value_type> tmp;
+ dealii::Vector<typename VectorType::value_type> tmp;
tmp = criteria;
const double total_error = tmp.l1_norm();
std::sort (tmp.begin(), tmp.end(), std::greater<double>());
// compute thresholds
- typename dealii::Vector<typename Vector::value_type>::const_iterator
+ typename dealii::Vector<typename VectorType::value_type>::const_iterator
pp=tmp.begin();
for (double sum=0;
(sum<top_fraction*total_error) && (pp!=(tmp.end()-1));
double top_threshold = ( pp != tmp.begin () ?
(*pp+*(pp-1))/2 :
*pp );
- typename dealii::Vector<typename Vector::value_type>::const_iterator
+ typename dealii::Vector<typename VectorType::value_type>::const_iterator
qq=(tmp.end()-1);
for (double sum=0;
(sum<bottom_fraction*total_error) && (qq!=tmp.begin());
-template <int dim, class Vector, int spacedim>
+template <int dim, typename VectorType, int spacedim>
void
GridRefinement::refine_and_coarsen_optimize (Triangulation<dim,spacedim> &tria,
- const Vector &criteria,
- const unsigned int order)
+ const VectorType &criteria,
+ const unsigned int order)
{
Assert (criteria.size() == tria.n_active_cells(),
ExcDimensionMismatch(criteria.size(), tria.n_active_cells()));
#include "grid_refinement.inst"
DEAL_II_NAMESPACE_CLOSE
-
#include <vector>
-template <class Vector>
-void test (Vector &vector)
+template <typename VectorType>
+void test (VectorType &vector)
{
const unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
vector(i) = i;
// select every other element
- std::vector<typename Vector::size_type> indices;
+ std::vector<typename VectorType::size_type> indices;
for (unsigned int j=0; j<vector.size()/2; ++j)
indices.push_back (2*j);
// do the extraction with the function that takes indices, then
// assert correctness
- std::vector<typename Vector::value_type> values1 (indices.size());
+ std::vector<typename VectorType::value_type> values1 (indices.size());
vector.extract_subvector_to (indices, values1);
for (unsigned int j=0; j<vector.size()/2; ++j)
AssertThrow (values1[j] == 2*j, ExcInternalError());
// do the same with the version of the function that takes iterators
- std::vector<typename Vector::value_type> values2 (indices.size());
+ std::vector<typename VectorType::value_type> values2 (indices.size());
vector.extract_subvector_to (indices.begin(),
indices.end(),
values2.begin());
#include <vector>
-template <class Vector>
-void set (Vector &vector)
+template <typename VectorType>
+void set (VectorType &vector)
{
for (unsigned int i=0; i<vector.size(); ++i)
if (vector.locally_owned_elements().is_element(i))
}
-template <class Vector>
-void test (Vector &vector)
+template <typename VectorType>
+void test (VectorType &vector)
{
const unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
// select every other element
- std::vector<typename Vector::size_type> indices;
+ std::vector<typename VectorType::size_type> indices;
for (unsigned int j=0; j<vector.size()/2; ++j)
indices.push_back (2*j);
// do the extraction with the function that takes indices, then
// assert correctness
- std::vector<typename Vector::value_type> values1 (indices.size());
+ std::vector<typename VectorType::value_type> values1 (indices.size());
vector.extract_subvector_to (indices, values1);
for (unsigned int j=0; j<vector.size()/2; ++j)
AssertThrow (values1[j] == 2*j, ExcInternalError());
// do the same with the version of the function that takes iterators
- std::vector<typename Vector::value_type> values2 (indices.size());
+ std::vector<typename VectorType::value_type> values2 (indices.size());
vector.extract_subvector_to (indices.begin(),
indices.end(),
values2.begin());
#include <fstream>
-template <class Vector, class Matrix, class Sparsity>
+template <typename VectorType, class Matrix, class Sparsity>
class LaplaceProblem
{
public:
void reinit_sparsity ();
void reinit_vectors ();
- Vector solution;
+ VectorType solution;
private:
void make_grid_and_dofs ();
const unsigned int n_blocks;
- Triangulation<2> triangulation;
- FE_Q<2> fe;
- DoFHandler<2> dof_handler;
+ Triangulation<2> triangulation;
+ FE_Q<2> fe;
+ DoFHandler<2> dof_handler;
- Sparsity sparsity_pattern;
- Matrix system_matrix;
+ Sparsity sparsity_pattern;
+ Matrix system_matrix;
- Vector system_rhs;
+ VectorType system_rhs;
};
-template <class Vector, class Matrix, class Sparsity>
-LaplaceProblem<Vector,Matrix,Sparsity>::LaplaceProblem (const unsigned int n_blocks) :
+template <typename VectorType, class Matrix, class Sparsity>
+LaplaceProblem<VectorType,Matrix,Sparsity>::LaplaceProblem (const unsigned int n_blocks) :
n_blocks (n_blocks),
fe(1),
dof_handler (triangulation)
-template <class Vector, class Matrix, class Sparsity>
-void LaplaceProblem<Vector,Matrix,Sparsity>::make_grid_and_dofs ()
+template <typename VectorType, class Matrix, class Sparsity>
+void LaplaceProblem<VectorType,Matrix,Sparsity>::make_grid_and_dofs ()
{
GridGenerator::hyper_cube (triangulation, -1, 1);
triangulation.refine_global (3);
-template <class Vector, class Matrix, class Sparsity>
-void LaplaceProblem<Vector,Matrix,Sparsity>::assemble_system ()
+template <typename VectorType, class Matrix, class Sparsity>
+void LaplaceProblem<VectorType,Matrix,Sparsity>::assemble_system ()
{
QGauss<2> quadrature_formula(2);
FEValues<2> fe_values (fe, quadrature_formula,
}
-template <class Vector, class Matrix, class Sparsity>
-void LaplaceProblem<Vector,Matrix,Sparsity>::solve ()
+template <typename VectorType, class Matrix, class Sparsity>
+void LaplaceProblem<VectorType,Matrix,Sparsity>::solve ()
{
- SolverControl solver_control (1000, 1e-12, false, false);
- PrimitiveVectorMemory<Vector> vector_memory;
- SolverCG<Vector> cg (solver_control, vector_memory);
+ SolverControl solver_control (1000, 1e-12, false, false);
+ PrimitiveVectorMemory<VectorType> vector_memory;
+ SolverCG<VectorType> cg (solver_control, vector_memory);
PreconditionJacobi<Matrix> preconditioner;
preconditioner.initialize (system_matrix, 0.8);
}
-template <class Vector, class Matrix, class Sparsity>
-void LaplaceProblem<Vector,Matrix,Sparsity>::run ()
+template <typename VectorType, class Matrix, class Sparsity>
+void LaplaceProblem<VectorType,Matrix,Sparsity>::run ()
{
make_grid_and_dofs ();
assemble_system ();
for (unsigned int i=0; i<solution.size(); ++i)
deallog
- //<< typeid(Vector).name ()
+ //<< typeid(VectorType).name ()
//<< ' '
//<< typeid(Matrix).name ()
//<< '-'
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/precondition.h>
-template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+template<class SOLVER, class MATRIX, typename VectorType, class PRECONDITION>
void
-check_solve( SOLVER &solver, const MATRIX &A,
- VECTOR &u, VECTOR &f, const PRECONDITION &P)
+check_solve (SOLVER &solver,
+ const MATRIX &A,
+ VectorType &u,
+ VectorType &f,
+ const PRECONDITION &P)
{
u = 0.;
f = 1.;
}
}
-template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+template<class SOLVER, class MATRIX, typename VectorType, class PRECONDITION>
void
-check_Tsolve(SOLVER &solver, const MATRIX &A,
- VECTOR &u, VECTOR &f, const PRECONDITION &P)
+check_Tsolve (SOLVER &solver,
+ const MATRIX &A,
+ VectorType &u,
+ VectorType &f,
+ const PRECONDITION &P)
{
u = 0.;
f = 1.;
}
}
}
-