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

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

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

Public Member Functions

 OpVelocityJacobian (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_res
 
VectorBoundedArray< adouble, 3 > v
 
VectorBoundedArray< adouble, 3 > dot_w
 
VectorBoundedArray< adouble, 3 > dot_W
 
VectorBoundedArray< adouble, 3 > dot_u
 
MatrixBoundedArray< adouble, 9 > h
 
MatrixBoundedArray< adouble, 9 > H
 
MatrixBoundedArray< adouble, 9 > invH
 
MatrixBoundedArray< adouble, 9 > F
 
adouble detH
 
std::vector< doubleactive
 

Detailed Description

Definition at line 279 of file ConvectiveMassElement.hpp.

Constructor & Destructor Documentation

◆ OpVelocityJacobian()

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

Definition at line 788 of file ConvectiveMassElement.cpp.

792  field_name, ForcesAndSourcesCore::UserDataOperator::OPROW),
793  dAta(data), commonData(common_data), tAg(tag), jAcobian(jacobian),
794  fieldDisp(false) {}

Member Function Documentation

◆ doWork()

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

Definition at line 796 of file ConvectiveMassElement.cpp.

797  {
799 
800  if (dAta.tEts.find(getNumeredEntFiniteElementPtr()->getEnt()) ==
801  dAta.tEts.end()) {
803  }
804 
805  // do it only once, no need to repeat this for edges,faces or tets
806  if (row_type != MBVERTEX)
808 
809  int nb_dofs = row_data.getIndices().size();
810  if (nb_dofs == 0)
812 
813  {
814 
815  v.resize(3);
816  dot_w.resize(3);
817  h.resize(3, 3);
818  h.clear();
819  F.resize(3, 3);
820  dot_W.resize(3);
821  dot_W.clear();
822  H.resize(3, 3);
823  H.clear();
824  invH.resize(3, 3);
825  invH.clear();
826  dot_u.resize(3);
827  for (int dd = 0; dd < 3; dd++) {
828  H(dd, dd) = 1;
829  invH(dd, dd) = 1;
830  }
831 
832  a_res.resize(3);
833  int nb_gauss_pts = row_data.getN().size1();
834  commonData.valVel.resize(nb_gauss_pts);
835  commonData.jacVelRowPtr.resize(nb_gauss_pts);
836  commonData.jacVel.resize(nb_gauss_pts);
837 
838  int nb_active_vars = 0;
839  for (int gg = 0; gg < nb_gauss_pts; gg++) {
840 
841  if (gg == 0) {
842 
843  trace_on(tAg);
844 
845  for (int nn1 = 0; nn1 < 3; nn1++) { // 0
846  v[nn1] <<=
848  nb_active_vars++;
849  }
850  for (int nn1 = 0; nn1 < 3; nn1++) { // 3
851  dot_w[nn1] <<=
853  [gg][nn1];
854  nb_active_vars++;
855  }
857  .size() > 0) {
858  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3 = 6
859  for (int nn2 = 0; nn2 < 3; nn2++) {
860  h(nn1, nn2) <<=
862  nn1, nn2);
863  if (fieldDisp) {
864  if (nn1 == nn2) {
865  h(nn1, nn2) += 1;
866  }
867  }
868  nb_active_vars++;
869  }
870  }
871  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3+9
872  dot_W[nn1] <<=
873  commonData
874  .dataAtGaussPts["DOT_" + commonData.meshPositions][gg][nn1];
875  nb_active_vars++;
876  }
877  }
879  for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3+9+3
880  for (int nn2 = 0; nn2 < 3; nn2++) {
881  H(nn1, nn2) <<=
883  nn2);
884  nb_active_vars++;
885  }
886  }
887  }
888  detH = 1;
889 
893 
897  auto t_invH = getFTensor2FromArray3by3(invH, FTensor::Number<0>(), 0);
898  auto t_dot_u =
900  auto t_dot_w =
902  auto t_dot_W =
904  auto t_v = FTensor::Tensor1<adouble *, 3>{&v[0], &v[1], &v[2]};
905  auto t_a_res =
907 
911  t_F(i, j) = t_h(i, k) * t_invH(k, j);
912  } else {
913  t_F(i, j) = t_h(i, j);
914  }
915 
916  t_dot_u(i) = t_dot_w(i) + t_F(i, j) * t_dot_W(j);
917  t_a_res(i) = t_v(i) - t_dot_u(i);
918  t_a_res(i) *= detH;
919 
920  // dependant
921  VectorDouble &res = commonData.valVel[gg];
922  res.resize(3);
923  for (int rr = 0; rr < 3; rr++) {
924  a_res[rr] >>= res[rr];
925  }
926  trace_off();
927  }
928 
929  active.resize(nb_active_vars);
930  int aa = 0;
931  for (int nn1 = 0; nn1 < 3; nn1++) {
932  active[aa++] =
934  }
935  for (int nn1 = 0; nn1 < 3; nn1++) {
936  active[aa++] =
937  commonData
938  .dataAtGaussPts["DOT_" + commonData.spatialPositions][gg][nn1];
939  }
940  if (commonData.dataAtGaussPts["DOT_" + commonData.meshPositions].size() >
941  0) {
942  for (int nn1 = 0; nn1 < 3; nn1++) {
943  for (int nn2 = 0; nn2 < 3; nn2++) {
944  if (fieldDisp && nn1 == nn2) {
945  active[aa++] =
947  nn1, nn2) +
948  1;
949  } else {
950  active[aa++] =
952  nn1, nn2);
953  }
954  }
955  }
956  for (int nn1 = 0; nn1 < 3; nn1++) {
957  active[aa++] =
958  commonData
959  .dataAtGaussPts["DOT_" + commonData.meshPositions][gg][nn1];
960  }
961  }
963  for (int nn1 = 0; nn1 < 3; nn1++) {
964  for (int nn2 = 0; nn2 < 3; nn2++) {
965  active[aa++] =
967  nn2);
968  }
969  }
970  }
971 
972  if (!jAcobian) {
973  VectorDouble &res = commonData.valVel[gg];
974  if (gg > 0) {
975  res.resize(3);
976  int r;
977  r = ::function(tAg, 3, nb_active_vars, &active[0], &res[0]);
978  if (r != 3) {
979  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
980  "ADOL-C function evaluation with error");
981  }
982  }
983  double val = getVolume() * getGaussPts()(3, gg);
984  res *= val;
985  } else {
986  commonData.jacVelRowPtr[gg].resize(3);
987  commonData.jacVel[gg].resize(3, nb_active_vars);
988  for (int nn1 = 0; nn1 < 3; nn1++) {
989  (commonData.jacVelRowPtr[gg])[nn1] = &(commonData.jacVel[gg](nn1, 0));
990  }
991  int r;
992  r = jacobian(tAg, 3, nb_active_vars, &active[0],
993  &(commonData.jacVelRowPtr[gg])[0]);
994  if (r != 3) {
995  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
996  "ADOL-C function evaluation with error");
997  }
998  double val = getVolume() * getGaussPts()(3, gg);
999  commonData.jacVel[gg] *= val;
1000  // std::cerr << gg << " : " << commonData.jacVel[gg] << std::endl;
1001  }
1002  }
1003  }
1005 }

