Skip to content

Commit

Permalink
Merge branch 'imprv_LIE_M' into 'master'
Browse files Browse the repository at this point in the history
[LIE/M] minor improvement

See merge request ogs/ogs!5082
  • Loading branch information
endJunction committed Aug 23, 2024
2 parents 7013777 + 1aae6ef commit 7917a6f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ std::unique_ptr<Process> createSmallDeformationProcess(
config.getConfigParameter<double>(
"reference_temperature", std::numeric_limits<double>::quiet_NaN());

SmallDeformationProcessData<DisplacementDim> process_data(
SmallDeformationProcessData<DisplacementDim> process_data{
materialIDs(mesh), std::move(solid_constitutive_relations),
std::move(fracture_model), std::move(fracture_properties),
reference_temperature);
reference_temperature};

SecondaryVariableCollection secondary_variables;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ SmallDeformationLocalAssemblerFracture<ShapeFunction, DisplacementDim>::
_ip_data.reserve(n_integration_points);
_secondary_data.N.resize(n_integration_points);

auto mat_id = (*_process_data._mesh_prop_materialIDs)[e.getID()];
auto frac_id = _process_data._map_materialID_to_fractureID[mat_id];
auto mat_id = (*_process_data.mesh_prop_materialIDs)[e.getID()];
auto frac_id = _process_data.map_materialID_to_fractureID[mat_id];
_fracture_property = &_process_data.fracture_properties[frac_id];
for (auto fid : process_data._vec_ele_connected_fractureIDs[e.getID()])
for (auto fid : process_data.vec_ele_connected_fractureIDs[e.getID()])
{
_fracID_to_local.insert({fid, _fracture_props.size()});
_fracture_props.push_back(&_process_data.fracture_properties[fid]);
}

_junction_props = process_data._vec_ele_connected_junctionIDs[e.getID()] |
_junction_props = process_data.vec_ele_connected_junctionIDs[e.getID()] |
ranges::views::transform(
[&](auto const jid)
{ return &_process_data.junction_properties[jid]; }) |
Expand All @@ -77,7 +77,7 @@ SmallDeformationLocalAssemblerFracture<ShapeFunction, DisplacementDim>::
{
x_position.setIntegrationPoint(ip);

_ip_data.emplace_back(*_process_data._fracture_model);
_ip_data.emplace_back(*_process_data.fracture_model);
auto const& sm = _shape_matrices[ip];
auto& ip_data = _ip_data[ip];
ip_data.integration_weight =
Expand Down Expand Up @@ -339,7 +339,7 @@ void SmallDeformationLocalAssemblerFracture<ShapeFunction, DisplacementDim>::
ele_b /= n_integration_points;
ele_w /= n_integration_points;
ele_sigma /= n_integration_points;
(*_process_data._mesh_prop_b)[_element.getID()] = ele_b;
(*_process_data.mesh_prop_b)[_element.getID()] = ele_b;

Eigen::Map<GlobalDimVectorType>(
&(*_process_data.element_fracture_stresses)[e_id * DisplacementDim]) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void SmallDeformationLocalAssemblerMatrix<ShapeFunction, DisplacementDim>::
variables_prev.mechanical_strain
.emplace<MathLib::KelvinVector::KelvinVectorType<DisplacementDim>>(
eps_prev);
variables_prev.temperature = _process_data._reference_temperature;
variables_prev.temperature = _process_data.reference_temperature;

auto&& solution = _ip_data[ip]._solid_material.integrateStress(
variables_prev, variables, t, x_position, dt, *state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ SmallDeformationLocalAssemblerMatrixNearFracture<ShapeFunction,
_secondary_data.N[ip] = sm.N;
}

for (auto fid : process_data._vec_ele_connected_fractureIDs[e.getID()])
for (auto fid : process_data.vec_ele_connected_fractureIDs[e.getID()])
{
_fracID_to_local.insert({fid, _fracture_props.size()});
_fracture_props.push_back(&_process_data.fracture_properties[fid]);
}

_junction_props = process_data._vec_ele_connected_junctionIDs[e.getID()] |
_junction_props = process_data.vec_ele_connected_junctionIDs[e.getID()] |
ranges::views::transform(
[&](auto const jid)
{ return &_process_data.junction_properties[jid]; }) |
Expand Down Expand Up @@ -255,7 +255,7 @@ void SmallDeformationLocalAssemblerMatrixNearFracture<
variables_prev.mechanical_strain
.emplace<MathLib::KelvinVector::KelvinVectorType<DisplacementDim>>(
eps_prev);
variables_prev.temperature = _process_data._reference_temperature;
variables_prev.temperature = _process_data.reference_temperature;

auto&& solution = _ip_data[ip]._solid_material.integrateStress(
variables_prev, variables, t, x_position, dt, *state);
Expand Down
32 changes: 15 additions & 17 deletions ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ SmallDeformationProcess<DisplacementDim>::SmallDeformationProcess(
// create a map from a material ID to a fracture ID
auto max_frac_mat_id = std::max_element(_vec_fracture_mat_IDs.begin(),
_vec_fracture_mat_IDs.end());
_process_data._map_materialID_to_fractureID.resize(*max_frac_mat_id + 1);
_process_data.map_materialID_to_fractureID.resize(*max_frac_mat_id + 1);
for (unsigned i = 0; i < _vec_fracture_mat_IDs.size(); i++)
{
_process_data._map_materialID_to_fractureID[_vec_fracture_mat_IDs[i]] =
_process_data.map_materialID_to_fractureID[_vec_fracture_mat_IDs[i]] =
i;
}

// create a table of connected fracture IDs for each element
_process_data._vec_ele_connected_fractureIDs.resize(
_process_data.vec_ele_connected_fractureIDs.resize(
mesh.getNumberOfElements());
for (unsigned i = 0; i < _vec_fracture_matrix_elements.size(); i++)
{
for (auto e : _vec_fracture_matrix_elements[i])
{
_process_data._vec_ele_connected_fractureIDs[e->getID()].push_back(
_process_data.vec_ele_connected_fractureIDs[e->getID()].push_back(
i);
}
}
Expand All @@ -103,10 +103,10 @@ SmallDeformationProcess<DisplacementDim>::SmallDeformationProcess(
auto slave_matId = matID[1];
auto& master_frac =
_process_data.fracture_properties
[_process_data._map_materialID_to_fractureID[master_matId]];
[_process_data.map_materialID_to_fractureID[master_matId]];
auto& slave_frac =
_process_data.fracture_properties
[_process_data._map_materialID_to_fractureID[slave_matId]];
[_process_data.map_materialID_to_fractureID[slave_matId]];

master_frac.branches_master.push_back(createBranchProperty(
*mesh.getNode(vec_branch_nodeID), master_frac, slave_frac));
Expand All @@ -130,24 +130,24 @@ SmallDeformationProcess<DisplacementDim>::SmallDeformationProcess(
auto const& material_ids = vec_junction_nodeID_matIDs[i].second;
assert(material_ids.size() == 2);
std::array<int, 2> fracture_ids{
{_process_data._map_materialID_to_fractureID[material_ids[0]],
_process_data._map_materialID_to_fractureID[material_ids[1]]}};
{_process_data.map_materialID_to_fractureID[material_ids[0]],
_process_data.map_materialID_to_fractureID[material_ids[1]]}};

_process_data.junction_properties.emplace_back(
i, *mesh.getNode(vec_junction_nodeID_matIDs[i].first),
fracture_ids);
}

// create a table of connected junction IDs for each element
_process_data._vec_ele_connected_junctionIDs.resize(
_process_data.vec_ele_connected_junctionIDs.resize(
mesh.getNumberOfElements());
for (unsigned i = 0; i < vec_junction_nodeID_matIDs.size(); i++)
{
auto node = mesh.getNode(vec_junction_nodeID_matIDs[i].first);
for (auto id :
mesh.getElementsConnectedToNode(*node) | MeshLib::views::ids)
{
_process_data._vec_ele_connected_junctionIDs[id].push_back(i);
_process_data.vec_ele_connected_junctionIDs[id].push_back(i);
}
}

Expand All @@ -173,7 +173,7 @@ SmallDeformationProcess<DisplacementDim>::SmallDeformationProcess(

MeshLib::PropertyVector<int> const* material_ids(
mesh.getProperties().getPropertyVector<int>("MaterialIDs"));
_process_data._mesh_prop_materialIDs = material_ids;
_process_data.mesh_prop_materialIDs = material_ids;
}

template <int DisplacementDim>
Expand Down Expand Up @@ -304,17 +304,15 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess(
std::vector<FractureProperty*> e_fracture_props;
std::unordered_map<int, int> e_fracID_to_local;
unsigned tmpi = 0;
for (auto fid :
_process_data._vec_ele_connected_fractureIDs[e->getID()])
for (auto fid : _process_data.vec_ele_connected_fractureIDs[e->getID()])
{
e_fracture_props.push_back(&_process_data.fracture_properties[fid]);
e_fracID_to_local.insert({fid, tmpi++});
}
std::vector<JunctionProperty*> e_junction_props;
std::unordered_map<int, int> e_juncID_to_local;
tmpi = 0;
for (auto fid :
_process_data._vec_ele_connected_junctionIDs[e->getID()])
for (auto fid : _process_data.vec_ele_connected_junctionIDs[e->getID()])
{
e_junction_props.push_back(&_process_data.junction_properties[fid]);
e_juncID_to_local.insert({fid, tmpi++});
Expand Down Expand Up @@ -361,7 +359,7 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess(
MeshLib::MeshItemType::Cell, 1);

mesh_prop_b->resize(mesh.getNumberOfElements());
auto const& mesh_prop_matid = *_process_data._mesh_prop_materialIDs;
auto const& mesh_prop_matid = *_process_data.mesh_prop_materialIDs;
for (auto const& fracture_prop : _process_data.fracture_properties)
{
for (MeshLib::Element const* e : _mesh.getElements())
Expand All @@ -382,7 +380,7 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess(
.mean();
}
}
_process_data._mesh_prop_b = mesh_prop_b;
_process_data.mesh_prop_b = mesh_prop_b;
}

template <int DisplacementDim>
Expand Down
49 changes: 10 additions & 39 deletions ProcessLib/LIE/SmallDeformation/SmallDeformationProcessData.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,6 @@ namespace SmallDeformation
template <int DisplacementDim>
struct SmallDeformationProcessData
{
SmallDeformationProcessData(
MeshLib::PropertyVector<int> const* const material_ids_,
std::map<int,
std::unique_ptr<
MaterialLib::Solids::MechanicsBase<DisplacementDim>>>&&
solid_materials_,
std::unique_ptr<
MaterialLib::Fracture::FractureModelBase<DisplacementDim>>&&
fracture_model,
std::vector<FractureProperty>&& fracture_properties_,
double const reference_temperature)
: material_ids(material_ids_),
solid_materials{std::move(solid_materials_)},
_fracture_model{std::move(fracture_model)},
fracture_properties(std::move(fracture_properties_)),
_reference_temperature(reference_temperature)
{
}

SmallDeformationProcessData(SmallDeformationProcessData&& other) = default;

//! Copies are forbidden.
SmallDeformationProcessData(SmallDeformationProcessData const&) = delete;

//! Assignments are not needed.
void operator=(SmallDeformationProcessData const&) = delete;

//! Assignments are not needed.
void operator=(SmallDeformationProcessData&&) = delete;

MeshLib::PropertyVector<int> const* const material_ids;

/// The constitutive relation for the mechanical part.
Expand All @@ -71,26 +41,27 @@ struct SmallDeformationProcessData
solid_materials;

std::unique_ptr<MaterialLib::Fracture::FractureModelBase<DisplacementDim>>
_fracture_model;
fracture_model;
std::vector<FractureProperty> fracture_properties;
std::vector<JunctionProperty> junction_properties;

MeshLib::PropertyVector<int> const* _mesh_prop_materialIDs = nullptr;
std::vector<int> _map_materialID_to_fractureID;
double const reference_temperature;

std::vector<JunctionProperty> junction_properties = {};

MeshLib::PropertyVector<int> const* mesh_prop_materialIDs = nullptr;
std::vector<int> map_materialID_to_fractureID = {};

// a table of connected fracture IDs for each element
std::vector<std::vector<int>> _vec_ele_connected_fractureIDs;
std::vector<std::vector<int>> _vec_ele_connected_junctionIDs;
std::vector<std::vector<int>> vec_ele_connected_fractureIDs = {};
std::vector<std::vector<int>> vec_ele_connected_junctionIDs = {};

// mesh properties to output element's stress.
MeshLib::PropertyVector<double>* element_stresses = nullptr;
MeshLib::PropertyVector<double>* element_local_jumps = nullptr;
MeshLib::PropertyVector<double>* element_fracture_stresses = nullptr;

// mesh property for fracture aperture
MeshLib::PropertyVector<double>* _mesh_prop_b = nullptr;

double const _reference_temperature;
MeshLib::PropertyVector<double>* mesh_prop_b = nullptr;
};

} // namespace SmallDeformation
Expand Down

0 comments on commit 7917a6f

Please sign in to comment.