/* * ExportGraph_ToJobs.hpp * * Created on: 08.03.2012 * Author: heber */ #ifndef EXPORTGRAPH_TOJOBS_HPP_ #define EXPORTGRAPH_TOJOBS_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include "Fragmentation/HydrogenSaturation_enum.hpp" #include "Fragmentation/Exporters/ExportGraph.hpp" #include "Fragmentation/Summation/SetValues/SamplingGridProperties.hpp" #include "LinearAlgebra/Vector.hpp" class ExportGraph_ToJobsTest; /** ExportGraph_ToJobs implements an ExportGraph by sending the created * configurations of fragmentary systems as jobs to a server. * */ class ExportGraph_ToJobs : public ExportGraph { //!> grant unit test access friend class ExportGraph_ToJobsTest; public: /** Constructor for ExportGraph_ToJobs. * * Sets default level. * * \param _graph Graph with all KeySet's * \param _treatment whether hydrogen is excluded in the _graph or not * \param _saturation whether we saturate dangling bonds or not * \param _globalsaturationpositions possibly empty map with global information * where to place saturation hydrogens to fulfill consistency principle */ ExportGraph_ToJobs( const Graph &_graph, const enum HydrogenTreatment _treatment, const enum HydrogenSaturation _saturation, const SaturatedFragment::GlobalSaturationPositions_t &_globalsaturationpositions); virtual ~ExportGraph_ToJobs(); bool operator()(); /** Sets the level for the sampling of the density. * * \param _level level to set */ void setLevel(const size_t _level) { level = _level; } /** Sets how far apart discrete points may be at most per axis. * * \param _max_meshwidth maximum allowed mesh width. */ void setMaximumMeshWidth(const double _max_meshwidth) { max_meshwidth = _max_meshwidth; } /** Helper to get the global domain grid from the current simulation box. * * Grid extensions are obtained from World::getDomain(). Level from parameter. * * \param _level level for this SamplingGrid * \return domain grid as SamplingGridProperties */ static SamplingGridProperties getDomainGrid(const int _level); private: /** Helper function to get the discrete extent of the grid that * captures the whole of the fragment inside \a _minmax, and some * additional boundary \a _minimum_empty_boundary for a given * domain \a _domain with some grid level. If the fragment is larger than * the empty boundary, we make the small fragment grid at most three times * the extent of the fragment. * * We need to maintain the following properties: * -# the fragment grid's begin and end need to reside (exactly) on grid points * of the global \a _domain * -# the length of the fragment grid in \a _domain's deltas needs to be a * power of 2. * * In order to achieve these, we use the center of the fragment obtained from * its extensions in \a _minmax and convert it to the next lower and upper grid * points on \a _domain. For increasing powers of 2 we check the extent of the * gridpoints by going half of the gridpoints back and forth relative to these * center grid points. If their length relative to \a _domain's delta is * sufficient to capture the desired extent of fragment, namely \a _minmax * including \a _minimum_empty_boundary, we are done. We need to do this * iteratively, as the fragment grid may exceed \a _domain's begin or end * and shifting is required. * * \param _minmax minimum and maximum components of fragment's bounding box * \param _domain grid with begin and end components and grid level * \param _minimum_empty_boundary additional empty boundary around fragment * \return grid with begin and end points and and grid level to have same spacing as domain */ static SamplingGridProperties getGridExtentsForGivenBoundingBox( const std::pair &_minmax, const SamplingGridProperties &_domain, const double & _minimum_empty_boundary); /** Helper function to calculate the required grid level for a fragment \a _grid * such that is discretization mesh width is below the acceptable \a _max_meshwidth. * * \param _grid grid properties of the fragment, sets its level on return * \param _max_meshwidth uppermost acceptable mesh width */ static void setAcceptableFragmentLevel( SamplingGridProperties &_grid, const double &_max_meshwidth); //>! log of two static const double log_two; private: //!> resolution of sampled electron density as \f$2^{\mathrm{level}}\f$ size_t level; //!> maximum allowed mesh width, i.e. discrete points may be at most that far part per axis double max_meshwidth; //!> desired minimum empty boundary around the fragment const double minimum_empty_boundary; }; #endif /* EXPORTGRAPH_TOJOBS_HPP_ */