Medusa  1.1
Coordinate Free Mehless Method implementation
mm::GeneralSurfaceFill< vec_t, param_vec_t > Class Template Reference

#include <GeneralSurfaceFill_fwd.hpp>

Detailed Description

template<typename vec_t, typename param_vec_t>
class mm::GeneralSurfaceFill< vec_t, param_vec_t >

Implements general n-d node placing algorithm for parametrically given d-d surfaces, as described in https://arxiv.org/abs/2005.08767.

If you specifically use this algorithm, we would appreciate if you cite the above publication.

Given a regular parametrization surface \( \vec r: \Lambda \subseteq \mathbb{R}^d \to \partial \Omega \subseteq \mathbb{R}^n\), and a spacing function \( h: \partial \Omega \to (0, \infty)\) the algorithm fills the domain discretization with points spaced approximately \(h\) apart.

The algorithm starts from existing nodes in the parametrization function's domain, usually one random node. They are processed in a queue and for each node, new candidates are generated around it on a circle. The circle's radius is determined in way that when the new candidates are mapped by the parametrization function, their distance from the initial node is approximately equal to the supplied density function. This is done using the first degree Taylor polynomial. Candidates are then checked and some are accepted and added to the queue. This is repeated until no more nodes can be generated or the maximal number of points has been reached.

Usage example (filling the surface of a torus):

// Define parametrization function.
auto torus_r = [](Vec2d t){
double a = 10.0, b = 25.0;
return Vec3d((a * cos(t(1)) + b) * cos(t(0)),
(a * cos(t(1)) + b) * sin(t(0)), a * sin(t(1)));
};
// Define Jacobian of parametrization function.
auto torus_jacobian = [](Vec2d t){
double a = 10.0, b = 25.0;
Eigen::Matrix<double, 3, 2> jm;
jm.col(0) << - (a * cos(t(1)) + b) * sin(t(0)), (a * cos(t(1)) + b) * cos(t(0)), 0;
jm.col(1) << - a * sin(t(1)) * cos(t(0)), - a * sin(t(1)) * sin(t(0)), a * cos(t(1));
return jm;
};
// Define density function.
auto gradient_h = [](Vec3d p){
double h_0 = 1.0;
return h_0 + (p[0] + p[1] + p[2]) / 500.0;
};
// Define domain.
UnknownShape<Vec3d> shape;
DomainDiscretization<Vec3d> domain(shape);
// Fill domain.
GeneralSurfaceFill<Vec3d, Vec2d> gsf; gsf.seed(0); // deterministic
BoxShape<Vec2d> param_domain_shape(Vec2d{0.0, 0.0}, Vec2d{2 * PI, 2 * PI});
DomainDiscretization<Vec2d> param_domain(param_domain_shape);
domain.fill(gsf, param_domain, torus_r, torus_jacobian, gradient_h);
Warning
If GeneralFill is not working after filling the boundary, normals might be turned on the inside; see compute_normal for more information.

Definition at line 49 of file GeneralSurfaceFill_fwd.hpp.

Public Member Functions

GeneralSurfaceFillmaxPoints (int max_points)
 Maximal number of points generated. More...
 
GeneralSurfaceFillseed (int seed)
 Set custom seed for the random number generator. More...
 
GeneralSurfaceFillproximityTolerance (scalar_t zeta)
 Set proximity tolerance. More...
 
GeneralSurfaceFillnumSamples (int n_samples)
 Controls the number of generated candidates from each point. More...
 
template<typename param_func_t , typename jm_func_t , typename search_t , typename spacing_func_t >
void operator() (domain_t &domain, param_domain_t &param_domain, const param_func_t &param_function, const jm_func_t &param_jacobian, const spacing_func_t &spacing_function, search_t &tree, int type=0) const
 Fills the parametrically given surface with a quality node distribution according to the spacing_function. More...
 
template<typename param_func_t , typename search_t , typename spacing_func_t >
void fillParametrization (domain_t &domain, param_domain_t &param_domain, const param_func_t &param, const spacing_func_t &spacing_function, search_t &tree, int type=0) const
 Version with single function returning a pair of point and jacobian. More...
 
template<typename param_func_t , typename jm_func_t , typename spacing_func_t >
void operator() (domain_t &domain, param_domain_t &param_domain, const param_func_t &param_function, const jm_func_t &param_jacobian, const spacing_func_t &spacing_function, int type=0) const
 Fills given surface according to the nodal spacing function spacing_function. More...
 
template<typename param_func_t , typename jm_func_t >
void operator() (domain_t &domain, param_domain_t &param_domain, const param_func_t &param_function, const jm_func_t &param_jacobian, const scalar_t &h, int type=0) const
 Overload for constant function. More...
 
