def save_ebc(self, filename, force=True, default=0.0): """ Save essential boundary conditions as state variables. """ output("saving ebc...") variables = self.get_variables(auto_create=True) ebcs = Conditions.from_conf(self.conf.ebcs, self.domain.regions) epbcs = Conditions.from_conf(self.conf.epbcs, self.domain.regions) try: variables.equation_mapping(ebcs, epbcs, self.ts, self.functions, problem=self) except: output("cannot make equation mapping!") raise state = State(variables) state.fill(default) if force: vals = dict_from_keys_init(variables.state) for ii, key in enumerate(vals.iterkeys()): vals[key] = ii + 1 state.apply_ebc(force_values=vals) else: state.apply_ebc() out = state.create_output_dict(extend=True) self.save_state(filename, out=out, fill_value=default) output("...done")
def save_ebc(self, filename, force=True, default=0.0): """ Save essential boundary conditions as state variables. """ output('saving ebc...') variables = self.get_variables(auto_create=True) ebcs = Conditions.from_conf(self.conf.ebcs, self.domain.regions) epbcs = Conditions.from_conf(self.conf.epbcs, self.domain.regions) try: variables.equation_mapping(ebcs, epbcs, self.ts, self.functions, problem=self) except: output('cannot make equation mapping!') raise state = State(variables) state.fill(default) if force: vals = dict_from_keys_init(variables.state) for ii, key in enumerate(vals.iterkeys()): vals[key] = ii + 1 state.apply_ebc(force_values=vals) else: state.apply_ebc() out = state.create_output_dict(extend=True) self.save_state(filename, out=out, fill_value=default) output('...done')
def save_ebc(self, filename, ebcs=None, epbcs=None, force=True, default=0.0): """ Save essential boundary conditions as state variables. Parameters ---------- filename : str The output file name. ebcs : Conditions instance, optional The essential (Dirichlet) boundary conditions. If not given, `self.conf.ebcs` are used. epbcs : Conditions instance, optional The periodic boundary conditions. If not given, `self.conf.epbcs` are used. force : bool If True, sequential nonzero values are forced to individual `ebcs` so that the conditions are visible even when zero. default : float The default constant value of state vector. """ output('saving ebc...') variables = self.get_variables(auto_create=True) if ebcs is None: ebcs = Conditions.from_conf(self.conf.ebcs, self.domain.regions) if epbcs is None: epbcs = Conditions.from_conf(self.conf.epbcs, self.domain.regions) try: variables.equation_mapping(ebcs, epbcs, self.ts, self.functions, problem=self) except: output('cannot make equation mapping!') raise state = State(variables) state.fill(default) if force: vals = dict_from_keys_init(variables.state) for ii, key in enumerate(vals.iterkeys()): vals[key] = ii + 1 state.apply_ebc(force_values=vals) else: state.apply_ebc() out = state.create_output_dict(extend=True) self.save_state(filename, out=out, fill_value=default) output('...done')