v0.14.0
Public Member Functions | Public Attributes | List of all members
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian Struct Reference

#include <users_modules/basic_finite_elements/src/ConvectiveMassElement.hpp>

Inheritance diagram for ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian:
[legend]
Collaboration diagram for ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian:
[legend]

Public Member Functions

 OpEshelbyDynamicMaterialMomentumJacobian (const std::string field_name, BlockData &data, CommonData &common_data, int tag, bool jacobian=true)
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntitiesFieldData::EntData &row_data)
 

Public Attributes

BlockDatadAta
 
CommonDatacommonData
 
int tAg
 
bool jAcobian
 
bool fieldDisp
 
VectorBoundedArray< adouble, 3 > a
 
VectorBoundedArray< adouble, 3 > v
 
VectorBoundedArray< adouble, 3 > a_T
 
MatrixBoundedArray< adouble, 9 > g
 
MatrixBoundedArray< adouble, 9 > H
 
MatrixBoundedArray< adouble, 9 > invH
 
MatrixBoundedArray< adouble, 9 > h
 
MatrixBoundedArray< adouble, 9 > F
 
MatrixBoundedArray< adouble, 9 > G
 
VectorDouble active
 

Detailed Description

Definition at line 347 of file ConvectiveMassElement.hpp.

Constructor & Destructor Documentation

◆ OpEshelbyDynamicMaterialMomentumJacobian()

ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::OpEshelbyDynamicMaterialMomentumJacobian ( const std::string  field_name,
BlockData data,
CommonData common_data,
int  tag,
bool  jacobian = true 
)

Definition at line 1234 of file ConvectiveMassElement.cpp.

1239  field_name, ForcesAndSourcesCore::UserDataOperator::OPROW),
1240  dAta(data), commonData(common_data), tAg(tag), jAcobian(jacobian),
1241  fieldDisp(false) {}

Member Function Documentation

◆ doWork()

MoFEMErrorCode ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::doWork ( int  row_side,
EntityType  row_type,
EntitiesFieldData::EntData row_data 
)

Definition at line 1244 of file ConvectiveMassElement.cpp.

