Flow123d  release_2.2.0-914-gf1a3a4f
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  //OLD_ASSERT( flags().match( FieldFlag::input_copy ) , "Try to assign to non-copy field '%s' from the field '%s'.", this->name().c_str(), other.name().c_str());
101  OLD_ASSERT(other.shared_->mesh_, "Must call set_mesh before assign to other field.\n");
102  OLD_ASSERT( !shared_->mesh_ || (shared_->mesh_==other.shared_->mesh_),
103  "Assignment between fields with different meshes.\n");
104 
105  // check for self assignement
106  if (&other == this) return *this;
107 
108  // class members derived from FieldCommon
109  shared_ = other.shared_;
110  shared_->is_fully_initialized_ = false;
112  last_time_ = other.last_time_;
116  this->multifield_ = false;
117 
118  // class members of Field class
119  data_ = other.data_;
120  factories_ = other.factories_;
122 
123  if (other.no_check_control_field_) {
124  no_check_control_field_ = make_shared<ControlField>(*other.no_check_control_field_);
125  }
126 
127  return *this;
128 }
129 
130 
131 
132 template<int spacedim, class Value>
134  return FieldBaseType::get_input_type_instance(shared_->input_element_selection_);
135 }
136 
137 
138 
139 template<int spacedim, class Value>
141  OLD_ASSERT(false, "This method can't be used for Field");
142 
143  it::Array arr = it::Array( it::Integer() );
144  return arr;
145 }
146 
147 
148 
149 template<int spacedim, class Value>
151  const Field<spacedim, typename FieldValue<spacedim>::Enum > &control_field,
152  const vector<FieldEnum> &value_list) -> Field &
153 {
154  no_check_control_field_=std::make_shared<ControlField>(control_field);
155  shared_->no_check_values_=value_list;
156  return *this;
157 }
158 
159 template<int spacedim, class Value>
160 void Field<spacedim,Value>::set_mesh(const Mesh &in_mesh) {
161  // since we allow copy of fields before set_mesh is called
162  // we have to check that all copies set the same mesh
163  if (shared_->mesh_ && shared_->mesh_ != &in_mesh) {
164  THROW(ExcFieldMeshDifference() << EI_Field(name()) );
165  }
166 
167  shared_->mesh_ = &in_mesh;
168 
169  // initialize table if it is empty, we assume that the RegionDB is closed at this moment
170  region_fields_.resize( mesh()->region_db().size() );
171  RegionHistory init_history(history_length_limit_); // capacity
172  data_->region_history_.resize( mesh()->region_db().size(), init_history );
173 
174  if (no_check_control_field_) no_check_control_field_->set_mesh(in_mesh);
175 }
176 
177 
178 /*
179 template<int spacedim, class Value>
180 std::shared_ptr< typename Field<spacedim,Value>::FieldBaseType >
181 Field<spacedim,Value>::operator[] (Region reg)
182 {
183  OLD_ASSERT_LESS(reg.idx(), this->region_fields_.size());
184  return this->region_fields_[reg.idx()];
185 }
186 */
187 
188 
189 template <int spacedim, class Value>
191  OLD_ASSERT(this->set_time_result_ != TimeStatus::unknown, "Unknown time status.\n");
192  OLD_ASSERT_LESS(reg.idx(), this->region_fields_.size());
193  FieldBasePtr region_field = this->region_fields_[reg.idx()];
194  return (region_field && typeid(*region_field) == typeid(FieldConstant<spacedim, Value>));
195 }
196 
197 
198 template<int spacedim, class Value>
200  const RegionSet &domain,
201  FieldBasePtr field,
202  double time)
203 {
204  OLD_ASSERT(field, "Null field pointer.\n");
205 
206  OLD_ASSERT( mesh(), "Null mesh pointer, set_mesh() has to be called before set_field().\n");
207  if (domain.size() == 0) return;
208 
209  OLD_ASSERT_EQUAL( field->n_comp() , n_comp());
210  field->set_mesh( mesh() , is_bc() );
211 
212  HistoryPoint hp = HistoryPoint(time, field);
213  for(const Region &reg: domain) {
214  RegionHistory &region_history = data_->region_history_[reg.idx()];
215  // insert hp into descending time sequence
216  OLD_ASSERT( region_history.size() == 0 || region_history[0].first < hp.first, "Can not insert smaller time %g then last time %g in field's history.\n",
217  hp.first, region_history[0].first );
218  region_history.push_front(hp);
219  }
221 }
222 
223 
224 
225 template<int spacedim, class Value>
227  const RegionSet &domain,
228  const Input::AbstractRecord &a_rec,
229  double time)
230 {
231  FieldAlgoBaseInitData init_data(input_name(), n_comp(), units(), limits(), flags());
232  set_field(domain, FieldBaseType::function_factory(a_rec, init_data), time);
233 }
234 
235 
236 
237 
238 template<int spacedim, class Value>
239 bool Field<spacedim, Value>::set_time(const TimeStep &time_step, LimitSide limit_side)
240 {
241  OLD_ASSERT( mesh() , "NULL mesh pointer of field '%s'. set_mesh must be called before.\n",name().c_str());
242 
243  // Skip setting time if the new time is equal to current time of the field
244  // and if either the field is continuous in that time or the current limit side is same as the new one.
245  if (time_step.end() == last_time_) {
246  if ( ! is_jump_time() ||
247  limit_side == last_limit_side_) {
248  last_limit_side_ = limit_side;
249  return changed();
250  }
251  }
252 
253  last_time_=time_step.end();
254  last_limit_side_ = limit_side;
255 
256  // possibly update our control field
258  no_check_control_field_->set_time(time_step, limit_side);
259  }
260 
262 
263  // read all descriptors satisfying time.ge(input_time)
264  update_history(time_step);
266 
267  //
268  is_jump_time_=false;
269  // set time_step on all regions
270  // for regions that match type of the field domain
271  for(const Region &reg: mesh()->region_db().get_region_set("ALL") ) {
272  auto rh = data_->region_history_[reg.idx()];
273 
274  // skip regions with no matching BC flag
275  if (reg.is_boundary() != is_bc()) continue;
276 
277  // Check regions with empty history, possibly set default.
278  if ( rh.empty()) continue;
279 
280  double last_time_in_history = rh.front().first;
281  unsigned int history_size=rh.size();
282  unsigned int i_history;
283  OLD_ASSERT(time_step.ge(last_time_in_history), "Setting field time back in history not fully supported yet!");
284 
285  // set history index
286  if ( time_step.gt(last_time_in_history) ) {
287  // in smooth time_step
288  i_history=0;
289  } else {
290  // time_step .eq. input_time; i.e. jump time
291  is_jump_time_=true;
292  if (limit_side == LimitSide::right) {
293  i_history=0;
294  } else {
295  i_history=1;
296  }
297  }
298  i_history=min(i_history, history_size - 1);
299  OLD_ASSERT(i_history >= 0, "Empty field history.");
300  // possibly update field pointer
301 
302  auto new_ptr = rh.at(i_history).second;
303  if (new_ptr != region_fields_[reg.idx()]) {
304  region_fields_[reg.idx()]=new_ptr;
306  }
307  // let FieldBase implementation set the time
308  if ( new_ptr->set_time(time_step) ) set_time_result_ = TimeStatus::changed;
309 
310  }
311 
312  return changed();
313 }
314 
315 
316 template<int spacedim, class Value>
318  ASSERT( flags().match(FieldFlag::equation_input))(other.name().c_str())(this->name().c_str())
319  .error("Can not copy to the non-input field.");
320 
321  // do not use copy if the field have its own input
323  && this->shared_->input_list_.size() != 0 ) return;
324 
325  if (typeid(other) == typeid(*this)) {
326  auto const &other_field = dynamic_cast< Field<spacedim, Value> const &>(other);
327  this->operator=(other_field);
328  }
329 }
330 
331 
332 
333 template<int spacedim, class Value>
334 void Field<spacedim, Value>::field_output(std::shared_ptr<OutputTime> stream)
335 {
336  // currently we cannot output boundary fields
337  if (!is_bc()) {
338  const OutputTime::DiscreteSpace type = this->get_output_type();
339 
341  this->compute_field_data( type, stream);
342  }
343 }
344 
345 
346 template<int spacedim, class Value>
347 void Field<spacedim, Value>::observe_output(std::shared_ptr<Observe> observe)
348 {
349  typedef typename Value::element_type ElemType;
350 
351  if (observe->points().size() == 0) return;
352 
353  ElementDataCache<ElemType> &output_data = observe->prepare_compute_data<ElemType>(this->name(), this->time(),
354  (unsigned int)Value::NRows_, (unsigned int)Value::NCols_);
355 
356  unsigned int i_data=0;
357  for(const ObservePoint &o_point : observe->points()) {
358  unsigned int ele_index = o_point.element_idx();
359  const Value &obs_value =
360  Value( const_cast<typename Value::return_type &>(
361  this->value(o_point.global_coords(),
362  ElementAccessor<spacedim>(this->mesh(), ele_index, false)) ));
363  ASSERT_EQ(output_data.n_elem(), obs_value.n_rows()*obs_value.n_cols()).error();
364  output_data.store_value(i_data, obs_value.mem_ptr());
365  i_data++;
366  }
367 }
368 
369 
370 
371 template<int spacedim, class Value>
373 
374  FieldResult result_all = result_none;
375  for(Region &reg : region_set) {
376  auto f = region_fields_[reg.idx()];
377  if (f) {
378  FieldResult fr = f->field_result();
379  if (result_all == result_none) // first region
380  result_all = fr;
381  else if (fr != result_all)
382  result_all = result_other; // if results from individual regions are different
383  } else return result_none; // if field is undefined on any region of the region set
384  }
385 
386  if (result_all == result_constant && region_set.size() > 1)
387  return result_other; // constant result for individual regions could be non-constant on the whole region set
388 
389  return result_all;
390 
391 }
392 
393 
394 template<int spacedim, class Value>
396 {
397  int nrows = Value::NRows_;
398  int ncols = Value::NCols_;
399  string type = "Integer";
401  type = "Double";
402 
403  return fmt::format("{{ \"shape\": [ {}, {} ], \"type\": \"{}\", \"limit\": [ {}, {} ] }}",
404  nrows, ncols, type, this->limits().first, this->limits().second);
405 }
406 
407 
408 template<int spacedim, class Value>
410  OLD_ASSERT( mesh(), "Null mesh pointer, set_mesh() has to be called before.\n");
411 
412  // read input up to given time
413  double input_time;
414  if (shared_->input_list_.size() != 0) {
415  while( shared_->list_idx_ < shared_->input_list_.size()
416  && time.ge( input_time = shared_->input_list_[shared_->list_idx_].val<double>("time") ) ) {
417 
418  const Input::Record & actual_list_item = shared_->input_list_[shared_->list_idx_];
419  // get domain specification
420  RegionSet domain;
421  Input::Array domain_name_array;
422  unsigned int id;
423  if (actual_list_item.opt_val("region", domain_name_array)) {
424  std::vector<string> domain_names = mesh()->region_db().get_and_check_operands(domain_name_array);
425  domain = mesh()->region_db().union_set(domain_names);
426 
427  } else if (actual_list_item.opt_val("rid", id)) {
428  Region region;
429  try {
430  region = mesh()->region_db().find_id(id);
431  } catch (RegionDB::ExcUniqueRegionId &e) {
432  e << actual_list_item.ei_address();
433  throw;
434  }
435  if (region.is_valid())
436  domain.push_back(region);
437  else
438  THROW(RegionDB::ExcUnknownRegion() << RegionDB::EI_ID(id) );
439  } else {
440  THROW(ExcMissingDomain()
441  << actual_list_item.ei_address() );
442  }
443 
444  // get field instance
445  for(auto rit = factories_.rbegin() ; rit != factories_.rend(); ++rit) {
446  FieldBasePtr field_instance = (*rit)->create_field(actual_list_item, *this);
447  if (field_instance) // skip descriptors without related keys
448  {
449  // add to history
450  OLD_ASSERT_EQUAL( field_instance->n_comp() , n_comp());
451  field_instance->set_mesh( mesh() , is_bc() );
452  for(const Region &reg: domain) {
453  data_->region_history_[reg.idx()].push_front(
454  HistoryPoint(input_time, field_instance)
455  );
456  //DebugOut() << "Update history" << print_var(this->name()) <<print_var(reg.label()) << print_var(input_time);
457  }
458  break;
459  }
460  }
461 
462  ++shared_->list_idx_;
463  }
464  }
465 }
466 
467 template<int spacedim, class Value>
469  OLD_ASSERT(mesh(), "Null mesh pointer.");
470  //if (shared_->is_fully_initialized_) return;
471 
472  // check there are no empty field pointers, collect regions to be initialized from default value
473  RegionSet regions_to_init; // empty vector
474 
475  for(const Region &reg : mesh()->region_db().get_region_set("ALL") )
476  if (reg.is_boundary() == is_bc()) { // for regions that match type of the field domain
477  RegionHistory &rh = data_->region_history_[reg.idx()];
478  if ( rh.empty() || ! rh[0].second) // empty region history
479  {
480  // test if check is turned on and control field is FieldConst
481  if (no_check_control_field_ && no_check_control_field_->is_constant(reg) ) {
482  // get constant enum value
483  auto elm = ElementAccessor<spacedim>(mesh(), reg);
484  FieldEnum value = no_check_control_field_->value(elm.centre(),elm);
485  // check that the value is in the disable list
486  if ( std::find(shared_->no_check_values_.begin(), shared_->no_check_values_.end(), value)
487  != shared_->no_check_values_.end() )
488  continue; // the field is not needed on this region
489  }
490  if (shared_->input_default_ != "") { // try to use default
491  regions_to_init.push_back( reg );
492  } else {
493  xprintf(UsrErr, "Missing value of the input field '%s' ('%s') on region ID: %d label: %s.\n",
494  input_name().c_str(), name().c_str(), reg.id(), reg.label().c_str() );
495  }
496  }
497  }
498 
499  // possibly set from default value
500  if ( regions_to_init.size() ) {
501  std::string region_list;
502  // has to deal with fact that reader can not deal with input consisting of simple values
503  string default_input=input_default();
504  auto input_type = get_input_type().make_instance().first;
505  Input::ReaderToStorage reader( default_input, *input_type, Input::FileFormat::format_JSON );
506 
507  auto a_rec = reader.get_root_interface<Input::AbstractRecord>();
508  FieldAlgoBaseInitData init_data(input_name(), n_comp(), units(), limits(), flags());
509  auto field_ptr = FieldBaseType::function_factory( a_rec , init_data );
510  field_ptr->set_mesh( mesh(), is_bc() );
511  for(const Region &reg: regions_to_init) {
512  data_->region_history_[reg.idx()]
513  .push_front(HistoryPoint( 0.0, field_ptr) );
514  region_list+=" "+reg.label();
515  }
516  FieldCommon::messages_data_.push_back( MessageData(input_default(), name(), region_list) );
517 
518  }
519  //shared_->is_fully_initialized_ = true;
520 }
521 
522 
523 template<int spacedim, class Value>
524 void Field<spacedim,Value>::add_factory(const std::shared_ptr<FactoryBase> factory) {
525  factories_.push_back( factory );
526 }
527 
528 
529 template<int spacedim, class Value>
531  Input::AbstractRecord field_record;
532  if (rec.opt_val(field.input_name(), field_record)) {
533  FieldAlgoBaseInitData init_data(field.input_name(), field.n_comp(), field.units(), field.limits(), field.get_flags());
534  return FieldBaseType::function_factory(field_record, init_data );
535  }
536  else
537  return FieldBasePtr();
538 }
539 
540 
541 template<int spacedim, class Value>
543  return in_rec.find<Input::AbstractRecord>(input_name);
544 }
545 
546 
547 
548 
549 template<int spacedim, class Value>
551  if (! flags().match(FieldFlag::declare_input)) return;
552 
553  // check that times forms ascending sequence
554  double time,last_time=0.0;
555 
557  it != list.end();
558  ++it) {
559  for(auto rit = factories_.rbegin() ; rit != factories_.rend(); ++rit) {
560  if ( (*rit)->is_active_field_descriptor( (*it), this->input_name() ) ) {
561  shared_->input_list_.push_back( Input::Record( *it ) );
562  time = it->val<double>("time");
563  if (time < last_time) {
564  THROW( ExcNonascendingTime()
565  << EI_Time(time)
566  << EI_Field(input_name())
567  << it->ei_address());
568  }
569  last_time = time;
570 
571  break;
572  }
573  }
574  }
575 
576 }
577 
578 
579 
580 template<int spacedim, class Value>
581 void Field<spacedim,Value>::compute_field_data(OutputTime::DiscreteSpace space_type, std::shared_ptr<OutputTime> stream) {
582  typedef typename Value::element_type ElemType;
583 
584  std::shared_ptr<OutputMeshBase> output_mesh = stream->get_output_mesh_ptr();
585 
586  if ( !output_mesh ) {
587  // Output mesh is not constructed for serial output and rank > 0
588  return;
589  }
590 
591  ElementDataCache<ElemType> &output_data = stream->prepare_compute_data<ElemType>(this->name(), space_type,
592  (unsigned int)Value::NRows_, (unsigned int)Value::NCols_);
593 
594  /* Copy data to array */
595  switch(space_type) {
596  case OutputTime::NODE_DATA: {
597  // set output data to zero
598  vector<unsigned int> count(output_data.n_values(), 0);
599  for(unsigned int idx=0; idx < output_data.n_values(); idx++)
600  output_data.zero(idx);
601 
602  for(const auto & ele : *output_mesh )
603  {
604  std::vector<Space<3>::Point> vertices = ele.vertex_list();
605  for(unsigned int i=0; i < ele.n_nodes(); i++)
606  {
607  unsigned int node_index = ele.node_index(i);
608  const Value &node_value =
609  Value( const_cast<typename Value::return_type &>(
610  this->value(vertices[i],
611  ElementAccessor<spacedim>(ele.orig_mesh(), ele.orig_element_idx(),false) ))
612  );
613  output_data.add(node_index, node_value.mem_ptr() );
614  count[node_index]++;
615  }
616  }
617 
618  // Compute mean values at nodes
619  for(unsigned int idx=0; idx < output_data.n_values(); idx++)
620  output_data.normalize(idx, count[idx]);
621  }
622  break;
624  for(const auto & ele : *output_mesh )
625  {
626  std::vector<Space<3>::Point> vertices = ele.vertex_list();
627  for(unsigned int i=0; i < ele.n_nodes(); i++)
628  {
629  unsigned int node_index = ele.node_index(i);
630  const Value &node_value =
631  Value( const_cast<typename Value::return_type &>(
632  this->value(vertices[i],
633  ElementAccessor<spacedim>(ele.orig_mesh(), ele.orig_element_idx(),false) ))
634  );
635  ASSERT_EQ(output_data.n_elem(), node_value.n_rows()*node_value.n_cols()).error();
636  output_data.store_value(node_index, node_value.mem_ptr() );
637  }
638  }
639  }
640  break;
641  case OutputTime::ELEM_DATA: {
642  for(const auto & ele : *output_mesh )
643  {
644  unsigned int ele_index = ele.idx();
645  const Value &ele_value =
646  Value( const_cast<typename Value::return_type &>(
647  this->value(ele.centre(),
648  ElementAccessor<spacedim>(ele.orig_mesh(), ele.orig_element_idx(),false))
649  )
650  );
651  ASSERT_EQ(output_data.n_elem(), ele_value.n_rows()*ele_value.n_cols()).error();
652  output_data.store_value(ele_index, ele_value.mem_ptr() );
653  }
654  }
655  break;
657  std::shared_ptr< FieldFE<spacedim, Value> > field_fe_ptr = this->get_field_fe();
658 
659  if (field_fe_ptr) {
660  ElementDataCache<double> &native_output_data = stream->prepare_compute_data<double>(this->name(), space_type,
661  (unsigned int)Value::NRows_, (unsigned int)Value::NCols_);
662  field_fe_ptr->fill_data_to_cache(native_output_data);
663  } else {
664  WarningOut().fmt("Field '{}' of native data space type is not of type FieldFE. Output will be skipped.\n", this->name());
665  }
666  }
667  break;
670  //should not happen
671  break;
672  }
673 
674  /* Set the last time */
675  stream->update_time(this->time());
676 
677 }
678 
679 
680 template<int spacedim, class Value>
681 std::shared_ptr< FieldFE<spacedim, Value> > Field<spacedim,Value>::get_field_fe() {
682  ASSERT_EQ_DBG(this->mesh()->region_db().size(), region_fields_.size()).error();
683  ASSERT(!this->shared_->bc_).error("FieldFE output of native data is supported only for bulk fields!");
684 
685  std::shared_ptr< FieldFE<spacedim, Value> > field_fe_ptr;
686 
687  bool is_fe = (region_fields_.size()>0); // indicate if FieldFE is defined on all bulk regions
688  is_fe = is_fe && region_fields_[1] && (typeid(*region_fields_[1]) == typeid(FieldFE<spacedim, Value>));
689  for (unsigned int i=3; i<2*this->mesh()->region_db().bulk_size(); i+=2)
690  if (!region_fields_[i] || (region_fields_[i] != region_fields_[1])) {
691  is_fe = false;
692  break;
693  }
694  if (is_fe) {
695  field_fe_ptr = std::dynamic_pointer_cast< FieldFE<spacedim, Value> >( region_fields_[1] );
696  }
697 
698  return field_fe_ptr;
699 }
700 
701 
702 
703 
704 #endif /* FIELD_IMPL_HH_ */
void check_initialized_region_fields_()
Definition: field.impl.hh:468
Classes for auxiliary output mesh.
Iterator< ValueType > begin() const
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:60
virtual bool is_active_field_descriptor(const Input::Record &in_rec, const std::string &input_name)
Definition: field.impl.hh:542
pair< double, FieldBasePtr > HistoryPoint
Pair: time, pointer to FieldBase instance.
Definition: field.hh:317
#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:174
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:268
RegionSet union_set(std::vector< string > set_names) const
Definition: region.cc:472
Reader for (slightly) modified input files.
std::string get_value_attribute() const override
Definition: field.impl.hh:395
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:62
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:75
void store_value(unsigned int idx, const T *value)
Definition: mesh.h:99
Iterator< Ret > find(const string &key) const
void update_history(const TimeStep &time)
Definition: field.impl.hh:409
Helper class that stores data of generic types.
Definition: type_generic.hh:89
void set_input_list(const Input::Array &list) override
Definition: field.impl.hh:550
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
void observe_output(std::shared_ptr< Observe > observe) override
Definition: field.impl.hh:347
double last_time_
const std::string & input_default() const
bool set_time(const TimeStep &time, LimitSide limit_side) override
Definition: field.impl.hh:239
const RegionDB & region_db() const
Definition: mesh.h:170
#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:334
Class for declaration of the integral input data.
Definition: type_base.hh:489
virtual FieldBasePtr create_field(Input::Record rec, const FieldCommon &field)
Definition: field.impl.hh:530
IT::Instance get_input_type() override
Definition: field.impl.hh:133
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:382
Field()
Definition: field.impl.hh:39
Class for declaration of inputs sequences.
Definition: type_base.hh:345
std::shared_ptr< SharedData > data_
Definition: field.hh:331
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
void add(unsigned int idx, const T *value)
EI_Address ei_address() const
Definition: accessors.cc:178
#define OLD_ASSERT(...)
Definition: global_defs.h:131
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:681
const std::string & name() const
bool ge(double other_time) const
unsigned int FieldEnum
Definition: field_values.hh:43
FieldFlag::Flags & flags()
Region find_id(unsigned int id, unsigned int dim) const
Definition: region.cc:180
const UnitSI & units() const
std::vector< string > get_and_check_operands(const Input::Array &operands) const
Definition: region.cc:312
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:140
void zero(unsigned int idx)
#define xprintf(...)
Definition: system.hh:92
std::shared_ptr< ControlField > no_check_control_field_
Definition: field.hh:341
#define OLD_ASSERT_LESS(a, b)
Definition: global_defs.h:134
static const unsigned int N_DISCRETE_SPACES
Definition: output_time.hh:97
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
Definition: field.hh:368
LimitSide last_limit_side_
double end() const
std::vector< FieldBasePtr > region_fields_
Definition: field.hh:346
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:459
void normalize(unsigned int idx, unsigned int divisor)
FieldResult
FieldResult field_result(RegionSet region_set) const override
Indicates special field states.
Definition: field.impl.hh:372
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:66
std::vector< std::shared_ptr< FactoryBase > > factories_
Definition: field.hh:348
auto disable_where(const Field< spacedim, typename FieldValue< spacedim >::Enum > &control_field, const vector< FieldEnum > &value_list) -> Field &
Definition: field.impl.hh:150
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:319
void set_component_index(unsigned int idx)
bool is_constant(Region reg) override
Definition: field.impl.hh:190
void add_factory(std::shared_ptr< FactoryBase > factory)
Definition: field.impl.hh:524
void set_field(const RegionSet &domain, FieldBasePtr field, double time=0.0)
Definition: field.impl.hh:199
#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)
Definition: field_common.hh:97
unsigned int n_comp() const
#define OLD_ASSERT_EQUAL(a, b)
Definition: global_defs.h:133
bool changed() const
void set_mesh(const Mesh &mesh) override
Definition: field.impl.hh:160
void set_history_changed()
bool is_valid() const
Returns false if the region has undefined/invalid value.
Definition: region.hh:77
const std::string & input_name() const
void copy_from(const FieldCommon &other) override
Definition: field.impl.hh:317
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:581
#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:47
#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:37
unsigned int idx() const
Returns a global index of the region.
Definition: region.hh:81