template<typename param_func_t , typename jm_func_t , typename spacing_func_t >
void operator() (domain_t &domain, DomainShape< param_vec_t > &param_domain_shape, const param_func_t &param_function, const jm_func_t &param_jacobian, const spacing_func_t &spacing_function, int type=0) const
 Overload for Shape instead of DomainDiscretization. More...
 
template<typename param_func_t , typename jm_func_t >
void operator() (domain_t &domain, DomainShape< param_vec_t > &param_domain_shape, const param_func_t &param_function, const jm_func_t &param_jacobian, const scalar_t &h, int type=0) const
 Overload for constant function and Shape instead of DomainDiscretization. More...
 

Public Types

enum  { dim = vec_t::dim, param_dim = param_vec_t::dim }
 Store dimension of the domains. More...
 
typedef DomainDiscretization< vec_t > domain_t
 Domain discretization type. More...
 
typedef DomainDiscretization< param_vec_t > param_domain_t
 Parametric domain discretization type. More...
 
typedef vec_t::scalar_t scalar_t
 Scalar type. More...
 
typedef param_vec_t::scalar_t param_scalar_t
 Parametric domain scalar type. More...
 

Private Attributes

int max_points = 5000000
 Maximal number of points generated. More...
 
int seed_
 Seed for the random number generator. More...
 
int n_samples = 15
 Number of samples. More...
 
scalar_t zeta = 1 - 1e-10
 Proximity tolerance. More...
 

Member Enumeration Documentation

◆ anonymous enum

template<typename vec_t , typename param_vec_t >
anonymous enum

Store dimension of the domains.

Enumerator
dim 

Dimensionality of the domain.

param_dim 

Dimensionality of the parametric domain.

Definition at line 57 of file GeneralSurfaceFill_fwd.hpp.

Member Function Documentation

◆ fillParametrization()

template<typename vec_t , typename param_vec_t >
template<typename param_func_t , typename search_t , typename spacing_func_t >
void mm::GeneralSurfaceFill< vec_t, param_vec_t >::fillParametrization ( domain_t domain,
param_domain_t param_domain,
const param_func_t &  param,
const spacing_func_t &  spacing_function,
search_t &  tree,
int  type = 0 
) const

Version with single function returning a pair of point and jacobian.

Definition at line 59 of file GeneralSurfaceFill.hpp.

◆ maxPoints()

template<typename vec_t , typename param_vec_t >
GeneralSurfaceFill& mm::GeneralSurfaceFill< vec_t, param_vec_t >::maxPoints ( int  max_points)
inline

Maximal number of points generated.

Warning
The actual upper bound for number of points generated is maxPoints \(\pm\) numSamples.

Definition at line 73 of file GeneralSurfaceFill_fwd.hpp.

◆ numSamples()

template<typename vec_t , typename param_vec_t >
GeneralSurfaceFill& mm::GeneralSurfaceFill< vec_t, param_vec_t >::numSamples ( int  n_samples)
inline

Controls the number of generated candidates from each point.

For 2-D it is the actual number of candidates, for 3-D it is the number of candidates on the great circle. Its value is ignored in 1-D.

Definition at line 84 of file GeneralSurfaceFill_fwd.hpp.

◆ operator()() [1/5]

template<typename vec_t , typename param_vec_t >
template<typename param_func_t , typename jm_func_t >
void mm::GeneralSurfaceFill< vec_t, param_vec_t >::operator() ( domain_t domain,
DomainShape< param_vec_t > &  param_domain_shape,
const param_func_t &  param_function,
const jm_func_t &  param_jacobian,
const scalar_t h,
int  type = 0 
) const
inline

Overload for constant function and Shape instead of DomainDiscretization.

Definition at line 139 of file GeneralSurfaceFill_fwd.hpp.

◆ operator()() [2/5]

template<typename vec_t , typename param_vec_t >
template<typename param_func_t , typename jm_func_t , typename spacing_func_t >
void mm::GeneralSurfaceFill< vec_t, param_vec_t >::operator() ( domain_t domain,
DomainShape< param_vec_t > &  param_domain_shape,
const param_func_t &  param_function,
const jm_func_t &  param_jacobian,
const spacing_func_t &  spacing_function,
int  type = 0 
) const

Overload for Shape instead of DomainDiscretization.

Definition at line 38 of file GeneralSurfaceFill.hpp.

◆ operator()() [3/5]

