Line data Source code
1 : /**********************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ 4 : /* */ 5 : /* Copyright 2017 Battelle Energy Alliance, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /**********************************************************************/ 8 : #ifdef FFTW3_ENABLED 9 : 10 : #pragma once 11 : 12 : #include "ElementUserObject.h" 13 : #include "PerfGraphInterface.h" 14 : #include "fftw3.h" 15 : 16 : #include <memory> 17 : 18 : /** 19 : * Compute the fourier transform of a selected variable field. 20 : */ 21 : class FourierTransform : public ElementUserObject 22 : { 23 : public: 24 : static InputParameters validParams(); 25 : 26 : FourierTransform(const InputParameters & parameters); 27 : ~FourierTransform() override; 28 : 29 : virtual void initialize() override; 30 : virtual void execute() override; 31 : virtual void finalize() override; 32 : virtual void threadJoin(const UserObject & y) override; 33 : 34 : ///@{ public API 35 12 : unsigned int dimension() const { return _dim; } 36 12 : const std::vector<int> & getGrid() const { return _grid; } 37 : const Point & getBoxSize() const { return _box_size; } 38 12 : const std::vector<double> & getBuffer() const { return _buffer; } 39 : ///@} 40 : 41 : protected: 42 : /// variable to compute FFT of 43 : const VariableValue & _var; 44 : 45 : /// mesh dimension 46 : unsigned int _dim; 47 : 48 : /// grid size for FFT (needs to be signed for FFTW) 49 : std::vector<int> _grid; 50 : 51 : ///@{ simulation box extents 52 : Point _min_corner; 53 : Point _max_corner; 54 : Point _box_size; 55 : ///@} 56 : 57 : /// FFT grid cell volume 58 : Real _cell_volume; 59 : 60 : /// FFTW data buffer 61 : std::vector<double> _buffer; 62 : std::size_t _buffer_size; 63 : 64 : /// FFTW plan 65 : fftw_plan _plan; 66 : 67 : ///@{ timers 68 : PerfID _perf_plan; 69 : PerfID _perf_fft; 70 : ///@} 71 : }; 72 : 73 : #endif // FFTW3_ENABLED