diff --git a/ProcessLib/CalculateSurfaceFlux/Balance.h b/ProcessLib/CalculateSurfaceFlux/Balance.h index 36ece38bec3930852367086402e0b58dbf90337b..5d2af71b77f70ac67e585971cbf706046e2d17a0 100644 --- a/ProcessLib/CalculateSurfaceFlux/Balance.h +++ b/ProcessLib/CalculateSurfaceFlux/Balance.h @@ -26,12 +26,17 @@ struct Balance std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::string&& balance_property_vector_name, std::string&& balance_output_mesh_file_name) - : mesh_name(std::move(balance_mesh_name)), + : surface_mesh(*BaseLib::findElementOrError( + meshes.begin(), meshes.end(), + [&balance_mesh_name](auto const& m) { + return balance_mesh_name == m->getName(); + }, + "Expected to find a mesh named " + balance_mesh_name + + " for the balance calculation.")), + mesh_name(std::move(balance_mesh_name)), property_vector_name(std::move(balance_property_vector_name)), output_mesh_file_name(std::move(balance_output_mesh_file_name)) { - 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\"", @@ -46,10 +51,10 @@ struct Balance std::string const fname = BaseLib::dropFileExtension(output_mesh_file_name) + "_t_" + std::to_string(t) + ".vtu"; - MeshLib::IO::writeMeshToFile(*surface_mesh, fname); + MeshLib::IO::writeMeshToFile(surface_mesh, fname); } - std::unique_ptr<MeshLib::Mesh> surface_mesh; + MeshLib::Mesh& surface_mesh; std::string const mesh_name; std::string const property_vector_name; std::string const output_mesh_file_name; diff --git a/ProcessLib/HT/CreateHTProcess.cpp b/ProcessLib/HT/CreateHTProcess.cpp index 74532627d3a19188455182b8031f408b03953832..21021372d6e00fd491365a37d370a76ad4a13bd4 100644 --- a/ProcessLib/HT/CreateHTProcess.cpp +++ b/ProcessLib/HT/CreateHTProcess.cpp @@ -218,7 +218,7 @@ std::unique_ptr<Process> createHTProcess( std::move(balance_out_fname))); // Surface mesh and bulk mesh must have equal axial symmetry flags! - balance->surface_mesh->setAxiallySymmetric(mesh.isAxiallySymmetric()); + balance->surface_mesh.setAxiallySymmetric(mesh.isAxiallySymmetric()); } std::unique_ptr<HTMaterialProperties> material_properties = diff --git a/ProcessLib/HT/HTProcess.cpp b/ProcessLib/HT/HTProcess.cpp index 7b7ddf23f08ae701538f51f8a973fd698e545525..56139edd81fa72a958bdec11831a6d30780e93a4 100644 --- a/ProcessLib/HT/HTProcess.cpp +++ b/ProcessLib/HT/HTProcess.cpp @@ -273,12 +273,12 @@ void HTProcess::postTimestepConcreteProcess(GlobalVector const& x, return; } auto* const balance_pv = MeshLib::getOrCreateMeshProperty<double>( - *(_balance->surface_mesh), _balance->property_vector_name, + _balance->surface_mesh, _balance->property_vector_name, MeshLib::MeshItemType::Cell, 1); // initialise the PropertyVector pv with zero values std::fill(balance_pv->begin(), balance_pv->end(), 0.0); auto balance = ProcessLib::CalculateSurfaceFlux( - *(_balance->surface_mesh), + _balance->surface_mesh, getProcessVariables(process_id)[0].get().getNumberOfComponents(), _integration_order);