54 for (
unsigned int nd = 0; nd < _nnodes; ++nd)
57 std::vector<dof_id_type> ivardofs(_nnodes);
59 std::vector<dof_id_type> neighbors = _pdmesh.getNeighbors(_current_elem->node_id(nd));
60 std::vector<dof_id_type> bonds = _pdmesh.getBonds(_current_elem->node_id(nd));
63 RealGradient origin_vec_nb, current_vec_nb;
65 for (
unsigned int nb = 0; nb < neighbors.size(); ++nb)
66 if (_bond_status_var->getElementalValue(_pdmesh.elemPtr(bonds[nb])) > 0.5)
69 _pdmesh.nodePtr(neighbors[nb])->dof_number(_sys.number(), _var.number(), 0);
70 vol_nb = _pdmesh.getNodeVolume(neighbors[nb]);
73 _pdmesh.getNodeCoord(neighbors[nb]) - _pdmesh.getNodeCoord(_current_elem->node_id(nd));
75 for (
unsigned int i = 0; i < _dim; ++i)
76 current_vec_nb(i) = origin_vec_nb(i) +
77 _disp_var[i]->getNodalValue(*_pdmesh.nodePtr(neighbors[nb])) -
78 _disp_var[i]->getNodalValue(*_current_elem->node_ptr(nd));
80 current_vec_nb /= current_vec_nb.
norm();
83 origin_vec_nb.norm() * current_vec_nb(
_component) * _bond_status;
84 _local_re(1) = -_local_re(0);
88 addResiduals(_assembly, _local_re, ivardofs, _var.scalingFactor());
93 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
94 for (
unsigned int i = 0; i < _save_in.size(); ++i)
96 std::vector<dof_id_type> save_in_dofs(2);
97 save_in_dofs[nd] = _current_elem->node_ptr(nd)->dof_number(
98 _save_in[i]->sys().number(), _save_in[i]->number(), 0);
99 save_in_dofs[1 - nd] =
100 _pdmesh.nodePtr(neighbors[nb])
101 ->dof_number(_save_in[i]->sys().number(), _save_in[i]->number(), 0);
103 _save_in[i]->sys().solution().add_vector(_local_re, save_in_dofs);
149 for (
unsigned int nd = 0; nd < _nnodes; ++nd)
152 std::vector<dof_id_type> ivardofs(_nnodes);
154 std::vector<dof_id_type> neighbors = _pdmesh.getNeighbors(_current_elem->node_id(nd));
155 std::vector<dof_id_type> bonds = _pdmesh.getBonds(_current_elem->node_id(nd));
158 RealGradient origin_vec_nb, current_vec_nb;
160 for (
unsigned int nb = 0; nb < neighbors.size(); ++nb)
161 if (_bond_status_var->getElementalValue(_pdmesh.elemPtr(bonds[nb])) > 0.5)
164 _pdmesh.nodePtr(neighbors[nb])->dof_number(_sys.number(), _var.number(), 0);
165 vol_nb = _pdmesh.getNodeVolume(neighbors[nb]);
168 _pdmesh.getNodeCoord(neighbors[nb]) - _pdmesh.getNodeCoord(_current_elem->node_id(nd));
170 for (
unsigned int k = 0; k < _dim; ++k)
171 current_vec_nb(k) = origin_vec_nb(k) +
172 _disp_var[k]->getNodalValue(*_pdmesh.nodePtr(neighbors[nb])) -
173 _disp_var[k]->getNodalValue(*_current_elem->node_ptr(nd));
175 current_vec_nb /= current_vec_nb.
norm();
177 const Real val = (nd == 0 ? 1 : -1) * current_vec_nb(
_component) *
181 for (
unsigned int i = 0; i < _nnodes; ++i)
182 for (
unsigned int j = 0; j < _nnodes; ++j)
184 (i == j ? 1 : -1) * val / origin_vec_nb.norm() * vol_nb * _bond_status;
186 addJacobian(_assembly, _local_ke, ivardofs,
_ivardofs, _var.scalingFactor());
188 if (_has_diag_save_in)
190 unsigned int rows = _nnodes;
191 DenseVector<Real> diag(rows);
192 for (
unsigned int i = 0; i < rows; ++i)
193 diag(i) = _local_ke(i, i);
197 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
198 for (
unsigned int i = 0; i < _diag_save_in.size(); ++i)
200 std::vector<dof_id_type> diag_save_in_dofs(2);
201 diag_save_in_dofs[nd] = _current_elem->node_ptr(nd)->dof_number(
202 _diag_save_in[i]->sys().number(), _diag_save_in[i]->number(), 0);
203 diag_save_in_dofs[1 - nd] =
204 _pdmesh.nodePtr(neighbors[nb])
205 ->dof_number(_diag_save_in[i]->sys().number(), _diag_save_in[i]->number(), 0);
207 _diag_save_in[i]->sys().solution().add_vector(diag, diag_save_in_dofs);
213 current_vec_nb.norm();
216 for (
unsigned int i = 0; i < _nnodes; ++i)
217 for (
unsigned int j = 0; j < _nnodes; ++j)
219 (i == j ? 1 : -1) * val2 / origin_vec_nb.norm() * vol_nb * _bond_status;
221 addJacobian(_assembly, _local_ke, ivardofs, ivardofs, _var.scalingFactor());
223 if (_has_diag_save_in)
225 unsigned int rows = _nnodes;
226 DenseVector<Real> diag(rows);
227 for (
unsigned int i = 0; i < rows; ++i)
228 diag(i) = _local_ke(i, i);
230 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
231 for (
unsigned int i = 0; i < _diag_save_in.size(); ++i)
233 std::vector<dof_id_type> diag_save_in_dofs(2);
234 diag_save_in_dofs[nd] = _current_elem->node_ptr(nd)->dof_number(
235 _diag_save_in[i]->sys().number(), _diag_save_in[i]->number(), 0);
236 diag_save_in_dofs[1 - nd] =
237 _pdmesh.nodePtr(neighbors[nb])
238 ->dof_number(_diag_save_in[i]->sys().number(), _diag_save_in[i]->number(), 0);
240 _diag_save_in[i]->sys().solution().add_vector(diag, diag_save_in_dofs);
249 unsigned int coupled_component)
251 std::vector<dof_id_type> jvardofs_ij(_nnodes);
252 for (
unsigned int nd = 0; nd < _nnodes; ++nd)
253 jvardofs_ij[nd] = _current_elem->node_ptr(nd)->dof_number(_sys.number(), jvar_num, 0);
255 for (
unsigned int nd = 0; nd < _nnodes; ++nd)
258 std::vector<dof_id_type> ivardofs(_nnodes), jvardofs(_nnodes);
260 jvardofs[nd] = jvardofs_ij[nd];
261 std::vector<dof_id_type> neighbors = _pdmesh.getNeighbors(_current_elem->node_id(nd));
262 std::vector<dof_id_type> bonds = _pdmesh.getBonds(_current_elem->node_id(nd));
265 RealGradient origin_vec_nb, current_vec_nb;
267 for (
unsigned int nb = 0; nb < neighbors.size(); ++nb)
268 if (_bond_status_var->getElementalValue(_pdmesh.elemPtr(bonds[nb])) > 0.5)
271 _pdmesh.nodePtr(neighbors[nb])->dof_number(_sys.number(), _var.number(), 0);
272 jvardofs[1 - nd] = _pdmesh.nodePtr(neighbors[nb])->dof_number(_sys.number(), jvar_num, 0);
273 vol_nb = _pdmesh.getNodeVolume(neighbors[nb]);
276 _pdmesh.getNodeCoord(neighbors[nb]) - _pdmesh.getNodeCoord(_current_elem->node_id(nd));
278 for (
unsigned int i = 0; i < _dim; ++i)
279 current_vec_nb(i) = origin_vec_nb(i) +
280 _disp_var[i]->getNodalValue(*_pdmesh.nodePtr(neighbors[nb])) -
281 _disp_var[i]->getNodalValue(*_current_elem->node_ptr(nd));
283 current_vec_nb /= current_vec_nb.
norm();
291 _local_ke(0, nd) += (nd == 0 ? -1 : 1) * val * _bond_status;
292 _local_ke(1, nd) += (nd == 0 ? 1 : -1) * val * _bond_status;
296 const Real val = (nd == 0 ? 1 : -1) * current_vec_nb(
_component) *
298 origin_vec_nb.norm() * vol_nb;
300 for (
unsigned int i = 0; i < _nnodes; ++i)
301 for (
unsigned int j = 0; j < _nnodes; ++j)
302 _local_ke(i, j) += (i == j ? 1 : -1) * val * _bond_status;
305 addJacobian(_assembly, _local_ke, ivardofs, jvardofs_ij, _var.scalingFactor());