PSCF v1.1
Mask.h
1#ifndef PSPC_MASK_H
2#define PSPC_MASK_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11
12#include <util/param/ParamComposite.h> // base class
13
14#include <pscf/math/IntVec.h> // function parameter
15#include <pscf/crystal/UnitCell.h> // function parameter
16#include <pspc/field/RField.h> // member template parameter
17#include <util/containers/DArray.h> // member template
18
19namespace Pscf {
20namespace Pspc {
21
22 template <int D> class FieldIo;
23
24 using namespace Util;
25
54 template <int D>
55 class Mask : public ParamComposite
56 {
57
58 public:
59
63 Mask();
64
68 ~Mask();
69
73 void setFieldIo(FieldIo<D> const & fieldIo);
74
84 void allocate(int nBasis, IntVec<D> const & dimensions);
85
95 void setBasis(DArray<double> const & field);
96
112 void setRGrid(RField<D> const & field,
113 bool isSymmetric = false);
114
128 void readBasis(std::istream& in, UnitCell<D>& unitCell);
129
143 void readBasis(std::string filename, UnitCell<D>& unitCell);
144
164 void readRGrid(std::istream& in, UnitCell<D>& unitCell,
165 bool isSymmetric = false);
166
186 void readRGrid(std::string filename, UnitCell<D>& unitCell,
187 bool isSymmetric = false);
188
194 DArray<double> const & basis() const;
195
201 RField<D> const & rgrid() const;
202
214 double phiTot() const;
215
219 bool isAllocated() const;
220
226 bool hasData() const;
227
236 bool isSymmetric() const;
237
238 private:
239
240 /*
241 * Components of field in symmetry-adapted basis format
242 */
243 DArray<double> basis_;
244
245 /*
246 * Field in real-space grid (r-grid) format
247 */
248 RField<D> rgrid_;
249
250 /*
251 * Pointer to associated FieldIo object
252 */
253 FieldIo<D> const * fieldIoPtr_;
254
255 /*
256 * Integer vector of grid dimensions.
257 *
258 * Element i is the number of grid points along direction i
259 */
260 IntVec<D> meshDimensions_;
261
262 /*
263 * Total number grid points (product of mesh dimensions)
264 */
265 int meshSize_;
266
267 /*
268 * Number of basis functions in symmetry-adapted basis
269 */
270 int nBasis_;
271
272 /*
273 * Number of monomer types (number of field)
274 */
275 int nMonomer_;
276
277 /*
278 * Has memory been allocated for field?
279 */
280 bool isAllocated_;
281
282 /*
283 * Has field data been initialized ?
284 */
285 bool hasData_;
286
287 /*
288 * Are the field symmetric under space group operations?
289 *
290 * Set true when field are set using the symmetry adapted basis
291 * format via function setBasis. False by otherwise.
292 */
293 bool isSymmetric_;
294
295 };
296
297 // Inline member functions
298
299 // Get array of all field in basis format (const)
300 template <int D>
301 inline
303 {
304 UTIL_ASSERT(hasData_);
305 UTIL_ASSERT(isSymmetric_);
306 return basis_;
307 }
308
309 // Get all field in r-grid format (const)
310 template <int D>
311 inline
312 RField<D> const & Mask<D>::rgrid() const
313 {
314 UTIL_ASSERT(hasData_);
315 return rgrid_;
316 }
317
318 // Has memory been allocated?
319 template <int D>
320 inline bool Mask<D>::isAllocated() const
321 { return isAllocated_; }
322
323 // Have the field data been set?
324 template <int D>
325 inline bool Mask<D>::hasData() const
326 { return hasData_; }
327
328 // Is the field symmetric under space group operations?
329 template <int D>
330 inline bool Mask<D>::isSymmetric() const
331 { return isSymmetric_; }
332
333 #ifndef PSPC_W_FIELD_CONTAINER_TPP
334 // Suppress implicit instantiation
335 extern template class Mask<1>;
336 extern template class Mask<2>;
337 extern template class Mask<3>;
338 #endif
339
340} // namespace Pspc
341} // namespace Pscf
342#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition: IntVec.h:27
File input/output operations and format conversions for fields.
A field to which the total density is constrained.
Definition: Mask.h:56
void setFieldIo(FieldIo< D > const &fieldIo)
Create association with FieldIo (store pointer).
Definition: Mask.tpp:48
void setBasis(DArray< double > const &field)
Set field component values, in symmetrized Fourier format.
Definition: Mask.tpp:78
Mask()
Constructor.
Definition: Mask.tpp:25
void setRGrid(RField< D > const &field, bool isSymmetric=false)
Set field values in real-space (r-grid) format.
Definition: Mask.tpp:93
bool isAllocated() const
Has memory been allocated?
Definition: Mask.h:320
DArray< double > const & basis() const
Get the field in basis format.
Definition: Mask.h:302
bool isSymmetric() const
Are field symmetric under all elements of the space group?
Definition: Mask.h:330
void readRGrid(std::istream &in, UnitCell< D > &unitCell, bool isSymmetric=false)
Reads field from an input stream in real-space (r-grid) format.
Definition: Mask.tpp:157
RField< D > const & rgrid() const
Get array of all field in r-space grid format.
Definition: Mask.h:312
~Mask()
Destructor.
Definition: Mask.tpp:41
void readBasis(std::istream &in, UnitCell< D > &unitCell)
Read field from input stream in symmetrized Fourier format.
Definition: Mask.tpp:114
bool hasData() const
Has field data been set in either format?
Definition: Mask.h:325
void allocate(int nBasis, IntVec< D > const &dimensions)
Allocate memory for the field.
Definition: Mask.tpp:55
double phiTot() const
Volume fraction of the unit cell occupied by the polymers/solvents.
Definition: Mask.tpp:201
Field of real double precision values on an FFT mesh.
Definition: RField.h:29
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition: UnitCell.h:44
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
An object that can read multiple parameters from file.
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
Definition: global.h:75
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1