41 int main(
int argc,
char *argv[])
44 const char *mesh_file =
"../data/star.mesh";
46 bool visualization = 1;
49 args.
AddOption(&mesh_file,
"-m",
"--mesh",
52 "Finite element order (polynomial degree).");
53 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
55 "Enable or disable GLVis visualization.");
67 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
77 for (
int l = 0; l < ref_levels; l++)
91 unsigned int trial_order = order;
92 unsigned int trace_order = order - 1;
93 unsigned int test_order = order;
95 if (dim == 2 && (order%2 == 0 || (mesh->
MeshGenerator() & 2 && order > 1)))
99 if (test_order < trial_order)
100 cerr <<
"Warning, test space not enriched enough to handle primal"
116 enum {x0_var, xhat_var, NVAR};
120 int s_test = test_space->
GetVSize();
129 offsets_test[1] = s_test;
131 std::cout <<
"\nNumber of Unknowns:\n"
132 <<
" Trial space, X0 : " << s0
133 <<
" (order " << trial_order <<
")\n"
134 <<
" Interface space, Xhat : " << s1
135 <<
" (order " << trace_order <<
")\n"
136 <<
" Test space, Y : " << s_test
137 <<
" (order " << test_order <<
")\n\n";
196 matSinv.
Mult(F,SinvF);
208 #ifndef MFEM_USE_SUITESPARSE
209 const double prec_rtol = 1e-3;
210 const int prec_maxit = 200;
237 PCG(A, P, b, x, 1, 200, 1e-12, 0.0);
244 cout <<
"\n|| B0*x0 + Bhat*xhat - F ||_{S^-1} = " << res << endl;
248 x0.
MakeRef(x0_space, x.GetBlock(x0_var), 0);
253 ofstream mesh_ofs(
"refined.mesh");
254 mesh_ofs.precision(8);
255 mesh->
Print(mesh_ofs);
256 ofstream sol_ofs(
"sol.gf");
257 sol_ofs.precision(8);
267 sol_sock.precision(8);
268 sol_sock <<
"solution\n" << *mesh << x0 << flush;
Class for domain integration L(v) := (f, v)
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Conjugate gradient method.
Class for grid function - Vector with associated FE space.
Integrator defining a sum of multiple Integrators.
A class to handle Vectors in a block fashion.
A coefficient that is constant across space and time.
HypreParMatrix * RAP(const HypreParMatrix *A, const HypreParMatrix *P)
Returns the matrix P^t * A * P.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
int GetNE() const
Returns number of elements.
void AddIntegrator(BilinearFormIntegrator *integ)
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Direct sparse solver using UMFPACK.
Integrator that inverts the matrix assembled by another integrator.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
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 UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetMaxIter(int max_it)
int MeshGenerator()
Get the mesh generator/type.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
The operator x -> R*A*P*x constructed through the actions of R^T, A and P.
virtual void MakeRef(FiniteElementSpace *f, double *v)
Make the GridFunction reference external data on a new FiniteElementSpace.
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
void PrintUsage(std::ostream &out) const
Print the usage message.
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void SetRelTol(double rtol)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
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...
FDualNumber< tbase > log(const FDualNumber< tbase > &f)
log([dual number])
virtual void Print(std::ostream &os=mfem::out) const
FDualNumber< tbase > sqrt(const FDualNumber< tbase > &f)
sqrt([dual number])
void PrintOptions(std::ostream &out) const
Print the options.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Arbitrary order "H^{-1/2}-conforming" face finite elements defined on the interface between mesh elem...
Arbitrary order H1-conforming (continuous) finite elements.
A class to handle Block systems in a matrix-free implementation.
double InnerProduct(const Vector &x, const Vector &y) const
Compute y^t A x.
void SetBlock(int iRow, int iCol, Operator *op, double c=1.0)
Add a block op in the block-entry (iblock, jblock).
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Good() const
Return true if the command line options were parsed successfully.