70 int main(
int argc,
char *argv[])
75 const char *mesh_file =
"../data/star-hilbert.mesh";
78 double max_elem_error = 5.0e-3;
79 double hysteresis = 0.15;
82 bool visualization =
true;
86 args.
AddOption(&mesh_file,
"-m",
"--mesh",
89 "Problem setup to use: 0 = spherical front, 1 = ball.");
91 "Number of solution features (fronts/balls).");
93 "Finite element order (polynomial degree).");
94 args.
AddOption(&max_elem_error,
"-e",
"--max-err",
95 "Maximum element error");
96 args.
AddOption(&hysteresis,
"-y",
"--hysteresis",
97 "Derefinement safety coefficient.");
98 args.
AddOption(&ref_levels,
"-r",
"--ref-levels",
99 "Number of initial uniform refinement levels.");
100 args.
AddOption(&nc_limit,
"-l",
"--nc-limit",
101 "Maximum level of hanging nodes.");
102 args.
AddOption(&t_final,
"-tf",
"--t-final",
103 "Final time; start time is 0.");
104 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
105 "--no-visualization",
106 "Enable or disable GLVis visualization.");
107 args.
AddOption(&visit,
"-visit",
"--visit-datafiles",
"-no-visit",
108 "--no-visit-datafiles",
109 "Save data files for VisIt (visit.llnl.gov) visualization.");
121 Mesh mesh(mesh_file, 1, 1);
130 if (ref_levels > 0) { ref_levels--; }
134 for (
int l = 0; l < ref_levels; l++)
141 "Boundary attributes required in the mesh.");
169 char vishost[] =
"localhost";
175 sout.
open(vishost, visport);
178 cout <<
"Unable to connect to GLVis server at "
179 << vishost <<
':' << visport << endl;
180 cout <<
"GLVis visualization disabled.\n";
181 visualization =
false;
220 for (
double time = 0.0; time < t_final + 1e-10; time += 0.01)
222 cout <<
"\nTime " << time <<
"\n\nRefinement:" << endl;
234 for (
int ref_it = 1; ; ref_it++)
236 cout <<
"Iteration: " << ref_it <<
", number of unknowns: "
255 #ifndef MFEM_USE_SUITESPARSE
257 PCG(A, M, B, X, 0, 500, 1e-12, 0.0);
260 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
262 umf_solver.
Mult(B, X);
273 sout <<
"solution\n" << mesh << x << flush;
300 if (derefiner.
Apply(mesh))
302 cout <<
"\nDerefined elements." << endl;
340 double front(
double x,
double y,
double z,
double t,
int)
342 double r = sqrt(x*x + y*y + z*z);
343 return exp(-0.5*pow((r - t)/
alpha, 2));
348 double x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
349 double r = sqrt(x2 + y2 + z2);
351 return -exp(-0.5*pow((r - t)/alpha, 2)) / a4 *
352 (-2*t*(x2 + y2 + z2 - (dim-1)*a2/2)/r + x2 + y2 + z2 + t2 - dim*a2);
356 double ball(
double x,
double y,
double z,
double t,
int)
358 double r = sqrt(x*x + y*y + z*z);
359 return -atan(2*(r - t)/
alpha);
364 double x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
365 double r = sqrt(x2 + y2 + z2);
367 double den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
368 return (dim == 2) ? 2*alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
369 : 4*alpha*(a2 + t2 - 4*r*t)/r/den;
373 template<
typename F0,
typename F1>
377 double x = pt(0), y = pt(1), z = 0.0;
378 if (dim == 3) { z = pt(2); }
384 return f0(x, y, z, t, dim);
391 double x0 = 0.5*cos(2*M_PI * i / nfeatures);
392 double y0 = 0.5*sin(2*M_PI * i / nfeatures);
393 sum += f0(x - x0, y - y0, z, t, dim);
403 double x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
404 double y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
405 sum += f1(x - x0, y - y0, z, 0.25, dim);
double front_laplace(double x, double y, double z, double t, int dim)
int Size() const
Logical size of the array.
Class for domain integration L(v) := (f, v)
double bdr_func(const Vector &pt, double t)
Class for grid function - Vector with associated FE space.
virtual void Update(bool want_transform=true)
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
Subclass constant coefficient.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list)
void SetNCLimit(int nc_limit)
Set the maximum ratio of refinement levels of adjacent elements (0 = unlimited).
int Size() const
Returns the size of the vector.
virtual void Save()
Save the collection and a VisIt root file.
bool Stop() const
Check if STOP action is requested, e.g. stopping criterion is satisfied.
int main(int argc, char *argv[])
double rhs_func(const Vector &pt, double t)
void UpdateProblem(Mesh &mesh, FiniteElementSpace &fespace, GridFunction &x, BilinearForm &a, LinearForm &b)
Data type for Gauss-Seidel smoother of sparse matrix.
Direct sparse solver using UMFPACK.
bool Apply(Mesh &mesh)
Perform the mesh operation.
virtual void Reset()
Reset the associated estimator.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
virtual void Reset()
Reset the associated estimator.
Mesh refinement operator using an error threshold.
Data collection with VisIt I/O routines.
void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
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 PrintUsage(std::ostream &out) const
void SetTime(double t)
Set physical time (for time-dependent simulations)
void SetNCLimit(int nc_limit)
Set the maximum ratio of refinement levels of adjacent elements (0 = unlimited).
int SpaceDimension() const
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
double ball_laplace(double x, double y, double z, double t, int dim)
double Control[UMFPACK_CONTROL]
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)
void PreferConformingRefinement()
Use conforming refinement, if possible (triangles, tetrahedra) – this is the default.
void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection and update the root file.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
void PrintOptions(std::ostream &out) const
void EnsureNCMesh(bool triangles_nonconforming=false)
double ball(double x, double y, double z, double t, int)
int open(const char hostname[], int port)
void SetThreshold(double thresh)
Set the de-refinement threshold. The default value is zero.
The ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure...
void SetLocalErrorGoal(double err_goal)
Set the local stopping criterion: stop when local_err_i <= local_err_goal. The default value is zero...
class for C-function coefficient
virtual void UpdatesFinished()
Free GridFunction transformation matrix (if any), to save memory.
Arbitrary order H1-conforming (continuous) finite elements.
void SetTotalErrorFraction(double fraction)
Set the total fraction used in the computation of the threshold. The default value is 1/2...
double front(double x, double y, double z, double t, int)
double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
void ProjectBdrCoefficient(Coefficient &coeff, Array< int > &attr)
De-refinement operator using an error threshold.
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.