Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-fu-tutorial
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
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
graeser
dune-fu-tutorial
Commits
92e90f53
Commit
92e90f53
authored
8 years ago
by
graeser
Browse files
Options
Downloads
Patches
Plain Diff
Add example files
parent
4e1e4998
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/01-basic-application.cc
+43
-0
43 additions, 0 deletions
src/01-basic-application.cc
src/02-basic-grid-interface.cc
+80
-0
80 additions, 0 deletions
src/02-basic-grid-interface.cc
src/CMakeLists.txt
+6
-0
6 additions, 0 deletions
src/CMakeLists.txt
with
129 additions
and
0 deletions
src/01-basic-application.cc
0 → 100644
+
43
−
0
View file @
92e90f53
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
// included standard library headers
#include
<iostream>
// included dune-common headers
#include
<dune/common/parallel/mpihelper.hh>
#include
<dune/common/exceptions.hh>
int
main
(
int
argc
,
char
**
argv
)
{
try
{
// Maybe initialize MPI
Dune
::
MPIHelper
&
helper
=
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
// Print process rank
if
(
Dune
::
MPIHelper
::
isFake
)
std
::
cout
<<
"This is a sequential program."
<<
std
::
endl
;
else
std
::
cout
<<
"I am rank "
<<
helper
.
rank
()
<<
" of "
<<
helper
.
size
()
<<
" processes!"
<<
std
::
endl
;
// Do nothing
return
0
;
}
catch
(
Dune
::
Exception
&
e
){
std
::
cerr
<<
"Dune reported error: "
<<
e
<<
std
::
endl
;
}
catch
(...){
std
::
cerr
<<
"Unknown exception thrown!"
<<
std
::
endl
;
}
}
This diff is collapsed.
Click to expand it.
src/02-basic-grid-interface.cc
0 → 100644
+
80
−
0
View file @
92e90f53
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
// included standard library headers
#include
<iostream>
#include
<array>
// included dune-common headers
#include
<dune/common/parallel/mpihelper.hh>
#include
<dune/common/exceptions.hh>
#include
<dune/common/fvector.hh>
// included dune-grid headers
#include
<dune/grid/yaspgrid.hh>
#include
<dune/grid/io/file/vtk/vtkwriter.hh>
int
main
(
int
argc
,
char
**
argv
)
{
try
{
// Maybe initialize MPI
Dune
::
MPIHelper
&
helper
=
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
// Print process rank
if
(
Dune
::
MPIHelper
::
isFake
)
std
::
cout
<<
"This is a sequential program."
<<
std
::
endl
;
else
std
::
cout
<<
"I am rank "
<<
helper
.
rank
()
<<
" of "
<<
helper
.
size
()
<<
" processes!"
<<
std
::
endl
;
// fix grid dimension
const
int
dim
=
2
;
// use the YaspGrid implementation
// YaspGrid = "Yet another structured parallel grid"
using
Grid
=
Dune
::
YaspGrid
<
dim
>
;
// extension of the domain [0,l]
Dune
::
FieldVector
<
double
,
dim
>
l
(
1
);
// start with 10x10x... elements
std
::
array
<
int
,
dim
>
E
;
for
(
auto
&
e
:
E
)
e
=
2
;
Grid
grid
(
l
,
E
);
// grid.globalRefine(2);
auto
gridView
=
grid
.
leafGridView
();
int
i
=
0
;
for
(
const
auto
&
e
:
Dune
::
elements
(
gridView
))
{
++
i
;
std
::
cout
<<
e
.
geometry
().
center
()
<<
std
::
endl
;
}
std
::
cout
<<
i
<<
std
::
endl
;
using
GridView
=
decltype
(
gridView
);
Dune
::
VTKWriter
<
GridView
>
vtkWriter
(
gridView
);
vtkWriter
.
write
(
"01-refined-grid"
);
return
0
;
}
catch
(
Dune
::
Exception
&
e
){
std
::
cerr
<<
"Dune reported error: "
<<
e
<<
std
::
endl
;
}
catch
(...){
std
::
cerr
<<
"Unknown exception thrown!"
<<
std
::
endl
;
}
}
This diff is collapsed.
Click to expand it.
src/CMakeLists.txt
+
6
−
0
View file @
92e90f53
add_executable
(
"dune-fu-tutorial"
dune-fu-tutorial.cc
)
target_link_dune_default_libraries
(
"dune-fu-tutorial"
)
add_executable
(
"01-basic-application"
01-basic-application.cc
)
target_link_dune_default_libraries
(
"01-basic-application"
)
add_executable
(
"02-basic-grid-interface"
02-basic-grid-interface.cc
)
target_link_dune_default_libraries
(
"02-basic-grid-interface"
)
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