Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
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
Container Registry
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
dumux-repositories
dumux
Commits
0f8a0e16
Commit
0f8a0e16
authored
7 years ago
by
Kilian Weishaupt
Browse files
Options
Downloads
Patches
Plain Diff
[test][3pwateroil] Use NewtonSolver
parent
a805d433
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/porousmediumflow/3pwateroil/implicit/test_box3pwateroil.cc
+13
-34
13 additions, 34 deletions
...orousmediumflow/3pwateroil/implicit/test_box3pwateroil.cc
with
13 additions
and
34 deletions
test/porousmediumflow/3pwateroil/implicit/test_box3pwateroil.cc
+
13
−
34
View file @
0f8a0e16
...
...
@@ -37,8 +37,7 @@
#include
<dumux/common/timeloop.hh>
#include
<dumux/linear/amgbackend.hh>
#include
<dumux/nonlinear/newtonmethod.hh>
#include
<dumux/porousmediumflow/compositional/privarswitchnewtoncontroller.hh>
#include
<dumux/nonlinear/privarswitchnewtonsolver.hh>
#include
<dumux/assembly/fvassembler.hh>
#include
<dumux/assembly/diffmethod.hh>
...
...
@@ -130,7 +129,6 @@ int main(int argc, char** argv) try
// get some time loop parameters
using
Scalar
=
typename
GET_PROP_TYPE
(
TypeTag
,
Scalar
);
const
auto
tEnd
=
getParam
<
Scalar
>
(
"TimeLoop.TEnd"
);
const
auto
maxDivisions
=
getParam
<
int
>
(
"TimeLoop.MaxTimeStepDivisions"
);
const
auto
maxDt
=
getParam
<
Scalar
>
(
"TimeLoop.MaxTimeStepSize"
);
auto
dt
=
getParam
<
Scalar
>
(
"TimeLoop.DtInitial"
);
...
...
@@ -159,36 +157,18 @@ int main(int argc, char** argv) try
auto
linearSolver
=
std
::
make_shared
<
LinearSolver
>
(
leafGridView
,
fvGridGeometry
->
dofMapper
());
// the non-linear solver
using
NewtonController
=
PriVarSwitchNewtonController
<
TypeTag
>
;
using
NewtonMethod
=
Dumux
::
NewtonMethod
<
NewtonController
,
Assembler
,
LinearSolver
>
;
auto
newtonController
=
std
::
make_shared
<
NewtonController
>
(
timeLoop
);
NewtonMethod
nonLinearSolver
(
newtonController
,
assembler
,
linearSolver
);
using
NewtonSolver
=
PriVarSwitchNewtonSolver
<
Assembler
,
LinearSolver
,
typename
GET_PROP_TYPE
(
TypeTag
,
PrimaryVariableSwitch
)
>
;
NewtonSolver
nonLinearSolver
(
assembler
,
linearSolver
);
// time loop
timeLoop
->
start
();
while
(
!
timeLoop
->
finished
())
timeLoop
->
start
();
do
{
// set previous solution for storage evaluations
assembler
->
setPreviousSolution
(
xOld
);
// try solving the non-linear system
for
(
int
i
=
0
;
i
<
maxDivisions
;
++
i
)
{
// linearize & solve
auto
converged
=
nonLinearSolver
.
solve
(
x
);
if
(
converged
)
break
;
if
(
!
converged
&&
i
==
maxDivisions
-
1
)
DUNE_THROW
(
Dune
::
MathError
,
"Newton solver didn't converge after "
<<
maxDivisions
<<
" time-step divisions. dt="
<<
timeLoop
->
timeStepSize
()
<<
".
\n
The solutions of the current and the previous time steps "
<<
"have been saved to restart files."
);
}
// solve the non-linear system with time step control
nonLinearSolver
.
solve
(
x
,
*
timeLoop
);
// make the new solution the old solution
xOld
=
x
;
...
...
@@ -197,17 +177,16 @@ int main(int argc, char** argv) try
// advance to the time loop to the next step
timeLoop
->
advanceTimeStep
();
// write vtk output
// if episode length was specificied output only at the end of episodes
if
(
!
haveParam
(
"TimeLoop.EpisodeLength"
)
||
timeLoop
->
isCheckPoint
()
||
timeLoop
->
finished
()
||
timeLoop
->
timeStepIndex
()
==
1
)
vtkWriter
.
write
(
timeLoop
->
time
());
// report statistics of this time step
timeLoop
->
reportTimeStep
();
// set new dt as suggested by newton controller
timeLoop
->
setTimeStepSize
(
newtonController
->
suggestTimeStepSize
(
timeLoop
->
timeStepSize
()));
}
timeLoop
->
setTimeStepSize
(
nonLinearSolver
.
suggestTimeStepSize
(
timeLoop
->
timeStepSize
()));
// write vtk output
vtkWriter
.
write
(
timeLoop
->
time
());
}
while
(
!
timeLoop
->
finished
());
timeLoop
->
finalize
(
leafGridView
.
comm
());
...
...
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