Skip to content

Commit b2d72ce

Browse files
committed
Use trailing return syntax for complex types
1 parent 550b35a commit b2d72ce

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

source/pbat/fem/DeformationGradient.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ namespace fem {
3636
*
3737
*/
3838
template <CElement TElement, class TDerivedx, class TDerivedX>
39-
Matrix<TDerivedx::RowsAtCompileTime, TElement::kDims>
40-
DeformationGradient(Eigen::MatrixBase<TDerivedx> const& x, Eigen::MatrixBase<TDerivedX> const& GP)
39+
auto DeformationGradient(
40+
Eigen::MatrixBase<TDerivedx> const& x,
41+
Eigen::MatrixBase<TDerivedX> const& GP) -> Matrix<TDerivedx::RowsAtCompileTime, TElement::kDims>
4142
{
4243
return x * GP;
4344
}
@@ -65,8 +66,8 @@ template <
6566
math::linalg::mini::CMatrix TMatrixGF,
6667
math::linalg::mini::CMatrix TMatrixGP,
6768
class ScalarType = typename TMatrixGF::ScalarType>
68-
math::linalg::mini::SVector<ScalarType, Dims>
69-
GradientSegmentWrtDofs(TMatrixGF const& GF, TMatrixGP const& GP, auto i)
69+
auto GradientSegmentWrtDofs(TMatrixGF const& GF, TMatrixGP const& GP, auto i)
70+
-> math::linalg::mini::SVector<ScalarType, Dims>
7071
{
7172
using namespace math::linalg::mini;
7273
SVector<ScalarType, Dims> dPsidx = Zeros<ScalarType, Dims, 1>{};
@@ -123,8 +124,8 @@ template <
123124
math::linalg::mini::CMatrix TMatrixGF,
124125
math::linalg::mini::CMatrix TMatrixGP,
125126
class ScalarType = typename TMatrixGF::ScalarType>
126-
math::linalg::mini::SVector<ScalarType, TElement::kNodes * Dims>
127-
GradientWrtDofs(TMatrixGF const& GF, TMatrixGP const& GP)
127+
auto GradientWrtDofs(TMatrixGF const& GF, TMatrixGP const& GP)
128+
-> math::linalg::mini::SVector<ScalarType, TElement::kNodes * Dims>
128129
{
129130
auto constexpr kRows = TElement::kNodes * Dims;
130131
using namespace math::linalg::mini;
@@ -166,8 +167,8 @@ template <
166167
math::linalg::mini::CMatrix TMatrixHF,
167168
math::linalg::mini::CMatrix TMatrixGP,
168169
class ScalarType = typename TMatrixHF::ScalarType>
169-
math::linalg::mini::SMatrix<ScalarType, Dims, Dims>
170-
HessianBlockWrtDofs(TMatrixHF const& HF, TMatrixGP const& GP, auto i, auto j)
170+
auto HessianBlockWrtDofs(TMatrixHF const& HF, TMatrixGP const& GP, auto i, auto j)
171+
-> math::linalg::mini::SMatrix<ScalarType, Dims, Dims>
171172
{
172173
using namespace math::linalg::mini;
173174
SMatrix<ScalarType, Dims, Dims> d2Psidx2 = Zeros<ScalarType, Dims, Dims>{};
@@ -228,8 +229,8 @@ template <
228229
math::linalg::mini::CMatrix TMatrixHF,
229230
math::linalg::mini::CMatrix TMatrixGP,
230231
class ScalarType = typename TMatrixHF::ScalarType>
231-
math::linalg::mini::SMatrix<ScalarType, TElement::kNodes * Dims, TElement::kNodes * Dims>
232-
HessianWrtDofs(TMatrixHF const& HF, TMatrixGP const& GP)
232+
auto HessianWrtDofs(TMatrixHF const& HF, TMatrixGP const& GP)
233+
-> math::linalg::mini::SMatrix<ScalarType, TElement::kNodes * Dims, TElement::kNodes * Dims>
233234
{
234235
auto constexpr kRows = TElement::kNodes * Dims;
235236
auto constexpr kCols = TElement::kNodes * Dims;

source/pbat/fem/Jacobian.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ namespace fem {
3838
* @return Matrix<TDerived::RowsAtCompileTime, TElement::kDims>
3939
*/
4040
template <CElement TElement, class TDerived>
41-
[[maybe_unused]] Matrix<TDerived::RowsAtCompileTime, TElement::kDims>
41+
[[maybe_unused]] auto
4242
Jacobian(Vector<TElement::kDims> const& X, Eigen::MatrixBase<TDerived> const& x)
43+
-> Matrix<TDerived::RowsAtCompileTime, TElement::kDims>
4344
{
4445
assert(x.cols() == TElement::kNodes);
4546
auto constexpr kDimsOut = TDerived::RowsAtCompileTime;
@@ -188,7 +189,7 @@ MatrixX InnerProductWeights(TMesh const& mesh, Eigen::MatrixBase<TDerivedDetJe>
188189
* the element whose vertices are \f$ x \f$.
189190
*
190191
* We use Gauss-Newton iterations on \f$ \min f \f$.
191-
* This gives the iteration
192+
* This gives the iteration
192193
* \f[
193194
* dx^{k+1} = [H(\xi^k)]^{-1} J_x(\xi^k)^T (x(\xi^k) - X)
194195
* \f]

source/pbat/fem/ShapeFunctions.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace fem {
3636
* of dimensions |# element nodes| x |# quad.pts.|
3737
*/
3838
template <CElement TElement, int QuadratureOrder>
39-
Matrix<TElement::kNodes, TElement::template QuadratureType<QuadratureOrder>::kPoints>
40-
ShapeFunctions()
39+
auto ShapeFunctions()
40+
-> Matrix<TElement::kNodes, TElement::template QuadratureType<QuadratureOrder>::kPoints>
4141
{
4242
using QuadratureRuleType = typename TElement::template QuadratureType<QuadratureOrder>;
4343
using ElementType = TElement;
@@ -275,15 +275,15 @@ MatrixX IntegratedShapeFunctions(TMesh const& mesh, Eigen::DenseBase<TDerived> c
275275
* \f{eqnarray*}{
276276
* \xi &= J^{-1} (X - X_0) \\
277277
* \nabla_X N(\xi(X)) &= \nabla_\xi N * J^{-1} \\
278-
* \nabla_X \phi^T &= J^{-T} \left[ \nabla_\xi N \right]^T
278+
* \nabla_X \phi^T &= J^{-T} \left[ \nabla_\xi N \right]^T
279279
* \f}
280280
* @note
281281
* If J is rectangular, then
282282
* \f{eqnarray*}{
283283
* (J^T J) \xi &= J^T (X - X_0) \\
284284
* \xi &= (J^T J)^{-1} J^T (X - X_0) \\
285285
* \nabla_X N(\xi(X)) &= \nabla_\xi N * (J^T J)^{-1} J^T \\
286-
* \left[ \nabla_X \phi \right]^T &= J (J^T J)^{-1} \left[ \nabla_\xi N \right]^T
286+
* \left[ \nabla_X \phi \right]^T &= J (J^T J)^{-1} \left[ \nabla_\xi N \right]^T
287287
* \f}
288288
* @note
289289
* For non-linear elements, like hexahedra or quadrilaterals, the accuracy of the gradients
@@ -299,9 +299,9 @@ MatrixX IntegratedShapeFunctions(TMesh const& mesh, Eigen::DenseBase<TDerived> c
299299
* @return |# nodes|x|Dims| matrix of basis function gradients in rows
300300
*/
301301
template <CElement TElement, class TDerivedXi, class TDerivedX>
302-
Matrix<TElement::kNodes, TDerivedX::RowsAtCompileTime> ShapeFunctionGradients(
302+
auto ShapeFunctionGradients(
303303
Eigen::MatrixBase<TDerivedXi> const& Xi,
304-
Eigen::MatrixBase<TDerivedX> const& X)
304+
Eigen::MatrixBase<TDerivedX> const& X) -> Matrix<TElement::kNodes, TDerivedX::RowsAtCompileTime>
305305
{
306306
auto constexpr kInputDims = TElement::kDims;
307307
auto constexpr kOutputDims = TDerivedX::RowsAtCompileTime;

0 commit comments

Comments
 (0)