Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
amdis
amdis-core
Commits
a5743f27
Commit
a5743f27
authored
Jan 20, 2020
by
Praetorius, Simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove comm from solver
parent
752f128d
Changes
47
Hide whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
586 additions
and
449 deletions
+586
-449
CMakeLists.txt
CMakeLists.txt
+1
-1
examples/navier_stokes.cc
examples/navier_stokes.cc
+1
-0
src/amdis/BiLinearForm.hpp
src/amdis/BiLinearForm.hpp
+2
-2
src/amdis/DOFVector.hpp
src/amdis/DOFVector.hpp
+1
-1
src/amdis/LinearAlgebra.hpp
src/amdis/LinearAlgebra.hpp
+1
-1
src/amdis/LinearForm.hpp
src/amdis/LinearForm.hpp
+2
-2
src/amdis/ProblemInstat.hpp
src/amdis/ProblemInstat.hpp
+3
-3
src/amdis/ProblemInstat.inc.hpp
src/amdis/ProblemInstat.inc.hpp
+1
-1
src/amdis/ProblemStat.hpp
src/amdis/ProblemStat.hpp
+16
-12
src/amdis/ProblemStat.inc.hpp
src/amdis/ProblemStat.inc.hpp
+5
-6
src/amdis/ProblemStatTraits.hpp
src/amdis/ProblemStatTraits.hpp
+12
-6
src/amdis/linearalgebra/CMakeLists.txt
src/amdis/linearalgebra/CMakeLists.txt
+1
-2
src/amdis/linearalgebra/LinearSolver.hpp
src/amdis/linearalgebra/LinearSolver.hpp
+13
-15
src/amdis/linearalgebra/LinearSolverInterface.hpp
src/amdis/linearalgebra/LinearSolverInterface.hpp
+20
-11
src/amdis/linearalgebra/RunnerInterface.hpp
src/amdis/linearalgebra/RunnerInterface.hpp
+8
-9
src/amdis/linearalgebra/Traits.hpp
src/amdis/linearalgebra/Traits.hpp
+6
-6
src/amdis/linearalgebra/eigen/DirectRunner.hpp
src/amdis/linearalgebra/eigen/DirectRunner.hpp
+10
-14
src/amdis/linearalgebra/eigen/IterativeRunner.hpp
src/amdis/linearalgebra/eigen/IterativeRunner.hpp
+9
-13
src/amdis/linearalgebra/eigen/SolverCreator.hpp
src/amdis/linearalgebra/eigen/SolverCreator.hpp
+27
-23
src/amdis/linearalgebra/eigen/Traits.hpp
src/amdis/linearalgebra/eigen/Traits.hpp
+5
-7
src/amdis/linearalgebra/istl/AMGPrecon.hpp
src/amdis/linearalgebra/istl/AMGPrecon.hpp
+43
-41
src/amdis/linearalgebra/istl/CMakeLists.txt
src/amdis/linearalgebra/istl/CMakeLists.txt
+1
-1
src/amdis/linearalgebra/istl/Communication.inc.hpp
src/amdis/linearalgebra/istl/Communication.inc.hpp
+1
-1
src/amdis/linearalgebra/istl/Constraints.hpp
src/amdis/linearalgebra/istl/Constraints.hpp
+3
-3
src/amdis/linearalgebra/istl/CreatorInterfaces.hpp
src/amdis/linearalgebra/istl/CreatorInterfaces.hpp
+4
-12
src/amdis/linearalgebra/istl/Creators.hpp
src/amdis/linearalgebra/istl/Creators.hpp
+24
-24
src/amdis/linearalgebra/istl/ISTLSolver.hpp
src/amdis/linearalgebra/istl/ISTLSolver.hpp
+67
-0
src/amdis/linearalgebra/istl/MatrixBackend.hpp
src/amdis/linearalgebra/istl/MatrixBackend.hpp
+10
-2
src/amdis/linearalgebra/istl/PreconCreator.cpp
src/amdis/linearalgebra/istl/PreconCreator.cpp
+1
-4
src/amdis/linearalgebra/istl/PreconCreator.hpp
src/amdis/linearalgebra/istl/PreconCreator.hpp
+35
-38
src/amdis/linearalgebra/istl/SolverCreator.cpp
src/amdis/linearalgebra/istl/SolverCreator.cpp
+1
-4
src/amdis/linearalgebra/istl/SolverCreator.hpp
src/amdis/linearalgebra/istl/SolverCreator.hpp
+36
-38
src/amdis/linearalgebra/istl/Traits.hpp
src/amdis/linearalgebra/istl/Traits.hpp
+26
-16
src/amdis/linearalgebra/istl/precompiled/Common.hpp
src/amdis/linearalgebra/istl/precompiled/Common.hpp
+12
-0
src/amdis/linearalgebra/mtl/CMakeLists.txt
src/amdis/linearalgebra/mtl/CMakeLists.txt
+1
-0
src/amdis/linearalgebra/mtl/HyprePrecon.hpp
src/amdis/linearalgebra/mtl/HyprePrecon.hpp
+20
-18
src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp
src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp
+15
-16
src/amdis/linearalgebra/mtl/ITL_Solver.hpp
src/amdis/linearalgebra/mtl/ITL_Solver.hpp
+6
-9
src/amdis/linearalgebra/mtl/KrylovRunner.hpp
src/amdis/linearalgebra/mtl/KrylovRunner.hpp
+32
-14
src/amdis/linearalgebra/mtl/Preconditioner.hpp
src/amdis/linearalgebra/mtl/Preconditioner.hpp
+17
-14
src/amdis/linearalgebra/mtl/PreconditionerInterface.hpp
src/amdis/linearalgebra/mtl/PreconditionerInterface.hpp
+35
-0
src/amdis/linearalgebra/mtl/SolverPrecon.hpp
src/amdis/linearalgebra/mtl/SolverPrecon.hpp
+19
-19
src/amdis/linearalgebra/mtl/Traits.hpp
src/amdis/linearalgebra/mtl/Traits.hpp
+5
-7
src/amdis/linearalgebra/mtl/UmfpackRunner.hpp
src/amdis/linearalgebra/mtl/UmfpackRunner.hpp
+10
-17
src/amdis/linearalgebra/petsc/PetscRunner.hpp
src/amdis/linearalgebra/petsc/PetscRunner.hpp
+9
-5
src/amdis/linearalgebra/petsc/SolverCreator.hpp
src/amdis/linearalgebra/petsc/SolverCreator.hpp
+4
-4
src/amdis/linearalgebra/petsc/Traits.hpp
src/amdis/linearalgebra/petsc/Traits.hpp
+5
-7
No files found.
CMakeLists.txt
View file @
a5743f27
...
...
@@ -23,7 +23,7 @@ add_subdirectory("src")
add_subdirectory
(
"test"
)
target_link_libraries
(
amdis fmt
)
target_compile_options
(
amdis PUBLIC
"-Wfatal-errors"
"-Wall"
"-Wpedantic"
)
target_compile_options
(
amdis PUBLIC
"-Wall"
"-Wpedantic"
)
option
(
ENABLE_ALL_WARNINGS
"enable all meaningful warnings"
OFF
)
if
(
ENABLE_ALL_WARNINGS
)
...
...
examples/navier_stokes.cc
View file @
a5743f27
...
...
@@ -12,6 +12,7 @@ struct NavierStokesBasis
using
Grid
=
Dune
::
YaspGrid
<
GRIDDIM
>
;
using
GlobalBasis
=
typename
TaylorHoodBasis
<
Grid
>::
GlobalBasis
;
using
CoefficientType
=
double
;
using
LinAlgTraits
=
BackendTraits
<
GlobalBasis
>
;
};
int
main
(
int
argc
,
char
**
argv
)
...
...
src/amdis/BiLinearForm.hpp
View file @
a5743f27
...
...
@@ -21,7 +21,7 @@ namespace AMDiS
* \tparam CB Basis of matrix columns
* \tparam T Coefficient type to store in the matrix
**/
template
<
class
RB
,
class
CB
,
class
T
=
double
,
class
Traits
=
BackendTraits
<
RB
,
T
>
>
template
<
class
RB
,
class
CB
,
class
T
=
double
,
class
Traits
=
BackendTraits
<
RB
>
>
class
BiLinearForm
:
public
MatrixFacade
<
T
,
Traits
::
template
MatrixImpl
>
,
private
ObserverSequence
<
event
::
adapt
,
2
>
...
...
@@ -39,7 +39,7 @@ namespace AMDiS
using
ColLocalView
=
typename
ColBasis
::
LocalView
;
/// The type of the elements of the DOFVector
using
CoefficientType
=
typename
Traits
::
CoefficientType
;
using
CoefficientType
=
T
;
/// The type of the matrix filled on an element with local contributions
using
ElementMatrix
=
FlatMatrix
<
CoefficientType
>
;
...
...
src/amdis/DOFVector.hpp
View file @
a5743f27
...
...
@@ -35,7 +35,7 @@ namespace AMDiS
* \tparam T Type of the coefficients
* \tparam TraitsType Collection of parameter for the linear-algebra backend
**/
template
<
class
GB
,
class
T
=
double
,
class
TraitsType
=
BackendTraits
<
GB
,
T
>
>
template
<
class
GB
,
class
T
=
double
,
class
TraitsType
=
BackendTraits
<
GB
>
>
class
DOFVector
:
public
VectorFacade
<
T
,
TraitsType
::
template
VectorImpl
>
,
private
Observer
<
event
::
preAdapt
>
...
...
src/amdis/LinearAlgebra.hpp
View file @
a5743f27
...
...
@@ -28,7 +28,7 @@
#else // ISTL
#include <amdis/linearalgebra/istl/Constraints.hpp>
#include <amdis/linearalgebra/istl/ISTL
Runn
er.hpp>
#include <amdis/linearalgebra/istl/ISTL
Solv
er.hpp>
#include <amdis/linearalgebra/istl/PreconCreator.hpp>
#include <amdis/linearalgebra/istl/SolverCreator.hpp>
#include <amdis/linearalgebra/istl/Traits.hpp>
...
...
src/amdis/LinearForm.hpp
View file @
a5743f27
...
...
@@ -19,7 +19,7 @@ namespace AMDiS
* \tparam T Coefficient type to store in the vector
* \tparam Traits Collection of parameter for the linear-algebra backend
**/
template
<
class
GB
,
class
T
=
double
,
class
Traits
=
BackendTraits
<
GB
,
T
>
>
template
<
class
GB
,
class
T
=
double
,
class
Traits
=
BackendTraits
<
GB
>
>
class
LinearForm
:
public
VectorFacade
<
T
,
Traits
::
template
VectorImpl
>
{
...
...
@@ -32,7 +32,7 @@ namespace AMDiS
using
LocalView
=
typename
GlobalBasis
::
LocalView
;
/// The type of the elements of the DOFVector
using
CoefficientType
=
typename
Traits
::
CoefficientType
;
using
CoefficientType
=
T
;
/// The type of the vector filled on an element with local contributions
using
ElementVector
=
FlatVector
<
CoefficientType
>
;
...
...
src/amdis/ProblemInstat.hpp
View file @
a5743f27
...
...
@@ -25,7 +25,7 @@ namespace AMDiS
using
Self
=
ProblemInstat
;
using
ProblemType
=
ProblemStat
<
Traits
>
;
using
Coefficient
Vector
=
typename
ProblemType
::
Coefficient
Vector
;
using
Solution
Vector
=
typename
ProblemType
::
Solution
Vector
;
public:
/// Constructs a ProblemInstat with prob as its stationary problem, stored as reference.
...
...
@@ -54,7 +54,7 @@ namespace AMDiS
ProblemType
const
&
problemStat
()
const
{
return
*
problemStat_
;
}
/// Returns const-ref of \ref oldSolution.
std
::
shared_ptr
<
Coefficient
Vector
const
>
oldSolutionVector
()
const
std
::
shared_ptr
<
Solution
Vector
const
>
oldSolutionVector
()
const
{
test_exit_dbg
(
bool
(
oldSolution_
),
"OldSolution need to be created. Call initialize with INIT_UH_OLD."
);
...
...
@@ -82,7 +82,7 @@ namespace AMDiS
ProblemType
*
problemStat_
;
/// Solution of the last timestep.
std
::
shared_ptr
<
Coefficient
Vector
>
oldSolution_
;
std
::
shared_ptr
<
Solution
Vector
>
oldSolution_
;
};
...
...
src/amdis/ProblemInstat.inc.hpp
View file @
a5743f27
...
...
@@ -43,7 +43,7 @@ void ProblemInstat<Traits>::createUhOld()
if
(
oldSolution_
)
warning
(
"oldSolution already created
\n
"
);
else
// create oldSolution
oldSolution_
.
reset
(
new
Coefficient
Vector
(
*
problemStat_
->
solutionVector
()));
oldSolution_
.
reset
(
new
Solution
Vector
(
*
problemStat_
->
solutionVector
()));
}
...
...
src/amdis/ProblemStat.hpp
View file @
a5743f27
...
...
@@ -76,13 +76,17 @@ namespace AMDiS
/// Dimension of the world
static
constexpr
int
dow
=
Grid
::
dimensionworld
;
using
LinearSolverTraits
=
BackendTraits
<
GlobalBasis
,
typename
Traits
::
CoefficientType
>
;
using
LinearSolverType
=
LinearSolverInterface
<
LinearSolverTraits
>
;
using
CommunicationType
=
typename
LinearSolverTraits
::
Comm
;
private:
using
LinAlgTraits
=
typename
Traits
::
LinAlgTraits
;
using
Mat
=
typename
LinAlgTraits
::
template
MatrixImpl
<
typename
Traits
::
CoefficientType
>;
using
Vec
=
typename
LinAlgTraits
::
template
VectorImpl
<
typename
Traits
::
CoefficientType
>;
using
PartitionSet
=
typename
LinAlgTraits
::
PartitionSet
;
using
SystemMatrix
=
BiLinearForm
<
GlobalBasis
,
GlobalBasis
,
typename
Traits
::
CoefficientType
>
;
using
SystemVector
=
LinearForm
<
GlobalBasis
,
typename
Traits
::
CoefficientType
>
;
using
CoefficientVector
=
DOFVector
<
GlobalBasis
,
typename
Traits
::
CoefficientType
>
;
public:
using
LinearSolver
=
LinearSolverInterface
<
Mat
,
Vec
>
;
using
SystemMatrix
=
BiLinearForm
<
GlobalBasis
,
GlobalBasis
,
typename
Traits
::
CoefficientType
,
LinAlgTraits
>
;
using
SystemVector
=
LinearForm
<
GlobalBasis
,
typename
Traits
::
CoefficientType
,
LinAlgTraits
>
;
using
SolutionVector
=
DOFVector
<
GlobalBasis
,
typename
Traits
::
CoefficientType
,
LinAlgTraits
>
;
public:
/**
...
...
@@ -334,16 +338,16 @@ namespace AMDiS
std
::
shared_ptr
<
GlobalBasis
const
>
globalBasis
()
const
{
return
globalBasis_
;
}
/// Return a reference to the linear solver, \ref linearSolver
std
::
shared_ptr
<
LinearSolver
Type
>
solver
()
{
return
linearSolver_
;
}
std
::
shared_ptr
<
LinearSolver
Type
const
>
solver
()
const
{
return
linearSolver_
;
}
std
::
shared_ptr
<
LinearSolver
>
solver
()
{
return
linearSolver_
;
}
std
::
shared_ptr
<
LinearSolver
const
>
solver
()
const
{
return
linearSolver_
;
}
/// Returns a reference to system-matrix, \ref systemMatrix_
std
::
shared_ptr
<
SystemMatrix
>
systemMatrix
()
{
return
systemMatrix_
;
}
std
::
shared_ptr
<
SystemMatrix
const
>
systemMatrix
()
const
{
return
systemMatrix_
;
}
/// Returns a reference to the solution vector, \ref solution_
std
::
shared_ptr
<
Coefficient
Vector
>
solutionVector
()
{
return
solution_
;
}
std
::
shared_ptr
<
Coefficient
Vector
const
>
solutionVector
()
const
{
return
solution_
;
}
std
::
shared_ptr
<
Solution
Vector
>
solutionVector
()
{
return
solution_
;
}
std
::
shared_ptr
<
Solution
Vector
const
>
solutionVector
()
const
{
return
solution_
;
}
/// Return a reference to the rhs system-vector, \ref rhs
std
::
shared_ptr
<
SystemVector
>
rhsVector
()
{
return
rhs_
;
}
...
...
@@ -485,13 +489,13 @@ namespace AMDiS
// std::vector<Estimator*> estimator;
/// An object of the linearSolver Interface
std
::
shared_ptr
<
LinearSolver
Type
>
linearSolver_
;
std
::
shared_ptr
<
LinearSolver
>
linearSolver_
;
/// Matrix that is filled during assembling
std
::
shared_ptr
<
SystemMatrix
>
systemMatrix_
;
/// Vector with the solution components
std
::
shared_ptr
<
Coefficient
Vector
>
solution_
;
std
::
shared_ptr
<
Solution
Vector
>
solution_
;
/// Vector (load-vector) corresponding to the right-hand side
/// of the equation, filled during assembling
...
...
src/amdis/ProblemStat.inc.hpp
View file @
a5743f27
...
...
@@ -240,7 +240,7 @@ template <class Traits>
void
ProblemStat
<
Traits
>::
createMatricesAndVectors
()
{
systemMatrix_
=
std
::
make_shared
<
SystemMatrix
>
(
globalBasis_
,
globalBasis_
);
solution_
=
std
::
make_shared
<
Coefficient
Vector
>
(
globalBasis_
);
solution_
=
std
::
make_shared
<
Solution
Vector
>
(
globalBasis_
);
rhs_
=
std
::
make_shared
<
SystemVector
>
(
globalBasis_
);
auto
localView
=
globalBasis_
->
localView
();
...
...
@@ -261,7 +261,7 @@ void ProblemStat<Traits>::createSolver()
Parameters
::
get
(
name_
+
"->solver"
,
solverName
);
auto
solverCreator
=
named
(
CreatorMap
<
LinearSolver
Type
>::
getCreator
(
solverName
,
name_
+
"->solver"
));
=
named
(
CreatorMap
<
LinearSolver
>::
getCreator
(
solverName
,
name_
+
"->solver"
));
linearSolver_
=
solverCreator
->
createWithString
(
name_
+
"->solver"
);
}
...
...
@@ -291,7 +291,7 @@ void ProblemStat<Traits>::createMarker()
template
<
class
Traits
>
void
ProblemStat
<
Traits
>::
createFileWriter
()
{
FileWriterCreator
<
Coefficient
Vector
>
creator
(
solution_
,
boundaryManager_
);
FileWriterCreator
<
Solution
Vector
>
creator
(
solution_
,
boundaryManager_
);
filewriter_
.
clear
();
auto
localView
=
globalBasis_
->
localView
();
...
...
@@ -382,8 +382,7 @@ solve(AdaptInfo& adaptInfo, bool createMatrixData, bool storeMatrixData)
solverInfo
.
setStoreMatrixData
(
storeMatrixData
);
solution_
->
resize
();
linearSolver_
->
solve
(
systemMatrix_
->
impl
().
matrix
(),
solution_
->
impl
().
vector
(),
rhs_
->
impl
().
vector
(),
globalBasis_
->
communicator
(),
solverInfo
);
linearSolver_
->
solve
(
*
systemMatrix_
,
*
solution_
,
*
rhs_
,
solverInfo
);
if
(
solverInfo
.
info
()
>
0
)
{
msg
(
"solution of discrete system needed {} seconds"
,
t
.
elapsed
());
...
...
@@ -525,7 +524,7 @@ buildAfterAdapt(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool as
msg
(
"{} local DOFs"
,
rhs_
->
localSize
());
// 2. traverse grid and assemble operators on the elements
for
(
auto
const
&
element
:
elements
(
gridView
(),
typename
LinearSolverTraits
::
PartitionSet
{}))
{
for
(
auto
const
&
element
:
elements
(
gridView
(),
PartitionSet
{}))
{
localView
.
bind
(
element
);
if
(
asmMatrix
)
...
...
src/amdis/ProblemStatTraits.hpp
View file @
a5743f27
...
...
@@ -59,16 +59,20 @@ namespace AMDiS
}
// end namespace Impl
/// An Exemplar for ProblemStatTraits
template
<
class
GlobalBasisType
,
class
T
=
double
>
/// Wrapper around a global basis providing default traits
template
<
class
GB
,
class
T
=
double
,
template
<
class
>
class
TraitsImpl
=
BackendTraits
>
struct
DefaultProblemTraits
{
using
GlobalBasis
=
G
lobalBasisType
;
using
GlobalBasis
=
G
B
;
using
CoefficientType
=
T
;
using
LinAlgTraits
=
TraitsImpl
<
GB
>
;
};
template
<
class
HostGrid
,
class
PreBasisCreator
,
class
T
=
double
>
/// Generator for a basis and default problem traits
template
<
class
HostGrid
,
class
PreBasisCreator
,
class
T
=
double
,
template
<
class
>
class
TraitsImpl
=
BackendTraits
>
struct
DefaultBasisCreator
{
using
Grid
=
AdaptiveGrid_t
<
HostGrid
>
;
...
...
@@ -84,10 +88,12 @@ namespace AMDiS
return
makeGlobalBasis
(
gridView
,
PreBasisCreator
::
create
());
}
using
GlobalBasis
=
Underlying_t
<
decltype
(
create
(
std
::
declval
<
GridView
>
()))
>
;
using
GlobalBasis
=
decltype
(
create
(
std
::
declval
<
GridView
>
()));
using
CoefficientType
=
T
;
using
LinAlgTraits
=
TraitsImpl
<
GlobalBasis
>
;
};
/// \brief ProblemStatTraits for a (composite) basis composed of
/// lagrange bases of different degree.
template
<
class
Grid
,
int
...
degrees
>
...
...
src/amdis/linearalgebra/CMakeLists.txt
View file @
a5743f27
...
...
@@ -8,13 +8,12 @@ install(FILES
LinearSolverInterface.hpp
MatrixFacade.hpp
ParallelIndexSet.hpp
PreconditionerInterface.hpp
RunnerInterface.hpp
SolverInfo.hpp
SparsityPattern.hpp
SymmetryStructure.hpp
Traits.hpp
Vector
DefaultImplementation
.hpp
Vector
Base
.hpp
VectorFacade.hpp
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/amdis/linearalgebra
)
...
...
src/amdis/linearalgebra/LinearSolver.hpp
View file @
a5743f27
...
...
@@ -21,16 +21,12 @@ namespace AMDiS
* solvers where the backend provides an interface, can be assigned
* by different Runner objects.
**/
template
<
class
Traits
,
class
Runner
>
template
<
class
Mat
,
class
Vec
,
class
Runner
>
class
LinearSolver
:
public
LinearSolverInterface
<
Traits
>
:
public
LinearSolverInterface
<
Mat
,
Vec
>
{
using
Self
=
LinearSolver
;
using
Super
=
LinearSolverInterface
<
Traits
>
;
using
Mat
=
typename
Traits
::
Mat
;
using
Vec
=
typename
Traits
::
Vec
;
using
Comm
=
typename
Traits
::
Comm
;
using
Super
=
LinearSolverInterface
<
Mat
,
Vec
>
;
public:
/// A creator to be used instead of the constructor.
...
...
@@ -49,23 +45,25 @@ namespace AMDiS
:
runner_
(
prefix
,
FWD
(
args
)...)
{}
Runner
&
runner
()
{
return
runner_
;
}
Runner
const
&
runner
()
const
{
return
runner_
;
}
Runner
*
runner
()
override
{
return
&
runner_
;
}
pr
ivate
:
/// Implements \ref LinearSolverInterface::solve
System
Impl()
void
solveImpl
(
Mat
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
Comm
const
&
comm
,
SolverInfo
&
solverInfo
)
override
pr
otected
:
/// Implements \ref LinearSolverInterface::solveImpl()
void
solveImpl
(
Mat
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
SolverInfo
&
solverInfo
)
override
{
Dune
::
Timer
t
;
if
(
solverInfo
.
doCreateMatrixData
())
{
// init matrix or wrap block-matrix or ...
runner_
.
init
(
A
,
comm
);
runner_
.
init
(
A
.
matrix
()
);
}
if
(
solverInfo
.
info
()
>
0
)
msg
(
"prepare solver needed {} seconds"
,
t
.
elapsed
());
int
error
=
runner_
.
solve
(
A
,
x
,
b
,
solverInfo
);
int
error
=
runner_
.
solve
(
A
.
matrix
(),
x
.
vector
(),
b
.
vector
()
,
solverInfo
);
solverInfo
.
setError
(
error
);
if
(
!
solverInfo
.
doStoreMatrixData
())
...
...
@@ -73,7 +71,7 @@ namespace AMDiS
}
private:
/// redirect the implementation to a runner
. I
mplementing a \ref RunnerInterface
/// redirect the implementation to a runner
i
mplementing a \ref RunnerInterface
Runner
runner_
;
};
...
...
src/amdis/linearalgebra/LinearSolverInterface.hpp
View file @
a5743f27
#pragma once
/** \file LinearSolverInterface.h */
#include <amdis/Output.hpp>
#include <amdis/linearalgebra/RunnerInterface.hpp>
/**
* \defgroup Solver Solver module
...
...
@@ -15,15 +16,16 @@ namespace AMDiS
{
class
SolverInfo
;
template
<
class
T
,
template
<
class
>
class
MatrixImpl
>
class
MatrixFacade
;
template
<
class
T
,
template
<
class
>
class
VectorImpl
>
class
VectorFacade
;
/// Abstract base class for linear solvers
template
<
class
Traits
>
template
<
class
Mat
,
class
Vec
>
class
LinearSolverInterface
{
protected:
using
Mat
=
typename
Traits
::
Mat
;
using
Vec
=
typename
Traits
::
Vec
;
using
Comm
=
typename
Traits
::
Comm
;
public:
/// Destructor.
virtual
~
LinearSolverInterface
()
=
default
;
...
...
@@ -38,14 +40,21 @@ namespace AMDiS
* \p x A [block-]vector for the unknown components.
* \p b A [block-]vector for the right-hand side of the linear system.
**/
void
solve
(
Mat
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
Comm
const
&
comm
,
SolverInfo
&
solverInfo
)
template
<
class
TA
,
class
TX
,
class
TY
,
template
<
class
>
class
MI
,
template
<
class
>
class
VI
>
void
solve
(
MatrixFacade
<
TA
,
MI
>
const
&
A
,
VectorFacade
<
TX
,
VI
>&
x
,
VectorFacade
<
TY
,
VI
>
const
&
b
,
SolverInfo
&
solverInfo
)
{
solveImpl
(
A
,
x
,
b
,
comm
,
solverInfo
);
solveImpl
(
A
.
impl
(),
x
.
impl
(),
b
.
impl
()
,
solverInfo
);
}
private:
virtual
RunnerInterface
<
Mat
,
Vec
>*
runner
()
{
error_exit
(
"Must be implemented by derived class."
);
return
nullptr
;
}
protected:
/// main methods that all solvers must implement
virtual
void
solveImpl
(
Mat
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
Comm
const
&
comm
,
SolverInfo
&
solverInfo
)
=
0
;
virtual
void
solveImpl
(
Mat
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
SolverInfo
&
solverInfo
)
=
0
;
};
}
// end namespace AMDiS
src/amdis/linearalgebra/RunnerInterface.hpp
View file @
a5743f27
...
...
@@ -7,29 +7,28 @@ namespace AMDiS
class
SolverInfo
;
/// Interface for Runner / Worker types used in solver classes
template
<
class
Traits
>
template
<
class
Mat
,
class
Vec
>
class
RunnerInterface
{
protected:
using
Mat
=
typename
Traits
::
Mat
;
using
Vec
=
typename
Traits
::
Vec
;
using
Comm
=
typename
Traits
::
Comm
;
using
M
=
typename
Mat
::
BaseMatrix
;
using
X
=
typename
Vec
::
BaseVector
;
using
Y
=
typename
Vec
::
BaseVector
;
public:
/// virtual destructor
virtual
~
RunnerInterface
()
=
default
;
/// Is called at the beginning of a solution procedure
virtual
void
init
(
M
at
const
&
A
,
Comm
const
&
comm
)
=
0
;
virtual
void
init
(
M
const
&
A
)
=
0
;
/// Is called at the end of a solution procedure
virtual
void
exit
()
=
0
;
/// Solve the system A*x = b
virtual
int
solve
(
M
at
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
SolverInfo
&
solverInfo
)
=
0
;
virtual
int
solve
(
M
const
&
A
,
X
&
x
,
Y
const
&
b
,
SolverInfo
&
solverInfo
)
=
0
;
/// Solve the
adjoint
system A
^T
*x = b
virtual
int
adjointSolve
(
M
at
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
SolverInfo
&
solverInfo
)
/// Solve the system A*x = b
virtual
int
adjointSolve
(
M
const
&
A
,
X
&
x
,
Y
const
&
b
,
SolverInfo
&
solverInfo
)
{
error_exit
(
"Must be implemented by derived class."
);
return
0
;
...
...
src/amdis/linearalgebra/Traits.hpp
View file @
a5743f27
...
...
@@ -22,17 +22,17 @@ namespace AMDiS
* required to provide the typedefs listed here.
*
* \tparam Basis A global basis from dune-functions
* \tparam T The type of the coefficients stored in the matrix and vector
*/
template
<
class
Basis
,
class
T
=
double
>
template
<
class
Basis
>
class
BackendTraits
{
public:
using
Mat
=
implementation_defined
;
//< The backend matrix type
using
Vec
=
implementation_defined
;
//< The backend vector type
using
Comm
=
implementation_defined
;
//< The communication type
template
<
class
T
>
using
MatrixImpl
=
implementation_defined
;
//< The backend matrix type
template
<
class
T
>
using
VectorImpl
=
implementation_defined
;
//< The backend vector type
using
CoefficientType
=
T
;
//< The type of the matrix/vector entries
using
SparsityPattern
=
implementation_defined
;
//< The SparsityPattern for the matrix type
using
PartitionSet
=
Dune
::
Partitions
::
All
;
//< The dune partition set where to assemble operators
};
...
...
src/amdis/linearalgebra/eigen/DirectRunner.hpp
View file @
a5743f27
...
...
@@ -14,16 +14,16 @@ namespace AMDiS
* \class AMDiS::DirectRunner
* \brief \implements RunnerInterface for the (external) direct solvers
*/
template
<
template
<
class
>
class
Solver
,
class
Traits
>
template
<
class
Mat
,
class
Vec
,
template
<
class
>
class
Solver
>
class
DirectRunner
:
public
RunnerInterface
<
Traits
>
:
public
RunnerInterface
<
Mat
,
Vec
>
{
using
M
=
typename
Mat
::
BaseMatrix
;
using
X
=
typename
Vec
::
BaseVector
;
using
Y
=
typename
Vec
::
BaseVector
;
protected:
using
Super
=
RunnerInterface
<
Traits
>
;
using
Mat
=
typename
Traits
::
Mat
;
using
Vec
=
typename
Traits
::
Vec
;
using
Comm
=
typename
Traits
::
Comm
;
using
EigenSolver
=
Solver
<
Mat
>
;
using
EigenSolver
=
Solver
<
M
>
;
public:
/// Constructor.
...
...
@@ -35,10 +35,8 @@ namespace AMDiS
}
/// Implements \ref RunnerInterface::init()
void
init
(
M
at
const
&
A
,
Comm
const
&
comm
)
override
void
init
(
M
const
&
A
)
override
{
DUNE_UNUSED_PARAMETER
(
comm
);
if
(
!
reusePattern_
||
!
initialized_
)
{
solver_
.
analyzePattern
(
A
);
initialized_
=
true
;
...
...
@@ -56,13 +54,11 @@ namespace AMDiS
}
/// Implements \ref RunnerInterface::solve()
int
solve
(
M
at
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
SolverInfo
&
solverInfo
)
override
int
solve
(
M
const
&
A
,
X
&
x
,
Y
const
&
b
,
SolverInfo
&
solverInfo
)
{
DUNE_UNUSED_PARAMETER
(
A
);
x
=
solver_
.
solve
(
b
);
auto
r
=
Vec
(
b
)
;
Y
r
=
b
;
if
(
x
.
norm
()
!=
0
)
r
-=
A
*
x
;
...
...
src/amdis/linearalgebra/eigen/IterativeRunner.hpp
View file @
a5743f27
...
...
@@ -9,15 +9,16 @@
namespace
AMDiS
{
template
<
class
IterativeSolver
,
class
Traits
>
template
<
class
Mat
,
class
Vec
,
class
IterativeSolver
>
class
IterativeRunner
:
public
RunnerInterface
<
Traits
>
:
public
RunnerInterface
<
Mat
,
Vec
>
{
using
M
=
typename
Mat
::
BaseMatrix
;
using
X
=
typename
Vec
::
BaseVector
;
using
Y
=
typename
Vec
::
BaseVector
;
using
SolverCfg
=
SolverConfig
<
IterativeSolver
>
;
using
PreconCfg
=
PreconConfig
<
typename
IterativeSolver
::
Preconditioner
>
;
using
Mat
=
typename
Traits
::
Mat
;
using
Vec
=
typename
Traits
::
Vec
;
using
Comm
=
typename
Traits
::
Comm
;
public:
IterativeRunner
(
std
::
string
const
&
prefix
)
...
...
@@ -28,12 +29,9 @@ namespace AMDiS
Parameters
::
get
(
prefix
+
"->reuse pattern"
,
reusePattern_
);
}
/// Implements \ref RunnerInterface::init()
void
init
(
M
at
const
&
A
,
Comm
const
&
comm
)
override
void
init
(
M
const
&
A
)
override
{
DUNE_UNUSED_PARAMETER
(
comm
);
if
(
!
reusePattern_
||
!
initialized_
)
{
solver_
.
analyzePattern
(
A
);
initialized_
=
true
;
...
...
@@ -51,14 +49,12 @@ namespace AMDiS
}
/// Implements \ref RunnerInterface::solve()
int
solve
(
M
at
const
&
A
,
Vec
&
x
,
Vec
const
&
b
,
SolverInfo
&
solverInfo
)
override
int
solve
(
M
const
&
A
,
X
&
x
,
Y
const
&
b
,
SolverInfo
&
solverInfo
)
override
{
DUNE_UNUSED_PARAMETER
(
A
);
solver_
.
setTolerance
(
solverInfo
.
relTolerance
());
x
=
solver_
.
solveWithGuess
(
b
,
x
);
auto
r
=
Vec
(
b
)
;
Y
r
=
b
;
if
(
x
.
norm
()
!=
0
)
r
-=
A
*
x
;
...
...
src/amdis/linearalgebra/eigen/SolverCreator.hpp
View file @
a5743f27
...
...
@@ -20,18 +20,17 @@
namespace
AMDiS
{
template
<
class
Traits
,
template
<
class
>
class
IterativeSolver
>
template
<
class
Mat
,
class
Vec
,
template
<
class
>
class
IterativeSolver
>
struct
IterativeSolverCreator
:
public
CreatorInterfaceName
<
LinearSolverInterface
<
Traits
>>
:
public
CreatorInterfaceName
<
LinearSolverInterface
<
Mat
,
Vec
>>
{
template
<
class
Precon
>
using
SolverCreator
=
typename
LinearSolver
<
Traits
,
IterativeRunner
<
IterativeSolver
<
Precon
>
,
Traits
>>::
Creator
;
=
typename
LinearSolver
<
Mat
,
Vec
,
IterativeRunner
<
Mat
,
Vec
,
IterativeSolver
<
Precon
>>>::
Creator
;
using
SolverBase
=
LinearSolverInterface
<
Traits
>
;
using
M
at
=
typename
Traits
::
Mat
;
using
Scalar
=
typename
M
at
::
Scalar
;
using
SolverBase
=
LinearSolverInterface
<
Mat
,
Vec
>
;
using
M
=
typename
Mat
::
BaseMatrix
;
using
Scalar
=
typename
M
::
Scalar
;