Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux-course
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-course
Commits
655918b0
Commit
655918b0
authored
6 years ago
by
Katharina Heck
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/ex-basic-setup' into 'master'
Fix/ex basic setup See merge request
!31
parents
40b4eb2a
f500fca4
No related branches found
No related tags found
1 merge request
!31
Fix/ex basic setup
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exercises/exercise-basic/exercise_basic.cc
+0
-197
0 additions, 197 deletions
exercises/exercise-basic/exercise_basic.cc
exercises/extradoc/exercise1_setup.png
+0
-0
0 additions, 0 deletions
exercises/extradoc/exercise1_setup.png
with
0 additions
and
197 deletions
exercises/exercise-basic/exercise_basic.cc
deleted
100644 → 0
+
0
−
197
View file @
40b4eb2a
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief The main file for the two-phase porousmediumflow problem of exercise-basic
*/
#include
<config.h>
#include
<ctime>
#include
<iostream>
#include
<dune/common/parallel/mpihelper.hh>
#include
<dune/common/timer.hh>
#include
<dune/grid/io/file/dgfparser/dgfexception.hh>
#include
<dune/grid/io/file/vtk.hh>
#include
<dumux/common/properties.hh>
#include
<dumux/common/parameters.hh>
#include
<dumux/common/dumuxmessage.hh>
#include
<dumux/common/defaultusagemessage.hh>
#include
<dumux/linear/amgbackend.hh>
#include
<dumux/nonlinear/newtonsolver.hh>
#include
<dumux/assembly/fvassembler.hh>
#include
<dumux/assembly/diffmethod.hh>
#include
<dumux/discretization/methods.hh>
#include
<dumux/io/vtkoutputmodule.hh>
#include
<dumux/io/grid/gridmanager.hh>
#include
"injection2pproblem.hh"
////////////////////////
// the main function
////////////////////////
int
main
(
int
argc
,
char
**
argv
)
try
{
using
namespace
Dumux
;
// define the type tag for this problem
using
TypeTag
=
TTAG
(
Injection2pCCTypeTag
);
// initialize MPI, finalize is done automatically on exit
const
auto
&
mpiHelper
=
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
// print dumux start message
if
(
mpiHelper
.
rank
()
==
0
)
DumuxMessage
::
print
(
/*firstCall=*/
true
);
// parse command line arguments and input file
Parameters
::
init
(
argc
,
argv
);
// try to create a grid (from the given grid file or the input file)
GridManager
<
typename
GET_PROP_TYPE
(
TypeTag
,
Grid
)
>
gridManager
;
gridManager
.
init
();
////////////////////////////////////////////////////////////
// run instationary non-linear problem on this grid
////////////////////////////////////////////////////////////
// we compute on the leaf grid view
const
auto
&
leafGridView
=
gridManager
.
grid
().
leafGridView
();
// create the finite volume grid geometry
using
FVGridGeometry
=
typename
GET_PROP_TYPE
(
TypeTag
,
FVGridGeometry
);
auto
fvGridGeometry
=
std
::
make_shared
<
FVGridGeometry
>
(
leafGridView
);
fvGridGeometry
->
update
();
// the problem (initial and boundary conditions)
using
Problem
=
typename
GET_PROP_TYPE
(
TypeTag
,
Problem
);
auto
problem
=
std
::
make_shared
<
Problem
>
(
fvGridGeometry
);
// the solution vector
using
SolutionVector
=
typename
GET_PROP_TYPE
(
TypeTag
,
SolutionVector
);
SolutionVector
x
(
fvGridGeometry
->
numDofs
());
problem
->
applyInitialSolution
(
x
);
auto
xOld
=
x
;
// the grid variables
using
GridVariables
=
typename
GET_PROP_TYPE
(
TypeTag
,
GridVariables
);
auto
gridVariables
=
std
::
make_shared
<
GridVariables
>
(
problem
,
fvGridGeometry
);
gridVariables
->
init
(
x
,
xOld
);
// get some time loop parameters
using
Scalar
=
typename
GET_PROP_TYPE
(
TypeTag
,
Scalar
);
const
auto
tEnd
=
getParam
<
Scalar
>
(
"TimeLoop.TEnd"
);
const
auto
maxDt
=
getParam
<
Scalar
>
(
"TimeLoop.MaxTimeStepSize"
);
auto
dt
=
getParam
<
Scalar
>
(
"TimeLoop.DtInitial"
);
// intialize the vtk output module
using
VtkOutputFields
=
typename
GET_PROP_TYPE
(
TypeTag
,
VtkOutputFields
);
VtkOutputModule
<
TypeTag
>
vtkWriter
(
*
problem
,
*
fvGridGeometry
,
*
gridVariables
,
x
,
problem
->
name
());
VtkOutputFields
::
init
(
vtkWriter
);
//! Add model specific output fields
// instantiate time loop
auto
timeLoop
=
std
::
make_shared
<
TimeLoop
<
Scalar
>>
(
0.0
,
dt
,
tEnd
);
timeLoop
->
setMaxTimeStepSize
(
maxDt
);
// the assembler with time loop for instationary problem
using
Assembler
=
FVAssembler
<
TypeTag
,
DiffMethod
::
numeric
>
;
auto
assembler
=
std
::
make_shared
<
Assembler
>
(
problem
,
fvGridGeometry
,
gridVariables
,
timeLoop
);
// the linear solver
using
LinearSolver
=
AMGBackend
<
TypeTag
>
;
auto
linearSolver
=
std
::
make_shared
<
LinearSolver
>
(
leafGridView
,
fvGridGeometry
->
dofMapper
());
// the non-linear solver
using
NewtonSolver
=
Dumux
::
NewtonSolver
<
Assembler
,
LinearSolver
>
;
NewtonSolver
nonLinearSolver
(
assembler
,
linearSolver
);
// time loop
timeLoop
->
start
();
while
(
!
timeLoop
->
finished
())
{
// set previous solution for storage evaluations
assembler
->
setPreviousSolution
(
xOld
);
//set time in problem (is used in time-dependent Neumann boundary condition)
problem
->
setTime
(
timeLoop
->
time
()
+
timeLoop
->
timeStepSize
());
// 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
();
// report statistics of this time step
timeLoop
->
reportTimeStep
();
// set new dt as suggested by the newton solver
timeLoop
->
setTimeStepSize
(
nonLinearSolver
.
suggestTimeStepSize
(
timeLoop
->
timeStepSize
()));
// output to vtk
vtkWriter
.
write
(
timeLoop
->
time
());
}
timeLoop
->
finalize
(
leafGridView
.
comm
());
////////////////////////////////////////////////////////////
// finalize, print dumux message to say goodbye
////////////////////////////////////////////////////////////
// print dumux end message
if
(
mpiHelper
.
rank
()
==
0
)
{
Parameters
::
print
();
DumuxMessage
::
print
(
/*firstCall=*/
false
);
}
return
0
;
}
// end main
catch
(
Dumux
::
ParameterException
&
e
)
{
std
::
cerr
<<
std
::
endl
<<
e
<<
" ---> Abort!"
<<
std
::
endl
;
return
1
;
}
catch
(
Dune
::
DGFException
&
e
)
{
std
::
cerr
<<
"DGF exception thrown ("
<<
e
<<
"). Most likely, the DGF file name is wrong "
"or the DGF file is corrupted, "
"e.g. missing hash at end of file or wrong number (dimensions) of entries."
<<
" ---> Abort!"
<<
std
::
endl
;
return
2
;
}
catch
(
Dune
::
Exception
&
e
)
{
std
::
cerr
<<
"Dune reported error: "
<<
e
<<
" ---> Abort!"
<<
std
::
endl
;
return
3
;
}
catch
(...)
{
std
::
cerr
<<
"Unknown exception thrown! ---> Abort!"
<<
std
::
endl
;
return
4
;
}
This diff is collapsed.
Click to expand it.
exercises/extradoc/exercise1_setup.png
+
0
−
0
View replaced file @
40b4eb2a
View file @
655918b0
56.8 KiB
|
W:
|
H:
55.4 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
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