Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61091600
all_forcing_engine.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, May 4, 11:52
Size
2 KB
Mime Type
text/x-python
Expires
Mon, May 6, 11:52 (2 d)
Engine
blob
Format
Raw Data
Handle
17463871
Attached To
R6746 RationalROMPy
all_forcing_engine.py
View Options
import
numpy
as
np
import
fenics
as
fen
from
rrompy.hfengines.linear_problem
import
LaplaceBaseProblemEngine
as
LBPE
from
rrompy.utilities.base
import
verbosityManager
as
vbMng
from
rrompy.solver.fenics
import
fenics2Vector
class
AllForcingEngine
(
LBPE
):
def
__init__
(
self
,
mu0
:
float
,
n
:
int
=
30
,
degree_threshold
:
int
=
np
.
inf
,
verbosity
:
int
=
10
,
timestamp
:
bool
=
True
):
super
()
.
__init__
(
mu0
=
mu0
,
degree_threshold
=
degree_threshold
,
homogeneized
=
False
,
verbosity
=
verbosity
,
timestamp
=
timestamp
)
mesh
=
fen
.
RectangleMesh
(
fen
.
Point
(
-
5.
,
-
5.
),
fen
.
Point
(
5.
,
5.
),
n
,
n
)
self
.
V
=
fen
.
FunctionSpace
(
mesh
,
"P"
,
1
)
self
.
nAs
,
self
.
nbs
=
1
,
4
x
,
y
=
fen
.
SpatialCoordinate
(
mesh
)[:]
scaling
=
(
2.
*
np
.
pi
)
**
-
1.
r2
=
x
**
2.
+
y
**
2.
self
.
forcingCoeffs
=
[
scaling
*
fen
.
exp
(
-
(
r2
+
1.
-
2.
*
x
+
1.
-
2.
*
y
)
/
2.
/
4.
)
/
2.
,
scaling
*
fen
.
exp
(
-
(
r2
+
1.
+
2.
*
x
+
1.
+
2.
*
y
)
/
2.
/
16.
)
/
4.
,
-
scaling
*
fen
.
exp
(
-
(
r2
+
1.
+
2.
*
x
+
1.
-
2.
*
y
)
/
2.
/
9.
)
/
30.
,
scaling
*
fen
.
exp
(
-
(
r2
+
1.
-
2.
*
x
+
1.
+
2.
*
y
)
/
2.
/
25.
)
/
120.
]
def
buildb
(
self
):
"""Build terms of operator of linear system."""
if
self
.
thbs
[
0
]
is
None
:
self
.
thbs
=
(
self
.
getMonomialWeights
(
self
.
nbs
)
+
[
None
]
*
(
self
.
homogeneized
*
self
.
nAs
))
for
j
in
range
(
self
.
nbs
):
if
self
.
bs
[
j
]
is
None
:
vbMng
(
self
,
"INIT"
,
"Assembling forcing term b{}."
.
format
(
j
),
20
)
parsRe
=
self
.
iterReduceQuadratureDegree
([(
self
.
forcingCoeffs
[
j
],
"forcingCoefficient"
)])
u0Re
=
self
.
DirichletDatum
[
0
]
L0Re
=
fen
.
dot
(
self
.
forcingCoeffs
[
j
],
self
.
v
)
*
fen
.
dx
DBCR
=
fen
.
DirichletBC
(
self
.
V
,
u0Re
,
self
.
DirichletBoundary
)
self
.
bs
[
j
]
=
fenics2Vector
(
L0Re
,
parsRe
,
DBCR
,
1
)
vbMng
(
self
,
"DEL"
,
"Done assembling forcing term."
,
20
)
self
.
setbHomogeneized
()
Event Timeline
Log In to Comment