Skip to content

Commit

Permalink
Merge branch 'UseMaterialSpatialDistributionMapAsValue' into 'master'
Browse files Browse the repository at this point in the history
Use MaterialSpatialDistributionMap as value

See merge request ogs/ogs!4745
  • Loading branch information
endJunction committed Sep 29, 2023
2 parents 1585744 + 3e5b2ee commit 3abcab8
Show file tree
Hide file tree
Showing 52 changed files with 113 additions and 159 deletions.
6 changes: 2 additions & 4 deletions MaterialLib/MPL/CreateMaterialSpatialDistributionMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

namespace MaterialPropertyLib
{
std::unique_ptr<MaterialSpatialDistributionMap>
createMaterialSpatialDistributionMap(
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(
std::map<int, std::shared_ptr<Medium>> const& media,
MeshLib::Mesh const& mesh)
{
Expand Down Expand Up @@ -45,7 +44,6 @@ createMaterialSpatialDistributionMap(
"in the mesh.",
media.size(), max_material_id - 1);
}
return std::make_unique<MaterialSpatialDistributionMap>(media,
material_ids);
return {media, material_ids};
}
} // namespace MaterialPropertyLib
3 changes: 1 addition & 2 deletions MaterialLib/MPL/CreateMaterialSpatialDistributionMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class MaterialSpatialDistributionMap;

class Medium;

std::unique_ptr<MaterialSpatialDistributionMap>
createMaterialSpatialDistributionMap(
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(
std::map<int, std::shared_ptr<Medium>> const& media,
MeshLib::Mesh const& mesh);
} // namespace MaterialPropertyLib
30 changes: 15 additions & 15 deletions ProcessLib/ComponentTransport/ComponentTransportFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
GlobalDim>(element, is_axially_symmetric,
_integration_method);
auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
for (unsigned ip = 0; ip < n_integration_points; ip++)
{
_ip_data.emplace_back(
Expand Down Expand Up @@ -314,7 +314,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
assert(_process_data.chemical_solver_interface);

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());

ParameterLib::SpatialPosition pos;
pos.setElementID(_element.getID());
Expand Down Expand Up @@ -355,7 +355,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
assert(_process_data.chemical_solver_interface);

auto const& medium =
_process_data.media_map->getMedium(_element.getID());
_process_data.media_map.getMedium(_element.getID());

MaterialPropertyLib::VariableArray vars;
MaterialPropertyLib::VariableArray vars_prev;
Expand Down Expand Up @@ -417,7 +417,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
return;
}

auto const& medium = *_process_data.media_map->getMedium(ele_id);
auto const& medium = *_process_data.media_map.getMedium(ele_id);

ParameterLib::SpatialPosition pos;
pos.setElementID(ele_id);
Expand Down Expand Up @@ -566,7 +566,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface

// Get material properties
auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
// Select the only valid for component transport liquid phase.
auto const& phase = medium.phase("AqueousLiquid");

Expand Down Expand Up @@ -738,7 +738,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
MaterialPropertyLib::VariableArray vars;

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& phase = medium.phase("AqueousLiquid");
auto const& component = phase.component(
_transport_process_variables[component_id].get().getName());
Expand Down Expand Up @@ -822,7 +822,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
.projected_specific_body_force_vectors[_element.getID()];

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& phase = medium.phase("AqueousLiquid");

MaterialPropertyLib::VariableArray vars;
Expand Down Expand Up @@ -961,7 +961,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
MaterialPropertyLib::VariableArray vars_prev;

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& phase = medium.phase("AqueousLiquid");
// Hydraulic process id is 0 and thus transport process id starts
// from 1.
Expand Down Expand Up @@ -1161,7 +1161,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
.projected_specific_body_force_vectors[_element.getID()];

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& phase = medium.phase("AqueousLiquid");

