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;
51 args.
AddOption(&mesh_file,
"-m",
"--mesh",
53 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
54 "--no-partial-assembly",
"Enable Partial Assembly.");
55 args.
AddOption(&device_config,
"-d",
"--device",
56 "Device configuration string, see Device::Configure().");
58 args.
AddOption(&algebraic_ceed,
"-a",
"--algebraic",
"-no-a",
"--no-algebraic",
59 "Use algebraic Ceed solver");
61 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
63 "Enable or disable GLVis visualization.");
64 args.
AddOption(&patchAssembly,
"-patcha",
"--patch-assembly",
"-no-patcha",
65 "--no-patch-assembly",
"Enable patch-wise assembly.");
66 args.
AddOption(&reducedIntegration,
"-rint",
"--reduced-integration",
"-fint",
67 "--full-integration",
"Enable reduced integration rules.");
68 args.
AddOption(&ref_levels,
"-ref",
"--refine",
69 "Number of uniform mesh refinements.");
70 args.
AddOption(&ir_order,
"-iro",
"--integration-order",
71 "Order of integration rule.");
72 args.
AddOption(&nurbs_degree_increase,
"-incdeg",
"--nurbs-degree-increase",
73 "Elevate NURBS mesh degree by this amount.");
74 args.
AddOption(&compareToElementWise,
"-cew",
"--compare-element",
75 "-no-compare",
"-no-compare-element",
76 "Compute element-wise solution for comparison");
77 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
86 MFEM_VERIFY(!(pa && !patchAssembly),
"Patch assembly must be used with -pa");
90 Device device(device_config);
96 Mesh mesh(mesh_file, 1, 1);
99 if (nurbs_degree_increase > 0) { mesh.
DegreeElevate(nurbs_degree_increase); }
102 for (
int l = 0; l < ref_levels; l++)
114 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
118 MFEM_ABORT(
"Mesh must have nodes");
121 cout <<
"Number of finite element unknowns: "
155 if (patchAssembly && reducedIntegration && !pa)
157#ifdef MFEM_USE_SINGLE
158 cout <<
"Reduced integration is not supported in single precision.\n";
159 return MFEM_SKIP_RETURN_VALUE;
164 else if (patchAssembly)
172 if (ir_order == -1) { ir_order = 2*fec->
GetOrder(); }
173 cout <<
"Using ir_order " << ir_order << endl;
182 std::vector<const IntegrationRule*> ir1D(
dim);
187 for (
int i=0; i<
dim; ++i)
200 cout <<
"Assembling system patch-wise and solving" << endl;
207 ofstream mesh_ofs(
"refined.mesh");
208 mesh_ofs.precision(8);
209 mesh.
Print(mesh_ofs);
210 ofstream sol_ofs(
"sol.gf");
211 sol_ofs.precision(8);
219 sol_sock.precision(8);
220 sol_sock <<
"solution\n" << mesh << x << flush;
225 if (compareToElementWise)
230 cout <<
"Assembling system element-wise and solving" << endl;
241 cout <<
"Element-wise solution norm " << solNorm << endl;
242 cout <<
"Relative error of patch-wise solution "
243 << x_ew.
Norml2() / solNorm << endl;
257 Array<int> const& ess_tdof_list,
const bool pa,
262 if (pa) {
a.SetAssemblyLevel(AssemblyLevel::PARTIAL); }
264 a.AddDomainIntegrator(bfi);
283 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B);
289 cout <<
"Timing for Assemble: " << timeAssemble <<
" seconds" << endl;
290 cout <<
"Timing for FormLinearSystem: " << timeFormLinearSystem <<
" seconds"
292 cout <<
"Timing for entire setup: " << timeAssemble + timeFormLinearSystem
293 <<
" seconds" << endl;
301#ifndef MFEM_USE_SUITESPARSE
304 PCG(*A, M, B, X, 1, 200, 1e-20, 0.0);
308 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
310 umf_solver.
Mult(B, X);
320 PCG(*A, M, B, X, 1, 400, 1e-12, 0.0);
325 PCG(*A, M, B, X, 1, 400, 1e-12, 0.0);
330 CG(*A, B, X, 1, 400, 1e-20, 0.0);
335 cout <<
"Timing for solve " << sw.
RealTime() << endl;
338 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.
void SetNURBSPatchIntRule(NURBSMeshRules *pr)
Sets an integration rule for use on NURBS patches.
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 *)
int GetNP() const
Return the number of patches.
void GetPatchKnotVectors(int p, Array< KnotVector * > &kv)
Return KnotVectors in kv in each dimension for patch p.
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.
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.
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)