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>
71template <
typename T, std::
size_t NDIM>
100template <
typename T, std::
size_t NDIM>
110 return base ?
base->do_pre_screening() :
false;
113 return base ?
base->pre_screening(key) :
false;
116 return base ?
base->special_refinement_needed(key) :
false;
119 return base ?
base->post_screening(key, coeff) :
false;
126 template <
typename Archive>
void serialize(Archive& ar) {
127 std::uintptr_t bits =
reinterpret_cast<std::uintptr_t
>(
base);
136template<
typename T, std::
size_t NDIM>
143 virtual std::string
name()
const {
return "default special box which only checks for the special points"; }
156 const std::vector<Vector<double, NDIM> >& special_points =
f->get_special_points();
157 if (special_points.empty())
return false;
162 const auto bperiodic =
bc.is_periodic();
163 for (
size_t i = 0; i < special_points.size(); ++i) {
173 template<
typename Archive>
185 for (
size_t i = 0; i <
NDIM; i++) {
197 if (sl % 2 == 0) ll = sl / 2;
198 else ll = (sl + 1) / 2;
207template<
typename T, std::
size_t NDIM>
214 template<
typename Archive>
217 std::string
name()
const {
return "Cuspybox_op"; }
225 if (not(key.
level() < 2)) {
230 if constexpr (
NDIM % 2 == 0) {
232 const auto bperiodic =
bc.template is_periodic<
NDIM / 2>();
237 if (ll < f->get_initial_level())
238 ll =
f->get_initial_level();
239 if (key.
level() > ll) {
245 if (
key1.is_neighbor_of(key2, bperiodic))
259template<
typename T, std::
size_t NDIM>
279 template<
typename Archive>
282 std::string
name()
const {
return "Cuspybox_op for nuclear cusps"; }
290 if (not(key.
level() < 2)) {
295 const std::vector<Vector<double, NDIM> >& special_points =
f->get_special_points();
297 "Demanded NuclearCuspyBox but the special points of the function are empty", 1);
300 std::vector<
Vector<double,
NDIM / 2> > lowdim_sp;
301 for (
size_t i = 0; i < special_points.size(); i++) {
303 for (
size_t j = 0; j <
NDIM / 2; j++) {
304 lowdim_tmp[j] = special_points[i][j];
307 "NuclearCuspyBox: Wrong format of special_point: ", 1);
309 lowdim_sp.push_back(lowdim_tmp);
314 const auto bperiodic =
bc.is_periodic();
319 for (
size_t i = 0; i < lowdim_sp.size(); ++i) {
322 const bool hit1 =
key1.is_neighbor_of(simpt, bperiodic);
323 const bool hit2 = key2.is_neighbor_of(simpt, bperiodic);
324 if (
particle == 1 and hit1)
return true;
325 else if (
particle == 2 and hit2)
return true;
326 else if (
particle == 0 and (hit1 or hit2))
return true;
335template<
typename T, std::
size_t NDIM,
typename opT,
typename specialboxT>
377 return "general_leaf_op";
405 if (
op == NULL)
return false;
406 if (key.
level() < this->f->get_initial_level())
return false;
408 const double cnorm = coeff.
normf();
412 const opkeyT
source =
op->get_source_key(key);
416 const double norm = opnorm * cnorm;
428 if (key.
level() < this->f->get_initial_level())
return false;
431 if (key.
level() < this->f->get_initial_level())
return false;
433 upsampled.
scale(-1.0);
435 const double dnorm = upsampled.
normf();
446 if (key.
level() >
f->get_special_level())
return false;
447 else if (
specialbox.check_special_points(key,
f))
return true;
452 template<
typename Archive>
455 ar & this->f & this->specialbox;
463template<
typename T, std::
size_t NDIM>
467 return "leaf_op_other";
490 return (not this->
f->get_coeffs().find(key).get()->second.has_children());
519 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:101
static int get_special_level()
Returns the default projection level for special boxes.
Definition funcdefaults.h:200
static const BoundaryConditions< NDIM > & get_bc()
Returns the default boundary conditions.
Definition funcdefaults.h:315
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:1043
double get_thresh() const
Definition mraimpl.h:340
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:1338
double truncate_tol(double tol, const keyT &key) const
Returns the truncation threshold according to truncate_method.
Definition mraimpl.h:722
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:428
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:71
Level level() const
Definition key.h:170
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:401
const Vector< Translation, NDIM > & translation() const
Definition key.h:175
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition key.h:500
void serialize(Archive &ar)
Definition leafop.h:521
bool post_screening(const Key< NDIM > &key, const GenTensor< T > &G) const override
this should never be called for this leaf_op since the function in this class as already constructed
Definition leafop.h:500
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:507
bool do_pre_screening() const override
Definition leafop.h:473
bool pre_screening(const Key< NDIM > &key) const override
Definition leafop.h:488
void sanity() const
make sanity check
Definition leafop.h:493
Leaf_op_other(const FunctionImpl< T, NDIM > *const f_)
Definition leafop.h:480
Leaf_op_other(const Leaf_op_other &other)
Definition leafop.h:484
Leaf_op_other()
Definition leafop.h:477
std::string name() const
Definition leafop.h:466
bool special_refinement_needed(const Key< NDIM > &key) const override
this should never be called for this leaf_op since the function in this class as already constructed
Definition leafop.h:514
specialboxT specialbox
Definition leafop.h:345
bool special_refinement_needed(const Key< NDIM > &key) const override
Definition leafop.h:445
void serialize(Archive &ar)
Definition leafop.h:454
bool do_pre_screening() const override
pre or post screening (see if this is the general_leaf_op or the leaf_op_other)
Definition leafop.h:349
bool pre_screening(const Key< NDIM > &key) const override
Definition leafop.h:392
bool post_screening(const Key< NDIM > &key, const GenTensor< T > &coeff) const override
Definition leafop.h:404
Leaf_op()
Definition leafop.h:353
const opT * op
the operator which is used for screening (null pointer means no screening)
Definition leafop.h:341
Leaf_op(const Leaf_op &other)
Definition leafop.h:369
virtual ~Leaf_op()
Definition leafop.h:372
Leaf_op(const FunctionImpl< T, NDIM > *const tmp, specialboxT &sb)
Definition leafop.h:361
bool compare_to_parent(const Key< NDIM > &key, const GenTensor< T > &coeff, const GenTensor< T > &parent) const
Definition leafop.h:427
Leaf_op(const FunctionImpl< T, NDIM > *const tmp, const opT *const ope, specialboxT &sb)
Definition leafop.h:365
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:339
virtual std::string name() const
Definition leafop.h:376
virtual void sanity() const
make sanity check
Definition leafop.h:382
Leaf_op(const FunctionImpl< T, NDIM > *const tmp)
Definition leafop.h:357
Definition operator.h:158
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
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 DFConvergence.h:9
@ BC_PERIODIC
Definition bc.h:52
double FunctionDefaults< NDIM >::thresh
Definition mraimpl.h:3879
std::optional< BoundaryConditions< NDIM > > FunctionDefaults< NDIM >::bc
Definition mraimpl.h:3890
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:469
NDIM & f
Definition mra.h:2817
static const double b
Definition nonlinschro.cc:119
static const double a
Definition nonlinschro.cc:118
~ElectronCuspyBox_op()
Definition leafop.h:212
std::string name() const
Definition leafop.h:217
bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:223
void serialize(Archive &ar)
Definition leafop.h:215
ElectronCuspyBox_op()
Definition leafop.h:210
virtual bool do_pre_screening() const
if true, the op uses pre_screening(key) before computing coeffs.
Definition leafop.h:76
virtual bool post_screening(const Key< NDIM > &, const GenTensor< T > &) const
Definition leafop.h:87
virtual bool pre_screening(const Key< NDIM > &) const
Definition leafop.h:80
virtual ~LeafOpBase()=default
virtual bool special_refinement_needed(const Key< NDIM > &) const
true ⇒ force refinement at the current key (e.g. cusp / special-box).
Definition leafop.h:83
bool pre_screening(const Key< NDIM > &key) const
Definition leafop.h:112
LeafOpRef & operator=(const LeafOpRef &)=default
LeafOpRef(const LeafOpRef &)=default
void serialize(Archive &ar)
Definition leafop.h:126
bool do_pre_screening() const
Definition leafop.h:109
LeafOpRef(const LeafOpBase< T, NDIM > &b)
Definition leafop.h:105
bool post_screening(const Key< NDIM > &key, const GenTensor< T > &coeff) const
Definition leafop.h:118
const LeafOpBase< T, NDIM > * base
Definition leafop.h:102
bool special_refinement_needed(const Key< NDIM > &key) const
Definition leafop.h:115
std::string name() const
Definition leafop.h:282
int particle
Definition leafop.h:277
bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:289
NuclearCuspyBox_op()
Definition leafop.h:262
~NuclearCuspyBox_op()
Definition leafop.h:273
NuclearCuspyBox_op(const size_t p)
Definition leafop.h:267
void serialize(Archive &ar)
Definition leafop.h:280
Specialbox_op()
Definition leafop.h:139
size_t get_half_of_special_level(const size_t &sl=FunctionDefaults< NDIM >::get_special_level()) const
Definition leafop.h:195
virtual bool box_is_at_boundary(const Key< NDIM > &key) const
Definition leafop.h:181
virtual ~Specialbox_op()
Definition leafop.h:141
bool check_special_points(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:155
void serialize(Archive &ar)
Definition leafop.h:175
virtual std::string name() const
Definition leafop.h:143
virtual bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f=NULL) const
Definition leafop.h:149
double norm(const T i1)
Definition test_cloud.cc:85
static Key< 1 > key1(Level n, Translation l)
Definition test_lbdeux.cc:26
constexpr std::size_t NDIM
Definition testgconv.cc:54
double source(const coordT &r)
Definition testperiodic.cc:48