6#ifndef __CELL_FORCES_HPP__
7#define __CELL_FORCES_HPP__
27 boost::shared_ptr<VectorDouble>
dispX;
28 boost::shared_ptr<VectorDouble>
dispY;
31 :
dispX(boost::shared_ptr<VectorDouble>(new VectorDouble())),
32 dispY(boost::shared_ptr<VectorDouble>(new VectorDouble())) {}
49 :
MoFEM::OpCalculateScalarFieldValues(
"DISP_X", common_data.dispX) {}
57 :
MoFEM::OpCalculateScalarFieldValues(
"DISP_Y", common_data.dispY) {}
78 MoFEMErrorCode
doWork(
int row_side,
int col_side, EntityType row_type,
80 DataForcesAndSourcesCore::EntData &row_data,
81 DataForcesAndSourcesCore::EntData &col_data) {
85 int nb_row = row_data.getIndices().size();
86 int nb_col = col_data.getIndices().size();
93 const VectorInt &row_indices = row_data.getIndices();
94 const VectorInt &col_indices = col_data.getIndices();
96 const int nb_gauss_pts = row_data.getN().size1();
98 C.resize(nb_row, nb_col,
false);
100 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
103 for (
int rr = 0; rr != nb_row; rr++) {
104 const double diff_nr_x = row_data.getDiffN()(gg, 2 * rr + 0);
105 const double diff_nr_y = row_data.getDiffN()(gg, 2 * rr + 1);
106 for (
int cc = 0; cc != nb_col; cc++) {
107 const double diff_nc_x = col_data.getDiffN()(gg, 2 * cc + 0);
108 const double diff_nc_y = col_data.getDiffN()(gg, 2 * cc + 1);
109 C(rr, cc) += val * (diff_nr_x * diff_nc_x + diff_nr_y * diff_nc_y);
114 CHKERR MatSetValues(
A, nb_row, &*row_indices.begin(), nb_col,
115 &*col_indices.begin(), &*
C.data().begin(), ADD_VALUES);
144 MoFEMErrorCode
doWork(
int row_side,
int col_side, EntityType row_type,
146 DataForcesAndSourcesCore::EntData &row_data,
147 DataForcesAndSourcesCore::EntData &col_data) {
151 int nb_row = row_data.getIndices().size();
152 int nb_col = col_data.getIndices().size();
159 const VectorInt &row_indices = row_data.getIndices();
160 const VectorInt &col_indices = col_data.getIndices();
162 const int nb_gauss_pts = row_data.getN().size1();
164 C.resize(nb_row, nb_col,
false);
166 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
169 for (
int rr = 0; rr != nb_row; rr++) {
170 const double diff_nr_x = row_data.getDiffN()(gg, 2 * rr + 0);
171 const double diff_nr_y = row_data.getDiffN()(gg, 2 * rr + 1);
172 for (
int cc = 0; cc != nb_col / 3; cc++) {
173 const double nc = col_data.getN(gg)[cc];
174 C(rr, 3 * cc + 0) -= val * diff_nr_x * nc;
175 C(rr, 3 * cc + 1) -= val * diff_nr_y * nc;
180 CHKERR MatSetValues(
A, nb_row, &*row_indices.begin(), nb_col,
181 &*col_indices.begin(), &*
C.data().begin(), ADD_VALUES);
206 MoFEMErrorCode
doWork(
int row_side,
int col_side, EntityType row_type,
208 DataForcesAndSourcesCore::EntData &row_data,
209 DataForcesAndSourcesCore::EntData &col_data) {
213 int nb_row = row_data.getIndices().size();
214 int nb_col = col_data.getIndices().size();
221 const VectorInt &row_indices = row_data.getIndices();
222 const VectorInt &col_indices = col_data.getIndices();
224 const int nb_gauss_pts = row_data.getN().size1();
226 C.resize(nb_row, nb_col,
false);
228 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
231 for (
int rr = 0; rr != nb_row / 3; rr++) {
232 const double nr = row_data.getN(gg)[rr];
233 for (
int cc = 0; cc != nb_col / 3; cc++) {
234 const double nc = col_data.getN(gg)[cc];
235 const double c = val * nr * nc;
236 C(3 * rr + 0, 3 * cc + 0) +=
c;
237 C(3 * rr + 1, 3 * cc + 1) +=
c;
242 CHKERR MatSetValues(
A, nb_row, &*row_indices.begin(), nb_col,
243 &*col_indices.begin(), &*
C.data().begin(), ADD_VALUES);
272 DataForcesAndSourcesCore::EntData &data) {
276 int nb_row = data.getIndices().size();
283 const int nb_gauss_pts = data.getN().size1();
285 nF.resize(nb_row,
false);
287 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
289 for (
int rr = 0; rr != nb_row / 3; rr++) {
290 const double nr = val * data.getN(gg)[rr];
291 nF[3 * rr + 0] += nr * disp_x[gg];
292 nF[3 * rr + 1] += nr * disp_y[gg];
296 CHKERR VecSetValues(
F, nb_row, &data.getIndices()[0], &
nF[0], ADD_VALUES);
321 MoFEMErrorCode
doWork(
int row_side,
int col_side, EntityType row_type,
323 DataForcesAndSourcesCore::EntData &row_data,
324 DataForcesAndSourcesCore::EntData &col_data) {
328 int nb_row = row_data.getIndices().size();
329 int nb_col = col_data.getIndices().size();
336 const VectorInt &row_indices = row_data.getIndices();
337 const VectorInt &col_indices = col_data.getIndices();
339 const int nb_gauss_pts = row_data.getN().size1();
341 auto t_diff_base_row = row_data.getFTensor2DiffN<3, 2>();
342 auto t_base_row = row_data.getFTensor1N<3>();
349 C.resize(nb_row, nb_col,
false);
351 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
354 for (
int rr = 0; rr != nb_row; rr++) {
355 const double curl_row = t_diff_base_row(1, 0) - t_diff_base_row(0, 1);
356 auto t_diff_base_col = col_data.getFTensor2DiffN<3, 2>(gg, 0);
357 auto t_base_col = col_data.getFTensor1N<3>(gg, 0);
358 for (
int cc = 0; cc != nb_col; cc++) {
359 const double curl_col = t_diff_base_col(1, 0) - t_diff_base_col(0, 1);
360 const double diag = val *
epsRho * t_base_row(
i) * t_base_col(
i);
362 epsL > 0 ? val * pow(
epsL, -1) * curl_row * curl_col : 0;
363 C(rr, cc) += diag + curl;
372 CHKERR MatSetValues(
A, nb_row, &*row_indices.begin(), nb_col,
373 &*col_indices.begin(), &*
C.data().begin(), ADD_VALUES);
396 MoFEMErrorCode
doWork(
int row_side,
int col_side, EntityType row_type,
398 DataForcesAndSourcesCore::EntData &row_data,
399 DataForcesAndSourcesCore::EntData &col_data) {
403 int nb_row = row_data.getIndices().size();
404 int nb_col = col_data.getIndices().size();
411 const VectorInt &row_indices = row_data.getIndices();
412 const VectorInt &col_indices = col_data.getIndices();
414 const int nb_gauss_pts = row_data.getN().size1();
416 auto t_base_row = row_data.getFTensor1N<3>();
418 C.resize(nb_row, nb_col,
false);
420 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
423 for (
int rr = 0; rr != nb_row; rr++) {
425 auto t_base_col = col_data.getFTensor0N(gg, 0);
426 for (
int cc = 0; cc != nb_col / 3; cc++) {
427 C(rr, 3 * cc + 0) -= val * t_base_row(0) * t_base_col;
428 C(rr, 3 * cc + 1) -= val * t_base_row(1) * t_base_col;
435 CHKERR MatSetValues(
A, nb_row, &*row_indices.begin(), nb_col,
436 &*col_indices.begin(), &*
C.data().begin(), ADD_VALUES);
464 DataForcesAndSourcesCore::EntData &data) {
469 if (data.getFieldData().empty())
472 const int nb_gauss_pts = data.getN().size1();
473 const int nb_dofs = data.getFieldData().size();
485 if (
type == MBVERTEX) {
486 mat->resize(nb_gauss_pts, 2,
false);
488 vec->resize(nb_gauss_pts,
false);
490 grad->resize(0, 0,
false);
494 for (
unsigned int gg = 0; gg < nb_gauss_pts; gg++) {
495 for (
int rr = 0; rr != nb_dofs; rr++) {
496 const double diff_base_x = data.getDiffN()(gg, 2 * rr + 0);
497 const double diff_base_y = data.getDiffN()(gg, 2 * rr + 1);
498 const double val = data.getFieldData()[rr];
499 (*mat)(gg, 0) += diff_base_x * val;
500 (*mat)(gg, 1) += diff_base_y * val;
501 const double base = data.getN()(gg, rr);
502 (*vec)[gg] += base * val;
532 DataForcesAndSourcesCore::EntData &data) {
537 if (data.getFieldData().empty())
540 const int nb_gauss_pts = data.getN().size1();
541 const int nb_dofs = data.getFieldData().size();
553 if (
type == MBEDGE && side == 0) {
554 mat->resize(nb_gauss_pts, 2,
false);
556 grad->resize(nb_gauss_pts, 4,
false);
558 vec->resize(0,
false);
562 auto t_base = data.getFTensor1N<3>();
563 auto t_diff_base_fun = data.getFTensor2DiffN<3, 2>();
565 for (
unsigned int gg = 0; gg < nb_gauss_pts; gg++) {
566 auto t_data = data.getFTensor0FieldData();
567 for (
int rr = 0; rr != nb_dofs; rr++) {
568 const double base_x = t_base(0);
569 const double base_y = t_base(1);
570 (*mat)(gg, 0) += base_x * t_data;
571 (*mat)(gg, 1) += base_y * t_data;
572 for (
int i = 0;
i != 2;
i++) {
573 for (
int j = 0;
j != 2;
j++) {
574 (*grad)(gg, 2 *
i +
j) += t_diff_base_fun(
i,
j) * t_data;
602 std::vector<EntityHandle> &map_gauss_pts,
613 DataForcesAndSourcesCore::EntData &data) {
616 if (
type != MBVERTEX)
619 double def_val[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
620 Tag th_force, th_force_potential, th_grad_force;
622 MB_TAG_CREAT | MB_TAG_SPARSE, def_val);
627 MB_TAG_CREAT | MB_TAG_SPARSE, def_val);
632 MB_TAG_CREAT | MB_TAG_SPARSE, def_val);
635 int nb_gauss_pts = data.getN().size1();
636 if (
mapGaussPts.size() != (
unsigned int)nb_gauss_pts) {
640 for (
int gg = 0; gg < nb_gauss_pts; gg++) {
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
FTensor::Index< 'j', 3 > j
implementation of Data Operators for Forces and Sources
constexpr auto field_name
MatrixDouble gradForceAtGaussPtrs
boost::shared_ptr< VectorDouble > dispY
VectorDouble forcePotentialAtGaussPoints
boost::shared_ptr< VectorDouble > dispX
MatrixDouble forceAtGaussPts
FaceElement(MoFEM::Interface &m_field)
int getRuleThroughThickness(int order)
int getRuleTrianglesOnly(int order)
FatPrism(MoFEM::Interface &m_field)
Calculate and assemble Z matrix.
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
OpCellCurlB(Mat a, const string field_name)
Calculate and assemble Z matrix.
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
OpCellCurlD(Mat a, const double eps_rho, const double eps_l)
Calculate and assemble B matrix.
OpCellPotentialB(Mat a, const string field_name)
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
Calculate and assemble D matrix.
OpCellPotentialD(Mat a, const double rho)
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
Calculate and assemble S matrix.
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
OpCellS(Mat a, const double eps_u)
Calculate and assemble g vector.
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
OpCell_g(Vec f, const double eps_u, CommonData &common_data)
OpGetDispX(CommonData &common_data)
OpGetDispY(CommonData &common_data)
OpVirtualCurlRho(std::string field_name, CommonData &common_data)
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
OpVirtualPotentialRho(std::string field_name, CommonData &common_data)
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
Shave results on mesh tags for post-processing.
PostProcTraction(MoFEM::Interface &m_field, moab::Interface &post_proc_mesh, std::vector< EntityHandle > &map_gauss_pts, CommonData &common_data)
MoFEM::Interface & mField
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
Here real work is done.
std::vector< EntityHandle > & mapGaussPts
moab::Interface & postProcMesh
bool sYmm
If true assume that matrix is symmetric structure.
Deprecated interface functions.
default operator for TRI element
double getArea()
get area of face
FatPrismElementForcesAndSourcesCore(Interface &m_field)
@ OPROW
operator doWork function is executed on FE rows
@ OPROWCOL
operator doWork is executed on FE rows &columns
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Specialization for double precision scalar field values calculation.