Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frap Theory
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
hubatsch
Frap Theory
Commits
ea36c41a
Commit
ea36c41a
authored
4 years ago
by
Lars Hubatsch
Browse files
Options
Downloads
Patches
Plain Diff
Adding save and load functions for dolfin functions.
parent
d2407b64
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fem_sol.py
+4
-1
4 additions, 1 deletion
fem_sol.py
fem_utils.py
+17
-0
17 additions, 0 deletions
fem_utils.py
with
21 additions
and
1 deletion
fem_sol.py
+
4
−
1
View file @
ea36c41a
# Customized FEM solver for FRAP theory
from
dolfin
import
*
import
fem_utils
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
time
...
...
@@ -49,6 +50,7 @@ class frap_solver:
self
.
cs
=
[]
# Intensity profiles over time
def
solve_frap
(
self
):
'''
Solver routine
...
...
@@ -87,7 +89,8 @@ class frap_solver:
ti
=
time
.
time
()
for
i
in
range
(
self
.
T
):
self
.
cs
.
append
([
Phi_u
([
x
,
self
.
cent_poin
[
1
],
self
.
cent_poin
[
2
]])
fem_utils
.
save_time_point
(
Phi_u0
,
self
.
name
+
'
t_p_
'
+
str
(
i
)
+
'
.h5
'
)
self
.
cs
.
append
([
Phi_u0
([
x
,
self
.
cent_poin
[
1
],
self
.
cent_poin
[
2
]])
for
x
in
np
.
linspace
(
4
,
4.5
,
100
)])
solve
(
Form
==
0
,
Phi_u
)
assign
(
Phi_u0
,
Phi_u
)
...
...
This diff is collapsed.
Click to expand it.
fem_utils.py
+
17
−
0
View file @
ea36c41a
...
...
@@ -2,6 +2,7 @@
Utilities for simplifying FEM modelling, e.g. Meshes.
'''
from
dolfin
import
*
import
meshio
import
numpy
as
np
...
...
@@ -107,3 +108,19 @@ def convert_msh_to_xdmf(input_path, output_path):
cell_data
=
{
"
name_to_read
"
:[
line_data
]})
meshio
.
write
(
output_path
,
tetra_mesh
)
def
save_time_point
(
f
,
name
):
'''
Save Fenics function to h5 file.
'''
fFile
=
HDF5File
(
MPI
.
comm_world
,
name
,
"
w
"
)
fFile
.
write
(
f
,
"
/f
"
)
fFile
.
close
()
def
load_time_point
(
name
,
mesh
):
'''
Load Fenics function from h5 file.
'''
V
=
FunctionSpace
(
mesh
,
'
CG
'
,
1
)
f
=
Function
(
V
)
fFile
=
HDF5File
(
MPI
.
comm_world
,
name
,
"
r
"
)
fFile
.
read
(
f
,
"
/f
"
)
fFile
.
close
()
return
f
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