96 #ifndef LIBMESH_HAVE_EXODUS_API 97 libmesh_example_requires(
false,
"--enable-exodus");
101 #ifndef LIBMESH_HAVE_SLEPC 102 if (
init.comm().rank() == 0)
103 libMesh::err <<
"ERROR: This example requires libMesh to be\n" 104 <<
"compiled with SLEPc eigen solvers support!" 110 #ifdef LIBMESH_DEFAULT_SINGLE_PRECISION 112 libmesh_example_requires(
false,
"--disable-singleprecision");
115 #if defined(LIBMESH_USE_COMPLEX_NUMBERS) && SLEPC_VERSION_LESS_THAN(3,6,2) 118 libmesh_example_requires(
false,
"--disable-complex or use SLEPc>=3.6.2");
122 #ifndef LIBMESH_ENABLE_DIRICHLET 123 libmesh_example_requires(
false,
"--enable-dirichlet");
130 for (
int i=1; i<argc; i++)
137 libmesh_example_requires(2 <= LIBMESH_DIM,
"2D support");
140 GetPot command_line (argc, argv);
143 const std::string mesh_name =
148 const unsigned int plotting_index =
152 const unsigned int n_evals =
156 std::ostringstream mesh_name_exodus;
157 mesh_name_exodus << mesh_name <<
"_mesh.e";
168 for (
const auto & elem :
mesh.element_ptr_range())
169 for (
auto side : elem->side_index_range())
170 if (elem->neighbor_ptr (side) ==
nullptr)
195 equation_systems.parameters.set<
unsigned int>(
"eigenpairs") = n_evals;
196 equation_systems.parameters.set<
unsigned int>(
"basis vectors") = n_evals*3;
199 equation_systems.parameters.set<
Real>(
"linear solver tolerance") =
pow(
TOLERANCE, 5./3.);
200 equation_systems.parameters.set<
unsigned int>
201 (
"linear solver maximum iterations") = 1000;
213 #ifdef LIBMESH_ENABLE_DIRICHLET 224 equation_systems.init();
227 equation_systems.print_info();
232 eigen_system.
solve();
242 if (plotting_index > n_evals)
244 libMesh::out <<
"WARNING: Solver did not converge for the requested eigenvector!" << std::endl;
248 std::ostringstream eigenvalue_output_name;
249 eigenvalue_output_name << mesh_name <<
"_evals.txt";
250 std::ofstream evals_file(eigenvalue_output_name.str().c_str());
252 for (
unsigned int i=0; i<nconv; i++)
257 libmesh_assert_less (eval.second,
TOLERANCE);
258 evals_file << eval.first << std::endl;
261 if (i == plotting_index)
263 #ifdef LIBMESH_HAVE_EXODUS_API 265 std::ostringstream eigenvector_output_name;
266 eigenvector_output_name << mesh_name <<
"_evec.e";
268 #endif // #ifdef LIBMESH_HAVE_EXODUS_API 274 #endif // LIBMESH_HAVE_SLEPC
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line...
This is the EquationSystems class.
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false)=0
Interfaces for reading/writing a mesh to/from a file.
ConstFunction that simply returns 0.
static constexpr Real TOLERANCE
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
const EigenSolver< Number > & get_eigen_solver() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual void solve() override
Override to solve the condensed eigenproblem with the dofs in local_non_condensed_dofs_vector strippe...
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.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
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.
void initialize_condensed_dofs(const std::set< dof_id_type > &global_condensed_dofs_set=std::set< dof_id_type >())
Loop over the dofs on each processor to initialize the list of non-condensed dofs.
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.
This class extends EigenSystem to allow a simple way of solving (standard or generalized) eigenvalue ...
void assemble_matrices(EquationSystems &es, const std::string &system_name)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i) override
Override get_eigenpair() to retrieve the eigenpair for the condensed eigensolve.
void set_eigenproblem_type(EigenProblemType ept)
Sets the type of the current eigen problem.
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
unsigned int get_n_converged() const
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
const DofMap & get_dof_map() const