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
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
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
agnumpde
dune-tectonic
Commits
95d0d1f4
Commit
95d0d1f4
authored
13 years ago
by
Elias Pipping
Committed by
Elias Pipping
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Control Neumann boundary conditions through python
parent
aa1bc668
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/Makefile.am
+5
-2
5 additions, 2 deletions
src/Makefile.am
src/one-body-sample.cc
+31
-7
31 additions, 7 deletions
src/one-body-sample.cc
src/one-body-sample_neumann.py
+13
-0
13 additions, 0 deletions
src/one-body-sample_neumann.py
with
49 additions
and
9 deletions
src/Makefile.am
+
5
−
2
View file @
95d0d1f4
...
@@ -51,6 +51,7 @@ AM_CXXFLAGS = \
...
@@ -51,6 +51,7 @@ AM_CXXFLAGS = \
AM_CPPFLAGS
=
\
AM_CPPFLAGS
=
\
$(
DUNE_CPPFLAGS
)
\
$(
DUNE_CPPFLAGS
)
\
$(
PYTHON_CPPFLAGS
)
\
-I
$(
top_srcdir
)
-I
$(
top_srcdir
)
# The libraries have to be given in reverse order (most basic libraries
# The libraries have to be given in reverse order (most basic libraries
...
@@ -58,9 +59,11 @@ AM_CPPFLAGS = \
...
@@ -58,9 +59,11 @@ AM_CPPFLAGS = \
# -L option in LDFLAGS instead of LIBS -- so we have to include the LDFLAGS
# -L option in LDFLAGS instead of LIBS -- so we have to include the LDFLAGS
# here as well.
# here as well.
LDADD
=
\
LDADD
=
\
$(
DUNE_LDFLAGS
)
$(
DUNE_LIBS
)
$(
DUNE_LDFLAGS
)
$(
DUNE_LIBS
)
\
$(
PYTHON_LIBS
)
AM_LDFLAGS
=
\
AM_LDFLAGS
=
\
$(
DUNE_LDFLAGS
)
$(
DUNE_LDFLAGS
)
\
$(
PYTHON_LDFLAGS
)
# don't follow the full GNU-standard
# don't follow the full GNU-standard
# we need automake 1.5
# we need automake 1.5
...
...
This diff is collapsed.
Click to expand it.
src/one-body-sample.cc
+
31
−
7
View file @
95d0d1f4
...
@@ -10,11 +10,17 @@
...
@@ -10,11 +10,17 @@
#undef HAVE_IPOPT
#undef HAVE_IPOPT
#endif
#endif
#ifndef HAVE_PYTHON
#error Python is required
#endif
#include
<exception>
#include
<exception>
#include
<iostream>
#include
<iostream>
#include
<boost/format.hpp>
#include
<boost/format.hpp>
#include
<Python.h>
#include
<cmath>
#include
<cmath>
#include
"LambertW.h"
#include
"LambertW.h"
...
@@ -42,11 +48,13 @@
...
@@ -42,11 +48,13 @@
#include
<dune/fufem/assemblers/operatorassembler.hh>
#include
<dune/fufem/assemblers/operatorassembler.hh>
#include
<dune/fufem/assemblers/transferoperatorassembler.hh>
#include
<dune/fufem/assemblers/transferoperatorassembler.hh>
#include
<dune/fufem/boundarypatch.hh>
#include
<dune/fufem/boundarypatch.hh>
#include
<dune/fufem/dunepython.hh>
#include
<dune/fufem/functions/basisgridfunction.hh>
#include
<dune/fufem/functions/basisgridfunction.hh>
#include
<dune/fufem/functions/constantfunction.hh>
#include
<dune/fufem/functions/constantfunction.hh>
#include
<dune/fufem/functions/vtkbasisgridfunction.hh>
#include
<dune/fufem/functions/vtkbasisgridfunction.hh>
#include
<dune/fufem/functionspacebases/p0basis.hh>
#include
<dune/fufem/functionspacebases/p0basis.hh>
#include
<dune/fufem/functionspacebases/p1nodalbasis.hh>
#include
<dune/fufem/functionspacebases/p1nodalbasis.hh>
#include
<dune/fufem/sharedpointermap.hh>
#include
<dune/solvers/common/numproc.hh>
// Solver::FULL
#include
<dune/solvers/common/numproc.hh>
// Solver::FULL
#include
<dune/solvers/iterationsteps/blockgsstep.hh>
#include
<dune/solvers/iterationsteps/blockgsstep.hh>
#include
<dune/solvers/iterationsteps/multigridstep.hh>
#include
<dune/solvers/iterationsteps/multigridstep.hh>
...
@@ -108,12 +116,12 @@ template <class GridType, class GridView, class LocalVectorType, class FEBasis>
...
@@ -108,12 +116,12 @@ template <class GridType, class GridView, class LocalVectorType, class FEBasis>
void
assemble_neumann
(
GridView
const
&
gridView
,
FEBasis
const
&
feBasis
,
void
assemble_neumann
(
GridView
const
&
gridView
,
FEBasis
const
&
feBasis
,
Dune
::
BitSetVector
<
1
>
const
&
neumannNodes
,
Dune
::
BitSetVector
<
1
>
const
&
neumannNodes
,
Dune
::
BlockVector
<
LocalVectorType
>
&
f
,
Dune
::
BlockVector
<
LocalVectorType
>
&
f
,
Dune
::
VirtualFunction
<
double
,
double
>
const
&
neumann
,
double
time
)
{
// constant sample function on neumann
double
time
)
{
// constant sample function on neumann
// boundary
// boundary
BoundaryPatch
<
GridView
>
const
neumannBoundary
(
gridView
,
neumannNodes
);
BoundaryPatch
<
GridView
>
const
neumannBoundary
(
gridView
,
neumannNodes
);
LocalVectorType
SampleVector
(
0
);
LocalVectorType
SampleVector
(
0
);
// FIXME: random values (time-dependent)
neumann
.
evaluate
(
time
,
SampleVector
[
0
]);
SampleVector
[
0
]
=
(
time
<=
0.5
)
?
sin
(
time
*
2
*
M_PI
)
:
(
time
-
0.5
)
*
2
;
SampleVector
[
1
]
=
0
;
SampleVector
[
1
]
=
0
;
ConstantFunction
<
LocalVectorType
,
LocalVectorType
>
const
fNeumann
(
ConstantFunction
<
LocalVectorType
,
LocalVectorType
>
const
fNeumann
(
SampleVector
);
SampleVector
);
...
@@ -225,6 +233,20 @@ double compute_state_update_lambert(double h, double unorm, double L,
...
@@ -225,6 +233,20 @@ double compute_state_update_lambert(double h, double unorm, double L,
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
try
{
typedef
SharedPointerMap
<
std
::
string
,
Dune
::
VirtualFunction
<
double
,
double
>>
FunctionMap
;
FunctionMap
functions
;
{
Python
::
start
();
Python
::
run
(
"import sys"
);
Python
::
run
(
"sys.path.append('"
srcdir
"')"
);
Python
::
import
(
"one-body-sample_neumann"
)
.
get
(
"Functions"
)
.
toC
<
FunctionMap
::
Base
>
(
functions
);
}
Dune
::
ParameterTree
parset
;
Dune
::
ParameterTree
parset
;
Dune
::
ParameterTreeParser
::
readINITree
(
srcdir
"/one-body-sample.parset"
,
Dune
::
ParameterTreeParser
::
readINITree
(
srcdir
"/one-body-sample.parset"
,
parset
);
// FIXME
parset
);
// FIXME
...
@@ -380,7 +402,8 @@ int main(int argc, char *argv[]) {
...
@@ -380,7 +402,8 @@ int main(int argc, char *argv[]) {
// b = neumann
// b = neumann
assemble_neumann
<
GridType
,
GridView
,
SmallVector
,
P1Basis
>
(
assemble_neumann
<
GridType
,
GridView
,
SmallVector
,
P1Basis
>
(
leafView
,
p1Basis
,
neumannNodes
,
b1
,
h
*
run
);
leafView
,
p1Basis
,
neumannNodes
,
b1
,
functions
.
get
(
"sampleFunction"
),
h
*
run
);
b2
=
b1
;
b2
=
b1
;
b3
=
b1
;
b3
=
b1
;
b4
=
b1
;
b4
=
b1
;
...
@@ -472,10 +495,10 @@ int main(int argc, char *argv[]) {
...
@@ -472,10 +495,10 @@ int main(int argc, char *argv[]) {
"%|40t|u[%03d] = %+3e"
);
"%|40t|u[%03d] = %+3e"
);
std
::
cout
<<
boost
::
format
(
formatter
)
%
run
%
(
*
s4_new
)[
i
]
%
run
%
u4
[
i
]
std
::
cout
<<
boost
::
format
(
formatter
)
%
run
%
(
*
s4_new
)[
i
]
%
run
%
u4
[
i
]
<<
std
::
endl
;
<<
std
::
endl
;
// FIXME: (Duplicate!) Magic values
double
out
;
octave_writer
<<
(
*
s4_new
)[
i
]
<<
" "
<<
u4
[
i
][
0
]
*
1e6
<<
" "
functions
.
get
(
"sampleFunction"
).
evaluate
(
h
*
run
,
out
);
<<
((
h
*
run
<=
0.5
)
?
sin
(
h
*
run
*
2
*
M_PI
)
octave_writer
<<
(
*
s4_new
)[
i
]
<<
" "
<<
u4
[
i
][
0
]
*
1e6
<<
" "
<<
out
:
(
h
*
run
-
0.5
)
*
2
)
<<
std
::
endl
;
<<
std
::
endl
;
break
;
break
;
}
}
...
@@ -573,6 +596,7 @@ int main(int argc, char *argv[]) {
...
@@ -573,6 +596,7 @@ int main(int argc, char *argv[]) {
std
::
cout
<<
boost
::
format
(
formatter
)
%
i
%
u1
[
i
]
%
i
%
u2
[
i
]
%
i
%
std
::
cout
<<
boost
::
format
(
formatter
)
%
i
%
u1
[
i
]
%
i
%
u2
[
i
]
%
i
%
u3
[
i
]
%
i
%
u4
[
i
]
<<
std
::
endl
;
u3
[
i
]
%
i
%
u4
[
i
]
<<
std
::
endl
;
}
}
Python
::
stop
();
}
}
catch
(
Dune
::
Exception
&
e
)
{
catch
(
Dune
::
Exception
&
e
)
{
Dune
::
derr
<<
"Dune reported error: "
<<
e
<<
std
::
endl
;
Dune
::
derr
<<
"Dune reported error: "
<<
e
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
src/one-body-sample_neumann.py
0 → 100644
+
13
−
0
View file @
95d0d1f4
class
sampleFunction
:
def
__call__
(
self
,
x
):
fst
=
0.3
snd
=
0.1
trd
=
0.3
if
x
<
1.0
/
3
:
return
fst
*
x
elif
x
<
2.0
/
3
:
return
snd
*
(
x
-
1.0
/
3
)
+
fst
*
1.0
/
3
else
:
return
trd
*
(
x
-
2.0
/
3
)
+
(
fst
+
snd
)
*
1.0
/
3
Functions
=
{
'
sampleFunction
'
:
sampleFunction
()}
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