Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gdt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
ag-ohlberger
dune-community
dune-gdt
Commits
bdba2b1e
Commit
bdba2b1e
authored
4 years ago
by
Dr. Felix Tobias Schindler
Committed by
Tobias Leibner
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[P] allow to visualize 1d functions
parent
79a4ea7e
No related branches found
No related tags found
1 merge request
!10
Draft: consolidate refactoring work
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/dune/gdt/__init__.py
+33
-15
33 additions, 15 deletions
python/dune/gdt/__init__.py
with
33 additions
and
15 deletions
python/dune/gdt/__init__.py
+
33
−
15
View file @
bdba2b1e
...
...
@@ -85,20 +85,38 @@ for mod_name in ( # order should not matter!
def
visualize_function
(
function
,
grid
=
None
,
subsampling
=
False
):
assert
function
.
dim_domain
==
2
,
f
'
Not implemented yet for
{
function
.
dim_domain
}
-dimensional grids!
'
assert
function
.
dim_range
==
1
,
f
'
Not implemented yet for
{
function
.
dim_domain
}
-dimensional functions!
'
tmpfile
=
NamedTemporaryFile
(
mode
=
'
wb
'
,
delete
=
False
,
suffix
=
'
.vtu
'
).
name
failed
=
False
try
:
# discrete function
function
.
visualize
(
filename
=
tmpfile
[:
-
4
])
return
plot
(
tmpfile
,
color_attribute_name
=
function
.
name
)
except
TypeError
:
failed
=
True
except
AttributeError
:
failed
=
True
assert
function
.
dim_domain
<=
2
,
f
'
Not implemented yet for
{
function
.
dim_domain
}
-dimensional grids!
'
if
function
.
dim_domain
==
1
:
import
numpy
as
np
from
matplotlib
import
pyplot
as
plt
from
dune.xt.functions
import
GridFunction
from
dune.gdt
import
ContinuousLagrangeSpace
,
default_interpolation
,
DiscreteFunction
if
failed
:
from
dune.xt.functions
import
visualize_function
as
visualize_xt_function
assert
grid
# not optimal
P1_space
=
ContinuousLagrangeSpace
(
grid
,
order
=
1
)
interpolation_points
=
np
.
array
(
P1_space
.
interpolation_points
(),
copy
=
False
)[:,
0
]
piecewise_linear_interpolant
=
default_interpolation
(
GridFunction
(
grid
,
function
),
P1_space
)
values
=
np
.
array
(
piecewise_linear_interpolant
.
dofs
.
vector
,
copy
=
False
)
assert
grid
return
visualize_xt_function
(
function
,
grid
,
subsampling
=
subsampling
)
plt
.
figure
()
plt
.
title
(
f
'
{
function
.
name
}
'
)
plt
.
plot
(
interpolation_points
,
values
)
return
plt
.
gca
()
elif
function
.
dim_domain
==
2
:
assert
function
.
dim_range
==
1
,
f
'
Not implemented yet for
{
function
.
dim_domain
}
-dimensional functions!
'
tmpfile
=
NamedTemporaryFile
(
mode
=
'
wb
'
,
delete
=
False
,
suffix
=
'
.vtu
'
).
name
failed
=
False
try
:
# discrete function
function
.
visualize
(
filename
=
tmpfile
[:
-
4
])
return
plot
(
tmpfile
,
color_attribute_name
=
function
.
name
)
except
TypeError
:
failed
=
True
except
AttributeError
:
failed
=
True
if
failed
:
from
dune.xt.functions
import
visualize_function
as
visualize_xt_function
assert
grid
return
visualize_xt_function
(
function
,
grid
,
subsampling
=
subsampling
)
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