Skip to content

Commit 764b075

Browse files
authored
Merge pull request #2745 from devitocodes/init_tweak
api: avoid double fill in initializer
2 parents 132a7e8 + f2e9cb9 commit 764b075

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)