35 namespace FiniteElement {
54 Eigen::MatrixXd
NB(
const Eigen::VectorXd&
N,
55 const int nDoFPerNode );
57 template <
int nDim,
int nNodes >
58 Eigen::Matrix< double, nDim, nDim * nNodes >
NB(
const Eigen::Matrix< double, 1, nNodes >&
N )
61 Eigen::Matrix< double, nDim, nDim* nNodes > N_ = Eigen::Matrix< double, nDim, nDim * nNodes >::Zero();
62 for (
int i = 0; i <
nNodes; i++ ) {
63 for (
int j = 0; j <
nDim; j++ ) {
64 N_( j,
nDim * i + j ) =
N( i );
70 Eigen::MatrixXd
Jacobian(
const Eigen::MatrixXd& dN_dXi,
71 const Eigen::VectorXd& coordinates );
73 template <
int nDim,
int nNodes >
74 Eigen::Matrix< double, nDim, nDim >
Jacobian(
const Eigen::Matrix< double, nDim, nNodes >&
dNdXi,
75 const Eigen::Matrix< double, nDim * nNodes, 1 >& coordinates )
79 Eigen::Matrix< double, nDim, nDim > J_ = Eigen::Matrix< double, nDim, nDim >::Zero();
80 for (
int i = 0; i <
nDim; i++ )
81 for (
int j = 0; j <
nDim; j++ )
82 for (
int k = 0; k <
nNodes; k++ )
83 J_( i, j ) +=
dNdXi( j, k ) * coordinates( i + k *
nDim );
93 using NSized = Eigen::Matrix< double, 1, nNodes >;
103 using NSized = Eigen::Matrix< double, 1, nNodes >;
111 namespace Spatial2D {
115 template <
int nNodes >
116 Eigen::Matrix< double, voigtSize, nNodes * nDim >
B(
const Eigen::Matrix< double, nDim, nNodes >& dNdX )
119 Eigen::Matrix< double, voigtSize, nNodes* nDim > B_ = Eigen::Matrix< double, voigtSize, nNodes * nDim >::Zero();
120 for (
int i = 0; i <
nNodes; i++ ) {
121 B_( 0, 2 * i ) = dNdX( 0, i );
122 B_( 1, 2 * i + 1 ) = dNdX( 1, i );
123 B_( 2, 2 * i ) = dNdX( 1, i );
124 B_( 2, 2 * i + 1 ) = dNdX( 0, i );
129 template <
int nNodes >
130 Eigen::Matrix< double, voigtSize, nNodes * nDim >
BGreen(
const Eigen::Matrix< double, nDim, nNodes >& dNdX,
131 const Eigen::Matrix2d&
F )
135 Eigen::Matrix< double, voigtSize, nNodes* nDim > B_ = Eigen::Matrix< double, voigtSize, nNodes * nDim >::Zero();
136 for (
int i = 0; i <
nNodes; i++ ) {
137 B_( 0, 2 * i ) = dNdX( 0, i ) *
F( 0, 0 );
138 B_( 0, 2 * i + 1 ) = dNdX( 0, i ) *
F( 1, 0 );
139 B_( 1, 2 * i ) = dNdX( 1, i ) *
F( 0, 1 );
140 B_( 1, 2 * i + 1 ) = dNdX( 1, i ) *
F( 1, 1 );
141 B_( 2, 2 * i ) = dNdX( 0, i ) *
F( 0, 1 ) + dNdX( 1, i ) *
F( 0, 0 );
142 B_( 2, 2 * i + 1 ) = dNdX( 0, i ) *
F( 1, 1 ) + dNdX( 1, i ) *
F( 1, 0 );
151 using NSized = Eigen::Matrix< double, 1, nNodes >;
164 using NSized = Eigen::Matrix< double, 1, nNodes >;
175 namespace Spatial3D {
179 template <
int nNodes >
180 Eigen::Matrix< double, voigtSize, nNodes * nDim >
B(
const Eigen::Matrix< double, nDim, nNodes >& dNdX )
191 Eigen::Matrix< double, voigtSize, nNodes* nDim > B_ = Eigen::Matrix< double, voigtSize, nNodes * nDim >::Zero();
193 for (
int i = 0; i <
nNodes; i++ ) {
194 B_( 0,
nDim * i ) = dNdX( 0, i );
195 B_( 1,
nDim * i + 1 ) = dNdX( 1, i );
196 B_( 2,
nDim * i + 2 ) = dNdX( 2, i );
197 B_( 3,
nDim * i + 0 ) = dNdX( 1, i );
198 B_( 3,
nDim * i + 1 ) = dNdX( 0, i );
199 B_( 4,
nDim * i + 0 ) = dNdX( 2, i );
200 B_( 4,
nDim * i + 2 ) = dNdX( 0, i );
201 B_( 5,
nDim * i + 1 ) = dNdX( 2, i );
202 B_( 5,
nDim * i + 2 ) = dNdX( 1, i );
208 template <
int nNodes >
209 Eigen::Matrix< double, voigtSize, nNodes * nDim >
BGreen(
const Eigen::Matrix< double, nDim, nNodes >& dNdX,
215 Eigen::Matrix< double, voigtSize, nNodes* nDim > B_ = Eigen::Matrix< double, voigtSize, nNodes * nDim >::Zero();
216 for (
int i = 0; i <
nNodes; i++ ) {
217 B_( 0,
nDim * i ) = dNdX( 0, i ) *
F( 0, 0 );
218 B_( 0,
nDim * i + 1 ) = dNdX( 0, i ) *
F( 1, 0 );
219 B_( 0,
nDim * i + 2 ) = dNdX( 0, i ) *
F( 2, 0 );
221 B_( 1,
nDim * i ) = dNdX( 1, i ) *
F( 0, 1 );
222 B_( 1,
nDim * i + 1 ) = dNdX( 1, i ) *
F( 1, 1 );
223 B_( 1,
nDim * i + 2 ) = dNdX( 1, i ) *
F( 2, 1 );
225 B_( 2,
nDim * i ) = dNdX( 2, i ) *
F( 0, 2 );
226 B_( 2,
nDim * i + 1 ) = dNdX( 2, i ) *
F( 1, 2 );
227 B_( 2,
nDim * i + 2 ) = dNdX( 2, i ) *
F( 2, 2 );
229 B_( 3,
nDim * i ) = dNdX( 0, i ) *
F( 0, 1 ) + dNdX( 1, i ) *
F( 0, 0 );
230 B_( 3,
nDim * i + 1 ) = dNdX( 0, i ) *
F( 1, 1 ) + dNdX( 1, i ) *
F( 1, 0 );
231 B_( 3,
nDim * i + 2 ) = dNdX( 0, i ) *
F( 2, 1 ) + dNdX( 1, i ) *
F( 2, 0 );
233 B_( 4,
nDim * i ) = dNdX( 0, i ) *
F( 0, 2 ) + dNdX( 2, i ) *
F( 0, 0 );
234 B_( 4,
nDim * i + 1 ) = dNdX( 0, i ) *
F( 1, 2 ) + dNdX( 2, i ) *
F( 1, 0 );
235 B_( 4,
nDim * i + 2 ) = dNdX( 0, i ) *
F( 2, 2 ) + dNdX( 2, i ) *
F( 2, 0 );
237 B_( 5,
nDim * i ) = dNdX( 2, i ) *
F( 0, 1 ) + dNdX( 1, i ) *
F( 0, 2 );
238 B_( 5,
nDim * i + 1 ) = dNdX( 2, i ) *
F( 1, 1 ) + dNdX( 1, i ) *
F( 1, 2 );
239 B_( 5,
nDim * i + 2 ) = dNdX( 2, i ) *
F( 2, 1 ) + dNdX( 1, i ) *
F( 2, 2 );
248 using NSized = Eigen::Matrix< double, 1, nNodes >;
262 using NSized = Eigen::Matrix< double, 1, nNodes >;
275 using NSized = Eigen::Matrix< double, 1, nNodes >;
287 using NSized = Eigen::Matrix< double, 1, nNodes >;
327 int parentFaceNumber,
328 const Eigen::VectorXd& parentCoordinates );
343 Eigen::Ref< Eigen::VectorXd > ParentVector );
348 Eigen::Ref< Eigen::VectorXd > ParentVector );
350 Eigen::Ref< Eigen::MatrixXd > KParent );
354 namespace FiniteElement::Quadrature {
355 constexpr
double gp2 = 0.577350269189625764509;
356 constexpr
double gp3 = 0.774596669241483;
370 namespace Spatial1D {
375 { ( Eigen::VectorXd ( 1 ) << 0 ).finished(), 2.0 }
379 { ( Eigen::VectorXd ( 1 ) << -
gp2 ).finished(), 1.0 },
380 { ( Eigen::VectorXd ( 1 ) << +
gp2 ).finished(), 1.0 }
384 { ( Eigen::VectorXd ( 1 ) << -
gp3 ).finished(), 5./9 },
385 { ( Eigen::VectorXd ( 1 ) << 0. ).finished(), 8./9 },
386 { ( Eigen::VectorXd ( 1 ) << +
gp3 ).finished(), 5./9 }
392 namespace Spatial2D {
397 { Eigen::Vector2d::Zero(), 4. }
401 { ( Eigen::Vector2d () << +
gp2, +
gp2 ).finished(), 1.0 },
402 { ( Eigen::Vector2d () << -
gp2, +
gp2 ).finished(), 1.0 },
403 { ( Eigen::Vector2d () << -
gp2, -
gp2 ).finished(), 1.0 },
404 { ( Eigen::Vector2d () << +
gp2, -
gp2 ).finished(), 1.0 }
408 { ( Eigen::Vector2d () << 0, 0. ).finished(), 64./81},
409 { ( Eigen::Vector2d () << -
gp3, -
gp3 ).finished(), 25./81},
410 { ( Eigen::Vector2d () << +
gp3, -
gp3 ).finished(), 25./81},
411 { ( Eigen::Vector2d () << +
gp3, +
gp3 ).finished(), 25./81},
412 { ( Eigen::Vector2d () << -
gp3, +
gp3 ).finished(), 25./81},
413 { ( Eigen::Vector2d () << 0, -
gp3 ).finished(), 40./81},
414 { ( Eigen::Vector2d () <<
gp3, 0. ).finished(), 40./81},
415 { ( Eigen::Vector2d () << 0, +
gp3 ).finished(), 40./81},
416 { ( Eigen::Vector2d () << -
gp3, 0. ).finished(), 40./81},
423 namespace Spatial3D {
428 { Eigen::Vector3d::Zero(), 8.0 }
436 { (
Eigen::Vector3d() << (5-std::sqrt(5))/20, (5-std::sqrt(5))/20, (5-std::sqrt(5))/20 ).finished(), 1./24},
437 { (
Eigen::Vector3d() << (5-std::sqrt(5))/20, (5-std::sqrt(5))/20, (5+3*std::sqrt(5))/20 ).finished(), 1./24},
438 { (
Eigen::Vector3d() << (5-std::sqrt(5))/20, (5+3*std::sqrt(5))/20, (5-std::sqrt(5))/20 ).finished(), 1./24},
439 { (
Eigen::Vector3d() << (5+3*std::sqrt(5))/20, (5-std::sqrt(5))/20, (5-std::sqrt(5))/20 ).finished(), 1./24},