Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
c3dc225d
Commit
c3dc225d
authored
Apr 26, 2019
by
Praetorius, Simon
Browse files
added Environment for MPI initialization
parent
73513f33
Changes
38
Hide whitespace changes
Inline
Side-by-side
src/amdis/Environment.hpp
0 → 100644
View file @
c3dc225d
#pragma once
// std c++ headers
#include
<cassert>
#include
<string>
#include
<dune/common/parallel/mpihelper.hh>
namespace
AMDiS
{
/// Establishes an environemnt for sequential and parallel AMDiS programs
/**
* This object initializes the MPI environement, parses initfiles and may
* initialize other external libraries. It is constructed with the program
* commandline arguments. In its destruction, the MPI environemnt is finalized.
* In the vast majority of AMDiS programs, an instance of Environemnt should
* be desclared at the very beginning of the main function.
**/
class
Environment
{
// insternal static container holding a pointer to the Dune::MPIHelper.
struct
Mpi
{
static
Mpi
&
instance
()
{
static
Mpi
mpi
;
return
mpi
;
}
void
registerMpiHelper
(
Dune
::
MPIHelper
&
mpiHelper
)
{
mpiHelper_
=
&
mpiHelper
;
}
int
rank
()
{
assert
(
mpiHelper_
!=
nullptr
);
return
mpiHelper_
->
rank
();
}
int
size
()
{
assert
(
mpiHelper_
!=
nullptr
);
return
mpiHelper_
->
size
();
}
private:
Dune
::
MPIHelper
*
mpiHelper_
=
nullptr
;
};
public:
/// Create an environment without mpi initialization, with a fixed initfile given as string
Environment
(
std
::
string
const
&
initFileName
=
""
);
/// Create an environemtn with initialization of MPI and initifiles from commandline arguments
/// or the provided initfile filename.
Environment
(
int
&
argc
,
char
**&
argv
,
std
::
string
const
&
initFileName
=
""
);
/// Return the MPI_Rank of the current processor.
static
int
mpiRank
()
{
return
Mpi
::
instance
().
rank
();
}
/// Return the MPI_Size if the group created by Dune::MPIHelper.
static
int
mpiSize
()
{
return
Mpi
::
instance
().
size
();
}
};
}
// end namespace AMDiS
src/amdis/Initfile.cpp
View file @
c3dc225d
#include
<amdis/Initfile.hpp>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
"Initfile.hpp"
#include
<amdis/InitfileParser.hpp>
...
...
src/amdis/InitfileParser.cpp
View file @
c3dc225d
#include
<amdis/InitfileParser.hpp>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
"InitfileParser.hpp"
#include
<amdis/Output.hpp>
#include
<amdis/common/Filesystem.hpp>
...
...
src/amdis/ProblemInstat.cpp
View file @
c3dc225d
#include
"config.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
"ProblemInstat.hpp"
namespace
AMDiS
...
...
src/amdis/ProblemInstatBase.cpp
View file @
c3dc225d
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
"ProblemInstatBase.hpp"
#include
"AdaptInfo.hpp"
...
...
src/amdis/ProblemStat.cpp
View file @
c3dc225d
#include
"config.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
"ProblemStat.hpp"
namespace
AMDiS
...
...
src/amdis/StandardProblemIteration.cpp
View file @
c3dc225d
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
"StandardProblemIteration.hpp"
#include
<amdis/AdaptInfo.hpp>
...
...
src/amdis/common/Filesystem.cpp
View file @
c3dc225d
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
"Filesystem.hpp"
#ifdef _WIN32
...
...
src/amdis/common/String.cpp
View file @
c3dc225d
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
"String.hpp"
namespace
AMDiS
...
...
test/DOFVectorTest.cpp
View file @
c3dc225d
...
...
@@ -7,6 +7,7 @@
#include
<dune/functions/functionspacebases/powerbasis.hh>
#include
<dune/functions/functionspacebases/lagrangebasis.hh>
#include
<amdis/AMDiS.hpp>
#include
<amdis/GridTransferManager.hpp>
#include
<amdis/LinearAlgebra.hpp>
...
...
@@ -36,7 +37,7 @@ void test_dofvector(B const& basis, DOFVector<B,T>& vec)
int
main
(
int
argc
,
char
**
argv
)
{
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
Environment
env
(
argc
,
argv
);
// create grid
Dune
::
FieldVector
<
double
,
2
>
L
;
L
=
1.0
;
...
...
test/DataTransferTest2d.cpp
View file @
c3dc225d
#include
<amdis/AMDiS.hpp>
#include
"DataTransferTest.hpp"
int
main
(
int
argc
,
char
**
argv
)
{
Environment
env
(
argc
,
argv
);
#ifdef HAVE_DUNE_UGGRID
using
Grid
=
Dune
::
UGGrid
<
2
>
;
#else
using
Grid
=
Dune
::
YaspGrid
<
2
>
;
#endif
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
using
Domain
=
typename
Dune
::
FieldVector
<
double
,
2
>
;
// polynomial of order 1
...
...
test/DataTransferTest3d.cpp
View file @
c3dc225d
#include
<amdis/AMDiS.hpp>
#include
"DataTransferTest.hpp"
int
main
(
int
argc
,
char
**
argv
)
{
Environment
env
(
argc
,
argv
);
#ifdef HAVE_DUNE_UGGRID
using
Grid
=
Dune
::
UGGrid
<
3
>
;
#else
using
Grid
=
Dune
::
YaspGrid
<
3
>
;
#endif
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
using
Domain
=
typename
Dune
::
FieldVector
<
double
,
3
>
;
// polynomial of order 1
...
...
test/DiscreteFunctionTest.cpp
View file @
c3dc225d
...
...
@@ -33,7 +33,7 @@ bool comp(DOFVector<GB,T> const& U, DOFVector<GB,T> const& V)
int
main
(
int
argc
,
char
**
argv
)
{
AMDiS
::
init
(
argc
,
argv
);
Environment
env
(
argc
,
argv
);
using
namespace
Dune
::
Indices
;
...
...
@@ -129,6 +129,5 @@ int main(int argc, char** argv)
AMDIS_TEST
(
comp
(
W3
,
W5
)
);
AMDIS_TEST
(
comp
(
W3
,
W6
)
);
AMDiS
::
finalize
();
return
0
;
}
test/ExpressionsTest.cpp
View file @
c3dc225d
...
...
@@ -18,7 +18,7 @@ using ElliptProblem = ProblemStat<ElliptParam>;
int
main
(
int
argc
,
char
**
argv
)
{
AMDiS
::
init
(
argc
,
argv
);
Environment
env
(
argc
,
argv
);
using
namespace
Dune
::
Indices
;
...
...
@@ -103,6 +103,5 @@ int main(int argc, char** argv)
DUNE_UNUSED
auto
int5
=
integrate
(
op5
,
gv
,
5
);
DUNE_UNUSED
auto
int6
=
integrate
(
op6
,
gv
,
5
);
AMDiS
::
finalize
();
return
0
;
}
test/IntegrateTest.cpp
View file @
c3dc225d
...
...
@@ -18,7 +18,7 @@ using ElliptProblem = ProblemStat<ElliptParam>;
int
main
(
int
argc
,
char
**
argv
)
{
AMDiS
::
init
(
argc
,
argv
);
Environment
env
(
argc
,
argv
);
ElliptProblem
prob
(
"ellipt"
);
prob
.
initialize
(
INIT_ALL
);
...
...
@@ -40,6 +40,5 @@ int main(int argc, char** argv)
AMDIS_TEST
(
i4
==
1.0
);
AMDiS
::
finalize
();
return
0
;
}
test/MarkerTest.cpp
View file @
c3dc225d
...
...
@@ -14,7 +14,7 @@ using DomainType = typename Dune::FieldVector<double,d>;
int
main
(
int
argc
,
char
**
argv
)
{
AMDiS
::
init
(
argc
,
argv
);
Environment
env
(
argc
,
argv
);
DomainType
lowerLeft
;
lowerLeft
=
0.0
;
// lower left grid corner
DomainType
upperRight
;
upperRight
=
1.0
;
// upper right grid corner
...
...
@@ -53,7 +53,5 @@ int main(int argc, char** argv)
prob
.
solution
().
interpolate
(
markerFunc
);
prob
.
writeFiles
(
adaptInfo
);
AMDiS
::
finalize
();
return
report_errors
();
}
test/OperationsTest.cpp
View file @
c3dc225d
...
...
@@ -11,7 +11,7 @@ using namespace AMDiS;
int
main
(
int
argc
,
char
**
argv
)
{
AMDiS
::
init
(
argc
,
argv
);
Environment
env
(
argc
,
argv
);
constexpr
Operation
::
StaticConstant
<
int
,
0
>
op0a
;
constexpr
Operation
::
Zero
op0b
;
...
...
@@ -77,6 +77,5 @@ int main(int argc, char** argv)
AMDIS_TEST_EQ
(
erg8
,
2
);
// constexpr int order8 = order(op8,2,3); // no order() for divides
AMDiS
::
finalize
();
return
report_errors
();
}
test/OperatorsTest.cpp
View file @
c3dc225d
...
...
@@ -15,7 +15,7 @@ using Problem = ProblemStat<Param>;
int
main
(
int
argc
,
char
**
argv
)
{
AMDiS
::
init
(
argc
,
argv
);
Environment
env
(
argc
,
argv
);
using
namespace
Dune
::
Indices
;
...
...
@@ -109,6 +109,5 @@ int main(int argc, char** argv)
prob
.
addMatrixOperator
(
opCDb
,
_p
,
_p
);
prob
.
addVectorOperator
(
opCDb
,
_p
);
AMDiS
::
finalize
();
return
0
;
}
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment