40{
41 DBUG(
"Assemble AnchorTerm.");
42
45
47 {
48 auto const element_id = element->getID();
49
52
53 std::vector<GlobalIndexType> const global_indices =
55 assert(global_indices.size() == 2 * GlobalDim);
56
57 Eigen::Vector<double, 2 * GlobalDim> const local_x =
59
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();
64
65
66
67 auto node_local_indices = [](int const i)
68 { return Eigen::seqN(i, Eigen::fix<GlobalDim>, Eigen::fix<2>); };
69
70 auto node_coords = [element](int const i)
71 { return element->getNode(i)->asEigenVector3d(); };
73 (node_coords(1) - node_coords(0)).template head<GlobalDim>();
74 double const l_original_norm = l_original.norm();
75
76
77 auto u = [&local_x, &node_local_indices](int const i)
78 { return local_x(node_local_indices(i)); };
80
83 (l.norm() - l_original_norm) /
84 l_original_norm;
85
87 l.transpose() / l.norm() / l_original_norm;
88
89
90 constexpr auto even_odd_sign = [](int const n)
91 { return (n % 2 == 0) ? 1.0 : -1.0; };
92
93
94
95
96 for (int i = 0; i < 2; ++i)
97 {
98 local_rhs(node_local_indices(i)).noalias() += even_odd_sign(i) * f;
99
100 for (int j = 0; j < 2; ++j)
101 {
102 local_Jac(node_local_indices(i), node_local_indices(j))
103 .noalias() += even_odd_sign(i) * even_odd_sign(j) * Df;
104 }
105 }
106
107 b.
add(global_indices, local_rhs);
108 if (jac)
109 {
110 jac->
add({global_indices, global_indices}, local_Jac);
111 }
112 }
113}
int add(IndexType row, IndexType col, double val)
void add(IndexType rowId, double v)
add entry
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
void setElementID(std::size_t element_id)
std::unique_ptr< NumLib::LocalToGlobalIndexMap > const _source_term_dof_table
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)