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_ <<
"]";
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());
165 template<
int spacedim,
class Value>
175 template<
int spacedim,
class Value>
183 for(
unsigned int i=0; i< point_list.
size(); i++) {
185 .error(
"value_list has wrong number of rows");
186 value_list[i]=this->
value(point_list.
vec<spacedim>(i), elm);
191 template<
int spacedim,
class Value>
196 if ( rec.
opt_val(
"unit", unit_record) ) {
197 if (!Value::is_scalable()) {
198 WarningOut().fmt(
"Setting unit conversion coefficient of non-floating point field at address {}\nCoefficient will be skipped.\n",
201 std::string unit_str = unit_record.
val<std::string>(
"unit_formula");
204 }
catch (ExcInvalidUnit &e) {
207 }
catch (ExcNoncorrespondingUnit &e) {
217 #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.
unsigned int size() const
virtual void cache_update(FieldValueCache< typename Value::element_type > &data_cache, ElementCacheMap &cache_map, unsigned int region_idx)
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.
std::string format(CStringRef format_str, ArgList args)
Directing class of FieldValueCache.
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 void value_list(const Armor::array &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)=0
ArmaVec< Type, nr > vec(uint mat_index) const
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