79 template <
class Value>
106 "Do not support output of vectors with fixed size >3. Field: %s\n",
114 THROW(OutputTime::ExcOutputVariableVector() << OutputTime::EI_FieldName(this->
field_name));
132 delete[] this->
data_;
142 void print(ostream &out_stream,
unsigned int idx)
override 146 for(ElemType *ptr = ptr_begin; ptr < ptr_begin +
n_elem_; ptr++ )
147 out_stream << *ptr <<
" ";
159 for(
unsigned int idx = 0; idx < this->
n_values; idx++) {
161 for(ElemType *ptr = ptr_begin; ptr < ptr_begin +
n_elem_; ptr++ )
162 out_stream << *ptr <<
" ";
170 operate(idx, value, [](ElemType& raw, ElemType val) {raw = val;});
176 void add(
unsigned int idx,
const Value& value) {
177 operate(idx, value, [](ElemType& raw, ElemType val) {raw += val;});
184 operate(idx,
val_aux, [](ElemType& raw, ElemType val) {raw = 0;});
190 void normalize(
unsigned int idx,
unsigned int divisor) {
191 operate(idx,
val_aux, [divisor](ElemType& raw, ElemType val) {raw /= divisor;});
199 template <
class Func>
200 void operate(
unsigned int idx,
const Value &val,
const Func& func) {
203 for(
unsigned int i_row = 0; i_row < this->
n_rows; i_row++) {
204 for(
unsigned int i_col = 0; i_col < this->
n_cols; i_col++) {
205 if (i_row < val.n_rows() && i_col < val.n_cols())
206 func(*ptr, val(i_row, i_col));
225 typename Value::return_type
aux;
248 template<
int spacedim,
class Value>
253 if (output_names.find(multi_field.
name()) == output_names.end())
return;
256 if (! flags) flags = 1 << type;
257 for (
unsigned long index=0; index < multi_field.
size(); index++)
258 for(
unsigned int ids=0; ids < N_DISCRETE_SPACES; ids++)
259 if (flags & (1 << ids))
260 this->compute_field_data(
DiscreteSpace(ids), multi_field[index] );
265 template<
int spacedim,
class Value>
270 if (output_names.find(field_ref.
name()) == output_names.end())
return;
273 if (! flags) flags = 1 << type;
274 for(
unsigned int ids=0; ids < N_DISCRETE_SPACES; ids++)
275 if (flags & (1 << ids))
281 template<
int spacedim,
class Value>
286 if( this->rank != 0) {
294 OLD_ASSERT(!this->_mesh || this->_mesh==field_mesh,
"Overwriting non-null mesh pointer.\n");
295 this->_mesh=field_mesh;
296 OLD_ASSERT(this->_mesh,
"Null mesh pointer.\n");
300 size[NODE_DATA]=this->_mesh->n_nodes();
301 size[ELEM_DATA]=this->_mesh->n_elements();
302 size[CORNER_DATA]=this->_mesh->n_corners();
304 auto &od_vec=this->output_data_vec_[space_type];
305 auto it=std::find_if(od_vec.begin(), od_vec.end(),
307 if (
it == od_vec.end() ) {
308 od_vec.push_back( std::make_shared<
OutputData<Value> >(field, size[space_type]) );
320 for(
unsigned int idx=0; idx < output_data.
n_values; idx++)
321 output_data.
zero(idx);
326 Node * node = ele->node[i_node];
327 unsigned int ele_index = ele.index();
328 unsigned int node_index = this->_mesh->node_vector.index(ele->node[i_node]);
330 const Value &node_value =
331 Value( const_cast<typename Value::return_type &>(
334 output_data.
add(node_index, node_value);
341 for(
unsigned int idx=0; idx < output_data.
n_values; idx++)
346 unsigned int corner_index=0;
349 Node * node = ele->node[i_node];
350 unsigned int ele_index = ele.index();
352 const Value &node_value =
353 Value( const_cast<typename Value::return_type &>(
364 unsigned int ele_index = ele.index();
365 const Value &ele_value =
366 Value( const_cast<typename Value::return_type &>(
367 field.
value(ele->centre(),
377 if(this->time < field.
time()) {
378 this->time = field.
time();
Common abstract parent of all Field<...> classes.
Common parent class for templated OutputData.
#define FOR_ELEMENT_NODES(i, j)
void operate(unsigned int idx, const Value &val, const Func &func)
std::string output_field_name
void print(ostream &out_stream, unsigned int idx) override
unsigned int size() const
Number of subfields that compose the multi-field.
#define FOR_ELEMENTS(_mesh_, __i)
Class template representing a field with values dependent on: point, element, and region...
void register_data(const DiscreteSpace type, MultiField< spacedim, Value > &multi_field)
Generic method for registering output data stored in MultiField.
~OutputData()
Destructor of OutputData.
This class is used for storing data that are copied from field.
void zero(unsigned int idx)
OutputData(const FieldCommon &field, unsigned int size)
Constructor of templated OutputData.
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
Value::element_type ElemType
unsigned int DiscreteSpaceFlags
void add(unsigned int idx, const Value &value)
#define OLD_ASSERT_LESS(a, b)
void normalize(unsigned int idx, unsigned int divisor)
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
void compute_field_data(DiscreteSpace type, Field< spacedim, Value > &field)
const Mesh * mesh() const
FieldCommon & name(const string &name)
std::shared_ptr< OutputDataBase > OutputDataPtr
Class for representation of a vector of fields of the same physical quantity.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
void store_value(unsigned int idx, const Value &value)
void print_all(ostream &out_stream) override
Print all data stored in output data.