Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Moore authored and Kenneth Moore committed Apr 15, 2020
1 parent 3b78a50 commit 15a42eb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 45 deletions.
4 changes: 2 additions & 2 deletions openmdao/jacobians/assembled_jacobian.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def _get_subjac_iters(self, system):
else:
global_conns = system._conn_global_abs_in2out

output_names = set(n for n in system._var_abs_names['output'])
input_names = set(n for n in system._var_abs_names['input'])
output_names = set(system._var_abs_names['output'])
input_names = set(system._var_abs_names['input'])

rev_conns = defaultdict(list)
for tgt, src in global_conns.items():
Expand Down
36 changes: 0 additions & 36 deletions openmdao/matrices/coo_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class COOMatrix(Matrix):
----------
_coo : coo_matrix
COO matrix. Used as a basis for conversion to CSC, CSR, Dense in inherited classes.
_first_gather : bool
If True, this is the first time the matrix has been gathered (MPI only).
"""

def __init__(self, comm, is_internal):
Expand All @@ -33,7 +31,6 @@ def __init__(self, comm, is_internal):
"""
super(COOMatrix, self).__init__(comm, is_internal)
self._coo = None
self._first_gather = True

def _build_coo(self, system):
"""
Expand Down Expand Up @@ -294,36 +291,3 @@ def _convert_mask(self, mask):
The converted mask array.
"""
return mask

def _get_assembled_matrix(self, system):
assert self._is_internal
if self._first_gather:
self._first_gather = False

# only need to gather the row/col indices the first time. After that we only need
# the data.
all_mtx = system.comm.gather(self._coo, root=0)

if system.comm.rank == 0:
data = []
rows = []
cols = []
for i, mtx in enumerate(all_mtx):
data.append(mtx.data)
rows.append(mtx.row)
cols.append(mtx.col)

data = np.hstack(data)
self._gathered_rows = rows = np.hstack(rows)
self._gathered_cols = cols = np.hstack(cols)

return csc_matrix((data, (rows, cols)), shape=self._matrix.shape)
else:
all_data = system.comm.gather(self._coo.data, root=0)

if system.comm.rank == 0:
data = np.hstack(all_data)
rows = self._gathered_rows
cols = self._gathered_cols

return csc_matrix((data, (rows, cols)), shape=self._matrix.shape)
7 changes: 0 additions & 7 deletions openmdao/matrices/dense_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,3 @@ def _post_update(self):
"""
# this will add any repeated entries together
self._matrix = self._coo.toarray()

def _get_assembled_matrix(self, system):
mat = super(DenseMatrix, self)._get_assembled_matrix(system)
if mat is None:
return mat

return mat.toarray()

0 comments on commit 15a42eb

Please sign in to comment.