Go to the documentation of this file.
21 #include "libmesh/libmesh_config.h"
26 #if defined(LIBMESH_USE_COMPLEX_NUMBERS)
33 #include "libmesh/frequency_system.h"
34 #include "libmesh/equation_systems.h"
35 #include "libmesh/libmesh_logging.h"
36 #include "libmesh/linear_solver.h"
37 #include "libmesh/numeric_vector.h"
47 const std::string & name_in,
48 const unsigned int number_in) :
50 solve_system (nullptr),
51 _finished_set_frequencies (false),
52 _keep_solution_duplicates (true),
53 _finished_init (false),
54 _finished_assemble (false)
107 unsigned int n_freq = es.
parameters.
get<
unsigned int>(
"n_frequencies");
108 for (
unsigned int n=0; n < n_freq; n++)
123 LOG_SCOPE(
"init()",
"FrequencySystem");
139 const unsigned int n_freq =
142 libmesh_assert_greater (n_freq, 0);
149 libmesh_error_msg(
"ERROR: Need to set frequencies before calling init().");
162 libmesh_error_msg(
"ERROR: Matrices already assembled.");
165 LOG_SCOPE(
"assemble()",
"FrequencySystem");
182 const unsigned int n_freq,
183 const bool allocate_solution_duplicates)
189 libmesh_error_msg(
"ERROR: frequencies already initialized.");
197 for (
unsigned int n=0; n<n_freq; n++)
201 base_freq +
Number(n) * freq_step;
218 const unsigned int n_freq,
219 const bool allocate_solution_duplicates)
225 libmesh_assert_greater (n_freq, 0);
228 libmesh_error_msg(
"ERROR: frequencies already initialized.");
237 for (
unsigned int n=0; n<n_freq; n++)
241 min_freq + static_cast<Number>(n)*(max_freq-min_freq)/static_cast<Number>(n_freq-1);
257 const bool allocate_solution_duplicates)
259 libmesh_deprecated();
266 libmesh_error_msg(
"ERROR: frequencies already initialized.");
272 es.
parameters.
set<
unsigned int>(
"n_frequencies") = frequencies.size();
275 for (std::size_t n=0; n<frequencies.size(); n++)
293 const bool allocate_solution_duplicates)
295 libmesh_deprecated();
302 libmesh_error_msg(
"ERROR: frequencies already initialized.");
308 es.
parameters.
set<
unsigned int>(
"n_frequencies") = frequencies.size();
349 const unsigned int n_stop)
370 const unsigned int maxits =
371 es.
parameters.
get<
unsigned int>(
"linear solver maximum iterations");
378 for (
unsigned int n=n_start; n<= n_stop; n++)
384 START_LOG(
"user_pre_solve()",
"FrequencySystem");
388 STOP_LOG(
"user_pre_solve()",
"FrequencySystem");
392 const std::pair<unsigned int, Real> rval =
416 const std::string &
name))
440 libmesh_assert_less (n, 9999);
442 sprintf(buf,
"frequency %04u", n);
450 libmesh_assert_less (n, 9999);
452 sprintf(buf,
"solution %04u", n);
459 #endif // if defined(LIBMESH_USE_COMPLEX_NUMBERS)
Real _final_linear_residual
The final residual for the linear system Ax=b.
virtual void assemble() override
Assemble the linear system.
const EquationSystems & get_equation_systems() const
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.
void remove(const std::string &)
Removes the specified parameter from the list, if it exists.
NumericVector< Number > * rhs
The system matrix.
virtual void clear() override
Clear all the data structures associated with the system.
void attach_solve_function(void fptr(EquationSystems &es, const std::string &name))
Register a required user function to use in assembling/solving the system.
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
The libMesh namespace provides an interface to certain functionality in the library.
bool _finished_assemble
true when we have finished the assemble() phase.
bool have_parameter(const std::string &) const
std::string form_solu_vec_name(const unsigned int n) const
unsigned int n_frequencies() const
virtual void init_data() override
Initializes new data members of the system.
void(* solve_system)(EquationSystems &es, const std::string &name)
Function that computes frequency-dependent data of the system.
virtual void init_data() override
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
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.
SparseMatrix< Number > * matrix
The system matrix.
virtual void assemble() override
Prepares matrix and _dof_map for matrix assembly.
bool _finished_set_frequencies
true when we have frequencies to solve for.
std::string form_freq_param_name(const unsigned int n) const
This is the EquationSystems class.
T & set(const std::string &)
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.
bool _keep_solution_duplicates
when the solution for each frequency should be stored in an additional vector, then this bool is true...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
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.
const std::string & name() const
virtual void clear() override
Clear all the data structures associated with the system, but leave the frequencies untouched.
FrequencySystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Constructor.
virtual void solve() override
Solves the system for all frequencies.
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
bool _finished_init
true when we have finished the init() phase.
unsigned int _n_linear_iterations
The number of linear iterations required to solve the linear system Ax=b.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
void set_current_frequency(unsigned int n)
Sets the current frequency to the n-th entry in the vector _frequencies.
const T & get(const std::string &) const
const NumericVector< Number > & get_vector(const std::string &vec_name) const
std::unique_ptr< LinearSolver< Number > > linear_solver
The LinearSolver defines the interface used to solve the linear_implicit system.
void clear_all()
The full clear method also clears the frequencies (stored as parameters of the EquationSystems object...
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
~FrequencySystem()
Destructor.
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
Parameters parameters
Data structure holding arbitrary parameters.