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

#include <GrainDropFill_fwd.hpp>

Detailed Description

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

Implements general n-d node placing algorithm, as described in https://arxiv.org/abs/1906.00636 This node generation algorithm simulates dropping grains with variable radius in a box.

First, a large bounding box is filled and only the nodes in the domain shape are kept. Thus, gaps may appear at the boundary and BasicRelax can be used to smooth them.

Usage example:

BoxShape<Vec3d> b(0.0, 1.0);
auto dx = [](const Vec3d& p) {
return std::pow(p[0]/10 + p[1]/10 + p[2]/10, 2) + 0.025;
};
DomainDiscretization<Vec3d> domain = b.discretizeBoundaryWithDensity(dx);
// execute fill domain with constant density
GrainDropFill<Vec3d> fill_engine(0.0, 1.0);
fill_engine.seed(0).initialSpacing(0.025/5).maxPoints(50000);
fill_engine(domain, dx);
See also
GeneralFill, BasicRelax

Definition at line 37 of file GrainDropFill_fwd.hpp.

Public Member Functions

 GrainDropFill (const vec_t &bot, const vec_t &top)
 Prepare to fill domain within [bot, top] bounding box. More...
 
GrainDropFillmaxPoints (int max_points)
 Maximal number of points generated. More...
 
GrainDropFillseed (int seed)
 Set custom seed for the random number generator. More...
 
GrainDropFillinitialSpacing (scalar_t dx)
 Set initial discretization density by specifying number of dots along each dimension. More...
 
GrainDropFillexcessFactor (scalar_t factor)
 Set percentage of allowed generation over the top. More...
 
template<typename func_t >
void operator() (DomainDiscretization< vec_t > &domain, const func_t &h, 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...
 
template<typename func_t >
std::vector< vec_t > fillBox (const func_t &h) const
 Actual fill algorithm which fills [bot, top] box with spacing h. More...
 
std::vector< Vec1dfillBox (const func_t &h) const
 Specialization for 1D. 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...
 
vec_t bot
 Bottom left corner of the box to fill. More...
 
vec_t top
 Top right corner of the box to fill. More...
 
scalar_t dx = -1.0
 Initial discretization spacing. More...
 
int seed_
 Seed for the random number generator. More...
 
scalar_t excess_factor = 10
 Fill excess_factor*dx over the top of the domain. 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 42 of file GrainDropFill_fwd.hpp.

Constructor & Destructor Documentation

◆ GrainDropFill()

template<typename vec_t >
mm::GrainDropFill< vec_t >::GrainDropFill ( const vec_t &  bot,
const vec_t &  top 
)

Prepare to fill domain within [bot, top] bounding box.

Definition at line 18 of file GrainDropFill.hpp.

Member Function Documentation

◆ excessFactor()

template<typename vec_t >
GrainDropFill& mm::GrainDropFill< vec_t >::excessFactor ( scalar_t  factor)
inline

Set percentage of allowed generation over the top.

Definition at line 67 of file GrainDropFill_fwd.hpp.

◆ fillBox() [1/2]

template<typename vec_t >
template<typename func_t >
std::vector< vec_t > mm::GrainDropFill< vec_t >::fillBox ( const func_t &  h) const

Actual fill algorithm which fills [bot, top] box with spacing h.

Definition at line 45 of file GrainDropFill.hpp.

◆ fillBox() [2/2]

std::vector< Vec1d > mm::GrainDropFill< Vec1d >::fillBox ( const func_t &  h) const

Specialization for 1D.

Definition at line 117 of file GrainDropFill.hpp.

◆ initialSpacing()

template<typename vec_t >
GrainDropFill& mm::GrainDropFill< vec_t >::initialSpacing ( scalar_t  dx)
inline

Set initial discretization density by specifying number of dots along each dimension.

The recommended density is 10 times less than the minimal nodal spacing. Number of data points along the last dimension is ignored.

Definition at line 65 of file GrainDropFill_fwd.hpp.

◆ maxPoints()

template<typename vec_t >
GrainDropFill& mm::GrainDropFill< vec_t >::maxPoints ( int  max_points)
inline

Maximal number of points generated.

Definition at line 57 of file GrainDropFill_fwd.hpp.

◆ operator()() [1/2]

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

Fills domain with a quality node distribution.

Parameters
domainDomain to fill with nodes. Can be partially filled.
hNodal spacing function.
typeType of the nodes. If 0 the engines default value is used.
Warning
Header #include <medusa/bits/domains/GrainDropFill.hpp> must be included additionally to #include <medusa/Medusa_fwd.hpp>.

Definition at line 28 of file GrainDropFill.hpp.

◆ operator()() [2/2]

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

Overload for constant function.

Definition at line 82 of file GrainDropFill_fwd.hpp.

◆ seed()

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

Set custom seed for the random number generator.

Definition at line 59 of file GrainDropFill_fwd.hpp.

Member Data Documentation

◆ bot

template<typename vec_t >
vec_t mm::GrainDropFill< vec_t >::bot
private

Bottom left corner of the box to fill.

Definition at line 46 of file GrainDropFill_fwd.hpp.

◆ dx

template<typename vec_t >
scalar_t mm::GrainDropFill< vec_t >::dx = -1.0
private

Initial discretization spacing.

Definition at line 48 of file GrainDropFill_fwd.hpp.

◆ excess_factor

template<typename vec_t >
scalar_t mm::GrainDropFill< vec_t >::excess_factor = 10
private

Fill excess_factor*dx over the top of the domain.

Definition at line 50 of file GrainDropFill_fwd.hpp.

◆ max_points

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

Maximal number of points generated.

Definition at line 45 of file GrainDropFill_fwd.hpp.

◆ seed_

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

Seed for the random number generator.

Definition at line 49 of file GrainDropFill_fwd.hpp.

◆ top

template<typename vec_t >
vec_t mm::GrainDropFill< vec_t >::top
private

Top right corner of the box to fill.

Definition at line 47 of file GrainDropFill_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::GrainDropFill::dx
scalar_t dx
Initial discretization spacing.
Definition: GrainDropFill_fwd.hpp:48