Skip to content
Snippets Groups Projects
Commit fd0fc30c authored by wenqing's avatar wenqing
Browse files

[M/Bbar] using std::optional as the return type

of the function to comput B_dil_bar matrix, and some other minor changes
parent ee66e627
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <Eigen/Core> #include <Eigen/Core>
#include <cmath> #include <cmath>
#include <optional>
#include "MeshLib/Elements/Elements.h" #include "MeshLib/Elements/Elements.h"
#include "NumLib/Fem/Integration/GenericIntegrationMethod.h" #include "NumLib/Fem/Integration/GenericIntegrationMethod.h"
...@@ -140,7 +141,7 @@ template <int DisplacementDim, int NPOINTS, typename BBarMatrixType, ...@@ -140,7 +141,7 @@ template <int DisplacementDim, int NPOINTS, typename BBarMatrixType,
void applyBbar(BBarMatrixType const& B_bar, BMatrixType& B, void applyBbar(BBarMatrixType const& B_bar, BMatrixType& B,
const bool is_axially_symmetric) const bool is_axially_symmetric)
{ {
if (DisplacementDim == 3) if constexpr (DisplacementDim == 3)
{ {
for (int i = 0; i < NPOINTS; ++i) for (int i = 0; i < NPOINTS; ++i)
{ {
...@@ -163,6 +164,7 @@ void applyBbar(BBarMatrixType const& B_bar, BMatrixType& B, ...@@ -163,6 +164,7 @@ void applyBbar(BBarMatrixType const& B_bar, BMatrixType& B,
return; return;
} }
// 2D or axisymmetry
for (int i = 0; i < NPOINTS; ++i) for (int i = 0; i < NPOINTS; ++i)
{ {
auto B_i_0 = B.col(i); auto B_i_0 = B.col(i);
...@@ -186,22 +188,23 @@ void applyBbar(BBarMatrixType const& B_bar, BMatrixType& B, ...@@ -186,22 +188,23 @@ void applyBbar(BBarMatrixType const& B_bar, BMatrixType& B,
/// Fills a B matrix, or a B bar matrix if required. /// Fills a B matrix, or a B bar matrix if required.
template <int DisplacementDim, int NPOINTS, typename BBarMatrixType, template <int DisplacementDim, int NPOINTS, typename BBarMatrixType,
typename BMatrixType, typename N_Type, typename DNDX_Type> typename BMatrixType, typename N_Type, typename DNDX_Type>
BMatrixType computeBMatrixPossiblyWithBbar(DNDX_Type const& dNdx, BMatrixType computeBMatrixPossiblyWithBbar(
N_Type const& N, DNDX_Type const& dNdx,
BBarMatrixType const& B_dil_bar, N_Type const& N,
const double radius, std::optional<BBarMatrixType> const& B_dil_bar,
const bool is_axially_symmetric, const double radius,
const bool use_b_bar) const bool is_axially_symmetric)
{ {
auto B = computeBMatrix<DisplacementDim, NPOINTS, BMatrixType, N_Type, auto B = computeBMatrix<DisplacementDim, NPOINTS, BMatrixType, N_Type,
DNDX_Type>(dNdx, N, radius, is_axially_symmetric); DNDX_Type>(dNdx, N, radius, is_axially_symmetric);
if (!use_b_bar)
if (!B_dil_bar)
{ {
return B; return B;
} }
detail::applyBbar<DisplacementDim, NPOINTS, BBarMatrixType, BMatrixType>( detail::applyBbar<DisplacementDim, NPOINTS, BBarMatrixType, BMatrixType>(
B_dil_bar, B, is_axially_symmetric); *B_dil_bar, B, is_axially_symmetric);
return B; return B;
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <optional>
#include <vector> #include <vector>
#include "LocalAssemblerInterface.h" #include "LocalAssemblerInterface.h"
...@@ -211,11 +212,11 @@ public: ...@@ -211,11 +212,11 @@ public:
"implemented."); "implemented.");
} }
BBarMatrixType getDilatationalBBarMatrix() const std::optional<BBarMatrixType> getDilatationalBBarMatrix() const
{ {
if (!(this->process_data_.use_b_bar)) if (!(this->process_data_.use_b_bar))
{ {
return {}; return std::nullopt;
} }
return LinearBMatrix::computeDilatationalBbar< return LinearBMatrix::computeDilatationalBbar<
...@@ -271,8 +272,7 @@ public: ...@@ -271,8 +272,7 @@ public:
auto const B = LinearBMatrix::computeBMatrixPossiblyWithBbar< auto const B = LinearBMatrix::computeBMatrixPossiblyWithBbar<
DisplacementDim, ShapeFunction::NPOINTS, BBarMatrixType, DisplacementDim, ShapeFunction::NPOINTS, BBarMatrixType,
typename BMatricesType::BMatrixType>( typename BMatricesType::BMatrixType>(
dNdx, N, B_dil_bar, x_coord, this->is_axially_symmetric_, dNdx, N, B_dil_bar, x_coord, this->is_axially_symmetric_);
this->process_data_.use_b_bar);
auto const CD = updateConstitutiveRelations( auto const CD = updateConstitutiveRelations(
B, u, u_prev, x_position, t, dt, constitutive_setting, medium, B, u, u_prev, x_position, t, dt, constitutive_setting, medium,
...@@ -321,8 +321,7 @@ public: ...@@ -321,8 +321,7 @@ public:
auto const B = LinearBMatrix::computeBMatrixPossiblyWithBbar< auto const B = LinearBMatrix::computeBMatrixPossiblyWithBbar<
DisplacementDim, ShapeFunction::NPOINTS, BBarMatrixType, DisplacementDim, ShapeFunction::NPOINTS, BBarMatrixType,
typename BMatricesType::BMatrixType>( typename BMatricesType::BMatrixType>(
dNdx, N, B_dil_bar, x_coord, this->is_axially_symmetric_, dNdx, N, B_dil_bar, x_coord, this->is_axially_symmetric_);
this->process_data_.use_b_bar);
updateConstitutiveRelations( updateConstitutiveRelations(
B, local_x, local_x_prev, x_position, t, dt, B, local_x, local_x_prev, x_position, t, dt,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment