41int 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);
76 (int)floor(log(10000./mesh->
GetNE())/log(2.)/
dim);
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;
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 real_t 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;
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
A class to handle Block diagonal preconditioners in a matrix-free implementation.
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).
A class to handle Block systems in a matrix-free implementation.
void SetBlock(int iRow, int iCol, Operator *op, real_t c=1.0)
Add a block op in the block-entry (iblock, jblock).
virtual void Mult(const Vector &x, Vector &y) const
Operator application.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator.
A class to handle Vectors in a block fashion.
Conjugate gradient method.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
A coefficient that is constant across space and time.
Class for domain integration .
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Class for grid function - Vector with associated FE space.
virtual void MakeRef(FiniteElementSpace *f, real_t *v)
Make the GridFunction reference external data on a new FiniteElementSpace.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
Arbitrary order H1-conforming (continuous) finite elements.
Integrator that inverts the matrix assembled by another integrator.
void SetRelTol(real_t rtol)
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
Arbitrary order "L2-conforming" discontinuous finite elements.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
int MeshGenerator() const
Get the mesh generator/type.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
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.
The operator x -> R*A*P*x constructed through the actions of R^T, A and P.
Arbitrary order "H^{-1/2}-conforming" face finite elements defined on the interface between mesh elem...
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
real_t InnerProduct(const Vector &x, const Vector &y) const
Compute y^t A x.
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
Integrator defining a sum of multiple Integrators.
Direct sparse solver using UMFPACK.
void RAP(const DenseMatrix &A, const DenseMatrix &P, DenseMatrix &RAP)
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)