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
2ba79464
Commit
2ba79464
authored
Sep 27, 2021
by
Dominik Thoennes
Browse files
refactor remaining PetscInts
parent
002d134b
Pipeline
#34425
failed with stages
in 38 minutes and 40 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/hyteg/composites/petsc/P1StokesPetsc.hpp
View file @
2ba79464
...
@@ -61,7 +61,7 @@ inline void createFunctionFromVector( const P1StokesFunction< PetscReal >& func
...
@@ -61,7 +61,7 @@ inline void createFunctionFromVector( const P1StokesFunction< PetscReal >& func
createFunctionFromVector
(
function
.
p
,
numerator
.
p
,
vec
,
level
,
flag
);
createFunctionFromVector
(
function
.
p
,
numerator
.
p
,
vec
,
level
,
flag
);
}
}
inline
void
applyDirichletBC
(
const
P1StokesFunction
<
idx_t
>&
numerator
,
std
::
vector
<
PetscIn
t
>&
mat
,
uint_t
level
)
inline
void
applyDirichletBC
(
const
P1StokesFunction
<
idx_t
>&
numerator
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
)
{
{
applyDirichletBC
(
numerator
.
uvw
[
0
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
0
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
1
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
1
],
mat
,
level
);
...
...
src/hyteg/composites/petsc/P2P1TaylorHoodPetsc.hpp
View file @
2ba79464
...
@@ -62,7 +62,7 @@ inline void createFunctionFromVector( const P2P1TaylorHoodFunction< PetscReal >&
...
@@ -62,7 +62,7 @@ inline void createFunctionFromVector( const P2P1TaylorHoodFunction< PetscReal >&
createFunctionFromVector
(
function
.
p
,
numerator
.
p
,
vec
,
level
,
flag
);
createFunctionFromVector
(
function
.
p
,
numerator
.
p
,
vec
,
level
,
flag
);
}
}
inline
void
applyDirichletBC
(
const
P2P1TaylorHoodFunction
<
idx_t
>&
numerator
,
std
::
vector
<
PetscIn
t
>&
mat
,
uint_t
level
)
inline
void
applyDirichletBC
(
const
P2P1TaylorHoodFunction
<
idx_t
>&
numerator
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
)
{
{
applyDirichletBC
(
numerator
.
uvw
[
0
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
0
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
1
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
1
],
mat
,
level
);
...
...
src/hyteg/composites/petsc/P2P2StabilizedStokesPetsc.hpp
View file @
2ba79464
...
@@ -57,7 +57,7 @@ inline void createFunctionFromVector( const P2P2StokesFunction< PetscReal >& fun
...
@@ -57,7 +57,7 @@ inline void createFunctionFromVector( const P2P2StokesFunction< PetscReal >& fun
createFunctionFromVector
(
function
.
p
,
numerator
.
p
,
vec
,
level
,
flag
);
createFunctionFromVector
(
function
.
p
,
numerator
.
p
,
vec
,
level
,
flag
);
}
}
inline
void
applyDirichletBC
(
const
P2P2StokesFunction
<
idx_t
>&
numerator
,
std
::
vector
<
PetscIn
t
>&
mat
,
uint_t
level
)
inline
void
applyDirichletBC
(
const
P2P2StokesFunction
<
idx_t
>&
numerator
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
)
{
{
applyDirichletBC
(
numerator
.
uvw
[
0
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
0
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
1
],
mat
,
level
);
applyDirichletBC
(
numerator
.
uvw
[
1
],
mat
,
level
);
...
...
src/hyteg/edgedofspace/EdgeDoFMacroEdge.hpp
View file @
2ba79464
...
@@ -613,7 +613,7 @@ inline void createFunctionFromVector( const uint_t&
...
@@ -613,7 +613,7 @@ inline void createFunctionFromVector( const uint_t&
inline
void
applyDirichletBC
(
const
uint_t
&
Level
,
inline
void
applyDirichletBC
(
const
uint_t
&
Level
,
Edge
&
edge
,
Edge
&
edge
,
std
::
vector
<
PetscIn
t
>&
mat
,
std
::
vector
<
idx_
t
>&
mat
,
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Edge
>&
numeratorId
)
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Edge
>&
numeratorId
)
{
{
auto
numerator
=
edge
.
getData
(
numeratorId
)
->
getPointer
(
Level
);
auto
numerator
=
edge
.
getData
(
numeratorId
)
->
getPointer
(
Level
);
...
@@ -621,7 +621,7 @@ inline void applyDirichletBC( const uint_t&
...
@@ -621,7 +621,7 @@ inline void applyDirichletBC( const uint_t&
for
(
const
auto
&
it
:
edgedof
::
macroedge
::
Iterator
(
Level
)
)
for
(
const
auto
&
it
:
edgedof
::
macroedge
::
Iterator
(
Level
)
)
{
{
const
uint_t
idx
=
edgedof
::
macroedge
::
indexFromHorizontalEdge
(
Level
,
it
.
col
(),
stencilDirection
::
EDGE_HO_C
);
const
uint_t
idx
=
edgedof
::
macroedge
::
indexFromHorizontalEdge
(
Level
,
it
.
col
(),
stencilDirection
::
EDGE_HO_C
);
mat
.
push_back
(
static_cast
<
PetscIn
t
>
(
numerator
[
idx
]
)
);
mat
.
push_back
(
static_cast
<
idx_
t
>
(
numerator
[
idx
]
)
);
}
}
}
}
#endif
#endif
...
...
src/hyteg/edgedofspace/EdgeDoFMacroFace.hpp
View file @
2ba79464
...
@@ -1084,7 +1084,7 @@ inline void createFunctionFromVector( const uint_t&
...
@@ -1084,7 +1084,7 @@ inline void createFunctionFromVector( const uint_t&
inline
void
applyDirichletBC
(
const
uint_t
&
Level
,
inline
void
applyDirichletBC
(
const
uint_t
&
Level
,
Face
&
face
,
Face
&
face
,
std
::
vector
<
PetscIn
t
>&
mat
,
std
::
vector
<
idx_
t
>&
mat
,
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Face
>&
numeratorId
)
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Face
>&
numeratorId
)
{
{
auto
numerator
=
face
.
getData
(
numeratorId
)
->
getPointer
(
Level
);
auto
numerator
=
face
.
getData
(
numeratorId
)
->
getPointer
(
Level
);
...
@@ -1095,21 +1095,21 @@ inline void applyDirichletBC( const uint_t&
...
@@ -1095,21 +1095,21 @@ inline void applyDirichletBC( const uint_t&
if
(
it
.
row
()
!=
0
)
if
(
it
.
row
()
!=
0
)
{
{
const
uint_t
idx
=
edgedof
::
macroface
::
horizontalIndex
(
Level
,
it
.
col
(),
it
.
row
()
);
const
uint_t
idx
=
edgedof
::
macroface
::
horizontalIndex
(
Level
,
it
.
col
(),
it
.
row
()
);
mat
.
push_back
(
static_cast
<
PetscInt
>
(
numerator
[
idx
]
)
);
mat
.
push_back
(
numerator
[
idx
]
);
}
}
// Do not read vertical DoFs at left border
// Do not read vertical DoFs at left border
if
(
it
.
col
()
!=
0
)
if
(
it
.
col
()
!=
0
)
{
{
const
uint_t
idx
=
edgedof
::
macroface
::
verticalIndex
(
Level
,
it
.
col
(),
it
.
row
()
);
const
uint_t
idx
=
edgedof
::
macroface
::
verticalIndex
(
Level
,
it
.
col
(),
it
.
row
()
);
mat
.
push_back
(
static_cast
<
PetscInt
>
(
numerator
[
idx
]
)
);
mat
.
push_back
(
numerator
[
idx
]
);
}
}
// Do not read diagonal DoFs at diagonal border
// Do not read diagonal DoFs at diagonal border
if
(
it
.
col
()
+
it
.
row
()
!=
(
hyteg
::
levelinfo
::
num_microedges_per_edge
(
Level
)
-
1
)
)
if
(
it
.
col
()
+
it
.
row
()
!=
(
hyteg
::
levelinfo
::
num_microedges_per_edge
(
Level
)
-
1
)
)
{
{
const
uint_t
idx
=
edgedof
::
macroface
::
diagonalIndex
(
Level
,
it
.
col
(),
it
.
row
()
);
const
uint_t
idx
=
edgedof
::
macroface
::
diagonalIndex
(
Level
,
it
.
col
(),
it
.
row
()
);
mat
.
push_back
(
static_cast
<
PetscInt
>
(
numerator
[
idx
]
)
);
mat
.
push_back
(
numerator
[
idx
]
);
}
}
}
}
}
}
...
...
src/hyteg/edgedofspace/EdgeDoFPetsc.hpp
View file @
2ba79464
...
@@ -601,7 +601,7 @@ inline void createFunctionFromVector( const EdgeDoFFunction< PetscReal >& func
...
@@ -601,7 +601,7 @@ inline void createFunctionFromVector( const EdgeDoFFunction< PetscReal >& func
}
}
}
}
inline
void
applyDirichletBC
(
const
EdgeDoFFunction
<
idx_t
>&
numerator
,
std
::
vector
<
PetscIn
t
>&
mat
,
uint_t
level
)
inline
void
applyDirichletBC
(
const
EdgeDoFFunction
<
idx_t
>&
numerator
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
)
{
{
for
(
auto
&
it
:
numerator
.
getStorage
()
->
getEdges
()
)
for
(
auto
&
it
:
numerator
.
getStorage
()
->
getEdges
()
)
{
{
...
...
src/hyteg/p1functionspace/P1Petsc.hpp
View file @
2ba79464
...
@@ -156,7 +156,7 @@ inline void createFunctionFromVector( const P1Function< PetscReal >& func
...
@@ -156,7 +156,7 @@ inline void createFunctionFromVector( const P1Function< PetscReal >& func
}
}
}
}
inline
void
applyDirichletBC
(
const
P1Function
<
idx_t
>&
numerator
,
std
::
vector
<
PetscIn
t
>&
mat
,
uint_t
level
)
inline
void
applyDirichletBC
(
const
P1Function
<
idx_t
>&
numerator
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
)
{
{
for
(
auto
&
it
:
numerator
.
getStorage
()
->
getVertices
()
)
for
(
auto
&
it
:
numerator
.
getStorage
()
->
getVertices
()
)
{
{
...
@@ -219,7 +219,7 @@ inline void createFunctionFromVector( const P1VectorFunction< PetscReal >& func
...
@@ -219,7 +219,7 @@ inline void createFunctionFromVector( const P1VectorFunction< PetscReal >& func
}
}
}
}
inline
void
applyDirichletBC
(
const
P1VectorFunction
<
idx_t
>&
numerator
,
std
::
vector
<
PetscIn
t
>&
mat
,
uint_t
level
)
inline
void
applyDirichletBC
(
const
P1VectorFunction
<
idx_t
>&
numerator
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
)
{
{
for
(
uint_t
k
=
0
;
k
<
numerator
.
getDimension
();
k
++
)
for
(
uint_t
k
=
0
;
k
<
numerator
.
getDimension
();
k
++
)
{
{
...
...
src/hyteg/p1functionspace/VertexDoFMacroEdge.hpp
View file @
2ba79464
...
@@ -809,14 +809,14 @@ inline void createFunctionFromVector( const uint_t&
...
@@ -809,14 +809,14 @@ inline void createFunctionFromVector( const uint_t&
inline
void
applyDirichletBC
(
const
uint_t
&
level
,
inline
void
applyDirichletBC
(
const
uint_t
&
level
,
Edge
&
edge
,
Edge
&
edge
,
std
::
vector
<
PetscIn
t
>&
mat
,
std
::
vector
<
idx_
t
>&
mat
,
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Edge
>&
numeratorId
)
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Edge
>&
numeratorId
)
{
{
size_t
rowsize
=
levelinfo
::
num_microvertices_per_edge
(
level
);
size_t
rowsize
=
levelinfo
::
num_microvertices_per_edge
(
level
);
for
(
uint_t
i
=
1
;
i
<
rowsize
-
1
;
i
++
)
for
(
uint_t
i
=
1
;
i
<
rowsize
-
1
;
i
++
)
{
{
mat
.
push_back
(
static_cast
<
PetscInt
>
(
edge
.
getData
(
numeratorId
)
->
getPointer
(
level
)[
i
]
)
);
mat
.
push_back
(
edge
.
getData
(
numeratorId
)
->
getPointer
(
level
)[
i
]
);
}
}
}
}
#endif
#endif
...
...
src/hyteg/p1functionspace/VertexDoFMacroFace.hpp
View file @
2ba79464
...
@@ -1263,13 +1263,12 @@ inline void createFunctionFromVector( const uint_t&
...
@@ -1263,13 +1263,12 @@ inline void createFunctionFromVector( const uint_t&
inline
void
applyDirichletBC
(
const
uint_t
&
level
,
inline
void
applyDirichletBC
(
const
uint_t
&
level
,
Face
&
face
,
Face
&
face
,
std
::
vector
<
PetscIn
t
>&
mat
,
std
::
vector
<
idx_
t
>&
mat
,
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Face
>&
numeratorId
)
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Face
>&
numeratorId
)
{
{
for
(
const
auto
&
it
:
vertexdof
::
macroface
::
Iterator
(
level
,
1
)
)
for
(
const
auto
&
it
:
vertexdof
::
macroface
::
Iterator
(
level
,
1
)
)
{
{
mat
.
push_back
(
static_cast
<
PetscInt
>
(
mat
.
push_back
(
face
.
getData
(
numeratorId
)
->
getPointer
(
level
)[
vertexdof
::
macroface
::
index
(
level
,
it
.
x
(),
it
.
y
()
)]
);
face
.
getData
(
numeratorId
)
->
getPointer
(
level
)[
vertexdof
::
macroface
::
index
(
level
,
it
.
x
(),
it
.
y
()
)]
)
);
}
}
}
}
...
...
src/hyteg/p1functionspace/VertexDoFMacroVertex.hpp
View file @
2ba79464
...
@@ -395,11 +395,11 @@ inline void createFunctionFromVector( Vertex&
...
@@ -395,11 +395,11 @@ inline void createFunctionFromVector( Vertex&
}
}
inline
void
applyDirichletBC
(
Vertex
&
vertex
,
inline
void
applyDirichletBC
(
Vertex
&
vertex
,
std
::
vector
<
PetscIn
t
>&
mat
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
,
uint_t
level
,
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Vertex
>&
numeratorId
)
const
PrimitiveDataID
<
FunctionMemory
<
idx_t
>
,
Vertex
>&
numeratorId
)
{
{
mat
.
push_back
(
static_cast
<
PetscInt
>
(
vertex
.
getData
(
numeratorId
)
->
getPointer
(
level
)[
0
]
)
);
mat
.
push_back
(
vertex
.
getData
(
numeratorId
)
->
getPointer
(
level
)[
0
]
);
}
}
#endif
#endif
...
...
src/hyteg/p2functionspace/P2Petsc.hpp
View file @
2ba79464
...
@@ -56,7 +56,7 @@ inline void createFunctionFromVector( const P2Function< PetscReal >& func
...
@@ -56,7 +56,7 @@ inline void createFunctionFromVector( const P2Function< PetscReal >& func
createFunctionFromVector
(
function
.
getEdgeDoFFunction
(),
numerator
.
getEdgeDoFFunction
(),
vec
,
level
,
flag
);
createFunctionFromVector
(
function
.
getEdgeDoFFunction
(),
numerator
.
getEdgeDoFFunction
(),
vec
,
level
,
flag
);
}
}
inline
void
applyDirichletBC
(
const
P2Function
<
idx_t
>&
numerator
,
std
::
vector
<
PetscIn
t
>&
mat
,
uint_t
level
)
inline
void
applyDirichletBC
(
const
P2Function
<
idx_t
>&
numerator
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
)
{
{
applyDirichletBC
(
numerator
.
getVertexDoFFunction
(),
mat
,
level
);
applyDirichletBC
(
numerator
.
getVertexDoFFunction
(),
mat
,
level
);
applyDirichletBC
(
numerator
.
getEdgeDoFFunction
(),
mat
,
level
);
applyDirichletBC
(
numerator
.
getEdgeDoFFunction
(),
mat
,
level
);
...
@@ -89,7 +89,7 @@ inline void createFunctionFromVector( const P2VectorFunction< PetscReal >& func
...
@@ -89,7 +89,7 @@ inline void createFunctionFromVector( const P2VectorFunction< PetscReal >& func
}
}
}
}
inline
void
applyDirichletBC
(
const
P2VectorFunction
<
idx_t
>&
numerator
,
std
::
vector
<
PetscIn
t
>&
mat
,
uint_t
level
)
inline
void
applyDirichletBC
(
const
P2VectorFunction
<
idx_t
>&
numerator
,
std
::
vector
<
idx_
t
>&
mat
,
uint_t
level
)
{
{
for
(
uint_t
k
=
0
;
k
<
numerator
.
getDimension
();
k
++
)
for
(
uint_t
k
=
0
;
k
<
numerator
.
getDimension
();
k
++
)
{
{
...
...
src/hyteg/petsc/PETScExportOperatorMatrix.hpp
View file @
2ba79464
...
@@ -30,12 +30,13 @@
...
@@ -30,12 +30,13 @@
#ifdef HYTEG_BUILD_WITH_PETSC
#ifdef HYTEG_BUILD_WITH_PETSC
namespace
hyteg
{
namespace
hyteg
::
petsc
{
namespace
petsc
{
/// \brief Auxilliary routine for pimping PETSC_VIEWER_ASCII_MATLAB file
/// \brief Auxilliary routine for pimping PETSC_VIEWER_ASCII_MATLAB file
void
pimpMatlabFile
(
std
::
string
fName
,
std
::
string
matrixName
,
bool
elimDirichletBC
,
std
::
vector
<
PetscInt
>&
indices
)
void
pimpMatlabFile
(
const
std
::
string
&
fName
,
const
std
::
string
&
matrixName
,
bool
elimDirichletBC
,
std
::
vector
<
idx_t
>&
indices
)
{
{
// Make Matlab be a little talkative
// Make Matlab be a little talkative
std
::
ofstream
ofs
;
std
::
ofstream
ofs
;
...
@@ -81,7 +82,7 @@ void pimpMatlabFile( std::string fName, std::string matrixName, bool elimDirichl
...
@@ -81,7 +82,7 @@ void pimpMatlabFile( std::string fName, std::string matrixName, bool elimDirichl
///
///
template
<
class
OperatorType
>
template
<
class
OperatorType
>
void
exportOperator
(
OperatorType
&
op
,
void
exportOperator
(
OperatorType
&
op
,
std
::
string
fName
,
const
std
::
string
&
fName
,
std
::
string
matrixName
,
std
::
string
matrixName
,
PetscViewerFormat
format
,
PetscViewerFormat
format
,
std
::
shared_ptr
<
PrimitiveStorage
>
storage
,
std
::
shared_ptr
<
PrimitiveStorage
>
storage
,
...
@@ -95,24 +96,24 @@ void exportOperator( OperatorType& op,
...
@@ -95,24 +96,24 @@ void exportOperator( OperatorType& op,
uint_t
globalDoFs
=
hyteg
::
numberOfGlobalDoFs
<
typename
OperatorType
::
srcType
::
Tag
>
(
*
storage
,
level
);
uint_t
globalDoFs
=
hyteg
::
numberOfGlobalDoFs
<
typename
OperatorType
::
srcType
::
Tag
>
(
*
storage
,
level
);
if
(
localDoFs
!=
globalDoFs
)
if
(
localDoFs
!=
globalDoFs
)
{
{
WALBERLA_ABORT
(
"localDoFs and globalDoFs must agree for exportOperator()!"
)
;
WALBERLA_ABORT
(
"localDoFs and globalDoFs must agree for exportOperator()!"
)
}
}
if
(
beVerbose
)
if
(
beVerbose
)
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
" * Dimension of function space is "
<<
globalDoFs
)
;
WALBERLA_LOG_INFO_ON_ROOT
(
" * Dimension of function space is "
<<
globalDoFs
)
}
}
// Fire up PETSc
// Fire up PETSc
if
(
beVerbose
)
if
(
beVerbose
)
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
" * Firing up PETSc"
)
;
WALBERLA_LOG_INFO_ON_ROOT
(
" * Firing up PETSc"
)
}
}
PETScManager
pmgr
;
PETScManager
pmgr
;
// Create PETSc matrix
// Create PETSc matrix
if
(
beVerbose
)
if
(
beVerbose
)
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
" * Converting Operator to PETSc matrix"
)
;
WALBERLA_LOG_INFO_ON_ROOT
(
" * Converting Operator to PETSc matrix"
)
}
}
PETScSparseMatrix
<
OperatorType
,
OperatorType
::
srcType
::
template
FunctionType
>
petscMatrix
(
PETScSparseMatrix
<
OperatorType
,
OperatorType
::
srcType
::
template
FunctionType
>
petscMatrix
(
localDoFs
,
globalDoFs
,
matrixName
.
c_str
()
);
localDoFs
,
globalDoFs
,
matrixName
.
c_str
()
);
...
@@ -121,14 +122,14 @@ void exportOperator( OperatorType& op,
...
@@ -121,14 +122,14 @@ void exportOperator( OperatorType& op,
petscMatrix
.
createMatrixFromOperator
(
op
,
level
,
numerator
);
petscMatrix
.
createMatrixFromOperator
(
op
,
level
,
numerator
);
// Zero rows and columns of "Dirichlet DoFs"
// Zero rows and columns of "Dirichlet DoFs"
std
::
vector
<
PetscIn
t
>
indices
;
std
::
vector
<
idx_
t
>
indices
;
if
(
elimDirichletBC
)
if
(
elimDirichletBC
)
{
{
if
(
elimSymmetric
)
if
(
elimSymmetric
)
{
{
if
(
beVerbose
)
if
(
beVerbose
)
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
" * Performing symmetric elimination of Dirichlet DoFs"
)
;
WALBERLA_LOG_INFO_ON_ROOT
(
" * Performing symmetric elimination of Dirichlet DoFs"
)
}
}
indices
=
petscMatrix
.
applyDirichletBCSymmetrically
(
numerator
,
level
);
indices
=
petscMatrix
.
applyDirichletBCSymmetrically
(
numerator
,
level
);
}
}
...
@@ -136,7 +137,7 @@ void exportOperator( OperatorType& op,
...
@@ -136,7 +137,7 @@ void exportOperator( OperatorType& op,
{
{
if
(
beVerbose
)
if
(
beVerbose
)
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
" * Performing non-symmetric elimination of Dirichlet DoFs"
)
;
WALBERLA_LOG_INFO_ON_ROOT
(
" * Performing non-symmetric elimination of Dirichlet DoFs"
)
}
}
hyteg
::
petsc
::
applyDirichletBC
(
numerator
,
indices
,
level
);
hyteg
::
petsc
::
applyDirichletBC
(
numerator
,
indices
,
level
);
petscMatrix
.
applyDirichletBC
(
numerator
,
level
);
petscMatrix
.
applyDirichletBC
(
numerator
,
level
);
...
@@ -146,7 +147,7 @@ void exportOperator( OperatorType& op,
...
@@ -146,7 +147,7 @@ void exportOperator( OperatorType& op,
// Write out matrix
// Write out matrix
if
(
beVerbose
)
if
(
beVerbose
)
{
{
WALBERLA_LOG_INFO_ON_ROOT
(
" * Exporting Operator to file '"
<<
fName
<<
"'"
)
;
WALBERLA_LOG_INFO_ON_ROOT
(
" * Exporting Operator to file '"
<<
fName
<<
"'"
)
}
}
petscMatrix
.
print
(
fName
.
c_str
(),
format
);
petscMatrix
.
print
(
fName
.
c_str
(),
format
);
...
@@ -161,7 +162,6 @@ void exportOperator( OperatorType& op,
...
@@ -161,7 +162,6 @@ void exportOperator( OperatorType& op,
}
}
}
}
}
// namespace petsc
}
// namespace hyteg::petsc
}
// namespace hyteg
#endif
#endif
src/hyteg/petsc/PETScSparseMatrix.hpp
View file @
2ba79464
...
@@ -116,15 +116,16 @@ class PETScSparseMatrix
...
@@ -116,15 +116,16 @@ class PETScSparseMatrix
void
applyDirichletBC
(
const
FunctionType
<
idx_t
>&
numerator
,
uint_t
level
)
void
applyDirichletBC
(
const
FunctionType
<
idx_t
>&
numerator
,
uint_t
level
)
{
{
std
::
vector
<
PetscInt
>
ind
;
std
::
vector
<
idx_t
>
bcIndices
;
hyteg
::
petsc
::
applyDirichletBC
(
numerator
,
ind
,
level
);
hyteg
::
petsc
::
applyDirichletBC
(
numerator
,
bcIndices
,
level
);
std
::
vector
<
PetscInt
>
PetscIntBcIndices
(
bcIndices
.
begin
(),
bcIndices
.
end
()
);
// This is required as the implementation of MatZeroRows() checks (for performance reasons?!)
// This is required as the implementation of MatZeroRows() checks (for performance reasons?!)
// if there are zero diagonals in the matrix. If there are, the function halts.
// if there are zero diagonals in the matrix. If there are, the function halts.
// To disable that check, we need to allow setting MAT_NEW_NONZERO_LOCATIONS to true.
// To disable that check, we need to allow setting MAT_NEW_NONZERO_LOCATIONS to true.
MatSetOption
(
mat
,
MAT_NEW_NONZERO_LOCATIONS
,
PETSC_TRUE
);
MatSetOption
(
mat
,
MAT_NEW_NONZERO_LOCATIONS
,
PETSC_TRUE
);
MatZeroRows
(
mat
,
static_cast
<
PetscInt
>
(
ind
.
size
()
),
ind
.
data
(),
1.0
,
nullptr
,
nullptr
);
MatZeroRows
(
mat
,
static_cast
<
PetscInt
>
(
PetscIntBcIndices
.
size
()
),
PetscIntBcIndices
.
data
(),
1.0
,
nullptr
,
nullptr
);
MatAssemblyBegin
(
mat
,
MAT_FINAL_ASSEMBLY
);
MatAssemblyBegin
(
mat
,
MAT_FINAL_ASSEMBLY
);
MatAssemblyEnd
(
mat
,
MAT_FINAL_ASSEMBLY
);
MatAssemblyEnd
(
mat
,
MAT_FINAL_ASSEMBLY
);
...
@@ -152,8 +153,9 @@ class PETScSparseMatrix
...
@@ -152,8 +153,9 @@ class PETScSparseMatrix
PETScVector
<
real_t
,
FunctionType
>&
rhsVec
,
PETScVector
<
real_t
,
FunctionType
>&
rhsVec
,
const
uint_t
&
level
)
const
uint_t
&
level
)
{
{
std
::
vector
<
PetscIn
t
>
bcIndices
;
std
::
vector
<
idx_
t
>
bcIndices
;
hyteg
::
petsc
::
applyDirichletBC
(
numerator
,
bcIndices
,
level
);
hyteg
::
petsc
::
applyDirichletBC
(
numerator
,
bcIndices
,
level
);
std
::
vector
<
PetscInt
>
PetscIntBcIndices
(
bcIndices
.
begin
(),
bcIndices
.
end
()
);
PETScVector
<
real_t
,
FunctionType
>
dirichletSolutionVec
(
PETScVector
<
real_t
,
FunctionType
>
dirichletSolutionVec
(
dirichletSolution
,
numerator
,
level
,
All
,
"dirichletSolutionVec"
,
rhsVec
.
getCommunicator
()
);
dirichletSolution
,
numerator
,
level
,
All
,
"dirichletSolutionVec"
,
rhsVec
.
getCommunicator
()
);
...
@@ -163,23 +165,26 @@ class PETScSparseMatrix
...
@@ -163,23 +165,26 @@ class PETScSparseMatrix
// To disable that check, we need to allow setting MAT_NEW_NONZERO_LOCATIONS to true.
// To disable that check, we need to allow setting MAT_NEW_NONZERO_LOCATIONS to true.
MatSetOption
(
mat
,
MAT_NEW_NONZERO_LOCATIONS
,
PETSC_TRUE
);
MatSetOption
(
mat
,
MAT_NEW_NONZERO_LOCATIONS
,
PETSC_TRUE
);
MatZeroRowsColumns
(
mat
,
bcIndices
.
size
(),
bcIndices
.
data
(),
1.0
,
dirichletSolutionVec
.
get
(),
rhsVec
.
get
()
);
MatZeroRowsColumns
(
mat
,
PetscIntBcIndices
.
size
(),
PetscIntBcIndices
.
data
(),
1.0
,
dirichletSolutionVec
.
get
(),
rhsVec
.
get
()
);
}
}
/// \brief Variant of applyDirichletBCSymmetrically() that only modifies the matrix itself
/// \brief Variant of applyDirichletBCSymmetrically() that only modifies the matrix itself
///
///
/// \return Vector with global indices of the Dirichlet DoFs
/// \return Vector with global indices of the Dirichlet DoFs
std
::
vector
<
PetscIn
t
>
applyDirichletBCSymmetrically
(
const
FunctionType
<
idx_t
>&
numerator
,
const
uint_t
&
level
)
std
::
vector
<
idx_
t
>
applyDirichletBCSymmetrically
(
const
FunctionType
<
idx_t
>&
numerator
,
const
uint_t
&
level
)
{
{
std
::
vector
<
PetscIn
t
>
bcIndices
;
std
::
vector
<
idx_
t
>
bcIndices
;
hyteg
::
petsc
::
applyDirichletBC
(
numerator
,
bcIndices
,
level
);
hyteg
::
petsc
::
applyDirichletBC
(
numerator
,
bcIndices
,
level
);
std
::
vector
<
PetscInt
>
PetscIntBcIndices
(
bcIndices
.
begin
(),
bcIndices
.
end
()
);
// This is required as the implementation of MatZeroRowsColumns() checks (for performance reasons?!)
// This is required as the implementation of MatZeroRowsColumns() checks (for performance reasons?!)
// if there are zero diagonals in the matrix. If there are, the function halts.
// if there are zero diagonals in the matrix. If there are, the function halts.
// To disable that check, we need to allow setting MAT_NEW_NONZERO_LOCATIONS to true.
// To disable that check, we need to allow setting MAT_NEW_NONZERO_LOCATIONS to true.
MatSetOption
(
mat
,
MAT_NEW_NONZERO_LOCATIONS
,
PETSC_TRUE
);
MatSetOption
(
mat
,
MAT_NEW_NONZERO_LOCATIONS
,
PETSC_TRUE
);
MatZeroRowsColumns
(
mat
,
static_cast
<
PetscInt
>
(
bcIndices
.
size
()
),
bcIndices
.
data
(),
1.0
,
nullptr
,
nullptr
);
MatZeroRowsColumns
(
mat
,
static_cast
<
PetscInt
>
(
PetscIntBcIndices
.
size
()
),
PetscIntBcIndices
.
data
(),
1.0
,
nullptr
,
nullptr
);
return
bcIndices
;
return
bcIndices
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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