LILAC
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
stable_spectral_pde_1d_tmpl.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2014, Sam Schetterer, Nathan Kutz, University of Washington
3 Authors: Sam Schetterer
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 
10 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11 
12 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 
16 */
17 #ifndef STABLE_SPECTRAL_PDE_1D_TMPL_HPP
18 #define STABLE_SPECTRAL_PDE_1D_TMPL_HPP
19 
20 
25 #include "stable_ode_tmpl.hpp"
26 #include "utils/comp_funcs.hpp"
27 template<class T>
29  private:
30  virtual void pre_integration_operations();
31  virtual void post_integration_operations();
32  protected:
33  double* t;
34  double* help;
35  size_t nts;
36  size_t num_pulses;
38  virtual void pre_fft_operations();
40  virtual void post_fft_operations();
42  virtual void pre_ifft_operations();
44  virtual void post_ifft_operations();
45  public:
46  virtual std::vector<std::string> dependencies() const;
47  virtual void postprocess(input& invals);
48  virtual std::string type() const;
50 };
51 
52 //stable_spectral_pde_1d functions
53 template<class T>
55  return std::string("stable_spectral_pde_1d_tmpl")+typeid(T).name();
56 }
57 
58 template<class T>
59 std::vector<std::string> stable_spectral_pde_1d_tmpl<T>::dependencies() const{
60  std::string deps[] = {"num_pulses"};
62 };
63 
64 template<class T>
67  int _num;
68  invals.retrieve(_num, "num_pulses", this);
69  if(_num <= 0){
70  err("Number of pulses must be greater than zero", "stable_spectral_pde_1d_tmpl<T>::postprocess",
71  "simulation/stable.cpp", FATAL_ERROR);
72  }
73  num_pulses=_num;
74  if(this->dimension%num_pulses){
75  err("Dimension must be divisible by the number of pulses", "stable_spectral_pde_1d_tmpl<T>::postprocess",
76  "simulation/stable.cpp", FATAL_ERROR);
77  }
78  nts=this->dimension/num_pulses;
79  double dt=60.0/nts;
80  this->memp.add(nts, &t, &help);
81  for(size_t i = 0; i < nts; i++){
82  t[i] = dt*((double)i-nts/2.0);
83  }
84  for(size_t i = 0; i < nts; i++){
85  this->ucur[i] = this->ucur[i+nts] = 1.00/cosh(t[i]/2.0);
86  this->help[i] = _real(this->ucur[i]);
87  }
88 }
89 template<class T>
91  if(stable::round==0){
92  for(size_t i = 0; i < nts; i++){
93  this->ucur[i] = this->ucur[i+nts] = 1.00/cosh(t[i]/2.0);
94  }
95  }
96  pre_fft_operations();
97  for(size_t i = 0; i < num_pulses; i++){
98  fft(this->ucur+i*nts, this->ucur+i*nts, nts);
99  }
100  post_fft_operations();
101 }
102 template<class T>
104  pre_ifft_operations();
105 
106  for(size_t i = 0; i < num_pulses; i++){
107  ifft(this->ucur+i*nts, this->ucur+i*nts, nts);
108  }
109  post_ifft_operations();
110 }
111 template<class T>
113 
114 template<class T>
116 
117 template<class T>
119 
120 template<class T>
122 
123 template<class T>
125 {
126 }
127 #endif