43 int main(
int argc,
char *argv[])
48 const char *mesh_file =
"../data/star.mesh";
50 bool visualization = 1;
53 args.
AddOption(&mesh_file,
"-m",
"--mesh",
56 "Finite element order (polynomial degree).");
57 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
59 "Enable or disable GLVis visualization.");
72 ifstream imesh(mesh_file);
75 cerr <<
"\nCan not open mesh file: " << mesh_file <<
'\n' << endl;
78 mesh =
new Mesh(imesh, 1, 1);
88 (int)floor(log(10000./mesh->
GetNE())/log(2.)/dim);
89 for (
int l = 0; l < ref_levels; l++)
105 block_offsets[0] = 0;
106 block_offsets[1] = R_space->
GetVSize();
107 block_offsets[2] = W_space->
GetVSize();
110 std::cout <<
"***********************************************************\n";
111 std::cout <<
"dim(R) = " << block_offsets[1] - block_offsets[0] <<
"\n";
112 std::cout <<
"dim(W) = " << block_offsets[2] - block_offsets[1] <<
"\n";
113 std::cout <<
"dim(R+W) = " << block_offsets.
Last() <<
"\n";
114 std::cout <<
"***********************************************************\n";
182 for (
int i = 0; i < Md.Size(); i++)
188 #ifndef MFEM_USE_SUITESPARSE
222 <<
" iterations with a residual norm of " << solver.
GetFinalNorm() <<
".\n";
225 <<
" iterations. Residual norm is " << solver.
GetFinalNorm() <<
".\n";
226 std::cout <<
"MINRES solver took " << chrono.
RealTime() <<
"s. \n";
230 u.
Update(R_space, x.GetBlock(0), 0);
231 p.
Update(W_space, x.GetBlock(1), 0);
233 int order_quad = max(2, 2*order+1);
235 for (
int i=0; i < Geometry::NumGeom; ++i)
243 std::cout <<
"|| u_h - u_ex || / || u_ex || = " << err_u / norm_u <<
"\n";
244 std::cout <<
"|| p_h - p_ex || / || p_ex || = " << err_p / norm_p <<
"\n";
250 ofstream mesh_ofs(
"ex5.mesh");
251 mesh_ofs.precision(8);
252 mesh->
Print(mesh_ofs);
254 ofstream u_ofs(
"sol_u.gf");
258 ofstream p_ofs(
"sol_p.gf");
272 char vishost[] =
"localhost";
276 u_sock <<
"solution\n" << *mesh << u <<
"window_title 'Velocity'" << endl;
279 p_sock <<
"solution\n" << *mesh << p <<
"window_title 'Pressure'" << endl;
310 u(0) = - exp(xi)*sin(yi)*cos(zi);
311 u(1) = - exp(xi)*cos(yi)*cos(zi);
314 u(2) = exp(xi)*sin(yi)*sin(zi);
327 return exp(xi)*sin(yi)*cos(zi);
Class for domain integration L(v) := (f, v)
Class for integration rule.
Class for grid function - Vector with associated FE space.
Data type for scaled Jacobi-type smoother of sparse matrix.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void fFun(const Vector &x, Vector &f)
virtual void RegisterField(const char *field_name, GridFunction *gf)
Add a grid function to the collection and update the root file.
Subclass constant coefficient.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
int Size() const
Returns the size of the vector.
int GetNE() const
Returns number of elements.
virtual void Save()
Save the collection and a VisIt root file.
bool iterative_mode
If true, use the second argument of Mult as an initial guess.
void ScaleRow(const int row, const double scale)
Data type for Gauss-Seidel smoother of sparse matrix.
Direct sparse solver using UMFPACK.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
void SetBlock(int i, int j, SparseMatrix *mat)
Set A(i,j) = mat.
virtual void Mult(const Vector &b, Vector &x) const
Operator application.
double ComputeLpNorm(double p, Coefficient &coeff, Mesh &mesh, const IntegrationRule *irs[])
IntegrationRules IntRules(0)
A global object with all integration rules (defined in intrules.cpp)
void SetPrintLevel(int print_lvl)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
double ComputeL2Error(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
A class to handle Block diagonal preconditioners in a matrix-free implementation. ...
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
double f_natural(Vector &x)
Data collection with VisIt I/O routines.
void SetMaxIter(int max_it)
void Transpose(const Table &A, Table &At, int _ncols_A)
Transpose a Table.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
void PrintUsage(std::ostream &out) const
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
virtual void Print(std::ostream &out=std::cout) const
Print the mesh to the given stream using the default MFEM mesh format.
void SetAbsTol(double atol)
int main(int argc, char *argv[])
void SetRelTol(double rtol)
Abstract finite element space.
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)
void PartialSum()
Partial Sum.
void uFun_ex(const Vector &x, Vector &u)
void PrintOptions(std::ostream &out) const
T & Last()
Return the last element in the array.
double pFun_ex(Vector &x)
for VectorFiniteElements (Nedelec, Raviart-Thomas)
class for C-function coefficient
Vector & GetBlock(int i)
Get the i-th vector in the block.
Integrator for (Q u, v) for VectorFiniteElements.
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).
Arbitrary order "L2-conforming" discontinuous finite elements.