v0.15.0
Loading...
Searching...
No Matches
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 789 of file ConvectiveMassElement.cpp.

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

Member Function Documentation

◆ doWork()

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

Definition at line 797 of file ConvectiveMassElement.cpp.

798 {
800
801 if (dAta.tEts.find(getNumeredEntFiniteElementPtr()->getEnt()) ==
802 dAta.tEts.end()) {
804 }
805
806 // do it only once, no need to repeat this for edges,faces or tets
807 if (row_type != MBVERTEX)
809
810 int nb_dofs = row_data.getIndices().size();
811 if (nb_dofs == 0)
813
814 {
815
816 v.resize(3);
817 dot_w.resize(3);
818 h.resize(3, 3);
819 h.clear();
820 F.resize(3, 3);
821 dot_W.resize(3);
822 dot_W.clear();
823 H.resize(3, 3);
824 H.clear();
825 invH.resize(3, 3);
826 invH.clear();
827 dot_u.resize(3);
828 for (int dd = 0; dd < 3; dd++) {
829 H(dd, dd) = 1;
830 invH(dd, dd) = 1;
831 }
832
833 a_res.resize(3);
834 int nb_gauss_pts = row_data.getN().size1();
835 commonData.valVel.resize(nb_gauss_pts);
836 commonData.jacVelRowPtr.resize(nb_gauss_pts);
837 commonData.jacVel.resize(nb_gauss_pts);
838
839 int nb_active_vars = 0;
840 for (int gg = 0; gg < nb_gauss_pts; gg++) {
841
842 if (gg == 0) {
843
844 trace_on(tAg);
845
846 for (int nn1 = 0; nn1 < 3; nn1++) { // 0
847 v[nn1] <<=
849 nb_active_vars++;
850 }
851 for (int nn1 = 0; nn1 < 3; nn1++) { // 3
852 dot_w[nn1] <<=
854 [gg][nn1];
855 nb_active_vars++;
856 }
858 .size() > 0) {
859 for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3 = 6
860 for (int nn2 = 0; nn2 < 3; nn2++) {
861 h(nn1, nn2) <<=
863 nn1, nn2);
864 if (fieldDisp) {
865 if (nn1 == nn2) {
866 h(nn1, nn2) += 1;
867 }
868 }
869 nb_active_vars++;
870 }
871 }
872 for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3+9
873 dot_W[nn1] <<=
875 .dataAtGaussPts["DOT_" + commonData.meshPositions][gg][nn1];
876 nb_active_vars++;
877 }
878 }
880 for (int nn1 = 0; nn1 < 3; nn1++) { // 3+3+9+3
881 for (int nn2 = 0; nn2 < 3; nn2++) {
882 H(nn1, nn2) <<=
884 nn2);
885 nb_active_vars++;
886 }
887 }
888 }
889 detH = 1;
890
891 FTensor::Index<'i', 3> i;
892 FTensor::Index<'j', 3> j;
893 FTensor::Index<'k', 3> k;
894
899 auto t_dot_u =
901 auto t_dot_w =
903 auto t_dot_W =
905 auto t_v = FTensor::Tensor1<adouble *, 3>{&v[0], &v[1], &v[2]};
906 auto t_a_res =
908
912 t_F(i, j) = t_h(i, k) * t_invH(k, j);
913 } else {
914 t_F(i, j) = t_h(i, j);
915 }
916
917 t_dot_u(i) = t_dot_w(i) + t_F(i, j) * t_dot_W(j);
918 t_a_res(i) = t_v(i) - t_dot_u(i);
919 t_a_res(i) *= detH;
920
921 // dependant
922 VectorDouble &res = commonData.valVel[gg];
923 res.resize(3);
924 for (int rr = 0; rr < 3; rr++) {
925 a_res[rr] >>= res[rr];
926 }
927 trace_off();
928 }
929
930 active.resize(nb_active_vars);
931 int aa = 0;
932 for (int nn1 = 0; nn1 < 3; nn1++) {
933 active[aa++] =
935 }
936 for (int nn1 = 0; nn1 < 3; nn1++) {
937 active[aa++] =
939 .dataAtGaussPts["DOT_" + commonData.spatialPositions][gg][nn1];
940 }
942 0) {
943 for (int nn1 = 0; nn1 < 3; nn1++) {
944 for (int nn2 = 0; nn2 < 3; nn2++) {
945 if (fieldDisp && nn1 == nn2) {
946 active[aa++] =
948 nn1, nn2) +
949 1;
950 } else {
951 active[aa++] =
953 nn1, nn2);
954 }
955 }
956 }
957 for (int nn1 = 0; nn1 < 3; nn1++) {
958 active[aa++] =
960 .dataAtGaussPts["DOT_" + commonData.meshPositions][gg][nn1];
961 }
962 }
964 for (int nn1 = 0; nn1 < 3; nn1++) {
965 for (int nn2 = 0; nn2 < 3; nn2++) {
966 active[aa++] =
968 nn2);
969 }
970 }
971 }
972
973 if (!jAcobian) {
974 VectorDouble &res = commonData.valVel[gg];
975 if (gg > 0) {
976 res.resize(3);
977 int r;
978 r = ::function(tAg, 3, nb_active_vars, &active[0], &res[0]);
979 if (r != 3) {
980 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
981 "ADOL-C function evaluation with error");
982 }
983 }
984 double val = getVolume() * getGaussPts()(3, gg);
985 res *= val;
986 } else {
987 commonData.jacVelRowPtr[gg].resize(3);
988 commonData.jacVel[gg].resize(3, nb_active_vars);
989 for (int nn1 = 0; nn1 < 3; nn1++) {
990 (commonData.jacVelRowPtr[gg])[nn1] = &(commonData.jacVel[gg](nn1, 0));
991 }
992 int r;
993 r = jacobian(tAg, 3, nb_active_vars, &active[0],
994 &(commonData.jacVelRowPtr[gg])[0]);
995 if (r != 3) {
996 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
997 "ADOL-C function evaluation with error");
998 }
999 double val = getVolume() * getGaussPts()(3, gg);
1000 commonData.jacVel[gg] *= val;
1001 // std::cerr << gg << " : " << commonData.jacVel[gg] << std::endl;
1002 }
1003 }
1004 }
1006}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
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
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.
auto getFTensor2FromArray3by3(ublas::matrix< T, L, A > &data, const FTensor::Number< S > &, const size_t rr, const size_t cc=0)
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
int r
Definition sdf.py:8
std::map< std::string, std::vector< VectorDouble > > dataAtGaussPts
std::vector< std::vector< double * > > jacVelRowPtr
std::map< std::string, std::vector< MatrixDouble > > gradAtGaussPts
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorInt & getIndices() const
Get global indices of dofs on entity.

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: