votca 2024.2-dev
Loading...
Searching...
No Matches
qmnblist.cc
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 */
19
20// Local VOTCA includes
21#include "votca/xtp/qmnblist.h"
23
24namespace votca {
25namespace xtp {
26
27QMPair& QMNBList::Add(const Segment& seg1, const Segment& seg2,
28 const Eigen::Vector3d& r) {
29 assert(this->FindPair(&seg1, &seg2) == nullptr &&
30 "Critical bug: pair already exists");
31 Index id = this->size();
32 QMPair* pair = new QMPair(id, &seg1, &seg2, r);
33 this->AddPair(pair);
34 return *pair;
35}
36
38 Index size = this->size();
39 w(size, "size");
40 if (size == 0) {
41 return;
42 }
43 std::vector<QMPair::data> dataVec(size);
44
45 CptTable table = w.openTable<QMPair>("pairs", size);
46 for (Index i = 0; i < size; i++) {
47 (pairs_[i]->WriteData(dataVec[i]));
48 }
49 table.write(dataVec);
50 for (QMPair::data data : dataVec) {
51 delete[] data.pair_type;
52 }
53}
54
56 const std::vector<Segment>& segments) {
57 Cleanup();
58 Index size = 0;
59 r(size, "size");
60 if (size == 0) {
61 return;
62 }
63 CptTable table = r.openTable<QMPair>("pairs");
64 std::vector<QMPair::data> dataVec(table.numRows());
65 table.read(dataVec);
66
67 for (const QMPair::data& data : dataVec) {
68 this->AddPair(new QMPair(data, segments));
69 }
70}
71
72} // namespace xtp
73} // namespace votca
QMPair * FindPair(const Segment *e1, const Segment *e2)
Definition pairlist.h:93
CptTable openTable(const std::string &name)
CptTable openTable(const std::string &name, std::size_t nRows, bool compact=false)
void write(void *buffer, const std::size_t &startIdx, const std::size_t &endIdx)
void read(void *buffer, const std::size_t &startIdx, const std::size_t &endIdx)
void ReadFromCpt(CheckpointReader &r, const std::vector< Segment > &segments)
Definition qmnblist.cc:55
void WriteToCpt(CheckpointWriter &w) const
Definition qmnblist.cc:37
QMPair & Add(const Segment &seg1, const Segment &seg2, const Eigen::Vector3d &r)
Definition qmnblist.cc:27
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26