Skip to content
Snippets Groups Projects
Commit 1d5b8fcc authored by Tom Fischer's avatar Tom Fischer
Browse files

[PL/ComponentTransport] Use struct SurfaceFluxData.

parent c2543b8f
No related branches found
No related tags found
No related merge requests found
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
#include <cassert> #include <cassert>
// TODO used for output, if output classes are ready this has to be changed #include "ProcessLib/SurfaceFlux/SurfaceFlux.h"
#include "MeshLib/IO/writeMeshToFile.h" #include "ProcessLib/SurfaceFlux/SurfaceFluxData.h"
#include "ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.h"
#include "ProcessLib/Utils/CreateLocalAssemblers.h" #include "ProcessLib/Utils/CreateLocalAssemblers.h"
namespace ProcessLib namespace ProcessLib
...@@ -33,16 +30,13 @@ ComponentTransportProcess::ComponentTransportProcess( ...@@ -33,16 +30,13 @@ ComponentTransportProcess::ComponentTransportProcess(
SecondaryVariableCollection&& secondary_variables, SecondaryVariableCollection&& secondary_variables,
NumLib::NamedFunctionCaller&& named_function_caller, NumLib::NamedFunctionCaller&& named_function_caller,
bool const use_monolithic_scheme, bool const use_monolithic_scheme,
std::unique_ptr<MeshLib::Mesh>&& balance_mesh, std::unique_ptr<ProcessLib::SurfaceFluxData>&& surfaceflux)
std::string&& balance_pv_name, std::string&& balance_out_fname)
: Process(mesh, std::move(jacobian_assembler), parameters, : Process(mesh, std::move(jacobian_assembler), parameters,
integration_order, std::move(process_variables), integration_order, std::move(process_variables),
std::move(secondary_variables), std::move(named_function_caller), std::move(secondary_variables), std::move(named_function_caller),
use_monolithic_scheme), use_monolithic_scheme),
_process_data(std::move(process_data)), _process_data(std::move(process_data)),
_balance_mesh(std::move(balance_mesh)), _surfaceflux(std::move(surfaceflux))
_balance_pv_name(std::move(balance_pv_name)),
_balance_out_fname(std::move(balance_out_fname))
{ {
} }
...@@ -130,32 +124,12 @@ void ComponentTransportProcess::postTimestepConcreteProcess( ...@@ -130,32 +124,12 @@ void ComponentTransportProcess::postTimestepConcreteProcess(
"ComponentTransportProcess."); "ComponentTransportProcess.");
return; return;
} }
if (!_balance_mesh) // computing the balance is optional if (!_surfaceflux) // computing the surfaceflux is optional
{ {
return; return;
} }
auto* const balance_pv = MeshLib::getOrCreateMeshProperty<double>( _surfaceflux->integrate(x, t, *this, process_id, _integration_order, _mesh);
*_balance_mesh, _balance_pv_name, MeshLib::MeshItemType::Cell, 1); _surfaceflux->save(t);
// initialise the PropertyVector pv with zero values
std::fill(balance_pv->begin(), balance_pv->end(), 0.0);
auto balance = ProcessLib::CalculateSurfaceFlux(
*_balance_mesh,
getProcessVariables(process_id)[0].get().getNumberOfComponents(),
_integration_order);
balance.integrate(
x, *balance_pv, t, _mesh,
[this](std::size_t const element_id, MathLib::Point3d const& pnt,
double const t, GlobalVector const& x) {
return getFlux(element_id, pnt, t, x);
});
// post: surface_mesh has scalar element property
// TODO output, if output classes are ready this has to be
// changed
std::string const fname = BaseLib::dropFileExtension(_balance_out_fname) +
"_t_" + std::to_string(t) + ".vtu";
MeshLib::IO::writeMeshToFile(*_balance_mesh, fname);
} }
} // namespace ComponentTransport } // namespace ComponentTransport
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
namespace ProcessLib namespace ProcessLib
{ {
struct SurfaceFluxData;
namespace ComponentTransport namespace ComponentTransport
{ {
...@@ -99,8 +100,7 @@ public: ...@@ -99,8 +100,7 @@ public:
SecondaryVariableCollection&& secondary_variables, SecondaryVariableCollection&& secondary_variables,
NumLib::NamedFunctionCaller&& named_function_caller, NumLib::NamedFunctionCaller&& named_function_caller,
bool const use_monolithic_scheme, bool const use_monolithic_scheme,
std::unique_ptr<MeshLib::Mesh>&& balance_mesh, std::unique_ptr<ProcessLib::SurfaceFluxData>&& surfaceflux);
std::string&& balance_pv_name, std::string&& balance_out_frame);
//! \name ODESystem interface //! \name ODESystem interface
//! @{ //! @{
...@@ -137,9 +137,7 @@ private: ...@@ -137,9 +137,7 @@ private:
std::vector<std::unique_ptr<ComponentTransportLocalAssemblerInterface>> std::vector<std::unique_ptr<ComponentTransportLocalAssemblerInterface>>
_local_assemblers; _local_assemblers;
std::unique_ptr<MeshLib::Mesh> _balance_mesh; std::unique_ptr<ProcessLib::SurfaceFluxData> _surfaceflux;
std::string const _balance_pv_name;
std::string const _balance_out_fname;
}; };
} // namespace ComponentTransport } // namespace ComponentTransport
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "MeshLib/IO/readMeshFromFile.h" #include "MeshLib/IO/readMeshFromFile.h"
#include "ProcessLib/CalculateSurfaceFlux/ParseCalculateSurfaceFluxData.h" #include "ProcessLib/SurfaceFlux/SurfaceFluxData.h"
#include "ProcessLib/Output/CreateSecondaryVariables.h" #include "ProcessLib/Output/CreateSecondaryVariables.h"
#include "ProcessLib/Parameter/ConstantParameter.h" #include "ProcessLib/Parameter/ConstantParameter.h"
#include "ProcessLib/Utils/ProcessUtils.h" #include "ProcessLib/Utils/ProcessUtils.h"
...@@ -170,44 +170,21 @@ std::unique_ptr<Process> createComponentTransportProcess( ...@@ -170,44 +170,21 @@ std::unique_ptr<Process> createComponentTransportProcess(
ProcessLib::createSecondaryVariables(config, secondary_variables, ProcessLib::createSecondaryVariables(config, secondary_variables,
named_function_caller); named_function_caller);
// for the balance std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
std::string balance_mesh_name; // surface mesh the balance will computed on auto surfaceflux_config =
std::string balance_pv_name; //! \ogs_file_param{prj__processes__process__calculatesurfaceflux}
std::string balance_out_fname; config.getConfigSubtreeOptional("calculatesurfaceflux");
std::unique_ptr<MeshLib::Mesh> surface_mesh; if (surfaceflux_config)
ProcessLib::parseCalculateSurfaceFluxData(
config, balance_mesh_name, balance_pv_name, balance_out_fname);
if (!mesh_name.empty()) // balance is optional
{ {
// find the mesh for the specified mesh_name surfaceflux = ProcessLib::SurfaceFluxData::createSurfaceFluxData(
auto balance_mesh = BaseLib::findElementOrError( *surfaceflux_config, meshes, output_directory);
meshes.begin(), meshes.end(),
[&balance_mesh_name](auto const& m) {
return balance_mesh_name == m->getName();
},
"Expected to find o mesh named " + balance_mesh_name +
" for balance calculation.");
balance_out_fname =
BaseLib::copyPathToFileName(balance_out_fname, output_directory);
DBUG(
"read balance meta data:\n\tbalance mesh:\"%s\"\n\tproperty name: "
"\"%s\"\n\toutput to: \"%s\"",
balance_mesh_name.c_str(), balance_pv_name.c_str(),
balance_out_fname.c_str());
// Surface mesh and bulk mesh must have equal axial symmetry flags!
surface_mesh->setAxiallySymmetric(mesh.isAxiallySymmetric());
} }
return std::make_unique<ComponentTransportProcess>( return std::make_unique<ComponentTransportProcess>(
mesh, std::move(jacobian_assembler), parameters, integration_order, mesh, std::move(jacobian_assembler), parameters, integration_order,
std::move(process_variables), std::move(process_data), std::move(process_variables), std::move(process_data),
std::move(secondary_variables), std::move(named_function_caller), std::move(secondary_variables), std::move(named_function_caller),
use_monolithic_scheme, std::move(surface_mesh), use_monolithic_scheme, std::move(surfaceflux));
std::move(balance_pv_name), std::move(balance_out_fname));
} }
} // namespace ComponentTransport } // namespace ComponentTransport
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment