49int main(
int argc,
char *argv[])
58 const char *mesh_file =
"../data/beam-tri.mesh";
62 bool visualization = 1;
67 args.
AddOption(&mesh_file,
"-m",
"--mesh",
70 "Finite element order (polynomial degree).");
72 "Number of desired eigenmodes.");
74 "Random seed used to initialize LOBPCG.");
75 args.
AddOption(&amg_elast,
"-elast",
"--amg-for-elasticity",
"-sys",
77 "Use the special AMG elasticity solver (GM/LN approaches), "
78 "or standard AMG for systems (unknown approach).");
79 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
81 "Enable or disable GLVis visualization.");
82 args.
AddOption(&adios2,
"-adios2",
"--adios2-streams",
"-no-adios2",
83 "--no-adios2-streams",
84 "Save data using adios2 streams.");
102 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
108 cerr <<
"\nInput mesh should have at least two materials!"
109 <<
" (See schematic in ex12p.cpp)\n"
127 (int)floor(log(1000./mesh->
GetNE())/log(2.)/
dim);
128 for (
int l = 0; l < ref_levels; l++)
140 int par_ref_levels = 1;
141 for (
int l = 0; l < par_ref_levels; l++)
155 const bool use_nodal_fespace = pmesh->
NURBSext && !amg_elast;
156 if (use_nodal_fespace)
169 cout <<
"Number of unknowns: " << size << endl
170 <<
"Assembling: " << flush;
184 lambda(0) = lambda(1)*50;
199 cout <<
"matrix ... " << flush;
202 a->EliminateEssentialBCDiag(ess_bdr, 1.0);
213 cout <<
"done." << endl;
262 if (!use_nodal_fespace)
270 ostringstream mesh_name, mode_name;
271 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
273 ofstream mesh_ofs(mesh_name.str().c_str());
274 mesh_ofs.precision(8);
275 pmesh->
Print(mesh_ofs);
277 for (
int i=0; i<nev; i++)
282 mode_name <<
"mode_" << setfill(
'0') << setw(2) << i <<
"."
283 << setfill(
'0') << setw(6) << myid;
285 ofstream mode_ofs(mode_name.str().c_str());
286 mode_ofs.precision(8);
294#ifdef MFEM_USE_ADIOS2
297 std::string postfix(mesh_file);
298 postfix.erase(0, std::string(
"../data/").size() );
299 postfix +=
"_o" + std::to_string(order);
302 adios2stream::openmode::out, MPI_COMM_WORLD);
303 pmesh->
Print(adios2output);
304 for (
int i=0; i<nev; i++)
308 x.
Save(adios2output,
"mode_" + std::to_string(i));
321 for (
int i=0; i<nev; i++)
325 cout <<
"Eigenmode " << i+1 <<
'/' << nev
326 <<
", Lambda = " << eigenvalues[i] << endl;
332 mode_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n"
333 <<
"solution\n" << *pmesh << x << flush
334 <<
"window_title 'Eigenmode " << i+1 <<
'/' << nev
335 <<
", Lambda = " << eigenvalues[i] <<
"'" << endl;
340 cout <<
"press (q)uit or (c)ontinue --> " << flush;
343 MPI_Bcast(&c, 1, MPI_CHAR, 0, MPI_COMM_WORLD);
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetSystemsOptions(int dim, bool order_bynodes=false)
void SetElasticityOptions(ParFiniteElementSpace *fespace, bool interp_refine=true)
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 GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void GetNodes(Vector &node_coord) const
void DegreeElevate(int rel_degree, int degree=16)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Array< int > attributes
A list of all unique element attributes used by the Mesh.
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).
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.
A piecewise constant coefficient with the constants keyed off the element attribute numbers.
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 SetNodalFESpace(FiniteElementSpace *nfes) override
void Print(std::ostream &out=mfem::out, const std::string &comments="") const override
int close()
Close the socketstream.