66{
67
69
70
71#ifndef LIBMESH_HAVE_SLEPC
72 if (
init.comm().rank() == 0)
73 libMesh::err <<
"ERROR: This example requires libMesh to be\n"
74 << "compiled with SLEPc eigen solvers support!"
75 << std::endl;
76
77 return 0;
78#else
79
80#ifdef LIBMESH_DEFAULT_SINGLE_PRECISION
81
82 libmesh_example_requires(false, "--disable-singleprecision");
83#endif
84
85
86 libmesh_error_msg_if(argc < 3, "\nUsage: " << argv[0] << " -n <number of eigen values>");
87
88
90
91 for (int i=1; i<argc; i++)
93
95
96
97
98
102
103
104
105 libmesh_example_requires(2 <= LIBMESH_DIM, "2D support");
106
107
108
110
111
112
114 nx, ny,
115 -1., 1.,
116 -1., 1.,
118
119
121
122
124
125
126
128 equation_systems.add_system<
EigenSystem> (
"Eigensystem");
129
130
131
132
134
135
136
138
139
140
141
142
143 equation_systems.parameters.set<unsigned int>("eigenpairs") = nev;
144 equation_systems.parameters.set<unsigned int>("basis vectors") = nev*3;
145
146
147
148
149
150
151
152
153
154
155 equation_systems.parameters.set<
Real>(
"linear solver tolerance") =
pow(
TOLERANCE, 5./3.);
156 equation_systems.parameters.set<unsigned int>("linear solver maximum iterations") = 1000;
157
158
159
161
162
163
165
166
167 equation_systems.init();
168
169
170 equation_systems.print_info();
171
172#if SLEPC_VERSION_LESS_THAN(3,1,0)
173 libmesh_error_msg("SLEPc 3.1 is required to call EigenSolver::set_initial_space()");
174#else
175
176
179 initial_space.
add(1.0);
181#endif
182
183
184 eigen_system.
solve();
185
186
188
190 << nconv
191 << "\n"
192 << std::endl;
193
194
195 if (nconv != 0)
196 {
198
199#ifdef LIBMESH_HAVE_EXODUS_API
200
202#endif
203 }
204 else
205 {
206 libMesh::out <<
"WARNING: Solver did not converge!\n" << nconv << std::endl;
207 }
208
209#endif
210
211
212 return 0;
213}
This class provides an interface to solvers for eigenvalue problems.
virtual void set_initial_space(NumericVector< T > &initial_space_in)=0
Provide one basis vector for the initial guess.
void set_eigenproblem_type(EigenProblemType ept)
Sets the type of the current eigen problem.
virtual void solve() override
Assembles & solves the eigen system.
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i)
unsigned int get_n_converged() const
const EigenSolver< Number > & get_eigen_solver() const
This is the EquationSystems class.
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
void attach_assemble_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in assembling the system matrix and RHS.
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
void assemble_mass(EquationSystems &es, const std::string &system_name)
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real