MADNESS  0.10.1
pointgroupoperator.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 
31  $Id$
32 */
33 
34 
35 /*!
36  \file chem/pointgroupoperator.h
37  \brief implements point group operations
38 
39  The source is
40  <a href=http://code.google.com/p/m-a-d-n-e-s-s/source/browse/local
41  /trunk/src/apps/chem/pointgroupoperator.h>here</a>.
42 
43 */
44 
45 #ifndef SRC_APPS_CHEM_POINTGROUPOPERATOR_H_
46 #define SRC_APPS_CHEM_POINTGROUPOPERATOR_H_
47 
49 
50 namespace madness {
51 
52 template<typename T, std::size_t NDIM>
53 class Function;
54 /// This class implements the symmetry operations (not the point groups)
55 class pg_operator {
56 
57 public:
58 
59  /// ctor with explicit mirror maps
60  pg_operator(std::string symbol, std::string name, const std::vector<long> mm,
61  const std::vector<long> md)
62  : symbol_(symbol), name_(name), mirrormap(mm), mapdim_(md) {}
63 
64  /// return the name of the symmetry operator
65  std::string name() const {return name_;}
66 
67  std::string symbol() const {return symbol_;}
68 
69  /// apply the operator on an n-dimensional MRA function
70  template<typename T, std::size_t NDIM>
71  Function<T,NDIM> operator()(const Function<T,NDIM>& f, bool fence=true) const {
72  Function<T,NDIM> result;
73 
74  if (name_=="identity") {
75  result=copy(f,fence);
76 
77  } else if (name_=="inversion"){
78 
79  std::vector<long> mm(NDIM,-1);
80  result=mirror(f,mm,fence);
81 
82  } else {
83  result=map_and_mirror(f,mapdim_,mirrormap,fence);
84  }
85 
86  return result;
87  }
88 
89  /// apply the operator on an n-dimensional MRA function
90  template<typename T, std::size_t NDIM>
91  std::vector<Function<T,NDIM> > operator()(const std::vector<Function<T,NDIM> >& vf, bool fence=true) const {
92  std::vector<Function<T,NDIM> > result(vf.size());
93 
94  // fast return
95  if (vf.size()==0) return result;
96  World& world=vf.begin()->world();
97 
98  for (size_t i=0; i<vf.size(); ++i) result[i]=this->operator()(vf[i],false);
99 
100  if (fence) world.gop.fence();
101  return result;
102  }
103 
104 
105  friend
106  std::ostream& operator<<(std::ostream& s, const pg_operator& pg_op) {
107  s << "Symmetry operator " << pg_op.name() ;
108  return s;
109  }
110 
111 
112 private:
113 
114  std::string symbol_;
115  std::string name_;
116  std::vector<long> mirrormap;
117  std::vector<long> mapdim_;
118 
119 };
120 
121 
122 // n-dimensional operations
123 static inline pg_operator pg_identity() {
124  return pg_operator("E","identity",std::vector<long>(), std::vector<long>());
125 }
126 
127 static inline pg_operator pg_inversion() {
128  return pg_operator("i","inversion",std::vector<long>(), std::vector<long>());
129 }
130 
131 // 2D operations
132 static inline pg_operator pg_sigma_x() {
133  return pg_operator("s","sigma_x",vector_factory<long>(1,-1),std::vector<long>());
134 }
135 
136 static inline pg_operator pg_sigma_y() {
137  return pg_operator("s","sigma_y",vector_factory<long>(-1,1),std::vector<long>());
138 }
139 
140 static inline pg_operator pg_c2() {
141  return pg_operator("C2","C_2",vector_factory<long>(-1,-1),std::vector<long>());
142 }
143 
144 static inline pg_operator pg_c4() {
145  return pg_operator("C4","C_4",vector_factory<long>(-1,1),vector_factory<long>(1,0));
146 }
147 
148 
149 // 3D operations
150 static inline pg_operator pg_sigma_xy() {
151  return pg_operator("s","sigma_xy",vector_factory<long>(1,1,-1), std::vector<long>());
152 }
153 
154 static inline pg_operator pg_sigma_xz() {
155  return pg_operator("s","sigma_xz",vector_factory<long>(1,-1,1), std::vector<long>());
156 }
157 
158 static inline pg_operator pg_sigma_yz() {
159  return pg_operator("s","sigma_yz",vector_factory<long>(-1,1,1), std::vector<long>());
160 }
161 
162 static inline pg_operator pg_c2x() {
163  return pg_operator("C2","C_2(x)",vector_factory<long>(1,-1,-1), std::vector<long>());
164 }
165 
166 static inline pg_operator pg_c2y() {
167  return pg_operator("C2","C_2(y)",vector_factory<long>(-1,1,-1), std::vector<long>());
168 }
169 
170 static inline pg_operator pg_c2z() {
171  return pg_operator("C2","C_2(z)",vector_factory<long>(-1,-1,1), std::vector<long>());
172 }
173 
174 static inline pg_operator pg_c4x() {
175  return pg_operator("C4","C_4(x)",vector_factory<long>(1,-1,1), vector_factory<long>(0,2,1));
176 }
177 
178 static inline pg_operator pg_c4y() {
179  return pg_operator("C4","C_4(y)",vector_factory<long>(1,1,-1), vector_factory<long>(2,1,0));
180 }
181 
182 static inline pg_operator pg_c4z() {
183  return pg_operator("C4","C_4(z)",vector_factory<long>(-1,1,1), vector_factory<long>(1,0,2));
184 }
185 
186 
187 } // namespace madness
188 
189 #endif /* SRC_APPS_CHEM_POINTGROUPOPERATOR_H_ */
A multiresolution adaptive numerical function.
Definition: mra.h:122
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition: worldgop.cc:161
A parallel world class.
Definition: world.h:132
WorldGopInterface & gop
Global operations.
Definition: world.h:205
This class implements the symmetry operations (not the point groups)
Definition: pointgroupoperator.h:55
std::string symbol_
Definition: pointgroupoperator.h:114
std::vector< long > mapdim_
Definition: pointgroupoperator.h:117
std::string name() const
return the name of the symmetry operator
Definition: pointgroupoperator.h:65
std::string symbol() const
Definition: pointgroupoperator.h:67
Function< T, NDIM > operator()(const Function< T, NDIM > &f, bool fence=true) const
apply the operator on an n-dimensional MRA function
Definition: pointgroupoperator.h:71
std::vector< Function< T, NDIM > > operator()(const std::vector< Function< T, NDIM > > &vf, bool fence=true) const
apply the operator on an n-dimensional MRA function
Definition: pointgroupoperator.h:91
pg_operator(std::string symbol, std::string name, const std::vector< long > mm, const std::vector< long > md)
ctor with explicit mirror maps
Definition: pointgroupoperator.h:60
friend std::ostream & operator<<(std::ostream &s, const pg_operator &pg_op)
Definition: pointgroupoperator.h:106
std::string name_
Definition: pointgroupoperator.h:115
std::vector< long > mirrormap
Definition: pointgroupoperator.h:116
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static pg_operator pg_c2x()
Definition: pointgroupoperator.h:162
static pg_operator pg_sigma_y()
Definition: pointgroupoperator.h:136
static pg_operator pg_c4y()
Definition: pointgroupoperator.h:178
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition: mra.h:2002
static pg_operator pg_c4()
Definition: pointgroupoperator.h:144
Function< T, NDIM > map_and_mirror(const Function< T, NDIM > &f, const std::vector< long > &map, const std::vector< long > &mirror, bool fence=true)
This is replaced with mirror(map(f)), optional fence.
Definition: mra.h:2288
static pg_operator pg_sigma_yz()
Definition: pointgroupoperator.h:158
static pg_operator pg_c4z()
Definition: pointgroupoperator.h:182
static pg_operator pg_sigma_x()
Definition: pointgroupoperator.h:132
static pg_operator pg_c2()
Definition: pointgroupoperator.h:140
NDIM & f
Definition: mra.h:2416
static pg_operator pg_c4x()
Definition: pointgroupoperator.h:174
Function< T, NDIM > mirror(const Function< T, NDIM > &f, const std::vector< long > &mirrormap, bool fence=true)
Generate a new function by mirroring within the dimensions .. optional fence.
Definition: mra.h:2271
static pg_operator pg_inversion()
Definition: pointgroupoperator.h:127
static pg_operator pg_c2z()
Definition: pointgroupoperator.h:170
static pg_operator pg_c2y()
Definition: pointgroupoperator.h:166
static pg_operator pg_sigma_xy()
Definition: pointgroupoperator.h:150
static pg_operator pg_sigma_xz()
Definition: pointgroupoperator.h:154
static pg_operator pg_identity()
Definition: pointgroupoperator.h:123
static const std::size_t NDIM
Definition: testpdiff.cc:42
Declares and implements factories for short vectors.