81int main(
int argc,
char *argv[])
92 const char *mesh_file =
"../data/star-hilbert.mesh";
95 real_t max_elem_error = 1.0e-4;
99 bool visualization =
true;
101 int which_estimator = 0;
104 args.
AddOption(&mesh_file,
"-m",
"--mesh",
105 "Mesh file to use.");
107 "Problem setup to use: 0 = spherical front, 1 = ball.");
109 "Number of solution features (fronts/balls).");
111 "Finite element order (polynomial degree).");
112 args.
AddOption(&max_elem_error,
"-e",
"--max-err",
113 "Maximum element error");
114 args.
AddOption(&hysteresis,
"-y",
"--hysteresis",
115 "Derefinement safety coefficient.");
116 args.
AddOption(&ref_levels,
"-r",
"--ref-levels",
117 "Number of initial uniform refinement levels.");
118 args.
AddOption(&nc_limit,
"-l",
"--nc-limit",
119 "Maximum level of hanging nodes.");
120 args.
AddOption(&t_final,
"-tf",
"--t-final",
121 "Final time; start time is 0.");
122 args.
AddOption(&which_estimator,
"-est",
"--estimator",
123 "Which estimator to use: "
124 "0 = L2ZZ, 1 = Kelly, 2 = ZZ. Defaults to L2ZZ.");
125 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
126 "--no-visualization",
127 "Enable or disable GLVis visualization.");
128 args.
AddOption(&visit,
"-visit",
"--visit-datafiles",
"-no-visit",
129 "--no-visit-datafiles",
130 "Save data files for VisIt (visit.llnl.gov) visualization.");
148 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
157 if (ref_levels > 0) { ref_levels--; }
161 for (
int l = 0; l < ref_levels; l++)
170 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
174 "Boundary attributes required in the mesh.");
194 a.AddDomainIntegrator(integ);
213 cout <<
"Unable to connect to GLVis server at "
214 <<
vishost <<
':' << visport << endl;
215 cout <<
"GLVis visualization disabled.\n";
217 visualization =
false;
234 switch (which_estimator)
252 std::cout <<
"Unknown estimator. Falling back to L2ZZ." << std::endl;
285 for (
real_t time = 0.0; time < t_final + 1e-10; time += 0.01)
289 cout <<
"\nTime " << time <<
"\n\nRefinement:" << endl;
302 for (
int ref_it = 1; ; ref_it++)
307 cout <<
"Iteration: " << ref_it <<
", number of unknowns: "
308 << global_dofs << flush;
337 a.RecoverFEMSolution(X,
b, x);
343 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
344 sout <<
"solution\n" << pmesh << x << flush;
357 refiner.
Apply(pmesh);
360 cout <<
", total error: " << estimator->GetTotalError() << endl;
378 if (derefiner.
Apply(pmesh))
382 cout <<
"\nDerefined elements." << endl;
435 real_t r = sqrt(x*x + y*y + z*z);
436 return exp(-0.5*pow((r - t)/
alpha, 2));
441 real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
442 real_t r = sqrt(x2 + y2 + z2);
444 return -
exp(-0.5*pow((r - t)/
alpha, 2)) / a4 *
445 (-2*t*(x2 + y2 + z2 - (
dim-1)*a2/2)/r + x2 + y2 + z2 + t2 -
dim*a2);
451 real_t r = sqrt(x*x + y*y + z*z);
452 return -atan(2*(r - t)/
alpha);
457 real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
458 real_t r = sqrt(x2 + y2 + z2);
460 real_t den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
461 return (
dim == 2) ? 2*
alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
462 : 4*
alpha*(a2 + t2 - 4*r*t)/r/den;
466template<
typename F0,
typename F1>
470 real_t x = pt(0), y = pt(1), z = 0.0;
471 if (
dim == 3) { z = pt(2); }
477 return f0(x, y, z, t,
dim);
486 sum += f0(x - x0, y - y0, z, t,
dim);
498 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.
A general function coefficient.
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_level)
void Mult(const HypreParVector &b, HypreParVector &x) const override
Solve Ax=b with hypre's PCG.
void SetPrintLevel(int print_lvl)
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void SetMaxIter(int max_iter)
Wrapper for hypre's ParCSR matrix class.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
The KellyErrorEstimator class provides a fast error indication strategy for smooth scalar parallel pr...
The L2ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure where t...
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.
bool Nonconforming() const
int Dimension() const
Dimension of the reference space used within the elements.
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1, int pyr_type=1)
Set the curvature of the mesh nodes using the given polynomial degree.
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)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
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.
Abstract parallel finite element space.
void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const override
void UpdatesFinished() override
Free ParGridFunction transformation matrix (if any), to save memory.
HYPRE_BigInt GlobalTrueVSize() const
void Update(bool want_transform=true) override
Class for parallel grid function.
void ProjectBdrCoefficient(Coefficient *coeff[], VectorCoefficient *vcoeff, const Array< int > &attr)
void Update() override
Transform by the Space UpdateMatrix (e.g., on Mesh change).
Class for parallel meshes.
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
De-refinement operator using an error threshold.
void Reset() override
Reset the associated estimator.
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).
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.
void Reset() override
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.
int Size() const
Returns the size of the vector.
Data collection with VisIt I/O routines.
void Save() override
Save the collection and a VisIt root file.
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'.
const int * ess_tdof_list
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)
void UpdateAndRebalance(ParMesh &pmesh, ParFiniteElementSpace &fespace, ParGridFunction &x, ParBilinearForm &a, ParLinearForm &b)
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)
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)
MFEM_HOST_DEVICE Complex exp(const Complex &q)