def main(): from sfepy.base.base import output from sfepy.base.conf import ProblemConf, get_standard_keywords from sfepy.fem import ProblemDefinition from sfepy.solvers.generic import solve_evolutionary_op output.prefix = 'therel:' required, other = get_standard_keywords() conf = ProblemConf.from_file(__file__, required, other) problem = ProblemDefinition.from_conf(conf, init_equations=False) # Setup output directory according to options above. problem.setup_default_output() # First solve the stationary electric conduction problem. problem.set_equations({'eq' : conf.equations['1']}) problem.time_update() state_el = problem.solve() problem.save_state(problem.get_output_name(suffix = 'el'), state_el) # Then solve the evolutionary heat conduction problem, using state_el. problem.set_equations({'eq' : conf.equations['2']}) phi_var = problem.get_variables()['phi_known'] phi_var.data_from_any(state_el()) solve_evolutionary_op(problem) output('results saved in %s' % problem.get_output_name(suffix = '*'))
def solve_branch( problem, options, branch_function ): from sfepy.solvers.generic import solve_evolutionary_op load = problem.materials['load'] load.set_function( branch_function ) displacements = {} for key, eq in problem.conf.equations.iteritems(): problem.set_equations( {key : eq} ) out = [] aux = solve_evolutionary_op( problem, save_results = False, step_hook = store_top_u( out ) ) displacements[key] = nm.array( out, dtype = nm.float64 ) return displacements