Flow123d
release_3.0.0-968-gc87a28e79
|
Go to the documentation of this file.
18 #ifndef field_algo_base_IMPL_HH_
19 #define field_algo_base_IMPL_HH_
49 template <
int spacedim,
class Value>
53 component_idx_(
std::numeric_limits<unsigned int>::max()),
54 unit_conversion_coefficient_(1.0)
61 template <
int spacedim,
class Value>
63 return fmt::format(
"R{:d}_to_{}", spacedim, Value::type_name() );
68 template <
int spacedim,
class Value>
71 ss <<
"[" << Value::NRows_ <<
", " << Value::NCols_ <<
"]";
72 return it::Abstract(
"Field_"+template_name(),
"Abstract for all time-space functions.")
80 template <
int spacedim,
class Value>
85 param_vec.push_back( std::make_pair(
"element_input_type", std::make_shared<it::Selection>(value_selection)) );
87 param_vec.push_back( std::make_pair(
"element_input_type", std::make_shared<typename Value::ElementInputType>()) );
93 template <
int spacedim,
class Value>
96 "Specify unit of an input value. "
97 "Evaluation of the unit formula results into a coeficient and a "
98 "unit in terms of powers of base SI units. The unit must match "
99 "expected SI unit of the value, while the value provided on the input "
100 "is multiplied by the coefficient before further processing. "
101 "The unit formula have a form:\n"
103 "<UnitExpr>;<Variable>=<Number>*<UnitExpr>;...,\n"
105 "where ```<Variable>``` is a variable name and ```<UnitExpr>``` is a units expression "
106 "which consists of products and divisions of terms.\n\n"
107 "A term has a form: "
108 "```<Base>^<N>```, where ```<N>``` is an integer exponent and ```<Base>``` "
109 "is either a base SI unit, a derived unit, or a variable defined in the same unit formula. "
110 "Example, unit for the pressure head:\n\n"
111 "```MPa/rho/g_; rho = 990*kg*m^-3; g_ = 9.8*m*s^-2```"
115 "Definition of unit." )
118 return it::Record(
"FieldAlgorithmBase_common_aux",
"")
120 "Unit of the field values provided in the main input file, in the external file, or "
121 "by a function (FieldPython).")
125 template <
int spacedim,
class Value>
126 shared_ptr< FieldAlgorithmBase<spacedim, Value> >
129 shared_ptr< FieldAlgorithmBase<spacedim, Value> > func;
137 template <
int spacedim,
class Value>
139 xprintf(
PrgErr,
"The field '%s' do not support initialization from input.\n",
140 typeid(
this).name());
145 template <
int spacedim,
class Value>
153 template <
int spacedim,
class Value>
159 template<
int spacedim,
class Value>
161 return (Value::NRows_ ? 0 : value_.n_rows());
166 template<
int spacedim,
class Value>
172 ASSERT_EQ( point_list.size(), value_list.size() ).error();
173 for(
unsigned int i=0; i< point_list.size(); i++) {
174 ASSERT(
Value(value_list[i]).n_rows()==this->value_.n_rows() )(i)(
Value(value_list[i]).n_rows())(this->value_.n_rows())
175 .error(
"value_list has wrong number of rows");
176 value_list[i]=this->
value(point_list[i], elm);
181 template<
int spacedim,
class Value>
186 if ( rec.
opt_val(
"unit", unit_record) ) {
187 if (!Value::is_scalable()) {
188 WarningOut().fmt(
"Setting unit conversion coefficient of non-floating point field at address {}\nCoefficient will be skipped.\n",
191 std::string unit_str = unit_record.
val<std::string>(
"unit_formula");
194 }
catch (ExcInvalidUnit &e) {
197 }
catch (ExcNoncorrespondingUnit &e) {
207 #endif //FUNCTION_BASE_IMPL_HH_
unsigned int n_comp() const
Basic time management class.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
static const Input::Type::Record & get_field_algo_common_keys()
static const Input::Type::Instance & get_input_type_instance(Input::Type::Selection value_selection=Input::Type::Selection())
static constexpr bool value
double convert_unit_from(std::string actual_unit) const
Convert and check user-defined unit.
static Input::Type::Abstract & get_input_type()
std::string format(CStringRef format_str, ArgList args)
static string field_value_shape()
FieldAlgorithmBase(unsigned int n_comp=0)
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Representation of one time step..
Value value_
Last value, prevents passing large values (vectors) by value.
void init_unit_conversion_coefficient(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Init value of unit_conversion_coefficient_ from input.
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
virtual void set_mesh(const Mesh *mesh, bool boundary_domain)
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)=0
static std::string template_name()
#define WarningOut()
Macro defining 'warning' record of log.
virtual bool set_time(const TimeStep &time)
static std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > function_factory(const Input::AbstractRecord &rec, const struct FieldAlgoBaseInitData &init_data)