45 int main(
int argc,
char *argv[])
49 MPI_Init(&argc, &argv);
50 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
51 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
54 const char *mesh_file =
"../data/beam-hex.mesh";
56 bool static_cond =
false;
58 const char *device_config =
"cpu";
59 bool visualization = 1;
62 args.
AddOption(&mesh_file,
"-m",
"--mesh",
65 "Finite element order (polynomial degree).");
66 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
67 "--no-static-condensation",
"Enable static condensation.");
68 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
69 "--no-partial-assembly",
"Enable Partial Assembly.");
70 args.
AddOption(&device_config,
"-d",
"--device",
71 "Device configuration string, see Device::Configure().");
72 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
74 "Enable or disable GLVis visualization.");
93 Device device(device_config);
94 if (myid == 0) { device.
Print(); }
99 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
108 int ref_levels = (int)floor(log(1000./mesh->
GetNE())/log(2.)/
dim);
109 for (
int l = 0; l < ref_levels; l++)
123 int par_ref_levels = 1;
124 for (
int l = 0; l < par_ref_levels; l++)
141 cout <<
"Number of Nedelec finite element unknowns: " << size << endl;
142 cout <<
"Number of H1 finite element unknowns: " << H1size << endl;
268 cout <<
"\n Solution of (E_h,v) = (grad p_h,v) for E_h and v in "
269 "H(curl): || E_h - grad p ||_{L^2} = " << errSol <<
'\n' << endl;
270 cout <<
" Gradient interpolant E_h = grad p_h in H(curl): || E_h - "
271 "grad p ||_{L^2} = " << errInterp <<
'\n' << endl;
272 cout <<
" Projection E_h of exact grad p in H(curl): || E_h - grad p "
273 "||_{L^2} = " << errProj <<
'\n' << endl;
280 ostringstream mesh_name, sol_name;
281 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
282 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
284 ofstream mesh_ofs(mesh_name.str().c_str());
285 mesh_ofs.precision(8);
286 pmesh->
Print(mesh_ofs);
288 ofstream sol_ofs(sol_name.str().c_str());
289 sol_ofs.precision(8);
296 char vishost[] =
"localhost";
299 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
300 sol_sock.precision(8);
301 sol_sock <<
"solution\n" << *pmesh << x << flush;
324 return sin(x(0)) * sin(x(1)) * sin(x(2));
328 return sin(x(0)) * sin(x(1));
338 f(0) = cos(x(0)) * sin(x(1)) * sin(x(2));
339 f(1) = sin(x(0)) * cos(x(1)) * sin(x(2));
340 f(2) = sin(x(0)) * sin(x(1)) * cos(x(2));
344 f(0) = cos(x(0)) * sin(x(1));
345 f(1) = sin(x(0)) * cos(x(1));
346 if (x.
Size() == 3) { f(2) = 0.0; }
Conjugate gradient method.
void SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
Subclass constant coefficient.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
virtual void ReorientTetMesh()
See the remarks for the serial version in mesh.hpp.
Pointer to an Operator of a specified type.
int Size() const
Returns the size of the vector.
int GetNE() const
Returns number of elements.
virtual void Save(std::ostream &out) const
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
int main(int argc, char *argv[])
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A * x + beta * y.
void SetPrintLevel(int print_lvl)
void AddDomainInterpolator(DiscreteInterpolator *di)
Adds a domain interpolator. Assumes ownership of di.
virtual int GetTrueVSize() const
Return the number of local vector true dofs.
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
void SetPrintLevel(int print_lvl)
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
Jacobi preconditioner in hypre.
Jacobi smoothing for a given bilinear form (no matrix necessary).
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetMaxIter(int max_it)
HYPRE_Int GlobalTrueVSize() const
virtual void Print(std::ostream &out=mfem::out) const
void PrintUsage(std::ostream &out) const
void SetMaxIter(int max_iter)
double p_exact(const Vector &x)
int SpaceDimension() const
void SetRelTol(double rtol)
Base class Coefficient that may optionally depend on time.
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)
virtual double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void PrintOptions(std::ostream &out) const
HypreParVector * GetTrueDofs() const
Returns the true dofs in a new HypreParVector.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
class for C-function coefficient
Arbitrary order H(curl)-conforming Nedelec finite elements.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
Class for parallel grid function.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
Wrapper for hypre's ParCSR matrix class.
virtual void Assemble(int skip_zeros=1)
Construct the internal matrix representation of the discrete linear operator.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
Class for parallel meshes.
void gradp_exact(const Vector &, Vector &)
double sigma(const Vector &x)