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;
88 for (
size_t i = 0; i < special_points.size(); ++i) {
94 if (ll < f->get_initial_level()) ll =
f->get_initial_level();
95 if (key.
level() > ll) {
96 if (specialkey == key)
return true;
107 template<
typename Archive>
119 for (
size_t i = 0; i <
NDIM; i++) {
131 if (sl % 2 == 0) ll = sl / 2;
132 else ll = (sl + 1) / 2;
141template<
typename T, std::
size_t NDIM>
148 template<
typename Archive>
151 std::string
name()
const {
return "Cuspybox_op"; }
159 if (not(key.
level() < 2)) {
171 if (ll < f->get_initial_level()) ll =
f->get_initial_level();
172 if (key.
level() > ll) {
173 if (key1 == key2)
return true;
176 if (key1.is_neighbor_of(key2, bperiodic))
return true;
187template<
typename T, std::
size_t NDIM>
207 template<
typename Archive>
210 std::string
name()
const {
return "Cuspybox_op for nuclear cusps"; }
218 if (not(key.
level() < 2)) {
223 const std::vector<Vector<double, NDIM> >& special_points =
f->get_special_points();
225 "Demanded NuclearCuspyBox but the special points of the function are empty", 1);
228 std::vector<
Vector<double,
NDIM / 2> > lowdim_sp;
229 for (
size_t i = 0; i < special_points.size(); i++) {
231 for (
size_t j = 0; j <
NDIM / 2; j++) {
232 lowdim_tmp[j] = special_points[i][j];
235 "NuclearCuspyBox: Wrong format of special_point: ", 1);
237 lowdim_sp.push_back(lowdim_tmp);
242 std::vector<bool> bperiodic = bc.is_periodic();
247 for (
size_t i = 0; i < lowdim_sp.size(); ++i) {
253 if (ll < f->get_initial_level()) ll =
f->get_initial_level();
254 if (key.
level() > ll) {
255 if (
particle == 1 and specialkey == key1)
return true;
256 else if (
particle == 2 and specialkey == key2)
return true;
257 else if (
particle == 0 and (specialkey == key1 or specialkey == key2))
return true;
260 if (
particle == 1 and specialkey.is_neighbor_of(key1, bperiodic))
return true;
261 else if (
particle == 2 and specialkey.is_neighbor_of(key2, bperiodic))
return true;
263 (specialkey.is_neighbor_of(key1, bperiodic) or specialkey.is_neighbor_of(key2, bperiodic)))
274template<
typename T, std::
size_t NDIM,
typename opT,
typename specialboxT>
316 return "general_leaf_op";
344 if (
op == NULL)
return false;
345 if (key.
level() < this->f->get_initial_level())
return false;
347 const double cnorm = coeff.
normf();
352 const opkeyT
source =
op->get_source_key(key);
355 const std::vector<opkeyT>& disp =
op->get_disp(key.
level());
356 const opkeyT&
d = *disp.begin();
358 const double norm = opnorm * cnorm;
370 if (key.
level() < this->f->get_initial_level())
return false;
373 if (key.
level() < this->f->get_initial_level())
return false;
375 upsampled.
scale(-1.0);
377 const double dnorm = upsampled.
normf();
388 if (key.
level() >
f->get_special_level())
return false;
389 else if (
specialbox.check_special_points(key,
f))
return true;
394 template<
typename Archive>
405template<
typename T, std::
size_t NDIM>
409 return "leaf_op_other";
432 return (not this->
f->get_coeffs().find(key).get()->second.has_children());
461 template<
typename Archive>
Definition test_derivative.cc:24
This class is used to specify boundary conditions for all operators.
Definition funcdefaults.h:101
std::vector< bool > is_periodic() const
Convenience for application of integral operators.
Definition funcdefaults.h:166
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:204
static const BoundaryConditions< NDIM > & get_bc()
Returns the default boundary conditions.
Definition funcdefaults.h:413
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:942
double get_thresh() const
Definition mraimpl.h:307
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:1210
int get_special_level() const
Definition funcimpl.h:965
double truncate_tol(double tol, const keyT &key) const
Returns the truncation threshold according to truncate_method.
Definition mraimpl.h:628
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:66
Level level() const
Definition key.h:159
const Vector< Translation, NDIM > & translation() const
Definition key.h:164
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition key.h:269
bool is_neighbor_of(const Key &key, const std::vector< bool > &bperiodic) const
Assuming keys are at the same level, returns true if displaced by no more than 1 in any direction.
Definition key.h:222
void serialize(Archive &ar)
Definition leafop.h:463
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:449
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:442
void sanity() const
make sanity check
Definition leafop.h:435
Leaf_op_other(const FunctionImpl< T, NDIM > *const f_)
Definition leafop.h:422
Leaf_op_other(const Leaf_op_other &other)
Definition leafop.h:426
bool do_pre_screening() const
Definition leafop.h:415
Leaf_op_other()
Definition leafop.h:419
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:456
bool pre_screening(const Key< NDIM > &key) const
Definition leafop.h:430
std::string name() const
Definition leafop.h:408
specialboxT specialbox
Definition leafop.h:284
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:288
virtual bool pre_screening(const Key< NDIM > &key) const
Definition leafop.h:331
bool special_refinement_needed(const Key< NDIM > &key) const
Definition leafop.h:387
virtual bool post_screening(const Key< NDIM > &key, const GenTensor< T > &coeff) const
Definition leafop.h:343
void serialize(Archive &ar)
Definition leafop.h:396
Leaf_op()
Definition leafop.h:292
const opT * op
the operator which is used for screening (null pointer means no screening)
Definition leafop.h:280
Leaf_op(const Leaf_op &other)
Definition leafop.h:308
virtual ~Leaf_op()
Definition leafop.h:311
Leaf_op(const FunctionImpl< T, NDIM > *const tmp, specialboxT &sb)
Definition leafop.h:300
bool compare_to_parent(const Key< NDIM > &key, const GenTensor< T > &coeff, const GenTensor< T > &parent) const
Definition leafop.h:369
Leaf_op(const FunctionImpl< T, NDIM > *const tmp, const opT *const ope, specialboxT &sb)
Definition leafop.h:304
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:278
virtual std::string name() const
Definition leafop.h:315
virtual void sanity() const
make sanity check
Definition leafop.h:321
Leaf_op(const FunctionImpl< T, NDIM > *const tmp)
Definition leafop.h:296
Convolutions in separated form (including Gaussian)
Definition operator.h:136
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:34
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 funcdefaults.h:56
static Key< NDIM > simpt2key(const Vector< T, NDIM > &pt, Level n)
Definition funcdefaults.h:533
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:524
NDIM & f
Definition mra.h:2416
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:146
std::string name() const
Definition leafop.h:151
bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:157
void serialize(Archive &ar)
Definition leafop.h:149
ElectronCuspyBox_op()
Definition leafop.h:144
std::string name() const
Definition leafop.h:210
int particle
Definition leafop.h:205
bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:217
NuclearCuspyBox_op()
Definition leafop.h:190
~NuclearCuspyBox_op()
Definition leafop.h:201
NuclearCuspyBox_op(const size_t p)
Definition leafop.h:195
void serialize(Archive &ar)
Definition leafop.h:208
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:129
virtual bool box_is_at_boundary(const Key< NDIM > &key) const
Definition leafop.h:115
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:109
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:332
double norm(const T i1)
Definition test_cloud.cc:72
static const std::size_t NDIM
Definition testpdiff.cc:42
double source(const coordT &r)
Definition testperiodic.cc:48