48 int main(
int argc,
char *argv[])
51 Mpi::Init(argc, argv);
52 int num_procs = Mpi::WorldSize();
53 int myid = Mpi::WorldRank();
57 const char *mesh_file =
"../../data/star.mesh";
58 int ser_ref_levels = 2;
59 int par_ref_levels = 1;
64 bool slu_solver =
false;
65 bool sp_solver =
false;
66 bool visualization = 1;
69 args.
AddOption(&mesh_file,
"-m",
"--mesh",
71 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
72 "Number of times to refine the mesh uniformly in serial.");
73 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
74 "Number of times to refine the mesh uniformly in parallel.");
76 "Finite element order (polynomial degree) or -1 for" 77 " isoparametric space.");
79 "Number of desired eigenmodes.");
81 "Random seed used to initialize LOBPCG.");
82 #ifdef MFEM_USE_SUPERLU 83 args.
AddOption(&slu_solver,
"-slu",
"--superlu",
"-no-slu",
84 "--no-superlu",
"Use the SuperLU Solver.");
86 #ifdef MFEM_USE_STRUMPACK 87 args.
AddOption(&sp_solver,
"-sp",
"--strumpack",
"-no-sp",
88 "--no-strumpack",
"Use the STRUMPACK Solver.");
90 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
92 "Enable or disable GLVis visualization.");
94 if (slu_solver && sp_solver)
97 cout <<
"WARNING: Both SuperLU and STRUMPACK have been selected," 98 <<
" please choose either one." << endl
99 <<
" Defaulting to SuperLU." << endl;
123 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
129 for (
int lev = 0; lev < ser_ref_levels; lev++)
140 for (
int lev = 0; lev < par_ref_levels; lev++)
160 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
167 cout <<
"Mesh does not have FEs --> Assume order 1.\n";
173 else if (pmesh->
NURBSext && (order[0] > 0) )
179 if (order.
Size() == 1)
185 if (order.
Size() != nkv ) {
mfem_error(
"Wrong number of orders set."); }
190 if (order.
Size() > 1) { cout <<
"Wrong number of orders set, needs one.\n"; }
198 cout <<
"Number of unknowns: " << size << endl;
226 a->EliminateEssentialBCDiag(ess_bdr, 1.0);
239 #if defined(MFEM_USE_SUPERLU) || defined(MFEM_USE_STRUMPACK) 241 #ifdef MFEM_USE_SUPERLU 247 #ifdef MFEM_USE_STRUMPACK 262 if (!slu_solver && !sp_solver)
270 #ifdef MFEM_USE_SUPERLU 281 #ifdef MFEM_USE_STRUMPACK 285 strumpack->SetPrintFactorStatistics(
true);
286 strumpack->SetPrintSolveStatistics(
false);
287 strumpack->SetKrylovSolver(strumpack::KrylovSolver::DIRECT);
288 strumpack->SetReorderingStrategy(strumpack::ReorderingStrategy::METIS);
320 ostringstream mesh_name, mode_name;
321 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
323 ofstream mesh_ofs(mesh_name.str().c_str());
324 mesh_ofs.precision(8);
325 pmesh->
Print(mesh_ofs);
327 for (
int i=0; i<nev; i++)
332 mode_name <<
"mode_" << setfill(
'0') << setw(2) << i <<
"." 333 << setfill(
'0') << setw(6) << myid;
335 ofstream mode_ofs(mode_name.str().c_str());
336 mode_ofs.precision(8);
348 mode_sock.precision(8);
350 for (
int i=0; i<nev; i++)
354 cout <<
"Eigenmode " << i+1 <<
'/' << nev
355 <<
", Lambda = " << eigenvalues[i] << endl;
361 mode_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n" 362 <<
"solution\n" << *pmesh << x << flush
363 <<
"window_title 'Eigenmode " << i+1 <<
'/' << nev
364 <<
", Lambda = " << eigenvalues[i] <<
"'" << endl;
369 cout <<
"press (q)uit or (c)ontinue --> " << flush;
372 MPI_Bcast(&c, 1, MPI_CHAR, 0, MPI_COMM_WORLD);
387 #if defined(MFEM_USE_SUPERLU) || defined(MFEM_USE_STRUMPACK) Arbitrary order non-uniform rational B-splines (NURBS) finite elements.
void GetEigenvalues(Array< double > &eigenvalues) const
Collect the converged eigenvalues.
A coefficient that is constant across space and time.
void PrintOptions(std::ostream &out) const
Print the options.
int Dimension() const
Dimension of the reference space used within the elements.
const HypreParVector & GetEigenvector(unsigned int i) const
Extract a single eigenvector.
void PrintUsage(std::ostream &out) const
Print the usage message.
int main(int argc, char *argv[])
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetPreconditioner(Solver &precond)
void SetMassMatrix(Operator &M)
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
void SetPrintLevel(int logging)
void SetSymmetricPattern(bool sym)
int close()
Close the socketstream.
void SetOperator(const Operator &op)
Set/update the solver for the given operator.
The BoomerAMG solver in hypre.
void SetMaxIter(int max_iter)
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void SetColumnPermutation(superlu::ColPerm col_perm)
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetPrintLevel(int print_level)
virtual const char * Name() const
void SetPrintStatistics(bool print_stat)
HYPRE_BigInt GlobalTrueVSize() const
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
virtual void Save(std::ostream &out) const
void SetRandomSeed(int s)
NURBSExtension * NURBSext
Optional NURBS mesh extension.
void SetOperator(Operator &A)
int Size() const
Return the logical size of the array.
void SetPrecondUsageMode(int pcg_mode)
Arbitrary order H1-conforming (continuous) finite elements.
void GetNodes(Vector &node_coord) const
void Print(std::ostream &out=mfem::out) const override
Class for parallel grid function.
Wrapper for hypre's ParCSR matrix class.
void SetNumModes(int num_eigs)
Class for parallel meshes.
void Solve()
Solve the eigenproblem.