Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gfe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sander, Oliver
dune-gfe
Commits
d7cb77f9
Commit
d7cb77f9
authored
9 years ago
by
Sander, Oliver
Browse files
Options
Downloads
Patches
Plain Diff
Use a MultiTypeBlockMatrix instead of four separate matrices
parent
a664285e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/gfe/mixedriemanniantrsolver.cc
+21
-28
21 additions, 28 deletions
dune/gfe/mixedriemanniantrsolver.cc
dune/gfe/mixedriemanniantrsolver.hh
+4
-4
4 additions, 4 deletions
dune/gfe/mixedriemanniantrsolver.hh
with
25 additions
and
32 deletions
dune/gfe/mixedriemanniantrsolver.cc
+
21
−
28
View file @
d7cb77f9
...
@@ -184,10 +184,7 @@ setup(const GridType& grid,
...
@@ -184,10 +184,7 @@ setup(const GridType& grid,
// \todo Why are the hessianMatrix objects class members at all, and not local to 'solve'?
// \todo Why are the hessianMatrix objects class members at all, and not local to 'solve'?
hessianMatrix00_
=
std
::
unique_ptr
<
MatrixType00
>
(
new
MatrixType00
);
hessianMatrix_
=
std
::
make_unique
<
MatrixType
>
();
hessianMatrix01_
=
std
::
unique_ptr
<
MatrixType01
>
(
new
MatrixType01
);
hessianMatrix10_
=
std
::
unique_ptr
<
MatrixType10
>
(
new
MatrixType10
);
hessianMatrix11_
=
std
::
unique_ptr
<
MatrixType11
>
(
new
MatrixType11
);
// ////////////////////////////////////
// ////////////////////////////////////
// Create the transfer operators
// Create the transfer operators
...
@@ -321,16 +318,15 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
...
@@ -321,16 +318,15 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
// Trust-Region Solver
// Trust-Region Solver
// /////////////////////////////////////////////////////
// /////////////////////////////////////////////////////
using
namespace
Dune
::
TypeTree
::
Indices
;
double
oldEnergy
=
assembler_
->
computeEnergy
(
x0_
,
x1_
);
double
oldEnergy
=
assembler_
->
computeEnergy
(
x0_
,
x1_
);
oldEnergy
=
mpiHelper
.
getCollectiveCommunication
().
sum
(
oldEnergy
);
oldEnergy
=
mpiHelper
.
getCollectiveCommunication
().
sum
(
oldEnergy
);
bool
recomputeGradientHessian
=
true
;
bool
recomputeGradientHessian
=
true
;
CorrectionType0
rhs0
;
CorrectionType0
rhs0
;
CorrectionType1
rhs1
;
CorrectionType1
rhs1
;
MatrixType00
stiffnessMatrix00
;
MatrixType
stiffnessMatrix
;
MatrixType01
stiffnessMatrix01
;
MatrixType10
stiffnessMatrix10
;
MatrixType11
stiffnessMatrix11
;
CorrectionType0
rhs_global0
;
CorrectionType0
rhs_global0
;
CorrectionType1
rhs_global1
;
CorrectionType1
rhs_global1
;
#if 0
#if 0
...
@@ -362,10 +358,10 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
...
@@ -362,10 +358,10 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
x1_
,
x1_
,
rhs0
,
rhs0
,
rhs1
,
rhs1
,
*
hessianMatrix
00_
,
(
*
hessianMatrix
_
)[
_0
][
_0
]
,
*
hessianMatrix
01_
,
(
*
hessianMatrix
_
)[
_0
][
_1
]
,
*
hessianMatrix
10_
,
(
*
hessianMatrix
_
)[
_1
][
_0
]
,
*
hessianMatrix
11_
,
(
*
hessianMatrix
_
)[
_1
][
_1
]
,
i
==
0
// assemble occupation pattern only for the first call
i
==
0
// assemble occupation pattern only for the first call
);
);
...
@@ -382,10 +378,7 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
...
@@ -382,10 +378,7 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
stiffnessMatrix10 = matrixComm.reduceAdd(*hessianMatrix10_);
stiffnessMatrix10 = matrixComm.reduceAdd(*hessianMatrix10_);
stiffnessMatrix11 = matrixComm.reduceAdd(*hessianMatrix11_);
stiffnessMatrix11 = matrixComm.reduceAdd(*hessianMatrix11_);
#endif
#endif
stiffnessMatrix00
=
*
hessianMatrix00_
;
stiffnessMatrix
=
*
hessianMatrix_
;
stiffnessMatrix01
=
*
hessianMatrix01_
;
stiffnessMatrix10
=
*
hessianMatrix10_
;
stiffnessMatrix11
=
*
hessianMatrix11_
;
// Transfer vector data
// Transfer vector data
#if 0
#if 0
...
@@ -412,13 +405,13 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
...
@@ -412,13 +405,13 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
CorrectionType0
residual0
=
rhs_global0
;
CorrectionType0
residual0
=
rhs_global0
;
CorrectionType1
residual1
=
rhs_global1
;
CorrectionType1
residual1
=
rhs_global1
;
mmgStep0
->
setProblem
(
stiffnessMatrix
00
,
corr_global0
,
residual0
);
mmgStep0
->
setProblem
(
stiffnessMatrix
[
_0
][
_0
]
,
corr_global0
,
residual0
);
trustRegionObstacles0
=
trustRegion0
.
obstacles
();
trustRegionObstacles0
=
trustRegion0
.
obstacles
();
mmgStep0
->
obstacles_
=
&
trustRegionObstacles0
;
mmgStep0
->
obstacles_
=
&
trustRegionObstacles0
;
mmgStep0
->
preprocess
();
mmgStep0
->
preprocess
();
mmgStep1
->
setProblem
(
stiffnessMatrix
11
,
corr_global1
,
residual1
);
mmgStep1
->
setProblem
(
stiffnessMatrix
[
_1
][
_1
]
,
corr_global1
,
residual1
);
trustRegionObstacles1
=
trustRegion1
.
obstacles
();
trustRegionObstacles1
=
trustRegion1
.
obstacles
();
mmgStep1
->
obstacles_
=
&
trustRegionObstacles1
;
mmgStep1
->
obstacles_
=
&
trustRegionObstacles1
;
...
@@ -431,23 +424,23 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
...
@@ -431,23 +424,23 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
for
(
int
ii
=
0
;
ii
<
innerIterations_
;
ii
++
)
for
(
int
ii
=
0
;
ii
<
innerIterations_
;
ii
++
)
{
{
residual0
=
rhs_global0
;
residual0
=
rhs_global0
;
stiffnessMatrix
01
.
mmv
(
corr_global1
,
residual0
);
stiffnessMatrix
[
_0
][
_1
]
.
mmv
(
corr_global1
,
residual0
);
mmgStep0
->
setRhs
(
residual0
);
mmgStep0
->
setRhs
(
residual0
);
mmgStep0
->
iterate
();
mmgStep0
->
iterate
();
residual1
=
rhs_global1
;
residual1
=
rhs_global1
;
stiffnessMatrix
10
.
mmv
(
corr_global0
,
residual1
);
stiffnessMatrix
[
_1
][
_0
]
.
mmv
(
corr_global0
,
residual1
);
mmgStep1
->
setRhs
(
residual1
);
mmgStep1
->
setRhs
(
residual1
);
mmgStep1
->
iterate
();
mmgStep1
->
iterate
();
// Compute energy
// Compute energy
CorrectionType0
tmp0
(
corr_global0
);
CorrectionType0
tmp0
(
corr_global0
);
stiffnessMatrix
00
.
mv
(
corr_global0
,
tmp0
);
stiffnessMatrix
[
_0
][
_0
]
.
mv
(
corr_global0
,
tmp0
);
stiffnessMatrix
01
.
umv
(
corr_global1
,
tmp0
);
stiffnessMatrix
[
_0
][
_1
]
.
umv
(
corr_global1
,
tmp0
);
CorrectionType1
tmp1
(
corr_global1
);
CorrectionType1
tmp1
(
corr_global1
);
stiffnessMatrix
10
.
mv
(
corr_global0
,
tmp1
);
stiffnessMatrix
[
_1
][
_0
]
.
mv
(
corr_global0
,
tmp1
);
stiffnessMatrix
11
.
umv
(
corr_global1
,
tmp1
);
stiffnessMatrix
[
_1
][
_1
]
.
umv
(
corr_global1
,
tmp1
);
double
energy
=
0.5
*
(
tmp0
*
corr_global0
+
tmp1
*
corr_global1
)
-
(
rhs_global0
*
corr_global0
+
rhs_global1
*
corr_global1
);
double
energy
=
0.5
*
(
tmp0
*
corr_global0
+
tmp1
*
corr_global1
)
-
(
rhs_global0
*
corr_global0
+
rhs_global1
*
corr_global1
);
...
@@ -504,13 +497,13 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
...
@@ -504,13 +497,13 @@ void MixedRiemannianTrustRegionSolver<GridType,Basis0,TargetSpace0,Basis1,Target
// Note that rhs = -g
// Note that rhs = -g
CorrectionType0
tmp0
(
corr0
.
size
());
CorrectionType0
tmp0
(
corr0
.
size
());
tmp0
=
0
;
tmp0
=
0
;
hessianMatrix
00_
->
umv
(
corr0
,
tmp0
);
(
*
hessianMatrix
_
)[
_0
][
_0
].
umv
(
corr0
,
tmp0
);
hessianMatrix
01_
->
umv
(
corr1
,
tmp0
);
(
*
hessianMatrix
_
)[
_0
][
_1
].
umv
(
corr1
,
tmp0
);
CorrectionType1
tmp1
(
corr1
.
size
());
CorrectionType1
tmp1
(
corr1
.
size
());
tmp1
=
0
;
tmp1
=
0
;
hessianMatrix
10_
->
umv
(
corr0
,
tmp1
);
(
*
hessianMatrix
_
)[
_1
][
_0
].
umv
(
corr0
,
tmp1
);
hessianMatrix
11_
->
umv
(
corr1
,
tmp1
);
(
*
hessianMatrix
_
)[
_1
][
_1
].
umv
(
corr1
,
tmp1
);
double
modelDecrease
=
(
rhs0
*
corr0
+
rhs1
*
corr1
)
-
0.5
*
(
corr0
*
tmp0
+
corr1
*
tmp1
);
double
modelDecrease
=
(
rhs0
*
corr0
+
rhs1
*
corr1
)
-
0.5
*
(
corr0
*
tmp0
+
corr1
*
tmp1
);
modelDecrease
=
mpiHelper
.
getCollectiveCommunication
().
sum
(
modelDecrease
);
modelDecrease
=
mpiHelper
.
getCollectiveCommunication
().
sum
(
modelDecrease
);
...
...
This diff is collapsed.
Click to expand it.
dune/gfe/mixedriemanniantrsolver.hh
+
4
−
4
View file @
d7cb77f9
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include
<dune/istl/bcrsmatrix.hh>
#include
<dune/istl/bcrsmatrix.hh>
#include
<dune/istl/bvector.hh>
#include
<dune/istl/bvector.hh>
#include
<dune/istl/multitypeblockmatrix.hh>
#include
<dune/grid/utility/globalindexset.hh>
#include
<dune/grid/utility/globalindexset.hh>
...
@@ -38,6 +39,8 @@ class MixedRiemannianTrustRegionSolver
...
@@ -38,6 +39,8 @@ class MixedRiemannianTrustRegionSolver
typedef
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
field_type
,
blocksize0
,
blocksize1
>
>
MatrixType01
;
typedef
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
field_type
,
blocksize0
,
blocksize1
>
>
MatrixType01
;
typedef
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
field_type
,
blocksize1
,
blocksize0
>
>
MatrixType10
;
typedef
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
field_type
,
blocksize1
,
blocksize0
>
>
MatrixType10
;
typedef
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
field_type
,
blocksize1
,
blocksize1
>
>
MatrixType11
;
typedef
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
field_type
,
blocksize1
,
blocksize1
>
>
MatrixType11
;
typedef
Dune
::
MultiTypeBlockMatrix
<
Dune
::
MultiTypeBlockVector
<
MatrixType00
,
MatrixType01
>
,
Dune
::
MultiTypeBlockVector
<
MatrixType10
,
MatrixType11
>
>
MatrixType
;
typedef
Dune
::
BlockVector
<
Dune
::
FieldVector
<
field_type
,
blocksize0
>
>
CorrectionType0
;
typedef
Dune
::
BlockVector
<
Dune
::
FieldVector
<
field_type
,
blocksize0
>
>
CorrectionType0
;
typedef
Dune
::
BlockVector
<
Dune
::
FieldVector
<
field_type
,
blocksize1
>
>
CorrectionType1
;
typedef
Dune
::
BlockVector
<
Dune
::
FieldVector
<
field_type
,
blocksize1
>
>
CorrectionType1
;
typedef
std
::
vector
<
TargetSpace0
>
SolutionType0
;
typedef
std
::
vector
<
TargetSpace0
>
SolutionType0
;
...
@@ -140,10 +143,7 @@ protected:
...
@@ -140,10 +143,7 @@ protected:
double
innerTolerance_
;
double
innerTolerance_
;
/** \brief Hessian matrix */
/** \brief Hessian matrix */
std
::
unique_ptr
<
MatrixType00
>
hessianMatrix00_
;
std
::
unique_ptr
<
MatrixType
>
hessianMatrix_
;
std
::
unique_ptr
<
MatrixType01
>
hessianMatrix01_
;
std
::
unique_ptr
<
MatrixType10
>
hessianMatrix10_
;
std
::
unique_ptr
<
MatrixType11
>
hessianMatrix11_
;
/** \brief The assembler for the material law */
/** \brief The assembler for the material law */
const
MixedGFEAssembler
<
Basis0
,
TargetSpace0
,
Basis1
,
TargetSpace1
>*
assembler_
;
const
MixedGFEAssembler
<
Basis0
,
TargetSpace0
,
Basis1
,
TargetSpace1
>*
assembler_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment