48int main(
int argc,
char *argv[])
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;
67 bool visualization = 1;
70 args.
AddOption(&mesh_file,
"-m",
"--mesh",
72 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
73 "Number of times to refine the mesh uniformly in serial.");
74 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
75 "Number of times to refine the mesh uniformly in parallel.");
77 "Finite element order (polynomial degree) or -1 for"
78 " isoparametric space.");
80 "Number of desired eigenmodes.");
82 "Random seed used to initialize LOBPCG.");
83#ifdef MFEM_USE_SUPERLU
84 args.
AddOption(&slu_solver,
"-slu",
"--superlu",
"-no-slu",
85 "--no-superlu",
"Use the SuperLU Solver.");
87#ifdef MFEM_USE_STRUMPACK
88 args.
AddOption(&sp_solver,
"-sp",
"--strumpack",
"-no-sp",
89 "--no-strumpack",
"Use the STRUMPACK Solver.");
91 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
93 "Enable or disable GLVis visualization.");
94 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
96 if (slu_solver && sp_solver)
99 cout <<
"WARNING: Both SuperLU and STRUMPACK have been selected,"
100 <<
" please choose either one." << endl
101 <<
" Defaulting to SuperLU." << endl;
125 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
131 for (
int lev = 0; lev < ser_ref_levels; lev++)
142 for (
int lev = 0; lev < par_ref_levels; lev++)
162 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
169 cout <<
"Mesh does not have FEs --> Assume order 1.\n";
175 else if (pmesh->
NURBSext && (order[0] > 0) )
181 if (order.
Size() == 1)
187 if (order.
Size() != nkv ) {
mfem_error(
"Wrong number of orders set."); }
192 if (order.
Size() > 1) { cout <<
"Wrong number of orders set, needs one.\n"; }
200 cout <<
"Number of unknowns: " << size << endl;
228 a->EliminateEssentialBCDiag(ess_bdr, 1.0);
241#if defined(MFEM_USE_SUPERLU) || defined(MFEM_USE_STRUMPACK)
243#ifdef MFEM_USE_SUPERLU
249#ifdef MFEM_USE_STRUMPACK
264 if (!slu_solver && !sp_solver)
272#ifdef MFEM_USE_SUPERLU
283#ifdef MFEM_USE_STRUMPACK
291 strumpack->
SetMatching(strumpack::MatchingJob::NONE);
323 ostringstream mesh_name, mode_name;
324 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
326 ofstream mesh_ofs(mesh_name.str().c_str());
327 mesh_ofs.precision(8);
328 pmesh->
Print(mesh_ofs);
330 for (
int i=0; i<nev; i++)
335 mode_name <<
"mode_" << setfill(
'0') << setw(2) << i <<
"."
336 << setfill(
'0') << setw(6) << myid;
338 ofstream mode_ofs(mode_name.str().c_str());
339 mode_ofs.precision(8);
350 mode_sock.precision(8);
352 for (
int i=0; i<nev; i++)
356 cout <<
"Eigenmode " << i+1 <<
'/' << nev
357 <<
", Lambda = " << eigenvalues[i] << endl;
363 mode_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n"
364 <<
"solution\n" << *pmesh << x << flush
365 <<
"window_title 'Eigenmode " << i+1 <<
'/' << nev
366 <<
", Lambda = " << eigenvalues[i] <<
"'" << endl;
371 cout <<
"press (q)uit or (c)ontinue --> " << flush;
374 MPI_Bcast(&c, 1, MPI_CHAR, 0, MPI_COMM_WORLD);
389#if defined(MFEM_USE_SUPERLU) || defined(MFEM_USE_STRUMPACK)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
A coefficient that is constant across space and time.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
virtual const char * Name() const
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_level)
void SetMassMatrix(Operator &M)
void SetPrintLevel(int logging)
void SetPreconditioner(Solver &precond)
void GetEigenvalues(Array< real_t > &eigenvalues) const
Collect the converged eigenvalues.
void SetOperator(Operator &A)
void SetNumModes(int num_eigs)
void Solve()
Solve the eigenproblem.
void SetPrecondUsageMode(int pcg_mode)
void SetRandomSeed(int s)
void SetMaxIter(int max_iter)
const HypreParVector & GetEigenvector(unsigned int i) const
Extract a single eigenvector.
Wrapper for hypre's ParCSR matrix class.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
int Dimension() const
Dimension of the reference space used within the elements.
void GetNodes(Vector &node_coord) const
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
NURBSExtension generally contains multiple NURBSPatch objects spanning an entire Mesh....
int GetNKV() const
Return the number of KnotVectors.
Arbitrary order non-uniform rational B-splines (NURBS) finite elements.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
HYPRE_BigInt GlobalTrueVSize() const
Class for parallel grid function.
void Save(std::ostream &out) const override
Class for parallel meshes.
void Print(std::ostream &out=mfem::out, const std::string &comments="") const override
void SetMatching(strumpack::MatchingJob job)
Configure static pivoting for stability.
void SetCompression(strumpack::CompressionType type)
Select compression for sparse data types.
void SetPrintFactorStatistics(bool print_stat)
Set up verbose printing during the factor step.
void SetKrylovSolver(strumpack::KrylovSolver method)
Set the Krylov solver method to use.
void SetFromCommandLine()
Set options that were captured from the command line.
void SetPrintSolveStatistics(bool print_stat)
Set up verbose printing during the solve step.
void SetOperator(const Operator &op) override
Set the operator/matrix.
void SetReorderingStrategy(strumpack::ReorderingStrategy method)
Set matrix reordering strategy.
void SetColumnPermutation(superlu::ColPerm col_perm)
Specify how to permute the columns of the matrix.
void SetSymmetricPattern(bool sym)
Specify whether the matrix has a symmetric pattern to avoid extra work (default false)
void SetOperator(const Operator &op)
Set the operator/matrix.
void SetPrintStatistics(bool print_stat)
Specify whether to print the solver statistics (default true)
int close()
Close the socketstream.
@ PARMETIS
Sequential ordering on structure of using the PARMETIS package.
void mfem_error(const char *msg)