1245  {
1247 
1248  if (dAta.tEts.find(getNumeredEntFiniteElementPtr()->getEnt()) ==
1249  dAta.tEts.end()) {
1251  }
1252 
1253  // do it only once, no need to repeat this for edges,faces or tets
1254  if (row_type != MBVERTEX)
1256 
1257  int nb_dofs = row_data.getIndices().size();
1258  if (nb_dofs == 0)
1260 
1261  try {
1262 
1263  a.resize(3);
1264  v.resize(3);
1265  g.resize(3, 3);
1266  G.resize(3, 3);
1267  h.resize(3, 3);
1268  F.resize(3, 3);
1269  H.resize(3, 3);
1270  H.clear();
1271  invH.resize(3, 3);
1272  invH.clear();
1273  for (int dd = 0; dd < 3; dd++) {
1274  H(dd, dd) = 1;
1275  invH(dd, dd) = 1;
1276  }
1277 
1278  int nb_gauss_pts = row_data.getN().size1();
1279  commonData.valT.resize(nb_gauss_pts);
1280  commonData.jacTRowPtr.resize(nb_gauss_pts);
1281  commonData.jacT.resize(nb_gauss_pts);
1282 
1283  int nb_active_vars = 0;
1284  for (int gg = 0; gg < nb_gauss_pts; gg++) {
1285 
1286  if (gg == 0) {
1287 
1288  trace_on(tAg);
1289 
1290  for (int nn1 = 0; nn1 < 3; nn1++) { // 0
1291  a[nn1] <<=
1293  [gg][nn1];
1294  nb_active_vars++;
1295  }
1296 
1297  for (int nn1 = 0; nn1 < 3; nn1++) { // 3
1298  v[nn1] <<=
1300  nb_active_vars++;
1301  }
1302  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3
1303  for (int nn2 = 0; nn2 < 3; nn2++) {
1304  g(nn1, nn2) <<=
1306  nn1, nn2);
1307  nb_active_vars++;
1308  }
1309  }
1310  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3+9
1311  for (int nn2 = 0; nn2 < 3; nn2++) {
1312  h(nn1, nn2) <<=
1314  nn2);
1315  nb_active_vars++;
1316  if (fieldDisp) {
1317  if (nn1 == nn2) {
1318  h(nn1, nn2) += 1;
1319  }
1320  }
1321  }
1322  }
1324  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3+9+9
1325  for (int nn2 = 0; nn2 < 3; nn2++) {
1326  H(nn1, nn2) <<=
1328  nn2);
1329  nb_active_vars++;
1330  }
1331  }
1332  }
1333  adouble detH;
1334  detH = 1;
1336  detH = determinantTensor3by3(H);
1337  }
1338  CHKERR invertTensor3by3(H, detH, invH);
1339 
1343 
1344  a_T.resize(3);
1345 
1346  auto t_h = getFTensor2FromArray3by3(h, FTensor::Number<0>(), 0);
1347  auto t_invH = getFTensor2FromArray3by3(invH, FTensor::Number<0>(), 0);
1348  auto t_F = getFTensor2FromArray3by3(F, FTensor::Number<0>(), 0);
1349  auto t_g = getFTensor2FromArray3by3(g, FTensor::Number<0>(), 0);
1350  auto t_G = getFTensor2FromArray3by3(G, FTensor::Number<0>(), 0);
1351 
1352  auto t_a = FTensor::Tensor1<adouble *, 3>{&a[0], &a[1], &a[2]};
1353  auto t_v = FTensor::Tensor1<adouble *, 3>{&v[0], &v[1], &v[2]};
1354  auto t_a_T = FTensor::Tensor1<adouble *, 3>{&a_T[0], &a_T[1], &a_T[2]};
1355 
1356  t_F(i, j) = t_h(i, k) * t_invH(k, j);
1357  t_G(i, j) = t_g(i, k) * t_invH(k, j);
1358  t_a_T(i) = t_F(k, i) * t_a(k) + t_G(k, i) * t_v(k);
1359  const auto rho0 = dAta.rho0;
1360  t_a_T(i) = -rho0 * detH;
1361 
1362  commonData.valT[gg].resize(3);
1363  for (int nn = 0; nn < 3; nn++) {
1364  a_T[nn] >>= (commonData.valT[gg])[nn];
1365  }
1366  trace_off();
1367  }
1368 
1369  active.resize(nb_active_vars);
1370  int aa = 0;
1371  for (int nn1 = 0; nn1 < 3; nn1++) { // 0
1372  active[aa++] =
1373  commonData
1374  .dataAtGaussPts["DOT_" + commonData.spatialVelocities][gg][nn1];
1375  }
1376 
1377  for (int nn1 = 0; nn1 < 3; nn1++) { // 3
1378  active[aa++] =
1380  }
1381  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3
1382  for (int nn2 = 0; nn2 < 3; nn2++) {
1383  active[aa++] =
1385  nn2);
1386  }
1387  }
1388  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3+9
1389  for (int nn2 = 0; nn2 < 3; nn2++) {
1390  if (fieldDisp && nn1 == nn2) {
1391  active[aa++] =
1393  nn1, nn2) +
1394  1;
1395  } else {
1396  active[aa++] =
1398  nn2);
1399  }
1400  }
1401  }
1403  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3+9+9
1404  for (int nn2 = 0; nn2 < 3; nn2++) {
1405  active[aa++] =
1407  nn2);
1408  }
1409  }
1410  }
1411 
1412  if (!jAcobian) {
1413  VectorDouble &res = commonData.valT[gg];
1414  if (gg > 0) {
1415  res.resize(3);
1416  int r;
1417  r = ::function(tAg, 3, nb_active_vars, &active[0], &res[0]);
1418  if (r != 3) { // function is locally analytic
1419  SETERRQ1(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
1420  "ADOL-C function evaluation with error r = %d", r);
1421  }
1422  }
1423  double val = getVolume() * getGaussPts()(3, gg);
1424  res *= val;
1425  } else {
1426  commonData.jacTRowPtr[gg].resize(3);
1427  commonData.jacT[gg].resize(3, nb_active_vars);
1428  for (int nn1 = 0; nn1 < 3; nn1++) {
1429  (commonData.jacTRowPtr[gg])[nn1] = &(commonData.jacT[gg](nn1, 0));
1430  }
1431  int r;
1432  r = jacobian(tAg, 3, nb_active_vars, &active[0],
1433  &(commonData.jacTRowPtr[gg])[0]);
1434  if (r != 3) {
1435  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
1436  "ADOL-C function evaluation with error");
1437  }
1438  double val = getVolume() * getGaussPts()(3, gg);
1439  commonData.jacT[gg] *= val;
1440  }
1441  }
1442 
1443  } catch (const std::exception &ex) {
1444  std::ostringstream ss;
1445  ss << "throw in method: " << ex.what() << std::endl;
1446  SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
1447  }
1448 
1450 }

Member Data Documentation

◆ a

VectorBoundedArray<adouble, 3> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::a

Definition at line 362 of file ConvectiveMassElement.hpp.

◆ a_T

VectorBoundedArray<adouble, 3> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::a_T

Definition at line 362 of file ConvectiveMassElement.hpp.

◆ active

VectorDouble ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::active

Definition at line 364 of file ConvectiveMassElement.hpp.

◆ commonData

CommonData& ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::commonData

Definition at line 352 of file ConvectiveMassElement.hpp.

◆ dAta

BlockData& ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::dAta

Definition at line 351 of file ConvectiveMassElement.hpp.

◆ F

MatrixBoundedArray<adouble, 9> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::F

Definition at line 363 of file ConvectiveMassElement.hpp.

◆ fieldDisp

bool ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::fieldDisp

Definition at line 355 of file ConvectiveMassElement.hpp.

◆ G

MatrixBoundedArray<adouble, 9> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::G

Definition at line 363 of file ConvectiveMassElement.hpp.

◆ g

MatrixBoundedArray<adouble, 9> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::g

