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
45245b21
Commit
45245b21
authored
6 years ago
by
Kilian Weishaupt
Browse files
Options
Downloads
Patches
Plain Diff
[test][1pncmin][implicit] Use NewtonSolver
parent
e55d8543
No related branches found
No related tags found
1 merge request
!898
Use NewtonSolver
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc
+21
-40
21 additions, 40 deletions
test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc
with
21 additions
and
40 deletions
test/porousmediumflow/1pncmin/implicit/test_1pncminni_fv.cc
+
21
−
40
View file @
45245b21
...
...
@@ -30,8 +30,7 @@
#include
<dumux/common/parameters.hh>
#include
<dumux/common/dumuxmessage.hh>
#include
<dumux/nonlinear/newtonmethod.hh>
#include
<dumux/nonlinear/newtoncontroller.hh>
#include
<dumux/nonlinear/newtonsolver.hh>
#include
<dumux/linear/seqsolverbackend.hh>
#include
<dumux/assembly/fvassembler.hh>
...
...
@@ -134,7 +133,6 @@ int main(int argc, char** argv) try
using
Scalar
=
typename
GET_PROP_TYPE
(
TypeTag
,
Scalar
);
auto
tEnd
=
getParam
<
Scalar
>
(
"TimeLoop.TEnd"
);
auto
dt
=
getParam
<
Scalar
>
(
"TimeLoop.DtInitial"
);
auto
maxDivisions
=
getParam
<
int
>
(
"TimeLoop.MaxTimeStepDivisions"
);
auto
maxDt
=
getParam
<
Scalar
>
(
"TimeLoop.MaxTimeStepSize"
);
// intialize the vtk output module
...
...
@@ -164,9 +162,8 @@ int main(int argc, char** argv) try
auto
linearSolver
=
std
::
make_shared
<
LinearSolver
>
();
// the non-linear solver
using
NewtonController
=
Dumux
::
NewtonController
<
Scalar
>
;
auto
newtonController
=
std
::
make_shared
<
NewtonController
>
(
timeLoop
);
NewtonMethod
<
NewtonController
,
Assembler
,
LinearSolver
>
nonLinearSolver
(
newtonController
,
assembler
,
linearSolver
);
using
NewtonSolver
=
Dumux
::
NewtonSolver
<
Assembler
,
LinearSolver
>
;
NewtonSolver
nonLinearSolver
(
assembler
,
linearSolver
);
// time loop
timeLoop
->
start
();
do
...
...
@@ -177,43 +174,27 @@ int main(int argc, char** argv) try
// 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."
);
}
// make the new solution the old solution
xOld
=
x
;
gridVariables
->
advanceTimeStep
();
// advance to the time loop to the next step
timeLoop
->
advanceTimeStep
();
// update the output fields before write
problem
->
updateVtkOutput
(
x
);
// solve the non-linear system with time step control
nonLinearSolver
.
solve
(
x
,
*
timeLoop
);
// make the new solution the old solution
xOld
=
x
;
gridVariables
->
advanceTimeStep
();
// advance to the time loop to the next step
timeLoop
->
advanceTimeStep
();
// update the output fields before write
problem
->
updateVtkOutput
(
x
);
// write vtk output
vtkWriter
.
write
(
timeLoop
->
time
());
// write vtk output
vtkWriter
.
write
(
timeLoop
->
time
());
// report statistics of this time step
timeLoop
->
reportTimeStep
();
// report statistics of this time step
timeLoop
->
reportTimeStep
();
// set new dt as suggested by newton
contr
ol
l
er
timeLoop
->
setTimeStepSize
(
n
ewtonContr
ol
l
er
->
suggestTimeStepSize
(
timeLoop
->
timeStepSize
()));
// set new dt as suggested by
the
newton
s
ol
v
er
timeLoop
->
setTimeStepSize
(
n
onLinearS
ol
v
er
.
suggestTimeStepSize
(
timeLoop
->
timeStepSize
()));
}
while
(
!
timeLoop
->
finished
());
...
...
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