Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure index arrays are of the right type for petsc. #1921

Merged
merged 1 commit into from
Feb 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions openmdao.main/src/openmdao/main/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
simple_node_iter, \
is_boundary_node
from openmdao.main.systems import SerialSystem, _create_simple_sys
from openmdao.main.vecwrapper import petsc_idxs

from openmdao.util.graph import list_deriv_vars, base_var, fix_single_tuple
from openmdao.util.log import logger
Expand Down Expand Up @@ -1390,9 +1391,9 @@ def _get_var_info(self, node):

if '[' in vname: # array index into basevar
base = vname.split('[',1)[0]
flat_idx = get_flattened_index(idx,
flat_idx = petsc_idxs(get_flattened_index(idx,
get_var_shape(base, child),
cvt_to_slice=False)
cvt_to_slice=False))
else:
base = None
flat_idx = None
Expand Down
4 changes: 2 additions & 2 deletions openmdao.main/src/openmdao/main/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,12 @@ def setup_sizes(self):
# components...
if name in self.vector_vars:
isrc = self.vector_vars.keys().index(name)
idxs = numpy.array(range(varmeta[name]['size']), 'i')
#idxs = numpy.array(range(varmeta[name]['size']), 'i')
idxs = petsc_linspace(0, varmeta[name]['size'])
else:
base = name[0].split('[', 1)[0]
if base == name[0]:
continue
#isrc = self.vector_vars.keys().index(self.scope.name2collapsed[base])
idxs = varmeta[name].get('flat_idx')

self.arg_idx[name] = idxs# + numpy.sum(self.local_var_sizes[:self.mpi.rank, isrc])
Expand Down
7 changes: 7 additions & 0 deletions openmdao.main/src/openmdao/main/vecwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,13 @@ def petsc_linspace(start, end):
else:
return numpy.arange(start, end, dtype='i')

def petsc_idxs(idxs):
""" Return an index vector of the right int type for PETSc """
if MPI:
return numpy.array(idxs, dtype=PETSc.IntType)

return idxs

def _filter(scope, lst):
filtered = _filter_subs(lst)
filtered = _filter_flat(scope, filtered)
Expand Down