67using namespace navier;
76 real_t fluid_kin_vis = 0.001;
79 int ode_solver_type = 3;
111 real_t alpha, kappa, udir;
127 virtual ~ConductionOperator();
132 int x = 0,
int y = 0,
int w = 400,
int h = 400,
135int main(
int argc,
char *argv[])
144 Array <const char *> mesh_file_list(lim_meshes);
145 Array <int> np_list(lim_meshes),
146 rs_levels(lim_meshes);
149 bool visualization =
true;
152 args.
AddOption(&np_list[0],
"-np1",
"--np1",
153 "number of MPI ranks for mesh 1");
154 args.
AddOption(&np_list[1],
"-np2",
"--np2",
155 "number of MPI ranks for mesh 1");
156 args.
AddOption(&rs_levels[0],
"-r1",
"--refine-serial 1",
157 "Number of times to refine the mesh 1 uniformly in serial.");
158 args.
AddOption(&rs_levels[1],
"-r2",
"--refine-serial 2",
159 "Number of times to refine the mesh 2 uniformly in serial.");
160 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
161 "--no-visualization",
162 "Enable or disable GLVis visualization.");
175 const int nmeshes = 2;
176 mesh_file_list[0] =
"fluid-cht.mesh";
177 mesh_file_list[1] =
"solid-cht.mesh";
180 MPI_Comm *comml =
new MPI_Comm;
183 for (
int i = 0; i < nmeshes; i++)
186 if (myid < npsum) { color = i;
break; }
188 MPI_Comm_split(MPI_COMM_WORLD, color, myid, comml);
189 int myidlocal, numproclocal;
190 MPI_Comm_rank(*comml, &myidlocal);
191 MPI_Comm_size(*comml, &numproclocal);
193 Mesh *mesh =
new Mesh(mesh_file_list[color], 1, 1);
197 for (
int lev = 0; lev < rs_levels[color]; lev++)
203 if (color == 0 && myidlocal == 0)
205 std::cout <<
"Number of elements: " << mesh->
GetNE() << std::endl;
210 pmesh =
new ParMesh(*comml, *mesh);
220 ConductionOperator *coper = NULL;
226 bool last_step =
false;
248 flowsolver->
Setup(dt);
257 switch (
schwarz.ode_solver_type)
265 case 12: ode_solver =
new RK2Solver(0.5);
break;
267 case 14: ode_solver =
new RK4Solver;
break;
274 std::cout <<
"Unknown ODE solver type: " <<
schwarz.ode_solver_type <<
'\n';
297 finder.
Setup(*pmesh, color);
302 for (
int i = 0; i < color_array.
Size(); i++)
304 color_array[i] = (
unsigned int)color;
311 finder.
Interpolate(vxyz, color_array, *u_gf, interp_vals);
319 coper =
new ConductionOperator(*fes_s,
schwarz.alpha,
schwarz.kappa,
321 coper->SetParameters(adv_gf_c);
328 int Ww = 350,
Wh = 350;
329 int Wx = color*
Ww+10,
Wy = 0;
344 if (ode_solver) { ode_solver->
Init(*coper); }
346 for (
int step = 0; !last_step; ++step)
348 if (
t + dt >= t_final - dt / 2)
356 flowsolver->
Step(
t, dt, step);
361 ode_solver->
Step(t_tdof,
t, dt);
364 finder.
Interpolate(vxyz, color_array, *u_gf, interp_vals);
369 coper->SetParameters(adv_gf_c);
386 if (color == 0 && myidlocal == 0)
388 printf(
"%11s %11s %11s\n",
"Time",
"dt",
"CFL");
389 printf(
"%.5E %.5E %.5E\n",
t, dt,cfl);
399 if (color == 1) {
delete u_gf; }
415 T(NULL), current_dt(0.0),
416 M_solver(
f.GetComm()), T_solver(
f.GetComm()), udir(10), z(height)
418 const real_t rel_tol = 1e-8;
420 Array<int> ess_bdr(
f.GetParMesh()->bdr_attributes.Max());
427 f.GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
432 M->FormSystemMatrix(ess_tdof_list, Mmat);
434 M_solver.iterative_mode =
false;
435 M_solver.SetRelTol(rel_tol);
436 M_solver.SetAbsTol(0.0);
437 M_solver.SetMaxIter(100);
438 M_solver.SetPrintLevel(0);
440 M_solver.SetPreconditioner(M_prec);
441 M_solver.SetOperator(Mmat);
446 T_solver.iterative_mode =
false;
447 T_solver.SetRelTol(rel_tol);
448 T_solver.SetAbsTol(0.0);
449 T_solver.SetMaxIter(100);
450 T_solver.SetPrintLevel(0);
451 T_solver.SetPreconditioner(T_prec);
453 SetParameters(adv_gf_c);
456void ConductionOperator::Mult(
const Vector &
u,
Vector &du_dt)
const
466 M_solver.
Mult(z, du_dt);
471void ConductionOperator::ImplicitSolve(
const real_t dt,
479 T =
Add(1.0, Mmat, dt, Kmat);
483 MFEM_VERIFY(dt == current_dt,
"");
488 T_solver.
Mult(z, du_dt);
496 u_alpha_gf.ProjectCoefficient(kapfuncoef);
511ConductionOperator::~ConductionOperator()
520 int x,
int y,
int w,
int h,
bool vec)
524 MPI_Comm comm = pmesh.
GetComm();
527 MPI_Comm_size(comm, &num_procs);
528 MPI_Comm_rank(comm, &myid);
530 bool newly_opened =
false;
531 int connection_failed;
543 sock <<
"solution\n";
549 if (myid == 0 && newly_opened)
552 ?
"mAcRjlmm" :
"mmaaAcl";
554 sock <<
"window_title '" << title <<
"'\n"
555 <<
"window_geometry "
556 << x <<
" " << y <<
" " << w <<
" " << h <<
"\n"
558 if ( vec ) { sock <<
"vvv"; }
564 connection_failed = !sock && !newly_opened;
566 MPI_Bcast(&connection_failed, 1, MPI_INT, 0, comm);
568 while (connection_failed);
580 if (std::fabs(xi+2.5)<1.e-5) {
u(0) = 0.25*yi*(3-yi)/(1.5*1.5); }
587 return x(1) <= 1.0 && std::fabs(x(0)) < 0.5 ? 5.: 1.0;
596 t_init = 10*(std::exp(-x(1)*x(1)));
598 if (std::fabs(x(0)) >= 0.5)
600 real_t dx = std::fabs(x(0))-0.5;
601 t_init *= std::exp(-10*dx*dx);
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
Backward Euler ODE solver. L-stable.
Conjugate gradient method.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the Conjugate Gradient method.
Mesh * GetMesh() const
Returns the mesh.
The classical forward Euler method.
A general function coefficient.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
FiniteElementSpace * FESpace()
Arbitrary order H1-conforming (continuous) finite elements.
Wrapper for hypre's ParCSR matrix class.
Parallel smoothers in hypre.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Implicit midpoint method. A-stable, not L-stable.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
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
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Set the curvature of the mesh nodes using the given polynomial degree.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static int WorldRank()
Return the MPI rank in 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).
Abstract class for solving systems of ODEs: dx/dt = f(x,t)
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
virtual void Step(Vector &x, real_t &t, real_t &dt)=0
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
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.
OversetFindPointsGSLIB enables use of findpts for arbitrary number of overlapping grids....
void Setup(Mesh &m, const int meshid, GridFunction *gfmax=NULL, const double bb_t=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
void Interpolate(const Vector &point_pos, Array< unsigned int > &point_id, const GridFunction &field_in, Vector &field_out, int point_pos_ordering=Ordering::byNODES)
Abstract parallel finite element space.
ParMesh * GetParMesh() const
Class for parallel grid function.
HypreParVector * GetTrueDofs() const
Returns the true dofs in a new HypreParVector.
void SetFromTrueDofs(const Vector &tv) override
Set the GridFunction from the given true-dof vector.
ParFiniteElementSpace * ParFESpace() const
void ProjectCoefficient(Coefficient &coeff) override
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
void SaveAsOne(const char *fname, int precision=16) const
Class for parallel meshes.
void PrintAsOne(std::ostream &out=mfem::out, const std::string &comments="") const
Third-order, strong stability preserving (SSP) Runge-Kutta method.
The classical explicit forth-order Runge-Kutta method, RK4.
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
Base abstract class for first order time dependent operators.
Vector coefficient that is constant in space and time.
Vector coefficient defined by a vector GridFunction.
void SetGridFunction(const GridFunction *gf)
Set the grid function for this coefficient. Also sets the Vector dimension to match that of the gf.
virtual const real_t * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
void Neg()
(*this) = -(*this)
void Print(std::ostream &out=mfem::out, int width=8) const
Prints vector to stream out.
void SetSubVector(const Array< int > &dofs, const real_t value)
Set the entries listed in dofs to the given value.
int Size() const
Returns the size of the vector.
Transient incompressible Navier Stokes solver in a split scheme formulation.
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.
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 Step(real_t &time, real_t dt, int cur_step, bool provisional=false)
Compute solution at the next time step t+dt.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
bool is_open()
True if the socketstream is open, false otherwise.
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, const char *keys, bool vec)
real_t u(const Vector &xvec)
std::function< real_t(const Vector &)> f(real_t mass_coeff)
void Add(const DenseMatrix &A, const DenseMatrix &B, real_t alpha, DenseMatrix &C)
C = A + alpha*B.
struct schwarz_common schwarz
real_t temp_init(const Vector &x)
void vel_dbc(const Vector &x, real_t t, Vector &u)
Fluid data.
real_t kappa_fun(const Vector &x)
Solid data.