75int main(
int argc,
char *argv[])
80 const char *mesh_file =
"../data/star-hilbert.mesh";
83 real_t max_elem_error = 5.0e-3;
87 bool visualization =
true;
89 int which_estimator = 0;
92 args.
AddOption(&mesh_file,
"-m",
"--mesh",
95 "Problem setup to use: 0 = spherical front, 1 = ball.");
97 "Number of solution features (fronts/balls).");
99 "Finite element order (polynomial degree).");
100 args.
AddOption(&max_elem_error,
"-e",
"--max-err",
101 "Maximum element error");
102 args.
AddOption(&hysteresis,
"-y",
"--hysteresis",
103 "Derefinement safety coefficient.");
104 args.
AddOption(&ref_levels,
"-r",
"--ref-levels",
105 "Number of initial uniform refinement levels.");
106 args.
AddOption(&nc_limit,
"-l",
"--nc-limit",
107 "Maximum level of hanging nodes.");
108 args.
AddOption(&t_final,
"-tf",
"--t-final",
109 "Final time; start time is 0.");
110 args.
AddOption(&which_estimator,
"-est",
"--estimator",
111 "Which estimator to use: "
112 "0 = ZZ, 1 = Kelly. Defaults to ZZ.");
113 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
114 "--no-visualization",
115 "Enable or disable GLVis visualization.");
116 args.
AddOption(&visit,
"-visit",
"--visit-datafiles",
"-no-visit",
117 "--no-visit-datafiles",
118 "Save data files for VisIt (visit.llnl.gov) visualization.");
130 Mesh mesh(mesh_file, 1, 1);
139 if (ref_levels > 0) { ref_levels--; }
143 for (
int l = 0; l < ref_levels; l++)
152 "Boundary attributes required in the mesh.");
172 a.AddDomainIntegrator(integ);
189 cout <<
"Unable to connect to GLVis server at "
191 cout <<
"GLVis visualization disabled.\n";
192 visualization =
false;
208 switch (which_estimator)
218 std::cout <<
"Unknown estimator. Falling back to ZZ." << std::endl;
250 for (
real_t time = 0.0; time < t_final + 1e-10; time += 0.01)
252 cout <<
"\nTime " << time <<
"\n\nRefinement:" << endl;
264 for (
int ref_it = 1; ; ref_it++)
266 cout <<
"Iteration: " << ref_it <<
", number of unknowns: "
283 a.FormLinearSystem(ess_tdof_list, x,
b, A, X, B);
285#ifndef MFEM_USE_SUITESPARSE
287 PCG(A, M, B, X, 0, 500, 1e-12, 0.0);
290 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
292 umf_solver.
Mult(B, X);
296 a.RecoverFEMSolution(X,
b, x);
303 sout <<
"solution\n" << mesh << x << flush;
330 if (derefiner.
Apply(mesh))
332 cout <<
"\nDerefined elements." << endl;
374 real_t r = sqrt(x*x + y*y + z*z);
375 return exp(-0.5*pow((r -
t)/
alpha, 2));
380 real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 =
t*
t;
381 real_t r = sqrt(x2 + y2 + z2);
383 return -exp(-0.5*pow((r -
t)/
alpha, 2)) / a4 *
384 (-2*
t*(x2 + y2 + z2 - (
dim-1)*a2/2)/r + x2 + y2 + z2 + t2 -
dim*a2);
390 real_t r = sqrt(x*x + y*y + z*z);
391 return -atan(2*(r -
t)/
alpha);
396 real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*
t*
t;
397 real_t r = sqrt(x2 + y2 + z2);
399 real_t den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*
t) - t2, 2.0);
400 return (
dim == 2) ? 2*
alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
401 : 4*
alpha*(a2 + t2 - 4*r*
t)/r/den;
405template<
typename F0,
typename F1>
409 real_t x = pt(0), y = pt(1), z = 0.0;
410 if (
dim == 3) { z = pt(2); }
416 return f0(x, y, z,
t,
dim);
425 sum += f0(x - x0, y - y0, z,
t,
dim);
437 sum += f1(x - x0, y - y0, z, 0.25,
dim);
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.
virtual void SetTime(real_t t)
Set the time for time dependent coefficients.
A coefficient that is constant across space and time.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
void SetTime(real_t t)
Set physical time (for time-dependent simulations)
Class for domain integration .
Base class for all element based error estimators.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
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 ...
virtual void UpdatesFinished()
Free the GridFunction update operator (if any), to save memory.
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
A general function coefficient.
Data type for Gauss-Seidel smoother of sparse matrix.
Class for grid function - Vector with associated FE space.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
void ProjectBdrCoefficient(Coefficient &coeff, const Array< int > &attr)
Project a Coefficient on the GridFunction, modifying only DOFs on the boundary associated with the bo...
Arbitrary order H1-conforming (continuous) finite elements.
The KellyErrorEstimator class provides a fast error indication strategy for smooth scalar parallel pr...
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Apply(Mesh &mesh)
Perform the mesh operation.
bool Stop() const
Check if STOP action is requested, e.g. stopping criterion is satisfied.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
int Dimension() const
Dimension of the reference space used within the elements.
int SpaceDimension() const
Dimension of the physical space containing the mesh.
virtual void Finalize(bool refine=false, bool fix_orientation=false)
Finalize the construction of a general Mesh.
void EnsureNCMesh(bool simplices_nonconforming=false)
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Set the curvature of the mesh nodes using the given polynomial degree.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
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.
De-refinement operator using an error threshold.
void SetThreshold(real_t thresh)
Set the de-refinement threshold. The default value is zero.
void SetNCLimit(int nc_limit_)
Set the maximum ratio of refinement levels of adjacent elements (0 = unlimited).
virtual void Reset()
Reset the associated estimator.
Mesh refinement operator using an error threshold.
void SetNCLimit(int nc_limit_)
Set the maximum ratio of refinement levels of adjacent elements (0 = unlimited).
void SetTotalErrorFraction(real_t fraction)
Set the total fraction used in the computation of the threshold. The default value is 1/2.
virtual void Reset()
Reset the associated estimator.
void PreferConformingRefinement()
Use conforming refinement, if possible (triangles, tetrahedra) – this is the default.
void SetLocalErrorGoal(real_t err_goal)
Set the local stopping criterion: stop when local_err_i <= local_err_goal. The default value is zero.
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.
int Size() const
Returns the size of the vector.
Data collection with VisIt I/O routines.
virtual void Save() override
Save the collection and a VisIt root file.
virtual void RegisterField(const std::string &field_name, GridFunction *gf) override
Add a grid function to the collection and update the root file.
The ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
real_t front_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
real_t ball(real_t x, real_t y, real_t z, real_t t, int)
real_t rhs_func(const Vector &pt, real_t t)
real_t front(real_t x, real_t y, real_t z, real_t t, int)
real_t composite_func(const Vector &pt, real_t t, F0 f0, F1 f1)
void UpdateProblem(Mesh &mesh, FiniteElementSpace &fespace, GridFunction &x, BilinearForm &a, LinearForm &b)
real_t bdr_func(const Vector &pt, real_t t)
real_t ball_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
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)