pi-DoMUS: Parallel Deal.II MUltiphysics Solver
lac_initializer.h
Go to the documentation of this file.
1 #ifndef _LAC_INITIALIZER_H_
2 #define _LAC_INITIALIZER_H_
3 
4 // This includes all types we know of.
5 #include "lac/lac_type.h"
6 #include <mpi.h>
7 
13 {
14 public:
15  ScopedLACInitializer(const std::vector<types::global_dof_index> &dofs_per_block,
16  const std::vector<IndexSet> &owned,
17  const std::vector<IndexSet> &relevant,
18  const MPI_Comm &comm = MPI_COMM_WORLD):
19  dofs_per_block(dofs_per_block),
20  owned(owned),
21  relevant(relevant),
22  comm(comm)
23  {};
24 
29  {
30  v.reinit(owned, comm, fast);
31  };
32 
33 
37  void ghosted(TrilinosWrappers::MPI::BlockVector &v, bool fast=false)
38  {
39  v.reinit(owned, relevant, comm, fast);
40  };
41 
45  void operator() (BlockVector<double> &v, bool fast=false)
46  {
47  v.reinit(dofs_per_block, fast);
48  };
49 
50 
55  void ghosted(BlockVector<double> &, bool fast=false)
56  {
57  Assert(false, ExcInternalError("You tried to create a ghosted vector in a serial run."));
58  (void)fast;
59  };
60 
64  template<int dim, int spacedim>
66  const DoFHandler<dim, spacedim> &dh,
67  const ConstraintMatrix &cm,
68  const Table<2,DoFTools::Coupling> &coupling)
69  {
70  s.reinit(owned, owned, relevant, comm);
72  coupling, s,
73  cm, false,
75  s.compress();
76  }
77 
81  template<int dim, int spacedim>
82  void operator() (dealii::BlockSparsityPattern &s,
83  const DoFHandler<dim, spacedim> &dh,
84  const ConstraintMatrix &cm,
85  const Table<2,DoFTools::Coupling> &coupling)
86  {
87  dealii::BlockDynamicSparsityPattern csp(dofs_per_block, dofs_per_block);
88 
90  coupling, csp,
91  cm, false);
92  csp.compress();
93  s.copy_from(csp);
94  }
95 
96 private:
100  const std::vector<types::global_dof_index> &dofs_per_block;
101 
105  const std::vector<IndexSet> &owned;
106 
110  const std::vector<IndexSet> &relevant;
111 
115  const MPI_Comm &comm;
116 };
117 
118 
119 // A few useful functions
121  VectorOperation::values op)
122 {
123  m.compress(op);
124 }
125 
126 inline void compress(dealii::BlockSparseMatrix<double> &,
127  VectorOperation::values )
128 {
129 }
130 #endif
void operator()(TrilinosWrappers::MPI::BlockVector &v, bool fast=false)
Initialize a non ghosted TrilinosWrappers::MPI::BlockVector.
Definition: lac_initializer.h:28
void reinit(const std::vector< size_type > &row_block_sizes, const std::vector< size_type > &col_block_sizes)
void ghosted(TrilinosWrappers::MPI::BlockVector &v, bool fast=false)
Initialize a ghosted TrilinosWrappers::MPI::BlockVector.
Definition: lac_initializer.h:37
General class, used to initialize different types of Vectors, Matrices and Sparsity Patterns using a ...
Definition: lac_initializer.h:12
void reinit(const std::vector< Epetra_Map > &parallel_partitioning, const bool omit_zeroing_entries=false) DEAL_II_DEPRECATED
#define Assert(cond, exc)
void reinit(const unsigned int n_blocks, const size_type block_size=0, const bool omit_zeroing_entries=false)
void make_sparsity_pattern(const DoFHandlerType &dof_handler, SparsityPatternType &sparsity_pattern, const ConstraintMatrix &constraints=ConstraintMatrix(), const bool keep_constrained_dofs=true, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id)
void ghosted(BlockVector< double > &, bool fast=false)
Initiale a ghosted BlockVector.
Definition: lac_initializer.h:55
unsigned int this_mpi_process(const MPI_Comm &mpi_communicator)
ScopedLACInitializer(const std::vector< types::global_dof_index > &dofs_per_block, const std::vector< IndexSet > &owned, const std::vector< IndexSet > &relevant, const MPI_Comm &comm=MPI_COMM_WORLD)
Definition: lac_initializer.h:15
void compress(::VectorOperation::values operation)
void compress(TrilinosWrappers::BlockSparseMatrix &m, VectorOperation::values op)
Definition: lac_initializer.h:120