Medusa  1.1
Coordinate Free Mehless Method implementation
mm::GeneralFill< vec_t > Class Template Reference

#include <GeneralFill_fwd.hpp>

Detailed Description

template<typename vec_t>
class mm::GeneralFill< vec_t >

Implements general n-d node placing algorithm, as described in https://arxiv.org/abs/1812.03160 If you specifically use this algorithm, we would appreciate if you cite the above publication.

The algorithm starts from existing nodes, usually the boundary discretization nodes. They are processed in a queue and for each node, new candidates are generated around it on a circle with radius defined by a supplied density function. 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:

GeneralFill<Vec3d> fill_engine;
fill_engine.seed(1);
// create test domain
BoxShape<Vec3d> b({0, 0, 0}, {1.2, 1.5, 1.1});
BallShape<Vec3d> c({0, 0, 0}, 0.5);
DomainDiscretization<Vec3d> domain(b-c);
// define target density
auto dx = [](const Vec3d& p) {
return std::pow(p[0]/10 + p[1]/10 + p[2]/10, 2) + 0.025;
};
domain.fill(fill_engine, dx);

Using background grid:

KDGrid<Vec2d> grid(bot, top, 0.005);
fill_engine(domain, dx, grid);
See also
GrainDropFill, BasicRelax

Definition at line 43 of file GeneralFill_fwd.hpp.

Public Member Functions

GeneralFillmaxPoints (int max_points)
 Maximal number of points generated. More...
 
GeneralFillseed (int seed)
 Set custom seed for the random number generator. More...
 
GeneralFillproximityTolerance (scalar_t zeta)
 Set proximity tolerance. More...
 
GeneralFillnumSamples (int n_samples)
 Controls the number of generated candidates from each point. More...
 
template<typename func_t >
void operator() (DomainDiscretization< vec_t > &domain, const func_t &h, int type=0) const
 Fills given domain according to the nodal spacing function h. More...
 
template<typename func_t , typename search_structure_t >
void operator() (DomainDiscretization< vec_t > &domain, const func_t &h, search_structure_t &search, int type=0) const
 Fills domain with a quality node distribution. More...
 
void operator() (DomainDiscretization< vec_t > &domain, const scalar_t &h, int type=0) const
 Overload for constant function. More...
 

Public Types

enum  { dim = vec_t::dim }
 Store dimension of the domain. More...
 
typedef vec_t::scalar_t scalar_t
 Scalar type;. More...
 
typedef vec_t vector_t
 Vector 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 >
anonymous enum

Store dimension of the domain.

Enumerator
dim 

Dimensionality of the domain.

Definition at line 48 of file GeneralFill_fwd.hpp.

Member Function Documentation

◆ maxPoints()

template<typename vec_t >
GeneralFill& mm::GeneralFill< 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 63 of file GeneralFill_fwd.hpp.

◆ numSamples()

template<typename vec_t >
GeneralFill& mm::GeneralFill< 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 74 of file GeneralFill_fwd.hpp.

◆ operator()() [1/3]

template<typename vec_t >
template<typename func_t >
void mm::GeneralFill< vec_t >::operator() ( DomainDiscretization< vec_t > &  domain,
const func_t &  h,
int  type = 0 
) const

Fills given domain according to the nodal spacing function h.

◆ operator()() [2/3]

template<typename vec_t >
template<typename func_t , typename search_structure_t >
void mm::GeneralFill< vec_t >::operator() ( DomainDiscretization< vec_t > &  domain,
const func_t &  h,
search_structure_t &  search,
int  type = 0 
) const

Fills domain with a quality node distribution.

Parameters
domainDomain to fill with nodes. Can be partially filled.
hNodal spacing function.
searchSpatial search structure to be used, e.g. a KDTree or KDGrid.
typeType of the nodes. If 0 the engines default value is used.
Warning
Header #include <medusa/bits/domains/GeneralFill.hpp> must be included additionally to #include <medusa/Medusa_fwd.hpp>.

◆ operator()() [3/3]

template<typename vec_t >
void mm::GeneralFill< vec_t >::operator() ( DomainDiscretization< vec_t > &  domain,
const scalar_t h,
int  type = 0 
) const
inline

Overload for constant function.

Definition at line 95 of file GeneralFill_fwd.hpp.

◆ proximityTolerance()

template<typename vec_t >
GeneralFill& mm::GeneralFill< 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.

◆ seed()

template<typename vec_t >
GeneralFill& mm::GeneralFill< vec_t >::seed ( int  seed)
inline

Set custom seed for the random number generator.

Definition at line 65 of file GeneralFill_fwd.hpp.

Member Data Documentation

◆ max_points

template<typename vec_t >
int mm::GeneralFill< vec_t >::max_points = 5000000
private

Maximal number of points generated.

Definition at line 51 of file GeneralFill_fwd.hpp.

◆ n_samples

template<typename vec_t >
int mm::GeneralFill< vec_t >::n_samples = 15
private

Number of samples.

Definition at line 53 of file GeneralFill_fwd.hpp.

◆ seed_

template<typename vec_t >
int mm::GeneralFill< vec_t >::seed_
private

Seed for the random number generator.

Definition at line 52 of file GeneralFill_fwd.hpp.

◆ zeta

template<typename vec_t >
scalar_t mm::GeneralFill< vec_t >::zeta = 1 - 1e-10
private

Proximity tolerance.

Definition at line 54 of file GeneralFill_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