Source code for scimba_torch.integration.mesh_based_quadrature
"""Implements the rectangle method for cube-like domains."""fromtypingimportAnyfromscimba_torch.domain.mesh_based_domain.cuboidimportCuboidfromscimba_torch.utils.scimba_tensorsimportLabelTensor
[docs]classRectangleMethod:"""Implements the rectangle method for cube-like domains. This sampler manages a primary volumetric sampler. At the moment, boundary samplers are not supported. Args: domain: The volumetric domain to sample. **kwargs: Additional configuration options. """def__init__(self,domain:Cuboid,**kwargs:Any):self.domain=domain#: The volumetric domain to be sampled.
[docs]defsample(self,n:int)->LabelTensor:"""Get equidistant points in the domain. Args: n: The number of points. Returns: The points. """points=self.domain.uniform_mesh(n)points.x.requires_grad_()returnpoints
[docs]defbc_sample(self,n:int)->LabelTensor:"""Get equidistant points on the domain boundary. Args: n: The number of points. Returns: The points. Raises: NotImplementedError: Boundary sampling is not supported for the rectangle method. """raiseNotImplementedError("Boundary sampling is not supported for the rectangle method.")