MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
cadf_iters_impl.h
1//
2// cadf_iters_impl.h
3//
4// Copyright (C) 2013 David Hollman
5//
6// Author: David Hollman
7// Maintainer: DSH
8// Created: Dec 18, 2013
9//
10// This file is part of the SC Toolkit.
11//
12// The SC Toolkit is free software; you can redistribute it and/or modify
13// it under the terms of the GNU Library General Public License as published by
14// the Free Software Foundation; either version 2, or (at your option)
15// any later version.
16//
17// The SC Toolkit is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU Library General Public License for more details.
21//
22// You should have received a copy of the GNU Library General Public License
23// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
24// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25//
26// The U.S. Government is granted a limited license as per AL 91-7.
27//
28
29#ifndef _chemistry_qc_scf_cadf_iters_impl_h
30#define _chemistry_qc_scf_cadf_iters_impl_h
31
32#include <util/misc/scexception.h>
33
34namespace sc {
35
36template<typename Range>
38 const ShellBlockSkeleton<Range>& sk
39) : ShellBlockData<Range>(
40 sk.shell_range,
41 sk.nshell, sk.nbf,
42 sk.restrictions
43 )
44{ }
45
46//============================================================================//
47// ShellData
48
49inline ShellData
50shell_data(
51 GaussianBasisSet* basis,
52 int ish, GaussianBasisSet* dfbasis
53)
54{
55 return ShellData(ish, basis, dfbasis);
56}
57
58inline const BasisFunctionData
59function_data(
60 const Ref<GaussianBasisSet>& basis,
61 int ish, const Ref<GaussianBasisSet>& dfbasis
62)
63{
64 return BasisFunctionData(ish, basis, dfbasis);
65}
66
67//============================================================================//
68
69template<typename Range>
70inline void
72{
73 bfoff = first_shell.bfoff;
74 last_function = last_shell.last_function;
75 if(restrictions & SameCenter) {
76 center = first_shell.center;
77 atom_bfoff = first_shell.atom_bfoff;
78 atom_shoff = first_shell.atom_shoff;
79 atom_nsh = first_shell.atom_nsh;
80 atom_nbf = first_shell.atom_nbf;
81 bfoff_in_atom = first_shell.bfoff_in_atom;
82 shoff_in_atom = first_shell.shoff_in_atom;
83 atom_last_function = last_shell.atom_last_function;
84 atom_last_shell = last_shell.atom_last_function;
85 if(dfbasis != 0){
86 atom_dfshoff = first_shell.atom_dfshoff;
87 atom_dfbfoff = first_shell.atom_dfbfoff;
88 atom_dfnbf = first_shell.atom_dfnbf;
89 atom_dfnsh = first_shell.atom_dfnsh;
90 atom_df_last_function = last_shell.atom_df_last_function;
91 atom_df_last_shell = last_shell.atom_df_last_shell;
92 }
93 }
94}
95
96template<typename ShellIterator, typename ShellRange>
97inline void
98shell_block_iterator<ShellIterator, ShellRange>::init_from_spot(
99 const decltype(all_shells.begin())& start_spot
100)
101{
102 //----------------------------------------//
103 if(start_spot == all_shells.end()){
104 const auto& begin = all_shells.begin();
105 const auto& end = all_shells.end();
106 current_skeleton = ShellBlockSkeleton<ShellRange>::end_skeleton();
107 return;
108 }
109 //----------------------------------------//
110 const auto& first_shell = *start_spot;
111 int first_center = first_shell.center;
112 auto first_am = basis->shell(first_shell).am();
113 int block_nbf = 0;
114 int block_nshell = 0;
115 int prev_index = first_shell.index - 1;
116 auto ish_iter = start_spot;
117 contiguous_ = true;
118 for(; ish_iter != all_shells.end(); ++ish_iter){
119 auto ish = *ish_iter;
120 out_assert(ish.center, !=, NotAssigned);
121 if(
122 // Same center condition
123 ((restrictions & SameCenter) and ish.center != first_center)
124 or
125 // Same angular momentum condition
126 ((restrictions & SameAngularMomentum) and
127 basis->shell(ish).am() != first_am)
128 or
129 // Maximum block size overflow condition
130 (target_size != NoMaximumBlockSize and block_nbf >= target_size)
131 or
132 // Contiguous condition
133 ((restrictions & Contiguous) and ish.index != prev_index + 1)
134 ){
135 // Store the current block
136 break;
137 }
138 else{
139 ++block_nshell;
140 block_nbf += ish.nbf;
141 if(ish.index != prev_index + 1){
142 contiguous_ = false;
143 }
144 prev_index = ish.index;
145 }
146 }
147 //----------------------------------------//
148 current_skeleton = ShellBlockSkeleton<ShellRange>(
149 shell_range(first_shell, ish_iter),
150 block_nshell, block_nbf, restrictions
151 );
152 //----------------------------------------//
153}
154
155template<typename ShellIterator, typename ShellRange>
156inline void
157shell_block_iterator<ShellIterator, ShellRange>::init()
158{
159 init_from_spot(all_shells.begin());
160}
161
162
163//============================================================================//
164
165template<typename Range>
166inline auto
168 const ShellBlockData<Range>& block
169) -> const decltype(block.shell_range)&
170{
171 return block.shell_range;
172}
173
174template<typename Range>
175inline const Range&
177 const ShellBlockSkeleton<Range>& skeleton
178)
179{
180 return skeleton.shell_range;
181}
182
183template<typename ShellRange>
184inline range_of<BasisFunctionData>
186 const ShellBlockData<ShellRange>& block
187)
188{
189 throw FeatureNotImplemented("function iteration over arbitrary shell block ranges", __FILE__, __LINE__);
190}
191
192template<>
193inline range_of<BasisFunctionData>
195 const ShellBlockData<range_of<ShellData>>& block
196)
197{
198 return function_range(block.basis, block.dfbasis, block.bfoff, block.last_function, block.bfoff);
199}
200
201//============================================================================//
202
203template <typename ShellRange1, typename ShellRange2>
204auto threaded_shell_block_pair_range(
205 const ShellBlockData<ShellRange1>& iblk,
206 const ShellBlockData<ShellRange2>& jblk,
207 int ithr, int nthr
208) -> decltype(thread_over_range(product_range(iblk.shell_range, jblk.shell_range), ithr, nthr))
209{
210 return thread_over_range(
211 product_range(iblk.shell_range, jblk.shell_range),
212 ithr, nthr
213 );
214}
215
216//============================================================================//
217
218} // end namespace sc
219
220
221#endif /* _chemistry_qc_scf_cadf_iters_impl_h */
Definition cadf_attic.h:479
Definition cadf_attic.h:375
Definition cadf_attic.h:330
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
Definition cadf_attic.h:100

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.