Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-tectonic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
podlesny
dune-tectonic
Commits
b9de9145
Commit
b9de9145
authored
13 years ago
by
Elias Pipping
Committed by
Elias Pipping
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Clean up construction of TNNMG solver
Mostly heap -> stack
parent
de278244
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/one-body-sample.cc
+35
-53
35 additions, 53 deletions
src/one-body-sample.cc
with
35 additions
and
53 deletions
src/one-body-sample.cc
+
35
−
53
View file @
b9de9145
...
@@ -268,51 +268,42 @@ int main(int argc, char *argv[]) {
...
@@ -268,51 +268,42 @@ int main(int argc, char *argv[]) {
myGlobalNonlinearity
,
nodalIntegrals
);
myGlobalNonlinearity
,
nodalIntegrals
);
// {{{ Set up TNNMG solver
// {{{ Set up TNNMG solver
auto
linearBaseSolverStep
=
// linear iteration step components
new
TruncatedBlockGSStep
<
OperatorType
,
VectorType
>
;
TruncatedBlockGSStep
<
OperatorType
,
VectorType
>
linearBaseSolverStep
;
auto
const
baseEnergyNorm
=
EnergyNorm
<
OperatorType
,
VectorType
>
baseEnergyNorm
(
linearBaseSolverStep
);
new
EnergyNorm
<
OperatorType
,
VectorType
>
(
*
linearBaseSolverStep
);
LoopSolver
<
VectorType
>
linearBaseSolver
(
auto
linearBaseSolver
=
new
LoopSolver
<
VectorType
>
(
&
linearBaseSolverStep
,
solver_maxIterations
,
solver_tolerance
,
linearBaseSolverStep
,
solver_maxIterations
,
solver_tolerance
,
&
baseEnergyNorm
,
Solver
::
QUIET
);
baseEnergyNorm
,
Solver
::
QUIET
);
TruncatedBlockGSStep
<
OperatorType
,
VectorType
>
linearPresmoother
;
TruncatedBlockGSStep
<
OperatorType
,
VectorType
>
linearPostsmoother
;
// {{{ Smoothers
auto
linearPresmoother
=
new
TruncatedBlockGSStep
<
OperatorType
,
VectorType
>
;
// linear iteration step
auto
linearPostsmoother
=
MultigridStep
<
OperatorType
,
VectorType
>
linearIterationStep
;
new
TruncatedBlockGSStep
<
OperatorType
,
VectorType
>
;
linearIterationStep
.
setNumberOfLevels
(
levels
);
// }}}
linearIterationStep
.
setMGType
(
parset
.
get
<
int
>
(
"solver.tnnmg.linear.mu"
),
parset
.
get
<
int
>
(
"solver.tnnmg.linear.nu1"
),
auto
linearIterationStep
=
new
MultigridStep
<
OperatorType
,
VectorType
>
;
parset
.
get
<
int
>
(
"solver.tnnmg.linear.nu2"
));
linearIterationStep
->
setNumberOfLevels
(
levels
);
linearIterationStep
.
basesolver_
=
&
linearBaseSolver
;
linearIterationStep
->
setMGType
(
parset
.
get
<
int
>
(
"solver.tnnmg.linear.mu"
),
linearIterationStep
.
setSmoother
(
&
linearPresmoother
,
&
linearPostsmoother
);
parset
.
get
<
int
>
(
"solver.tnnmg.linear.nu1"
),
parset
.
get
<
int
>
(
"solver.tnnmg.linear.nu2"
));
// transfer operators
linearIterationStep
->
basesolver_
=
linearBaseSolver
;
std
::
vector
<
CompressedMultigridTransfer
<
VectorType
>
*>
transferOperators
(
linearIterationStep
->
setSmoother
(
linearPresmoother
,
linearPostsmoother
);
refinements
);
// {{{ Transfer operators
std
::
vector
<
CompressedMultigridTransfer
<
VectorType
>
*>
transferOperators
;
transferOperators
.
resize
(
refinements
);
for
(
auto
&
x
:
transferOperators
)
for
(
auto
&
x
:
transferOperators
)
x
=
new
CompressedMultigridTransfer
<
VectorType
>
;
x
=
new
CompressedMultigridTransfer
<
VectorType
>
;
TransferOperatorAssembler
<
GridType
>
(
grid
)
.
assembleOperatorPointerHierarchy
(
transferOperators
);
linearIterationStep
.
setTransferOperators
(
transferOperators
);
TransferOperatorAssembler
<
GridType
>
transferOperatorAssembler
(
grid
);
// tnnmg iteration step
transferOperatorAssembler
.
assembleOperatorPointerHierarchy
(
transferOperators
);
linearIterationStep
->
setTransferOperators
(
transferOperators
);
// }}}
typedef
GenericNonlinearGS
<
MyBlockProblemType
>
NonlinearSmootherType
;
typedef
GenericNonlinearGS
<
MyBlockProblemType
>
NonlinearSmootherType
;
typedef
TruncatedNonsmoothNewtonMultigrid
<
NonlinearSmootherType
nonlinearSmoother
;
MyBlockProblemType
,
NonlinearSmootherType
>
TNNMGStepType
;
TruncatedNonsmoothNewtonMultigrid
<
MyBlockProblemType
,
NonlinearSmootherType
>
multigridStep
(
linearIterationStep
,
nonlinearSmoother
);
auto
nonlinearSmoother
=
new
NonlinearSmootherType
;
multigridStep
.
setSmoothingSteps
(
parset
.
get
<
int
>
(
"solver.tnnmg.main.nu1"
),
auto
multigridStep
=
parset
.
get
<
int
>
(
"solver.tnnmg.main.mu"
),
new
TNNMGStepType
(
*
linearIterationStep
,
*
nonlinearSmoother
);
parset
.
get
<
int
>
(
"solver.tnnmg.main.nu2"
));
multigridStep
->
setSmoothingSteps
(
parset
.
get
<
int
>
(
"solver.tnnmg.main.nu1"
),
multigridStep
.
ignoreNodes_
=
&
ignoreNodes
;
parset
.
get
<
int
>
(
"solver.tnnmg.main.mu"
),
parset
.
get
<
int
>
(
"solver.tnnmg.main.nu2"
));
multigridStep
->
ignoreNodes_
=
&
ignoreNodes
;
// }}}
// }}}
for
(
size_t
run
=
1
;
run
<=
parset
.
get
<
size_t
>
(
"timesteps"
);
++
run
)
{
for
(
size_t
run
=
1
;
run
<=
parset
.
get
<
size_t
>
(
"timesteps"
);
++
run
)
{
...
@@ -376,10 +367,10 @@ int main(int argc, char *argv[]) {
...
@@ -376,10 +367,10 @@ int main(int argc, char *argv[]) {
}
}
MyBlockProblemType
myBlockProblem
(
parset
,
myConvexProblem
);
MyBlockProblemType
myBlockProblem
(
parset
,
myConvexProblem
);
multigridStep
->
setProblem
(
u4_diff
,
myBlockProblem
);
multigridStep
.
setProblem
(
u4_diff
,
myBlockProblem
);
LoopSolver
<
VectorType
>
overallSolver
(
LoopSolver
<
VectorType
>
overallSolver
(
multigridStep
,
solver_maxIterations
,
solver_tolerance
,
&
energyNorm
,
&
multigridStep
,
solver_maxIterations
,
solver_tolerance
,
&
energyNorm
,
verbosity
);
verbosity
);
overallSolver
.
solve
();
overallSolver
.
solve
();
}
}
...
@@ -437,18 +428,9 @@ int main(int argc, char *argv[]) {
...
@@ -437,18 +428,9 @@ int main(int argc, char *argv[]) {
}
}
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
// {{{ Clean up after the TNNMG solver
// Clean up after the TNNMG solver
delete
linearBaseSolverStep
;
delete
baseEnergyNorm
;
delete
linearBaseSolver
;
delete
linearPresmoother
;
delete
linearPostsmoother
;
for
(
auto
&
x
:
transferOperators
)
for
(
auto
&
x
:
transferOperators
)
delete
x
;
delete
x
;
delete
linearIterationStep
;
delete
nonlinearSmoother
;
delete
multigridStep
;
// }}}
if
(
parset
.
get
<
bool
>
(
"printDifference"
))
{
if
(
parset
.
get
<
bool
>
(
"printDifference"
))
{
VectorType
diff2
=
u2
;
VectorType
diff2
=
u2
;
...
...
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