v0.9.0
Public Member Functions | Public Attributes | List of all members
MoFEM::HelmholtzElement::OpHelmholtzLhs_A Struct Reference

#include <users_modules/helmholtz/src/HelmholtzElementObsolete.hpp>

Inherits UserDataOperator.

Collaboration diagram for MoFEM::HelmholtzElement::OpHelmholtzLhs_A:
[legend]

Public Member Functions

 OpHelmholtzLhs_A (const string re_field_name, const string im_field_name, BlockData &data, CommonData &common_data, bool calculate)
 
 OpHelmholtzLhs_A (const string re_field_name, const string im_field_name, Mat _A, BlockData &data, CommonData &common_data, bool calculate)
 
PetscErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSurcesCore::EntData &row_data, DataForcesAndSurcesCore::EntData &col_data)
 calculate helmholtz stiffness matrix More...
 

Public Attributes

BlockDatadAta
 
CommonDatacommonData
 
bool cAlculate
 
bool useTsB
 
Mat A
 
MatrixDouble transK
 

Detailed Description

\biref operator to calculate left hand side of stiffness terms \infroup mofem_helmholtz_elem

Definition at line 892 of file HelmholtzElementObsolete.hpp.

Constructor & Destructor Documentation

◆ OpHelmholtzLhs_A() [1/2]

MoFEM::HelmholtzElement::OpHelmholtzLhs_A::OpHelmholtzLhs_A ( const string  re_field_name,
const string  im_field_name,
BlockData data,
CommonData common_data,
bool  calculate 
)

◆ OpHelmholtzLhs_A() [2/2]

MoFEM::HelmholtzElement::OpHelmholtzLhs_A::OpHelmholtzLhs_A ( const string  re_field_name,
const string  im_field_name,
Mat  _A,
BlockData data,
CommonData common_data,
bool  calculate 
)

Member Function Documentation

◆ doWork()

PetscErrorCode MoFEM::HelmholtzElement::OpHelmholtzLhs_A::doWork ( int  row_side,
int  col_side,
EntityType  row_type,
EntityType  col_type,
DataForcesAndSurcesCore::EntData row_data,
DataForcesAndSurcesCore::EntData col_data 
)

calculate helmholtz stiffness matrix

K = int diffN^T * diffN^T - K^2 N^T N dOmega^2

Definition at line 915 of file HelmholtzElementObsolete.hpp.

