57 #ifndef MADNESS_MRA_SDF_DOMAINMASK_H__INCLUDED 
   58 #define MADNESS_MRA_SDF_DOMAINMASK_H__INCLUDED 
   73     template <std::
size_t NDIM>
 
  113         virtual double mask(
double d) 
const = 0;
 
  120         virtual double dmask(
double d) 
const = 0;
 
  131         virtual double surface(
double d) 
const = 0;
 
  138         virtual double dsurface(
double d) 
const = 0;
 
  157     template <std::
size_t NDIM>
 
  187             : mask(mask), sdf(sdf), mswitch(MASK)
 
  199             : mask(mask), sdf(sdf), mswitch(MASK) {
 
  200             if(_mswitch == MASK || _mswitch == DMASK || _mswitch == SURFACE ||
 
  201                _mswitch == DSURFACE || _mswitch == MASK_COMPLEMENT) {
 
  205                 error(
"Unrecognized function option in DomainMaskSDFFunctor" \
 
  206                       "::DomainMaskSDFFunctor()");
 
  216                 return mask->mask(sdf->sdf(x));
 
  218                 return 1.0 - mask->mask(sdf->sdf(x));
 
  220                 return mask->dmask(sdf->sdf(x));
 
  222                 return mask->surface(sdf->sdf(x));
 
  224                 return mask->dsurface(sdf->sdf(x));
 
  226                 error(
"Unknown function from DomainMaskInterface in " \
 
  227                       "DomainMaskSDFFunctor::operator()");
 
  238             if(_mswitch == MASK || _mswitch == DMASK || _mswitch == SURFACE ||
 
  239                _mswitch == DSURFACE || _mswitch == MASK_COMPLEMENT) {
 
  243                 error(
"Unrecognized function option in DomainMaskSDFFunctor" \
 
  244                       "::setMaskFunction()");
 
  251     template<std::
size_t NDIM>
 
  252     const int DomainMaskSDFFunctor<NDIM>::MASK = 1;
 
  254     template<std::
size_t NDIM>
 
  255     const int DomainMaskSDFFunctor<NDIM>::MASK_COMPLEMENT = 2;
 
  257     template<std::
size_t NDIM>
 
  258     const int DomainMaskSDFFunctor<NDIM>::DMASK = 3;
 
  260     template<std::
size_t NDIM>
 
  263     template<std::
size_t NDIM>
 
  264     const int DomainMaskSDFFunctor<NDIM>::DSURFACE = 5;
 
  323             if (d > 8.0*epsilon) {
 
  326             else if (d < -8.0*epsilon) {
 
  330                 return 0.5 * (1.0 - 
tanh(3.0 * d / epsilon));
 
  340             if (
fabs(d) > 8.0*epsilon) {
 
  344                 double tanh3d = 
tanh(3.0*d/epsilon);
 
  345                 return 1.5*(tanh3d*tanh3d - 1.0) / 
epsilon;
 
  354             double phi = 
mask(d);
 
  355             double phic = 1.0 - phi;
 
  356             return 36.0*phi*phi*phic*phic/
epsilon;
 
  364             double phi = 
mask(d);
 
  365             double dphi = 
dmask(d);
 
  366             return 72.0*phi*(1.0-phi)*dphi*(1.0 - 2.0*phi)/
epsilon;
 
  396             if (d > 8.0*epsilon) {
 
  399             else if (d < -8.0*epsilon) {
 
  403                 return (1.0 - 
erf(d / (
sqrt(2.0) * epsilon))) * 0.5;
 
  413             if (
fabs(d) > 8.0*epsilon) {
 
  445 #endif // MADNESS_MRA_SDF_DOMAINMASK_H__INCLUDED 
Use a Gaussian for the surface function and the corresponding erf for the domain mask. 
Definition: sdf_domainmask.h:374
void error(const char *msg)
Definition: world.cc:128
Definition: shared_ptr_bits.h:38
double mask(double d) const 
Value of characteristic function at normal distance d from the surface. 
Definition: sdf_domainmask.h:395
const mpreal exp(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2234
const double pi
Mathematical constant pi. 
Definition: constants.h:44
const mpreal erf(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2457
Main include file for MADNESS and defines Function interface. 
virtual double surface(double d) const =0
Returns the value of the normalized surface layer function. 
const double epsilon
The width of the transition region. 
Definition: sdf_domainmask.h:379
void setMaskFunction(int _mswitch)
Toggles which function from DomainMaskInterface to use when making the MADNESS function. 
Definition: sdf_domainmask.h:237
const double epsilon
The width of the transition region. 
Definition: sdf_domainmask.h:306
static const int MASK_COMPLEMENT
Get the complement of mask() 
Definition: sdf_domainmask.h:176
double dmask(double d) const 
Derivative of characteristic function with respect to the normal distance. 
Definition: sdf_domainmask.h:339
virtual double sdf(const Vector< double, NDIM > &x) const =0
Returns the signed distance from the surface,. 
Framework for combining a signed distance function (sdf) with a domain mask to produce MADNESS functi...
Definition: sdf_domainmask.h:158
virtual double dmask(double d) const =0
Returns the derivative of the characteristic mask function with respect to the distance (from the sur...
double dsurface(double d) const 
Value of d(surface)/ddistance. 
Definition: sdf_domainmask.h:435
virtual ~SignedDFInterface()
Definition: sdf_domainmask.h:92
virtual ~LLRVDomainMask()
Definition: sdf_domainmask.h:369
virtual double dsurface(double d) const =0
Returns the derivative of the normalized surface layer function. 
The interface for a signed distance function (sdf). 
Definition: sdf_domainmask.h:74
double surface(double d) const 
Value of surface function at distance d normal to surface. 
Definition: sdf_domainmask.h:426
DomainMaskSDFFunctor(std::shared_ptr< DomainMaskInterface > mask, std::shared_ptr< SignedDFInterface< NDIM > > sdf, int _mswitch)
Constructor for mask/sdf function specifying the desired function (mask, surface, etc...
Definition: sdf_domainmask.h:197
double surface(double d) const 
Value of surface function at distance d normal to surface. 
Definition: sdf_domainmask.h:353
virtual ~DomainMaskInterface()
Definition: sdf_domainmask.h:140
tensorT sqrt(const tensorT &s, double tol=1e-8)
Computes matrix square root (not used any more?) 
Definition: DFcode/moldft.cc:446
static const int DMASK
Use the dmask() function in mask. 
Definition: sdf_domainmask.h:177
GaussianDomainMask(double epsilon)
Constructor for the domain mask. 
Definition: sdf_domainmask.h:385
Abstract base class interface required for functors used as input to Functions. 
Definition: function_interface.h:58
virtual double mask(double d) const =0
Returns the characteristic mask function. 
double mask(double d) const 
Value of characteristic function at normal distance d from the surface. 
Definition: sdf_domainmask.h:322
Provides the Li-Lowengrub-Ratz-Voight (LLRV) domain mask characteristic functions. 
Definition: sdf_domainmask.h:301
double operator()(const Vector< double, NDIM > &x) const 
Uses the functor interface to make a MADNESS function. 
Definition: sdf_domainmask.h:214
virtual ~GaussianDomainMask()
Definition: sdf_domainmask.h:440
DomainMaskSDFFunctor(std::shared_ptr< DomainMaskInterface > mask, std::shared_ptr< SignedDFInterface< NDIM > > sdf)
Constructor for mask/sdf functor. 
Definition: sdf_domainmask.h:185
const mpreal tanh(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2352
virtual Vector< double, NDIM > grad_sdf(const Vector< double, NDIM > &x) const =0
Returns the gradient of the signed distance from the surface (i.e., dsdf(x)/dx[i] ) ...
static const int SURFACE
Use the surface() function in mask. 
Definition: sdf_domainmask.h:178
const mpreal fabs(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2187
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces. 
Definition: chem/atomutil.cc:45
The interface for masking functions defined by signed distance functions. 
Definition: sdf_domainmask.h:104
LLRVDomainMask(double epsilon)
Constructor for the domain mask. 
Definition: sdf_domainmask.h:312
double dmask(double d) const 
Derivative of characteristic function with respect to the normal distance. 
Definition: sdf_domainmask.h:412
double dsurface(double d) const 
Value of d(surface)/ddistance. 
Definition: sdf_domainmask.h:363
virtual ~DomainMaskSDFFunctor()
Definition: sdf_domainmask.h:248
static const int DSURFACE
Use the dsurface() function in mask. 
Definition: sdf_domainmask.h:179
static const int MASK
Use the mask() function in mask. 
Definition: sdf_domainmask.h:175