Flow123d  release_3.0.0-899-g9314a17
field.impl.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file field.impl.hh
15  * @brief
16  */
17 
18 #ifndef FIELD_IMPL_HH_
19 #define FIELD_IMPL_HH_
20 
21 #include <boost/foreach.hpp>
22 
23 #include "field.hh"
24 #include "field_algo_base.impl.hh"
25 #include "field_fe.hh"
26 #include "mesh/region.hh"
28 #include "input/accessors.hh"
29 #include "io/observe.hh"
30 #include "io/output_mesh.hh"
31 #include "io/output_element.hh"
32 
33 
34 /******************************************************************************************
35  * Implementation of Field<...>
36  */
37 
38 template<int spacedim, class Value>
40 : data_(std::make_shared<SharedData>())
41 {
42  // n_comp is nonzero only for variable size vectors Vector, VectorEnum, ..
43  // this invariant is kept also by n_comp setter
44  shared_->n_comp_ = (Value::NRows_ ? 0 : 1);
45  this->add_factory( std::make_shared<FactoryBase>() );
46 
47  this->multifield_ = false;
48 }
49 
50 
51 template<int spacedim, class Value>
52 Field<spacedim,Value>::Field(const string &name, bool bc)
53 : data_(std::make_shared<SharedData>())
54 
55 {
56  // n_comp is nonzero only for variable size vectors Vector, VectorEnum, ..
57  // this invariant is kept also by n_comp setter
58  shared_->n_comp_ = (Value::NRows_ ? 0 : 1);
59  shared_->bc_=bc;
60  this->name( name );
61  this->add_factory( std::make_shared<FactoryBase>() );
62  this->multifield_ = false;
63 }
64 
65 
66 
67 template<int spacedim, class Value>
68 Field<spacedim,Value>::Field(unsigned int component_index, string input_name, string name, bool bc)
69 : data_(std::make_shared<SharedData>())
70 {
71  // n_comp is nonzero only for variable size vectors Vector, VectorEnum, ..
72  // this invariant is kept also by n_comp setter
73  shared_->n_comp_ = (Value::NRows_ ? 0 : 1);
74  this->set_component_index(component_index);
75  this->name_ = (name=="") ? input_name : name;
76  this->shared_->input_name_ = input_name;
77  shared_->bc_ = bc;
78 
79  this->multifield_ = false;
80 }
81 
82 
83 template<int spacedim, class Value>
85 : FieldCommon(other),
86  data_(other.data_),
88  factories_(other.factories_)
89 {
90  if (other.no_check_control_field_)
91  no_check_control_field_ = make_shared<ControlField>(*other.no_check_control_field_);
92 
93  this->multifield_ = false;
94 }
95 
96 
97 template<int spacedim, class Value>
99 {
100  //ASSERT( flags().match(FieldFlag::input_copy) )(this->name())(other.name()).error("Try to assign to non-copy field from the field.");
101  ASSERT(other.shared_->mesh_).error("Must call set_mesh before assign to other field.\n");
102  ASSERT( !shared_->mesh_ || (shared_->mesh_==other.shared_->mesh_) ).error("Assignment between fields with different meshes.\n");
103 
104  // check for self assignement
105  if (&other == this) return *this;
106 
107  // class members derived from FieldCommon
108  shared_ = other.shared_;
109  shared_->is_fully_initialized_ = false;
111  last_time_ = other.last_time_;
115  this->multifield_ = false;
116 
117  // class members of Field class
118  data_ = other.data_;
119  factories_ = other.factories_;
121 
122  if (other.no_check_control_field_) {
123  no_check_control_field_ = make_shared<ControlField>(*other.no_check_control_field_);
124  }
125 
126  return *this;
127 }
128 
129 
130 
131 template<int spacedim, class Value>
133  return FieldBaseType::get_input_type_instance(shared_->input_element_selection_);
134 }
135 
136 
137 
138 template<int spacedim, class Value>
140  ASSERT(false).error("This method can't be used for Field");
141 
142  it::Array arr = it::Array( it::Integer() );
143  return arr;
144 }
145 
146 
147 
148 template<int spacedim, class Value>
150  const Field<spacedim, typename FieldValue<spacedim>::Enum > &control_field,
151  const vector<FieldEnum> &value_list) -> Field &
152 {
153  no_check_control_field_=std::make_shared<ControlField>(control_field);
154  shared_->no_check_values_=value_list;
155  return *this;
156 }
157 
158 template<int spacedim, class Value>
159 void Field<spacedim,Value>::set_mesh(const Mesh &in_mesh) {
160  // since we allow copy of fields before set_mesh is called
161  // we have to check that all copies set the same mesh
162  if (shared_->mesh_ && shared_->mesh_ != &in_mesh) {
163  THROW(ExcFieldMeshDifference() << EI_Field(name()) );
164  }
165 
166  shared_->mesh_ = &in_mesh;
167 
168  // initialize table if it is empty, we assume that the RegionDB is closed at this moment
169  region_fields_.resize( mesh()->region_db().size() );
170  RegionHistory init_history(history_length_limit_); // capacity
171  data_->region_history_.resize( mesh()->region_db().size(), init_history );
172 
173  if (no_check_control_field_) no_check_control_field_->set_mesh(in_mesh);
174 }
175 
176 
177 /*
178 template<int spacedim, class Value>
179 std::shared_ptr< typename Field<spacedim,Value>::FieldBaseType >
180 Field<spacedim,Value>::operator[] (Region reg)
181 {
182  ASSERT_LT(reg.idx(), this->region_fields_.size());
183  return this->region_fields_[reg.idx()];
184 }
185 */
186 
187 
188 template <int spacedim, class Value>
190  ASSERT(this->set_time_result_ != TimeStatus::unknown).error("Unknown time status.\n");
191  ASSERT_LT(reg.idx(), this->region_fields_.size());
192  FieldBasePtr region_field = this->region_fields_[reg.idx()];
193  return ( region_field && region_field->is_constant_in_space() );
194 }
195 
196 
197 template<int spacedim, class Value>
199  const RegionSet &domain,
200  FieldBasePtr field,
201  double time)
202 {
203  ASSERT_PTR(field).error("Null field pointer.\n");
204 
205  ASSERT_PTR( mesh() ).error("Null mesh pointer, set_mesh() has to be called before set_field().\n");
206  if (domain.size() == 0) return;
207 
208  ASSERT_EQ( field->n_comp() , n_comp());
209  field->set_mesh( mesh() , is_bc() );
210 
211  HistoryPoint hp = HistoryPoint(time, field);
212  for(const Region &reg: domain) {
213  RegionHistory &region_history = data_->region_history_[reg.idx()];
214  // insert hp into descending time sequence
215  ASSERT( region_history.size() == 0 || region_history[0].first < hp.first)(hp.first)(region_history[0].first)
216  .error("Can not insert smaller time then last time in field's history.\n");
217  region_history.push_front(hp);
218  }
220 }
221 
222 
223 
224 template<int spacedim, class Value>
226  const RegionSet &domain,
227  const Input::AbstractRecord &a_rec,
228  double time)
229 {
230  FieldAlgoBaseInitData init_data(input_name(), n_comp(), units(), limits(), flags());
231  set_field(domain, FieldBaseType::function_factory(a_rec, init_data), time);
232 }
233 
234 
235 
236 
237 template<int spacedim, class Value>
238 bool Field<spacedim, Value>::set_time(const TimeStep &time_step, LimitSide limit_side)
239 {
240  ASSERT_PTR( mesh() )( name() ).error("NULL mesh pointer of field with given name. set_mesh must be called before.\n");
241 
242  // Skip setting time if the new time is equal to current time of the field
243  // and if either the field is continuous in that time or the current limit side is same as the new one.
244  if (time_step.end() == last_time_) {
245  if ( ! is_jump_time() ||
246  limit_side == last_limit_side_) {
247  last_limit_side_ = limit_side;
248  return changed();
249  }
250  }
251 
252  last_time_=time_step.end();
253  last_limit_side_ = limit_side;
254 
255  // possibly update our control field
257  no_check_control_field_->set_time(time_step, limit_side);
258  }
259 
261 
262  // read all descriptors satisfying time.ge(input_time)
263  update_history(time_step);
265 
266  //
267  is_jump_time_=false;
268  // set time_step on all regions
269  // for regions that match type of the field domain
270  for(const Region &reg: mesh()->region_db().get_region_set("ALL") ) {
271  auto rh = data_->region_history_[reg.idx()];
272 
273  // skip regions with no matching BC flag
274  if (reg.is_boundary() != is_bc()) continue;
275 
276  // Check regions with empty history, possibly set default.
277  if ( rh.empty()) continue;
278 
279  double last_time_in_history = rh.front().first;
280  unsigned int history_size=rh.size();
281  unsigned int i_history;
282  ASSERT( time_step.ge(last_time_in_history) ).error("Setting field time back in history not fully supported yet!");
283 
284  // set history index
285  if ( time_step.gt(last_time_in_history) ) {
286  // in smooth time_step
287  i_history=0;
288  } else {
289  // time_step .eq. input_time; i.e. jump time
290  is_jump_time_=true;
291  if (limit_side == LimitSide::right) {
292  i_history=0;
293  } else {
294  i_history=1;
295  }
296  }
297  i_history=min(i_history, history_size - 1);
298  ASSERT(i_history >= 0).error("Empty field history.");
299  // possibly update field pointer
300 
301  auto new_ptr = rh.at(i_history).second;
302  if (new_ptr != region_fields_[reg.idx()]) {
303  region_fields_[reg.idx()]=new_ptr;
305  }
306  // let FieldBase implementation set the time
307  if ( new_ptr->set_time(time_step) ) set_time_result_ = TimeStatus::changed;
308 
309  }
310 
311  return changed();
312 }
313 
314 
315 template<int spacedim, class Value>
317  ASSERT( flags().match(FieldFlag::equation_input))(other.name().c_str())(this->name().c_str())
318  .error("Can not copy to the non-input field.");
319 
320  // do not use copy if the field have its own input
322  && this->shared_->input_list_.size() != 0 ) return;
323 
324  if (typeid(other) == typeid(*this)) {
325  auto const &other_field = dynamic_cast< Field<spacedim, Value> const &>(other);
326  this->operator=(other_field);
327  }
328 }
329 
330 
331 
332 template<int spacedim, class Value>
333 void Field<spacedim, Value>::field_output(std::shared_ptr<OutputTime> stream)
334 {
335  // currently we cannot output boundary fields
336  if (!is_bc()) {
337  const OutputTime::DiscreteSpace type = this->get_output_type();
338 
340  this->compute_field_data( type, stream);
341  }
342 }
343 
344 
345 template<int spacedim, class Value>
346 void Field<spacedim, Value>::observe_output(std::shared_ptr<Observe> observe)
347 {
348  typedef typename Value::element_type ElemType;
349 
350  if (observe->points().size() == 0) return;
351 
352  ElementDataCache<ElemType> &output_data = observe->prepare_compute_data<ElemType>(this->name(), this->time(),
353  (unsigned int)Value::NRows_, (unsigned int)Value::NCols_);
354 
355  unsigned int i_data=0;
356  for(const ObservePoint &o_point : observe->points()) {
357  unsigned int ele_index = o_point.element_idx();
358  const Value &obs_value =
359  Value( const_cast<typename Value::return_type &>(
360  this->value(o_point.global_coords(),
361  ElementAccessor<spacedim>(this->mesh(), ele_index)) ));
362  ASSERT_EQ(output_data.n_comp(), obs_value.n_rows()*obs_value.n_cols()).error();
363  output_data.store_value(i_data, obs_value.mem_ptr());
364  i_data++;
365  }
366 }
367 
368 
369 
370 template<int spacedim, class Value>
372 
373  FieldResult result_all = result_none;
374  for(Region &reg : region_set) {
375  auto f = region_fields_[reg.idx()];
376  if (f) {
377  FieldResult fr = f->field_result();
378  if (result_all == result_none) // first region
379  result_all = fr;
380  else if (fr != result_all)
381  result_all = result_other; // if results from individual regions are different
382  } else return result_none; // if field is undefined on any region of the region set
383  }
384 
385  if (result_all == result_constant && region_set.size() > 1)
386  return result_other; // constant result for individual regions could be non-constant on the whole region set
387 
388  return result_all;
389 
390 }
391 
392 
393 template<int spacedim, class Value>
395 {
396  int nrows = Value::NRows_;
397  int ncols = Value::NCols_;
398  string type = "Integer";
400  type = "Double";
401 
402  return fmt::format("{{ \"shape\": [ {}, {} ], \"type\": \"{}\", \"limit\": [ {}, {} ] }}",
403  nrows, ncols, type, this->limits().first, this->limits().second);
404 }
405 
406 
407 template<int spacedim, class Value>
409  ASSERT_PTR( mesh() ).error("Null mesh pointer, set_mesh() has to be called before.\n");
410 
411  // read input up to given time
412  double input_time;
413  if (shared_->input_list_.size() != 0) {
414  while( shared_->list_idx_ < shared_->input_list_.size()
415  && time.ge( input_time = time.read_time( shared_->input_list_[shared_->list_idx_].find<Input::Tuple>("time") ) ) ) {
416 
417  const Input::Record & actual_list_item = shared_->input_list_[shared_->list_idx_];
418  // get domain specification
419  RegionSet domain;
420  Input::Array domain_name_array;
421  unsigned int id;
422  if (actual_list_item.opt_val("region", domain_name_array)) {
423  std::vector<string> domain_names = mesh()->region_db().get_and_check_operands(domain_name_array);
424  domain = mesh()->region_db().union_set(domain_names);
425 
426  } else if (actual_list_item.opt_val("rid", id)) {
427  Region region;
428  try {
429  region = mesh()->region_db().find_id(id);
430  } catch (RegionDB::ExcUniqueRegionId &e) {
431  e << actual_list_item.ei_address();
432  throw;
433  }
434  if (region.is_valid())
435  domain.push_back(region);
436  else
437  THROW(RegionDB::ExcUnknownRegion() << RegionDB::EI_ID(id) );
438  } else {
439  THROW(ExcMissingDomain()
440  << actual_list_item.ei_address() );
441  }
442 
443  // get field instance
444  for(auto rit = factories_.rbegin() ; rit != factories_.rend(); ++rit) {
445  FieldBasePtr field_instance = (*rit)->create_field(actual_list_item, *this);
446  if (field_instance) // skip descriptors without related keys
447  {
448  // add to history
449  ASSERT_EQ( field_instance->n_comp() , n_comp());
450  field_instance->set_mesh( mesh() , is_bc() );
451  for(const Region &reg: domain) {
452  // if region history is empty, add new field
453  // or if region history is not empty and the input_time is higher, add new field
454  // otherwise (region history is not empty and the input_time is the same),
455  // rewrite the region field
456  if( data_->region_history_[reg.idx()].size() == 0
457  || data_->region_history_[reg.idx()].back().first < input_time)
458  {
459  data_->region_history_[reg.idx()].push_front(
460  HistoryPoint(input_time, field_instance));
461  //DebugOut() << "Update history" << print_var(this->name()) << print_var(reg.label()) << print_var(input_time);
462  }
463  else
464  {
465  data_->region_history_[reg.idx()].back() =
466  HistoryPoint(input_time, field_instance);
467  }
468  }
469  break;
470  }
471  }
472 
473  ++shared_->list_idx_;
474  }
475  }
476 }
477 
478 template<int spacedim, class Value>
480  ASSERT_PTR(mesh()).error("Null mesh pointer.");
481  //if (shared_->is_fully_initialized_) return;
482 
483  // check there are no empty field pointers, collect regions to be initialized from default value
484  RegionSet regions_to_init; // empty vector
485 
486  for(const Region &reg : mesh()->region_db().get_region_set("ALL") )
487  if (reg.is_boundary() == is_bc()) { // for regions that match type of the field domain
488  RegionHistory &rh = data_->region_history_[reg.idx()];
489  if ( rh.empty() || ! rh[0].second) // empty region history
490  {
491  // test if check is turned on and control field is FieldConst
492  if (no_check_control_field_ && no_check_control_field_->is_constant(reg) ) {
493  // get constant enum value
494  auto elm = ElementAccessor<spacedim>(mesh(), reg);
495  FieldEnum value = no_check_control_field_->value(elm.centre(),elm);
496  // check that the value is in the disable list
497  if ( std::find(shared_->no_check_values_.begin(), shared_->no_check_values_.end(), value)
498  != shared_->no_check_values_.end() )
499  continue; // the field is not needed on this region
500  }
501  if (shared_->input_default_ != "") { // try to use default
502  regions_to_init.push_back( reg );
503  } else {
504  xprintf(UsrErr, "Missing value of the input field '%s' ('%s') on region ID: %d label: %s.\n",
505  input_name().c_str(), name().c_str(), reg.id(), reg.label().c_str() );
506  }
507  }
508  }
509 
510  // possibly set from default value
511  if ( regions_to_init.size() ) {
512  std::string region_list;
513  // has to deal with fact that reader can not deal with input consisting of simple values
514  string default_input=input_default();
515  auto input_type = get_input_type().make_instance().first;
516  Input::ReaderToStorage reader( default_input, *input_type, Input::FileFormat::format_JSON );
517 
518  auto a_rec = reader.get_root_interface<Input::AbstractRecord>();
519  FieldAlgoBaseInitData init_data(input_name(), n_comp(), units(), limits(), flags());
520  auto field_ptr = FieldBaseType::function_factory( a_rec , init_data );
521  field_ptr->set_mesh( mesh(), is_bc() );
522  for(const Region &reg: regions_to_init) {
523  data_->region_history_[reg.idx()]
524  .push_front(HistoryPoint( 0.0, field_ptr) );
525  region_list+=" "+reg.label();
526  }
527  FieldCommon::messages_data_.push_back( MessageData(input_default(), name(), region_list) );
528 
529  }
530  //shared_->is_fully_initialized_ = true;
531 }
532 
533 
534 template<int spacedim, class Value>
535 void Field<spacedim,Value>::add_factory(const std::shared_ptr<FactoryBase> factory) {
536  factories_.push_back( factory );
537 }
538 
539 
540 template<int spacedim, class Value>
542  Input::AbstractRecord field_record;
543  if (rec.opt_val(field.input_name(), field_record)) {
544  FieldAlgoBaseInitData init_data(field.input_name(), field.n_comp(), field.units(), field.limits(), field.get_flags());
545  return FieldBaseType::function_factory(field_record, init_data );
546  }
547  else
548  return FieldBasePtr();
549 }
550 
551 
552 template<int spacedim, class Value>
554  return in_rec.find<Input::AbstractRecord>(input_name);
555 }
556 
557 
558 
559 
560 template<int spacedim, class Value>
562  if (! flags().match(FieldFlag::declare_input)) return;
563 
564  // check that times forms ascending sequence
565  double time,last_time=0.0;
566 
568  it != list.end();
569  ++it) {
570  for(auto rit = factories_.rbegin() ; rit != factories_.rend(); ++rit) {
571  if ( (*rit)->is_active_field_descriptor( (*it), this->input_name() ) ) {
572  shared_->input_list_.push_back( Input::Record( *it ) );
573  time = tg.read_time( it->find<Input::Tuple>("time") );
574  if (time < last_time) {
575  THROW( ExcNonascendingTime()
576  << EI_Time(time)
577  << EI_Field(input_name())
578  << it->ei_address());
579  }
580  last_time = time;
581 
582  break;
583  }
584  }
585  }
586 
587 }
588 
589 
590 
591 template<int spacedim, class Value>
592 void Field<spacedim,Value>::compute_field_data(OutputTime::DiscreteSpace space_type, std::shared_ptr<OutputTime> stream) {
593  typedef typename Value::element_type ElemType;
594 
595  std::shared_ptr<OutputMeshBase> output_mesh = stream->get_output_mesh_ptr();
596 
597  ASSERT(output_mesh);
598 
599  ElementDataCache<ElemType> &output_data = stream->prepare_compute_data<ElemType>(this->name(), space_type,
600  (unsigned int)Value::NRows_, (unsigned int)Value::NCols_);
601 
602  /* Copy data to array */
603  switch(space_type) {
606  unsigned int node_index = 0;
607  for(const auto & ele : *output_mesh )
608  {
609  std::vector<Space<3>::Point> vertices = ele.vertex_list();
610  for(unsigned int i=0; i < ele.n_nodes(); i++)
611  {
612  const Value &node_value =
613  Value( const_cast<typename Value::return_type &>(
614  this->value(vertices[i],
615  ElementAccessor<spacedim>(ele.orig_mesh(), ele.orig_element_idx()) ))
616  );
617  ASSERT_EQ(output_data.n_comp(), node_value.n_rows()*node_value.n_cols()).error();
618  output_data.store_value(node_index, node_value.mem_ptr() );
619  ++node_index;
620  }
621  }
622  }
623  break;
624  case OutputTime::ELEM_DATA: {
625  for(const auto & ele : *output_mesh )
626  {
627  unsigned int ele_index = ele.idx();
628  const Value &ele_value =
629  Value( const_cast<typename Value::return_type &>(
630  this->value(ele.centre(),
631  ElementAccessor<spacedim>(ele.orig_mesh(), ele.orig_element_idx()))
632  )
633  );
634  ASSERT_EQ(output_data.n_comp(), ele_value.n_rows()*ele_value.n_cols()).error();
635  output_data.store_value(ele_index, ele_value.mem_ptr() );
636  }
637  }
638  break;
640  std::shared_ptr< FieldFE<spacedim, Value> > field_fe_ptr = this->get_field_fe();
641 
642  if (field_fe_ptr) {
643  ElementDataCache<double> &native_output_data = stream->prepare_compute_data<double>(this->name(), space_type,
644  (unsigned int)Value::NRows_, (unsigned int)Value::NCols_);
645  field_fe_ptr->native_data_to_cache(native_output_data);
646  } else {
647  WarningOut().fmt("Field '{}' of native data space type is not of type FieldFE. Output will be skipped.\n", this->name());
648  }
649  }
650  break;
653  //should not happen
654  break;
655  }
656 
657  /* Set the last time */
658  stream->update_time(this->time());
659 
660 }
661 
662 
663 template<int spacedim, class Value>
664 std::shared_ptr< FieldFE<spacedim, Value> > Field<spacedim,Value>::get_field_fe() {
665  ASSERT_EQ_DBG(this->mesh()->region_db().size(), region_fields_.size()).error();
666  ASSERT(!this->shared_->bc_).error("FieldFE output of native data is supported only for bulk fields!");
667 
668  std::shared_ptr< FieldFE<spacedim, Value> > field_fe_ptr;
669 
670  bool is_fe = (region_fields_.size()>0); // indicate if FieldFE is defined on all bulk regions
671  is_fe = is_fe && region_fields_[1] && (typeid(*region_fields_[1]) == typeid(FieldFE<spacedim, Value>));
672  for (unsigned int i=3; i<2*this->mesh()->region_db().bulk_size(); i+=2)
673  if (!region_fields_[i] || (region_fields_[i] != region_fields_[1])) {
674  is_fe = false;
675  break;
676  }
677  if (is_fe) {
678  field_fe_ptr = std::dynamic_pointer_cast< FieldFE<spacedim, Value> >( region_fields_[1] );
679  }
680 
681  return field_fe_ptr;
682 }
683 
684 
685 
686 
687 #endif /* FIELD_IMPL_HH_ */
void check_initialized_region_fields_()
Definition: field.impl.hh:479
Classes for auxiliary output mesh.
Iterator< ValueType > begin() const
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:73
virtual bool is_active_field_descriptor(const Input::Record &in_rec, const std::string &input_name)
Definition: field.impl.hh:553
pair< double, FieldBasePtr > HistoryPoint
Pair: time, pointer to FieldBase instance.
Definition: field.hh:338
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Definition: asserts.hh:331
bool is_jump_time_
Accessor to input data conforming to declared Array.
Definition: accessors.hh:567
unsigned int size() const
Number of subfields that compose the multi-field.
Definition: multi_field.hh:206
MakeInstanceReturnType make_instance(std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
Implements TypeBase::make_instance.
FieldFlag::Flags get_flags() const
static const Input::Type::Instance & get_input_type_instance(Input::Type::Selection value_selection=Input::Type::Selection())
unsigned int bulk_size() const
Definition: region.cc:269
Reader for (slightly) modified input files.
std::string get_value_attribute() const override
Definition: field.impl.hh:394
OutputTime::DiscreteSpace get_output_type() const
std::string name_
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:83
std::string format(CStringRef format_str, ArgList args)
Definition: format.h:3141
unsigned int component_index_
std::pair< double, double > limits() const
Store data of one initialization message.
Definition: field_common.hh:88
void store_value(unsigned int idx, const T *value)
Definition: mesh.h:80
Iterator< Ret > find(const string &key) const
void update_history(const TimeStep &time)
Definition: field.impl.hh:408
Helper class that stores data of generic types.
Definition: type_generic.hh:89
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
void observe_output(std::shared_ptr< Observe > observe) override
Definition: field.impl.hh:346
double last_time_
RegionSet union_set(std::vector< std::string > set_names) const
Definition: region.cc:473
const std::string & input_default() const
bool set_time(const TimeStep &time, LimitSide limit_side) override
Definition: field.impl.hh:238
const RegionDB & region_db() const
Definition: mesh.h:147
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:346
void field_output(std::shared_ptr< OutputTime > stream) override
Definition: field.impl.hh:333
Class for declaration of the integral input data.
Definition: type_base.hh:490
Basic time management functionality for unsteady (and steady) solvers (class Equation).
virtual FieldBasePtr create_field(Input::Record rec, const FieldCommon &field)
Definition: field.impl.hh:541
IT::Instance get_input_type() override
Definition: field.impl.hh:132
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list) const
Definition: field.hh:403
Field()
Definition: field.impl.hh:39
Class for declaration of inputs sequences.
Definition: type_base.hh:346
std::shared_ptr< SharedData > data_
Definition: field.hh:352
static constexpr bool value
Definition: json.hpp:87
constexpr bool match(Mask mask) const
Definition: flag_array.hh:163
std::shared_ptr< SharedData > shared_
IteratorBase end() const
EI_Address ei_address() const
Definition: accessors.cc:178
bool opt_val(const string &key, Ret &value) const
double time() const
std::shared_ptr< FieldFE< spacedim, Value > > get_field_fe()
Definition: field.impl.hh:664
const std::string & name() const
bool ge(double other_time) const
unsigned int FieldEnum
Definition: field_values.hh:56
FieldFlag::Flags & flags()
Region find_id(unsigned int id, unsigned int dim) const
Definition: region.cc:181
const UnitSI & units() const
std::vector< std::string > get_and_check_operands(const Input::Array &operands) const
Definition: region.cc:313
T get_root_interface() const
Returns the root accessor.
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
IT::Array get_multifield_input_type() override
Definition: field.impl.hh:139
#define xprintf(...)
Definition: system.hh:92
std::shared_ptr< ControlField > no_check_control_field_
Definition: field.hh:362
static const unsigned int N_DISCRETE_SPACES
Definition: output_time.hh:103
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
Definition: field.hh:389
LimitSide last_limit_side_
double end() const
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
std::vector< FieldBasePtr > region_fields_
Definition: field.hh:367
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:459
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
FieldResult
FieldResult field_result(RegionSet region_set) const override
Indicates special field states.
Definition: field.impl.hh:371
Definition: system.hh:64
bool is_jump_time()
static std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > function_factory(const Input::AbstractRecord &rec, const struct FieldAlgoBaseInitData &init_data)
std::shared_ptr< FieldBaseType > FieldBasePtr
Definition: field.hh:87
std::vector< std::shared_ptr< FactoryBase > > factories_
Definition: field.hh:369
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
Definition: asserts.hh:335
auto disable_where(const Field< spacedim, typename FieldValue< spacedim >::Enum > &control_field, const vector< FieldEnum > &value_list) -> Field &
Definition: field.impl.hh:149
static std::vector< MessageData > messages_data_
Vector of data of initialization messages.
boost::circular_buffer< HistoryPoint > RegionHistory
Nearest history of one region.
Definition: field.hh:340
void set_component_index(unsigned int idx)
bool is_constant(Region reg) override
Definition: field.impl.hh:189
void add_factory(std::shared_ptr< FactoryBase > factory)
Definition: field.impl.hh:535
void set_field(const RegionSet &domain, FieldBasePtr field, double time=0.0)
Definition: field.impl.hh:198
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than)
Definition: asserts.hh:295
Class OutputElement and its iterator OutputElementIterator on the output mesh.
bool gt(double other_time) const
const Mesh * mesh() const
#define WarningOut()
Macro defining &#39;warning&#39; record of log.
Definition: logger.hh:246
FieldCommon & name(const string &name)
unsigned int n_comp() const
bool changed() const
void set_mesh(const Mesh &mesh) override
Definition: field.impl.hh:159
void set_history_changed()
Accessor to the data with type Type::Tuple.
Definition: accessors.hh:412
bool is_valid() const
Returns false if the region has undefined/invalid value.
Definition: region.hh:78
const std::string & input_name() const
void copy_from(const FieldCommon &other) override
Definition: field.impl.hh:316
unsigned int n_comp() const
static constexpr Mask equation_input
The field is data parameter of the owning equation. (default on)
Definition: field_flag.hh:33
bool is_bc() const
void compute_field_data(OutputTime::DiscreteSpace space_type, std::shared_ptr< OutputTime > stream)
Definition: field.impl.hh:592
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
Representation of one time step..
TimeStatus set_time_result_
Field & operator=(const Field &other)
Definition: field.impl.hh:98
static const unsigned int history_length_limit_
LimitSide
Definition: field_common.hh:60
void set_input_list(const Input::Array &list, const TimeGovernor &tg) override
Definition: field.impl.hh:561
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
Definition: asserts.hh:327
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on) ...
Definition: field_flag.hh:35
Definition: field.hh:56
unsigned int idx() const
Returns a global index of the region.
Definition: region.hh:82