Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
getdp
cim
Commits
8ec7621f
Commit
8ec7621f
authored
7 years ago
by
Nicolas Marsic
Browse files
Options
Downloads
Patches
Plain Diff
Start to reuse LU in a GetDP way...
WARNING: change in the GetDP .pro file interface!
parent
df4c533c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/beyn.py
+8
-11
8 additions, 11 deletions
bin/beyn.py
bin/solver.py
+31
-18
31 additions, 18 deletions
bin/solver.py
example/maxwell_linear/maxwell.pro
+25
-10
25 additions, 10 deletions
example/maxwell_linear/maxwell.pro
with
64 additions
and
39 deletions
bin/beyn.py
+
8
−
11
View file @
8ec7621f
...
@@ -101,7 +101,7 @@ def simple(operator, origin, radius,
...
@@ -101,7 +101,7 @@ def simple(operator, origin, radius,
norm
=
np
.
empty
((
nFound
))
norm
=
np
.
empty
((
nFound
))
for
i
in
range
(
nFound
):
for
i
in
range
(
nFound
):
operator
.
apply
(
Q
[:,
i
],
myLambda
[
i
])
# Apply eigenpair
operator
.
apply
(
Q
[:,
i
],
myLambda
[
i
])
# Apply eigenpair
r
=
operator
.
solution
()
# Get residual
r
=
operator
.
solution
(
0
)
# Get residual
norm
[
i
]
=
np
.
linalg
.
norm
(
r
)
# Save the norm
norm
[
i
]
=
np
.
linalg
.
norm
(
r
)
# Save the norm
# Done
# Done
...
@@ -174,18 +174,15 @@ def multiSolve(solver, B, w):
...
@@ -174,18 +174,15 @@ def multiSolve(solver, B, w):
w -- the complex frequency to use
w -- the complex frequency to use
"""
"""
#
Number of s
olve
#
S
olve
nS
olve
=
B
.
shape
[
1
]
s
olve
r
.
solve
(
B
,
w
)
# Initialise X
# Get solutions
nSolve
=
B
.
shape
[
1
]
size
=
solver
.
size
()
size
=
solver
.
size
()
X
=
np
.
matlib
.
empty
((
size
,
nSolve
),
dtype
=
complex
)
X
=
np
.
matlib
.
empty
((
size
,
nSolve
),
dtype
=
complex
)
# Loop and solve
for
i
in
range
(
nSolve
):
for
i
in
range
(
nSolve
):
b
=
B
[:,
i
]
X
[:,
i
]
=
solver
.
solution
(
i
)
solver
.
solve
(
b
,
w
)
X
[:,
i
]
=
solver
.
solution
()
# Done
# Done
return
X
return
X
...
...
This diff is collapsed.
Click to expand it.
bin/solver.py
+
31
−
18
View file @
8ec7621f
...
@@ -18,11 +18,13 @@ class GetDPWave:
...
@@ -18,11 +18,13 @@ class GetDPWave:
The .pro file should use the following variables:
The .pro file should use the following variables:
angularFreqRe -- the real part of the angular frequency to use
angularFreqRe -- the real part of the angular frequency to use
angularFreqIm -- the imaginary part of the angular frequency to use
angularFreqIm -- the imaginary part of the angular frequency to use
b -- the right hand side (RHS) to use
nRHS -- the number of right hand side that should be considered (default: 1)
x -- the solution vector computed by GetDP
b_i / b~{i} -- the ith right hand side to use (first index is 0)
imposeRHS -- should the imposed RHS be taken into account?
x_i / x~{i} -- the ith solution vector computed by GetDP (first index is 0)
doPostpro -- should only a view be created for x?
doInit -- should some initialization be done (default: 0)?
doApply -- should only the application of x be computed?
doSolve -- should Ax_i = b_i be solved for all i (default: 0)?
doPostpro -- should only a view be created for x (default: 0)?
doApply -- should only the application of x be computed (default: 0)?
fileName -- post-processing file name
fileName -- post-processing file name
"""
"""
...
@@ -44,19 +46,20 @@ class GetDPWave:
...
@@ -44,19 +46,20 @@ class GetDPWave:
self
.
__resolution
=
resolution
self
.
__resolution
=
resolution
self
.
__optional
=
optional
self
.
__optional
=
optional
# Generate DoFs and initialise RHS and solution vectors in GetDP
# Generate DoFs and assemble a first system
GetDP
.
GetDPSetNumber
(
"
doInit
"
,
1
);
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
"
-msh
"
,
self
.
__mesh
,
"
-msh
"
,
self
.
__mesh
,
"
-solve
"
,
self
.
__resolution
,
"
-solve
"
,
self
.
__resolution
,
"
-v
"
,
"
2
"
]
+
self
.
__optional
)
"
-v
"
,
"
2
"
]
+
self
.
__optional
)
def
solution
(
self
):
def
solution
(
self
,
i
):
"""
Returns the solution
"""
"""
Returns the solution
for the ith RHS (first index is 0)
"""
return
self
.
__toNumpy
(
GetDP
.
GetDPGetNumber
(
"
x
"
))
return
self
.
__toNumpy
(
GetDP
.
GetDPGetNumber
(
"
x
_
"
+
str
(
i
)
))
def
size
(
self
):
def
size
(
self
):
"""
Returns the number of degrees of freedom
"""
"""
Returns the number of degrees of freedom
"""
return
self
.
solution
().
shape
[
0
]
return
self
.
solution
(
0
).
shape
[
0
]
def
apply
(
self
,
x
,
w
):
def
apply
(
self
,
x
,
w
):
"""
Applies x to the operator with a pulsation of w
"""
Applies x to the operator with a pulsation of w
...
@@ -65,23 +68,34 @@ class GetDPWave:
...
@@ -65,23 +68,34 @@ class GetDPWave:
"""
"""
GetDP
.
GetDPSetNumber
(
"
angularFreqRe
"
,
np
.
real
(
w
).
tolist
())
GetDP
.
GetDPSetNumber
(
"
angularFreqRe
"
,
np
.
real
(
w
).
tolist
())
GetDP
.
GetDPSetNumber
(
"
angularFreqIm
"
,
np
.
imag
(
w
).
tolist
())
GetDP
.
GetDPSetNumber
(
"
angularFreqIm
"
,
np
.
imag
(
w
).
tolist
())
GetDP
.
GetDPSetNumber
(
"
x
"
,
self
.
__toGetDP
(
x
))
GetDP
.
GetDPSetNumber
(
"
x
_0
"
,
self
.
__toGetDP
(
x
))
GetDP
.
GetDPSetNumber
(
"
doApply
"
,
1
)
GetDP
.
GetDPSetNumber
(
"
doApply
"
,
1
)
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
"
-msh
"
,
self
.
__mesh
,
"
-msh
"
,
self
.
__mesh
,
"
-cal
"
]
+
self
.
__optional
)
"
-cal
"
]
+
self
.
__optional
)
GetDP
.
GetDPSetNumber
(
"
doApply
"
,
0
)
def
solve
(
self
,
b
,
w
):
def
solve
(
self
,
b
,
w
):
"""
Solves with b as RHS and w as complex angular frequency
"""
"""
Solves with b as RHS and w as complex angular frequency
b is a matrix and each column is a different RHS
"""
# Number of RHS
nRHS
=
b
.
shape
[
1
]
# Set variables
GetDP
.
GetDPSetNumber
(
"
nRHS
"
,
nRHS
)
GetDP
.
GetDPSetNumber
(
"
angularFreqRe
"
,
np
.
real
(
w
).
tolist
())
GetDP
.
GetDPSetNumber
(
"
angularFreqRe
"
,
np
.
real
(
w
).
tolist
())
GetDP
.
GetDPSetNumber
(
"
angularFreqIm
"
,
np
.
imag
(
w
).
tolist
())
GetDP
.
GetDPSetNumber
(
"
angularFreqIm
"
,
np
.
imag
(
w
).
tolist
())
GetDP
.
GetDPSetNumber
(
"
b
"
,
self
.
__toGetDP
(
b
))
GetDP
.
GetDPSetNumber
(
"
imposeRHS
"
,
1
)
# Set RHS
for
i
in
range
(
nRHS
):
GetDP
.
GetDPSetNumber
(
"
b_
"
+
str
(
i
),
self
.
__toGetDP
(
b
[:,
i
]))
# Solve
GetDP
.
GetDPSetNumber
(
"
doSolve
"
,
1
)
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
"
-msh
"
,
self
.
__mesh
,
"
-msh
"
,
self
.
__mesh
,
"
-cal
"
]
+
self
.
__optional
)
"
-cal
"
]
+
self
.
__optional
)
GetDP
.
GetDPSetNumber
(
"
imposeRHS
"
,
0
)
def
view
(
self
,
x
,
fileName
):
def
view
(
self
,
x
,
fileName
):
"""
Generates a post-processing view
"""
Generates a post-processing view
...
@@ -92,13 +106,12 @@ class GetDPWave:
...
@@ -92,13 +106,12 @@ class GetDPWave:
This method generates a linear system
This method generates a linear system
"""
"""
GetDP
.
GetDPSetNumber
(
"
x
"
,
self
.
__toGetDP
(
x
))
GetDP
.
GetDPSetNumber
(
"
x
_0
"
,
self
.
__toGetDP
(
x
))
GetDP
.
GetDPSetNumber
(
"
doPostpro
"
,
1
)
GetDP
.
GetDPSetNumber
(
"
doPostpro
"
,
1
)
GetDP
.
GetDPSetString
(
"
fileName
"
,
fileName
)
GetDP
.
GetDPSetString
(
"
fileName
"
,
fileName
)
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
GetDP
.
GetDP
([
"
getdp
"
,
self
.
__pro
,
"
-msh
"
,
self
.
__mesh
,
"
-msh
"
,
self
.
__mesh
,
"
-cal
"
]
+
self
.
__optional
)
"
-cal
"
]
+
self
.
__optional
)
GetDP
.
GetDPSetNumber
(
"
doPostpro
"
,
0
)
@staticmethod
@staticmethod
def
__toNumpy
(
vGetDP
):
def
__toNumpy
(
vGetDP
):
...
...
This diff is collapsed.
Click to expand it.
example/maxwell_linear/maxwell.pro
+
25
−
10
View file @
8ec7621f
...
@@ -16,11 +16,15 @@ Function{
...
@@ -16,11 +16,15 @@ Function{
angularFreqRe
,
angularFreqIm
];
angularFreqRe
,
angularFreqIm
];
//
Algebraic
data
//
//
Algebraic
data
//
DefineConstant
[
x
()
=
{},
//
Solution
DefineConstant
[
nRHS
=
1
];
//
Number
of
RHS
for
this
run
b
()
=
{}];
//
Right
hand
side
For
i
In
{
0
:
nRHS
-
1
}
DefineConstant
[
x
~
{
i
}()
=
{},
//
Solution
b
~
{
i
}()
=
{}];
//
Right
hand
side
EndFor
//
Control
data
//
//
Control
data
//
DefineConstant
[
imposeRHS
=
0
,
//
Should
I
use
an
imposed
RHS
?
DefineConstant
[
doInit
=
0
,
//
Should
I
initialize
some
stuff
?
doSolve
=
0
,
//
Should
I
solve
Ax
=
b
?
doPostpro
=
0
,
//
Should
I
only
create
a
view
for
x
()
?
doPostpro
=
0
,
//
Should
I
only
create
a
view
for
x
()
?
doApply
=
0
,
//
Should
I
only
apply
x
()
:
x
<-
Ax
?
doApply
=
0
,
//
Should
I
only
apply
x
()
:
x
<-
Ax
?
fileName
=
"eig.pos"
];
//
Postpro
file
name
fileName
=
"eig.pos"
];
//
Postpro
file
name
...
@@ -91,21 +95,32 @@ Resolution{
...
@@ -91,21 +95,32 @@ Resolution{
Operation
{
Operation
{
Generate
[
A
];
Generate
[
A
];
If
(
imposeRHS
)
If
(
doInit
)
Copy
RightHandSide
[
b
(),
A
];
Copy
Solution
[
A
,
x
~
{
0
}()
];
EndIf
EndIf
If
(!
doPostpro
&&
!
doApply
)
If
(
doSolve
)
//
Full
solve
for
first
RHS
CopyRightHandSide
[
b
~
{
0
}(),
A
];
Solve
[
A
];
Solve
[
A
];
CopySolution
[
A
,
x
()];
CopySolution
[
A
,
x
~
{
0
}()];
//
SolveAgain
for
other
RHSs
For
i
In
{
1
:
nRHS
-
1
}
CopyRightHandSide
[
b
~
{
i
}(),
A
];
SolveAgain
[
A
];
CopySolution
[
A
,
x
~
{
i
}()];
EndFor
EndIf
EndIf
If
(
doApply
)
If
(
doApply
)
CopySolution
[
x
(),
A
];
CopySolution
[
x
~
{
0
}
(),
A
];
Apply
[
A
];
Apply
[
A
];
CopySolution
[
A
,
x
()];
CopySolution
[
A
,
x
~
{
0
}
()];
EndIf
EndIf
If
(
doPostpro
)
If
(
doPostpro
)
CopySolution
[
x
(),
A
];
CopySolution
[
x
~
{
0
}
(),
A
];
PostOperation
[
Maxwell
];
PostOperation
[
Maxwell
];
EndIf
EndIf
}
}
...
...
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