Member Data Documentation

◆ a_res

VectorBoundedArray<adouble, 3> ConvectiveMassElement::OpVelocityJacobian::a_res

Definition at line 291 of file ConvectiveMassElement.hpp.

◆ active

std::vector<double> ConvectiveMassElement::OpVelocityJacobian::active

Definition at line 295 of file ConvectiveMassElement.hpp.

◆ commonData

CommonData& ConvectiveMassElement::OpVelocityJacobian::commonData

Definition at line 284 of file ConvectiveMassElement.hpp.

◆ dAta

BlockData& ConvectiveMassElement::OpVelocityJacobian::dAta

Definition at line 283 of file ConvectiveMassElement.hpp.

◆ detH

adouble ConvectiveMassElement::OpVelocityJacobian::detH

Definition at line 293 of file ConvectiveMassElement.hpp.

◆ dot_u

VectorBoundedArray<adouble, 3> ConvectiveMassElement::OpVelocityJacobian::dot_u

Definition at line 291 of file ConvectiveMassElement.hpp.

◆ dot_w

VectorBoundedArray<adouble, 3> ConvectiveMassElement::OpVelocityJacobian::dot_w

Definition at line 291 of file ConvectiveMassElement.hpp.

◆ dot_W

VectorBoundedArray<adouble, 3> ConvectiveMassElement::OpVelocityJacobian::dot_W

Definition at line 291 of file ConvectiveMassElement.hpp.

◆ F

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

Definition at line 292 of file ConvectiveMassElement.hpp.

