def prematrix_applicator(prematrix, field_mid=None, interface_coeffs=[], petsc_name="", result="cofield"): log.log(15, "Creating prematrix applicator ") # XXX Note: interface coeffs have special conventions on "jokers": # (-2,-2,1.0) would mean: include all interfaces with coefficient 1.0 # (-> see __parse_if_coeffs in pyfem2.ml) - Document this! opt_mid = [] if field_mid: opt_mid = [field_mid] app = ocaml.prematrix_to_applicator(interface_coeffs, opt_mid, petsc_name, prematrix) if result == "cofield": def py_app(field, target=None): opt_target = [] if target: opt_target = [target] return app(opt_target, field) return py_app elif result == "field": buffer = make_cofield(ocaml.prematrix_mwe(prematrix, "mwe_left")) print "DDD Buffer: ", buffer def py_app(field, target=None): cofield = app([buffer], field) return cofield_to_field(cofield, target=target) return py_app
def update_sigma(the_field_sigma): compute_grad_phi = ocaml.prematrix_to_applicator( [], # interface_coeffs [the_field_sigma], "", prematrix_grad_phi) # # laplace_solver = ocaml.laplace_solver( [], # if coeffs [(-1, 1, laplace_dbc)], # dbcs [the_field_sigma], # mid field "", # Petsc name prematrix_laplace) # # result_field_phi = laplace_solver([], laplace_dbc_value, cofield_drho_by_dt) last_field_phi[0] = result_field_phi # # field_J = ocaml.cofield_to_field( [], compute_grad_phi( [], # no target result_field_phi)) # # # Next, let us compute the new condictivity by site-wise operation on # field_J. We just overwrite field_sigma: # recompute_conductivity = ocaml.site_wise_applicator( [mwe_sigma, mwe_J], # all the fields we use [], ["H_x", "H_y", "sigma0", "alpha"], # all the names of extra parameters "", code_recompute_conductivity, True) # # recompute_conductivity([h_x, h_y, sigma0, alpha], [the_field_sigma, field_J], []) return the_field_sigma
def update_sigma(the_field_sigma): compute_grad_phi = ocaml.prematrix_to_applicator([], [the_field_sigma], "", prematrix_grad_phi) # interface_coeffs # # laplace_solver = ocaml.laplace_solver( [], # if coeffs [(-1, 1, laplace_dbc)], # dbcs [the_field_sigma], # mid field "", # Petsc name prematrix_laplace, ) # # result_field_phi = laplace_solver([], laplace_dbc_value, cofield_drho_by_dt) last_field_phi[0] = result_field_phi # # field_J = ocaml.cofield_to_field([], compute_grad_phi([], result_field_phi)) # no target # # # Next, let us compute the new condictivity by site-wise operation on # field_J. We just overwrite field_sigma: # recompute_conductivity = ocaml.site_wise_applicator( [mwe_sigma, mwe_J], # all the fields we use [], ["H_x", "H_y", "sigma0", "alpha"], # all the names of extra parameters "", code_recompute_conductivity, True, ) # # recompute_conductivity([h_x, h_y, sigma0, alpha], [the_field_sigma, field_J], []) return the_field_sigma