87 int main(
int argc,
char *argv[])
90 Mpi::Init(argc, argv);
91 int num_procs = Mpi::WorldSize();
92 int myid = Mpi::WorldRank();
96 const char *mesh_file =
"../data/star.mesh";
100 bool visualization =
true;
101 bool verification =
false;
104 args.
AddOption(&mesh_file,
"-m",
"--mesh",
105 "Mesh file to use.");
107 "Finite element order (polynomial degree) or -1 for"
108 " isoparametric space.");
109 args.
AddOption(&num_refs,
"-r",
"--refs",
110 "Number of uniform refinements");
111 args.
AddOption(&alpha,
"-alpha",
"--alpha",
112 "Fractional exponent");
113 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
114 "--no-visualization",
115 "Enable or disable GLVis visualization.");
116 args.
AddOption(&verification,
"-ver",
"--verification",
"-no-ver",
118 "Use sinusoidal function (f) for analytic comparison.");
131 int progress_steps = 1;
135 const int power_of_laplace = floor(alpha);
136 double exponent_to_approximate = alpha - power_of_laplace;
137 bool integer_order =
false;
139 if (abs(exponent_to_approximate) > 1e-12)
143 mfem::out <<
"Approximating the fractional exponent "
144 << exponent_to_approximate
152 alpha = exponent_to_approximate + power_of_laplace;
156 integer_order =
true;
159 mfem::out <<
"Treating integer order PDE." << endl;
164 Mesh mesh(mesh_file, 1, 1);
168 for (
int i = 0; i < num_refs; i++)
172 ParMesh pmesh(MPI_COMM_WORLD, mesh);
180 cout <<
"Number of finite element unknowns: "
197 for (
int i=0; i<x.Size(); i++)
199 val *= sin(M_PI*x(i));
201 return pow(x.Size()*pow(M_PI,2),
alpha) * val;
237 if (power_of_laplace > 0)
267 mfem::out <<
"\nComputing (-Δ) ^ -" << power_of_laplace
268 <<
" ( f ) " << endl;
270 for (
int i = 0; i < power_of_laplace; i++)
275 if (i == power_of_laplace - 1)
279 if (integer_order && verification)
288 fout.
open(vishost, visport);
290 oss_f.str(
""); oss_f.clear();
291 oss_f <<
"Step " << progress_steps++ <<
": Solution of PDE -Δ ^ "
294 fout <<
"parallel " << num_procs <<
" " << myid <<
"\n"
295 <<
"solution\n" << pmesh << g
296 <<
"window_title '" << oss_f.str() <<
"'" << flush;
319 ostringstream oss_x, oss_u;
322 xout.
open(vishost, visport);
324 uout.
open(vishost, visport);
329 for (
int i = 0; i < coeffs.
Size(); i++)
333 mfem::out <<
"\nSolving PDE -Δ u + " << -poles[i]
334 <<
" u = " << coeffs[i] <<
" g " << endl;
374 oss_x.str(
""); oss_x.clear();
375 oss_x <<
"Step " << progress_steps
376 <<
": Solution of PDE -Δ u + " << -poles[i]
377 <<
" u = " << coeffs[i] <<
" g";
378 xout <<
"parallel " << num_procs <<
" " << myid <<
"\n"
379 <<
"solution\n" << pmesh << x
380 <<
"window_title '" << oss_x.str() <<
"'" << flush;
382 oss_u.str(
""); oss_u.clear();
383 oss_u <<
"Step " << progress_steps + 1
384 <<
": Solution of fractional PDE (-Δ)^" << alpha
386 uout <<
"parallel " << num_procs <<
" " << myid <<
"\n"
387 <<
"solution\n" << pmesh << u
388 <<
"window_title '" << oss_u.str() <<
"'"
399 auto solution = [] (
const Vector &x)
402 for (
int i=0; i<x.
Size(); i++)
404 val *= sin(M_PI*x(i));
417 analytic_solution =
"sin(π x)";
418 expected_mesh =
"inline_segment.mesh";
421 analytic_solution =
"sin(π x) sin(π y)";
422 expected_mesh =
"inline_quad.mesh";
425 analytic_solution =
"sin(π x) sin(π y) sin(π z)";
426 expected_mesh =
"inline_hex.mesh";
431 <<
"\n\nSolution Verification in "<< dim <<
"D \n\n"
432 <<
"Analytic solution : " << analytic_solution <<
"\n"
433 <<
"Expected mesh : " << expected_mesh <<
"\n"
434 <<
"Your mesh : " << mesh_file <<
"\n"
435 <<
"L2 error : " << l2_error <<
"\n\n"
436 << string(80,
'=') << endl;
int Size() const
Return the logical size of the array.
Class for domain integration L(v) := (f, v)
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Conjugate gradient method.
A coefficient that is constant across space and time.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
Pointer to an Operator of a specified type.
int Size() const
Returns the size of the vector.
Abstract parallel finite element space.
virtual int GetTrueVSize() const
Return the number of local vector true dofs.
The BoomerAMG solver in hypre.
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 ...
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetPrintLevel(int print_level)
void SetMaxIter(int max_it)
virtual double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
double analytic_solution(const Vector &x)
void PrintUsage(std::ostream &out) const
Print the usage message.
void SetSubVectorComplement(const Array< int > &dofs, const double val)
Set all vector entries NOT in the dofs Array to the given val.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void SetRelTol(double rtol)
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...
void ComputePartialFractionApproximation(double &alpha, Array< double > &coeffs, Array< double > &poles, double lmax=1000., double tol=1e-10, int npoints=1000, int max_order=100)
virtual const SparseMatrix * GetRestrictionMatrix() const
Get the R matrix which restricts a local dof vector to true dof vector.
void MultTranspose(const Vector &x, Vector &y) const
Multiply a vector with the transposed matrix. y = At * x.
void PrintOptions(std::ostream &out) const
Print the options.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void Clear()
Clear the contents of the Mesh.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
A general function coefficient.
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0) const
Computes y = alpha * A * x + beta * y.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
double u(const Vector &xvec)
Class for parallel grid function.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Wrapper for hypre's ParCSR matrix class.
Class for parallel meshes.
double f(const Vector &p)
bool Good() const
Return true if the command line options were parsed successfully.