259 MoFEMErrorCode
doWork(
int row_side,
int col_side, EntityType row_type,
261 EntitiesFieldData::EntData &row_data,
262 EntitiesFieldData::EntData &col_data) {
265 if (A == PETSC_NULLPTR)
267 if (row_data.getIndices().size() == 0)
269 if (col_data.getIndices().size() == 0)
272 const auto &dof_ptr = row_data.getFieldDofs()[0];
273 int rank = dof_ptr->getNbOfCoeffs();
274 int nb_row_dofs = row_data.getIndices().size() / rank;
275 int nb_col_dofs = col_data.getIndices().size() / rank;
276 NN.resize(nb_row_dofs, nb_col_dofs,
false);
278 unsigned int nb_gauss_pts = row_data.getN().size1();
279 for (
unsigned int gg = 0; gg != nb_gauss_pts; gg++) {
280 double w = getGaussPts()(2, gg);
281 if (getNormalsAtGaussPts().size1()) {
282 w *= 0.5 * cblas_dnrm2(3, &getNormalsAtGaussPts()(gg, 0), 1);
287 cblas_dger(CblasRowMajor, nb_row_dofs, nb_col_dofs, w,
288 &row_data.getN()(gg, 0), 1, &col_data.getN()(gg, 0), 1,
289 &*
NN.data().begin(), nb_col_dofs);
292 if ((row_type != col_type) || (row_side != col_side)) {
293 transNN.resize(nb_col_dofs, nb_row_dofs,
false);
297 double *data = &*
NN.data().begin();
298 double *trans_data = &*
transNN.data().begin();
299 VectorInt row_indices, col_indices;
300 row_indices.resize(nb_row_dofs);
301 col_indices.resize(nb_col_dofs);
302 for (
int rr = 0; rr < rank; rr++) {
303 if ((row_data.getIndices().size() % rank) != 0) {
305 "data inconsistency");
307 if ((col_data.getIndices().size() % rank) != 0) {
309 "data inconsistency");
311 unsigned int nb_rows;
312 unsigned int nb_cols;
316 ublas::noalias(row_indices) = ublas::vector_slice<VectorInt>(
317 row_data.getIndices(),
318 ublas::slice(rr, rank, row_data.getIndices().size() / rank));
319 ublas::noalias(col_indices) = ublas::vector_slice<VectorInt>(
320 col_data.getIndices(),
321 ublas::slice(rr, rank, col_data.getIndices().size() / rank));
322 nb_rows = row_indices.size();
323 nb_cols = col_indices.size();
324 rows = &*row_indices.data().begin();
325 cols = &*col_indices.data().begin();
327 nb_rows = row_data.getIndices().size();
328 nb_cols = col_data.getIndices().size();
329 rows = &*row_data.getIndices().data().begin();
330 cols = &*col_data.getIndices().data().begin();
332 if (nb_rows !=
NN.size1()) {
334 "data inconsistency");
336 if (nb_cols !=
NN.size2()) {
338 "data inconsistency");
340 CHKERR MatSetValues(A, nb_rows, rows, nb_cols, cols, data, ADD_VALUES);
341 if ((row_type != col_type) || (row_side != col_side)) {
342 if (nb_rows !=
transNN.size2()) {
344 "data inconsistency");
346 if (nb_cols !=
transNN.size1()) {
348 "data inconsistency");
350 CHKERR MatSetValues(A, nb_cols, cols, nb_rows, rows, trans_data,
359 MoFEMErrorCode
doWork(
int side, EntityType type,
360 EntitiesFieldData::EntData &data) {
363 if (data.getIndices().size() == 0)
366 const auto &dof_ptr = data.getFieldDofs()[0];
367 unsigned int rank = dof_ptr->getNbOfCoeffs();
369 int nb_row_dofs = data.getIndices().size() / rank;
371 if (getCoordsAtGaussPts().size1() != data.getN().size1()) {
373 "data inconsistency");
375 if (getCoordsAtGaussPts().size2() != 3) {
377 "data inconsistency");
380 VectorDouble normal(3);
381 VectorDouble tangent1(3);
382 VectorDouble tangent2(3);
387 unsigned int nb_gauss_pts = data.getN().size1();
388 for (
unsigned int gg = 0; gg != nb_gauss_pts; gg++) {
389 double w = getGaussPts()(2, gg);
390 w *= 0.5 * cblas_dnrm2(3, &getNormalsAtGaussPts()(gg, 0), 1);
393 const double x = getCoordsAtGaussPts()(gg, 0);
394 const double y = getCoordsAtGaussPts()(gg, 1);
395 const double z = getCoordsAtGaussPts()(gg, 2);
397 if (getNormalsAtGaussPts().size1()) {
398 noalias(normal) = getNormalsAtGaussPts(gg);
399 for (
int dd = 0; dd < 3; dd++) {
400 tangent1[dd] = getTangent1AtGaussPts()(gg, dd);
401 tangent2[dd] = getTangent2AtGaussPts()(gg, dd);
404 noalias(normal) = getNormal();
407 std::vector<VectorDouble> fun_val;
408 EntityHandle ent = getFEMethod()->numeredEntFiniteElementPtr->getEnt();
410 if (fun_val.size() !=
vecF.size()) {
412 "data inconsistency");
415 Nf.resize(fun_val.size());
416 for (
unsigned int lhs = 0; lhs != fun_val.size(); lhs++) {
418 Nf[lhs].resize(data.getIndices().size());
421 if (fun_val[lhs].size() != rank) {
423 "data inconsistency");
425 for (
unsigned int rr = 0; rr != rank; rr++) {
426 cblas_daxpy(nb_row_dofs, w * (fun_val[lhs])[rr],
427 &data.getN()(gg, 0), 1, &(
Nf[lhs])[rr], rank);
432 for (
unsigned int lhs = 0; lhs !=
vecF.size(); lhs++) {
434 CHKERR VecSetValues(
vecF[lhs], data.getIndices().size(),
435 &data.getIndices()[0], &(
Nf[lhs])[0], ADD_VALUES);