1 | /*
|
---|
2 | * ExportGraph_ToJobs.hpp
|
---|
3 | *
|
---|
4 | * Created on: 08.03.2012
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef EXPORTGRAPH_TOJOBS_HPP_
|
---|
9 | #define EXPORTGRAPH_TOJOBS_HPP_
|
---|
10 |
|
---|
11 | // include config.h
|
---|
12 | #ifdef HAVE_CONFIG_H
|
---|
13 | #include <config.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #include <string>
|
---|
17 | #include <vector>
|
---|
18 |
|
---|
19 | #include "Fragmentation/HydrogenSaturation_enum.hpp"
|
---|
20 | #include "Fragmentation/Exporters/ExportGraph.hpp"
|
---|
21 | #include "Fragmentation/Summation/SetValues/SamplingGridProperties.hpp"
|
---|
22 | #include "LinearAlgebra/Vector.hpp"
|
---|
23 |
|
---|
24 | class ExportGraph_ToJobsTest;
|
---|
25 |
|
---|
26 | /** ExportGraph_ToJobs implements an ExportGraph by sending the created
|
---|
27 | * configurations of fragmentary systems as jobs to a server.
|
---|
28 | *
|
---|
29 | */
|
---|
30 | class ExportGraph_ToJobs : public ExportGraph
|
---|
31 | {
|
---|
32 | //!> grant unit test access
|
---|
33 | friend class ExportGraph_ToJobsTest;
|
---|
34 | public:
|
---|
35 | /** Constructor for ExportGraph_ToJobs.
|
---|
36 | *
|
---|
37 | * Sets default level.
|
---|
38 | *
|
---|
39 | * \param _graph Graph with all KeySet's
|
---|
40 | * \param _treatment whether hydrogen is excluded in the _graph or not
|
---|
41 | * \param _saturation whether we saturate dangling bonds or not
|
---|
42 | * \param _globalsaturationpositions possibly empty map with global information
|
---|
43 | * where to place saturation hydrogens to fulfill consistency principle
|
---|
44 | */
|
---|
45 | ExportGraph_ToJobs(
|
---|
46 | const Graph &_graph,
|
---|
47 | const enum HydrogenTreatment _treatment,
|
---|
48 | const enum HydrogenSaturation _saturation,
|
---|
49 | const SaturatedFragment::GlobalSaturationPositions_t &_globalsaturationpositions);
|
---|
50 | virtual ~ExportGraph_ToJobs();
|
---|
51 |
|
---|
52 | bool operator()();
|
---|
53 |
|
---|
54 | /** Sets the level for the sampling of the density.
|
---|
55 | *
|
---|
56 | * \param _level level to set
|
---|
57 | */
|
---|
58 | void setLevel(const size_t _level) { level = _level; }
|
---|
59 |
|
---|
60 | /** Sets how far apart discrete points may be at most per axis.
|
---|
61 | *
|
---|
62 | * \param _max_meshwidth maximum allowed mesh width.
|
---|
63 | */
|
---|
64 | void setMaximumMeshWidth(const double _max_meshwidth) { max_meshwidth = _max_meshwidth; }
|
---|
65 |
|
---|
66 | /** Helper to get the global domain grid from the current simulation box.
|
---|
67 | *
|
---|
68 | * Grid extensions are obtained from World::getDomain(). Level from parameter.
|
---|
69 | *
|
---|
70 | * \param _level level for this SamplingGrid
|
---|
71 | * \return domain grid as SamplingGridProperties
|
---|
72 | */
|
---|
73 | static SamplingGridProperties getDomainGrid(const int _level);
|
---|
74 |
|
---|
75 | private:
|
---|
76 |
|
---|
77 | /** Helper function to get the discrete extent of the grid that
|
---|
78 | * captures the whole of the fragment inside \a _minmax, and some
|
---|
79 | * additional boundary \a _minimum_empty_boundary for a given
|
---|
80 | * domain \a _domain with some grid level. If the fragment is larger than
|
---|
81 | * the empty boundary, we make the small fragment grid at most three times
|
---|
82 | * the extent of the fragment.
|
---|
83 | *
|
---|
84 | * We need to maintain the following properties:
|
---|
85 | * -# the fragment grid's begin and end need to reside (exactly) on grid points
|
---|
86 | * of the global \a _domain
|
---|
87 | * -# the length of the fragment grid in \a _domain's deltas needs to be a
|
---|
88 | * power of 2.
|
---|
89 | *
|
---|
90 | * In order to achieve these, we use the center of the fragment obtained from
|
---|
91 | * its extensions in \a _minmax and convert it to the next lower and upper grid
|
---|
92 | * points on \a _domain. For increasing powers of 2 we check the extent of the
|
---|
93 | * gridpoints by going half of the gridpoints back and forth relative to these
|
---|
94 | * center grid points. If their length relative to \a _domain's delta is
|
---|
95 | * sufficient to capture the desired extent of fragment, namely \a _minmax
|
---|
96 | * including \a _minimum_empty_boundary, we are done. We need to do this
|
---|
97 | * iteratively, as the fragment grid may exceed \a _domain's begin or end
|
---|
98 | * and shifting is required.
|
---|
99 | *
|
---|
100 | * \param _minmax minimum and maximum components of fragment's bounding box
|
---|
101 | * \param _domain grid with begin and end components and grid level
|
---|
102 | * \param _minimum_empty_boundary additional empty boundary around fragment
|
---|
103 | * \return grid with begin and end points and and grid level to have same spacing as domain
|
---|
104 | */
|
---|
105 | static SamplingGridProperties getGridExtentsForGivenBoundingBox(
|
---|
106 | const std::pair<Vector, Vector> &_minmax,
|
---|
107 | const SamplingGridProperties &_domain,
|
---|
108 | const double & _minimum_empty_boundary);
|
---|
109 |
|
---|
110 | /** Helper function to calculate the required grid level for a fragment \a _grid
|
---|
111 | * such that is discretization mesh width is below the acceptable \a _max_meshwidth.
|
---|
112 | *
|
---|
113 | * \param _grid grid properties of the fragment, sets its level on return
|
---|
114 | * \param _max_meshwidth uppermost acceptable mesh width
|
---|
115 | */
|
---|
116 | static void setAcceptableFragmentLevel(
|
---|
117 | SamplingGridProperties &_grid,
|
---|
118 | const double &_max_meshwidth);
|
---|
119 |
|
---|
120 | //>! log of two
|
---|
121 | static const double log_two;
|
---|
122 |
|
---|
123 | private:
|
---|
124 | //!> resolution of sampled electron density as \f$2^{\mathrm{level}}\f$
|
---|
125 | size_t level;
|
---|
126 | //!> maximum allowed mesh width, i.e. discrete points may be at most that far part per axis
|
---|
127 | double max_meshwidth;
|
---|
128 | //!> desired minimum empty boundary around the fragment
|
---|
129 | const double minimum_empty_boundary;
|
---|
130 | };
|
---|
131 |
|
---|
132 | #endif /* EXPORTGRAPH_TOJOBS_HPP_ */
|
---|