32#ifndef MADNESS_MRA_FUNCDEFAULTS_H__INCLUDED
33#define MADNESS_MRA_FUNCDEFAULTS_H__INCLUDED
51 template <std::
size_t NDIM>
class Displacements;
52 template <
typename T, std::
size_t NDIM>
class FunctionImpl;
55 static const int MAXK = 30;
72 template<std::
size_t NDIM=1>
75 else if (treestate==
compressed) os <<
"compressed";
76 else if (treestate==
nonstandard) os <<
"nonstandard";
79 else if (treestate==
redundant) os <<
"redundant";
81 else if (treestate==
on_demand) os <<
"on_demand";
82 else if (treestate==
unknown) os <<
"unknown";
100 template <std::
size_t NDIM>
118 static std::optional<BoundaryConditions<NDIM>>
bc;
126 static std::shared_ptr< WorldDCPmapInterface< Key<NDIM> > >
pmap;
316 if (!
bc.has_value()) {
317 const std::string msg =
"FunctionDefaults<" + std::to_string(
NDIM) +
">::get_bc: must initialize boundary conditions by set_bc or set_defaults or startup";
344 const double dk = (double)
k;
346 double lo_sim=
lo/Lmax;
415 static std::shared_ptr< WorldDCPmapInterface< Key<NDIM> > >&
get_pmap() {
434 static std::shared_ptr< WorldDCPmapInterface< Key<NDIM> > >
get_pmap(
World& world) {
459 pmap->redistribute(world,newpmap);
468 template <std::
size_t NDIM>
470 for (std::size_t i=0; i<
NDIM; ++i)
477 template <
typename T, std::
size_t NDIM>
480 double twon = std::pow(2.0,
double(n));
481 for (std::size_t i=0; i<
NDIM; ++i) {
488 template <std::
size_t NDIM>
490 for (std::size_t i=0; i<
NDIM; ++i)
This header should include pretty much everything needed for the parallel runtime.
Provides BoundaryConditions.
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
long ndim() const
Returns the number of dimensions in the tensor.
Definition basetensor.h:144
This class is used to specify boundary conditions for all operators.
Definition bc.h:72
static void set_width(const Tensor< double > &width)
Definition displacements.h:336
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 Tensor< double > make_default_cell_width()
Definition funcdefaults.h:138
static void set_tensor_type(const TensorType &t)
Sets the default tensor type.
Definition funcdefaults.h:334
static int get_k()
Returns the default wavelet order.
Definition funcdefaults.h:170
static void set_apply_randomize(bool value)
Sets the random load balancing for integral operators flag.
Definition funcdefaults.h:299
static bool get_project_randomize()
Gets the random load balancing for projection flag.
Definition funcdefaults.h:305
static std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > make_default_pmap(World &world)
Makes a default process map for the given world.
Definition mraimpl.h:3765
static bool truncate_on_project
If true initial projection inserts at n-1 not n.
Definition funcdefaults.h:115
static int get_truncate_mode()
Gets the default truncation mode.
Definition funcdefaults.h:235
static void set_truncate_mode(int value)
Sets the default truncation mode.
Definition funcdefaults.h:242
static bool apply_randomize
If true use randomization for load balancing in apply integral operator.
Definition funcdefaults.h:116
static void set_truncate_on_project(bool value)
Sets the default truncate on project flag.
Definition funcdefaults.h:289
static void set_thresh(double value)
Sets the default threshold.
Definition funcdefaults.h:190
static void clear_cell()
clear user cell – will be reset once a function is loaded from file
Definition funcdefaults.h:359
static double cell_volume
Volume of simulation cell.
Definition funcdefaults.h:122
static void set_special_level(int value)
Existing functions are unaffected.
Definition funcdefaults.h:213
static void set_k(int value)
Sets the default wavelet order.
Definition funcdefaults.h:177
static void redistribute(World &world, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &newpmap)
Sets the default process map and redistributes all functions using the old map.
Definition funcdefaults.h:458
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:183
static int k
Wavelet order.
Definition funcdefaults.h:106
static double get_cell_volume()
Returns the volume of the user cell.
Definition funcdefaults.h:410
static int get_max_refine_level()
Gets the default maximum adaptive refinement level.
Definition funcdefaults.h:220
static bool get_debug()
Gets the default debug flag, which gates verbose MRA diagnostics.
Definition funcdefaults.h:272
static void set_debug(bool value)
Sets the default debug flag; see get_debug.
Definition funcdefaults.h:277
static int truncate_mode
Truncation method.
Definition funcdefaults.h:111
static void set_default_pmap(World &world)
Definition mraimpl.h:3772
static int pmap_nproc
Number of processes assumed by pmap, -1 indicates uninitialized pmap.
Definition funcdefaults.h:127
static bool get_refine()
Gets the default adaptive refinement flag.
Definition funcdefaults.h:248
static Tensor< double > cell_width
Width of simulation cell in each dimension.
Definition funcdefaults.h:120
static void set_autorefine(bool value)
Sets the default adaptive autorefinement flag.
Definition funcdefaults.h:267
static double thresh
Truncation threshold.
Definition funcdefaults.h:107
static void set_bc(const BoundaryConditions< NDIM > &value)
Sets the default boundary conditions.
Definition funcdefaults.h:324
static void set_project_randomize(bool value)
Sets the random load balancing for projection flag.
Definition funcdefaults.h:310
static int get_pmap_nproc()
Returns number of the default processes returned by get_pmap()
Definition funcdefaults.h:429
static bool get_autorefine()
Gets the default adaptive autorefinement flag.
Definition funcdefaults.h:260
static bool debug
Controls output of debug info.
Definition funcdefaults.h:114
static int special_level
Minimum level for fine scale projection of special boxes.
Definition funcdefaults.h:109
static double cell_min_width
Size of smallest dimension.
Definition funcdefaults.h:123
static std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > pmap
Default mapping of keys to processes.
Definition funcdefaults.h:126
static TensorType get_tensor_type()
Returns the default tensor type.
Definition funcdefaults.h:329
static const Tensor< double > & get_cell_width()
Returns the width of each user cell dimension.
Definition funcdefaults.h:390
static std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap()
Returns the default process map that was last initialized via set_default_pmap()
Definition funcdefaults.h:415
static void set_initial_level(int value)
Sets the default initial projection level.
Definition funcdefaults.h:207
static void set_cubic_cell(double lo, double hi)
Sets the user cell to be cubic with each dimension having range [lo,hi].
Definition funcdefaults.h:383
static double get_cell_geometric_mean_width()
Returns the geometric mean width of the user cell, volume^(1/NDIM)
Definition funcdefaults.h:400
static double cell_geometric_mean_width
volume^(1/NDIM), the mean dimension
Definition funcdefaults.h:124
static void set_refine(bool value)
Sets the default adaptive refinement flag.
Definition funcdefaults.h:255
static void set_max_refine_level(int value)
Sets the default maximum adaptive refinement level.
Definition funcdefaults.h:227
static const BoundaryConditions< NDIM > & get_bc()
Returns the default boundary conditions.
Definition funcdefaults.h:315
static Tensor< double > cell
cell[NDIM][2] Simulation cell, cell(0,0)=xlo, cell(0,1)=xhi, ...
Definition funcdefaults.h:119
static void set_cell(const Tensor< double > &value)
Sets the user cell for the simulation.
Definition funcdefaults.h:374
static void set_pmap(const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &value)
Sets the default process map (does not redistribute existing functions)
Definition funcdefaults.h:446
static int initial_level
Initial level for fine scale projection.
Definition funcdefaults.h:108
static bool autorefine
Whether to autorefine in multiplication, etc.
Definition funcdefaults.h:113
static const Tensor< double > & get_rcell_width()
Returns the reciprocal of the width of each user cell dimension.
Definition funcdefaults.h:395
static Tensor< double > make_default_cell()
Definition funcdefaults.h:129
static std::optional< BoundaryConditions< NDIM > > bc
Default boundary conditions, not initialized by default and must be set explicitly before use.
Definition funcdefaults.h:118
static int set_length_scale(const double lo, const size_t k=get_k())
adapt the special level to resolve the smallest length scale
Definition funcdefaults.h:343
static void print()
Definition mraimpl.h:3779
static std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > get_pmap(World &world)
Returns the default process map that can be used with the given world.
Definition funcdefaults.h:434
static Tensor< double > rcell_width
Reciprocal of width.
Definition funcdefaults.h:121
static bool get_apply_randomize()
Gets the random load balancing for integral operators flag.
Definition funcdefaults.h:294
static double get_cell_min_width()
Returns the minimum width of any user cell dimension.
Definition funcdefaults.h:405
static void recompute_cell_info()
Definition funcdefaults.h:147
static bool project_randomize
If true use randomization for load balancing in project/refine.
Definition funcdefaults.h:117
static const Tensor< double > & get_cell()
Gets the user cell for the simulation.
Definition funcdefaults.h:352
static void set_defaults(World &world)
Definition mraimpl.h:3744
static int max_refine_level
Level at which to stop refinement.
Definition funcdefaults.h:110
static TensorType tt
structure of the tensor in FunctionNode
Definition funcdefaults.h:125
static int get_initial_level()
Returns the default initial projection level.
Definition funcdefaults.h:195
static bool get_truncate_on_project()
Gets the default truncate on project flag.
Definition funcdefaults.h:282
static bool refine
Whether to refine new functions.
Definition funcdefaults.h:112
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:70
A tensor is a multidimensional array.
Definition tensor.h:318
T max(long *ind=0) const
Return the maximum value (and if ind is non-null, its index) in the Tensor.
Definition tensor.h:1704
T product() const
Return the product of all elements of the tensor.
Definition tensor.h:1677
T min(long *ind=0) const
Return the minimum value (and if ind is non-null, its index) in the Tensor.
Definition tensor.h:1684
void clear()
Frees all memory and resests to state of default constructor.
Definition tensor.h:1901
A simple, fixed dimension vector.
Definition vector.h:64
Interface to be provided by any process map.
Definition worlddc.h:125
A parallel world class.
Definition world.h:134
static World & get_default()
Default World object accessor.
Definition world.h:269
ProcessID nproc() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:349
static double lo
Definition dirac-hatom.cc:23
Multidimension Key for MRA tree and associated iterators.
#define MADNESS_PRAGMA_CLANG(x)
Definition madness_config.h:200
#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
std::ostream & operator<<(std::ostream &os, const particle< PDIM > &p)
Definition lowrankfunction.h:401
static Key< NDIM > simpt2key(const Vector< T, NDIM > &pt, Level n)
Definition funcdefaults.h:478
TreeState
Definition funcdefaults.h:60
@ nonstandard_after_apply
s and d coeffs, state after operator application
Definition funcdefaults.h:65
@ on_demand
no coeffs anywhere, but a functor providing if necessary
Definition funcdefaults.h:68
@ redundant_after_merge
s coeffs everywhere, must be summed up to yield the result
Definition funcdefaults.h:67
@ reconstructed
s coeffs at the leaves only
Definition funcdefaults.h:61
@ nonstandard
s and d coeffs in internal nodes
Definition funcdefaults.h:63
@ unknown
Definition funcdefaults.h:69
@ compressed
d coeffs in internal nodes, s and d coeffs at the root, empty leaves may be present
Definition funcdefaults.h:62
@ redundant
s coeffs everywhere
Definition funcdefaults.h:66
@ nonstandard_with_leaves
like nonstandard, with s coeffs at the leaves
Definition funcdefaults.h:64
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
int64_t Translation
Definition key.h:58
static void sim_to_user(const Vector< double, NDIM > &xsim, Vector< double, NDIM > &xuser)
Convert simulation coords ([0,1]^ndim) to user coords (FunctionDefaults<NDIM>::get_cell())
Definition funcdefaults.h:489
static const int MAXLEVEL
The maximum depth of refinement possible.
Definition funcdefaults.h:58
static const Slice _(0,-1, 1)
int Level
Definition key.h:59
bool initialized()
Check if the MADNESS runtime has been initialized (and not subsequently finalized).
Definition world.cc:75
static double pop(std::vector< double > &v)
Definition SCF.cc:117
TensorType
low rank representations of tensors (see gentensor.h)
Definition gentensor.h:120
@ TT_FULL
Definition gentensor.h:120
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2233
static const int MAXK
The maximum wavelet order presently supported.
Definition funcdefaults.h:55
Defines and implements most of Tensor.
constexpr std::size_t NDIM
Definition testgconv.cc:54
Implement the madness:Vector class, an extension of std::array that supports some mathematical operat...
Implements WorldContainer.