def get_qp(self, geometry): """ Get quadrature point coordinates and corresponding weights for given geometry. For built-in quadratures, the integration order is given by `self.order`. Parameters ---------- geometry : str The geometry key describing the integration domain, see the keys of `sfepy.discrete.quadratures.quadrature_tables`. Returns ------- coors : array The coordinates of quadrature points. weights: array The quadrature weights. """ if geometry in self.qps: qp = self.qps[geometry] else: if self.mode == 'builtin': qp = QuadraturePoints.from_table(geometry, self.order) else: qp = QuadraturePoints(None, coors=self.coors, weights=self.weights) self.qps[geometry] = qp return qp.coors, qp.weights
def integrate(self, function, order=1, geometry='1_2'): """ Integrate numerically a given scalar function. Parameters ---------- function : callable(coors) The function of space coordinates to integrate. order : int, optional The integration order. For tensor product geometries, this is the 1D (line) order. geometry : str The geometry key describing the integration domain. Default is `'1_2'`, i.e. a line integral in [0, 1]. For other values see the keys of `sfepy.discrete.quadratures.quadrature_tables`. Returns ------- val : float The value of the integral. """ qp = QuadraturePoints.from_table(geometry, order) fvals = function(qp.coors) val = nm.sum(fvals * qp.weights) return val