Flow123d
JS_before_hm-1829-g302b31a68
|
Go to the documentation of this file.
34 "Record with data for iterative coupling of flow and mechanics.\n")
40 "Flow equation, provides the velocity field as a result.")
42 "Mechanics, provides the displacement field.")
45 .make_field_descriptor_type(
"Coupling_Iterative")),
47 "Input fields of the HM coupling.")
49 "Tuning parameter for iterative splitting. Its default value"
50 "corresponds to a theoretically optimal value with fastest convergence." )
52 "Maximal count of HM iterations." )
54 "Minimal count of HM iterations." )
56 "Absolute tolerance for difference in HM iteration." )
58 "Relative tolerance for difference in HM iteration." )
63 const int HM_Iterative::registrar = Input::register_class< HM_Iterative, Mesh &, const Input::Record >(
"Coupling_Iterative")
84 *
this +=
beta.
name(
"relaxation_beta")
104 pressure_potential.set(potential_ptr_, 0.0);
107 beta.set(beta_ptr_, 0.0);
109 flow_source_ptr_ = create_field_fe<3, FieldValue<3>::Scalar>(beta_ptr_->get_dofhandler());
110 flow_source.set(flow_source_ptr_, 0.0);
112 old_pressure_ptr_ = create_field_fe<3, FieldValue<3>::Scalar>(beta_ptr_->get_dofhandler());
113 old_iter_pressure_ptr_ = create_field_fe<3, FieldValue<3>::Scalar>(beta_ptr_->get_dofhandler());
114 div_u_ptr_ = create_field_fe<3, FieldValue<3>::Scalar>(beta_ptr_->get_dofhandler());
115 old_div_u_ptr_ = create_field_fe<3, FieldValue<3>::Scalar>(beta_ptr_->get_dofhandler());
125 using namespace Input;
135 std::stringstream ss;
142 mechanics_->eq_fields()[
"cross_section"].copy_from(
flow_->data()[
"cross_section"]);
146 beta_ = in_record.
val<
double>(
"iteration_parameter");
163 template<
int dim,
class Value>
167 auto vec = to_field.
vec();
171 for (
auto cell : dh->own_range() )
172 vec.set( cell.local_idx(), from_field.
value(cell.elm().centre(), cell.elm()) );
180 std::stringstream ss;
184 flow_->zero_time_step();
208 flow_->solve_time_step(
false);
226 flow_->accept_time_step();
227 flow_->output_data();
240 field_edge_pressure.
copy_from(*
flow_->data().field(
"pressure_edge"));
241 for (
auto ele : dh->local_range() )
243 auto elm = ele.elm();
244 LocDofVec dof_indices = ele.get_loc_dof_indices();
245 for (
auto side : ele.side_range() )
250 double pressure = field_edge_pressure.
value(side.centre(), elm);
251 double potential = -alpha*density*gravity*pressure;
253 potential_vec_.set( dof_indices[side.side_idx()], potential );
268 field_ele_pressure.
copy_from(*
flow_->data().field(
"pressure_p0"));
269 for (
auto ele : dh->local_range() )
271 auto elm = ele.elm();
274 double young =
mechanics_->eq_fields().young_modulus.value(elm.centre(), elm);
275 double poisson =
mechanics_->eq_fields().poisson_ratio.value(elm.centre(), elm);
279 double p = field_ele_pressure.
value(elm.centre(), elm);
282 double src = (beta*(p-old_p) + alpha*(old_div_u - div_u)) /
time_->
dt();
284 beta_vec.set(ele.local_idx(), beta);
285 src_vec.set(ele.local_idx(), src);
298 double p_dif2 = 0, p_norm2 = 0;
300 field_ele_pressure.
copy_from(*
flow_->data().field(
"pressure_p0"));
301 for (
auto cell : dh->own_range())
303 auto elm = cell.elm();
304 double new_p = field_ele_pressure.
value(elm.centre(), elm);
306 p_dif2 += pow(new_p - old_p, 2)*elm.measure();
307 p_norm2 += pow(old_p, 2)*elm.measure();
310 double send_data[] = { p_dif2, p_norm2 };
313 abs_error = sqrt(recv_data[0]);
314 rel_error = abs_error / (sqrt(recv_data[1]) + std::numeric_limits<double>::min());
316 MessageOut().fmt(
"HM Iteration {} abs. difference: {} rel. difference: {}\n"
317 "--------------------------------------------------------",
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
static const Input::Type::Record & get_input_type()
Define input record.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > old_iter_pressure_ptr_
static constexpr Mask in_rhs
A field is part of the right hand side of the equation.
arma::Col< IntIdx > LocDofVec
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > beta_ptr_
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > old_div_u_ptr_
bool set_time(const TimeStep &time, LimitSide limit_side)
std::shared_ptr< RichardsLMH > flow_
steady or unsteady water flow simulator based on MH scheme
#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
FieldCommon & flags(FieldFlag::Flags::Mask mask)
std::shared_ptr< Elasticity > mechanics_
solute transport with chemistry through operator splitting
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)
Field< 3, FieldValue< 3 >::Scalar > pressure_potential
Potential -alpha*pressure whose gradient is passed to mechanics as additional load.
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > flow_source_ptr_
void initialize(Mesh &mesh)
void update_after_converged() override
Save data after iterations have finished.
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > div_u_ptr_
std::shared_ptr< DOFHandlerMultiDim > get_dofhandler() const
double a_tol_
Absolute tolerance for difference between two succeeding iterations.
HM_Iterative(Mesh &mesh, Input::Record in_record)
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > old_pressure_ptr_
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()
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > potential_ptr_
FieldFE for pressure_potential field.
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.
void update_flow_fields()
static Input::Type::Abstract & get_input_type()
void update_solution() override
void view(const char *name="") const
double beta_
Tuning parameter for iterative splitting.
virtual const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm) const
void initialize() override
FieldCommon & input_default(const string &input_default)
Field< 3, FieldValue< 3 >::Scalar > alpha
Biot coefficient.
double r_tol_
Relative tolerance for difference between two succeeding iterations.
static const Input::Type::Record & get_input_type()
#define MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm)
Field< 3, FieldValue< 3 >::Scalar > gravity
Standard gravity.
#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.
Field< 3, FieldValue< 3 >::Scalar > flow_source
Field< 3, FieldValue< 3 >::Scalar > beta
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)
Class template representing a field with values dependent on: point, element, and region.
Field< 3, FieldValue< 3 >::Scalar > density
Density of fluid.
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.