29using namespace navier;
33 int ser_ref_levels = 1;
36 real_t 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);
86int 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;
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);
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."
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
virtual void SetTime(real_t t)
Set the time for time dependent coefficients.
A general function coefficient.
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(),...
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void EnsureNodes()
Make sure that the mesh has valid nodes, i.e. its geometry is described by a vector finite element gr...
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void GetNodes(Vector &node_coord) const
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Array< int > attributes
A list of all unique element attributes used by the Mesh.
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
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.
void Setup(real_t dt)
Initialize forms, solvers and preconditioners.
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.
ParGridFunction * GetCurrentVelocity()
Return a pointer to the current velocity ParGridFunction.
void AddAccelTerm(VectorCoefficient *coeff, Array< int > &attr)
Add an acceleration term to the RHS of the equation.
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...
struct s_NavierContext ctx
void vel(const Vector &x, real_t t, Vector &u)
real_t p(const Vector &x, real_t t)
void accel(const Vector &x, real_t t, Vector &u)