30 Array<int> const& ess_tdof_list,
const bool pa,
33int 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)
155#ifdef MFEM_USE_SINGLE
156 MFEM_ABORT(
"Reduced integration is not supported in single precision.");
161 else if (patchAssembly)
169 if (ir_order == -1) { ir_order = 2*fec->
GetOrder(); }
170 cout <<
"Using ir_order " << ir_order << endl;
179 std::vector<const IntegrationRule*> ir1D(
dim);
184 for (
int i=0; i<
dim; ++i)
197 cout <<
"Assembling system patch-wise and solving" << endl;
204 ofstream mesh_ofs(
"refined.mesh");
205 mesh_ofs.precision(8);
206 mesh.
Print(mesh_ofs);
207 ofstream sol_ofs(
"sol.gf");
208 sol_ofs.precision(8);
217 sol_sock.precision(8);
218 sol_sock <<
"solution\n" << mesh << x << flush;
223 if (compareToElementWise)
228 cout <<
"Assembling system element-wise and solving" << endl;
239 cout <<
"Element-wise solution norm " << solNorm << endl;
240 cout <<
"Relative error of patch-wise solution "
241 << x_ew.
Norml2() / solNorm << endl;
255 Array<int> const& ess_tdof_list,
const bool pa,
260 if (pa) {
a.SetAssemblyLevel(AssemblyLevel::PARTIAL); }
262 a.AddDomainIntegrator(bfi);
281 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B);
287 cout <<
"Timing for Assemble: " << timeAssemble <<
" seconds" << endl;
288 cout <<
"Timing for FormLinearSystem: " << timeFormLinearSystem <<
" seconds"
290 cout <<
"Timing for entire setup: " << timeAssemble + timeFormLinearSystem
291 <<
" seconds" << endl;
299#ifndef MFEM_USE_SUITESPARSE
302 PCG(*A, M, B, X, 1, 200, 1e-20, 0.0);
306 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
308 umf_solver.
Mult(B, X);
318 PCG(*A, M, B, X, 1, 400, 1e-12, 0.0);
323 PCG(*A, M, B, X, 1, 400, 1e-12, 0.0);
328 CG(*A, B, X, 1, 400, 1e-20, 0.0);
333 cout <<
"Timing for solve " << sw.
RealTime() << endl;
336 a.RecoverFEMSolution(X,
b, x);
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.
A coefficient that is constant across space and time.
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.
Class for domain integration .
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
virtual const char * Name() const
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.
void GetTrueDofs(Vector &tv) const
Extract the true-dofs from the GridFunction.
Class for an integration rule - an Array of IntegrationPoint.
IntegrationRule * ApplyToKnotIntervals(KnotVector const &kv) const
Return an integration rule for KnotVector kv, defined by applying this rule on each knot interval.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
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 Dimension() const
Dimension of the reference space used within the elements.
void GetNodes(Vector &node_coord) const
void DegreeElevate(int rel_degree, int degree=16)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void GetPatchKnotVectors(int p, Array< KnotVector * > &kv)
Class for defining different integration rules on each NURBS patch.
void Finalize(Mesh const &mesh)
Finalize() must be called before this class can be used for assembly. In particular,...
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....
Pointer to an Operator of a specified type.
Jacobi smoothing for a given bilinear form (no matrix necessary).
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.
double RealTime()
Return the number of real seconds elapsed since the stopwatch was started.
void Start()
Start the stopwatch. The elapsed time is not cleared.
void Stop()
Stop the stopwatch.
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.
Direct sparse solver using UMFPACK.
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.
real_t Control[UMFPACK_CONTROL]
virtual void Mult(const Vector &b, Vector &x) const
Direct solution of the linear system using UMFPACK.
real_t Norml2() const
Returns the l2 norm of the vector.
Wrapper for AlgebraicMultigrid object.
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)
void CG(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Conjugate gradient method. (tolerances are squared)
bool UsesTensorBasis(const FiniteElementSpace &fes)
Return true if the mesh contains only one topology and the elements are tensor elements.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
real_t p(const Vector &x, real_t t)
void AssembleAndSolve(LinearForm &b, BilinearFormIntegrator *bfi, Array< int > const &ess_tdof_list, const bool pa, const bool algebraic_ceed, GridFunction &x)