OGS
SurfaceFluxData.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <memory>
14 #include <string>
15 
16 #include "BaseLib/Logging.h"
18 
19 namespace ProcessLib
20 {
21 struct SurfaceFluxData final
22 {
23  SurfaceFluxData(MeshLib::Mesh& surfaceflux_mesh,
24  std::string&& surfaceflux_property_vector_name)
25  : surface_mesh(surfaceflux_mesh),
26  property_vector_name(std::move(surfaceflux_property_vector_name))
27  {
28  // set the initial surface flux into the mesh
29  auto* const surfaceflux_pv = MeshLib::getOrCreateMeshProperty<double>(
31  // initialise the PropertyVector pv with zero values
32  std::fill(surfaceflux_pv->begin(), surfaceflux_pv->end(), 0.0);
33  }
34 
35  static std::unique_ptr<ProcessLib::SurfaceFluxData> createSurfaceFluxData(
36  BaseLib::ConfigTree const& calculatesurfaceflux_config,
37  std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes)
38  {
39  auto mesh_name =
41  calculatesurfaceflux_config.getConfigParameter<std::string>("mesh");
42  auto surfaceflux_pv_name =
44  calculatesurfaceflux_config.getConfigParameter<std::string>(
45  "property_name");
46  if (mesh_name.empty())
47  {
48  return nullptr;
49  }
50 
51  DBUG(
52  "Read surfaceflux meta data:\n\tmesh:'{:s}'\n\tproperty name: "
53  "'{:s}'\n",
54  mesh_name, surfaceflux_pv_name);
55 
57  meshes.begin(), meshes.end(),
58  [&mesh_name](auto const& m) { return mesh_name == m->getName(); },
59  "Expected to find a mesh named " + mesh_name +
60  " for the surfaceflux calculation.");
61 
62  return std::make_unique<SurfaceFluxData>(
63  surface_mesh, std::move(surfaceflux_pv_name));
64  }
65 
66  void integrate(std::vector<GlobalVector*> const& x, double const t,
67  Process const& p, int const process_id,
68  int const integration_order, MeshLib::Mesh const& bulk_mesh,
69  std::vector<std::size_t> const& active_element_ids)
70  {
71  auto* const surfaceflux_pv = MeshLib::getOrCreateMeshProperty<double>(
73  // initialise the PropertyVector pv with zero values
74  std::fill(surfaceflux_pv->begin(), surfaceflux_pv->end(), 0.0);
75  auto surfaceflux_process =
77  p.getProcessVariables(process_id)[0]
78  .get()
79  .getNumberOfGlobalComponents(),
80  integration_order);
81 
82  surfaceflux_process.integrate(
83  x, *surfaceflux_pv, t, bulk_mesh, active_element_ids,
84  [&p](std::size_t const element_id, MathLib::Point3d const& pnt,
85  double const t, std::vector<GlobalVector*> const& x) {
86  return p.getFlux(element_id, pnt, t, x);
87  });
88  }
89 
90 private:
92  std::string const property_vector_name;
93 };
94 } // namespace ProcessLib
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
T getConfigParameter(std::string const &param) const
std::iterator_traits< InputIt >::reference findElementOrError(InputIt begin, InputIt end, Predicate predicate, std::string const &error="")
Definition: Algorithm.h:69
std::string const property_vector_name
SurfaceFluxData(MeshLib::Mesh &surfaceflux_mesh, std::string &&surfaceflux_property_vector_name)
static std::unique_ptr< ProcessLib::SurfaceFluxData > createSurfaceFluxData(BaseLib::ConfigTree const &calculatesurfaceflux_config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes)
void integrate(std::vector< GlobalVector * > const &x, double const t, Process const &p, int const process_id, int const integration_order, MeshLib::Mesh const &bulk_mesh, std::vector< std::size_t > const &active_element_ids)