MADNESS 0.10.1
leafop.h
Go to the documentation of this file.
1/*
2 This file is part of MADNESS.
3
4 Copyright (C) 2007,2010 Oak Ridge National Laboratory
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 For more information please contact:
21
22 Robert J. Harrison
23 Oak Ridge National Laboratory
24 One Bethel Valley Road
25 P.O. Box 2008, MS-6367
26
27 email: harrisonrj@ornl.gov
28 tel: 865-241-3937
29 fax: 865-572-0680
30*/
31
32/*
33* Leafop.h
34 *
35 * Created on: Apr 12, 2016
36 * Author: kottmanj
37 *
38 * Definition of Operators which operate on leaf boxes
39 * includes special operators for cuspy funtions (f12 applications) which enforce deeper refinement on the "diagonal" boxes (coordinate r1 == coordinate r2)
40 *
41 */
42
43#ifndef SRC_MADNESS_MRA_LEAFOP_H_
44#define SRC_MADNESS_MRA_LEAFOP_H_
45
46namespace madness {
47
48// forward declarations
49template<std::size_t NDIM>
50class Key;
51
52template<typename T>
53class GenTensor;
54
55template<typename T, std::size_t NDIM>
57
58
59/// Abstract base for leaf_ops with the four-hook interface used by
60/// composite_product_op_NS (do_pre_screening, pre_screening,
61/// special_refinement_needed, post_screening).
62///
63/// This base is intentionally non-templated on the convolution-op type or the
64/// special-box helper, so that polymorphic dispatch is possible across all
65/// concrete leaf_ops the composite operator can take.
66///
67/// NOTE: the leaf_op concept used by `multiply`, `hartree_product`, `apply`
68/// (the *_leaf_op, op_leaf_op, hartree_leaf_op types in funcimpl.h) is a
69/// different concept — those are operator()-based callables with key/coeff
70/// signatures and are not unified here.
71template <typename T, std::size_t NDIM>
72struct LeafOpBase {
73 virtual ~LeafOpBase() = default;
74
75 /// if true, the op uses pre_screening(key) before computing coeffs.
76 virtual bool do_pre_screening() const { return false; }
77
78 /// true ⇒ the current key is already a leaf; do not refine further.
79 /// Only called when do_pre_screening() == true.
80 virtual bool pre_screening(const Key<NDIM>& /*key*/) const { return false; }
81
82 /// true ⇒ force refinement at the current key (e.g. cusp / special-box).
83 virtual bool special_refinement_needed(const Key<NDIM>& /*key*/) const { return false; }
84
85 /// true ⇒ the computed coefficients are sufficiently small/converged that
86 /// the current key can be a leaf node.
87 virtual bool post_screening(const Key<NDIM>& /*key*/,
88 const GenTensor<T>& /*coeff*/) const { return false; }
89};
90
91
92/// Value-type adapter that satisfies the existing concept used by
93/// composite_product_op_NS (do_pre_screening, pre_screening,
94/// special_refinement_needed, post_screening, serialize) by forwarding to a
95/// LeafOpBase<T,NDIM> through a pointer.
96///
97/// Lifetime: the caller must keep the LeafOpBase alive for the duration of
98/// the composite_product / composite_inner call. This matches MADNESS's
99/// existing convention (Leaf_op holds a raw FunctionImpl pointer the same way).
100template <typename T, std::size_t NDIM>
101struct LeafOpRef {
102 const LeafOpBase<T, NDIM>* base = nullptr;
103
104 LeafOpRef() = default;
105 explicit LeafOpRef(const LeafOpBase<T, NDIM>& b) : base(&b) {}
106 LeafOpRef(const LeafOpRef&) = default;
107 LeafOpRef& operator=(const LeafOpRef&) = default;
108
109 bool do_pre_screening() const {
110 return base ? base->do_pre_screening() : false;
111 }
112 bool pre_screening(const Key<NDIM>& key) const {
113 return base ? base->pre_screening(key) : false;
114 }
115 bool special_refinement_needed(const Key<NDIM>& key) const {
116 return base ? base->special_refinement_needed(key) : false;
117 }
118 bool post_screening(const Key<NDIM>& key, const GenTensor<T>& coeff) const {
119 return base ? base->post_screening(key, coeff) : false;
120 }
121
122 /// Pointer serialization: archive the bit pattern via uintptr_t. This is
123 /// only meaningful for in-process tasks (the leaf_op must live in the same
124 /// address space across the task boundary), which matches the existing
125 /// MADNESS convention (Leaf_op already holds a raw FunctionImpl pointer).
126 template <typename Archive> void serialize(Archive& ar) {
127 std::uintptr_t bits = reinterpret_cast<std::uintptr_t>(base);
128 ar & bits;
129 base = reinterpret_cast<const LeafOpBase<T, NDIM>*>(bits);
130 }
131};
132
133/// helper structure for the Leaf_op
134/// The class has an operator which decides if a given key belongs to a special box (needs further refinement up to a special level)
135/// this is the default class which always gives back false
136template<typename T, std::size_t NDIM>
138public:
140
141 virtual ~Specialbox_op() {}
142
143 virtual std::string name() const { return "default special box which only checks for the special points"; }
144
145 /// the operator which deceides if the given box is special
146 /// @param[in] the key of the current box
147 /// @param[in] the function which will be constructed (if it is needed)
148 /// @param[out] bool which states if the box is special or not
149 virtual bool operator()(const Key<NDIM>& key, const FunctionImpl<T, NDIM> *const f = NULL) const { return false; }
150
151 // check if on of the special points is in the current box (or at low refinement level in a neighbouring box)
152 /// @param[in] the key of the box
153 /// @param[in] the function which will be constructed (if it is needed)
154 bool
155 check_special_points(const Key<NDIM>& key, const FunctionImpl<T, NDIM> *const f) const {
156 const std::vector<Vector<double, NDIM> >& special_points = f->get_special_points();
157 if (special_points.empty()) return false;
158 // level 0 and 1 has only boundary boxes
159 if (key.level() > 1 and box_is_at_boundary(key)) return false;
160 // check for all special points if they are neighbours of the current box
162 const auto bperiodic = bc.is_periodic();
163 for (size_t i = 0; i < special_points.size(); ++i) {
165 user_to_sim(special_points[i], simpt);
166 if (key.is_neighbor_of(simpt, bperiodic)) return true;
167 else return false;
168 }
169 return false;
170 }
171
172
173 template<typename Archive>
174 void
175 serialize(Archive& ar) {}
176
177 /// Determine if a given box is at the boundary of the simulation box
178 /// @param[in] the key of the current box
179 /// Since boxes of level 0 and 1 are always at the boundary this case should be avoided
180 /// if the boundary conditions are periodic then all boxes are boundary boxes
181 virtual bool box_is_at_boundary(const Key<NDIM>& key) const {
182 // l runs from l=0 to l=2^n-1 for every dimension
183 // if one l is = 2^n or 0 we are at the boundary
184 // note that boxes of level 0 and 1 are always boundary boxes
185 for (size_t i = 0; i < NDIM; i++) {
186 if (key.translation()[i] == 0 or key.translation()[i] == pow(2, key.level()) - 1) {
187 if (FunctionDefaults<NDIM>::get_bc()(i, 0) != BC_PERIODIC)return true;
188 }
189 }
190 return false;
191 }
192
193 // if you want to use milder refinement conditions for special boxes with increasing refinement level
194 // Cuspybox_op needs this
196 size_t ll = sl;
197 if (sl % 2 == 0) ll = sl / 2;
198 else ll = (sl + 1) / 2;
199 return ll;
200 }
201
202};
203
204/// the high_dimensional key is broken appart into two lower dimensional keys, if they are neighbours of each other then refinement
205/// up to the special_level is enforced
206/// For general class description see the base class Specialbox_op
207template<typename T, std::size_t NDIM>
208struct ElectronCuspyBox_op : public Specialbox_op<T, NDIM> {
209public:
211
213
214 template<typename Archive>
215 void serialize(Archive& ar) {}
216
217 std::string name() const { return "Cuspybox_op"; }
218
219 /// Operator which decides if the key belongs to a special box
220 /// The key is broken apart in two lower dimensional keys (for electron cusps this is 6D -> 2x3D)
221 /// if the keys are neighbours then refinement up to the special level is enforced (means the 6D box is close to the cusp or contains it)
222 /// if the refinement level is already beyond half of the special_level then refinement is only enforded if the broken keys are the same (6D box contains cusp)
223 bool operator()(const Key<NDIM>& key, const FunctionImpl<T, NDIM> *const f) const {
224 // do not treat boundary boxes beyond level 2 as special (level 1 and 0 consist only of boundary boxes)
225 if (not(key.level() < 2)) {
226 if (this->box_is_at_boundary(key)) return false;
227 }
228
229 // Cuspybox_op only valid for even dimensions, if uneven dims are needed just make a new class with NDIM+1/2 and NDIM-LDIM
230 if constexpr (NDIM % 2 == 0) {
232 const auto bperiodic = bc.template is_periodic<NDIM / 2>();
233 Key<NDIM / 2> key1;
234 Key<NDIM / 2> key2;
235 key.break_apart(key1, key2);
236 int ll = this->get_half_of_special_level();
237 if (ll < f->get_initial_level())
238 ll = f->get_initial_level();
239 if (key.level() > ll) {
240 if (key1 == key2)
241 return true;
242 else
243 return false;
244 } else {
245 if (key1.is_neighbor_of(key2, bperiodic))
246 return true;
247 else
248 return false;
249 }
250 }
251 MADNESS_EXCEPTION("We should not end up here (check further of cuspy box)", 1);
252 return false;
253 }
254
255};
256
257/// This works similar to the Cuspybox_op: The key is broken apart (2N-dimensional -> 2x N-Dimensional)
258/// then it is checked if one of the lower dimensional keys contains a lower dimensional special points (which will be the nuclear-coordinates)
259template<typename T, std::size_t NDIM>
260struct NuclearCuspyBox_op : public Specialbox_op<T, NDIM> {
261public:
263 // failsafe
264 if (NDIM % 2 != 0) MADNESS_EXCEPTION("NuclearCuspyBox works only for even dimensions", 1);
265 }
266
267 NuclearCuspyBox_op(const size_t p) : particle(p) {
268 // failsafe
269 if (NDIM % 2 != 0) MADNESS_EXCEPTION("NuclearCuspyBox works only for even dimensions", 1);
270 MADNESS_ASSERT(particle == 1 or particle == 2 or particle == 0);
271 }
272
274
275 // particle==0: check both particles
276 // particle==1 or particle==2: check only particle1 or 2
278
279 template<typename Archive>
280 void serialize(Archive& ar) { ar & particle; }
281
282 std::string name() const { return "Cuspybox_op for nuclear cusps"; }
283
284 /// Operator which decides if the key belongs to a special box
285 /// The key is broken appart in two lower dimensional keys (6D -> 2x3D)
286 /// The special points should be given in a format which can also be broken appart
287 /// so: 6D special_points = (3D-special-points, 3D-special-points)
288 /// if the refinement level is already beyond half of the special_level then refinement is only enforded if the broken keys are the same (6D box contains cusp)
289 bool operator()(const Key<NDIM>& key, const FunctionImpl<T, NDIM> *const f) const {
290 if (not(key.level() < 2)) {
291 if (this->box_is_at_boundary(key)) return false;
292 }
293 MADNESS_ASSERT(particle == 1 or particle == 2 or particle == 0);
294 if (f == NULL) MADNESS_EXCEPTION("NuclearCuspyBox: Pointer to function is NULL", 1);
295 const std::vector<Vector<double, NDIM> >& special_points = f->get_special_points();
296 if (special_points.empty()) MADNESS_EXCEPTION(
297 "Demanded NuclearCuspyBox but the special points of the function are empty", 1);
298
299 // break the special points into 3D points
300 std::vector<Vector<double, NDIM / 2> > lowdim_sp;
301 for (size_t i = 0; i < special_points.size(); i++) {
302 Vector<double, NDIM / 2> lowdim_tmp;
303 for (size_t j = 0; j < NDIM / 2; j++) {
304 lowdim_tmp[j] = special_points[i][j];
305 // check if the formatting is correct
306 if (special_points[i][j] != special_points[i][NDIM / 2 + j]) MADNESS_EXCEPTION(
307 "NuclearCuspyBox: Wrong format of special_point: ", 1);
308 }
309 lowdim_sp.push_back(lowdim_tmp);
310 }
311
312 // now break the key appart and check if one if the results is in the neighbourhood of a special point
313 BoundaryConditions<NDIM / 2> bc = FunctionDefaults<NDIM / 2>::get_bc();
314 const auto bperiodic = bc.is_periodic();
315 Key<NDIM / 2> key1;
316 Key<NDIM / 2> key2;
317
318 key.break_apart(key1, key2);
319 for (size_t i = 0; i < lowdim_sp.size(); ++i) {
320 Vector<double, NDIM / 2> simpt;
321 user_to_sim(lowdim_sp[i], simpt);
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;
327 else return false;
328 }
329 return false;
330 }
331
332
333};
334
335template<typename T, std::size_t NDIM, typename opT, typename specialboxT>
336class Leaf_op : public LeafOpBase<T, NDIM> {
337public:
338 /// the function which the operators use (in most cases this function is also the function that will be constructed)
340 /// the operator which is used for screening (null pointer means no screening)
341 const opT *op;
342 /// special box structure: has an operator which decides if a given key belongs to a special box
343 /// the base class Specialbox_op<T,NDIM> just gives back false for every key
344 /// the derived class Cuspybox_op<T,NDIM> is used for potentials containing cusps at coalescence points of electrons
345 specialboxT specialbox;
346
347 /// pre or post screening (see if this is the general_leaf_op or the leaf_op_other)
348 bool
349 do_pre_screening() const override {
350 return false;
351 }
352
354 : f(NULL), op(NULL), specialbox(specialboxT()) {
355 }
356
358 : f(tmp), op(NULL), specialbox(specialboxT()) {
359 }
360
361 Leaf_op(const FunctionImpl<T, NDIM> *const tmp, specialboxT& sb)
362 : f(tmp), op(NULL), specialbox(sb) {
363 }
364
365 Leaf_op(const FunctionImpl<T, NDIM> *const tmp, const opT *const ope, specialboxT& sb)
366 : f(tmp), op(ope), specialbox(sb) {
367 }
368
369 Leaf_op(const Leaf_op& other) : f(other.f), op(other.op), specialbox(other.specialbox) {}
370
371 virtual
373 }
374
375 virtual std::string
376 name() const {
377 return "general_leaf_op";
378 }
379
380 /// make sanity check
381 virtual void
382 sanity() const {
383 if (f == NULL) MADNESS_EXCEPTION(("Error in " + name() + " pointer to function is NULL").c_str(), 1);
384 }
385
386public:
387 /// pre-determination
388 /// the decision if the current box will be a leaf box is made from information of another function
389 /// this is needed for on demand function
390 /// not that the on-demand function that is being constructed is not the function in this class
391 bool
392 pre_screening(const Key<NDIM>& key) const override {
393 MADNESS_EXCEPTION("pre-screening was called for leaf_op != leaf_op_other", 1);
394 return false;
395 }
396
397 /// post-determination
398 /// determination if the box will be a leaf box after the coefficients are made
399 /// the function that is being constructed is the function in this class
400 /// the function will use the opartor op in order to screen, if op is a NULL pointer the result is always: false
401 /// @param[in] key: the key to the current box
402 /// @param[in] coeff: Coefficients of the current box
403 bool
404 post_screening(const Key<NDIM>& key, const GenTensor<T>& coeff) const override {
405 if (op == NULL) return false;
406 if (key.level() < this->f->get_initial_level()) return false;
407 sanity();
408 const double cnorm = coeff.normf();
409 // const auto bperiodic = bc.is_periodic();
410
411 typedef Key<opT::opdim> opkeyT;
412 const opkeyT source = op->get_source_key(key);
413
414 const double thresh = (this->f->truncate_tol(this->f->get_thresh(), key));
415 const double opnorm = op->norm_bound(key.level(), source); // the operator's largest block at this level
416 const double norm = opnorm * cnorm;
417
418 return norm < thresh;
419 }
420
421 /// determines if a node is well represented compared to the parents
422 /// @param[in] key the FunctionNode which we want to determine if it's a leaf node
423 /// @param[in] coeff the coeffs of key
424 /// @param[in] parent the coeffs of key's parent node
425 /// @return is the FunctionNode of key a leaf node?
426 bool
427 compare_to_parent(const Key<NDIM>& key, const GenTensor<T>& coeff, const GenTensor<T>& parent) const {
428 if (key.level() < this->f->get_initial_level()) return false;
429 //this->sanity();
430 if (parent.has_no_data()) return false;
431 if (key.level() < this->f->get_initial_level()) return false;
432 GenTensor<T> upsampled = this->f->upsample(key, parent);
433 upsampled.scale(-1.0);
434 upsampled += coeff;
435 const double dnorm = upsampled.normf();
436 const bool is_leaf = (dnorm < this->f->truncate_tol(this->f->get_thresh(), key.level()));
437 return is_leaf;
438 }
439
440 /// check if the box is a special box
441 /// first check: Is one of the special points defined in the function f in the current box or a neighbour box
442 /// second check: Is the box special according to the specialbox operator (see class description of Specialbox_op)
443 /// @param[in] the key of the box
444 bool
445 special_refinement_needed(const Key<NDIM>& key) const override {
446 if (key.level() > f->get_special_level()) return false;
447 else if (specialbox.check_special_points(key, f)) return true;
448 else if (specialbox(key, f)) return true;
449 else return false;
450 }
451
452 template<typename Archive>
453 void
454 serialize(Archive& ar) {
455 ar & this->f & this->specialbox;
456 }
457
458};
459
460/// leaf_op for construction of an on-demand function
461/// the function in the class is the function which defines the structure of the on-demand function
462/// means: The tree of the function which is to construct will mirror the tree-structure of the function in this class (function variable defined in base-class)
463template<typename T, std::size_t NDIM>
464class Leaf_op_other : public Leaf_op<T, NDIM, SeparatedConvolution<double, NDIM>, Specialbox_op<T, NDIM> > {
465 std::string
466 name() const {
467 return "leaf_op_other";
468 }
469 /// we only need the pre-determination based on the already constructed function f
470 /// if f at box(key) is a leaf then return true
471public:
472 bool
473 do_pre_screening() const override {
474 return true;
475 }
476
479
481 this->f = f_;
482 }
483
485 : Leaf_op<T, NDIM, SeparatedConvolution<double, NDIM>, Specialbox_op<T, NDIM> >(other.f) {}
486
487 bool
488 pre_screening(const Key<NDIM>& key) const override {
489 MADNESS_ASSERT(this->f->get_coeffs().is_local(key));
490 return (not this->f->get_coeffs().find(key).get()->second.has_children());
491 }
492
493 void sanity() const {
494 if (this->f == 0) MADNESS_EXCEPTION("Leaf_op_other: f is NULL pointer", 1);
495 if (this->op != 0) MADNESS_EXCEPTION("Leaf_op_other: Screening operator was set", 1);
496 }
497
498 /// this should never be called for this leaf_op since the function in this class as already constructed
499 bool
500 post_screening(const Key<NDIM>& key, const GenTensor<T>& G) const override {
501 MADNESS_EXCEPTION("post-determination was called for leaf_op_other", 1);
502 return false;
503 }
504
505 /// this should never be called for this leaf_op since the function in this class as already constructed
506 bool
507 compare_to_parent(const Key<NDIM>& key, const GenTensor<T>& a, const GenTensor<T>& b) const {
508 MADNESS_EXCEPTION("compare-to-parent was called for leaf_op_other", 1);
509 return false;
510 }
511
512 /// this should never be called for this leaf_op since the function in this class as already constructed
513 bool
514 special_refinement_needed(const Key<NDIM>& key) const override {
515 MADNESS_EXCEPTION("special_refinement_needed was called for leaf_op_other", 1);
516 return false;
517 }
518
519 template<typename Archive>
520 void
521 serialize(Archive& ar) {
522 ar & this->f;
523 }
524
525};
526
527} /* namespace madness */
528
529#endif /* SRC_MADNESS_MRA_LEAFOP_H_ */
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
Definition leafop.h:72
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
Definition leafop.h:137
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