46 using namespace navier;
48 struct s_NavierContext
50 int ser_ref_levels = 1;
52 double kinvis = 1.0 / 40.0;
53 double t_final = 10 * 0.001;
55 double reference_pressure = 0.0;
56 double reynolds = 1.0 / kinvis;
57 double lam = 0.5 * reynolds
58 - sqrt(0.25 * reynolds * reynolds + 4.0 * M_PI * M_PI);
61 bool visualization =
false;
62 bool checkres =
false;
70 u(0) = 1.0 - exp(
ctx.lam * xi) * cos(2.0 * M_PI * yi);
71 u(1) =
ctx.lam / (2.0 * M_PI) * exp(
ctx.lam * xi) * sin(2.0 * M_PI * yi);
78 return 0.5 * (1.0 - exp(2.0 *
ctx.lam * xi)) +
ctx.reference_pressure;
81 int main(
int argc,
char *argv[])
90 "Number of times to refine the mesh uniformly in serial.");
94 "Order (degree) of the finite elements.");
95 args.
AddOption(&
ctx.dt,
"-dt",
"--time-step",
"Time step.");
96 args.
AddOption(&
ctx.t_final,
"-tf",
"--final-time",
"Final time.");
102 "Enable partial assembly.");
108 "Enable numerical integration rules.");
113 "--no-visualization",
114 "Enable or disable GLVis visualization.");
121 "Enable or disable checking of the result. Returns -1 on failure.");
143 for (
int i = 0; i <
ctx.ser_ref_levels; ++i)
150 std::cout <<
"Number of elements: " << mesh.
GetNE() << std::endl;
153 auto *pmesh =
new ParMesh(MPI_COMM_WORLD, mesh);
176 double t_final =
ctx.t_final;
177 bool last_step =
false;
179 flowsolver.
Setup(dt);
189 for (
int step = 0; !last_step; ++step)
191 if (t + dt >= t_final - dt / 2)
196 flowsolver.
Step(t, dt, step);
202 u_excoeff.SetTime(t);
206 p_ex_gf.ProjectCoefficient(p_excoeff);
212 double cfl = flowsolver.
ComputeCFL(*u_gf, dt);
216 printf(
"%5s %8s %8s %8s %11s %11s\n",
223 printf(
"%5.2d %8.2E %.2E %.2E %.5E %.5E err\n",
234 if (
ctx.visualization)
239 sol_sock.precision(8);
242 sol_sock <<
"solution\n" << *pmesh << *u_ic << std::flush;
252 if (err_u > tol_u || err_p > tol_p)
256 mfem::out <<
"Result has a larger error than expected."
void PrintTimingData()
Print timing summary of the solving routine.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(), hypre will be finalized automatically at program exit.
Class for grid function - Vector with associated FE space.
void vel_kovasznay(const Vector &x, double t, Vector &u)
double pres_kovasznay(const Vector &x, double t)
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
int GetNE() const
Returns number of elements.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
static int WorldSize()
Return the size of MPI_COMM_WORLD.
virtual void SetTime(double t)
Set the time for time dependent coefficients.
void Setup(double dt)
Initialize forms, solvers and preconditioners.
void MeanZero(ParGridFunction &v)
Remove the mean from a ParGridFunction.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
double ComputeCFL(ParGridFunction &u, double dt)
Compute CFL.
struct s_NavierContext ctx
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
ParGridFunction * GetCurrentPressure()
Return a pointer to the current pressure ParGridFunction.
virtual double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
void EnablePA(bool pa)
Enable partial assembly for every operator.
void AddVelDirichletBC(VectorCoefficient *coeff, Array< int > &attr)
Add a Dirichlet boundary condition to the velocity field.
static void Init()
Singleton creation with Mpi::Init();.
void PrintUsage(std::ostream &out) const
Print the usage message.
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
A general vector function coefficient.
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...
static Mesh MakeCartesian2D(int nx, int ny, Element::Type type, bool generate_edges=false, double sx=1.0, double sy=1.0, bool sfc_ordering=true)
ParGridFunction * GetCurrentVelocity()
Return a pointer to the current velocity ParGridFunction.
void PrintOptions(std::ostream &out) const
Print the options.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
void Clear()
Clear the contents of the Mesh.
A general function coefficient.
void GetNodes(Vector &node_coord) const
void Step(double &time, double dt, int cur_step, bool provisional=false)
Compute solution at the next time step t+dt.
double u(const Vector &xvec)
Class for parallel grid function.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Class for parallel meshes.
Transient incompressible Navier Stokes solver in a split scheme formulation.
ParFiniteElementSpace * ParFESpace() const
bool Good() const
Return true if the command line options were parsed successfully.