43#ifndef SRC_MADNESS_MRA_LEAFOP_H_
44#define SRC_MADNESS_MRA_LEAFOP_H_
49template<std::
size_t NDIM>
55template<
typename T, std::
size_t NDIM>
56class SeparatedConvolution;
61template<
typename T, std::
size_t NDIM>
68 virtual std::string
name()
const {
return "default special box which only checks for the special points"; }
81 const std::vector<Vector<double, NDIM> >& special_points =
f->get_special_points();
82 if (special_points.empty())
return false;
87 const auto bperiodic = bc.is_periodic();
88 for (
size_t i = 0; i < special_points.size(); ++i) {
98 template<
typename Archive>
110 for (
size_t i = 0; i <
NDIM; i++) {
122 if (sl % 2 == 0) ll = sl / 2;
123 else ll = (sl + 1) / 2;
132template<
typename T, std::
size_t NDIM>
139 template<
typename Archive>
142 std::string
name()
const {
return "Cuspybox_op"; }
150 if (not(key.
level() < 2)) {
155 if constexpr (
NDIM % 2 == 0) {
157 const auto bperiodic = bc.template is_periodic<
NDIM / 2>();
162 if (ll < f->get_initial_level())
163 ll =
f->get_initial_level();
164 if (key.
level() > ll) {
170 if (key1.is_neighbor_of(key2, bperiodic))
184template<
typename T, std::
size_t NDIM>
204 template<
typename Archive>
207 std::string
name()
const {
return "Cuspybox_op for nuclear cusps"; }
215 if (not(key.
level() < 2)) {
220 const std::vector<Vector<double, NDIM> >& special_points =
f->get_special_points();
222 "Demanded NuclearCuspyBox but the special points of the function are empty", 1);
225 std::vector<
Vector<double,
NDIM / 2> > lowdim_sp;
226 for (
size_t i = 0; i < special_points.size(); i++) {
228 for (
size_t j = 0; j <
NDIM / 2; j++) {
229 lowdim_tmp[j] = special_points[i][j];
232 "NuclearCuspyBox: Wrong format of special_point: ", 1);
234 lowdim_sp.push_back(lowdim_tmp);
239 const auto bperiodic = bc.is_periodic();
244 for (
size_t i = 0; i < lowdim_sp.size(); ++i) {
247 const bool hit1 = key1.is_neighbor_of(simpt, bperiodic);
248 const bool hit2 = key2.is_neighbor_of(simpt, bperiodic);
249 if (
particle == 1 and hit1)
return true;
250 else if (
particle == 2 and hit2)
return true;
251 else if (
particle == 0 and (hit1 or hit2))
return true;
260template<
typename T, std::
size_t NDIM,
typename opT,
typename specialboxT>
302 return "general_leaf_op";
330 if (
op == NULL)
return false;
331 if (key.
level() < this->f->get_initial_level())
return false;
333 const double cnorm = coeff.
normf();
337 const opkeyT
source =
op->get_source_key(key);
340 const std::vector<opkeyT>& disp =
op->get_disp(key.
level());
341 const opkeyT&
d = *disp.begin();
343 const double norm = opnorm * cnorm;
355 if (key.
level() < this->f->get_initial_level())
return false;
358 if (key.
level() < this->f->get_initial_level())
return false;
360 upsampled.
scale(-1.0);
362 const double dnorm = upsampled.
normf();
373 if (key.
level() >
f->get_special_level())
return false;
374 else if (
specialbox.check_special_points(key,
f))
return true;
379 template<
typename Archive>
390template<
typename T, std::
size_t NDIM>
394 return "leaf_op_other";
417 return (not this->
f->get_coeffs().find(key).get()->second.has_children());
446 template<
typename Archive>
Definition test_derivative.cc:24
This class is used to specify boundary conditions for all operators.
Definition bc.h:72
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:100
static const BoundaryConditions< NDIM > & get_bc()
Returns the default boundary conditions.
Definition funcdefaults.h:311
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:945
double get_thresh() const
Definition mraimpl.h:328
coeffT upsample(const keyT &key, const coeffT &coeff) const
upsample the sum coefficients of level 1 to sum coeffs on level n+1
Definition mraimpl.h:1231
double truncate_tol(double tol, const keyT &key) const
Returns the truncation threshold according to truncate_method.
Definition mraimpl.h:649
Definition lowranktensor.h:59
bool has_no_data() const
Definition gentensor.h:211
float_scalar_type normf() const
Definition lowranktensor.h:406
IsSupported< TensorTypeData< Q >, GenTensor< T > & >::type scale(Q fac)
Inplace multiplication by scalar of supported type (legacy name)
Definition lowranktensor.h:426
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:70
Level level() const
Definition key.h:169
bool is_neighbor_of(const Key &key, const array_of_bools< NDIM > &bperiodic) const
Assuming keys are at the same level, returns true if displaced by no more than 1 in any direction.
Definition key.h:325
const Vector< Translation, NDIM > & translation() const
Definition key.h:174
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition key.h:424
void serialize(Archive &ar)
Definition leafop.h:448
bool compare_to_parent(const Key< NDIM > &key, const GenTensor< T > &a, const GenTensor< T > &b) const
this should never be called for this leaf_op since the function in this class as already constructed
Definition leafop.h:434
bool post_screening(const Key< NDIM > &key, const GenTensor< T > &G) const
this should never be called for this leaf_op since the function in this class as already constructed
Definition leafop.h:427
void sanity() const
make sanity check
Definition leafop.h:420
Leaf_op_other(const FunctionImpl< T, NDIM > *const f_)
Definition leafop.h:407
Leaf_op_other(const Leaf_op_other &other)
Definition leafop.h:411
bool do_pre_screening() const
Definition leafop.h:400
Leaf_op_other()
Definition leafop.h:404
bool special_refinement_needed(const Key< NDIM > &key) const
this should never be called for this leaf_op since the function in this class as already constructed
Definition leafop.h:441
bool pre_screening(const Key< NDIM > &key) const
Definition leafop.h:415
std::string name() const
Definition leafop.h:393
specialboxT specialbox
Definition leafop.h:270
virtual bool do_pre_screening() const
pre or post screening (see if this is the general_leaf_op or the leaf_op_other)
Definition leafop.h:274
virtual bool pre_screening(const Key< NDIM > &key) const
Definition leafop.h:317
bool special_refinement_needed(const Key< NDIM > &key) const
Definition leafop.h:372
virtual bool post_screening(const Key< NDIM > &key, const GenTensor< T > &coeff) const
Definition leafop.h:329
void serialize(Archive &ar)
Definition leafop.h:381
Leaf_op()
Definition leafop.h:278
const opT * op
the operator which is used for screening (null pointer means no screening)
Definition leafop.h:266
Leaf_op(const Leaf_op &other)
Definition leafop.h:294
virtual ~Leaf_op()
Definition leafop.h:297
Leaf_op(const FunctionImpl< T, NDIM > *const tmp, specialboxT &sb)
Definition leafop.h:286
bool compare_to_parent(const Key< NDIM > &key, const GenTensor< T > &coeff, const GenTensor< T > &parent) const
Definition leafop.h:354
Leaf_op(const FunctionImpl< T, NDIM > *const tmp, const opT *const ope, specialboxT &sb)
Definition leafop.h:290
const FunctionImpl< T, NDIM > * f
the function which the operators use (in most cases this function is also the function that will be c...
Definition leafop.h:264
virtual std::string name() const
Definition leafop.h:301
virtual void sanity() const
make sanity check
Definition leafop.h:307
Leaf_op(const FunctionImpl< T, NDIM > *const tmp)
Definition leafop.h:282
Convolutions in separated form (including Gaussian)
Definition operator.h:139
A simple, fixed dimension vector.
Definition vector.h:64
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:28
static double pow(const double *a, const double *b)
Definition lda.h:74
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
@ BC_PERIODIC
Definition bc.h:52
static void user_to_sim(const Vector< double, NDIM > &xuser, Vector< double, NDIM > &xsim)
Convert user coords (cell[][]) to simulation coords ([0,1]^ndim)
Definition funcdefaults.h:455
NDIM & f
Definition mra.h:2543
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
static const double thresh
Definition rk.cc:45
~ElectronCuspyBox_op()
Definition leafop.h:137
std::string name() const
Definition leafop.h:142
bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:148
void serialize(Archive &ar)
Definition leafop.h:140
ElectronCuspyBox_op()
Definition leafop.h:135
std::string name() const
Definition leafop.h:207
int particle
Definition leafop.h:202
bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:214
NuclearCuspyBox_op()
Definition leafop.h:187
~NuclearCuspyBox_op()
Definition leafop.h:198
NuclearCuspyBox_op(const size_t p)
Definition leafop.h:192
void serialize(Archive &ar)
Definition leafop.h:205
Specialbox_op()
Definition leafop.h:64
size_t get_half_of_special_level(const size_t &sl=FunctionDefaults< NDIM >::get_special_level()) const
Definition leafop.h:120
virtual bool box_is_at_boundary(const Key< NDIM > &key) const
Definition leafop.h:106
virtual ~Specialbox_op()
Definition leafop.h:66
bool check_special_points(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:80
void serialize(Archive &ar)
Definition leafop.h:100
virtual std::string name() const
Definition leafop.h:68
virtual bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f=NULL) const
Definition leafop.h:74
Definition lowrankfunction.h:336
double norm(const T i1)
Definition test_cloud.cc:85
constexpr std::size_t NDIM
Definition testgconv.cc:54
double source(const coordT &r)
Definition testperiodic.cc:48