def compute_integrand_scaling_factor(integral): """Change integrand geometry to the right representations.""" domain = integral.ufl_domain() integral_type = integral.integral_type() # co = CellOrientation(domain) weight = QuadratureWeight(domain) tdim = domain.topological_dimension() # gdim = domain.geometric_dimension() # Polynomial degree of integrand scaling degree = 0 if integral_type == "cell": detJ = JacobianDeterminant(domain) degree = estimate_total_polynomial_degree( apply_geometry_lowering(detJ)) # Despite the abs, |detJ| is polynomial except for # self-intersecting cells, where we have other problems. scale = abs(detJ) * weight elif integral_type.startswith("exterior_facet"): if tdim > 1: # Scaling integral by facet jacobian determinant and # quadrature weight detFJ = FacetJacobianDeterminant(domain) degree = estimate_total_polynomial_degree( apply_geometry_lowering(detFJ)) scale = detFJ * weight else: # No need to scale 'integral' over a vertex scale = 1 elif integral_type.startswith("interior_facet"): if tdim > 1: # Scaling integral by facet jacobian determinant from one # side and quadrature weight detFJ = FacetJacobianDeterminant(domain) degree = estimate_total_polynomial_degree( apply_geometry_lowering(detFJ)) scale = detFJ('+') * weight else: # No need to scale 'integral' over a vertex scale = 1 elif integral_type in custom_integral_types: # Scaling with custom weight, which includes eventual volume # scaling scale = weight elif integral_type in point_integral_types: # No need to scale 'integral' over a point scale = 1 else: error("Unknown integral type {}, don't know how to scale.".format( integral_type)) return scale, degree
def compute_integrand_scaling_factor(integral): """Change integrand geometry to the right representations.""" domain = integral.ufl_domain() integral_type = integral.integral_type() # co = CellOrientation(domain) weight = QuadratureWeight(domain) tdim = domain.topological_dimension() # gdim = domain.geometric_dimension() if integral_type == "cell": scale = abs(JacobianDeterminant(domain)) * weight elif integral_type.startswith("exterior_facet"): if tdim > 1: # Scaling integral by facet jacobian determinant and # quadrature weight scale = FacetJacobianDeterminant(domain) * weight else: # No need to scale 'integral' over a vertex scale = 1 elif integral_type.startswith("interior_facet"): if tdim > 1: # Scaling integral by facet jacobian determinant from one # side and quadrature weight scale = FacetJacobianDeterminant(domain)('+') * weight else: # No need to scale 'integral' over a vertex scale = 1 elif integral_type in custom_integral_types: # Scaling with custom weight, which includes eventual volume # scaling scale = weight elif integral_type in point_integral_types: # No need to scale 'integral' over a point scale = 1 else: error("Unknown integral type {}, don't know how to scale.".format( integral_type)) return scale
def facet_area(self, o): if self._preserve_types[o._ufl_typecode_]: return o domain = o.ufl_domain() tdim = domain.topological_dimension() if not domain.is_piecewise_linear_simplex_domain(): # Don't lower for non-affine cells, instead leave it to # form compiler warning("Only know how to compute the facet area of an affine cell.") return o # Area of "facet" of interval (i.e. "area" of a vertex) is defined as 1.0 if tdim == 1: return FloatValue(1.0) r = self.facet_jacobian_determinant(FacetJacobianDeterminant(domain)) r0 = ReferenceFacetVolume(domain) return abs(r * r0)