def bind(self, discr, **extra_context): "Convert the abstract operator template into compiled code." from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.pec_tag, self.absorb_tag, self.incident_tag]) compiled_op_template = discr.compile(self.op_template()) from hedge.tools import full_to_subset_indices e_indices = full_to_subset_indices(self.get_eh_subset()[0:3]) all_indices = full_to_subset_indices(self.get_eh_subset()) def rhs(t, w): if self.current is not None: j = self.current.volume_interpolant(t, discr)[e_indices] else: j = 0 if self.incident_bc_data is not None: incident_bc_data = self.incident_bc_data.boundary_interpolant( t, discr, self.incident_tag)[all_indices] else: incident_bc_data = 0 kwargs = {} kwargs.update(extra_context) if not self.fixed_material: kwargs["epsilon"] = self.epsilon.volume_interpolant(t, discr) kwargs["mu"] = self.mu.volume_interpolant(t, discr) return compiled_op_template( w=w, j=j, incident_bc=incident_bc_data, **kwargs) return rhs
def bind(self, discr, sensor=None): from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.dirichlet_tag, self.neumann_tag, self.radiation_tag]) compiled_op_template = discr.compile(self.op_template( with_sensor=sensor is not None)) def rhs(t, w): kwargs = {} if sensor is not None: kwargs["sensor"] = sensor(t, w) rhs = compiled_op_template(w=w, c=self.c.volume_interpolant(t, discr), **kwargs) if self.source is not None: rhs[0] += self.source.volume_interpolant(t, discr) return rhs return rhs
def bind(self, discr): """Return a :class:`BoundPoissonOperator`.""" assert self.dimensions == discr.dimensions from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [self.dirichlet_tag, self.neumann_tag]) return BoundDiffusionOperator(self, discr)
def bind(self, discr): compiled_op_template = discr.compile(self.op_template()) from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [self.inflow_tag, self.outflow_tag]) def rhs(t, u): bc_in = self.inflow_u.boundary_interpolant(t, discr, self.inflow_tag) return compiled_op_template(u=u, bc_in=bc_in) return rhs
def bind(self, discr): check_bc_coverage(discr.mesh, self.boundaryconditions_tag.values()) compiled_op_template = discr.compile(self.op_template()) def rhs(t, q): extra_kwargs = self.bind_sources(t, discr) extra_kwargs['state_null'] = self.state_null.volume_interpolant(t, discr) q[0] = self.material.volume_interpolant(t, discr) return compiled_op_template(q=q, **extra_kwargs) return rhs
def bind(self, discr, sensor=None, sensor_scaling=None, viscosity_only=False): if (sensor is None and self.artificial_viscosity_mode is not None): raise ValueError("must specify a sensor if using " "artificial viscosity") bound_op = discr.compile( self.op_template(sensor_scaling=sensor_scaling, viscosity_only=False)) from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.inflow_tag, self.outflow_tag, self.noslip_tag, self.wall_tag, self.supersonic_inflow_tag, self.supersonic_outflow_tag, ]) if self.mu == 0 and not discr.get_boundary(self.noslip_tag).is_empty(): raise RuntimeError("no-slip BCs only make sense for " "viscous problems") def rhs(t, q): extra_kwargs = {} if self.source is not None: extra_kwargs["source_vect"] = self.source.volume_interpolant( t, q, discr) if sensor is not None: extra_kwargs["sensor"] = sensor(q) opt_result = bound_op( q=q, bc_q_in=self.bc_inflow.boundary_interpolant( t, discr, self.inflow_tag), bc_q_out=self.bc_outflow.boundary_interpolant( t, discr, self.outflow_tag), bc_q_noslip=self.bc_noslip.boundary_interpolant( t, discr, self.noslip_tag), bc_q_supersonic_in=self.bc_supersonic_inflow. boundary_interpolant(t, discr, self.supersonic_inflow_tag), **extra_kwargs) max_speed = opt_result[-1] ode_rhs = opt_result[:-1] return ode_rhs, discr.nodewise_max(max_speed) return rhs
def bind(self, discr): from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.dirichlet_tag, self.neumann_tag, self.radiation_tag]) compiled_op_template = discr.compile(self.op_template()) def rhs(t, w, **extra_context): return compiled_op_template(t=t, w=w, **extra_context) return rhs
def bind(self, discr, sensor=None, sensor_scaling=None, viscosity_only=False): if (sensor is None and self.artificial_viscosity_mode is not None): raise ValueError("must specify a sensor if using " "artificial viscosity") bound_op = discr.compile(self.op_template( sensor_scaling=sensor_scaling, viscosity_only=False)) from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.inflow_tag, self.outflow_tag, self.noslip_tag, self.wall_tag, self.supersonic_inflow_tag, self.supersonic_outflow_tag, ]) if self.mu == 0 and not discr.get_boundary(self.noslip_tag).is_empty(): raise RuntimeError("no-slip BCs only make sense for " "viscous problems") def rhs(t, q): extra_kwargs = {} if self.source is not None: extra_kwargs["source_vect"] = self.source.volume_interpolant( t, q, discr) if sensor is not None: extra_kwargs["sensor"] = sensor(q) opt_result = bound_op(q=q, bc_q_in=self.bc_inflow.boundary_interpolant( t, discr, self.inflow_tag), bc_q_out=self.bc_outflow.boundary_interpolant( t, discr, self.outflow_tag), bc_q_noslip=self.bc_noslip.boundary_interpolant( t, discr, self.noslip_tag), bc_q_supersonic_in=self.bc_supersonic_inflow .boundary_interpolant(t, discr, self.supersonic_inflow_tag), **extra_kwargs ) max_speed = opt_result[-1] ode_rhs = opt_result[:-1] return ode_rhs, discr.nodewise_max(max_speed) return rhs
def bind(self, discr, u0=1, sensor=None): compiled_op_template = discr.compile( self.op_template(with_sensor=sensor is not None)) from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, []) def rhs(t, u): kwargs = {} if sensor is not None: kwargs["sensor"] = sensor(u) return compiled_op_template(u=u, u0=u0, **kwargs) return rhs
def bind(self, discr): "Convert the abstract operator template into compiled code." from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.pec_tag, self.absorb_tag, self.incident_tag]) compiled_op_template = discr.compile(self.op_template()) def rhs(t, w, **extra_context): kwargs = {} kwargs.update(extra_context) return compiled_op_template(w=w, t=t, **kwargs) return rhs
def bind(self, discr): "Convert the abstract operator template into compiled code." from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [self.pec_tag, self.absorb_tag, self.incident_tag]) compiled_op_template = discr.compile(self.op_template()) def rhs(t, w, **extra_context): kwargs = {} kwargs.update(extra_context) return compiled_op_template(w=w, t=t, **kwargs) return rhs
def bind(self, discr, sensor=None): from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.dirichlet_tag, self.neumann_tag, self.radiation_tag]) compiled_op_template = discr.compile(self.op_template( with_sensor=sensor is not None)) def rhs(t, w): kwargs = {} if sensor is not None: kwargs["sensor"] = sensor(t, w) return compiled_op_template(t=t, w=w, **kwargs) return rhs
def bind(self, discr, coefs): check_bc_coverage(discr.mesh, self.boundaryconditions_tag.values()) compiled_op_template = discr.compile(self.op_template()) def rhs(t, q): extra_kwargs = self.bind_sources(t, discr) extra_kwargs['state_null'] = self.state_null.volume_interpolant(t, discr) dim = self.dimensions q2 = q[0:dim+self.len_f+1] q2[0] = self.material.volume_interpolant(t, discr) return compiled_op_template(q=q2, f2=q[dim+self.len_f+1:dim+self.len_f+self.len_f2+1], sigma=coefs.sigma, alpha=coefs.alpha, kappa=coefs.kappa, **extra_kwargs) return rhs
def bind(self, discr): from hedge.mesh import check_bc_coverage check_bc_coverage( discr.mesh, [self.dirichlet_tag, self.neumann_tag, self.radiation_tag]) compiled_op_template = discr.compile(self.op_template()) def rhs(t, w): kwargs = {"w": w} if self.dirichlet_bc_f: kwargs["dir_bc_u"] = self.dirichlet_bc_f.boundary_interpolant( t, discr, self.dirichlet_tag) if self.source_f is not None: kwargs["source_u"] = self.source_f.volume_interpolant(t, discr) return compiled_op_template(**kwargs) return rhs
def bind(self, discr, **extra_context): "Convert the abstract operator template into compiled code." from hedge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.dirichlet_tag, self.traction_tag]) compiled_op_template = discr.compile(self.op_template()) def rhs(t, w): if self.dirichlet_bc_data is not None: dirichlet_bc_data = self.dirichlet_bc_data.boundary_interpolant( t, discr, self.dirichlet_tag)[0:3] else: dirichlet_bc_data = 0 kwargs = {} kwargs.update(extra_context) return compiled_op_template(w=w, dirichlet_bc=dirichlet_bc_data, **kwargs) return rhs
def bind(self, discr, sensor=None): compiled_op_template = discr.compile( self.op_template(with_sensor=sensor is not None)) from hedge.mesh import check_bc_coverage, TAG_ALL check_bc_coverage(discr.mesh, [TAG_ALL]) def rhs(t, u): kwargs = {} if sensor is not None: kwargs["sensor"] = sensor(t, u) if self.bc_u_f is not "None": kwargs["bc_u"] = \ self.bc_u_f.boundary_interpolant(t, discr, tag=TAG_ALL) return compiled_op_template( u=u, v=self.advec_v.volume_interpolant(t, discr), **kwargs) return rhs
def bind(self, discr, sensor=None): compiled_op_template = discr.compile( self.op_template(with_sensor=sensor is not None)) from hedge.mesh import check_bc_coverage, TAG_ALL check_bc_coverage(discr.mesh, [TAG_ALL]) def rhs(t, u): kwargs = {} if sensor is not None: kwargs["sensor"] = sensor(t, u) if self.bc_u_f is not "None": kwargs["bc_u"] = \ self.bc_u_f.boundary_interpolant(t, discr, tag=TAG_ALL) return compiled_op_template(u=u, v=self.advec_v.volume_interpolant( t, discr), **kwargs) return rhs