def get_homog_mat(ts, coors, mode, term=None, problem=None, **kwargs): if problem.update_materials_flag == 2 and mode == 'qp': out = hyperelastic_data['homog_mat'] return {k: nm.array(v) for k, v in six.iteritems(out)} elif problem.update_materials_flag == 0 or not mode == 'qp': return output('get_homog_mat') dim = problem.domain.mesh.dim update_var = problem.conf.options.mesh_update_variables[0] state_u = problem.equations.variables[update_var] state_u.field.clear_mappings() family_data = problem.family_data(state_u, term.region, term.integral, term.integration) mtx_f = family_data.mtx_f.reshape((coors.shape[0],) + family_data.mtx_f.shape[-2:]) out = get_homog_coefs_nonlinear(ts, coors, mode, mtx_f, term=term, problem=problem, iteration=problem.iiter, **kwargs) out['E'] = 0.5 * (la.dot_sequences(mtx_f, mtx_f, 'ATB') - nm.eye(dim)) hyperelastic_data['time'] = ts.step hyperelastic_data['homog_mat_shape'] = family_data.det_f.shape[:2] hyperelastic_data['homog_mat'] = \ {k: nm.array(v) for k, v in six.iteritems(out)} return out
def get_homog_mat(ts, coors, mode, term=None, problem=None, **kwargs): hyperela = hyperelastic_data ts = hyperela['ts'] output('get_homog_mat: mode=%s, update=%s'\ % (mode, hyperela['update_materials'])) if not mode == 'qp': return if not hyperela['update_materials']: out = hyperela['homog_mat'] return {k: nm.array(v) for k, v in six.iteritems(out)} dim = problem.domain.mesh.dim nqp = coors.shape[0] state_u = problem.equations.variables['u'] if len(state_u.field.mappings0) == 0: state_u.field.get_mapping(term.region, term.integral, term.integration) state_u.field.save_mappings() state_u.field.clear_mappings() state_u.set_data( hyperela['state']['u'].ravel()) # + state_u.data[-1][state_u.indx] mtx_f = problem.evaluate('ev_def_grad.i.Omega(u)', mode='qp').reshape(-1, dim, dim) # relative deformation gradient if hasattr(problem, 'mtx_f_prev'): rel_mtx_f = la.dot_sequences(mtx_f, nm.linalg.inv(problem.mtx_f_prev), 'AB') else: rel_mtx_f = mtx_f problem.mtx_f_prev = mtx_f.copy() macro_data = { 'mtx_e_rel': rel_mtx_f - nm.eye(dim), # relative macro strain } for ch in problem.conf.chs: plab = 'p%d' % ch state_p = problem.equations.variables[plab] state_p.set_data(hyperela['state'][plab]) macro_data['p%d_0' % ch] = \ problem.evaluate('ev_volume_integrate.i.Omega(p%d)' % ch, mode='qp').reshape(-1, 1, 1) macro_data['gp%d_0' % ch] = \ problem.evaluate('ev_grad.i.Omega(p%d)' % ch, mode='qp').reshape(-1, dim, 1) state_p.set_data(hyperela['state']['d' + plab]) macro_data['dp%d_0' % ch] = \ problem.evaluate('ev_volume_integrate.i.Omega(p%d)' % ch, mode='qp').reshape(-1, 1, 1) macro_data['gdp%d_0' % ch] = \ problem.evaluate('ev_grad.i.Omega(p%d)' % ch, mode='qp').reshape(-1, dim, 1) nel = term.region.entities[-1].shape[0] ccoors0, macro_data0 = homog_macro_map(coors, macro_data, nel) macro_data0['macro_ccoor'] = ccoors0 out0 = get_homog_coefs_nonlinear(ts, ccoors0, mode, macro_data0, term=term, problem=problem, iteration=ts.step, **kwargs) out0['C1'] += nm.eye(2) * 1e-12 # ! auxiliary permeability out0['C2'] += nm.eye(2) * 1e-12 # ! auxiliary permeability out = homog_macro_remap(out0, nqp) # Green strain out['E'] = 0.5 * (la.dot_sequences(mtx_f, mtx_f, 'ATB') - nm.eye(dim)) for ch in problem.conf.chs: out['B%d' % ch] = out['B%d' % ch].reshape((nqp, dim, dim)) out['Q'] = out['Q'].reshape((nqp, dim, dim)) hyperela['time'] = ts.step hyperela['homog_mat'] = \ {k: nm.array(v) for k, v in six.iteritems(out)} hyperela['update_materials'] = False hyperela['macro_data'] = macro_data return out