30 Array<int> const& ess_tdof_list,
const bool pa,
33 int main(
int argc,
char *argv[])
36 const char *mesh_file =
"../../data/beam-hex-nurbs.mesh";
39 const char *device_config =
"cpu";
40 bool visualization =
true;
41 bool algebraic_ceed =
false;
42 bool patchAssembly =
false;
43 bool reducedIntegration =
true;
44 bool compareToElementWise =
true;
45 int nurbs_degree_increase = 0;
50 args.
AddOption(&mesh_file,
"-m",
"--mesh",
52 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
53 "--no-partial-assembly",
"Enable Partial Assembly.");
54 args.
AddOption(&device_config,
"-d",
"--device",
55 "Device configuration string, see Device::Configure().");
57 args.
AddOption(&algebraic_ceed,
"-a",
"--algebraic",
"-no-a",
"--no-algebraic",
58 "Use algebraic Ceed solver");
60 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
62 "Enable or disable GLVis visualization.");
63 args.
AddOption(&patchAssembly,
"-patcha",
"--patch-assembly",
"-no-patcha",
64 "--no-patch-assembly",
"Enable patch-wise assembly.");
65 args.
AddOption(&reducedIntegration,
"-rint",
"--reduced-integration",
"-fint",
66 "--full-integration",
"Enable reduced integration rules.");
67 args.
AddOption(&ref_levels,
"-ref",
"--refine",
68 "Number of uniform mesh refinements.");
69 args.
AddOption(&ir_order,
"-iro",
"--integration-order",
70 "Order of integration rule.");
71 args.
AddOption(&nurbs_degree_increase,
"-incdeg",
"--nurbs-degree-increase",
72 "Elevate NURBS mesh degree by this amount.");
73 args.
AddOption(&compareToElementWise,
"-cew",
"--compare-element",
74 "-no-compare",
"-no-compare-element",
75 "Compute element-wise solution for comparison");
84 MFEM_VERIFY(!(pa && !patchAssembly),
"Patch assembly must be used with -pa");
88 Device device(device_config);
94 Mesh mesh(mesh_file, 1, 1);
97 if (nurbs_degree_increase > 0) { mesh.
DegreeElevate(nurbs_degree_increase); }
100 for (
int l = 0; l < ref_levels; l++)
112 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
116 MFEM_ABORT(
"Mesh must have nodes");
119 cout <<
"Number of finite element unknowns: " 153 if (patchAssembly && reducedIntegration && !pa)
157 else if (patchAssembly)
165 if (ir_order == -1) { ir_order = 2*fec->
GetOrder(); }
166 cout <<
"Using ir_order " << ir_order << endl;
175 std::vector<const IntegrationRule*> ir1D(
dim);
180 for (
int i=0; i<
dim; ++i)
193 cout <<
"Assembling system patch-wise and solving" << endl;
200 ofstream mesh_ofs(
"refined.mesh");
201 mesh_ofs.precision(8);
202 mesh.
Print(mesh_ofs);
203 ofstream sol_ofs(
"sol.gf");
204 sol_ofs.precision(8);
213 sol_sock.precision(8);
214 sol_sock <<
"solution\n" << mesh << x << flush;
219 if (compareToElementWise)
224 cout <<
"Assembling system element-wise and solving" << endl;
232 const double solNorm = x_ew.
Norml2();
235 cout <<
"Element-wise solution norm " << solNorm << endl;
236 cout <<
"Relative error of patch-wise solution " 237 << x_ew.
Norml2() / solNorm << endl;
251 Array<int> const& ess_tdof_list,
const bool pa,
256 if (pa) {
a.SetAssemblyLevel(AssemblyLevel::PARTIAL); }
258 a.AddDomainIntegrator(bfi);
270 const double timeAssemble = sw.
RealTime();
277 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B);
281 const double timeFormLinearSystem = sw.
RealTime();
283 cout <<
"Timing for Assemble: " << timeAssemble <<
" seconds" << endl;
284 cout <<
"Timing for FormLinearSystem: " << timeFormLinearSystem <<
" seconds" 286 cout <<
"Timing for entire setup: " << timeAssemble + timeFormLinearSystem
287 <<
" seconds" << endl;
295 #ifndef MFEM_USE_SUITESPARSE 298 PCG(*A, M, B, X, 1, 200, 1e-20, 0.0);
302 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
304 umf_solver.
Mult(B, X);
314 PCG(*A, M, B, X, 1, 400, 1e-12, 0.0);
319 PCG(*A, M, B, X, 1, 400, 1e-12, 0.0);
324 CG(*A, B, X, 1, 400, 1e-20, 0.0);
329 cout <<
"Timing for solve " << sw.
RealTime() << endl;
332 a.RecoverFEMSolution(X,
b, x);
Class for domain integration L(v) := (f, v)
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
A coefficient that is constant across space and time.
void PrintOptions(std::ostream &out) const
Print the options.
int Dimension() const
Dimension of the reference space used within the elements.
void PrintUsage(std::ostream &out) const
Print the usage message.
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
Pointer to an Operator of a specified type.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
double RealTime()
Return the number of real seconds elapsed since the stopwatch was started.
bool Good() const
Return true if the command line options were parsed successfully.
void Finalize(Mesh const &mesh)
Finalize() must be called before this class can be used for assembly. In particular, it defines data used by GetPointElement().
bool UsesTensorBasis(const FiniteElementSpace &fes)
Return true if the mesh contains only one topology and the elements are tensor elements.
int main(int argc, char *argv[])
IntegrationRule * ApplyToKnotIntervals(KnotVector const &kv) const
Return an integration rule for KnotVector kv, defined by applying this rule on each knot interval...
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Data type for Gauss-Seidel smoother of sparse matrix.
void Stop()
Stop the stopwatch.
Direct sparse solver using UMFPACK.
void GetTrueDofs(Vector &tv) const
Extract the true-dofs from the GridFunction.
void SetPatchRules1D(const int patch, std::vector< const IntegrationRule *> &ir1D)
Set 1D integration rules to be used as a tensor product rule on the patch with index patch...
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
Jacobi smoothing for a given bilinear form (no matrix necessary).
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
virtual const char * Name() const
void CG(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Conjugate gradient method. (tolerances are squared)
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
void Start()
Start the stopwatch. The elapsed time is not cleared.
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
double p(const Vector &x, double t)
double Control[UMFPACK_CONTROL]
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
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 GetPatchKnotVectors(int p, Array< KnotVector *> &kv)
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
Wrapper for AlgebraicMultigrid object.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
void DegreeElevate(int rel_degree, int degree=16)
double Norml2() const
Returns the l2 norm of the vector.
int Size() const
Return the logical size of the array.
virtual void Print(std::ostream &os=mfem::out) const
void GetNodes(Vector &node_coord) const
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
void AssembleAndSolve(LinearForm &b, BilinearFormIntegrator *bfi, Array< int > const &ess_tdof_list, const bool pa, const bool algebraic_ceed, GridFunction &x)
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.
Class for defining different integration rules on each NURBS patch.
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.