Skip to content

Commit

Permalink
[PL] LIE; Add braces around statements;
Browse files Browse the repository at this point in the history
clang-tidy '*readability-braces-around-statements'
  • Loading branch information
endJunction committed Dec 10, 2018
1 parent 6baf7c9 commit 4904a1b
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ProcessLib/LIE/Common/FractureProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ inline void setFractureProperty(int const dim, MeshLib::Element const& e,
// 1st node is used but using other node is also possible, because
// a fracture is not curving
for (int j = 0; j < 3; j++)
{
frac_prop.point_on_fracture[j] = e.getCenterOfGravity().getCoords()[j];
}
computeNormalVector(e, dim, frac_prop.normal_vector);
frac_prop.R.resize(dim, dim);
computeRotationMatrix(e, frac_prop.normal_vector, dim, frac_prop.R);
Expand Down
2 changes: 2 additions & 0 deletions ProcessLib/LIE/Common/HMatrixUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ void computeHMatrix(N_Type const& N, HMatrixType& H)
H.setZero();

for (unsigned j = 0; j < DisplacementDim; j++)
{
H.block(j, j * NPOINTS, 1, NPOINTS) = N;
}
}

} // namespace ProcessLib
2 changes: 2 additions & 0 deletions ProcessLib/LIE/Common/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ MathLib::Point3d computePhysicalCoordinates(
{
MeshLib::Node const& node = *e.getNode(i);
for (unsigned j = 0; j < 3; j++)
{
pt[j] += shape[i] * node[j];
}
}
return pt;
}
Expand Down
6 changes: 6 additions & 0 deletions ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ std::unique_ptr<Process> createHydroMechanicsProcess(
if (!use_monolithic_scheme)
{
if (pv_name == "pressure")
{
p_process_variables.emplace_back(
const_cast<ProcessVariable&>(*variable));
}
else
{
u_process_variables.emplace_back(
Expand All @@ -113,15 +115,19 @@ std::unique_ptr<Process> createHydroMechanicsProcess(
}

if (p_u_process_variables.size() > 3 || u_process_variables.size() > 2)
{
OGS_FATAL("Currently only one displacement jump is supported");
}

if (!use_monolithic_scheme)
{
process_variables.push_back(std::move(p_process_variables));
process_variables.push_back(std::move(u_process_variables));
}
else
{
process_variables.push_back(std::move(p_u_process_variables));
}

auto solid_constitutive_relations =
MaterialLib::Solids::createConstitutiveRelations<GlobalDim>(parameters,
Expand Down
14 changes: 14 additions & 0 deletions ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ HydroMechanicsProcess<GlobalDim>::HydroMechanicsProcess(
if (std::find(vec_fracture_mat_IDs.begin(),
vec_fracture_mat_IDs.end(),
matID) == vec_fracture_mat_IDs.end())
{
vec_p_inactive_matIDs.push_back(matID);
}
}
_process_data.p_element_status =
std::make_unique<MeshLib::ElementStatus>(&mesh,
Expand Down Expand Up @@ -300,7 +302,9 @@ void HydroMechanicsProcess<GlobalDim>::initializeConcreteProcess(
for (MeshLib::Element const* e : _mesh.getElements())
{
if (e->getDimension() < GlobalDim)
{
continue;
}

std::vector<FractureProperty*> fracture_props(
{_process_data.fracture_property.get()});
Expand Down Expand Up @@ -336,9 +340,13 @@ void HydroMechanicsProcess<GlobalDim>::initializeConcreteProcess(
for (MeshLib::Element const* e : _mesh.getElements())
{
if (e->getDimension() == GlobalDim)
{
continue;
}
if ((*mesh_prop_matid)[e->getID()] != frac->mat_id)
{
continue;
}
ProcessLib::SpatialPosition x;
x.setElementID(e->getID());
(*mesh_prop_b)[e->getID()] = frac->aperture0(0, x)[0];
Expand Down Expand Up @@ -501,7 +509,9 @@ void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
// skip aperture computation for element-wise defined b0 because there
// are jumps on the nodes between the element's values.
if (dynamic_cast<MeshElementParameter<double> const*>(&b0))
{
return std::numeric_limits<double>::quiet_NaN();
}

ProcessLib::SpatialPosition x;
x.setNodeID(node_id);
Expand All @@ -514,11 +524,15 @@ void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
auto const node_id = node->getID();
g.setZero();
for (int k = 0; k < GlobalDim; k++)
{
g[k] = mesh_prop_g[node_id * GlobalDim + k];
}

w.noalias() = R * g;
for (int k = 0; k < GlobalDim; k++)
{
vec_w[node_id * GlobalDim + k] = w[k];
}

vec_b[node_id] = compute_nodal_aperture(node_id, w[GlobalDim - 1]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,12 @@ void HydroMechanicsLocalAssemblerFracture<ShapeFunctionDisplacement,
// aperture
b_m = ip_data.aperture0 + w[index_normal];
if (b_m < 0.0)
{
OGS_FATAL(
"Element %d, gp %d: Fracture aperture is %g, but it must be "
"non-negative.",
_element.getID(), ip, b_m);
}

auto const initial_effective_stress =
_process_data.initial_fracture_effective_stress(0, x_position);
Expand Down Expand Up @@ -352,10 +354,12 @@ void HydroMechanicsLocalAssemblerFracture<ShapeFunctionDisplacement,
// aperture
b_m = ip_data.aperture0 + w[index_normal];
if (b_m < 0.0)
{
OGS_FATAL(
"Element %d, gp %d: Fracture aperture is %g, but it must be "
"non-negative.",
_element.getID(), ip, b_m);
}

auto const initial_effective_stress =
_process_data.initial_fracture_effective_stress(0, x_position);
Expand Down Expand Up @@ -411,8 +415,10 @@ void HydroMechanicsLocalAssemblerFracture<ShapeFunctionDisplacement,
}

for (unsigned i = 0; i < 3; i++)
{
(*_process_data.mesh_prop_velocity)[element_id * 3 + i] =
ele_velocity[i];
}
}

} // namespace HydroMechanics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class HydroMechanicsLocalAssemblerFracture
double const /*delta_t*/) override
{
for (auto& data : _ip_data)
{
data.pushBackState();
}
}

void computeSecondaryVariableConcreteWithVector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ class HydroMechanicsLocalAssemblerInterface

_local_u.setZero();
for (unsigned i = 0; i < local_dof_size; i++)
{
_local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
}
_local_udot.setZero();
for (unsigned i = 0; i < local_dof_size; i++)
{
_local_udot[_dofIndex_to_localIndex[i]] = local_xdot_[i];
}
_local_b.setZero();
_local_J.setZero();

Expand All @@ -80,13 +84,19 @@ class HydroMechanicsLocalAssemblerInterface

local_b_data.resize(local_dof_size);
for (unsigned i = 0; i < local_dof_size; i++)
{
local_b_data[i] = _local_b[_dofIndex_to_localIndex[i]];
}

local_Jac_data.resize(local_dof_size * local_dof_size);
for (unsigned i = 0; i < local_dof_size; i++)
{
for (unsigned j = 0; j < local_dof_size; j++)
{
local_Jac_data[i * local_dof_size + j] = _local_J(
_dofIndex_to_localIndex[i], _dofIndex_to_localIndex[j]);
}
}
}

void computeSecondaryVariableConcrete(
Expand All @@ -96,7 +106,9 @@ class HydroMechanicsLocalAssemblerInterface

_local_u.setZero();
for (unsigned i = 0; i < local_dof_size; i++)
{
_local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
}

computeSecondaryVariableConcreteWithVector(t, _local_u);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
ip_data.dNdx_u = sm_u.dNdx;
ip_data.H_u.setZero(GlobalDim, displacement_size);
for (int i = 0; i < GlobalDim; ++i)
{
ip_data.H_u
.template block<1, displacement_size / GlobalDim>(
i, i * displacement_size / GlobalDim)
.noalias() = ip_data.N_u;
}

ip_data.N_p = sm_p.N;
ip_data.dNdx_p = sm_p.dNdx;
Expand Down Expand Up @@ -243,7 +245,9 @@ void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
*state, _process_data.reference_temperature);

if (!solution)
{
OGS_FATAL("Computation of local constitutive relation failed.");
}

MathLib::KelvinVector::KelvinMatrixType<GlobalDim> C;
std::tie(sigma_eff, state, C) = std::move(*solution);
Expand Down Expand Up @@ -308,7 +312,9 @@ void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
auto p = const_cast<Eigen::VectorXd&>(local_x).segment(pressure_index,
pressure_size);
if (_process_data.deactivate_matrix_in_flow)
{
setPressureOfInactiveNodes(t, p);
}
auto u = local_x.segment(displacement_index, displacement_size);

computeSecondaryVariableConcreteWithBlockVectors(t, p, u);
Expand Down Expand Up @@ -361,7 +367,9 @@ void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
*state, _process_data.reference_temperature);

if (!solution)
{
OGS_FATAL("Computation of local constitutive relation failed.");
}

MathLib::KelvinVector::KelvinMatrixType<GlobalDim> C;
std::tie(sigma_eff, state, C) = std::move(*solution);
Expand Down Expand Up @@ -419,8 +427,10 @@ void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
}

for (unsigned i = 0; i < 3; i++)
{
(*_process_data.mesh_prop_velocity)[element_id * 3 + i] =
ele_velocity[i];
}

NumLib::interpolateToHigherOrderNodes<
ShapeFunctionPressure, typename ShapeFunctionDisplacement::MeshElement,
Expand All @@ -442,7 +452,9 @@ void HydroMechanicsLocalAssemblerMatrix<
{
// only inactive nodes
if (_process_data.p_element_status->isActiveNode(_element.getNode(i)))
{
continue;
}
x_position.setNodeID(_element.getNodeIndex(i));
auto const p0 = (*_process_data.p0)(t, x_position)[0];
p[i] = p0;
Expand All @@ -459,7 +471,9 @@ void HydroMechanicsLocalAssemblerMatrix<
{
// only inactive nodes
if (_process_data.p_element_status->isActiveNode(_element.getNode(i)))
{
continue;
}
p_dot[i] = 0;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class HydroMechanicsLocalAssemblerMatrix
double const /*delta_t*/) override
{
for (auto& data : _ip_data)
{
data.pushBackState();
}
}

Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ void HydroMechanicsLocalAssemblerMatrixNearFracture<
auto p = const_cast<Eigen::VectorXd&>(local_x).segment(pressure_index,
pressure_size);
if (_process_data.deactivate_matrix_in_flow)
{
Base::setPressureOfInactiveNodes(t, p);
}
auto u = local_x.segment(displacement_index, displacement_size);

// levelset value of the element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ class LocalDataInitializer final
: _dof_table(dof_table)
{
if (shapefunction_order != 2)
{
OGS_FATAL(
"The given shape function order %d is not supported.\nOnly "
"shape functions of order 2 are supported.",
shapefunction_order);
}
// /// Quads and Hexahedra ///////////////////////////////////

#if (OGS_ENABLED_ELEMENTS & ENABLED_ELEMENT_TYPE_QUAD) != 0 && \
Expand Down Expand Up @@ -205,7 +207,9 @@ class LocalDataInitializer final
std::vector<int> involved_varIDs; // including deactived elements
involved_varIDs.reserve(varIDs.size() + 1);
if (isPressureDeactivated)
{
involved_varIDs.push_back(0); // always pressure come in
}
involved_varIDs.insert(involved_varIDs.end(), varIDs.begin(),
varIDs.end());

Expand All @@ -219,8 +223,10 @@ class LocalDataInitializer final
mesh_item.getNumberOfBaseNodes()); // pressure
auto const max_varID = *std::max_element(varIDs.begin(), varIDs.end());
for (int i = 1; i < max_varID + 1; i++)
{
vec_n_element_nodes.push_back(
mesh_item.getNumberOfNodes()); // displacements
}

unsigned local_id = 0;
unsigned dof_id = 0;
Expand All @@ -242,7 +248,9 @@ class LocalDataInitializer final
auto global_index =
_dof_table.getGlobalIndex(l, var_id, var_comp_id);
if (global_index != NumLib::MeshComponentMap::nop)
{
dofIndex_to_localIndex[dof_id++] = local_id;
}
local_id++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ std::unique_ptr<Process> createSmallDeformationProcess(
"'displacement_junctionN'");
}
if (pv_name.find("displacement_jump") == 0)
{
n_var_du++;
}

auto variable = std::find_if(variables.cbegin(), variables.cend(),
[&pv_name](ProcessVariable const& v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,12 @@ void SmallDeformationLocalAssemblerFracture<ShapeFunction, IntegrationMethod,
// aperture
b_m = ip_data._aperture0 + w[index_normal];
if (b_m < 0.0)
{
OGS_FATAL(
"Element %d, gp %d: Fracture aperture is %g, but it must be "
"non-negative.",
_element.getID(), ip, b_m);
}

// local C, local stress
mat.computeConstitutiveRelation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class SmallDeformationLocalAssemblerInterface
{
_local_u.setZero();
for (std::size_t i = 0; i < local_x_.size(); i++)
{
_local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
}
}

computeSecondaryVariableConcreteWithVector(t, _local_u);
Expand Down
2 changes: 2 additions & 0 deletions ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,9 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess(
for (MeshLib::Element const* e : _mesh.getElements())
{
if (e->getDimension() < DisplacementDim)
{
continue;
}

Eigen::Vector3d const pt(e->getCenterOfGravity().getCoords());
std::vector<FractureProperty*> e_fracture_props;
Expand Down

0 comments on commit 4904a1b

Please sign in to comment.