Definition at line 363 of file ConvectiveMassElement.hpp.

◆ H

MatrixBoundedArray<adouble, 9> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::H

Definition at line 363 of file ConvectiveMassElement.hpp.

◆ h

MatrixBoundedArray<adouble, 9> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::h

Definition at line 363 of file ConvectiveMassElement.hpp.

◆ invH

MatrixBoundedArray<adouble, 9> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::invH

Definition at line 363 of file ConvectiveMassElement.hpp.

◆ jAcobian

bool ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::jAcobian

Definition at line 354 of file ConvectiveMassElement.hpp.

◆ tAg

int ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::tAg

Definition at line 353 of file ConvectiveMassElement.hpp.

◆ v

VectorBoundedArray<adouble, 3> ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::v

Definition at line 362 of file ConvectiveMassElement.hpp.


The documentation for this struct was generated from the following files:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::v
VectorBoundedArray< adouble, 3 > v
Definition: ConvectiveMassElement.hpp:362
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::commonData
CommonData & commonData
Definition: ConvectiveMassElement.hpp:352
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::dAta
BlockData & dAta
Definition: ConvectiveMassElement.hpp:351
ConvectiveMassElement::CommonData::jacT
std::vector< MatrixDouble > jacT
Definition: ConvectiveMassElement.hpp:146
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::active
VectorDouble active
Definition: ConvectiveMassElement.hpp:364
ConvectiveMassElement::BlockData::tEts
Range tEts
elements in block set
Definition: ConvectiveMassElement.hpp:119
ConvectiveMassElement::CommonData::spatialVelocities
string spatialVelocities
Definition: ConvectiveMassElement.hpp:137
ConvectiveMassElement::CommonData::dataAtGaussPts
std::map< std::string, std::vector< VectorDouble > > dataAtGaussPts
Definition: ConvectiveMassElement.hpp:133
ConvectiveMassElement::CommonData::jacTRowPtr
std::vector< std::vector< double * > > jacTRowPtr
Definition: ConvectiveMassElement.hpp:145
sdf.r
int r
Definition: sdf.py:8
MoFEM::invertTensor3by3
MoFEMErrorCode invertTensor3by3(ublas::matrix< T, L, A > &jac_data, ublas::vector< T, A > &det_data, ublas::matrix< T, L, A > &inv_jac_data)
Calculate inverse of tensor rank 2 at integration points.
Definition: Templates.hpp:1588
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::jAcobian
bool jAcobian
Definition: ConvectiveMassElement.hpp:354
ConvectiveMassElement::CommonData::gradAtGaussPts
std::map< std::string, std::vector< MatrixDouble > > gradAtGaussPts
Definition: ConvectiveMassElement.hpp:134
FTensor::Number< 0 >
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::H
MatrixBoundedArray< adouble, 9 > H
Definition: ConvectiveMassElement.hpp:363
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::invH
MatrixBoundedArray< adouble, 9 > invH
Definition: ConvectiveMassElement.hpp:363
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1214
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::g
MatrixBoundedArray< adouble, 9 > g
Definition: ConvectiveMassElement.hpp:363
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::a
VectorBoundedArray< adouble, 3 > a
Definition: ConvectiveMassElement.hpp:362
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::F
MatrixBoundedArray< adouble, 9 > F
Definition: ConvectiveMassElement.hpp:363
MOFEM_OPERATION_UNSUCCESSFUL
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition: definitions.h:34
ConvectiveMassElement::CommonData::spatialPositions
string spatialPositions
Definition: ConvectiveMassElement.hpp:135
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
FTensor::Index< 'i', 3 >
ConvectiveMassElement::CommonData::valT
std::vector< VectorDouble > valT
Definition: ConvectiveMassElement.hpp:144
ConvectiveMassElement::BlockData::rho0
double rho0
reference density
Definition: ConvectiveMassElement.hpp:117
MoFEM::getFTensor2FromArray3by3
auto getFTensor2FromArray3by3(ublas::matrix< T, L, A > &data, const FTensor::Number< S > &, const size_t rr, const size_t cc=0)
Definition: Templates.hpp:1342
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::h
MatrixBoundedArray< adouble, 9 > h
Definition: ConvectiveMassElement.hpp:363
MoFEM::determinantTensor3by3
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
Definition: Templates.hpp:1540
adouble
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
MoFEM::EntitiesFieldData::EntData::getN
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
Definition: EntitiesFieldData.hpp:1318
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::a_T
VectorBoundedArray< adouble, 3 > a_T
Definition: ConvectiveMassElement.hpp:362
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::fieldDisp
bool fieldDisp
Definition: ConvectiveMassElement.hpp:355
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::G
MatrixBoundedArray< adouble, 9 > G
Definition: ConvectiveMassElement.hpp:363
MoFEM::Types::VectorDouble
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
ConvectiveMassElement::CommonData::meshPositions
string meshPositions
Definition: ConvectiveMassElement.hpp:136
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
ConvectiveMassElement::OpEshelbyDynamicMaterialMomentumJacobian::tAg
int tAg
Definition: ConvectiveMassElement.hpp:353
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20