18 #ifndef field_algo_base_IMPL_HH_ 19 #define field_algo_base_IMPL_HH_ 51 template <
int spacedim,
class Value>
55 component_idx_(
std::numeric_limits<unsigned int>::max()),
56 unit_conversion_coefficient_(1.0)
63 template <
int spacedim,
class Value>
65 return boost::str(
boost::format(
"R%i_to_%s") % spacedim % Value::type_name() );
70 template <
int spacedim,
class Value>
73 ss <<
"[" << Value::NRows_ <<
", " << Value::NCols_ <<
"]";
82 template <
int spacedim,
class Value>
87 param_vec.push_back( std::make_pair(
"element_input_type", std::make_shared<it::Selection>(value_selection)) );
89 param_vec.push_back( std::make_pair(
"element_input_type", std::make_shared<typename Value::ElementInputType>()) );
95 template <
int spacedim,
class Value>
98 "Specify unit of an input value. " 99 "Evaluation of the unit formula results into a coeficient and a " 100 "unit in terms of powers of base SI units. The unit must match " 101 "expected SI unit of the value, while the value provided on the input " 102 "is multiplied by the coefficient before further processing. " 103 "The unit formula have a form:\n" 105 "<UnitExpr>;<Variable>=<Number>*<UnitExpr>;...,\n" 107 "where ```<Variable>``` is a variable name and ```<UnitExpr>``` is a units expression " 108 "which consists of products and divisions of terms.\n\n" 109 "A term has a form: " 110 "```<Base>^<N>```, where ```<N>``` is an integer exponent and ```<Base>``` " 111 "is either a base SI unit, a derived unit, or a variable defined in the same unit formula. " 112 "Example, unit for the pressure head:\n\n" 113 "```MPa/rho/g_; rho = 990*kg*m^-3; g_ = 9.8*m*s^-2```" 117 "Definition of unit." )
120 return it::Record(
"FieldAlgorithmBase_common_aux",
"")
122 "Unit of the field values provided in the main input file, in the external file, or " 123 "by a function (FieldPython).")
127 template <
int spacedim,
class Value>
128 shared_ptr< FieldAlgorithmBase<spacedim, Value> >
131 shared_ptr< FieldAlgorithmBase<spacedim, Value> > func;
139 template <
int spacedim,
class Value>
141 xprintf(
PrgErr,
"The field '%s' do not support initialization from input.\n",
142 typeid(
this).name());
147 template <
int spacedim,
class Value>
155 template <
int spacedim,
class Value>
161 template<
int spacedim,
class Value>
163 return (Value::NRows_ ? 0 :
value_.n_rows());
168 template<
int spacedim,
class Value>
174 ASSERT_EQ( point_list.size(), value_list.size() ).error();
175 for(
unsigned int i=0; i< point_list.size(); i++) {
176 ASSERT( Value(value_list[i]).n_rows()==this->
value_.n_rows() )(i)(Value(value_list[i]).n_rows())(this->
value_.n_rows())
177 .error(
"value_list has wrong number of rows");
178 value_list[i]=this->
value(point_list[i], elm);
183 template<
int spacedim,
class Value>
188 if ( rec.
opt_val(
"unit", unit_record) ) {
189 if (!Value::is_scalable()) {
190 WarningOut().fmt(
"Setting unit conversion coefficient of non-floating point field at address {}\nCoefficient will be skipped.\n",
193 std::string unit_str = unit_record.
val<std::string>(
"unit_formula");
196 }
catch (ExcInvalidUnit &e) {
199 }
catch (ExcNoncorrespondingUnit &e) {
209 #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