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

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

Inherits UserDataOperator.

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

Public Member Functions

 OpHelmholtzRhs_F (const string re_field_name, const string im_field_name, BlockData &data, CommonData &common_data, MatrixDouble &ho_coords, bool usescalar, bool use_real)
 
 OpHelmholtzRhs_F (const string re_field_name, const string im_field_name, Vec _F, BlockData &data, CommonData &common_data, MatrixDouble &ho_coords, bool usescalar, bool use_real)
 
PetscErrorCode doWork (int side, EntityType type, DataForcesAndSurcesCore::EntData &data)
 calculate Helmholtz RHS source term. More...
 

Public Attributes

BlockDatadAta
 
CommonDatacommonData
 
MatrixDoublehoCoords
 
bool useTsF
 
bool useScalar
 
bool useReal
 
Vec F
 
VectorDouble Nf
 

Detailed Description

\biref operator to calculate right hand side wave source term F \infroup mofem_helmholtz_elem

Definition at line 725 of file HelmholtzElementObsolete.hpp.

Constructor & Destructor Documentation

◆ OpHelmholtzRhs_F() [1/2]

MoFEM::HelmholtzElement::OpHelmholtzRhs_F::OpHelmholtzRhs_F ( const string  re_field_name,
const string  im_field_name,
BlockData data,
CommonData common_data,
MatrixDouble ho_coords,
bool  usescalar,
bool  use_real 
)

◆ OpHelmholtzRhs_F() [2/2]

MoFEM::HelmholtzElement::OpHelmholtzRhs_F::OpHelmholtzRhs_F ( const string  re_field_name,
const string  im_field_name,
Vec  _F,
BlockData data,
CommonData common_data,
MatrixDouble ho_coords,
bool  usescalar,
bool  use_real 
)

Member Function Documentation

◆ doWork()

PetscErrorCode MoFEM::HelmholtzElement::OpHelmholtzRhs_F::doWork ( int  side,
EntityType  type,
DataForcesAndSurcesCore::EntData data 
)

calculate Helmholtz RHS source term.

F = int diffN^T F(x,y,z) dOmega^2

Definition at line 751 of file HelmholtzElementObsolete.hpp.

