Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
IMAGINE
Commits
344fafef
Commit
344fafef
authored
Mar 12, 2017
by
Theo Steininger
Browse files
The MagneticFieldFactory now reuses the spaces for domain when creating MagneticFields.
parent
61cc64d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
imagine/magnetic_fields/magnetic_field/magnetic_field_factory.py
View file @
344fafef
...
...
@@ -21,6 +21,18 @@ class MagneticFieldFactory(Loggable, object):
self
.
_variable_to_parameter_mappings
=
\
self
.
_initial_variable_to_parameter_mappings
distances
=
np
.
array
(
self
.
box_dimensions
)
/
np
.
array
(
self
.
resolution
)
self
.
_grid_space
=
RGSpace
(
shape
=
self
.
resolution
,
distances
=
distances
)
self
.
_vector
=
FieldArray
(
shape
=
(
3
,))
self
.
_ensemble_cache
=
{}
def
_get_ensemble
(
self
,
ensemble_size
):
if
ensemble_size
not
in
self
.
_ensemble_cache
:
self
.
_ensemble_cache
[
ensemble_size
]
=
\
FieldArray
(
shape
=
(
ensemble_size
,))
return
self
.
_ensemble_cache
[
ensemble_size
]
@
property
def
box_dimensions
(
self
):
return
self
.
_box_dimensions
...
...
@@ -114,12 +126,9 @@ class MagneticFieldFactory(Loggable, object):
work_parameters
=
self
.
parameter_defaults
.
copy
()
work_parameters
.
update
(
mapped_variables
)
distances
=
np
.
array
(
self
.
box_dimensions
)
/
np
.
array
(
self
.
resolution
)
grid_space
=
RGSpace
(
shape
=
self
.
resolution
,
distances
=
distances
)
ensemble
=
FieldArray
(
shape
=
(
ensemble_size
,))
vector
=
FieldArray
(
shape
=
(
3
,))
domain
=
(
ensemble
,
grid_space
,
vector
)
domain
=
(
self
.
_get_ensemble
(
ensemble_size
),
self
.
_grid_space
,
self
.
_vector
)
result_magnetic_field
=
self
.
magnetic_field_class
(
domain
=
domain
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment