57 double r = sqrt(pow(x, 2.0) + pow(y, 2.0));
62 if (std::abs(r) >= 0.25 - 1e-8)
68 q(2) = A * exp(-(pow(x, 2.0) / 2.0 + pow(y, 2.0) / 2.0));
95 double kappa = 1.0e-1)
100 ess_tdofs_(ess_tdofs),
101 M_solver(fes.GetComm())
113 M.Reset(Mform.ParallelAssemble(),
true);
116 bform.AddBdrFaceIntegrator(
126 Kform.FormSystemMatrix(empty, K);
127 Mform.FormSystemMatrix(ess_tdofs_, M);
130 b = bform.ParallelAssemble();
133 M_solver.iterative_mode =
false;
134 M_solver.SetRelTol(1e-8);
135 M_solver.SetAbsTol(0.0);
136 M_solver.SetMaxIter(100);
137 M_solver.SetPrintLevel(0);
139 M_solver.SetPreconditioner(M_prec);
140 M_solver.SetOperator(*M);
150 M_solver.Mult(t1, du_dt);
154 ~ConvectionDiffusionTDO()
192 double current_dt = -1.0;
204 int main(
int argc,
char *argv[])
212 double t_final = 5.0;
214 bool visualization =
true;
219 "Finite element order (polynomial degree).");
220 args.
AddOption(&t_final,
"-tf",
"--t-final",
221 "Final time; start time is 0.");
222 args.
AddOption(&dt,
"-dt",
"--time-step",
224 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
225 "--no-visualization",
226 "Enable or disable GLVis visualization.");
227 args.
AddOption(&vis_steps,
"-vs",
"--visualization-steps",
228 "Visualize every n-th timestep.");
231 Mesh *serial_mesh =
new Mesh(
"multidomain-hex.mesh");
243 cylinder_domain_attributes[0] = 1;
245 auto cylinder_submesh =
250 Array<int> inflow_attributes(cylinder_submesh.bdr_attributes.Max());
251 inflow_attributes = 0;
252 inflow_attributes[7] = 1;
255 cylinder_submesh.bdr_attributes.Max());
256 inner_cylinder_wall_attributes = 0;
257 inner_cylinder_wall_attributes[8] = 1;
262 Array<int> inflow_tdofs, interface_tdofs, ess_tdofs;
266 ess_tdofs.
Append(inflow_tdofs);
267 ess_tdofs.
Append(interface_tdofs);
270 ConvectionDiffusionTDO cd_tdo(fes_cylinder, ess_tdofs);
273 temperature_cylinder_gf = 0.0;
275 Vector temperature_cylinder;
276 temperature_cylinder_gf.
GetTrueDofs(temperature_cylinder);
279 cd_ode_solver.
Init(cd_tdo);
282 outer_domain_attributes[0] = 2;
285 outer_domain_attributes);
289 Array<int> block_wall_attributes(block_submesh.bdr_attributes.Max());
290 block_wall_attributes = 0;
291 block_wall_attributes[0] = 1;
292 block_wall_attributes[1] = 1;
293 block_wall_attributes[2] = 1;
294 block_wall_attributes[3] = 1;
297 block_submesh.bdr_attributes.Max());
298 outer_cylinder_wall_attributes = 0;
299 outer_cylinder_wall_attributes[8] = 1;
303 ConvectionDiffusionTDO d_tdo(fes_block, ess_tdofs, 0.0, 1.0);
306 temperature_block_gf = 0.0;
312 temperature_block_gf.
GetTrueDofs(temperature_block);
315 d_ode_solver.
Init(d_tdo);
318 cylinder_surface_attributes[0] = 9;
321 cylinder_surface_attributes);
328 cyl_sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
329 cyl_sol_sock.precision(8);
330 cyl_sol_sock <<
"solution\n" << cylinder_submesh << temperature_cylinder_gf <<
331 "pause\n" << std::flush;
336 block_sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
337 block_sol_sock.precision(8);
338 block_sol_sock <<
"solution\n" << block_submesh << temperature_block_gf <<
339 "pause\n" << std::flush;
344 temperature_block_gf,
345 temperature_cylinder_gf);
348 bool last_step =
false;
349 for (
int ti = 1; !last_step; ti++)
351 if (t + dt >= t_final - dt/2)
357 d_ode_solver.
Step(temperature_block, t, dt);
363 temperature_block_to_cylinder_map.Transfer(temperature_block_gf,
364 temperature_cylinder_gf);
366 temperature_cylinder_gf.
GetTrueDofs(temperature_cylinder);
370 cd_ode_solver.
Step(temperature_cylinder, t, dt);
372 if (last_step || (ti % vis_steps) == 0)
376 out <<
"step " << ti <<
", t = " << t << std::endl;
384 cyl_sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
385 cyl_sol_sock <<
"solution\n" << cylinder_submesh << temperature_cylinder_gf <<
387 block_sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
388 block_sol_sock <<
"solution\n" << block_submesh << temperature_block_gf <<
static ParSubMesh CreateFromBoundary(const ParMesh &parent, Array< int > &boundary_attributes)
Create a surface ParSubMesh from it's parent.
void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
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.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Conjugate gradient method.
void Unique()
Removes duplicities from a sorted array. This requires operator== to be defined for T...
ParMesh * GetParMesh() const
Base class for vector Coefficients that optionally depend on time and space.
A coefficient that is constant across space and time.
Base abstract class for first order time dependent operators.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
Pointer to an Operator of a specified type.
void velocity_profile(const Vector &c, Vector &q)
Abstract parallel finite element space.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
static ParSubMesh CreateFromDomain(const ParMesh &parent, Array< int > &domain_attributes)
Create a domain ParSubMesh from it's parent.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
bool IsDGSpace() const
Return whether or not the space is discontinuous (L2)
Parallel smoothers in hypre.
static void Init()
Singleton creation with Mpi::Init();.
void Sort()
Sorts the array in ascending order. This requires operator< to be defined for T.
A general vector function coefficient.
void ProjectBdrCoefficient(Coefficient *coeff[], VectorCoefficient *vcoeff, Array< int > &attr)
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
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...
Third-order, strong stability preserving (SSP) Runge-Kutta method.
static ParTransferMap CreateTransferMap(const ParGridFunction &src, const ParGridFunction &dst)
Create a Transfer Map object.
HypreParVector * GetTrueDofs() const
Returns the true dofs in a new HypreParVector.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
Arbitrary order H1-conforming (continuous) finite elements.
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.
void Step(Vector &x, double &t, double &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in]...
void ParseCheck(std::ostream &out=mfem::out)