template<typename vec_t , typename param_vec_t >
template<typename param_func_t , typename jm_func_t >
void mm::GeneralSurfaceFill< vec_t, param_vec_t >::operator() ( domain_t domain,
param_domain_t param_domain,
const param_func_t &  param_function,
const jm_func_t &  param_jacobian,
const scalar_t h,
int  type = 0 
) const
inline

Overload for constant function.

Definition at line 124 of file GeneralSurfaceFill_fwd.hpp.

◆ operator()() [4/5]

template<typename vec_t , typename param_vec_t >
template<typename param_func_t , typename jm_func_t , typename spacing_func_t >
void mm::GeneralSurfaceFill< vec_t, param_vec_t >::operator() ( domain_t domain,
param_domain_t param_domain,
const param_func_t &  param_function,
const jm_func_t &  param_jacobian,
const spacing_func_t &  spacing_function,
int  type = 0 
) const

Fills given surface according to the nodal spacing function spacing_function.

Definition at line 27 of file GeneralSurfaceFill.hpp.

◆ operator()() [5/5]

template<typename vec_t , typename param_vec_t >
template<typename param_func_t , typename jm_func_t , typename search_t , typename spacing_func_t >
void mm::GeneralSurfaceFill< vec_t, param_vec_t >::operator() ( domain_t domain,
param_domain_t param_domain,
const param_func_t &  param_function,
const jm_func_t &  param_jacobian,
const spacing_func_t &  spacing_function,
search_t &  tree,
int  type = 0 
) const

Fills the parametrically given surface with a quality node distribution according to the spacing_function.

Parameters
domainDomain \(\Omega\) to fill with nodes. Can be partially filled.
param_domainDomain \(\Lambda\) of the parametrization function. Can be partially filled with parameters, which are taken as seeds. It is assumed that all parameters have a corresponding node in domain (but domain can contain other nodes as well).
param_functionParametrization function \(\vec r\).
param_jacobianJacobian matrix \(\nabla \vec r\) of the parametrization function. Must have full rank.
spacing_functionNodal spacing function \(h\).
treeSearch structure on domain. This can be used if the domain already has some nodes, such as when filling different patches separately.
typeType of the nodes. If 0, the engines default value is used.
Warning
Header #include <medusa/bits/domains/GeneralSurfaceFill.hpp> must be included additionally to #include <medusa/Medusa_fwd.hpp>.

Definition at line 47 of file GeneralSurfaceFill.hpp.

◆ proximityTolerance()

template<typename vec_t , typename param_vec_t >
GeneralSurfaceFill< vec_t, param_vec_t > & mm::GeneralSurfaceFill< vec_t, param_vec_t >::proximityTolerance ( scalar_t  zeta)

Set proximity tolerance.

A new candidate mush be at least zeta*h(p) away. It should hold that 0 < zeta < 1.

Definition at line 149 of file GeneralSurfaceFill.hpp.

◆ seed()

template<typename vec_t , typename param_vec_t >
GeneralSurfaceFill& mm::GeneralSurfaceFill< vec_t, param_vec_t >::seed ( int  seed)
inline

Set custom seed for the random number generator.

Definition at line 75 of file GeneralSurfaceFill_fwd.hpp.

Member Data Documentation

◆ max_points

template<typename vec_t , typename param_vec_t >
int mm::GeneralSurfaceFill< vec_t, param_vec_t >::max_points = 5000000
private

Maximal number of points generated.

Definition at line 61 of file GeneralSurfaceFill_fwd.hpp.

◆ n_samples

template<typename vec_t , typename param_vec_t >
int mm::GeneralSurfaceFill< vec_t, param_vec_t >::n_samples = 15
private

Number of samples.

Definition at line 63 of file GeneralSurfaceFill_fwd.hpp.

◆ seed_

template<typename vec_t , typename param_vec_t >
int mm::GeneralSurfaceFill< vec_t, param_vec_t >::seed_
private

Seed for the random number generator.

Definition at line 62 of file GeneralSurfaceFill_fwd.hpp.

◆ zeta

template<typename vec_t , typename param_vec_t >
scalar_t mm::GeneralSurfaceFill< vec_t, param_vec_t >::zeta = 1 - 1e-10
private

Proximity tolerance.

Definition at line 64 of file GeneralSurfaceFill_fwd.hpp.


The documentation for this class was generated from the following files:
mm::Vec3d
Vec< double, 3 > Vec3d
Convenience typedef for 3d vector of doubles.
Definition: Vec_fwd.hpp:35
mm::PI
static const double PI
Mathematical constant pi in double precision.
Definition: Config.hpp:44
mm::Vec2d
Vec< double, 2 > Vec2d
Convenience typedef for 2d vector of doubles.
Definition: Vec_fwd.hpp:34