752  {
753  PetscFunctionBegin;
754 
755  if(dAta.tEts.find(getMoFEMFEPtr()->get_ent()) == dAta.tEts.end()) {
756  PetscFunctionReturn(0);
757  }
758 
759 
760  try {
761 
762  PetscErrorCode ierr;
763  if(data.getIndices().size()==0) PetscFunctionReturn(0);
764  int nb_row = data.getIndices().size();
765  Nf.resize(nb_row);
766  bzero(&Nf[0],nb_row*sizeof(double));
767  double x,y,z;
768  double iNcidentwave;
769  double wAvenumber = dAta.aNgularfreq/dAta.sPeed;
770 
771  for(unsigned int gg = 0;gg<data.getN().size1();gg++) {
772 
773  double val = getVolume()*getGaussPts()(3,gg);
774 
775  if(getHoGaussPtsDetJac().size()>0) {
776  val *= getHoGaussPtsDetJac()[gg]; ///< higher order geometry
777  x = hoCoords(gg,0);
778  y = hoCoords(gg,1);
779  z = hoCoords(gg,2);
780 
781  } else {
782  x = getCoordsAtGaussPts()(gg,0);
783  y = getCoordsAtGaussPts()(gg,1);
784  z = getCoordsAtGaussPts()(gg,2);
785  }
786 
787  VectorDouble F_S;
788  //Scalar value source term F = a
789  if(useScalar) {
790  const double f_scalar = -1; //scalar source vector F=1, wait for modification.
791  ublas::scalar_vector<double> F (data.getN().size1(),f_scalar); //scalar source vector
792  F_S = F;
793  }
794 
795 
796  //Functional value source term F =f(x)
797 
798 
799  else {
800 
801 
802  /***** incident wave in x direction *****/
803  /*** incident wave from Finite Element Analysis of Acoustic Scattering by Frank Ihlenburg **/
804 
805  double theta = atan2(y,x)+2*M_PI; //the arctan of radians (y/x)
806 
807  const double k = wAvenumber; //Wave number
808  const double a = 0.5; //radius of the sphere,wait to modify by user
809  const double const1 = k * a;
810 
811  const complex< double > i( 0.0, 1.0 );
812 
813  //// magnitude of incident wave
814  const double phi_incident_mag = 1.0;
815 
816  const double tol = 1.0e-10;
817  double max = 0.0;
818  double min = 999999.0;
819  complex< double > result = 0.0;
820  complex< double > prev_result;
821  double error = 100.0;
822 
823 
824  /*** Cyclindrical incident wave ***/
825  //double R = sqrt(pow(x,2.0)+pow(y,2.0)); //radius
826  double R = 0.5;
827  unsigned int n = 1; //initialized the infinite series loop
828 
829  double Jn_der_zero = ( - cyl_bessel_j( 1, const1 ));
830 
831  //n=0;
832  result -= Jn_der_zero;
833 
834  while( error > tol ) //finding the acoustic potential in one single point.
835  {
836  prev_result = result;
837  //The derivative of bessel function
838  double Jn_der = (n / const1 * cyl_bessel_j( n, const1 ) - cyl_bessel_j( n + 1, const1 ));
839 
840  result -= 2.0 * pow( i, n ) * Jn_der * cos(n*theta);
841  error = abs( abs( result ) - abs( prev_result ) );
842  ++n;
843  }
844 
845  /** End **/
846  //result = i * k * cos( theta ) * exp( i * k * R * cos( theta ) ); //derivative of incident wave
847 
848  //cout << "\n rhs_F is running \n" << endl;
849 
850  if(useReal){
851  iNcidentwave = std::real(k*result);
852 
853  } else if(!useReal) {
854  iNcidentwave = std::imag(k*result);
855 
856  }
857 
858  }
859 
860  val *= iNcidentwave;
861  ublas::noalias(Nf) += val*data.getN(gg,nb_row);
862 
863  }
864 
865 
866 
867  if(useTsF) {
868  ierr = VecSetValues(getFEMethod()->ts_F,data.getIndices().size(),
869  &data.getIndices()[0],&Nf[0],ADD_VALUES); CHKERRQ(ierr);
870  } else {
871  ierr = VecSetValues(F,data.getIndices().size(),
872  &data.getIndices()[0],&Nf[0],ADD_VALUES); CHKERRQ(ierr);
873 
874  }
875 
876 
877  } catch (const std::exception& ex) {
878  ostringstream ss;
879  ss << "throw in method: " << ex.what() << endl;
880  SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
881  }
882 
883  PetscFunctionReturn(0);
884  }
Range tEts
constatins elements in block set
double tol
CHKERRQ(ierr)
static moab::Error error
MoFEMErrorCode VecSetValues(Vec V, const DataForcesAndSourcesCore::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
ublas::vector< double, DoubleAllocator > VectorDouble
Definition: Types.hpp:72

Member Data Documentation

◆ commonData

CommonData& MoFEM::HelmholtzElement::OpHelmholtzRhs_F::commonData

Definition at line 728 of file HelmholtzElementObsolete.hpp.

◆ dAta

BlockData& MoFEM::HelmholtzElement::OpHelmholtzRhs_F::dAta

Definition at line 727 of file HelmholtzElementObsolete.hpp.

◆ F

Vec MoFEM::HelmholtzElement::OpHelmholtzRhs_F::F

Definition at line 738 of file HelmholtzElementObsolete.hpp.

◆ hoCoords

MatrixDouble& MoFEM::HelmholtzElement::OpHelmholtzRhs_F::hoCoords

Definition at line 729 of file HelmholtzElementObsolete.hpp.

◆ Nf

VectorDouble MoFEM::HelmholtzElement::OpHelmholtzRhs_F::Nf

Definition at line 743 of file HelmholtzElementObsolete.hpp.

◆ useReal

bool MoFEM::HelmholtzElement::OpHelmholtzRhs_F::useReal

Definition at line 732 of file HelmholtzElementObsolete.hpp.

◆ useScalar

bool MoFEM::HelmholtzElement::OpHelmholtzRhs_F::useScalar

Definition at line 731 of file HelmholtzElementObsolete.hpp.

◆ useTsF

bool MoFEM::HelmholtzElement::OpHelmholtzRhs_F::useTsF

Definition at line 730 of file HelmholtzElementObsolete.hpp.


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