29 using namespace navier;
31 struct s_NavierContext
33 int ser_ref_levels = 1;
36 double t_final = 10 * 0.25e-4;
40 bool visualization =
false;
41 bool checkres =
false;
49 u(0) = M_PI * sin(t) * pow(sin(M_PI * xi), 2.0) * sin(2.0 * M_PI * yi);
50 u(1) = -(M_PI * sin(t) * sin(2.0 * M_PI * xi) * pow(sin(M_PI * yi), 2.0));
58 return cos(M_PI * xi) * sin(t) * sin(M_PI * yi);
66 u(0) = M_PI * sin(t) * sin(M_PI * xi) * sin(M_PI * yi)
68 + 2.0 * pow(M_PI, 2.0) * sin(t) * sin(M_PI * xi)
69 * sin(2.0 * M_PI * xi) * sin(M_PI * yi))
71 * (2.0 *
ctx.kinvis * pow(M_PI, 2.0)
72 * (1.0 - 2.0 * cos(2.0 * M_PI * xi)) * sin(t)
73 + cos(t) * pow(sin(M_PI * xi), 2.0))
74 * sin(2.0 * M_PI * yi);
76 u(1) = M_PI * cos(M_PI * yi) * sin(t)
78 + 2.0 *
ctx.kinvis * pow(M_PI, 2.0) * cos(M_PI * yi)
79 * sin(2.0 * M_PI * xi))
80 - M_PI * (cos(t) + 6.0 *
ctx.kinvis * pow(M_PI, 2.0) * sin(t))
81 * sin(2.0 * M_PI * xi) * pow(sin(M_PI * yi), 2.0)
82 + 4.0 * pow(M_PI, 3.0) * cos(M_PI * yi) * pow(sin(t), 2.0)
83 * pow(sin(M_PI * xi), 2.0) * pow(sin(M_PI * yi), 3.0);
86 int main(
int argc,
char *argv[])
95 "Number of times to refine the mesh uniformly in serial.");
99 "Order (degree) of the finite elements.");
100 args.
AddOption(&
ctx.dt,
"-dt",
"--time-step",
"Time step.");
101 args.
AddOption(&
ctx.t_final,
"-tf",
"--final-time",
"Final time.");
107 "Enable partial assembly.");
113 "Enable numerical integration rules.");
118 "--no-visualization",
119 "Enable or disable GLVis visualization.");
126 "Enable or disable checking of the result. Returns -1 on failure.");
141 Mesh *mesh =
new Mesh(
"../../data/inline-quad.mesh");
147 for (
int i = 0; i <
ctx.ser_ref_levels; ++i)
154 std::cout <<
"Number of elements: " << mesh->
GetNE() << std::endl;
184 double t_final =
ctx.t_final;
185 bool last_step =
false;
187 naviersolver.
Setup(dt);
196 for (
int step = 0; !last_step; ++step)
198 if (t + dt >= t_final - dt / 2)
203 naviersolver.
Step(t, dt, step);
206 u_excoeff.SetTime(t);
213 printf(
"%11s %11s %11s %11s\n",
"Time",
"dt",
"err_u",
"err_p");
214 printf(
"%.5E %.5E %.5E %.5E err\n", t, dt, err_u, err_p);
219 if (
ctx.visualization)
226 sol_sock <<
"solution\n" << *pmesh << *u_ic << std::flush;
235 if (err_u > tol || err_p > tol)
239 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.
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 Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
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
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
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.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
double p(const Vector &x, double t)
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...
ParGridFunction * GetCurrentVelocity()
Return a pointer to the current velocity ParGridFunction.
void vel(const Vector &x, double t, Vector &u)
void PrintOptions(std::ostream &out) const
Print the options.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
void accel(const Vector &x, double t, Vector &u)
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.
Array< int > attributes
A list of all unique element attributes used by the Mesh.
void AddAccelTerm(VectorCoefficient *coeff, Array< int > &attr)
Add an acceleration term to the RHS of the equation.
bool Good() const
Return true if the command line options were parsed successfully.