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;
157 template <std::
size_t NDIM>
166 std::shared_ptr<DomainMaskInterface>
mask;
169 std::shared_ptr<SignedDFInterface<NDIM> >
sdf;
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()");
243 error(
"Unrecognized function option in DomainMaskSDFFunctor" \
244 "::setMaskFunction()");
251 template<std::
size_t NDIM>
254 template<std::
size_t NDIM>
257 template<std::
size_t NDIM>
260 template<std::
size_t NDIM>
263 template<std::
size_t NDIM>
330 return 0.5 * (1.0 - tanh(3.0 *
d /
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);
366 return 72.0*phi*(1.0-phi)*dphi*(1.0 - 2.0*phi)/
epsilon;
403 return (1.0 - erf(
d / (sqrt(2.0) *
epsilon))) * 0.5;
The interface for masking functions defined by signed distance functions.
Definition sdf_domainmask.h:104
virtual double dmask(double d) const =0
Returns the derivative of the characteristic mask function with respect to the distance (from the sur...
virtual double dsurface(double d) const =0
Returns the derivative of the normalized surface layer function.
virtual double mask(double d) const =0
Returns the characteristic mask function.
virtual ~DomainMaskInterface()
Definition sdf_domainmask.h:140
virtual double surface(double d) const =0
Returns the value of the normalized surface layer function.
Framework for combining a signed distance function (sdf) with a domain mask to produce MADNESS functi...
Definition sdf_domainmask.h:158
static const int MASK
Use the mask() function in mask.
Definition sdf_domainmask.h:175
virtual ~DomainMaskSDFFunctor()
Definition sdf_domainmask.h:248
DomainMaskSDFFunctor()
Bury the default constructor.
Definition sdf_domainmask.h:162
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
void setMaskFunction(int _mswitch)
Toggles which function from DomainMaskInterface to use when making the MADNESS function.
Definition sdf_domainmask.h:237
double operator()(const Vector< double, NDIM > &x) const
Uses the functor interface to make a MADNESS function.
Definition sdf_domainmask.h:214
DomainMaskSDFFunctor(std::shared_ptr< DomainMaskInterface > mask, std::shared_ptr< SignedDFInterface< NDIM > > sdf)
Constructor for mask/sdf functor.
Definition sdf_domainmask.h:185
static const int DMASK
Use the dmask() function in mask.
Definition sdf_domainmask.h:177
static const int MASK_COMPLEMENT
Get the complement of mask()
Definition sdf_domainmask.h:176
std::shared_ptr< DomainMaskInterface > mask
The domain mask to use.
Definition sdf_domainmask.h:166
std::shared_ptr< SignedDFInterface< NDIM > > sdf
The signed distance function.
Definition sdf_domainmask.h:169
static const int SURFACE
Use the surface() function in mask.
Definition sdf_domainmask.h:178
static const int DSURFACE
Use the dsurface() function in mask.
Definition sdf_domainmask.h:179
int mswitch
Which masking function to use (mask, surface, etc.)
Definition sdf_domainmask.h:171
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
Use a Gaussian for the surface function and the corresponding erf for the domain mask.
Definition sdf_domainmask.h:374
double mask(double d) const
Value of characteristic function at normal distance d from the surface.
Definition sdf_domainmask.h:395
double dsurface(double d) const
Value of d(surface)/ddistance.
Definition sdf_domainmask.h:435
virtual ~GaussianDomainMask()
Definition sdf_domainmask.h:440
const double epsilon
The width of the transition region.
Definition sdf_domainmask.h:379
GaussianDomainMask(double epsilon)
Constructor for the domain mask.
Definition sdf_domainmask.h:385
GaussianDomainMask()
Forbidden.
Definition sdf_domainmask.h:376
double surface(double d) const
Value of surface function at distance d normal to surface.
Definition sdf_domainmask.h:426
double dmask(double d) const
Derivative of characteristic function with respect to the normal distance.
Definition sdf_domainmask.h:412
Provides the Li-Lowengrub-Ratz-Voight (LLRV) domain mask characteristic functions.
Definition sdf_domainmask.h:301
double surface(double d) const
Value of surface function at distance d normal to surface.
Definition sdf_domainmask.h:353
const double epsilon
The width of the transition region.
Definition sdf_domainmask.h:306
virtual ~LLRVDomainMask()
Definition sdf_domainmask.h:369
LLRVDomainMask()
Forbidden.
Definition sdf_domainmask.h:303
double mask(double d) const
Value of characteristic function at normal distance d from the surface.
Definition sdf_domainmask.h:322
double dmask(double d) const
Derivative of characteristic function with respect to the normal distance.
Definition sdf_domainmask.h:339
LLRVDomainMask(double epsilon)
Constructor for the domain mask.
Definition sdf_domainmask.h:312
double dsurface(double d) const
Value of d(surface)/ddistance.
Definition sdf_domainmask.h:363
The interface for a signed distance function (sdf).
Definition sdf_domainmask.h:74
virtual double sdf(const Vector< double, NDIM > &x) const =0
Returns the signed distance from the surface,.
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] )
virtual ~SignedDFInterface()
Definition sdf_domainmask.h:92
A simple, fixed dimension vector.
Definition vector.h:64
real_function_3d mask
Definition dirac-hatom.cc:27
Main include file for MADNESS and defines Function interface.
const double pi
Mathematical constant .
Definition constants.h:48
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
void error(const char *msg)
Definition world.cc:139
static const double d
Definition nonlinschro.cc:121