Flow123d
JS_before_hm-2203-gd2ee21200
|
Go to the documentation of this file.
34 inline double operator() (
double alpha,
double density,
double gravity,
double pressure)
36 return -alpha*density*gravity*pressure;
62 inline double operator() (
double alpha,
double beta,
double pressure,
double old_pressure,
double div_u,
double old_div_u)
64 return (beta*(pressure-old_pressure) + alpha*(old_div_u - div_u)) /
time_->
dt();
75 "Record with data for iterative coupling of flow and mechanics.\n")
81 "Flow equation, provides the velocity field as a result.")
83 "Mechanics, provides the displacement field.")
86 .make_field_descriptor_type(
"Coupling_Iterative")),
88 "Input fields of the HM coupling.")
90 "Tuning parameter for iterative splitting. Its default value "
91 "corresponds to a theoretically optimal value with fastest convergence." )
93 "Maximal count of HM iterations." )
95 "Minimal count of HM iterations." )
97 "Absolute tolerance for difference in HM iteration." )
99 "Relative tolerance for difference in HM iteration." )
104 const int HM_Iterative::registrar = Input::register_class< HM_Iterative, Mesh &, const Input::Record >(
"Coupling_Iterative")
117 .
description(
"Volumetric mass density of the fluid.")
123 .
description(
"Gravitational acceleration constant.")
128 *
this +=
beta.
name(
"relaxation_beta")
129 .
description(
"Parameter of numerical method for iterative solution of hydro-mechanical coupling.")
134 .
description(
"Coupling term entering the mechanics equation.")
144 .
description(
"Displacement divergence from last computed time.")
149 .
description(
"Pressure potential on boundary (taking into account the flow boundary condition.")
154 .
description(
"Coupling term entering the flow equation.")
166 ref_pressure_potential.set(ref_potential_ptr_, 0.0);
168 old_pressure_ptr_ = create_field_fe<3, FieldValue<3>::Scalar>(parent.
flow_->eq_data().dh_cr_, &parent.
flow_->eq_data().p_edge_solution_previous_time);
170 old_div_u_ptr_ = create_field_fe<3, FieldValue<3>::Scalar>(parent.
mechanics_->eq_fields().output_div_ptr->get_dofhandler());
180 using namespace Input;
193 mechanics_->initialize();
196 mechanics_->eq_fields()[
"cross_section"].copy_from(
flow_->eq_fields()[
"cross_section"]);
201 flow_->eq_fields() +=
mechanics_->eq_fields()[
"cross_section_updated"];
206 std::stringstream ss;
232 flow_->eq_fields().field_edge_pressure
246 flow_->eq_fields().field_edge_pressure,
254 template<
int dim,
class Value>
258 auto vec = to_field.
vec();
262 for (
auto cell : dh->own_range() )
263 vec.set( cell.local_idx(), from_field.
value(cell.elm().centre(), cell.elm()) );
271 std::stringstream ss;
276 flow_->zero_time_step();
299 flow_->solve_time_step(
false);
316 flow_->accept_time_step();
317 flow_->output_data();
329 field_edge_pressure.
copy_from(*
flow_->eq_fields().field(
"pressure_edge"));
331 for (
auto ele : dh->local_range() )
333 auto elm = ele.elm();
334 LocDofVec dof_indices = ele.get_loc_dof_indices();
335 for (
auto side : ele.side_range() )
343 if (side.side().is_boundary() &&
348 double bc_pressure =
flow_->eq_fields().bc_pressure.value(side.centre(), side.cond().element_accessor());
349 ref_potential_vec_.set(dof_indices[side.side_idx()], -alpha*density*gravity*bc_pressure);
352 ref_potential_vec_.set(dof_indices[side.side_idx()], 0);
356 ref_potential_vec_.local_to_ghost_begin();
357 ref_potential_vec_.local_to_ghost_end();
376 double p_dif2 = 0, p_norm2 = 0;
378 field_ele_pressure.
copy_from(*
flow_->eq_fields().field(
"pressure_p0"));
379 for (
auto cell : dh->own_range())
381 auto elm = cell.elm();
382 double new_p = field_ele_pressure.
value(elm.centre(), elm);
384 p_dif2 += pow(new_p - old_p, 2)*elm.measure();
385 p_norm2 += pow(old_p, 2)*elm.measure();
388 double send_data[] = { p_dif2, p_norm2 };
391 abs_error = sqrt(recv_data[0]);
392 rel_error = abs_error / (sqrt(recv_data[1]) + std::numeric_limits<double>::min());
394 MessageOut().fmt(
"HM Iteration {} abs. difference: {} rel. difference: {}\n"
395 "--------------------------------------------------------",
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
Field< 3, FieldValue< 3 >::Scalar > alpha
Biot coefficient.
static const Input::Type::Record & get_input_type()
Define input record.
static constexpr Mask in_rhs
A field is part of the right hand side of the equation.
arma::Col< IntIdx > LocDofVec
Class for solution of fully coupled flow and mechanics using fixed-stress iterative splitting.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > old_div_u_ptr_
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > old_pressure_ptr_
Field< 3, FieldValue< 3 >::Scalar > beta
double operator()(double alpha, double density, double gravity, double pressure)
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > ref_potential_ptr_
FieldFE for pressure_potential field.
Field< 3, FieldValue< 3 >::Scalar > pressure_potential
Potential -alpha*pressure whose gradient is passed to mechanics as additional load.
bool set_time(const TimeStep &time, LimitSide limit_side)
const double beta_factor
User-defined factor for iteration parameter.
Field< 3, FieldValue< 3 >::Scalar > density
Density of fluid.
std::shared_ptr< RichardsLMH > flow_
steady or unsteady water flow simulator based on MH scheme
Field< 3, FieldValue< 3 >::Scalar > flow_source
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
void set_input_list(Input::Array input_list, const TimeGovernor &tg)
static const int registrar
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
void zero_time_step() override
fn_fluid_source(TimeGovernor *time)
FieldCommon & flags(FieldFlag::Flags::Mask mask)
Field< 3, FieldValue< 3 >::Scalar > ref_pressure_potential
Potential of reference (prescribed) pressure from flow b.c. TODO: Swith to BCField when possible.
std::shared_ptr< Elasticity > mechanics_
solute transport with chemistry through operator splitting
double operator()(double alpha, double beta, double pressure, double old_pressure, double div_u, double old_div_u)
void set_time_result_changed()
Manually mark flag that the field has been changed.
void copy_field(const FieldCommon &from_field_common, FieldFE< dim, Value > &to_field)
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > old_iter_pressure_ptr_
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
Field< 3, FieldValue< 3 >::Scalar > gravity
Standard gravity.
void update_after_converged() override
Save data after iterations have finished.
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
std::shared_ptr< DOFHandlerMultiDim > get_dofhandler() const
double a_tol_
Absolute tolerance for difference between two succeeding iterations.
const TimeGovernor * time_
double operator()(double alpha, double lame_mu, double lame_lambda)
HM_Iterative(Mesh &mesh, Input::Record in_record)
static constexpr Mask equation_result
Match result fields. These are never given by input or copy of input.
static const Input::Type::Record & record_template()
static const Input::Type::Record & get_input_type()
void set(FieldBasePtr field, double time, std::vector< std::string > region_set_names={"ALL"})
Basic time management functionality for unsteady (and steady) solvers (class Equation).
const TimeStep & step(int index=-1) const
void compute_iteration_error(double &abs_error, double &rel_error) override
Compute absolute and relative error in the solution.
Common abstract parent of all Field<...> classes.
static bool print_message_table(ostream &stream, std::string equation_name)
Class for representation SI units of Fields.
Input::Record input_record_
Field< 3, FieldValue< 3 >::Scalar > old_pressure
void initialize(Mesh &mesh, HM_Iterative &parent)
void update_flow_fields()
static Input::Type::Abstract & get_input_type()
void update_solution() override
void view(const char *name="") const
virtual const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm) const
void initialize() override
FieldCommon & input_default(const string &input_default)
double r_tol_
Relative tolerance for difference between two succeeding iterations.
#define MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm)
#define WarningOut()
Macro defining 'warning' record of log.
double lame_mu(double young, double poisson)
static Input::Type::Record & record_template()
Template Record with common keys for derived equations.
void update_after_iteration() override
Save data (e.g. solution fields) for the next iteration.
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportDG.
void solve_iteration() override
Solve equations and update data (fields).
double lame_lambda(double young, double poisson)
FieldCommon & description(const string &description)
Class template representing a field with values dependent on: point, element, and region.
fn_hm_coupling_beta(double beta_f)
Field< 3, FieldValue< 3 >::Scalar > old_div_u
void next_time()
Proceed to the next time according to current estimated time step.
unsigned int max_it_
Maximal number of iterations.
void copy_from(const FieldCommon &other) override
#define START_TIMER(tag)
Starts a timer with specified tag.
FieldCommon & name(const string &name)
#define MessageOut()
Macro defining 'message' record of log.