239 *
using namespace dealii::LinearAlgebraPETSc;
242 *
using namespace dealii::LinearAlgebraTrilinos;
292 * <a name=
"Linearsolversandpreconditioners"></a>
313 * vector
types in
the vmult function.
316 *
template <
class Matrix,
class Preconditioner>
322 *
template <
typename VectorType>
323 *
void vmult(VectorType &dst,
const VectorType &src)
const;
331 *
template <
class Matrix,
class Preconditioner>
336 *
, preconditioner(preconditioner)
341 *
template <
class Matrix,
class Preconditioner>
342 *
template <
typename VectorType>
345 *
const VectorType &src)
const
347 *
SolverControl solver_control(src.size(), 1e-8 * src.l2_norm());
353 *
cg.solve(*matrix, dst, src, preconditioner);
355 *
catch (std::exception &e)
357 *
Assert(
false, ExcMessage(
e.what()));
368 *
template <
class PreconditionerA,
class PreconditionerS>
375 *
void vmult(LA::MPI::BlockVector & dst,
376 *
const LA::MPI::BlockVector &src)
const;
383 *
template <
class PreconditionerA,
class PreconditionerS>
392 *
template <
class PreconditionerA,
class PreconditionerS>
394 *
LA::MPI::BlockVector & dst,
395 *
const LA::MPI::BlockVector &src)
const
406 * <a name=
"Problemsetup"></a>
426 *
virtual void vector_value(
const Point<dim> &p,
435 *
const double R_x = p[0];
436 *
const double R_y = p[1];
466 *
virtual void vector_value(
const Point<dim> &p,
474 *
const double R_x = p[0];
475 *
const double R_y = p[1];
489 *
(-6538034.74494422 +
508 * <a name=
"Themainprogram"></a>
533 *
void refine_grid();
549 *
LA::MPI::BlockSparseMatrix system_matrix;
596 * <a name=
"SystemSetup"></a>
611 *
dof_handler.distribute_dofs(fe);
630 *
pcout <<
" Number of degrees of freedom: " << dof_handler.n_dofs() <<
" ("
631 *
<<
n_u <<
'+' <<
n_p <<
')' << std::endl;
643 *
dof_handler.locally_owned_dofs().get_view(
n_u,
n_u +
n_p);
655 * because we only perform global refinement, it is still a good idea
656 * to put this function call in, in case adaptive refinement gets
661 * constraints.reinit(locally_relevant_dofs);
663 * const FEValuesExtractors::Vector velocities(0);
664 * DoFTools::make_hanging_node_constraints(dof_handler, constraints);
665 * VectorTools::interpolate_boundary_values(dof_handler,
667 * ExactSolution<dim>(),
669 * fe.component_mask(velocities));
670 * constraints.close();
675 * Now we create the system matrix based on a BlockDynamicSparsityPattern.
684 *
system_matrix.clear();
687 *
for (
unsigned int c = 0; c < dim + 1; ++c)
688 *
for (
unsigned int d = 0;
d < dim + 1; ++
d)
689 *
if (c == dim && d == dim)
691 *
else if (c == dim || d == dim || c == d)
703 *
dof_handler.locally_owned_dofs(),
721 *
for (
unsigned int c = 0; c < dim + 1; ++c)
722 *
for (
unsigned int d = 0;
d < dim + 1; ++
d)
723 *
if (c == dim && d == dim)
735 *
dof_handler.locally_owned_dofs()),
759 * <a name=
"Assembly"></a>
784 *
const unsigned int dofs_per_cell = fe.n_dofs_per_cell();
794 *
std::vector<Tensor<2, dim>>
grad_phi_u(dofs_per_cell);
795 *
std::vector<double>
div_phi_u(dofs_per_cell);
796 *
std::vector<double>
phi_p(dofs_per_cell);
798 *
std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
802 *
for (
const auto &cell : dof_handler.active_cell_iterators())
803 *
if (cell->is_locally_owned())
812 *
for (
unsigned int q = 0;
q < n_q_points; ++
q)
814 *
for (
unsigned int k = 0;
k < dofs_per_cell; ++
k)
821 *
for (
unsigned int i = 0; i < dofs_per_cell; ++i)
823 *
for (
unsigned int j = 0;
j < dofs_per_cell; ++
j)
836 *
fe.system_to_component_index(i).first;
837 *
cell_rhs(i) += fe_values.shape_value(i,
q) *
843 *
cell->get_dof_indices(local_dof_indices);
844 *
constraints.distribute_local_to_global(cell_matrix,
865 * <a name=
"Solving"></a>
881 *
LA::MPI::PreconditionAMG
prec_A;
883 *
LA::MPI::PreconditionAMG::AdditionalData
data;
886 *
data.symmetric_operator =
true;
888 *
prec_A.initialize(system_matrix.block(0, 0),
data);
891 *
LA::MPI::PreconditionAMG
prec_S;
893 *
LA::MPI::PreconditionAMG::AdditionalData
data;
896 *
data.symmetric_operator =
true;
907 *
LA::MPI::PreconditionAMG>;
935 *
solver.solve(system_matrix,
940 *
pcout <<
" Solved in " << solver_control.last_step() <<
" iterations."
953 *
const double mean_pressure =
967 * <a name=
"Therest"></a>
1030 *
std::vector<DataComponentInterpretation::DataComponentInterpretation>
1031 *
data_component_interpretation(
1033 *
data_component_interpretation.push_back(
1037 *
data_out.attach_dof_handler(dof_handler);
1041 *
data_component_interpretation);
1057 *
data_component_interpretation);
1064 *
data_out.add_data_vector(
subdomain,
"subdomain");
1066 *
data_out.build_patches();
1068 *
data_out.write_vtu_with_pvtu_record(
1069 *
"./",
"solution", cycle, mpi_communicator, 2);
1074 *
template <
int dim>
1078 *
pcout <<
"Running using PETSc." << std::endl;
1080 *
pcout <<
"Running using Trilinos." << std::endl;
1082 *
const unsigned int n_cycles = 5;
1083 *
for (
unsigned int cycle = 0; cycle < n_cycles; ++cycle)
1085 *
pcout <<
"Cycle " << cycle <<
':' << std::endl;
1106 *
pcout << std::endl;
1117 *
using namespace dealii;
1118 *
using namespace Step55;
1125 *
catch (std::exception &exc)
1127 *
std::cerr << std::endl
1129 *
<<
"----------------------------------------------------"
1131 *
std::cerr <<
"Exception on processing: " << std::endl
1132 *
<< exc.what() << std::endl
1133 *
<<
"Aborting!" << std::endl
1134 *
<<
"----------------------------------------------------"
1141 *
std::cerr << std::endl
1143 *
<<
"----------------------------------------------------"
1145 *
std::cerr <<
"Unknown exception!" << std::endl
1146 *
<<
"Aborting!" << std::endl
1147 *
<<
"----------------------------------------------------"
1375<a name=
"extensions"></a>
1376<a name=
"Possibilitiesforextensions"></a><
h3>Possibilities
for extensions</
h3>
1406 QGauss<dim - 1>(fe.degree + 1),
value_type * data() const noexcept
void reinit(value_type *starting_element, const std::size_t n_elements)
#define DEAL_II_WITH_TRILINOS
#define DEAL_II_WITH_PETSC
__global__ void set(Number *val, const Number s, const size_type N)
#define Assert(cond, exc)
void loop(ITERATOR begin, std_cxx20::type_identity_t< ITERATOR > end, DOFINFO &dinfo, INFOBOX &info, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
void make_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern, const AffineConstraints< number > &constraints=AffineConstraints< number >(), const bool keep_constrained_dofs=true, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id)
@ update_values
Shape function values.
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
std::vector< value_type > split(const typename ::Triangulation< dim, spacedim >::cell_iterator &parent, const value_type parent_value)
@ component_is_part_of_vector
void component_wise(DoFHandler< dim, spacedim > &dof_handler, const std::vector< unsigned int > &target_component=std::vector< unsigned int >())
void hyper_cube(Triangulation< dim, spacedim > &tria, const double left=0., const double right=1., const bool colorize=false)
@ matrix
Contents is actually a matrix.
@ symmetric
Matrix is symmetric.
@ diagonal
Matrix is diagonal.
void cell_matrix(FullMatrix< double > &M, const FEValuesBase< dim > &fe, const FEValuesBase< dim > &fetest, const ArrayView< const std::vector< double > > &velocity, const double factor=1.)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
void call(const std::function< RT()> &function, internal::return_value< RT > &ret_val)
std::vector< unsigned int > serial(const std::vector< unsigned int > &targets, const std::function< RequestType(const unsigned int)> &create_request, const std::function< AnswerType(const unsigned int, const RequestType &)> &answer_request, const std::function< void(const unsigned int, const AnswerType &)> &process_answer, const MPI_Comm comm)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
std::vector< T > all_gather(const MPI_Comm comm, const T &object_to_send)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
void run(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length, const unsigned int chunk_size)
int(&) functions(const void *v1, const void *v2)
static constexpr double PI
::VectorizedArray< Number, width > exp(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
const TriangulationDescription::Settings settings
const ::Triangulation< dim, spacedim > & tria