votca 2024-dev
Loading...
Searching...
No Matches
parallelxjobcalc.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
21
22#pragma once
23#ifndef VOTCA_XTP_PARALLELXJOBCALC_H
24#define VOTCA_XTP_PARALLELXJOBCALC_H
25
26// VOTCA includes
27#include <votca/tools/mutex.h>
28
29// Local VOTCA includes
30#include "job.h"
31#include "jobcalculator.h"
32#include "progressobserver.h"
33#include "qmthread.h"
34
42
45
46namespace votca {
47namespace xtp {
48
49template <typename JobContainer>
51
52 public:
53 class JobOperator;
54 using Job = typename JobContainer::value_type;
55 using Result = typename Job::JobResult;
56
57 ParallelXJobCalc() = default;
58 ~ParallelXJobCalc() override = default;
59
60 std::string Identify() const override = 0;
61
62 void ParseOptions(const tools::Property &opt) final {
65 }
66
67 bool Evaluate(const Topology &top) final;
68 virtual void CustomizeLogger(QMThread &thread);
69 virtual Result EvalJob(const Topology &top, Job &job, QMThread &thread) = 0;
70
71 void LockCout() { coutMutex_.Lock(); }
73 void LockLog() { logMutex_.Lock(); }
75
76 // ======================================== //
77 // XJOB OPERATOR (THREAD) //
78 // ======================================== //
79
80 class JobOperator : public QMThread {
81 public:
82 JobOperator(Index id, const Topology &top,
83 ParallelXJobCalc<JobContainer> &master, Index openmp_threads)
84 : top_(top), master_(master), openmp_threads_(openmp_threads) {
85 setId(id);
86 } // comes from baseclass so Id cannot be in initializer list
87 ~JobOperator() override = default;
88
89 void Run() override;
90
91 private:
92 const Topology &top_;
95 };
96
97 protected:
98 virtual void ParseSpecificOptions(const tools::Property &options) = 0;
99
100 // set the basis sets and functional in DFT package
102 // set the basis sets and functional in GWBSE
104
105 JobContainer XJobs_;
108 std::string mapfile_ = "";
109 std::string jobfile_ = "";
110
111 private:
112 void ParseCommonOptions(const tools::Property &options);
113};
114
115} // namespace xtp
116} // namespace votca
117
118#endif // VOTCA_XTP_PARALLELXJOBCALC_H
class to manage program options with xml serialization functionality
Definition property.h:55
ParallelXJobCalc< JobContainer > & master_
void Run() override
Run() executes the actual code.
JobOperator(Index id, const Topology &top, ParallelXJobCalc< JobContainer > &master, Index openmp_threads)
virtual void ParseSpecificOptions(const tools::Property &options)=0
tools::Property UpdateGWBSEOptions(const tools::Property &options)
tools::Property UpdateDFTOptions(const tools::Property &options)
typename JobContainer::value_type Job
void ParseCommonOptions(const tools::Property &options)
void ParseOptions(const tools::Property &opt) final
~ParallelXJobCalc() override=default
virtual Result EvalJob(const Topology &top, Job &job, QMThread &thread)=0
typename Job::JobResult Result
virtual void CustomizeLogger(QMThread &thread)
std::string Identify() const override=0
Calculator name.
bool Evaluate(const Topology &top) final
void setId(Index id)
Definition qmthread.h:52
Container for segments and box and atoms.
Definition topology.h:41
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26