Flow123d  release_2.2.0-41-g0958a8d
generic_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 generic_field.impl.hh
15  * @brief
16  */
17 
18 #ifndef GENERIC_FIELD_IMPL_HH_
19 #define GENERIC_FIELD_IMPL_HH_
20 
21 #include <memory>
22 #include "mesh/mesh.h"
23 
24 #include "fields/generic_field.hh"
25 
26 
27 template <int spacedim>
29  IndexField region_id;
30  region_id.name("region_id");
31  region_id.units( UnitSI::dimensionless() );
32  region_id.set_mesh(mesh);
33 
34  RegionSet all_regions=mesh.region_db().get_region_set("ALL");
35  for(Region reg : all_regions) {
36  auto field_algo=std::make_shared<FieldConstant<spacedim, IntegerScalar>>();
37  field_algo->set_value(reg.id());
38  region_id.set_field(
39  {reg} ,
40  field_algo,
41  0.0); // time=0.0
42  }
43  return region_id;
44 }
45 
46 template <int spacedim>
48  auto field_subdomain_data= mesh.get_part()->subdomain_id_field_data();
49 
50  IndexField subdomain;
51  subdomain.name("subdomain");
52  subdomain.units( UnitSI::dimensionless() );
53  subdomain.set_mesh(mesh);
54 
55  subdomain.set_field(
56  mesh.region_db().get_region_set("ALL"),
57  make_shared< FieldElementwise<spacedim, FieldValue<3>::Integer> >(field_subdomain_data, 1),
58  0.0); // time=0.0
59 
60  return subdomain;
61 }
62 
63 
64 
65 #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:62
Definition: mesh.h:97
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:198
FieldCommon & name(const string &name)
Definition: field_common.hh:97
void set_mesh(const Mesh &mesh) override
Definition: field.impl.hh:159
static UnitSI & dimensionless()
Returns dimensionless unit.
Definition: unit_si.cc:55