39 return (0.25 * (2.0 + x[0]) - x[2]) * (x[2] + 0.25 * (2.0 + x[0]));
45 du[0] = 0.125 * (2.0 + x[0]) * x[1] * x[1];
46 du[1] = -0.125 * (2.0 + x[0]) * x[0] * x[1];
64int main(
int argc,
char *argv[])
76 int ser_ref_levels = 2;
77 int par_ref_levels = 1;
78 bool static_cond =
false;
79 bool visualization =
true;
82 args.
AddOption(&mesh_type,
"-mt",
"--mesh-type",
83 "Mesh type: 3 - Triangular, 4 - Quadrilateral.");
84 args.
AddOption(&mesh_order,
"-mo",
"--mesh-order",
85 "Geometric order of the curved mesh.");
86 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
87 "Number of times to refine the mesh uniformly in serial.");
88 args.
AddOption(&par_ref_levels,
"-rp",
"--refine-parallel",
89 "Number of times to refine the mesh uniformly in parallel.");
91 "Finite element order (polynomial degree) or -1 for"
92 " isoparametric space.");
93 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
94 "--no-static-condensation",
"Enable static condensation.");
95 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
97 "Enable or disable GLVis visualization.");
107 for (
int l = 0; l < ser_ref_levels; l++)
115 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
117 for (
int l = 0; l < par_ref_levels; l++)
133 cout <<
"Number of unknowns: " << total_num_dofs << endl;
168 a.AddDomainIntegrator(integ);
174 if (static_cond) {
a.EnableStaticCondensation(); }
179 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B);
183 cout <<
"Size of linear system: "
206 if (myid == 0) { cout <<
"|u - u_h|_2 = " << error << endl; }
215 if (myid == 0) { cout <<
"|f - f_h|_2 = " << flux_err << endl; }
220 ostringstream mesh_name, sol_name, flux_name;
221 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
222 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
223 flux_name <<
"flux." << setfill(
'0') << setw(6) << myid;
225 ofstream mesh_ofs(mesh_name.str().c_str());
226 mesh_ofs.precision(8);
227 pmesh.
Print(mesh_ofs);
229 ofstream sol_ofs(sol_name.str().c_str());
230 sol_ofs.precision(8);
233 ofstream flux_ofs(flux_name.str().c_str());
234 flux_ofs.precision(8);
244 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
245 sol_sock.precision(8);
246 sol_sock <<
"solution\n" << pmesh << x
247 <<
"window_title 'Solution'\n" << flush;
250 flux_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
251 flux_sock.precision(8);
252 flux_sock <<
"solution\n" << pmesh << flux
254 <<
"window_geometry 402 0 400 350\n"
255 <<
"window_title 'Flux'\n" << flush;
269 mesh =
new Mesh(2, 12, 16, 8, 3);
312 mesh =
new Mesh(2, 8, 4, 8, 3);
339 MFEM_ABORT(
"Unrecognized mesh type " << type <<
"!");
354 if (fabs(x[1] + 1.0) < tol)
356 theta = 0.25 * M_PI * (x[0] - 2.0);
358 else if (fabs(x[0] - 1.0) < tol)
360 theta = 0.25 * M_PI * x[1];
362 else if (fabs(x[1] - 1.0) < tol)
364 theta = 0.25 * M_PI * (2.0 - x[0]);
366 else if (fabs(x[0] + 1.0) < tol)
368 theta = 0.25 * M_PI * (4.0 - x[1]);
372 cerr <<
"side not recognized "
373 << x[0] <<
" " << x[1] <<
" " << x[2] << endl;
378 r[2] = 0.25 * (2.0 * x[2] - 1.0) * (r[0] + 2.0);
385 real_t a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
386 s(0,0) = 0.5 + x[0] * x[0] * (8.0 /
a - 0.5);
387 s(0,1) = x[0] * x[1] * (8.0 /
a - 0.5);
390 s(1,1) = 0.5 * x[0] * x[0] + 8.0 * x[1] * x[1] /
a;
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
int Size() const
Return the logical size of the array.
Conjugate gradient method.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the Conjugate Gradient method.
A coefficient that is constant across space and time.
Data type dense matrix using column-major storage.
Class for domain integration .
A general function coefficient.
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
Wrapper for hypre's ParCSR matrix class.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
void SetRelTol(real_t rtol)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
A matrix coefficient with an optional scalar coefficient multiplier q. The matrix function can either...
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
int AddQuad(int v1, int v2, int v3, int v4, int attr=1)
Adds a quadrilateral to the mesh given by 4 vertices v1 through v4.
int AddTriangle(int v1, int v2, int v3, int attr=1)
Adds a triangle to the mesh given by 3 vertices v1 through v3.
void FinalizeTopology(bool generate_bdr=true)
Finalize the construction of the secondary topology (connectivity) data of a Mesh.
int AddVertex(real_t x, real_t y=0.0, real_t z=0.0)
int Dimension() const
Dimension of the reference space used within the elements.
int AddBdrSegment(int v1, int v2, int attr=1)
void Transform(void(*f)(const Vector &, Vector &))
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
Pointer to an Operator of a specified type.
OpType * As() const
Return the Operator pointer statically cast to a specified OpType. Similar to the method Get().
virtual void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x)
Reconstruct a solution vector x (e.g. a GridFunction) from the solution X of a constrained linear sys...
void ParseCheck(std::ostream &out=mfem::out)
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...
Abstract parallel finite element space.
void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const override
HYPRE_BigInt GlobalTrueVSize() const
Class for parallel grid function.
void Save(std::ostream &out) const override
real_t ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const override
void ComputeFlux(BilinearFormIntegrator &blfi, GridFunction &flux, bool wcoef=true, int subdomain=-1) override
Class for parallel meshes.
void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1) override
Set the curvature of the mesh nodes using the given polynomial degree.
void Print(std::ostream &out=mfem::out, const std::string &comments="") const override
A general vector function coefficient.
void SetSize(int s)
Resize the vector to size s.
real_t sigma(const Vector &x)
void sigmaFunc(const Vector &x, DenseMatrix &s)
void duExact(const Vector &x, Vector &du)
void fluxExact(const Vector &x, Vector &f)
real_t uExact(const Vector &x)
void trans(const Vector &x, Vector &r)
std::function< real_t(const Vector &)> f(real_t mass_coeff)