Skip to content

Commit f2e9cb9

Browse files
committed
api: avoid double fill in initializer
1 parent 132a7e8 commit f2e9cb9

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

devito/builtins/initializers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,11 @@ def initialize_function(function, data, nbl, mapper=None, mode='constant',
367367
if any(isinstance(f, dv.TimeFunction) for f in functions):
368368
raise NotImplementedError("TimeFunctions are not currently supported.")
369369

370+
# Allocate data and avoid pre-filling with zeros since we immediately overwrite
371+
# the data with the provided `data`
372+
for f in functions:
373+
f._create_data()
374+
370375
if nbl == 0:
371376
for f, data in zip(functions, datas):
372377
if isinstance(data, dv.Function):
@@ -376,6 +381,7 @@ def initialize_function(function, data, nbl, mapper=None, mode='constant',
376381
else:
377382
lhss, rhss, optionss = [], [], []
378383
for f, data in zip(functions, datas):
384+
379385
lhs, rhs, options = _initialize_function(f, data, nbl, mapper, mode)
380386

381387
lhss.extend(lhs)

0 commit comments

Comments
 (0)