OGS
SurfaceFluxData.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "SurfaceFluxData.h"
5
7#include "BaseLib/Logging.h"
11
12namespace ProcessLib
13{
15 std::string&& surfaceflux_property_vector_name)
16 : surface_mesh(surfaceflux_mesh),
17 property_vector_name(std::move(surfaceflux_property_vector_name))
18{
19 // set the initial surface flux into the mesh
20 auto* const surfaceflux_pv = MeshLib::getOrCreateMeshProperty<double>(
22 // initialise the PropertyVector pv with zero values
23 std::fill(surfaceflux_pv->begin(), surfaceflux_pv->end(), 0.0);
24}
25
26std::unique_ptr<ProcessLib::SurfaceFluxData>
28 BaseLib::ConfigTree const& calculatesurfaceflux_config,
29 std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes)
30{
31 auto mesh_name =
33 calculatesurfaceflux_config.getConfigParameter<std::string>("mesh");
34 auto surfaceflux_pv_name =
36 calculatesurfaceflux_config.getConfigParameter<std::string>(
37 "property_name");
38 if (mesh_name.empty())
39 {
40 return nullptr;
41 }
42
43 DBUG(
44 "Read surfaceflux meta data:\n\tmesh:'{:s}'\n\tproperty name: "
45 "'{:s}'\n",
46 mesh_name, surfaceflux_pv_name);
47
48 auto& surfaceflux_mesh = MeshLib::findMeshByName(meshes, mesh_name);
49
50 return std::make_unique<SurfaceFluxData>(surfaceflux_mesh,
51 std::move(surfaceflux_pv_name));
52}
53
55 std::vector<GlobalVector*> const& x, double const t, Process const& p,
56 int const process_id, int const integration_order,
57 MeshLib::Mesh const& bulk_mesh,
58 std::vector<std::size_t> const& active_element_ids)
59{
60 auto* const surfaceflux_pv = MeshLib::getOrCreateMeshProperty<double>(
62 // initialise the PropertyVector pv with zero values
63 std::fill(surfaceflux_pv->begin(), surfaceflux_pv->end(), 0.0);
64 auto surfaceflux_process =
66 p.getProcessVariables(process_id)[0]
67 .get()
68 .getNumberOfGlobalComponents(),
69 integration_order);
70
71 surfaceflux_process.integrate(
72 x, *surfaceflux_pv, t, bulk_mesh, active_element_ids,
73 [&p](std::size_t const element_id, MathLib::Point3d const& pnt,
74 double const t, std::vector<GlobalVector*> const& x)
75 { return p.getFlux(element_id, pnt, t, x); });
76}
77} // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
T getConfigParameter(std::string const &param) const
virtual Eigen::Vector3d getFlux(std::size_t, MathLib::Point3d const &, double const, std::vector< GlobalVector * > const &) const
Definition Process.h:178
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > const & getProcessVariables() const
Definition Process.h:149
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:354
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)