Skip to content

Commit 3b44dc0

Browse files
committed
fix mpi comm
1 parent 2f1083a commit 3b44dc0

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

include/lac/lac_initializer.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// This includes all types we know of.
55
#include "lac/lac_type.h"
6+
#include <deal.II/base/mpi.h>
67
#include <mpi.h>
78

89
/**
@@ -15,20 +16,20 @@ class ScopedLACInitializer
1516
ScopedLACInitializer(const std::vector<types::global_dof_index> &dofs_per_block,
1617
const std::vector<IndexSet> &owned,
1718
const std::vector<IndexSet> &relevant,
18-
const MPI_Comm &comm = MPI_COMM_WORLD):
19+
const MPI_Comm extcomm= MPI_COMM_WORLD):
1920
dofs_per_block(dofs_per_block),
2021
owned(owned),
2122
relevant(relevant),
22-
comm(comm)
23-
{};
23+
comm(Utilities::MPI::duplicate_communicator(extcomm))
24+
{}
2425

2526
/**
2627
* Initialize a non ghosted TrilinosWrappers::MPI::BlockVector.
2728
*/
2829
void operator() (TrilinosWrappers::MPI::BlockVector &v, bool fast=false)
2930
{
3031
v.reinit(owned, comm, fast);
31-
};
32+
}
3233

3334

3435
/**
@@ -37,15 +38,15 @@ class ScopedLACInitializer
3738
void ghosted(TrilinosWrappers::MPI::BlockVector &v, bool fast=false)
3839
{
3940
v.reinit(owned, relevant, comm, fast);
40-
};
41+
}
4142

4243
/**
4344
* Initialize a serial BlockVector<double>.
4445
*/
4546
void operator() (BlockVector<double> &v, bool fast=false)
4647
{
4748
v.reinit(dofs_per_block, fast);
48-
};
49+
}
4950

5051

5152
/**
@@ -56,7 +57,7 @@ class ScopedLACInitializer
5657
{
5758
Assert(false, ExcInternalError("You tried to create a ghosted vector in a serial run."));
5859
(void)fast;
59-
};
60+
}
6061

6162
/**
6263
* Initialize a Trilinos Sparsity Pattern.
@@ -112,7 +113,7 @@ class ScopedLACInitializer
112113
/**
113114
* MPI Communicator.
114115
*/
115-
const MPI_Comm &comm;
116+
MPI_Comm comm;
116117
};
117118

118119

include/pidomus.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class piDoMUS : public ParameterAcceptor, public SundialsInterface<typename LAC:
6666

6767
piDoMUS (const std::string &name,
6868
const BaseInterface<dim, spacedim, LAC> &energy,
69-
const MPI_Comm &comm = MPI_COMM_WORLD);
69+
const MPI_Comm comm = MPI_COMM_WORLD);
7070

7171
virtual void declare_parameters(ParameterHandler &prm);
7272
virtual void parse_parameters_call_back();
@@ -301,7 +301,7 @@ class piDoMUS : public ParameterAcceptor, public SundialsInterface<typename LAC:
301301

302302
void set_constrained_dofs_to_zero(typename LAC::VectorType &v) const;
303303

304-
const MPI_Comm &comm;
304+
MPI_Comm comm;
305305
const BaseInterface<dim, spacedim, LAC> &interface;
306306

307307
unsigned int n_cycles;

source/pidomus.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ using namespace deal2lkit;
4444
template <int dim, int spacedim, typename LAC>
4545
piDoMUS<dim, spacedim, LAC>::piDoMUS (const std::string &name,
4646
const BaseInterface<dim, spacedim, LAC> &interface,
47-
const MPI_Comm &communicator)
47+
const MPI_Comm communicator)
4848
:
4949
ParameterAcceptor(name),
5050
SundialsInterface<typename LAC::VectorType>(communicator),
51-
comm(communicator),
51+
comm(Utilities::MPI::duplicate_communicator(communicator)),
5252
interface(interface),
5353
pcout (std::cout,
5454
(Utilities::MPI::this_mpi_process(comm)

tests/checkpoint_restart_02.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#include "pidomus.h"
2-
#include "interfaces/poisson_problem_signals.h"
2+
#include "interfaces/poisson_problem.h"
33
#include "tests.h"
44

5-
6-
// test that we can write snapshots
75
using namespace dealii;
86
int main (int argc, char *argv[])
97
{
@@ -12,7 +10,6 @@ int main (int argc, char *argv[])
1210
numbers::invalid_unsigned_int);
1311

1412
MPILogInitAll log;
15-
deallog.depth_file(1);
1613

1714
deallog.depth_file(1);
1815
const int dim = 2;
@@ -29,6 +26,5 @@ int main (int argc, char *argv[])
2926

3027
deallog << "OK" << std::endl;
3128

32-
3329
return 0;
3430
}

tests/parameters/checkpoint_restart_02.prm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ subsection pidomus
164164
set Print some useful informations about processes = true
165165
set Refine mesh during transient = false
166166
set Resume computation from snapshot = false
167-
set Save snapshots during simulation = false
167+
set Save snapshots during simulation = true
168168
set Snapshot prefix =
169169
set Threshold for solver's restart = 1e-2
170170
set Time stepper = imex

0 commit comments

Comments
 (0)