◆ fieldDisp

bool ConvectiveMassElement::OpVelocityJacobian::fieldDisp

Definition at line 286 of file ConvectiveMassElement.hpp.

◆ h

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

Definition at line 292 of file ConvectiveMassElement.hpp.

◆ H

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

Definition at line 292 of file ConvectiveMassElement.hpp.

◆ invH

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

Definition at line 292 of file ConvectiveMassElement.hpp.

◆ jAcobian

bool ConvectiveMassElement::OpVelocityJacobian::jAcobian

Definition at line 286 of file ConvectiveMassElement.hpp.

◆ tAg

int ConvectiveMassElement::OpVelocityJacobian::tAg

Definition at line 285 of file ConvectiveMassElement.hpp.

◆ v

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

Definition at line 291 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
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
ConvectiveMassElement::OpVelocityJacobian::dot_W
VectorBoundedArray< adouble, 3 > dot_W
Definition: ConvectiveMassElement.hpp:291
ConvectiveMassElement::OpVelocityJacobian::a_res
VectorBoundedArray< adouble, 3 > a_res
Definition: ConvectiveMassElement.hpp:291
ConvectiveMassElement::CommonData::jacVelRowPtr
std::vector< std::vector< double * > > jacVelRowPtr
Definition: ConvectiveMassElement.hpp:139
ConvectiveMassElement::OpVelocityJacobian::commonData
CommonData & commonData
Definition: ConvectiveMassElement.hpp:284
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
sdf.r
int r
Definition: sdf.py:8
ConvectiveMassElement::OpVelocityJacobian::H
MatrixBoundedArray< adouble, 9 > H
Definition: ConvectiveMassElement.hpp:292
ConvectiveMassElement::OpVelocityJacobian::fieldDisp
bool fieldDisp
Definition: ConvectiveMassElement.hpp:286
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::OpVelocityJacobian::v
VectorBoundedArray< adouble, 3 > v
Definition: ConvectiveMassElement.hpp:291
ConvectiveMassElement::CommonData::gradAtGaussPts
std::map< std::string, std::vector< MatrixDouble > > gradAtGaussPts
Definition: ConvectiveMassElement.hpp:134
ConvectiveMassElement::OpVelocityJacobian::jAcobian
bool jAcobian
Definition: ConvectiveMassElement.hpp:286
FTensor::Number< 0 >
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
ConvectiveMassElement::OpVelocityJacobian::active
std::vector< double > active
Definition: ConvectiveMassElement.hpp:295
ConvectiveMassElement::OpVelocityJacobian::dAta
BlockData & dAta
Definition: ConvectiveMassElement.hpp:283
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1214
ConvectiveMassElement::OpVelocityJacobian::dot_u
VectorBoundedArray< adouble, 3 > dot_u
Definition: ConvectiveMassElement.hpp:291
MOFEM_OPERATION_UNSUCCESSFUL
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition: definitions.h:34
ConvectiveMassElement::CommonData::jacVel
std::vector< MatrixDouble > jacVel
Definition: ConvectiveMassElement.hpp:140
ConvectiveMassElement::CommonData::spatialPositions
string spatialPositions
Definition: ConvectiveMassElement.hpp:135
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
ConvectiveMassElement::OpVelocityJacobian::dot_w
VectorBoundedArray< adouble, 3 > dot_w
Definition: ConvectiveMassElement.hpp:291
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
FTensor::Index< 'i', 3 >
ConvectiveMassElement::OpVelocityJacobian::h
MatrixBoundedArray< adouble, 9 > h
Definition: ConvectiveMassElement.hpp:292
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
MoFEM::determinantTensor3by3
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
Definition: Templates.hpp:1540
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
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
ConvectiveMassElement::OpVelocityJacobian::tAg
int tAg
Definition: ConvectiveMassElement.hpp:285
ConvectiveMassElement::OpVelocityJacobian::F
MatrixBoundedArray< adouble, 9 > F
Definition: ConvectiveMassElement.hpp:292
ConvectiveMassElement::OpVelocityJacobian::detH
adouble detH
Definition: ConvectiveMassElement.hpp:293
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::OpVelocityJacobian::invH
MatrixBoundedArray< adouble, 9 > invH
Definition: ConvectiveMassElement.hpp:292
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
ConvectiveMassElement::CommonData::valVel
std::vector< VectorDouble > valVel
Definition: ConvectiveMassElement.hpp:138