50using namespace navier;
54 int ser_ref_levels = 1;
56 real_t kinvis = 1.0 / 40.0;
57 real_t t_final = 10 * 0.001;
59 real_t reference_pressure = 0.0;
60 real_t reynolds = 1.0 / kinvis;
61 real_t lam = 0.5 * reynolds
62 - sqrt(0.25 * reynolds * reynolds + 4.0 * M_PI * M_PI);
65 bool visualization =
false;
66 bool checkres =
false;
74 u(0) = 1.0 - exp(
ctx.lam * xi) * cos(2.0 * M_PI * yi);
75 u(1) =
ctx.lam / (2.0 * M_PI) * exp(
ctx.lam * xi) * sin(2.0 * M_PI * yi);
82 return 0.5 * (1.0 - exp(2.0 *
ctx.lam * xi)) +
ctx.reference_pressure;
85int main(
int argc,
char *argv[])
94 "Number of times to refine the mesh uniformly in serial.");
98 "Order (degree) of the finite elements.");
99 args.
AddOption(&
ctx.dt,
"-dt",
"--time-step",
"Time step.");
100 args.
AddOption(&
ctx.t_final,
"-tf",
"--final-time",
"Final time.");
106 "Enable partial assembly.");
112 "Enable numerical integration rules.");
117 "--no-visualization",
118 "Enable or disable GLVis visualization.");
125 "Enable or disable checking of the result. Returns -1 on failure.");
147 for (
int i = 0; i <
ctx.ser_ref_levels; ++i)
154 std::cout <<
"Number of elements: " << mesh.
GetNE() << std::endl;
157 auto *pmesh =
new ParMesh(MPI_COMM_WORLD, mesh);
181 bool last_step =
false;
183 flowsolver.
Setup(dt);
197 for (
int step = 0; !last_step; ++step)
199 if (
t + dt >= t_final - dt / 2)
205 flowsolver.
Step(
t, dt, step,
true);
213 real_t error_est = cfl / (cfl_max + cfl_tol);
214 if (error_est >= 1.0)
220 <<
"Step reached maximum CFL, retrying with smaller step size..."
233 real_t eta = pow(1.0 / (fac_safety * error_est), 1.0 / (1.0 + 3.0));
236 dt = dt * std::min(fac_max, std::max(fac_min, eta));
257 printf(
"%5s %8s %8s %8s %11s %11s\n",
264 printf(
"%5.2d %8.2E %.2E %.2E %.5E %.5E err\n",
275 if (
ctx.visualization)
280 sol_sock.precision(8);
283 sol_sock <<
"solution\n" << *pmesh << *u_ic << std::flush;
293 if (err_u > tol_u || err_p > tol_p)
297 mfem::out <<
"Result has a larger error than expected."
virtual void SetTime(real_t t)
Set the time for time dependent coefficients.
A general function coefficient.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Class for grid function - Vector with associated FE space.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
void EnsureNodes()
Make sure that the mesh has valid nodes, i.e. its geometry is described by a vector finite element gr...
void Clear()
Clear the contents of the Mesh.
int GetNE() const
Returns number of elements.
void GetNodes(Vector &node_coord) const
static Mesh MakeCartesian2D(int nx, int ny, Element::Type type, bool generate_edges=false, real_t sx=1.0, real_t sy=1.0, bool sfc_ordering=true)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny quadrilaterals if type = QUADRILATER...
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
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.
Class for parallel grid function.
real_t ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const override
ParFiniteElementSpace * ParFESpace() const
void ProjectCoefficient(Coefficient &coeff) override
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Class for parallel meshes.
virtual void SetTime(real_t t)
Set the time for time dependent coefficients.
A general vector function coefficient.
Transient incompressible Navier Stokes solver in a split scheme formulation.
ParGridFunction * GetProvisionalVelocity()
Return a pointer to the provisional velocity ParGridFunction.
void Setup(real_t dt)
Initialize forms, solvers and preconditioners.
real_t ComputeCFL(ParGridFunction &u, real_t dt)
Compute CFL.
void AddVelDirichletBC(VectorCoefficient *coeff, Array< int > &attr)
Add a Dirichlet boundary condition to the velocity field.
ParGridFunction * GetCurrentPressure()
Return a pointer to the current pressure ParGridFunction.
void PrintTimingData()
Print timing summary of the solving routine.
void EnablePA(bool pa)
Enable partial assembly for every operator.
void MeanZero(ParGridFunction &v)
Remove the mean from a ParGridFunction.
ParGridFunction * GetCurrentVelocity()
Return a pointer to the current velocity ParGridFunction.
void UpdateTimestepHistory(real_t dt)
Rotate entries in the time step and solution history arrays.
void Step(real_t &time, real_t dt, int cur_step, bool provisional=false)
Compute solution at the next time step t+dt.
real_t u(const Vector &xvec)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
real_t pres_kovasznay(const Vector &x, real_t t)
struct s_NavierContext ctx
void vel_kovasznay(const Vector &x, real_t t, Vector &u)