-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,28 +56,17 @@ def solve_system(self, impl_sys, u0, t): | |
""" | ||
me = self.dtype_u(self.init) | ||
|
||
def implSysAsNumpy(unknowns, **kwargs): | ||
me.diff[:] = unknowns[: np.size(me.diff)].reshape(me.diff.shape) | ||
me.alg[:] = unknowns[np.size(me.diff) :].reshape(me.alg.shape) | ||
def implSysFlatten(unknowns, **kwargs): | ||
me[:] = unknowns.reshape(me.shape) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lisawim
Author
Collaborator
|
||
sys = impl_sys(me, **kwargs) | ||
return np.append(sys.diff.flatten(), sys.alg.flatten()) # TODO: more efficient way? | ||
return sys.flatten() | ||
|
||
if type(me) == DAEMesh: | ||
opt = root( | ||
implSysAsNumpy, | ||
np.append(u0.diff.flatten(), u0.alg.flatten()), | ||
method='hybr', | ||
tol=self.newton_tol, | ||
) | ||
me.diff[:] = opt.x[: np.size(me.diff)].reshape(me.diff.shape) | ||
me.alg[:] = opt.x[np.size(me.diff) :].reshape(me.alg.shape) | ||
else: | ||
opt = root( | ||
impl_sys, | ||
u0, | ||
method='hybr', | ||
tol=self.newton_tol, | ||
) | ||
me[:] = opt.x | ||
opt = root( | ||
implSysFlatten, | ||
u0.flatten(), | ||
method='hybr', | ||
tol=self.newton_tol, | ||
) | ||
me[:] = opt.x.reshape(me.shape) | ||
self.work_counters['newton'].niter += opt.nfev | ||
return me |
I am wondering if we can make this more efficient.
impl_sys
wants aMultiComponentMesh
, so we cannot just passunknowns.reshape(self.init[0])
. This would be nice because, if I understand correctly, it would not cause any copying of data, but create a view onto the same data with a different shape. Could we plugunknowns.reshape(self.init[0]).view(type(u0))
intoimpl_sys
? Would this even avoid copying? What do you think @tlunet, @pancetta? If you don't think it's worth bothering, we can just go ahead and finally merge this!