def solve(self, state0=None, nls_status=None, ls_conf=None, nls_conf=None, force_values=None, var_data=None): """Solve self.equations in current time step. Parameters ---------- var_data : dict A dictionary of {variable_name : data vector} used to initialize parameter variables. """ solvers = self.get_solvers() if solvers is None: self.init_solvers(nls_status, ls_conf, nls_conf) solvers = self.get_solvers() if state0 is None: state0 = State(self.equations.variables) else: if isinstance(state0, nm.ndarray): state0 = State(self.equations.variables, vec=state0) self.equations.set_data(var_data, ignore_unknown=True) self.update_materials() state0.apply_ebc(force_values=force_values) vec0 = state0.get_reduced() vec = solvers.nls(vec0) state = state0.copy(preserve_caches=True) state.set_reduced(vec, preserve_caches=True) return state
def __init__(self, conf, **kwargs): from sfepy.fem.state import State ScipyDirect.__init__(self, conf, **kwargs) equations = self.problem.equations aux_state = State(equations.variables) conf.idxs = {} for bk, bv in conf.blocks.iteritems(): aux_state.fill(0.0) for jj in bv: idx = equations.variables.di.indx[jj] aux_state.vec[idx] = nm.nan aux_state.apply_ebc() vec0 = aux_state.get_reduced() conf.idxs[bk] = nm.where(nm.isnan(vec0))[0]