58 static double mu_ = 1.0;
59 static double epsilon_ = 1.0;
60 static double sigma_ = 2.0;
64 int main(
int argc,
char *argv[])
67 Mpi::Init(argc, argv);
68 int num_procs = Mpi::WorldSize();
69 int myid = Mpi::WorldRank();
73 const char *mesh_file =
"../data/fichera-mixed.mesh";
74 int ser_ref_levels = 1;
75 int par_ref_levels = 1;
81 double omega = 2.0 * M_PI;
83 bool herm_conv =
true;
84 bool slu_solver =
false;
85 bool visualization = 1;
88 const char *device_config =
"cpu";
91 args.
AddOption(&mesh_file,
"-m",
"--mesh",
93 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
94 "Number of times to refine the mesh uniformly in serial.");
95 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
96 "Number of times to refine the mesh uniformly in parallel.");
98 "Finite element order (polynomial degree).");
100 "Choose between 0: H_1, 1: H(Curl), or 2: H(Div) " 101 "damped harmonic oscillator.");
102 args.
AddOption(&mode,
"-em",
"--eigenmode",
103 "Choose the index of the port eigenmode.");
104 args.
AddOption(&a_coef,
"-a",
"--stiffness-coef",
105 "Stiffness coefficient (spring constant or 1/mu).");
106 args.
AddOption(&epsilon_,
"-b",
"--mass-coef",
107 "Mass coefficient (or epsilon).");
108 args.
AddOption(&sigma_,
"-c",
"--damping-coef",
109 "Damping coefficient (or sigma).");
110 args.
AddOption(&mu_,
"-mu",
"--permeability",
111 "Permeability of free space (or 1/(spring constant)).");
112 args.
AddOption(&epsilon_,
"-eps",
"--permittivity",
113 "Permittivity of free space (or mass constant).");
114 args.
AddOption(&sigma_,
"-sigma",
"--conductivity",
115 "Conductivity (or damping constant).");
117 "Frequency (in Hz).");
118 args.
AddOption(&port_bc_attr,
"-pbc",
"--port-bc-attr",
119 "Attributes of port boundary condition");
120 args.
AddOption(&herm_conv,
"-herm",
"--hermitian",
"-no-herm",
121 "--no-hermitian",
"Use convention for Hermitian operators.");
122 #ifdef MFEM_USE_SUPERLU 123 args.
AddOption(&slu_solver,
"-slu",
"--superlu",
"-no-slu",
124 "--no-superlu",
"Use the SuperLU Solver.");
126 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
127 "--no-visualization",
128 "Enable or disable GLVis visualization.");
129 args.
AddOption(&mixed,
"-mixed",
"--mixed-mesh",
"-hex",
130 "--hex-mesh",
"Mixed mesh of hexahedral mesh.");
131 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
132 "--no-partial-assembly",
"Enable Partial Assembly.");
133 args.
AddOption(&device_config,
"-d",
"--device",
134 "Device configuration string, see Device::Configure().");
147 mesh_file =
"../data/fichera.mesh";
158 if (port_bc_attr.
Size() == 0 &&
159 (strcmp(mesh_file,
"../data/fichera-mixed.mesh") == 0 ||
160 strcmp(mesh_file,
"../data/fichera.mesh") == 0))
165 port_bc_attr[2] = 11;
166 port_bc_attr[3] = 12;
175 "Unrecognized problem type: " <<
prob);
178 herm_conv ? ComplexOperator::HERMITIAN : ComplexOperator::BLOCK_SYMMETRIC;
182 Device device(device_config);
183 if (myid == 0) { device.
Print(); }
188 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
192 for (
int l = 0; l < ser_ref_levels; l++)
200 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
202 for (
int l = 0; l < par_ref_levels; l++)
208 ParSubMesh pmesh_port(ParSubMesh::CreateFromBoundary(pmesh, port_bc_attr));
217 cout <<
"Switching to problem type 0, H1 basis functions, " 218 <<
"for 1 dimensional mesh." << endl;
235 cout <<
"Number of finite element unknowns: " << size << endl;
253 BasisType::GaussLegendre,
254 FiniteElement::INTEGRAL);
258 BasisType::GaussLegendre,
259 FiniteElement::INTEGRAL);
break;
266 cout <<
"Number of finite element port BC unknowns: " << size_port
281 ostringstream mesh_name, port_name;
282 mesh_name <<
"port_mesh." << setfill(
'0') << setw(6) << myid;
283 port_name <<
"port_mode." << setfill(
'0') << setw(6) << myid;
285 ofstream mesh_ofs(mesh_name.str().c_str());
286 mesh_ofs.precision(8);
287 pmesh_port.
Print(mesh_ofs);
289 ofstream port_ofs(port_name.str().c_str());
290 port_ofs.precision(8);
291 port_bc.
Save(port_ofs);
294 if (visualization &&
dim == 3)
299 port_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
300 port_sock.precision(8);
301 port_sock <<
"solution\n" << pmesh_port << port_bc
302 <<
"window_title 'Port BC'" 303 <<
"window_geometry 0 0 400 350" << flush;
321 b.Vector::operator=(0.0);
335 port_to_full.
Transfer(port_bc, full_bc);
342 full_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
343 full_sock.precision(8);
344 full_sock <<
"solution\n" << pmesh << full_bc
345 <<
"window_title 'Transferred BC'" 346 <<
"window_geometry 400 0 400 350"<< flush;
369 if (pa) {
a.SetAssemblyLevel(AssemblyLevel::PARTIAL); }
402 a.FormLinearSystem(ess_tdof_list,
u,
b, A, U, B);
406 cout <<
"Size of linear system: " 407 << 2 * size << endl << endl;
451 blockTrueOffsets[0] = 0;
452 blockTrueOffsets[1] = A->
Height() / 2;
453 blockTrueOffsets[2] = A->
Height() / 2;
492 (conv == ComplexOperator::HERMITIAN) ?
507 #ifdef MFEM_USE_SUPERLU 526 a.RecoverFEMSolution(U,
b,
u);
532 ostringstream mesh_name, sol_r_name, sol_i_name;
533 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
534 sol_r_name <<
"sol_r." << setfill(
'0') << setw(6) << myid;
535 sol_i_name <<
"sol_i." << setfill(
'0') << setw(6) << myid;
537 ofstream mesh_ofs(mesh_name.str().c_str());
538 mesh_ofs.precision(8);
539 pmesh.
Print(mesh_ofs);
541 ofstream sol_r_ofs(sol_r_name.str().c_str());
542 ofstream sol_i_ofs(sol_i_name.str().c_str());
543 sol_r_ofs.precision(8);
544 sol_i_ofs.precision(8);
545 u.real().Save(sol_r_ofs);
546 u.imag().Save(sol_i_ofs);
555 sol_sock_r <<
"parallel " << num_procs <<
" " << myid <<
"\n";
556 sol_sock_r.precision(8);
557 sol_sock_r <<
"solution\n" << pmesh <<
u.real()
558 <<
"window_title 'Solution: Real Part'" 559 <<
"window_geometry 800 0 400 350" << flush;
561 MPI_Barrier(MPI_COMM_WORLD);
564 sol_sock_i <<
"parallel " << num_procs <<
" " << myid <<
"\n";
565 sol_sock_i.precision(8);
566 sol_sock_i <<
"solution\n" << pmesh <<
u.imag()
567 <<
"window_title 'Solution: Imaginary Part'" 568 <<
"window_geometry 1200 0 400 350" << flush;
577 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
578 sol_sock.precision(8);
579 sol_sock <<
"solution\n" << pmesh << u_t
580 <<
"window_title 'Harmonic Solution (t = 0.0 T)'" 581 <<
"window_geometry 0 432 600 450" 582 <<
"pause\n" << flush;
584 cout <<
"GLVis visualization paused." 585 <<
" Press space (in the GLVis window) to resume it.\n";
590 double t = (double)(i % num_frames) / num_frames;
592 oss <<
"Harmonic Solution (t = " <<
t <<
" T)";
594 add(cos( 2.0 * M_PI *
t),
u.real(),
595 sin(-2.0 * M_PI *
t),
u.imag(), u_t);
596 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
597 sol_sock <<
"solution\n" << pmesh << u_t
598 <<
"window_title '" << oss.str() <<
"'" << flush;
617 int nev = std::max(mode + 2, 5);
633 a.EliminateEssentialBCDiag(ess_bdr, 1.0);
675 int nev = std::max(mode + 2, 5);
690 a.EliminateEssentialBCDiag(ess_bdr, 1.0);
733 int nev = std::max(mode + 2, 5);
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
void ScalarWaveGuide(int mode, ParGridFunction &x)
The Auxiliary-space Maxwell Solver in hypre.
The Auxiliary-space Divergence Solver in hypre.
A coefficient that is constant across space and time.
void SetMassMatrix(const HypreParMatrix &M)
void PrintOptions(std::ostream &out) const
Print the options.
void SetPortBC(int prob, int dim, int mode, ParGridFunction &port_bc)
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.
Integrator for (curl u, curl v) for Nedelec elements.
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
Pointer to an Operator of a specified type.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetPreconditioner(HypreSolver &precond)
void SetPreconditioner(Solver &precond)
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
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)
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
(Q div u, div v) for RT elements
void add(const Vector &v1, const Vector &v2, Vector &v)
void SetSymmetricPattern(bool sym)
Subdomain representation of a topological parent in another ParMesh.
virtual void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
void SetOperator(const Operator &op)
Set/update the solver for the given operator.
The BoomerAMG solver in hypre.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_iter)
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
A class to handle Block diagonal preconditioners in a matrix-free implementation. ...
void VectorWaveGuide(int mode, ParGridFunction &x)
const FiniteElementCollection * FEColl() const
void SetColumnPermutation(superlu::ColPerm col_perm)
Jacobi smoothing for a given bilinear form (no matrix necessary).
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetPrintLevel(int print_level)
ParMesh * GetParMesh() const
void SetMaxIter(int max_it)
int main(int argc, char *argv[])
ParTransferMap represents a mapping of degrees of freedom from a source ParGridFunction to a destinat...
void SetPrintStatistics(bool print_stat)
HYPRE_BigInt GlobalTrueVSize() const
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
void Transfer(const ParGridFunction &src, ParGridFunction &dst) const
Transfer the source ParGridFunction to the destination ParGridFunction.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void SetRelTol(double rtol)
Scaled Operator B: x -> a A(x).
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
void SetPrintLevel(int print_lvl)
ParFiniteElementSpace * ParFESpace() const
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.
void Solve()
Solve the eigenproblem.
void PartialSum()
Fill the entries of the array with the cumulative sum of the entries.
void SetNumModes(int num_eigs)
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
void SetMaxIter(int max_iter)
virtual void Save(std::ostream &out) const
void SetRandomSeed(int s)
OpType * As() const
Return the Operator pointer statically cast to a specified OpType. Similar to the method Get()...
Specialization of the ComplexOperator built from a pair of HypreParMatrices.
void SetOperator(Operator &A)
void SetPrintLevel(int logging)
Operator * Ptr() const
Access the underlying Operator pointer.
int Size() const
Return the logical size of the array.
Arbitrary order H(curl)-conforming Nedelec finite elements.
void SetPrecondUsageMode(int pcg_mode)
void SetOperator(const HypreParMatrix &A)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
void Print(std::ostream &out=mfem::out) const override
double u(const Vector &xvec)
Class for parallel grid function.
static void Transfer(const ParGridFunction &src, ParGridFunction &dst)
Transfer the dofs of a ParGridFunction.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
Wrapper for hypre's ParCSR matrix class.
void SetNumModes(int num_eigs)
Class for parallel meshes.
void SetSingularProblem()
Set this option when solving a curl-curl problem with zero mass term.
void Solve()
Solve the eigenproblem.
void PseudoScalarWaveGuide(int mode, ParGridFunction &x_l2)
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).
const HypreParVector & GetEigenvector(unsigned int i) const
Extract a single eigenvector.
Arbitrary order "L2-conforming" discontinuous finite elements.