18 #ifndef field_algo_base_IMPL_HH_ 19 #define field_algo_base_IMPL_HH_ 50 template <
int spacedim,
class Value>
54 component_idx_(
std::numeric_limits<unsigned int>::max()),
55 unit_conversion_coefficient_(1.0)
62 template <
int spacedim,
class Value>
64 return boost::str(
boost::format(
"R%i_to_%s") % spacedim % Value::type_name() );
69 template <
int spacedim,
class Value>
72 ss <<
"[" << Value::NRows_ <<
", " << Value::NCols_ <<
"]";
81 template <
int spacedim,
class Value>
86 param_vec.push_back( std::make_pair(
"element_input_type", std::make_shared<it::Selection>(value_selection)) );
88 param_vec.push_back( std::make_pair(
"element_input_type", std::make_shared<typename Value::ElementInputType>()) );
94 template <
int spacedim,
class Value>
97 "Specify unit of an input value. " 98 "Evaluation of the unit formula results into a coeficient and a " 99 "unit in terms of powers of base SI units. The unit must match " 100 "expected SI unit of the value, while the value provided on the input " 101 "is multiplied by the coefficient before further processing. " 102 "The unit formula have a form:\n" 104 "<UnitExpr>;<Variable>=<Number>*<UnitExpr>;...,\n" 106 "where ```<Variable>``` is a variable name and ```<UnitExpr>``` is a units expression " 107 "which consists of products and divisions of terms.\n\n" 108 "A term has a form: " 109 "```<Base>^<N>```, where ```<N>``` is an integer exponent and ```<Base>``` " 110 "is either a base SI unit, a derived unit, or a variable defined in the same unit formula. " 111 "Example, unit for the pressure head:\n\n" 112 "```MPa/rho/g_; rho = 990*kg*m^-3; g_ = 9.8*m*s^-2```" 116 "Definition of unit." )
119 return it::Record(
"FieldAlgorithmBase_common_aux",
"")
121 "Unit of the field values provided in the main input file, in the external file, or " 122 "by a function (FieldPython).")
126 template <
int spacedim,
class Value>
127 shared_ptr< FieldAlgorithmBase<spacedim, Value> >
130 shared_ptr< FieldAlgorithmBase<spacedim, Value> > func;
138 template <
int spacedim,
class Value>
140 xprintf(
PrgErr,
"The field '%s' do not support initialization from input.\n",
141 typeid(
this).name());
146 template <
int spacedim,
class Value>
154 template <
int spacedim,
class Value>
160 template<
int spacedim,
class Value>
162 return (Value::NRows_ ? 0 :
value_.n_rows());
167 template<
int spacedim,
class Value>
173 ASSERT_EQ( point_list.size(), value_list.size() ).error();
174 for(
unsigned int i=0; i< point_list.size(); i++) {
176 .error(
"value_list has wrong number of rows");
177 value_list[i]=this->
value(point_list[i], elm);
182 template<
int spacedim,
class Value>
187 if ( rec.
opt_val(
"unit", unit_record) ) {
188 if (!Value::is_scalable()) {
189 WarningOut().fmt(
"Setting unit conversion coefficient of non-floating point field at address {}\nCoefficient will be skipped.\n",
192 std::string unit_str = unit_record.
val<std::string>(
"unit_formula");
195 }
catch (ExcInvalidUnit &e) {
198 }
catch (ExcNoncorrespondingUnit &e) {
208 #endif //FUNCTION_BASE_IMPL_HH_
TimeStep time_
Actual time level; initial value is -infinity.
void init_unit_conversion_coefficient(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Init value of unit_conversion_coefficient_ from input.
static const Input::Type::Instance & get_input_type_instance(Input::Type::Selection value_selection=Input::Type::Selection())
virtual bool set_time(const TimeStep &time)
double convert_unit_from(std::string actual_unit) const
Convert and check user-defined unit.
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)=0
std::string format(CStringRef format_str, ArgList args)
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)=0
Basic time management class.
static constexpr bool is_enum_valued
double unit_conversion_coefficient_
Coeficient of conversion of user-defined unit.
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
static string field_value_shape()
static std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > function_factory(const Input::AbstractRecord &rec, const struct FieldAlgoBaseInitData &init_data)
FieldAlgorithmBase(unsigned int n_comp=0)
Value value_
Last value, prevents passing large values (vectors) by value.
static Input::Type::Abstract & get_input_type()
virtual void set_mesh(const Mesh *mesh, bool boundary_domain)
#define WarningOut()
Macro defining 'warning' record of log.
static const Input::Type::Record & get_field_algo_common_keys()
static std::string template_name()
Representation of one time step..
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
unsigned int n_comp() const