Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hyteg
hyteg
Commits
1b84cfb5
Commit
1b84cfb5
authored
Jan 25, 2022
by
Nils Kohl
🌝
Browse files
Merge branch 'kohl/petsc-dynamic-sparse-matrix-allocation' into 'master'
PETSc dynamic sparse matrix allocation See merge request
!476
parents
cad4b9db
83b8b855
Pipeline
#37059
passed with stages
in 147 minutes and 42 seconds
Changes
26
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
apps/annulus.cpp
View file @
1b84cfb5
...
@@ -91,7 +91,7 @@ void solveProblem( std::shared_ptr< hyteg::PrimitiveStorage >& storage, uint_t l
...
@@ -91,7 +91,7 @@ void solveProblem( std::shared_ptr< hyteg::PrimitiveStorage >& storage, uint_t l
uint_t
localDoFs
=
numberOfLocalDoFs
<
enumTag
>
(
*
storage
,
level
);
uint_t
localDoFs
=
numberOfLocalDoFs
<
enumTag
>
(
*
storage
,
level
);
// assemble matrices
// assemble matrices
PETScSparseMatrix
<
opType
>
lapMat
(
localDoFs
,
globalDoFs
);
PETScSparseMatrix
<
opType
>
lapMat
(
"Mat"
);
switch
(
verbosity
)
switch
(
verbosity
)
{
{
...
...
apps/benchmarks/PetscCompare-2D-P2-Apply/PetscCompare-2D-P2-Apply.cpp
View file @
1b84cfb5
...
@@ -106,12 +106,12 @@ int main( int argc, char* argv[] )
...
@@ -106,12 +106,12 @@ int main( int argc, char* argv[] )
};
};
wcTimingTreeApp
.
start
(
"Function allocation"
);
wcTimingTreeApp
.
start
(
"Function allocation"
);
hyteg
::
P2Function
<
double
>
oneFunc
(
"x"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
oneFunc
(
"x"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
x
(
"x"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
x
(
"x"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
y
(
"y"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
y
(
"y"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
z
(
"z"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
z
(
"z"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
diff
(
"diff"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
double
>
diff
(
"diff"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
idx_t
>
numerator
(
"numerator"
,
storage
,
level
,
level
);
hyteg
::
P2Function
<
idx_t
>
numerator
(
"numerator"
,
storage
,
level
,
level
);
wcTimingTreeApp
.
stop
(
"Function allocation"
);
wcTimingTreeApp
.
stop
(
"Function allocation"
);
const
uint_t
totalDoFs
=
numberOfGlobalDoFs
<
hyteg
::
P2FunctionTag
>
(
*
storage
,
level
);
const
uint_t
totalDoFs
=
numberOfGlobalDoFs
<
hyteg
::
P2FunctionTag
>
(
*
storage
,
level
);
...
@@ -126,18 +126,17 @@ int main( int argc, char* argv[] )
...
@@ -126,18 +126,17 @@ int main( int argc, char* argv[] )
wcTimingTreeApp
.
stop
(
"Interpolation"
);
wcTimingTreeApp
.
stop
(
"Interpolation"
);
wcTimingTreeApp
.
start
(
"Enumeration"
);
wcTimingTreeApp
.
start
(
"Enumeration"
);
const
uint_t
globalDoFs
=
hyteg
::
numberOfGlobalDoFs
<
P2FunctionTag
>
(
*
storage
,
level
);
const
uint_t
localDoFs
=
hyteg
::
numberOfLocalDoFs
<
P2FunctionTag
>
(
*
storage
,
level
);
numerator
.
enumerate
(
level
);
numerator
.
enumerate
(
level
);
wcTimingTreeApp
.
stop
(
"Enumeration"
);
wcTimingTreeApp
.
stop
(
"Enumeration"
);
LIKWID_MARKER_START
(
"PETSc-setup"
);
LIKWID_MARKER_START
(
"PETSc-setup"
);
wcTimingTreeApp
.
start
(
"Petsc setup"
);
wcTimingTreeApp
.
start
(
"Petsc setup"
);
hyteg
::
PETScSparseMatrix
<
hyteg
::
P2ConstantLaplaceOperator
>
matPetsc
(
localDoFs
,
globalDoFs
)
;
hyteg
::
PETScSparseMatrix
<
hyteg
::
P2ConstantLaplaceOperator
>
matPetsc
;
matPetsc
.
createMatrixFromOperator
(
mass
,
level
,
numerator
,
hyteg
::
Inner
);
matPetsc
.
createMatrixFromOperator
(
mass
,
level
,
numerator
,
hyteg
::
Inner
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P2Function
>
vecPetsc
(
localDoFs
)
;
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P2Function
>
vecPetsc
;
vecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
vecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P2Function
>
dstvecPetsc
(
localDoFs
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P2Function
>
dstvecPetsc
;
dstvecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
wcTimingTreeApp
.
stop
(
"Petsc setup"
);
wcTimingTreeApp
.
stop
(
"Petsc setup"
);
LIKWID_MARKER_STOP
(
"PETSc-setup"
);
LIKWID_MARKER_STOP
(
"PETSc-setup"
);
...
...
apps/benchmarks/PetscCompare-3D-P1-Apply/PetscCompare-3D-P1-Apply.cpp
View file @
1b84cfb5
...
@@ -105,12 +105,12 @@ int main( int argc, char* argv[] )
...
@@ -105,12 +105,12 @@ int main( int argc, char* argv[] )
};
};
wcTimingTreeApp
.
start
(
"Function allocation"
);
wcTimingTreeApp
.
start
(
"Function allocation"
);
hyteg
::
P1Function
<
double
>
oneFunc
(
"x"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
oneFunc
(
"x"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
x
(
"x"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
x
(
"x"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
y
(
"y"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
y
(
"y"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
z
(
"z"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
z
(
"z"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
diff
(
"diff"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
double
>
diff
(
"diff"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
idx_t
>
numerator
(
"numerator"
,
storage
,
level
,
level
);
hyteg
::
P1Function
<
idx_t
>
numerator
(
"numerator"
,
storage
,
level
,
level
);
wcTimingTreeApp
.
stop
(
"Function allocation"
);
wcTimingTreeApp
.
stop
(
"Function allocation"
);
const
uint_t
totalDoFs
=
numberOfGlobalDoFs
<
hyteg
::
P1FunctionTag
>
(
*
storage
,
level
);
const
uint_t
totalDoFs
=
numberOfGlobalDoFs
<
hyteg
::
P1FunctionTag
>
(
*
storage
,
level
);
...
@@ -125,18 +125,17 @@ int main( int argc, char* argv[] )
...
@@ -125,18 +125,17 @@ int main( int argc, char* argv[] )
wcTimingTreeApp
.
stop
(
"Interpolation"
);
wcTimingTreeApp
.
stop
(
"Interpolation"
);
wcTimingTreeApp
.
start
(
"Enumeration"
);
wcTimingTreeApp
.
start
(
"Enumeration"
);
const
uint_t
globalDoFs
=
hyteg
::
numberOfGlobalDoFs
<
P1FunctionTag
>
(
*
storage
,
level
);
const
uint_t
localDoFs
=
hyteg
::
numberOfLocalDoFs
<
P1FunctionTag
>
(
*
storage
,
level
);
numerator
.
enumerate
(
level
);
numerator
.
enumerate
(
level
);
wcTimingTreeApp
.
stop
(
"Enumeration"
);
wcTimingTreeApp
.
stop
(
"Enumeration"
);
LIKWID_MARKER_START
(
"PETSc-setup"
);
LIKWID_MARKER_START
(
"PETSc-setup"
);
wcTimingTreeApp
.
start
(
"Petsc setup"
);
wcTimingTreeApp
.
start
(
"Petsc setup"
);
hyteg
::
PETScSparseMatrix
<
hyteg
::
P1ConstantLaplaceOperator
>
matPetsc
(
localDoFs
,
globalDoFs
)
;
hyteg
::
PETScSparseMatrix
<
hyteg
::
P1ConstantLaplaceOperator
>
matPetsc
;
matPetsc
.
createMatrixFromOperator
(
mass
,
level
,
numerator
,
hyteg
::
Inner
);
matPetsc
.
createMatrixFromOperator
(
mass
,
level
,
numerator
,
hyteg
::
Inner
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P1Function
>
vecPetsc
(
localDoFs
)
;
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P1Function
>
vecPetsc
;
vecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
vecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P1Function
>
dstvecPetsc
(
localDoFs
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P1Function
>
dstvecPetsc
;
dstvecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
wcTimingTreeApp
.
stop
(
"Petsc setup"
);
wcTimingTreeApp
.
stop
(
"Petsc setup"
);
LIKWID_MARKER_STOP
(
"PETSc-setup"
);
LIKWID_MARKER_STOP
(
"PETSc-setup"
);
...
...
apps/benchmarks/PetscCompare/PetscCompare.cpp
View file @
1b84cfb5
...
@@ -56,12 +56,13 @@ int main( int argc, char* argv[] )
...
@@ -56,12 +56,13 @@ int main( int argc, char* argv[] )
PETScManager
petscManager
(
&
argc
,
&
argv
);
PETScManager
petscManager
(
&
argc
,
&
argv
);
auto
cfg
=
std
::
make_shared
<
walberla
::
config
::
Config
>
();
auto
cfg
=
std
::
make_shared
<
walberla
::
config
::
Config
>
();
if
(
env
.
config
()
==
nullptr
)
if
(
env
.
config
()
==
nullptr
)
{
{
auto
defaultFile
=
"./PetscCompare.prm"
;
auto
defaultFile
=
"./PetscCompare.prm"
;
WALBERLA_LOG_PROGRESS_ON_ROOT
(
"No Parameter file given loading default parameter file: "
<<
defaultFile
);
WALBERLA_LOG_PROGRESS_ON_ROOT
(
"No Parameter file given loading default parameter file: "
<<
defaultFile
);
cfg
->
readParameterFile
(
defaultFile
);
cfg
->
readParameterFile
(
defaultFile
);
}
else
}
else
{
{
cfg
=
env
.
config
();
cfg
=
env
.
config
();
}
}
...
@@ -69,14 +70,15 @@ int main( int argc, char* argv[] )
...
@@ -69,14 +70,15 @@ int main( int argc, char* argv[] )
const
uint_t
level
=
mainConf
.
getParameter
<
uint_t
>
(
"level"
);
const
uint_t
level
=
mainConf
.
getParameter
<
uint_t
>
(
"level"
);
std
::
shared_ptr
<
hyteg
::
MeshInfo
>
meshInfo
;
std
::
shared_ptr
<
hyteg
::
MeshInfo
>
meshInfo
;
if
(
mainConf
.
getParameter
<
bool
>
(
"useMeshFile"
)
)
if
(
mainConf
.
getParameter
<
bool
>
(
"useMeshFile"
)
)
{
{
std
::
string
meshFileName
=
mainConf
.
getParameter
<
std
::
string
>
(
"mesh"
);
std
::
string
meshFileName
=
mainConf
.
getParameter
<
std
::
string
>
(
"mesh"
);
meshInfo
=
std
::
make_shared
<
hyteg
::
MeshInfo
>
(
hyteg
::
MeshInfo
::
fromGmshFile
(
meshFileName
)
);
meshInfo
=
std
::
make_shared
<
hyteg
::
MeshInfo
>
(
hyteg
::
MeshInfo
::
fromGmshFile
(
meshFileName
)
);
}
else
}
else
{
{
uint_t
numberOfFaces
=
mainConf
.
getParameter
<
uint_t
>
(
"numberOfFaces"
);
uint_t
numberOfFaces
=
mainConf
.
getParameter
<
uint_t
>
(
"numberOfFaces"
);
if
(
mainConf
.
getParameter
<
bool
>
(
"facesTimesProcs"
)
)
if
(
mainConf
.
getParameter
<
bool
>
(
"facesTimesProcs"
)
)
{
{
meshInfo
=
std
::
make_shared
<
hyteg
::
MeshInfo
>
(
meshInfo
=
std
::
make_shared
<
hyteg
::
MeshInfo
>
(
hyteg
::
MeshInfo
::
meshFaceChain
(
numberOfFaces
*
uint_c
(
walberla
::
MPIManager
::
instance
()
->
numProcesses
()
)
)
);
hyteg
::
MeshInfo
::
meshFaceChain
(
numberOfFaces
*
uint_c
(
walberla
::
MPIManager
::
instance
()
->
numProcesses
()
)
)
);
...
@@ -84,7 +86,7 @@ int main( int argc, char* argv[] )
...
@@ -84,7 +86,7 @@ int main( int argc, char* argv[] )
}
}
hyteg
::
SetupPrimitiveStorage
setupStorage
(
*
meshInfo
,
hyteg
::
SetupPrimitiveStorage
setupStorage
(
*
meshInfo
,
walberla
::
uint_c
(
walberla
::
mpi
::
MPIManager
::
instance
()
->
numProcesses
()
)
);
walberla
::
uint_c
(
walberla
::
mpi
::
MPIManager
::
instance
()
->
numProcesses
()
)
);
uint_t
numberOfFaces
=
setupStorage
.
getNumberOfFaces
();
uint_t
numberOfFaces
=
setupStorage
.
getNumberOfFaces
();
...
@@ -101,7 +103,7 @@ int main( int argc, char* argv[] )
...
@@ -101,7 +103,7 @@ int main( int argc, char* argv[] )
std
::
shared_ptr
<
hyteg
::
PrimitiveStorage
>
storage
=
std
::
make_shared
<
hyteg
::
PrimitiveStorage
>
(
setupStorage
,
timingTree
);
std
::
shared_ptr
<
hyteg
::
PrimitiveStorage
>
storage
=
std
::
make_shared
<
hyteg
::
PrimitiveStorage
>
(
setupStorage
,
timingTree
);
if
(
mainConf
.
getParameter
<
bool
>
(
"writeDomain"
)
)
if
(
mainConf
.
getParameter
<
bool
>
(
"writeDomain"
)
)
{
{
hyteg
::
writeDomainPartitioningVTK
(
storage
,
"./output"
,
"domain"
);
hyteg
::
writeDomainPartitioningVTK
(
storage
,
"./output"
,
"domain"
);
}
}
...
@@ -162,11 +164,12 @@ int main( int argc, char* argv[] )
...
@@ -162,11 +164,12 @@ int main( int argc, char* argv[] )
numerator
.
enumerate
(
level
);
numerator
.
enumerate
(
level
);
LIKWID_MARKER_START
(
"PETSc-setup"
);
LIKWID_MARKER_START
(
"PETSc-setup"
);
hyteg
::
PETScSparseMatrix
<
hyteg
::
P1ConstantLaplaceOperator
>
matPetsc
(
localDoFs
,
totalDoFs
)
;
hyteg
::
PETScSparseMatrix
<
hyteg
::
P1ConstantLaplaceOperator
>
matPetsc
;
matPetsc
.
createMatrixFromOperator
(
mass
,
level
,
numerator
,
hyteg
::
Inner
);
matPetsc
.
createMatrixFromOperator
(
mass
,
level
,
numerator
,
hyteg
::
Inner
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P1Function
>
vecPetsc
(
localDoFs
)
;
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P1Function
>
vecPetsc
;
vecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
vecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P1Function
>
dstvecPetsc
(
localDoFs
);
hyteg
::
PETScVector
<
real_t
,
hyteg
::
P1Function
>
dstvecPetsc
;
dstvecPetsc
.
createVectorFromFunction
(
x
,
numerator
,
level
,
hyteg
::
Inner
);
LIKWID_MARKER_STOP
(
"PETSc-setup"
);
LIKWID_MARKER_STOP
(
"PETSc-setup"
);
walberla
::
WcTimer
timer
;
walberla
::
WcTimer
timer
;
...
@@ -196,12 +199,12 @@ int main( int argc, char* argv[] )
...
@@ -196,12 +199,12 @@ int main( int argc, char* argv[] )
//dstvecPetsc.print("../output/vector1.vec");
//dstvecPetsc.print("../output/vector1.vec");
diff
.
assign
(
{
1.0
,
-
1.0
},
{
z
,
y
},
level
,
hyteg
::
All
);
diff
.
assign
(
{
1.0
,
-
1.0
},
{
z
,
y
},
level
,
hyteg
::
All
);
if
(
mainConf
.
getParameter
<
bool
>
(
"VTKOutput"
)
)
if
(
mainConf
.
getParameter
<
bool
>
(
"VTKOutput"
)
)
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
"writing VTK output"
);
WALBERLA_LOG_INFO_ON_ROOT
(
"writing VTK output"
);
hyteg
::
VTKOutput
vtkOutput
(
"./output"
,
"petscCompare"
,
storage
);
hyteg
::
VTKOutput
vtkOutput
(
"./output"
,
"petscCompare"
,
storage
);
vtkOutput
.
add
(
x
);
vtkOutput
.
add
(
x
);
vtkOutput
.
add
(
z
);
vtkOutput
.
add
(
z
);
vtkOutput
.
add
(
y
);
vtkOutput
.
add
(
y
);
...
@@ -212,12 +215,12 @@ int main( int argc, char* argv[] )
...
@@ -212,12 +215,12 @@ int main( int argc, char* argv[] )
walberla
::
WcTimingTree
tt
=
timingTree
->
getReduced
();
walberla
::
WcTimingTree
tt
=
timingTree
->
getReduced
();
auto
tt2
=
tt
.
getCopyWithRemainder
();
auto
tt2
=
tt
.
getCopyWithRemainder
();
if
(
mainConf
.
getParameter
<
bool
>
(
"printTiming"
)
)
if
(
mainConf
.
getParameter
<
bool
>
(
"printTiming"
)
)
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
tt2
);
WALBERLA_LOG_INFO_ON_ROOT
(
tt2
);
}
}
if
(
mainConf
.
getParameter
<
bool
>
(
"writeJSON"
)
)
if
(
mainConf
.
getParameter
<
bool
>
(
"writeJSON"
)
)
{
{
nlohmann
::
json
ttjson
=
nlohmann
::
json
(
tt2
);
nlohmann
::
json
ttjson
=
nlohmann
::
json
(
tt2
);
std
::
ofstream
o
(
"PetscCompareOutput.json"
);
std
::
ofstream
o
(
"PetscCompareOutput.json"
);
...
...
src/hyteg/petsc/PETScBlockPreconditionedStokesSolver.hpp
View file @
1b84cfb5
/*
* Copyright (c) 2017-2022 Nils Kohl.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#pragma once
#include <memory>
#include <memory>
...
@@ -39,21 +58,12 @@ class PETScBlockPreconditionedStokesSolver : public Solver< OperatorType >
...
@@ -39,21 +58,12 @@ class PETScBlockPreconditionedStokesSolver : public Solver< OperatorType >
:
allocatedLevel_
(
level
)
:
allocatedLevel_
(
level
)
,
petscCommunicator_
(
storage
->
getSplitCommunicatorByPrimitiveDistribution
()
)
,
petscCommunicator_
(
storage
->
getSplitCommunicatorByPrimitiveDistribution
()
)
,
num
(
"numerator"
,
storage
,
level
,
level
)
,
num
(
"numerator"
,
storage
,
level
,
level
)
,
Amat
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
,
Amat
(
"Amat"
,
petscCommunicator_
)
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
,
AmatNonEliminatedBC
(
"AmatNonEliminatedBC"
,
petscCommunicator_
)
"Amat"
,
,
Pmat
(
"Pmat"
,
petscCommunicator_
)
petscCommunicator_
)
,
xVec
(
"xVec"
,
petscCommunicator_
)
,
AmatNonEliminatedBC
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
,
bVec
(
"bVec"
,
petscCommunicator_
)
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
,
nullspaceVec_
(
"nullspaceVec"
,
petscCommunicator_
)
"AmatNonEliminatedBC"
,
petscCommunicator_
)
,
Pmat
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
"Pmat"
,
petscCommunicator_
)
,
xVec
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"xVec"
,
petscCommunicator_
)
,
bVec
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"bVec"
,
petscCommunicator_
)
,
nullspaceVec_
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"nullspaceVec"
,
petscCommunicator_
)
,
storage_
(
storage
)
,
storage_
(
storage
)
,
tolerance_
(
tolerance
)
,
tolerance_
(
tolerance
)
,
maxIterations_
(
maxIterations
)
,
maxIterations_
(
maxIterations
)
...
@@ -208,8 +218,7 @@ class PETScBlockPreconditionedStokesSolver : public Solver< OperatorType >
...
@@ -208,8 +218,7 @@ class PETScBlockPreconditionedStokesSolver : public Solver< OperatorType >
case
1
:
case
1
:
PCSetType
(
pc_u
,
PCJACOBI
);
PCSetType
(
pc_u
,
PCJACOBI
);
break
;
break
;
case
3
:
case
3
:
{
{
PCSetType
(
pc_u
,
PCHYPRE
);
PCSetType
(
pc_u
,
PCHYPRE
);
break
;
break
;
}
}
...
...
src/hyteg/petsc/PETScCGSolver.hpp
View file @
1b84cfb5
/*
/*
* Copyright (c) 2017-20
19
Dominik Thoennes, Nils Kohl.
* Copyright (c) 2017-20
22
Dominik Thoennes, Nils Kohl.
*
*
* This file is part of HyTeG
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
* (see https://i10git.cs.fau.de/hyteg/hyteg).
...
@@ -44,17 +44,11 @@ class PETScCGSolver : public Solver< OperatorType >
...
@@ -44,17 +44,11 @@ class PETScCGSolver : public Solver< OperatorType >
:
allocatedLevel_
(
level
)
:
allocatedLevel_
(
level
)
,
petscCommunicator_
(
storage
->
getSplitCommunicatorByPrimitiveDistribution
()
)
,
petscCommunicator_
(
storage
->
getSplitCommunicatorByPrimitiveDistribution
()
)
,
num
(
"numerator"
,
storage
,
level
,
level
)
,
num
(
"numerator"
,
storage
,
level
,
level
)
,
Amat
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
,
Amat
(
"Amat"
,
petscCommunicator_
)
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
,
AmatNonEliminatedBC
(
"AmatNonEliminatedBC"
,
petscCommunicator_
)
"Amat"
,
,
xVec
(
"xVec"
,
petscCommunicator_
)
petscCommunicator_
)
,
bVec
(
"bVec"
,
petscCommunicator_
)
,
AmatNonEliminatedBC
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
,
nullspaceVec_
(
"nullspaceVec"
,
petscCommunicator_
)
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
"AmatNonEliminatedBC"
,
petscCommunicator_
)
,
xVec
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"xVec"
,
petscCommunicator_
)
,
bVec
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"bVec"
,
petscCommunicator_
)
,
nullspaceVec_
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"nullspaceVec"
,
petscCommunicator_
)
,
flag_
(
hyteg
::
All
)
,
flag_
(
hyteg
::
All
)
,
nullSpaceSet_
(
false
)
,
nullSpaceSet_
(
false
)
,
reassembleMatrix_
(
false
)
,
reassembleMatrix_
(
false
)
...
...
src/hyteg/petsc/PETScExportLinearSystem.hpp
View file @
1b84cfb5
/*
/*
* Copyright (c) 2017-20
19
Nils Kohl, Dominik Thoennes, Marcus Mohr.
* Copyright (c) 2017-20
22
Nils Kohl, Dominik Thoennes, Marcus Mohr.
*
*
* This file is part of HyTeG
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
* (see https://i10git.cs.fau.de/hyteg/hyteg).
...
@@ -92,7 +92,7 @@ void exportLinearSystem( OperatorType op,
...
@@ -92,7 +92,7 @@ void exportLinearSystem( OperatorType op,
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
" * Converting Operator to PETSc matrix"
);
WALBERLA_LOG_INFO_ON_ROOT
(
" * Converting Operator to PETSc matrix"
);
}
}
PETScSparseMatrix
<
OperatorType
>
petscMatrix
(
localDoFs
,
globalDoFs
,
nameMatrix
.
c_str
()
);
PETScSparseMatrix
<
OperatorType
>
petscMatrix
(
nameMatrix
.
c_str
()
);
FunctionType
<
idx_t
>
numerator
(
"numerator"
,
storage
,
level
,
level
);
FunctionType
<
idx_t
>
numerator
(
"numerator"
,
storage
,
level
,
level
);
numerator
.
enumerate
(
level
);
numerator
.
enumerate
(
level
);
petscMatrix
.
createMatrixFromOperator
(
op
,
level
,
numerator
);
petscMatrix
.
createMatrixFromOperator
(
op
,
level
,
numerator
);
...
...
src/hyteg/petsc/PETScExportOperatorMatrix.hpp
View file @
1b84cfb5
...
@@ -115,7 +115,7 @@ void exportOperator( OperatorType& op,
...
@@ -115,7 +115,7 @@ void exportOperator( OperatorType& op,
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
" * Converting Operator to PETSc matrix"
)
WALBERLA_LOG_INFO_ON_ROOT
(
" * Converting Operator to PETSc matrix"
)
}
}
PETScSparseMatrix
<
OperatorType
>
petscMatrix
(
localDoFs
,
globalDoFs
,
matrixName
.
c_str
()
);
PETScSparseMatrix
<
OperatorType
>
petscMatrix
(
matrixName
.
c_str
()
);
typename
OperatorType
::
srcType
::
template
FunctionType
<
idx_t
>
numerator
(
"numerator"
,
storage
,
level
,
level
);
typename
OperatorType
::
srcType
::
template
FunctionType
<
idx_t
>
numerator
(
"numerator"
,
storage
,
level
,
level
);
numerator
.
enumerate
(
level
);
numerator
.
enumerate
(
level
);
petscMatrix
.
createMatrixFromOperator
(
op
,
level
,
numerator
);
petscMatrix
.
createMatrixFromOperator
(
op
,
level
,
numerator
);
...
...
src/hyteg/petsc/PETScLUSolver.hpp
View file @
1b84cfb5
/*
/*
* Copyright (c) 2017-20
19
Boerge Struempfel, Daniel Drzisga, Dominik Thoennes, Nils Kohl.
* Copyright (c) 2017-20
22
Boerge Struempfel, Daniel Drzisga, Dominik Thoennes, Nils Kohl.
*
*
* This file is part of HyTeG
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
* (see https://i10git.cs.fau.de/hyteg/hyteg).
...
@@ -53,20 +53,11 @@ class PETScLUSolver : public Solver< OperatorType >
...
@@ -53,20 +53,11 @@ class PETScLUSolver : public Solver< OperatorType >
,
allocatedLevel_
(
level
)
,
allocatedLevel_
(
level
)
,
petscCommunicator_
(
storage
->
getSplitCommunicatorByPrimitiveDistribution
()
)
,
petscCommunicator_
(
storage
->
getSplitCommunicatorByPrimitiveDistribution
()
)
,
num
(
"numerator"
,
storage
,
level
,
level
)
,
num
(
"numerator"
,
storage
,
level
,
level
)
,
Amat
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
,
Amat
(
"Amat"
,
petscCommunicator_
)
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
,
AmatUnsymmetric
(
"AmatUnsymmetric"
,
petscCommunicator_
)
"Amat"
,
,
AmatTmp
(
"AmatTmp"
,
petscCommunicator_
)
petscCommunicator_
)
,
xVec
(
"xVec"
,
petscCommunicator_
)
,
AmatUnsymmetric
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
,
bVec
(
"bVec"
,
petscCommunicator_
)
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
"AmatUnsymmetric"
,
petscCommunicator_
)
,
AmatTmp
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
"AmatTmp"
,
petscCommunicator_
)
,
xVec
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"xVec"
,
petscCommunicator_
)
,
bVec
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"bVec"
,
petscCommunicator_
)
#if 0
#if 0
, inKernel( numberOfLocalDoFs< typename FunctionType::Tag >( *storage, level ) )
, inKernel( numberOfLocalDoFs< typename FunctionType::Tag >( *storage, level ) )
#endif
#endif
...
@@ -231,8 +222,9 @@ class PETScLUSolver : public Solver< OperatorType >
...
@@ -231,8 +222,9 @@ class PETScLUSolver : public Solver< OperatorType >
storage_
->
getTimingTree
()
->
start
(
"RHS vector setup"
);
storage_
->
getTimingTree
()
->
start
(
"RHS vector setup"
);
b
.
assign
(
{
1.0
},
{
x
},
level
,
DirichletBoundary
);
b
.
assign
(
{
1.0
},
{
x
},
level
,
DirichletBoundary
);
bVec
.
createVectorFromFunction
(
b
,
num
,
level
,
All
);
bVec
.
createVectorFromFunction
(
b
,
num
,
level
,
All
);
xVec
.
createVectorFromFunction
(
x
,
num
,
level
,
All
);
if
(
assumeSymmetry_
)
if
(
assumeSymmetry_
)
{
{
...
...
src/hyteg/petsc/PETScMinResSolver.hpp
View file @
1b84cfb5
/*
/*
* Copyright (c) 2017-20
19
Dominik Thoennes, Nils Kohl.
* Copyright (c) 2017-20
22
Dominik Thoennes, Nils Kohl.
*
*
* This file is part of HyTeG
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
* (see https://i10git.cs.fau.de/hyteg/hyteg).
...
@@ -44,17 +44,11 @@ class PETScMinResSolver : public Solver< OperatorType >
...
@@ -44,17 +44,11 @@ class PETScMinResSolver : public Solver< OperatorType >
:
allocatedLevel_
(
level
)
:
allocatedLevel_
(
level
)
,
petscCommunicator_
(
storage
->
getSplitCommunicatorByPrimitiveDistribution
()
)
,
petscCommunicator_
(
storage
->
getSplitCommunicatorByPrimitiveDistribution
()
)
,
num
(
"numerator"
,
storage
,
level
,
level
)
,
num
(
"numerator"
,
storage
,
level
,
level
)
,
Amat
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
,
Amat
(
"Amat"
,
petscCommunicator_
)
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
,
AmatNonEliminatedBC
(
"AmatNonEliminatedBC"
,
petscCommunicator_
)
"Amat"
,
,
xVec
(
"xVec"
,
petscCommunicator_
)
petscCommunicator_
)
,
bVec
(
"bVec"
,
petscCommunicator_
)
,
AmatNonEliminatedBC
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
,
nullspaceVec_
(
"nullspaceVec"
,
petscCommunicator_
)
numberOfGlobalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
,
petscCommunicator_
),
"AmatNonEliminatedBC"
,
petscCommunicator_
)
,
xVec
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"xVec"
,
petscCommunicator_
)
,
bVec
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"bVec"
,
petscCommunicator_
)
,
nullspaceVec_
(
numberOfLocalDoFs
<
typename
FunctionType
::
Tag
>
(
*
storage
,
level
),
"nullspaceVec"
,
petscCommunicator_
)
,
flag_
(
hyteg
::
All
)
,
flag_
(
hyteg
::
All
)
,
nullSpaceSet_
(
false
)
,
nullSpaceSet_
(
false
)
,
reassembleMatrix_
(
false
)
,
reassembleMatrix_
(
false
)
...
...
src/hyteg/petsc/PETScSparseMatrix.hpp
View file @
1b84cfb5
/*
/*
* Copyright (c) 2017-20
19
Boerge Struempfel, Daniel Drzisga, Dominik Thoennes, Marcus Mohr, Nils Kohl.
* Copyright (c) 2017-20
22
Boerge Struempfel, Daniel Drzisga, Dominik Thoennes, Marcus Mohr, Nils Kohl.
*
*
* This file is part of HyTeG
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
* (see https://i10git.cs.fau.de/hyteg/hyteg).
...
@@ -51,78 +51,34 @@ class PETScSparseMatrix
...
@@ -51,78 +51,34 @@ class PETScSparseMatrix
template
<
typename
ValueType
>
template
<
typename
ValueType
>
using
FunctionTypeDst
=
typename
OperatorType
::
dstType
::
template
FunctionType
<
ValueType
>;
using
FunctionTypeDst
=
typename
OperatorType
::
dstType
::
template
FunctionType
<
ValueType
>;
PETScSparseMatrix
()
=
delete
;
PETScSparseMatrix
(
const
std
::
string
name
=
"Mat"
,
const
MPI_Comm
&
petscCommunicator
=
walberla
::
mpi
::
MPIManager
::
instance
()
->
comm
()
)
PETScSparseMatrix
(
uint_t
localRows
,
:
name_
(
name
)
uint_t
localCols
,
,
petscCommunicator_
(
petscCommunicator
)
uint_t
globalRows
,
,
allocated_
(
false
)
uint_t
globalCols
,
const
char
name
[]
=
"Mat"
,
const
MPI_Comm
&
petscCommunicator
=
walberla
::
mpi
::
MPIManager
::
instance
()
->
comm
()
)
:
petscCommunicator_
(
petscCommunicator
)
,
assembled_
(
false
)
,
assembled_
(
false
)
{
MatCreate
(
petscCommunicator
,
&
mat
);
MatSetType
(
mat
,
MATMPIAIJ
);
MatSetSizes
(
mat
,
static_cast
<
PetscInt
>
(
localRows
),
static_cast
<
PetscInt
>
(
localCols
),
static_cast
<
PetscInt
>
(
globalRows
),
static_cast
<
PetscInt
>
(
globalCols
)
);
// Roughly overestimate number of non-zero entries for faster assembly of matrix
MatMPIAIJSetPreallocation
(
mat
,
500
,
NULL
,
500
,
NULL
);
setName
(
name
);
reset
();
}
PETScSparseMatrix
(
uint_t
localSize
,
uint_t
globalSize
,
const
char
name
[]
=
"Mat"
,
const
MPI_Comm
&
petscCommunicator
=
walberla
::
mpi
::
MPIManager
::
instance
()
->
comm
()
)
:
PETScSparseMatrix
(
localSize
,
localSize
,
globalSize
,
globalSize
,
name
,
petscCommunicator
)
{}
{}
PETScSparseMatrix
(
const
std
::
shared_ptr
<
PrimitiveStorage
>&
storage
,
virtual
~
PETScSparseMatrix
()
const
uint_t
&
level
,
{