90int main(
int argc,
char *argv[])
93 cout <<
"This example is not supported in single precision.\n\n";
94 return MFEM_SKIP_RETURN_VALUE;
104 const char *mesh_file =
"../data/star.mesh";
108 bool visualization =
true;
109 bool verification =
false;
112 args.
AddOption(&mesh_file,
"-m",
"--mesh",
113 "Mesh file to use.");
115 "Finite element order (polynomial degree) or -1 for"
116 " isoparametric space.");
117 args.
AddOption(&num_refs,
"-r",
"--refs",
118 "Number of uniform refinements");
120 "Fractional exponent");
121 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
122 "--no-visualization",
123 "Enable or disable GLVis visualization.");
124 args.
AddOption(&verification,
"-ver",
"--verification",
"-no-ver",
126 "Use sinusoidal function (f) for manufactured "
140 int progress_steps = 1;
144 const int power_of_laplace = floor(
alpha);
145 real_t exponent_to_approximate =
alpha - power_of_laplace;
146 bool integer_order =
false;
148 if (abs(exponent_to_approximate) > 1e-12)
152 mfem::out <<
"Approximating the fractional exponent "
153 << exponent_to_approximate
161 alpha = exponent_to_approximate + power_of_laplace;
165 integer_order =
true;
168 mfem::out <<
"Treating integer order PDE." << endl;
173 Mesh mesh(mesh_file, 1, 1);
177 for (
int i = 0; i < num_refs; i++)
181 ParMesh pmesh(MPI_COMM_WORLD, mesh);
190 cout <<
"Number of degrees of freedom: "
207 for (
int i=0; i<x.Size(); i++)
209 val *= sin(M_PI*x(i));
211 return pow(x.Size()*pow(M_PI,2),
alpha) * val;
247 if (power_of_laplace > 0)
277 mfem::out <<
"\nComputing (-Δ) ^ -" << power_of_laplace
278 <<
" ( f ) " << endl;
280 for (
int i = 0; i < power_of_laplace; i++)
285 if (i == power_of_laplace - 1)
289 if (integer_order && verification)
300 oss_f.str(
""); oss_f.clear();
301 oss_f <<
"Step " << progress_steps++ <<
": Solution of PDE -Δ ^ "
304 fout <<
"parallel " << num_procs <<
" " << myid <<
"\n"
305 <<
"solution\n" << pmesh << g
306 <<
"window_title '" << oss_f.str() <<
"'" << flush;
329 ostringstream oss_x, oss_u;
339 for (
int i = 0; i < coeffs.
Size(); i++)
343 mfem::out <<
"\nSolving PDE -Δ u + " << -poles[i]
344 <<
" u = " << coeffs[i] <<
" g " << endl;
360 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B);
375 a.RecoverFEMSolution(X,
b, x);
384 oss_x.str(
""); oss_x.clear();
385 oss_x <<
"Step " << progress_steps
386 <<
": Solution of PDE -Δ u + " << -poles[i]
387 <<
" u = " << coeffs[i] <<
" g";
388 xout <<
"parallel " << num_procs <<
" " << myid <<
"\n"
389 <<
"solution\n" << pmesh << x
390 <<
"window_title '" << oss_x.str() <<
"'" << flush;
392 oss_u.str(
""); oss_u.clear();
393 oss_u <<
"Step " << progress_steps + 1
394 <<
": Solution of fractional PDE (-Δ)^" <<
alpha
396 uout <<
"parallel " << num_procs <<
" " << myid <<
"\n"
397 <<
"solution\n" << pmesh <<
u
398 <<
"window_title '" << oss_u.str() <<
"'"
409 auto solution = [] (
const Vector &x)
412 for (
int i=0; i<x.
Size(); i++)
414 val *= sin(M_PI*x(i));
419 real_t l2_error =
u.ComputeL2Error(sol);
423 string manufactured_solution,expected_mesh;
427 manufactured_solution =
"sin(π x)";
428 expected_mesh =
"inline_segment.mesh";
431 manufactured_solution =
"sin(π x) sin(π y)";
432 expected_mesh =
"inline_quad.mesh";
435 manufactured_solution =
"sin(π x) sin(π y) sin(π z)";
436 expected_mesh =
"inline_hex.mesh";
441 <<
"\n\nSolution Verification in "<<
dim <<
"D \n\n"
442 <<
"Manufactured solution : " << manufactured_solution <<
"\n"
443 <<
"Expected mesh : " << expected_mesh <<
"\n"
444 <<
"Your mesh : " << mesh_file <<
"\n"
445 <<
"L2 error : " << l2_error <<
"\n\n"
446 << string(80,
'=') << endl;
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.
Class for domain integration .
A general function coefficient.
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_level)
Wrapper for hypre's ParCSR matrix class.
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, real_t alpha=1.0, real_t beta=0.0) const
Computes y = alpha * A * x + beta * y.
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)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void Clear()
Clear the contents of the Mesh.
int Dimension() const
Dimension of the reference space used within the elements.
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.
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.
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
const SparseMatrix * GetRestrictionMatrix() const override
Get the R matrix which restricts a local dof vector to true dof vector.
Class for parallel grid function.
Class for parallel meshes.
virtual void MultTranspose(const Vector &x, Vector &y) const
Multiply a vector with the transposed matrix. y = At * x.
int Size() const
Returns the size of the vector.
void SetSubVectorComplement(const Array< int > &dofs, const real_t val)
Set all vector entries NOT in the dofs Array to the given val.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void ComputePartialFractionApproximation(real_t &alpha, Array< real_t > &coeffs, Array< real_t > &poles, real_t lmax=1000., real_t tol=1e-10, int npoints=1000, int max_order=100)
real_t u(const Vector &xvec)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
std::function< real_t(const Vector &)> f(real_t mass_coeff)