41 DBUG(
"Assemble AnchorTerm.");
43 using GlobalDimVector = Eigen::Vector<double, GlobalDim>;
44 using GlobalDimMatrix = Eigen::Matrix<double, GlobalDim, GlobalDim>;
48 auto const element_id = element->getID();
53 std::vector<GlobalIndexType>
const global_indices =
55 assert(global_indices.size() == 2 * GlobalDim);
57 Eigen::Vector<double, 2 * GlobalDim>
const local_x =
60 Eigen::Vector<double, 2 * GlobalDim> local_rhs =
61 Eigen::Vector<double, 2 * GlobalDim>::Zero();
62 Eigen::Matrix<double, 2 * GlobalDim, 2 * GlobalDim> local_Jac =
63 Eigen::Matrix<double, 2 * GlobalDim, 2 * GlobalDim>::Zero();
67 auto node_local_indices = [](
int const i)
68 {
return Eigen::seqN(i, Eigen::fix<GlobalDim>, Eigen::fix<2>); };
70 auto node_coords = [element](
int const i)
71 {
return element->getNode(i)->asEigenVector3d(); };
72 GlobalDimVector
const l_original =
73 (node_coords(1) - node_coords(0)).
template head<GlobalDim>();
74 double const l_original_norm = l_original.norm();
77 auto u = [&local_x, &node_local_indices](
int const i)
78 {
return local_x(node_local_indices(i)); };
79 GlobalDimVector
const l = l_original + u(1) - u(0);
81 double const K = parameter_(t, pos)[0];
82 GlobalDimVector
const f = l_original / l_original_norm * K *
83 (l.norm() - l_original_norm) /
86 GlobalDimMatrix
const Df = l_original / l_original_norm * K *
87 l.transpose() / l.norm() / l_original_norm;
90 constexpr auto even_odd_sign = [](
int const n)
91 {
return (n % 2 == 0) ? 1.0 : -1.0; };
96 for (
int i = 0; i < 2; ++i)
98 local_rhs(node_local_indices(i)).noalias() += even_odd_sign(i) * f;
100 for (
int j = 0; j < 2; ++j)
102 local_Jac(node_local_indices(i), node_local_indices(j))
103 .noalias() += even_odd_sign(i) * even_odd_sign(j) * Df;
107 b.
add(global_indices, local_rhs);
110 jac->
add({global_indices, global_indices}, local_Jac);
AnchorTerm(std::unique_ptr< NumLib::LocalToGlobalIndexMap > source_term_dof_table, std::size_t const source_term_mesh_id, MeshLib::Mesh const &st_mesh, const int variable_id, ParameterLib::Parameter< double > const ¶meter)