919  {
920  PetscFunctionBegin;
921 
922  if(dAta.tEts.find(getMoFEMFEPtr()->get_ent()) == dAta.tEts.end()) {
923  PetscFunctionReturn(0);
924  }
925 
926  MatrixDouble *K_ptr;
927 
928  try {
929 
930  if(row_data.getIndices().size()==0) PetscFunctionReturn(0);
931  if(col_data.getIndices().size()==0) PetscFunctionReturn(0);
932 
933 
934  switch(row_type) {
935 
936  case MBVERTEX:
937  switch(col_type) {
938  case MBVERTEX:
939  K_ptr = &commonData.Ann;
940  break;
941  case MBTET:
942  K_ptr = &commonData.Anv;
943  break;
944  default:
945  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"row_type = MBVERTEX, error col_type not match");
946  break;
947  }
948  break;
949 
950  case MBEDGE:
951  switch(col_type) {
952  case MBVERTEX:
953  commonData.Aen.resize(6);
954  K_ptr = &commonData.Aen[row_side];
955  break;
956  case MBTET:
957  commonData.Aev.resize(6);
958  K_ptr = &commonData.Aev[row_side];
959  break;
960  case MBEDGE:
961  commonData.Aee.resize(6,6);
962  K_ptr = &commonData.Aee(row_side,col_side);
963  break;
964  case MBTRI:
965  commonData.Aef.resize(6,4);
966  K_ptr = &commonData.Aef(row_side,col_side);
967  break;
968 
969  default:
970  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"row_type = MBEDGE, error col_type not match");
971  break;
972  }
973  break;
974 
975  case MBTRI:
976  switch(col_type) {
977  case MBVERTEX:
978  commonData.Afn.resize(4);
979  K_ptr = &commonData.Afn[row_side];
980  break;
981  case MBTET:
982  commonData.Afv.resize(4);
983  K_ptr = &commonData.Afv[row_side];
984  break;
985  case MBTRI:
986  commonData.Aff.resize(4,4);
987  K_ptr = &commonData.Aff(row_side,col_side);
988  break;
989  default:
990  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"row_type = MBTRI, error col_type not match");
991  break;
992  }
993  break;
994 
995  case MBTET:
996  K_ptr = &commonData.Avv;
997  break;
998  default:
999  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"row_type not match");
1000  break;
1001  //never should happen
1002  }
1003 
1004  MatrixDouble &K = *K_ptr;
1005 
1006  int nb_row = row_data.getIndices().size();
1007  int nb_col = col_data.getIndices().size();
1008 
1009  if(cAlculate) {
1010 
1011  K.resize(nb_row,nb_col);
1012  bzero(&*K.data().begin(),nb_row*nb_col*sizeof(double));
1013 
1014  for(unsigned int gg = 0;gg<row_data.getN().size1();gg++) {
1015 
1016  double wAvenumber = dAta.aNgularfreq/dAta.sPeed;
1017  double k_2 = pow(wAvenumber,2.0);
1018  /* check whether if double wAvenUmber = pow(dAta.aNgularfreq/dAta.sPeed,2.0); takes
1019  less time the the calculation above */
1020 
1021  double val = getVolume()*getGaussPts()(3,gg);
1022  if(getHoGaussPtsDetJac().size()>0) {
1023  val *= getHoGaussPtsDetJac()[gg]; ///< higher order geometry
1024  }
1025  noalias(K) += val*(prod(row_data.getDiffN(gg,nb_row),trans(col_data.getDiffN(gg,nb_col)))-k_2*outer_prod( row_data.getN(gg,nb_row),col_data.getN(gg,nb_col) ));
1026  }
1027 
1028  }
1029  PetscErrorCode ierr;
1030  if(!useTsB) {
1031  const_cast<FEMethod*>(getFEMethod())->ts_B = A; //FEMethod does not belong to MoFEM::Interface anymore.
1032  }
1033 
1034  ierr = MatSetValues(
1035  A, //(getFEMethod()->ts_B), instead in New thermal element. wait
1036  nb_row,&row_data.getIndices()[0],
1037  nb_col,&col_data.getIndices()[0],
1038  &K(0,0),ADD_VALUES); CHKERRQ(ierr);
1039 
1040  if(row_side != col_side || row_type != col_type) {
1041  transK.resize(nb_col,nb_row);
1042  noalias(transK) = trans( K );
1043  ierr = MatSetValues(
1044  A,
1045  nb_col,&col_data.getIndices()[0],
1046  nb_row,&row_data.getIndices()[0],
1047  &transK(0,0),ADD_VALUES); CHKERRQ(ierr);
1048  }
1049 
1050  } catch (const std::exception& ex) {
1051  ostringstream ss;
1052  ss << "throw in method: " << ex.what() << endl;
1053  SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
1054  }
1055 
1056  PetscFunctionReturn(0);
1057  }
ublas::matrix< double, ublas::row_major, DoubleAllocator > MatrixDouble
Definition: Types.hpp:74
Range tEts
constatins elements in block set
CHKERRQ(ierr)
MoFEMErrorCode MatSetValues(Mat M, const DataForcesAndSourcesCore::EntData &row_data, const DataForcesAndSourcesCore::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.

Member Data Documentation

◆ A

Mat MoFEM::HelmholtzElement::OpHelmholtzLhs_A::A

Definition at line 903 of file HelmholtzElementObsolete.hpp.

◆ cAlculate

bool MoFEM::HelmholtzElement::OpHelmholtzLhs_A::cAlculate

Definition at line 896 of file HelmholtzElementObsolete.hpp.

◆ commonData

CommonData& MoFEM::HelmholtzElement::OpHelmholtzLhs_A::commonData

Definition at line 895 of file HelmholtzElementObsolete.hpp.

◆ dAta

BlockData& MoFEM::HelmholtzElement::OpHelmholtzLhs_A::dAta

Definition at line 894 of file HelmholtzElementObsolete.hpp.

◆ transK

MatrixDouble MoFEM::HelmholtzElement::OpHelmholtzLhs_A::transK

Definition at line 908 of file HelmholtzElementObsolete.hpp.

◆ useTsB

bool MoFEM::HelmholtzElement::OpHelmholtzLhs_A::useTsB

Definition at line 898 of file HelmholtzElementObsolete.hpp.


The documentation for this struct was generated from the following file: