libMesh
frequency_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_FREQUENCY_SYSTEM_H
21 #define LIBMESH_FREQUENCY_SYSTEM_H
22 
23 #include "libmesh/libmesh_config.h"
24 
25 // Frequency domain solutions only possible with complex arithmetic
26 #if defined(LIBMESH_USE_COMPLEX_NUMBERS)
27 
28 // Local Includes
29 #include "libmesh/linear_implicit_system.h"
30 
31 // C++ includes
32 #include <string>
33 #include <vector>
34 
35 namespace libMesh
36 {
37 
64 {
65 public:
66 
72  const std::string & name_in,
73  const unsigned int number_in);
78 
85  virtual void clear () override;
86 
92  void clear_all ();
93 
98  virtual void assemble () override;
99 
103  virtual void solve () override;
104 
113  void solve (const unsigned int n_start,
114  const unsigned int n_stop);
115 
120  virtual std::string system_type () const override { return "Frequency"; }
121 
122 
123  //--------------------------------------------------------
124  // Methods specific to the FrequencySystem
125  //
126 
139  void set_frequencies_by_steps (const Number base_freq,
140  const Number freq_step=0.,
141  const unsigned int n_freq=1,
142  const bool allocate_solution_duplicates=true);
143 
153  void set_frequencies_by_range (const Number min_freq,
154  const Number max_freq,
155  const unsigned int n_freq,
156  const bool allocate_solution_duplicates=true);
157 
165  void set_frequencies (const std::vector<Real> & frequencies,
166  const bool allocate_solution_duplicates=true);
167 
168 
169  void set_frequencies (const std::vector<Number> & frequencies,
170  const bool allocate_solution_duplicates=true);
171 
175  unsigned int n_frequencies () const;
176 
184  const std::string & name));
185 
190  const std::string & name);
191 
195  std::pair<unsigned int, Real> get_rval (unsigned int n) const;
196 
202  std::string form_freq_param_name(const unsigned int n) const;
203 
209  std::string form_solu_vec_name(const unsigned int n) const;
210 
211 
212 protected:
213 
214 
221  virtual void init_data () override;
222 
227  void set_current_frequency(unsigned int n);
228 
235 
244 
251 
265 
270  std::vector<std::pair<unsigned int, Real>> vec_rval;
271 
272 };
273 
274 
275 
276 // ------------------------------------------------------------
277 // FrequencySystem inline methods
278 inline
279 std::pair<unsigned int, Real> FrequencySystem::get_rval (unsigned int n) const
280 {
281  libmesh_assert_less (n, vec_rval.size());
282 
283  return vec_rval[n];
284 }
285 
286 
287 } // namespace libMesh
288 
289 #endif // if defined(LIBMESH_USE_COMPLEX_NUMBERS)
290 
291 #endif // LIBMESH_FREQUENCY_SYSTEM_H
libMesh::FrequencySystem::assemble
virtual void assemble() override
Assemble the linear system.
Definition: frequency_system.C:157
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::FrequencySystem::system_type
virtual std::string system_type() const override
Definition: frequency_system.h:120
libMesh::FrequencySystem::vec_rval
std::vector< std::pair< unsigned int, Real > > vec_rval
The number of iterations and the final residual when the Ax=b is solved for multiple frequencies.
Definition: frequency_system.h:270
libMesh::FrequencySystem::attach_solve_function
void attach_solve_function(void fptr(EquationSystems &es, const std::string &name))
Register a required user function to use in assembling/solving the system.
Definition: frequency_system.C:415
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::FrequencySystem::_finished_assemble
bool _finished_assemble
true when we have finished the assemble() phase.
Definition: frequency_system.h:264
libMesh::FrequencySystem::form_solu_vec_name
std::string form_solu_vec_name(const unsigned int n) const
Definition: frequency_system.C:448
libMesh::FrequencySystem::n_frequencies
unsigned int n_frequencies() const
Definition: frequency_system.C:330
libMesh::FrequencySystem::solve_system
void(* solve_system)(EquationSystems &es, const std::string &name)
Function that computes frequency-dependent data of the system.
Definition: frequency_system.h:189
libMesh::FrequencySystem::init_data
virtual void init_data() override
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
Definition: frequency_system.C:117
libMesh::FrequencySystem::set_frequencies_by_range
void set_frequencies_by_range(const Number min_freq, const Number max_freq, const unsigned int n_freq, const bool allocate_solution_duplicates=true)
Set the frequency range for which the system should be solved.
Definition: frequency_system.C:216
libMesh::FrequencySystem::get_rval
std::pair< unsigned int, Real > get_rval(unsigned int n) const
Definition: frequency_system.h:279
libMesh::FrequencySystem
FrequencySystem provides a specific system class for frequency-dependent (linear) systems.
Definition: frequency_system.h:63
libMesh::FrequencySystem::_finished_set_frequencies
bool _finished_set_frequencies
true when we have frequencies to solve for.
Definition: frequency_system.h:234
libMesh::FrequencySystem::form_freq_param_name
std::string form_freq_param_name(const unsigned int n) const
Definition: frequency_system.C:438
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::FrequencySystem::set_frequencies
void set_frequencies(const std::vector< Real > &frequencies, const bool allocate_solution_duplicates=true)
Set the frequency range by simply copying the values from frequencies.
Definition: frequency_system.C:256
libMesh::FrequencySystem::_keep_solution_duplicates
bool _keep_solution_duplicates
when the solution for each frequency should be stored in an additional vector, then this bool is true...
Definition: frequency_system.h:243
libMesh::FrequencySystem::set_frequencies_by_steps
void set_frequencies_by_steps(const Number base_freq, const Number freq_step=0., const unsigned int n_freq=1, const bool allocate_solution_duplicates=true)
Set the frequency range for which the system should be solved.
Definition: frequency_system.C:180
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::FrequencySystem::clear
virtual void clear() override
Clear all the data structures associated with the system, but leave the frequencies untouched.
Definition: frequency_system.C:73
libMesh::FrequencySystem::FrequencySystem
FrequencySystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Constructor.
Definition: frequency_system.C:46
libMesh::FrequencySystem::solve
virtual void solve() override
Solves the system for all frequencies.
Definition: frequency_system.C:338
libMesh::FrequencySystem::_finished_init
bool _finished_init
true when we have finished the init() phase.
Definition: frequency_system.h:250
libMesh::LinearImplicitSystem
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
Definition: linear_implicit_system.h:55
fptr
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libMesh::FrequencySystem::set_current_frequency
void set_current_frequency(unsigned int n)
Sets the current frequency to the n-th entry in the vector _frequencies.
Definition: frequency_system.C:425
libMesh::FrequencySystem::clear_all
void clear_all()
The full clear method also clears the frequencies (stored as parameters of the EquationSystems object...
Definition: frequency_system.C:97
libMesh::FrequencySystem::~FrequencySystem
~FrequencySystem()
Destructor.
Definition: frequency_system.C:63