Flow123d  jenkins-Flow123d-linux-release-multijob-198
generic_field.impl.hh
Go to the documentation of this file.
1 /*
2  * generic_field.impl.hh
3  *
4  * Created on: Dec 9, 2014
5  * Author: jb
6  */
7 
8 #ifndef GENERIC_FIELD_IMPL_HH_
9 #define GENERIC_FIELD_IMPL_HH_
10 
11 #include <memory>
12 #include "mesh/mesh.h"
13 
14 #include "fields/generic_field.hh"
15 
16 
17 template <int spacedim>
19  IndexField region_id;
20  region_id.name("region_id");
21  region_id.units( UnitSI::dimensionless() );
22  region_id.set_mesh(mesh);
23 
24  RegionSet all_regions=mesh.region_db().get_region_set("ALL");
25  for(Region reg : all_regions) {
26  auto field_algo=std::make_shared<FieldConstant<spacedim, IntegerScalar>>();
27  field_algo->set_value(reg.id());
28  region_id.set_field(
29  {reg} ,
30  field_algo);
31  }
32 
33  //region_id.set_time(0.0);
34 
35  return region_id;
36 }
37 
38 template <int spacedim>
40  auto field_subdomain_data= mesh.get_part()->subdomain_id_field_data();
41 
42  IndexField subdomain;
43  subdomain.name("subdomain");
44  subdomain.units( UnitSI::dimensionless() );
45  subdomain.set_mesh(mesh);
46 
47  subdomain.set_field(
48  mesh.region_db().get_region_set("ALL"),
49  make_shared< FieldElementwise<spacedim, FieldValue<3>::Integer> >(field_subdomain_data, 1),
50  0.0); // time=0.0
51 
52 
53  //subdomain.set_time(0.0);
54  return subdomain;
55 }
56 
57 
58 
59 #endif /* GENERAL_FIELD_IMPL_HH_ */
static auto subdomain(Mesh &mesh) -> IndexField
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:52
???
Definition: mesh.h:109
Fields computed from the mesh data.
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
static auto region_id(Mesh &mesh) -> IndexField
void set_field(const RegionSet &domain, FieldBasePtr field, double time=0.0)
Definition: field.impl.hh:210
FieldCommon & name(const string &name)
Definition: field_common.hh:73
void set_mesh(const Mesh &mesh) override
Definition: field.impl.hh:172
static UnitSI & dimensionless()
Returns dimensionless unit.
Definition: unit_si.cc:44