58 real_t r = sqrt(pow(x, 2.0) + pow(y, 2.0));
63 if (std::abs(r) >= 0.25 - 1e-8)
69 q(2) = A * exp(-(pow(x, 2.0) / 2.0 + pow(y, 2.0) / 2.0));
109 ess_tdofs_(ess_tdofs),
110 M_solver(fes.GetComm())
150 M_solver.
Mult(t1, du_dt);
154 ~ConvectionDiffusionTDO()
205int main(
int argc,
char *argv[])
215 bool visualization =
true;
220 "Finite element order (polynomial degree).");
221 args.
AddOption(&t_final,
"-tf",
"--t-final",
222 "Final time; start time is 0.");
223 args.
AddOption(&dt,
"-dt",
"--time-step",
225 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
226 "--no-visualization",
227 "Enable or disable GLVis visualization.");
228 args.
AddOption(&vis_steps,
"-vs",
"--visualization-steps",
229 "Visualize every n-th timestep.");
232 Mesh *serial_mesh =
new Mesh(
"multidomain-hex.mesh");
244 cylinder_domain_attributes[0] = 1;
246 auto cylinder_submesh =
251 Array<int> inflow_attributes(cylinder_submesh.bdr_attributes.Max());
252 inflow_attributes = 0;
253 inflow_attributes[7] = 1;
256 cylinder_submesh.bdr_attributes.Max());
257 inner_cylinder_wall_attributes = 0;
258 inner_cylinder_wall_attributes[8] = 1;
263 Array<int> inflow_tdofs, interface_tdofs, ess_tdofs;
267 ess_tdofs.
Append(inflow_tdofs);
268 ess_tdofs.
Append(interface_tdofs);
271 ConvectionDiffusionTDO cd_tdo(fes_cylinder, ess_tdofs);
274 pressure_cylinder_gf = 0.0;
277 pressure_cylinder_gf.
GetTrueDofs(pressure_cylinder);
280 cd_ode_solver.
Init(cd_tdo);
283 outer_domain_attributes[0] = 2;
286 outer_domain_attributes);
290 Array<int> block_wall_attributes(block_submesh.bdr_attributes.Max());
291 block_wall_attributes = 1;
292 block_wall_attributes[8] = 0;
295 block_submesh.bdr_attributes.Max());
296 outer_cylinder_wall_attributes = 0;
297 outer_cylinder_wall_attributes[8] = 1;
301 ConvectionDiffusionTDO d_tdo(fes_block, ess_tdofs, 0.0, 1.0);
304 pressure_block_gf = 0.0;
308 block_wall_attributes);
314 d_ode_solver.
Init(d_tdo);
317 cylinder_surface_attributes[0] = 9;
319 auto cylinder_surface_submesh =
328 cyl_sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
329 cyl_sol_sock.precision(8);
330 cyl_sol_sock <<
"solution\n" << cylinder_submesh
331 << pressure_cylinder_gf
332 <<
"window_title \"Time step: " << 0 <<
"\""
333 <<
"keys cvv\n autoscale off\n valuerange 0 1.414\n"
334 <<
"pause\n" << std::flush;
340 block_sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
341 block_sol_sock.precision(8);
342 block_sol_sock <<
"solution\n" << block_submesh << pressure_block_gf
343 <<
"window_title \"Time step: " << 0 <<
"\""
344 <<
"window_geometry 400 0 400 350\n"
345 <<
"keys cvv\n autoscale off\n valuerange 0 1.414\n"
346 <<
"pause\n" << std::flush;
352 pressure_cylinder_gf);
355 bool last_step =
false;
356 for (
int ti = 1; !last_step; ti++)
358 if (
t + dt >= t_final - dt/2)
364 d_ode_solver.
Step(pressure_block,
t, dt);
370 pressure_block_to_cylinder_map.Transfer(pressure_block_gf,
371 pressure_cylinder_gf);
373 pressure_cylinder_gf.
GetTrueDofs(pressure_cylinder);
377 cd_ode_solver.
Step(pressure_cylinder,
t, dt);
379 if (last_step || (ti % vis_steps) == 0)
383 out <<
"step " << ti <<
", t = " <<
t << std::endl;
391 cyl_sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
392 cyl_sol_sock <<
"solution\n" << cylinder_submesh
393 << pressure_cylinder_gf
394 <<
"window_title \"Time step: " << ti <<
"\""
396 block_sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
397 block_sol_sock <<
"solution\n" << block_submesh
399 <<
"window_title \"Time step: " << ti <<
"\""
void Sort()
Sorts the array in ascending order. This requires operator< to be defined for T.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void Unique()
Removes duplicities from a sorted array. This requires operator== to be defined for T.
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.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
A coefficient that is constant across space and time.
for Raviart-Thomas elements
void ProjectBdrCoefficientNormal(VectorCoefficient &vcoeff, const Array< int > &bdr_attr)
Parallel smoothers in hypre.
void SetType(HypreSmoother::Type type, int relax_times=1)
Set the relaxation type and number of sweeps.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
void SetRelTol(real_t rtol)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
void SetAbsTol(real_t atol)
int Dimension() const
Dimension of the reference space used within the elements.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
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).
Pointer to an Operator of a specified type.
int height
Dimension of the output / number of rows in the matrix.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
void ParseCheck(std::ostream &out=mfem::out)
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...
Abstract parallel finite element space.
void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const override
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.
Class for parallel meshes.
static ParTransferMap CreateTransferMap(const ParGridFunction &src, const ParGridFunction &dst)
Create a Transfer Map object.
static ParSubMesh CreateFromBoundary(const ParMesh &parent, Array< int > &boundary_attributes)
Create a surface ParSubMesh from it's parent.
static ParSubMesh CreateFromDomain(const ParMesh &parent, Array< int > &domain_attributes)
Create a domain ParSubMesh from it's parent.
Third-order, strong stability preserving (SSP) Runge-Kutta method.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
Vector coefficient defined as a product of scalar and vector coefficients.
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Base abstract class for first order time dependent operators.
Base class for vector Coefficients that optionally depend on time and space.
A general vector function coefficient.
void SetSubVector(const Array< int > &dofs, const real_t value)
Set the entries listed in dofs to the given value.
void SetSize(int s)
Resize the vector to size s.
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void square_xy(const Vector &p, Vector &v)
void velocity_profile(const Vector &c, Vector &q)
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 p(const Vector &x, real_t t)