MaterialPropertyLib::VariableArray vars;
Expand Down Expand Up @@ -1283,7 +1283,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
MaterialPropertyLib::VariableArray vars_prev;

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& phase = medium.phase("AqueousLiquid");
auto const& component = phase.component(
_transport_process_variables[component_id].get().getName());
Expand Down Expand Up @@ -1409,7 +1409,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
MaterialPropertyLib::VariableArray vars_prev;

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const component_id = transport_process_id - 1;
for (unsigned ip(0); ip < n_integration_points; ++ip)
{
Expand Down Expand Up @@ -1525,7 +1525,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
MaterialPropertyLib::VariableArray vars;

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& phase = medium.phase("AqueousLiquid");

for (unsigned ip = 0; ip < n_integration_points; ++ip)
Expand Down Expand Up @@ -1607,7 +1607,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
MaterialPropertyLib::VariableArray vars;

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& phase = medium.phase("AqueousLiquid");

// local_x contains the local concentration and pressure values
Expand Down Expand Up @@ -1676,7 +1676,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface

if (_process_data.chemically_induced_porosity_change)
{
auto const& medium = *_process_data.media_map->getMedium(ele_id);
auto const& medium = *_process_data.media_map.getMedium(ele_id);

for (auto& ip_data : _ip_data)
{
Expand Down Expand Up @@ -1748,7 +1748,7 @@ class LocalAssemblerData : public ComponentTransportLocalAssemblerInterface
MaterialPropertyLib::VariableArray vars;

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& phase = medium.phase("AqueousLiquid");

int const component_id = 0;
Expand Down
5 changes: 2 additions & 3 deletions ProcessLib/ComponentTransport/ComponentTransportProcessData.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "ChemistryLib/ChemicalSolverInterface.h"
#include "LookupTable.h"
#include "MaterialLib/MPL/CreateMaterialSpatialDistributionMap.h"
#include "MaterialLib/MPL/MaterialSpatialDistributionMap.h"
#include "MathLib/LinAlg/Eigen/EigenMapTools.h"
#include "NumLib/NumericalStability/NumericalStabilization.h"
#include "ParameterLib/ConstantParameter.h"
Expand All @@ -38,8 +38,7 @@ namespace ComponentTransport
{
struct ComponentTransportProcessData
{
std::unique_ptr<MaterialPropertyLib::MaterialSpatialDistributionMap>
media_map;
MaterialPropertyLib::MaterialSpatialDistributionMap media_map;
bool const has_gravity;
bool const non_advective_form;
/// This optional tag provides a simple means of considering the temperature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ std::unique_ptr<Process> createComponentTransportProcess(
process_variables);

DBUG("Check the media properties of ComponentTransport process ...");
checkMPLProperties(mesh, *media_map);
checkMPLProperties(mesh, media_map);
DBUG("Media properties verified.");

auto stabilizer = NumLib::createNumericalStabilization(mesh, config);
Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/HT/CreateHTProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ std::unique_ptr<Process> createHTProcess(
MaterialPropertyLib::createMaterialSpatialDistributionMap(media, mesh);

DBUG("Check the media properties of HT process ...");
checkMPLProperties(mesh, *media_map);
checkMPLProperties(mesh, media_map);
DBUG("Media properties verified.");

auto stabilizer = NumLib::createNumericalStabilization(mesh, config);
Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/HT/HTFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class HTFEM : public HTLocalAssemblerInterface
vars.phase_pressure = p_int_pt;

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& liquid_phase = medium.phase("AqueousLiquid");

// TODO (naumov) Temporary value not used by current material models.
Expand Down Expand Up @@ -181,7 +181,7 @@ class HTFEM : public HTLocalAssemblerInterface
double const dt)
{
auto const& medium =
*_process_data.media_map->getMedium(this->_element.getID());
*_process_data.media_map.getMedium(this->_element.getID());
auto const& solid_phase = medium.phase("Solid");

auto const specific_heat_capacity_solid =
Expand All @@ -206,7 +206,7 @@ class HTFEM : public HTLocalAssemblerInterface
double const dt)
{
auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());

auto thermal_conductivity =
MaterialPropertyLib::formEigenTensor<GlobalDim>(
Expand Down Expand Up @@ -267,7 +267,7 @@ class HTFEM : public HTLocalAssemblerInterface
&local_p[0], ShapeFunction::NPOINTS);

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
auto const& liquid_phase = medium.phase("AqueousLiquid");

for (unsigned ip = 0; ip < n_integration_points; ++ip)
Expand Down
4 changes: 1 addition & 3 deletions ProcessLib/HT/HTProcessData.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#pragma once

#include <Eigen/Core>
#include <memory>
#include <utility>

#include "MaterialLib/MPL/MaterialSpatialDistributionMap.h"
Expand All @@ -25,8 +24,7 @@ namespace HT
{
struct HTProcessData final
{
std::unique_ptr<MaterialPropertyLib::MaterialSpatialDistributionMap>
media_map;
MaterialPropertyLib::MaterialSpatialDistributionMap media_map;
bool const has_fluid_thermal_expansion;
ParameterLib::Parameter<double> const& solid_thermal_expansion;
ParameterLib::Parameter<double> const& biot_constant;
Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/HT/MonolithicHTFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MonolithicHTFEM : public HTFEM<ShapeFunction, GlobalDim>
&local_x[pressure_index], pressure_size);

auto const& medium =
*process_data.media_map->getMedium(this->_element.getID());
*process_data.media_map.getMedium(this->_element.getID());
auto const& liquid_phase = medium.phase("AqueousLiquid");
auto const& solid_phase = medium.phase("Solid");

Expand Down
4 changes: 2 additions & 2 deletions ProcessLib/HT/StaggeredHTFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void StaggeredHTFEM<ShapeFunction, GlobalDim>::assembleHydraulicEquation(

auto const& process_data = this->_process_data;
auto const& medium =
*this->_process_data.media_map->getMedium(this->_element.getID());
*this->_process_data.media_map.getMedium(this->_element.getID());
auto const& liquid_phase = medium.phase("AqueousLiquid");
auto const& solid_phase = medium.phase("Solid");

Expand Down Expand Up @@ -192,7 +192,7 @@ void StaggeredHTFEM<ShapeFunction, GlobalDim>::assembleHeatTransportEquation(

auto const& process_data = this->_process_data;
auto const& medium =
*process_data.media_map->getMedium(this->_element.getID());
*process_data.media_map.getMedium(this->_element.getID());
auto const& liquid_phase = medium.phase("AqueousLiquid");

auto const& b =
Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/HeatConduction/CreateHeatConductionProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ std::unique_ptr<Process> createHeatConductionProcess(
MaterialPropertyLib::createMaterialSpatialDistributionMap(media, mesh);

DBUG("Check the media properties of heat conduction process ...");
checkMPLProperties(mesh, *media_map);
checkMPLProperties(mesh, media_map);
DBUG("Media properties verified.");

/// \section parametersheatconduction Process Parameters
Expand Down
6 changes: 3 additions & 3 deletions ProcessLib/HeatConduction/HeatConductionFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class LocalAssemblerData : public HeatConductionLocalAssemblerInterface
_integration_method.getNumberOfPoints();

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
MaterialPropertyLib::VariableArray vars;

for (unsigned ip = 0; ip < n_integration_points; ip++)
Expand Down Expand Up @@ -185,7 +185,7 @@ class LocalAssemblerData : public HeatConductionLocalAssemblerInterface
pos.setElementID(_element.getID());

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
MaterialPropertyLib::VariableArray vars;

for (unsigned ip = 0; ip < n_integration_points; ip++)
Expand Down Expand Up @@ -260,7 +260,7 @@ class LocalAssemblerData : public HeatConductionLocalAssemblerInterface
pos.setElementID(_element.getID());

auto const& medium =
*_process_data.media_map->getMedium(_element.getID());
*_process_data.media_map.getMedium(_element.getID());
MaterialPropertyLib::VariableArray vars;

double const dt = std::numeric_limits<double>::quiet_NaN();
Expand Down
4 changes: 1 addition & 3 deletions ProcessLib/HeatConduction/HeatConductionProcessData.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@

#pragma once

#include <memory>
#include "MaterialLib/MPL/MaterialSpatialDistributionMap.h"

namespace ProcessLib::HeatConduction
{
struct HeatConductionProcessData
{
std::unique_ptr<MaterialPropertyLib::MaterialSpatialDistributionMap>
media_map;
MaterialPropertyLib::MaterialSpatialDistributionMap media_map;

/// If set mass lumping will be applied to the equation.
bool const mass_lumping;
Expand Down
8 changes: 3 additions & 5 deletions ProcessLib/HeatTransportBHE/HeatTransportBHEProcessData.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,20 @@ namespace ProcessLib::HeatTransportBHE
struct HeatTransportBHEProcessData final
{
HeatTransportBHEProcessData(
std::unique_ptr<MaterialPropertyLib::MaterialSpatialDistributionMap>&&
media_map_,
MaterialPropertyLib::MaterialSpatialDistributionMap media_map_,
std::vector<BHE::BHETypes>&& vec_BHEs_,
BHEInflowPythonBoundaryConditionPythonSideInterface* py_bc_object_ =
nullptr,
const bool use_tespy = false,
const bool use_server_communication = false)
: media_map(std::move(media_map_)),
: media_map(media_map_),
_vec_BHE_property(std::move(vec_BHEs_)),
py_bc_object(py_bc_object_),
_use_tespy(use_tespy),
_use_server_communication(use_server_communication)
{
}
std::unique_ptr<MaterialPropertyLib::MaterialSpatialDistributionMap>
media_map;
MaterialPropertyLib::MaterialSpatialDistributionMap media_map;

std::vector<BHE::BHETypes> _vec_BHE_property;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void HeatTransportBHELocalAssemblerSoil<ShapeFunction>::assemble(
ParameterLib::SpatialPosition pos;
pos.setElementID(_element_id);

auto const& medium = *_process_data.media_map->getMedium(_element_id);
auto const& medium = *_process_data.media_map.getMedium(_element_id);
auto const& solid_phase = medium.phase("Solid");
auto const& liquid_phase = medium.phase("AqueousLiquid");

Expand Down
4 changes: 2 additions & 2 deletions ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ std::unique_ptr<Process> createHydroMechanicsProcess(

for (auto const& element_id : mesh.getElements() | MeshLib::views::ids)
{
media_map->checkElementHasMedium(element_id);
auto const& medium = *media_map->getMedium(element_id);
media_map.checkElementHasMedium(element_id);
auto const& medium = *media_map.getMedium(element_id);
checkRequiredProperties(medium, requiredMediumProperties);
checkRequiredProperties(fluidPhase(medium), requiredFluidProperties);
checkRequiredProperties(medium.phase("Solid"), requiredSolidProperties);
Expand Down
Loading

0 comments on commit 3abcab8

Please sign in to comment.