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) {
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)) {
164 if constexpr (
NDIM % 2 == 0) {
166 const auto bperiodic = bc.template is_periodic<
NDIM / 2>();
171 if (ll < f->get_initial_level())
172 ll =
f->get_initial_level();
173 if (key.
level() > ll) {
179 if (key1.is_neighbor_of(key2, bperiodic))
193template<
typename T, std::
size_t NDIM>
213 template<
typename Archive>
216 std::string
name()
const {
return "Cuspybox_op for nuclear cusps"; }
224 if (not(key.
level() < 2)) {
229 const std::vector<Vector<double, NDIM> >& special_points =
f->get_special_points();
231 "Demanded NuclearCuspyBox but the special points of the function are empty", 1);
234 std::vector<
Vector<double,
NDIM / 2> > lowdim_sp;
235 for (
size_t i = 0; i < special_points.size(); i++) {
237 for (
size_t j = 0; j <
NDIM / 2; j++) {
238 lowdim_tmp[j] = special_points[i][j];
241 "NuclearCuspyBox: Wrong format of special_point: ", 1);
243 lowdim_sp.push_back(lowdim_tmp);
248 const auto bperiodic = bc.is_periodic();
253 for (
size_t i = 0; i < lowdim_sp.size(); ++i) {
259 if (ll < f->get_initial_level()) ll =
f->get_initial_level();
260 if (key.
level() > ll) {
261 if (
particle == 1 and specialkey == key1)
return true;
262 else if (
particle == 2 and specialkey == key2)
return true;
263 else if (
particle == 0 and (specialkey == key1 or specialkey == key2))
return true;
266 if (
particle == 1 and specialkey.is_neighbor_of(key1, bperiodic))
return true;
267 else if (
particle == 2 and specialkey.is_neighbor_of(key2, bperiodic))
return true;
269 (specialkey.is_neighbor_of(key1, bperiodic) or specialkey.is_neighbor_of(key2, bperiodic)))
280template<
typename T, std::
size_t NDIM,
typename opT,
typename specialboxT>
322 return "general_leaf_op";
350 if (
op == NULL)
return false;
351 if (key.
level() < this->f->get_initial_level())
return false;
353 const double cnorm = coeff.
normf();
358 const opkeyT
source =
op->get_source_key(key);
361 const std::vector<opkeyT>& disp =
op->get_disp(key.
level());
362 const opkeyT&
d = *disp.begin();
364 const double norm = opnorm * cnorm;
376 if (key.
level() < this->f->get_initial_level())
return false;
379 if (key.
level() < this->f->get_initial_level())
return false;
381 upsampled.
scale(-1.0);
383 const double dnorm = upsampled.
normf();
394 if (key.
level() >
f->get_special_level())
return false;
395 else if (
specialbox.check_special_points(key,
f))
return true;
400 template<
typename Archive>
411template<
typename T, std::
size_t NDIM>
415 return "leaf_op_other";
438 return (not this->
f->get_coeffs().find(key).get()->second.has_children());
467 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:310
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:945
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:968
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:68
Level level() const
Definition key.h:161
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:280
const Vector< Translation, NDIM > & translation() const
Definition key.h:166
void break_apart(Key< LDIM > &key1, Key< KDIM > &key2) const
break key into two low-dimensional keys
Definition key.h:336
void serialize(Archive &ar)
Definition leafop.h:469
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:455
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:448
void sanity() const
make sanity check
Definition leafop.h:441
Leaf_op_other(const FunctionImpl< T, NDIM > *const f_)
Definition leafop.h:428
Leaf_op_other(const Leaf_op_other &other)
Definition leafop.h:432
bool do_pre_screening() const
Definition leafop.h:421
Leaf_op_other()
Definition leafop.h:425
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:462
bool pre_screening(const Key< NDIM > &key) const
Definition leafop.h:436
std::string name() const
Definition leafop.h:414
specialboxT specialbox
Definition leafop.h:290
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:294
virtual bool pre_screening(const Key< NDIM > &key) const
Definition leafop.h:337
bool special_refinement_needed(const Key< NDIM > &key) const
Definition leafop.h:393
virtual bool post_screening(const Key< NDIM > &key, const GenTensor< T > &coeff) const
Definition leafop.h:349
void serialize(Archive &ar)
Definition leafop.h:402
Leaf_op()
Definition leafop.h:298
const opT * op
the operator which is used for screening (null pointer means no screening)
Definition leafop.h:286
Leaf_op(const Leaf_op &other)
Definition leafop.h:314
virtual ~Leaf_op()
Definition leafop.h:317
Leaf_op(const FunctionImpl< T, NDIM > *const tmp, specialboxT &sb)
Definition leafop.h:306
bool compare_to_parent(const Key< NDIM > &key, const GenTensor< T > &coeff, const GenTensor< T > &parent) const
Definition leafop.h:375
Leaf_op(const FunctionImpl< T, NDIM > *const tmp, const opT *const ope, specialboxT &sb)
Definition leafop.h:310
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:284
virtual std::string name() const
Definition leafop.h:321
virtual void sanity() const
make sanity check
Definition leafop.h:327
Leaf_op(const FunctionImpl< T, NDIM > *const tmp)
Definition leafop.h:302
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: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 bc.h:52
static Key< NDIM > simpt2key(const Vector< T, NDIM > &pt, Level n)
Definition funcdefaults.h:434
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:425
NDIM & f
Definition mra.h:2451
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:216
int particle
Definition leafop.h:211
bool operator()(const Key< NDIM > &key, const FunctionImpl< T, NDIM > *const f) const
Definition leafop.h:223
NuclearCuspyBox_op()
Definition leafop.h:196
~NuclearCuspyBox_op()
Definition leafop.h:207
NuclearCuspyBox_op(const size_t p)
Definition leafop.h:201
void serialize(Archive &ar)
Definition leafop.h:214
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
constexpr std::size_t NDIM
Definition testgconv.cc:54
double source(const coordT &r)
Definition testperiodic.cc:48