Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80587276
fenics_norms.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
Sun, Sep 1, 13:05
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Sep 3, 13:05 (2 d)
Engine
blob
Format
Raw Data
Handle
20402164
Attached To
R6746 RationalROMPy
fenics_norms.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/>.
#
import
fenics
as
fen
from
rrompy.utilities.base.types
import
Np2D
,
FenFunc
,
FenFuncSpace
from
scipy.sparse
import
csr_matrix
__all__
=
[
'L2NormMatrix'
,
'H1NormMatrix'
,
'elasticNormMatrix'
]
def
_fen2sp
(
expr
):
matFen
=
fen
.
as_backend_type
(
fen
.
assemble
(
expr
))
.
mat
()
return
csr_matrix
(
matFen
.
getValuesCSR
()[::
-
1
],
shape
=
matFen
.
size
)
def
L2NormMatrix
(
V
:
FenFuncSpace
)
->
Np2D
:
u
=
fen
.
TrialFunction
(
V
)
v
=
fen
.
TestFunction
(
V
)
return
_fen2sp
(
fen
.
dot
(
u
,
v
)
*
fen
.
dx
)
def
H1NormMatrix
(
V
:
FenFuncSpace
,
w
:
FenFunc
=
0.
)
->
Np2D
:
u
=
fen
.
TrialFunction
(
V
)
v
=
fen
.
TestFunction
(
V
)
return
_fen2sp
((
w
*
fen
.
dot
(
u
,
v
)
+
fen
.
dot
(
fen
.
grad
(
u
),
fen
.
grad
(
v
)))
*
fen
.
dx
)
def
elasticNormMatrix
(
V
:
FenFuncSpace
,
l_
:
FenFunc
,
m_
:
FenFunc
,
w
:
FenFunc
=
0.
)
->
Np2D
:
u
=
fen
.
TrialFunction
(
V
)
v
=
fen
.
TestFunction
(
V
)
epsilon
=
lambda
f
:
0.5
*
(
fen
.
grad
(
f
)
+
fen
.
nabla_grad
(
f
))
sigma
=
(
l_
*
fen
.
div
(
u
)
*
fen
.
Identity
(
u
.
geometric_dimension
())
+
2.
*
m_
*
epsilon
(
u
))
return
_fen2sp
((
w
*
fen
.
dot
(
u
,
v
)
+
fen
.
inner
(
sigma
,
epsilon
(
v
)))
*
fen
.
dx
)
Event Timeline
Log In to Comment