$extrastylesheet
frequency_system.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_FREQUENCY_SYSTEM_H
00021 #define LIBMESH_FREQUENCY_SYSTEM_H
00022 
00023 #include "libmesh/libmesh_config.h"
00024 
00025 // Frequency domain solutions only possible with complex arithmetic
00026 #if defined(LIBMESH_USE_COMPLEX_NUMBERS)
00027 
00028 // Local Includes
00029 #include "libmesh/linear_implicit_system.h"
00030 
00031 // C++ includes
00032 #include <string>
00033 #include <vector>
00034 
00035 namespace libMesh
00036 {
00037 
00038 
00039 
00040 
00066 // ------------------------------------------------------------
00067 // FrequencySystem class definition
00068 
00069 class FrequencySystem : public LinearImplicitSystem
00070 {
00071 public:
00072 
00077   FrequencySystem (EquationSystems& es,
00078                    const std::string& name_in,
00079                    const unsigned int number_in);
00083   ~FrequencySystem ();
00084 
00091   virtual void clear ();
00092 
00098   void clear_all ();
00099 
00104   virtual void assemble ();
00105 
00109   virtual void solve ();
00110 
00119   void solve (const unsigned int n_start,
00120               const unsigned int n_stop);
00121 
00126   virtual std::string system_type () const { return "Frequency"; }
00127 
00128 
00129   //--------------------------------------------------------
00130   // Methods specific to the FrequencySystem
00131   //
00132 
00145   void set_frequencies_by_steps (const Real base_freq,
00146                                  const Real freq_step=0.,
00147                                  const unsigned int n_freq=1,
00148                                  const bool allocate_solution_duplicates=true);
00149 
00159   void set_frequencies_by_range (const Real min_freq,
00160                                  const Real max_freq,
00161                                  const unsigned int n_freq,
00162                                  const bool allocate_solution_duplicates=true);
00163 
00171   void set_frequencies (const std::vector<Real>& frequencies,
00172                         const bool allocate_solution_duplicates=true);
00173 
00177   unsigned int n_frequencies () const;
00178 
00185   void attach_solve_function(void fptr(EquationSystems& es,
00186                                        const std::string& name));
00187 
00191   void (* solve_system) (EquationSystems& es,
00192                          const std::string& name);
00193 
00197   std::pair<unsigned int, Real> get_rval (unsigned int n) const;
00198 
00204   std::string form_freq_param_name(const unsigned int n) const;
00205 
00211   std::string form_solu_vec_name(const unsigned int n) const;
00212 
00213 
00214 protected:
00215 
00216 
00223   virtual void init_data ();
00224 
00229   void set_current_frequency(unsigned int n);
00230 
00236   bool _finished_set_frequencies;
00237 
00245   bool _keep_solution_duplicates;
00246 
00252   bool _finished_init;
00253 
00266   bool _finished_assemble;
00267 
00272   std::vector<std::pair<unsigned int, Real> > vec_rval;
00273 
00274 };
00275 
00276 
00277 
00278 // ------------------------------------------------------------
00279 // FrequencySystem inline methods
00280 inline
00281 std::pair<unsigned int, Real> FrequencySystem::get_rval (unsigned int n) const
00282 {
00283   libmesh_assert_less (n, vec_rval.size());
00284 
00285   return vec_rval[n];
00286 }
00287 
00288 
00289 } // namespace libMesh
00290 
00291 #endif // if defined(LIBMESH_USE_COMPLEX_NUMBERS)
00292 
00293 #endif // LIBMESH_FREQUENCY_SYSTEM_H