Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F68921083
fenics_serial.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 29, 12:06
Size
1 KB
Mime Type
text/x-python
Expires
Mon, Jul 1, 12:06 (2 d)
Engine
blob
Format
Raw Data
Handle
18523038
Attached To
R6746 RationalROMPy
fenics_serial.py
View Options
# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
from
os
import
remove
import
fenics
as
fen
from
rrompy.utilities.base.data_structures
import
getNewFilename
from
rrompy.utilities.parallel
import
SELF
__all__
=
[
'serializeMesh'
,
'serializeFunctionSpace'
]
def
serializeMesh
(
mesh
):
mesh_comm
=
mesh
.
mpi_comm
()
if
mesh_comm
.
size
==
1
:
return
mesh
if
mesh_comm
.
Get_rank
()
==
0
:
filename
=
getNewFilename
(
"mesh"
,
"h5"
,
False
)
else
:
filename
=
None
filename
=
mesh_comm
.
bcast
(
filename
,
root
=
0
)
fout
=
fen
.
HDF5File
(
mesh_comm
,
filename
,
"w"
)
fout
.
write
(
mesh
,
"mesh"
)
fout
.
close
()
del
fout
mesh_comm
.
Barrier
()
fin
=
fen
.
HDF5File
(
SELF
,
filename
,
"r"
)
meshS
=
fen
.
Mesh
(
SELF
)
fin
.
read
(
meshS
,
"mesh"
,
False
)
fin
.
close
()
del
fin
mesh_comm
.
Barrier
()
if
mesh_comm
.
Get_rank
()
==
0
:
remove
(
filename
)
return
meshS
def
serializeFunctionSpace
(
space
):
return
fen
.
FunctionSpace
(
serializeMesh
(
space
.
mesh
()),
space
.
ufl_element
(),
constrained_domain
=
space
.
dofmap
()
.
constrained_domain
)
Event Timeline
Log In to Comment