Flow123d
release_3.0.0-973-g92f55e826
|
Go to the documentation of this file.
19 #include <boost/type_traits/is_floating_point.hpp>
36 template <
int spacedim,
class Value>
43 "Input file with ASCII GMSH file format.")
45 "The values of the Field are read from the ```$ElementData``` section with field name given by this key.")
49 "Allow set default value of elements that have not listed values in mesh data file.")
51 "Definition of unit of all times defined in mesh data file.")
53 "Allow set time shift of field data read from the mesh data file. For time 't', field descriptor with time 'T', "
54 "time shift 'S' and if 't > T', we read time frame 't + S'.")
59 template <
int spacedim,
class Value>
61 Input::register_class< FieldElementwise<spacedim, Value>,
unsigned int >(
"FieldElementwise") +
66 template <
int spacedim,
class Value>
69 internal_raw_data(true), mesh_(NULL), unit_si_(
UnitSI::dimensionless() )
78 template <
int spacedim,
class Value>
80 unsigned int n_components)
82 internal_raw_data(false), mesh_(NULL), unit_si_(
UnitSI::dimensionless() )
92 template <
int spacedim,
class Value>
94 this->init_unit_conversion_coefficient(rec, init_data);
97 this->limits_ = init_data.
limits_;
99 DebugOut() <<
"Reader file: " << string(reader_file_);
100 ASSERT(internal_raw_data).error(
"Trying to initialize internal FieldElementwise from input.");
101 ASSERT(reader_file_ ==
FilePath()).error(
"Multiple call of init_from_input.");
104 field_name_ = rec.
val<std::string>(
"field_name");
105 if (!in_rec_.opt_val(
"default_value", default_value_) ) {
106 default_value_ = numeric_limits<double>::signaling_NaN();
127 template <
int spacedim,
class Value>
129 OLD_ASSERT(mesh_,
"Null mesh pointer of elementwise field: %s, did you call set_mesh()?\n", field_name_.c_str());
130 if ( reader_file_ ==
FilePath() )
return false;
136 double time_unit_coef = time.
read_coef(in_rec_.find<
string>(
"time_unit"));
138 double read_time = (time.
end()+time_shift) / time_unit_coef;
142 n_entities_, n_components_, boundary_domain_, this->component_idx_);
144 this->unit_conversion_coefficient_, default_value_, limits_.first, limits_.second);
147 THROW( ExcUndefElementValue() << EI_Field(field_name_) );
149 WarningOut().fmt(
"Values of some elements of FieldElementwise '{}' at address '{}' is out of limits: <{}, {}>\n"
150 "Unit of the Field: [{}]\n",
151 field_name_, in_rec_.address_string(), limits_.first, limits_.second, unit_si_.format_text() );
159 template <
int spacedim,
class Value>
162 OLD_ASSERT(mesh_ ==
nullptr || mesh_ == mesh,
"Trying to change mesh of the FieldElementwise.");
163 boundary_domain_ = boundary_domain;
166 n_entities_=mesh_->
n_elements(boundary_domain_);
170 data_ = std::make_shared<std::vector<typename Value::element_type>>();
171 data_->resize(n_entities_ * n_components_);
174 if ( reader_file_ ==
FilePath() )
return;
183 template <
int spacedim,
class Value>
187 OLD_ASSERT( elm.
is_boundary() == boundary_domain_,
"Trying to get value of FieldElementwise '%s' for wrong ElementAccessor type (boundary/bulk).\n", field_name_.c_str() );
189 unsigned int idx = n_components_ * elm.
idx();
192 return Value::from_raw(this->r_value_, (
typename Value::element_type *)(&vec[idx]));
200 template <
int spacedim,
class Value>
205 OLD_ASSERT( elm.
is_boundary() == boundary_domain_,
"Trying to get value of FieldElementwise '%s' for wrong ElementAccessor type (boundary/bulk).\n", field_name_.c_str() );
208 unsigned int idx = n_components_ * elm.
idx();
211 typename Value::return_type
const &ref = Value::from_raw(this->r_value_, (
typename Value::element_type *)(&vec[idx]));
212 for(
unsigned int i=0; i< value_list.size(); i++) {
214 "value_list[%d] has wrong number of rows: %d; should match number of components: %d\n",
215 i,
Value(value_list[i]).n_rows(),this->value_.n_rows());
220 xprintf(
UsrErr,
"FieldElementwise is not implemented for discrete return types.\n");
226 template <
int spacedim,
class Value>
#define OLD_ASSERT_EQUAL(a, b)
virtual ~FieldElementwise()
std::shared_ptr< std::vector< typename Value::element_type > > data_
Raw buffer of n_entities rows each containing Value::size() doubles.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
static constexpr bool value
Dedicated class for storing path to input and output files.
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
bool is_constant_in_space_
Flag detects that field is only dependent on time.
const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm) override
bool set_time(const TimeStep &time) override
bool is_elemental() const
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
Space< spacedim >::Point Point
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data) override
bool is_boundary() const
We need this method after replacing Region by RegionIdx, and movinf RegionDB instance into particular...
unsigned int n_components_
Size of Value.
std::pair< double, double > limits_
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
Representation of one time step..
CheckResult
Return type of method that checked data stored in ElementDataCache (NaN values, limits)
Value value_
Last value, prevents passing large values (vectors) by value.
Class for representation SI units of Fields.
static const Input::Type::Record & get_input_type()
Implementation.
@ not_a_number
Some value(s) is set to NaN.
#define WarningOut()
Macro defining 'warning' record of log.
#define INSTANCE_ALL(field)
@ out_of_limits
Some value(s) is out of limits.
unsigned int idx() const
Return local idx of element in boundary / bulk part of element vector.
static std::shared_ptr< BaseMeshReader > get_reader(const FilePath &file_path)
static const Input::Type::Tuple & get_input_time_type(double lower_bound=-std::numeric_limits< double >::max(), double upper_bound=std::numeric_limits< double >::max())
void set_mesh(const Mesh *mesh, bool boundary_domain) override
void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list) override
FieldElementwise(unsigned int n_comp=0)
virtual unsigned int n_elements(bool boundary=false) const
Returns count of boundary or bulk elements.
#define DebugOut()
Macro defining 'debug' record of log.
double read_coef(Input::Iterator< std::string > unit_it) const