OGS
SurfaceFluxData.cpp
Go to the documentation of this file.
1
11#include "SurfaceFluxData.h"
12
13#include "BaseLib/ConfigTree.h"
14#include "BaseLib/Logging.h"
16#include "ProcessLib/Process.h"
18
19namespace ProcessLib
20{
22 std::string&& surfaceflux_property_vector_name)
23 : surface_mesh(surfaceflux_mesh),
24 property_vector_name(std::move(surfaceflux_property_vector_name))
25{
26 // set the initial surface flux into the mesh
27 auto* const surfaceflux_pv = MeshLib::getOrCreateMeshProperty<double>(
29 // initialise the PropertyVector pv with zero values
30 std::fill(surfaceflux_pv->begin(), surfaceflux_pv->end(), 0.0);
31}
32
33std::unique_ptr<ProcessLib::SurfaceFluxData>
35 BaseLib::ConfigTree const& calculatesurfaceflux_config,
36 std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes)
37{
38 auto mesh_name =
40 calculatesurfaceflux_config.getConfigParameter<std::string>("mesh");
41 auto surfaceflux_pv_name =
43 calculatesurfaceflux_config.getConfigParameter<std::string>(
44 "property_name");
45 if (mesh_name.empty())
46 {
47 return nullptr;
48 }
49
50 DBUG(
51 "Read surfaceflux meta data:\n\tmesh:'{:s}'\n\tproperty name: "
52 "'{:s}'\n",
53 mesh_name, surfaceflux_pv_name);
54
55 auto& surfaceflux_mesh = MeshLib::findMeshByName(meshes, mesh_name);
56
57 return std::make_unique<SurfaceFluxData>(surfaceflux_mesh,
58 std::move(surfaceflux_pv_name));
59}
60
62 std::vector<GlobalVector*> const& x, double const t, Process const& p,
63 int const process_id, int const integration_order,
64 MeshLib::Mesh const& bulk_mesh,
65 std::vector<std::size_t> const& active_element_ids)
66{
67 auto* const surfaceflux_pv = MeshLib::getOrCreateMeshProperty<double>(
69 // initialise the PropertyVector pv with zero values
70 std::fill(surfaceflux_pv->begin(), surfaceflux_pv->end(), 0.0);
71 auto surfaceflux_process =
73 p.getProcessVariables(process_id)[0]
74 .get()
75 .getNumberOfGlobalComponents(),
76 integration_order);
77
78 surfaceflux_process.integrate(
79 x, *surfaceflux_pv, t, bulk_mesh, active_element_ids,
80 [&p](std::size_t const element_id, MathLib::Point3d const& pnt,
81 double const t, std::vector<GlobalVector*> const& x)
82 { return p.getFlux(element_id, pnt, t, x); });
83}
84} // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
T getConfigParameter(std::string const &param) const
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
Mesh & findMeshByName(std::vector< std::unique_ptr< Mesh > > const &meshes, std::string_view const name)
Definition Mesh.cpp:364
std::string const property_vector_name
SurfaceFluxData(MeshLib::Mesh &surfaceflux_mesh, std::string &&surfaceflux_property_vector_name)
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)
static std::unique_ptr< ProcessLib::SurfaceFluxData > createSurfaceFluxData(BaseLib::ConfigTree const &calculatesurfaceflux_config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes)