Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
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
Container registry
Model registry
Monitor
Service Desk
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
ift
NIFTy
Commits
9d7fe771
There was a problem fetching the pipeline summary.
Commit
9d7fe771
authored
7 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
a few fixes
parent
6dd60a22
Branches
update/validation
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nifty/operators/dof_projection_operator.py
+12
-6
12 additions, 6 deletions
nifty/operators/dof_projection_operator.py
nifty/spaces/dof_space.py
+2
-1
2 additions, 1 deletion
nifty/spaces/dof_space.py
with
14 additions
and
7 deletions
nifty/operators/dof_projection_operator.py
+
12
−
6
View file @
9d7fe771
...
@@ -5,9 +5,11 @@ from ..spaces import DOFSpace
...
@@ -5,9 +5,11 @@ from ..spaces import DOFSpace
class
DOFProjectionOperator
(
LinearOperator
):
class
DOFProjectionOperator
(
LinearOperator
):
def
__init__
(
self
,
do
main
,
dofdex
,
space
=
None
):
def
__init__
(
self
,
do
fdex
,
domain
=
None
,
space
=
None
):
super
(
DOFProjectionOperator
,
self
).
__init__
()
super
(
DOFProjectionOperator
,
self
).
__init__
()
if
domain
is
None
:
domain
=
dofdex
.
domain
self
.
_domain
=
DomainTuple
.
make
(
domain
)
self
.
_domain
=
DomainTuple
.
make
(
domain
)
if
space
is
None
and
len
(
self
.
_domain
)
==
1
:
if
space
is
None
and
len
(
self
.
_domain
)
==
1
:
space
=
0
space
=
0
...
@@ -17,15 +19,19 @@ class DOFProjectionOperator(LinearOperator):
...
@@ -17,15 +19,19 @@ class DOFProjectionOperator(LinearOperator):
partner
=
self
.
_domain
[
space
]
partner
=
self
.
_domain
[
space
]
if
not
isinstance
(
dofdex
,
Field
):
if
not
isinstance
(
dofdex
,
Field
):
raise
TypeError
(
"
dofdex must be a Field
"
)
raise
TypeError
(
"
dofdex must be a Field
"
)
if
not
isinstance
(
dofdex
.
dtype
,
np
.
integer
):
if
not
len
(
dofdex
.
domain
)
==
1
:
raise
ValueError
(
"
dofdex must live on exactly one Space
"
)
if
not
np
.
issubdtype
(
dofdex
.
dtype
,
np
.
integer
):
print
(
dofdex
.
dtype
.
type
,
np
.
integer
)
raise
TypeError
(
"
dofdex must contain integer numbers
"
)
raise
TypeError
(
"
dofdex must contain integer numbers
"
)
if
partner
!=
dofdex
.
domain
:
if
partner
!=
dofdex
.
domain
[
0
]:
print
(
partner
,
dofdex
.
domain
[
0
])
raise
ValueError
(
"
incorrect dofdex domain
"
)
raise
ValueError
(
"
incorrect dofdex domain
"
)
nbin
=
dofdex
.
max
()
nbin
=
dofdex
.
max
()
if
partner
.
scalar_dvol
()
is
not
None
:
if
partner
.
scalar_dvol
()
is
not
None
:
wgt
=
np
.
bincount
(
dobj
.
local_data
(
dofdex
.
val
).
ravel
(),
wgt
=
np
.
bincount
(
dobj
.
local_data
(
dofdex
.
val
).
ravel
(),
minlength
=
nbin
)
minlength
=
nbin
)
.
astype
(
np
.
float64
)
wgt
*=
partner
.
scalar_dvol
()
wgt
*=
partner
.
scalar_dvol
()
else
:
else
:
dvol
=
dobj
.
local_data
(
partner
.
dvol
())
dvol
=
dobj
.
local_data
(
partner
.
dvol
())
...
@@ -45,9 +51,9 @@ class DOFProjectionOperator(LinearOperator):
...
@@ -45,9 +51,9 @@ class DOFProjectionOperator(LinearOperator):
self
.
_target
=
DomainTuple
.
make
(
tgt
)
self
.
_target
=
DomainTuple
.
make
(
tgt
)
if
dobj
.
default_distaxis
()
in
self
.
domain
.
axes
[
self
.
_space
]:
if
dobj
.
default_distaxis
()
in
self
.
domain
.
axes
[
self
.
_space
]:
dofdex
=
dobj
.
local_data
(
dofdex
)
dofdex
=
dobj
.
local_data
(
dofdex
.
val
)
else
:
# dofdex must be available fully on every task
else
:
# dofdex must be available fully on every task
dofdex
=
dobj
.
to_global_data
(
dofdex
)
dofdex
=
dobj
.
to_global_data
(
dofdex
.
val
)
self
.
_dofdex
=
dofdex
.
ravel
()
self
.
_dofdex
=
dofdex
.
ravel
()
firstaxis
=
self
.
_domain
.
axes
[
self
.
_space
][
0
]
firstaxis
=
self
.
_domain
.
axes
[
self
.
_space
][
0
]
lastaxis
=
self
.
_domain
.
axes
[
self
.
_space
][
-
1
]
lastaxis
=
self
.
_domain
.
axes
[
self
.
_space
][
-
1
]
...
...
This diff is collapsed.
Click to expand it.
nifty/spaces/dof_space.py
+
2
−
1
View file @
9d7fe771
import
numpy
as
np
from
.space
import
Space
from
.space
import
Space
...
@@ -23,7 +24,7 @@ class DOFSpace(Space):
...
@@ -23,7 +24,7 @@ class DOFSpace(Space):
return
None
return
None
def
dvol
(
self
):
def
dvol
(
self
):
return
self
.
_dvol
return
np
.
array
(
self
.
_dvol
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'
this is a dof space
'
return
'
this is a dof space
'
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