40int main(
int argc,
char *argv[])
43 const char *mesh_file =
"../../data/square-nurbs.mesh";
47 bool static_cond =
false;
49 const char *device_config =
"cpu";
51 bool visualization = 1;
54 args.
AddOption(&mesh_file,
"-m",
"--mesh",
56 args.
AddOption(&ref_levels,
"-r",
"--refine",
57 "Number of times to refine the mesh uniformly, -1 for auto.");
59 "Finite element order (polynomial degree).");
60 args.
AddOption(&NURBS,
"-n",
"--nurbs",
"-nn",
"--no-nurbs",
62 args.
AddOption(&
freq,
"-f",
"--frequency",
"Set the frequency for the exact"
64 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
65 "--no-static-condensation",
"Enable static condensation.");
66 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
67 "--no-partial-assembly",
"Enable Partial Assembly.");
68 args.
AddOption(&device_config,
"-d",
"--device",
69 "Device configuration string, see Device::Configure().");
70 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
72 "Enable or disable GLVis visualization.");
73 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
85 Device device(device_config);
91 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
103 (int)floor(log(50000./mesh->
GetNE())/log(2.)/
dim);
105 for (
int l = 0; l < ref_levels; l++)
120 mfem::out<<
"Create NURBS fec and ext"<<std::endl;
126 mfem::out<<
"Create Normal fec"<<std::endl;
130 cout <<
"Number of finite element unknowns: "
144 cout <<
"Number of knowns in essential BCs: "
145 << ess_tdof_list.
Size() << endl;
171 if (pa) {
a->SetAssemblyLevel(AssemblyLevel::PARTIAL); }
179 if (static_cond) {
a->EnableStaticCondensation(); }
184 a->FormLinearSystem(ess_tdof_list, x, *
b, A, X, B);
186 cout <<
"Size of linear system: " << A->
Height() << endl;
192 PCG(*A, M, B, X, 1, 1000, 1e-12, 0.0);
196#ifndef MFEM_USE_SUITESPARSE
200 PCG(*A, M, B, X, 1, 500, 1e-12, 0.0);
205 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
207 umf_solver.
Mult(B, X);
212 a->RecoverFEMSolution(X, *
b, x);
215 cout <<
"\n|| E_h - E ||_{L^2} = " << x.
ComputeL2Error(E) <<
'\n' << endl;
220 ofstream mesh_ofs(
"refined.mesh");
221 mesh_ofs.precision(8);
222 mesh->
Print(mesh_ofs);
223 ofstream sol_ofs(
"sol.gf");
224 sol_ofs.precision(8);
233 sol_sock.precision(8);
234 sol_sock <<
"solution\n" << *mesh << x << flush;
259 E(0) = sin(
kappa * x(1));
260 E(1) = sin(
kappa * x(2));
261 E(2) = sin(
kappa * x(0));
265 E(0) = sin(
kappa * x(1));
266 E(1) = sin(
kappa * x(0));
267 if (x.
Size() == 3) { E(2) = 0.0; }
283 if (x.
Size() == 3) {
f(2) = 0.0; }
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.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
A coefficient that is constant across space and time.
Integrator for for Nedelec elements.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
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...
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
Data type for Gauss-Seidel smoother of sparse matrix.
Class for grid function - Vector with associated FE space.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
virtual real_t ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
Returns ||exsol - u_h||_L2 for scalar or vector H1 or L2 elements.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
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 SpaceDimension() const
Dimension of the physical space containing the mesh.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Arbitrary order H(curl)-conforming Nedelec finite elements.
NURBSExtension generally contains multiple NURBSPatch objects spanning an entire Mesh....
Arbitrary order H(curl) NURBS finite elements.
Pointer to an Operator of a specified type.
Jacobi smoothing for a given bilinear form (no matrix necessary).
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
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.
Direct sparse solver using UMFPACK.
real_t Control[UMFPACK_CONTROL]
void SetOperator(const Operator &op) override
Factorize the given Operator op which must be a SparseMatrix.
void Mult(const Vector &b, Vector &x) const override
Direct solution of the linear system using UMFPACK.
for VectorFiniteElements (Nedelec, Raviart-Thomas)
A general vector function coefficient.
int Size() const
Returns the size of the vector.
Data collection with VisIt I/O routines.
void Save() override
Save the collection and a VisIt root file.
void RegisterField(const std::string &field_name, GridFunction *gf) override
Add a grid function to the collection and update the root file.
real_t sigma(const Vector &x)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
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)
std::function< real_t(const Vector &)> f(real_t mass_coeff)
void E_exact(const Vector &, Vector &)
void f_exact(const Vector &, Vector &)