diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 12e6cb06d5d37d245a5a3df6d8df36288fa296f0..5fe229eae8c6c69ef408a27611d48b45cab49b98 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -332,7 +332,7 @@ void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config, process = ProcessLib::GroundwaterFlow::createGroundwaterFlowProcess( *_mesh_vec[0], std::move(jacobian_assembler), _process_variables, _parameters, integration_order, - process_config, project_directory, output_directory); + process_config, _mesh_vec, output_directory); } else #endif diff --git a/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp b/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp index 449a7090f4f36f22520c036fdd39fb07ec1481a0..5fe729f57e6e0c4cb7c5ab4782f38630b18ce300 100644 --- a/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp +++ b/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp @@ -29,7 +29,7 @@ std::unique_ptr<Process> createGroundwaterFlowProcess( std::vector<std::unique_ptr<ParameterBase>> const& parameters, unsigned const integration_order, BaseLib::ConfigTree const& config, - std::string const& project_directory, + std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::string const& output_directory) { //! \ogs_file_param{prj__processes__process__type} @@ -70,6 +70,7 @@ std::unique_ptr<Process> createGroundwaterFlowProcess( ProcessLib::createSecondaryVariables(config, secondary_variables, named_function_caller); + std::unique_ptr<ProcessLib::Balance> balance; std::string mesh_name; std::string balance_pv_name; std::string balance_out_fname; @@ -79,29 +80,22 @@ std::unique_ptr<Process> createGroundwaterFlowProcess( if (!mesh_name.empty()) // balance is optional { - mesh_name = BaseLib::copyPathToFileName(mesh_name, project_directory); - balance_out_fname = BaseLib::copyPathToFileName(balance_out_fname, output_directory); - surface_mesh.reset(MeshLib::IO::readMeshFromFile(mesh_name)); - - DBUG( - "read balance meta data:\n\tbalance mesh:\"%s\"\n\tproperty name: " - "\"%s\"\n\toutput to: \"%s\"", - mesh_name.c_str(), balance_pv_name.c_str(), - balance_out_fname.c_str()); + balance.reset(new ProcessLib::Balance(std::move(mesh_name), meshes, + std::move(balance_pv_name), + std::move(balance_out_fname))); // Surface mesh and bulk mesh must have equal axial symmetry flags! - surface_mesh->setAxiallySymmetric(mesh.isAxiallySymmetric()); + balance->surface_mesh.setAxiallySymmetric(mesh.isAxiallySymmetric()); } return std::make_unique<GroundwaterFlowProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), std::move(secondary_variables), std::move(named_function_caller), - surface_mesh.release(), std::move(balance_pv_name), - std::move(balance_out_fname)); + std::move(balance)); } } // namespace GroundwaterFlow diff --git a/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.h index e9d20ae4c2d6a37d4db57118a22b47eb3357b75e..33f09822eaeea288a2f65df4273bb50d0e26ea46 100644 --- a/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.h @@ -24,7 +24,7 @@ std::unique_ptr<Process> createGroundwaterFlowProcess( std::vector<std::unique_ptr<ParameterBase>> const& parameters, unsigned const integration_order, BaseLib::ConfigTree const& config, - std::string const& project_directory, + std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::string const& output_directory); } // namespace GroundwaterFlow diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp index 24c16c7fba114ff7935d9e830cd15a392d602ff1..c27264115dd58d27d8568a72ede22947e4c45774 100644 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp +++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp @@ -27,16 +27,12 @@ GroundwaterFlowProcess::GroundwaterFlowProcess( GroundwaterFlowProcessData&& process_data, SecondaryVariableCollection&& secondary_variables, NumLib::NamedFunctionCaller&& named_function_caller, - MeshLib::Mesh* balance_mesh, - std::string&& balance_pv_name, - std::string&& balance_out_fname) + std::unique_ptr<ProcessLib::Balance>&& balance) : Process(mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(secondary_variables), std::move(named_function_caller)), _process_data(std::move(process_data)), - _balance_mesh(balance_mesh), - _balance_pv_name(std::move(balance_pv_name)), - _balance_out_fname(std::move(balance_out_fname)) + _balance(std::move(balance)) { } diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h index 4b3691624c72668390939a26043b3e80d15de837..36421ffe98838a056be244d0f7d750c483eae6ef 100644 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h @@ -12,7 +12,7 @@ #include "GroundwaterFlowFEM.h" #include "GroundwaterFlowProcessData.h" #include "NumLib/DOF/LocalToGlobalIndexMap.h" -#include "ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.h" +#include "ProcessLib/CalculateSurfaceFlux/Balance.h" #include "ProcessLib/Process.h" // TODO used for output, if output classes are ready this has to be changed @@ -36,8 +36,7 @@ public: GroundwaterFlowProcessData&& process_data, SecondaryVariableCollection&& secondary_variables, NumLib::NamedFunctionCaller&& named_function_caller, - MeshLib::Mesh* balance_mesh, std::string&& balance_pv_name, - std::string&& balance_out_fname); + std::unique_ptr<ProcessLib::Balance>&& balance); //! \name ODESystem interface //! @{ @@ -70,36 +69,12 @@ public: OGS_FATAL("The condition of process_id = 0 must be satisfied for " "GroundwaterFlowProcess, which is a single process." ); } - if (_balance_mesh) // computing the balance is optional + if (!_balance) // computing the balance is optional { - std::vector<double> init_values( - _balance_mesh->getNumberOfElements(), 0.0); - MeshLib::addPropertyToMesh(*_balance_mesh, _balance_pv_name, - MeshLib::MeshItemType::Cell, 1, - init_values); - auto balance = ProcessLib::CalculateSurfaceFlux( - *_balance_mesh, - getProcessVariables(process_id)[0] - .get() - .getNumberOfComponents(), - _integration_order); - - auto* const balance_pv = - _balance_mesh->getProperties() - .template getPropertyVector<double>(_balance_pv_name); - - 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 - MeshLib::IO::writeMeshToFile(*_balance_mesh, _balance_out_fname); + return; } + _balance->integrate(x, t, *this, process_id, _integration_order, _mesh); + _balance->save(t); } private: @@ -122,9 +97,7 @@ private: std::vector<std::unique_ptr<GroundwaterFlowLocalAssemblerInterface>> _local_assemblers; - std::unique_ptr<MeshLib::Mesh> _balance_mesh; - std::string const _balance_pv_name; - std::string const _balance_out_fname; + std::unique_ptr<ProcessLib::Balance> _balance; }; } // namespace GroundwaterFlow