/*!\file PentaVertexInput.c * \brief: implementation of the PentaVertexInput object */ #ifdef HAVE_CONFIG_H #include "config.h" #else #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" #endif #include "stdio.h" #include #include "../objects.h" #include "../../EnumDefinitions/EnumDefinitions.h" #include "../../shared/shared.h" #include "../../DataSet/DataSet.h" #include "../../include/include.h" /*Object constructors and destructor*/ /*FUNCTION PentaVertexInput::PentaVertexInput(){{{1*/ PentaVertexInput::PentaVertexInput(){ return; } /*}}}*/ /*FUNCTION PentaVertexInput::PentaVertexInput(int in_enum_type,double* values){{{1*/ PentaVertexInput::PentaVertexInput(int in_enum_type,double* in_values){ enum_type=in_enum_type; values[0]=in_values[0]; values[1]=in_values[1]; values[2]=in_values[2]; values[3]=in_values[3]; values[4]=in_values[4]; values[5]=in_values[5]; } /*}}}*/ /*FUNCTION PentaVertexInput::~PentaVertexInput(){{{1*/ PentaVertexInput::~PentaVertexInput(){ return; } /*}}}*/ /*Object management*/ /*FUNCTION PentaVertexInput::copy{{{1*/ Object* PentaVertexInput::copy() { return new PentaVertexInput(this->enum_type,this->values); } /*}}}*/ /*FUNCTION PentaVertexInput::DeepEcho{{{1*/ void PentaVertexInput::DeepEcho(void){ printf("PentaVertexInput:\n"); printf(" enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type)); printf(" values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]); } /*}}}*/ /*FUNCTION PentaVertexInput::Demarshall{{{1*/ void PentaVertexInput::Demarshall(char** pmarshalled_dataset){ char* marshalled_dataset=NULL; int i; /*recover marshalled_dataset: */ marshalled_dataset=*pmarshalled_dataset; /*this time, no need to get enum type, the pointer directly points to the beginning of the *object data (thanks to DataSet::Demarshall):*/ memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values); /*return: */ *pmarshalled_dataset=marshalled_dataset; return; } /*}}}*/ /*FUNCTION PentaVertexInput::Echo {{{1*/ void PentaVertexInput::Echo(void){ this->DeepEcho(); } /*}}}*/ /*FUNCTION PentaVertexInput::Enum{{{1*/ int PentaVertexInput::Enum(void){ return PentaVertexInputEnum; } /*}}}*/ /*FUNCTION PentaVertexInput::EnumType{{{1*/ int PentaVertexInput::EnumType(void){ return this->enum_type; } /*}}}*/ /*FUNCTION PentaVertexInput::Id{{{1*/ int PentaVertexInput::Id(void){ return -1; } /*}}}*/ /*FUNCTION PentaVertexInput::Marshall{{{1*/ void PentaVertexInput::Marshall(char** pmarshalled_dataset){ char* marshalled_dataset=NULL; int enum_value=0; /*recover marshalled_dataset: */ marshalled_dataset=*pmarshalled_dataset; /*get enum value of PentaVertexInput: */ enum_value=PentaVertexInputEnum; /*marshall enum: */ memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value); /*marshall PentaVertexInput data: */ memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values); *pmarshalled_dataset=marshalled_dataset; } /*}}}*/ /*FUNCTION PentaVertexInput::MarshallSize{{{1*/ int PentaVertexInput::MarshallSize(){ return sizeof(values)+ +sizeof(enum_type)+ +sizeof(int); //sizeof(int) for enum value } /*}}}*/ /*FUNCTION PentaVertexInput::MyRank{{{1*/ int PentaVertexInput::MyRank(void){ extern int my_rank; return my_rank; } /*}}}*/ /*FUNCTION PentaVertexInput::SpawnSingInput{{{1*/ Input* PentaVertexInput::SpawnSingInput(int index){ /*output*/ SingVertexInput* outinput=NULL; /*Create new Sing input (copy of current input)*/ ISSMASSERT(index<6 && index>=0); outinput=new SingVertexInput(this->enum_type,this->values[index]); /*Assign output*/ return outinput; } /*}}}*/ /*FUNCTION PentaVertexInput::SpawnBeamInput{{{1*/ Input* PentaVertexInput::SpawnBeamInput(int* indices){ /*output*/ BeamVertexInput* outinput=NULL; double newvalues[2]; /*Loop over the new indices*/ for(int i=0;i<2;i++){ /*Check index value*/ ISSMASSERT(indices[i]>=0 && indices[i]<6); /*Assign value to new input*/ newvalues[i]=this->values[indices[i]]; } /*Create new Beam input*/ outinput=new BeamVertexInput(this->enum_type,&newvalues[0]); /*Assign output*/ return outinput; } /*}}}*/ /*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/ Input* PentaVertexInput::SpawnTriaInput(int* indices){ /*output*/ TriaVertexInput* outinput=NULL; double newvalues[3]; /*Loop over the new indices*/ for(int i=0;i<3;i++){ /*Check index value*/ ISSMASSERT(indices[i]>=0 && indices[i]<6); /*Assign value to new input*/ newvalues[i]=this->values[indices[i]]; } /*Create new Tria input*/ outinput=new TriaVertexInput(this->enum_type,&newvalues[0]); /*Assign output*/ return outinput; } /*}}}*/ /*FUNCTION PentaVertexInput::SpawnResult{{{1*/ Result* PentaVertexInput::SpawnResult(int step, double time){ return new PentaVertexResult(this->enum_type,this->values,step,time); } /*}}}*/ /*Object functions*/ /*FUNCTION PentaVertexInput::GetParameterValue(bool* pvalue) {{{1*/ void PentaVertexInput::GetParameterValue(bool* pvalue){ISSMERROR(" not supported yet!");} /*}}}*/ /*FUNCTION PentaVertexInput::GetParameterValue(int* pvalue){{{1*/ void PentaVertexInput::GetParameterValue(int* pvalue){ISSMERROR(" not supported yet!");} /*}}}*/ /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue){{{1*/ void PentaVertexInput::GetParameterValue(double* pvalue){ISSMERROR(" not supported yet!");} /*}}}*/ /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,Node* node){{{1*/ void PentaVertexInput::GetParameterValue(double* pvalue,Node* node){ISSMERROR(" not supported yet!");} /*}}}*/ /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_coord){{{1*/ void PentaVertexInput::GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_coord){ISSMERROR(" not supported yet!");} /*}}}*/ /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){{{1*/ void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){ /*P1 interpolation on Gauss point*/ /*intermediary*/ double l1l6[6]; /*nodal functions: */ GetNodalFunctionsP1(&l1l6[0],gauss); /*Assign output pointers:*/ *pvalue=l1l6[0]*values[0]+l1l6[1]*values[1]+l1l6[2]*values[2]+l1l6[3]*values[3]+l1l6[4]*values[4]+l1l6[5]*values[5]; } /*}}}*/ /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){{{1*/ void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){ISSMERROR(" not supported yet!");} /*}}}*/ /*FUNCTION PentaVertexInput::GetParameterValues(double* values,double* gauss_pointers, int numgauss){{{1*/ void PentaVertexInput::GetParameterValues(double* values,double* gauss_pointers, int numgauss){ /*It is assumed that output values has been correctly allocated*/ int i,j; double gauss[4]; for (i=0;ivalues[0]*dh1dh6[0][0]+this->values[1]*dh1dh6[0][1]+this->values[2]*dh1dh6[0][2]+this->values[3]*dh1dh6[0][3]+this->values[4]*dh1dh6[0][4]+this->values[5]*dh1dh6[0][5]; p[1]=this->values[0]*dh1dh6[1][0]+this->values[1]*dh1dh6[1][1]+this->values[2]*dh1dh6[1][2]+this->values[3]*dh1dh6[1][3]+this->values[4]*dh1dh6[1][4]+this->values[5]*dh1dh6[1][5]; p[2]=this->values[0]*dh1dh6[2][0]+this->values[1]*dh1dh6[2][1]+this->values[2]*dh1dh6[2][2]+this->values[3]*dh1dh6[2][3]+this->values[4]*dh1dh6[2][4]+this->values[5]*dh1dh6[2][5]; } /*}}}*/ /*FUNCTION PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, double* gauss) {{{1*/ void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, double* gauss){ int i,j; const int numgrids=6; const int DOFVELOCITY=3; double B[8][27]; double B_reduced[6][DOFVELOCITY*numgrids]; double velocity[numgrids][DOFVELOCITY]; /*Get B matrix: */ GetBStokes(&B[0][0], xyz_list, gauss); /*Create a reduced matrix of B to get rid of pressure */ for (i=0;i<6;i++){ for (j=0;j<3;j++){ B_reduced[i][j]=B[i][j]; } for (j=4;j<7;j++){ B_reduced[i][j-1]=B[i][j]; } for (j=8;j<11;j++){ B_reduced[i][j-2]=B[i][j]; } for (j=12;j<15;j++){ B_reduced[i][j-3]=B[i][j]; } for (j=16;j<19;j++){ B_reduced[i][j-4]=B[i][j]; } for (j=20;j<23;j++){ B_reduced[i][j-5]=B[i][j]; } } /*Here, we are computing the strain rate of (vx,0,0)*/ for(i=0;ivalues[i]; velocity[i][1]=0.0; velocity[i][2]=0.0; } /*Multiply B by velocity, to get strain rate: */ MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvx,0); } /*}}}*/ /*FUNCTION PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, double* gauss) {{{1*/ void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, double* gauss){ int i,j; const int numgrids=6; const int DOFVELOCITY=3; double B[8][27]; double B_reduced[6][DOFVELOCITY*numgrids]; double velocity[numgrids][DOFVELOCITY]; /*Get B matrix: */ GetBStokes(&B[0][0], xyz_list, gauss); /*Create a reduced matrix of B to get rid of pressure */ for (i=0;i<6;i++){ for (j=0;j<3;j++){ B_reduced[i][j]=B[i][j]; } for (j=4;j<7;j++){ B_reduced[i][j-1]=B[i][j]; } for (j=8;j<11;j++){ B_reduced[i][j-2]=B[i][j]; } for (j=12;j<15;j++){ B_reduced[i][j-3]=B[i][j]; } for (j=16;j<19;j++){ B_reduced[i][j-4]=B[i][j]; } for (j=20;j<23;j++){ B_reduced[i][j-5]=B[i][j]; } } /*Here, we are computing the strain rate of (0,vy,0)*/ for(i=0;ivalues[i]; velocity[i][2]=0.0; } /*Multiply B by velocity, to get strain rate: */ MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvy,0); } /*}}}*/ /*FUNCTION PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss) {{{1*/ void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss){ int i,j; const int numgrids=6; const int DOFVELOCITY=3; double B[8][27]; double B_reduced[6][DOFVELOCITY*numgrids]; double velocity[numgrids][DOFVELOCITY]; /*Get B matrix: */ GetBStokes(&B[0][0], xyz_list, gauss); /*Create a reduced matrix of B to get rid of pressure */ for (i=0;i<6;i++){ for (j=0;j<3;j++){ B_reduced[i][j]=B[i][j]; } for (j=4;j<7;j++){ B_reduced[i][j-1]=B[i][j]; } for (j=8;j<11;j++){ B_reduced[i][j-2]=B[i][j]; } for (j=12;j<15;j++){ B_reduced[i][j-3]=B[i][j]; } for (j=16;j<19;j++){ B_reduced[i][j-4]=B[i][j]; } for (j=20;j<23;j++){ B_reduced[i][j-5]=B[i][j]; } } /*Here, we are computing the strain rate of (0,0,vz)*/ for(i=0;ivalues[i]; } /*Multiply B by velocity, to get strain rate: */ MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvz,0); } /*}}}*/ /*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, double* gauss) {{{1*/ void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, double* gauss){ int i; const int numgrids=6; const int NDOF2=2; double B[5][NDOF2*numgrids]; double velocity[numgrids][NDOF2]; /*Get B matrix: */ GetBPattyn(&B[0][0], xyz_list, gauss); /*Here, we are computing the strain rate of (vx,0)*/ for(i=0;ivalues[i]; velocity[i][1]=0.0; } /*Multiply B by velocity, to get strain rate: */ MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0, &velocity[0][0],NDOF2*numgrids,1,0, epsilonvx,0); } /*}}}*/ /*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss) {{{1*/ void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss){ int i; const int numgrids=6; const int NDOF2=2; double B[5][NDOF2*numgrids]; double velocity[numgrids][NDOF2]; /*Get B matrix: */ GetBPattyn(&B[0][0], xyz_list, gauss); /*Here, we are computing the strain rate of (0,vy)*/ for(i=0;ivalues[i]; } /*Multiply B by velocity, to get strain rate: */ MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0, &velocity[0][0],NDOF2*numgrids,1,0, epsilonvy,0); } /*}}}*/ /*FUNCTION PentaVertexInput::ChangeEnum(int newenumtype){{{1*/ void PentaVertexInput::ChangeEnum(int newenumtype){ this->enum_type=newenumtype; } /*}}}*/ /*FUNCTION PentaVertexInput::GetParameterAverage(double* pvalue){{{1*/ void PentaVertexInput::GetParameterAverage(double* pvalue){ *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]); } /*}}}*/ /*Intermediary*/ /*FUNCTION PentaVertexInput::GetNodalFunctionsP1 {{{1*/ void PentaVertexInput::GetNodalFunctionsP1(double* l1l6, double* gauss_coord){ /*This routine returns the values of the nodal functions at the gaussian point.*/ l1l6[0]=gauss_coord[0]*(1-gauss_coord[3])/2.0; l1l6[1]=gauss_coord[1]*(1-gauss_coord[3])/2.0; l1l6[2]=gauss_coord[2]*(1-gauss_coord[3])/2.0; l1l6[3]=gauss_coord[0]*(1+gauss_coord[3])/2.0; l1l6[4]=gauss_coord[1]*(1+gauss_coord[3])/2.0; l1l6[5]=gauss_coord[2]*(1+gauss_coord[3])/2.0; } /*}}}*/ /*FUNCTION PentaVertexInput::GetNodalFunctionsMINI{{{1*/ void PentaVertexInput::GetNodalFunctionsMINI(double* l1l7, double* gauss_coord){ /*This routine returns the values of the nodal functions at the gaussian point.*/ /*First nodal function: */ l1l7[0]=gauss_coord[0]*(1.0-gauss_coord[3])/2.0; /*Second nodal function: */ l1l7[1]=gauss_coord[1]*(1.0-gauss_coord[3])/2.0; /*Third nodal function: */ l1l7[2]=gauss_coord[2]*(1.0-gauss_coord[3])/2.0; /*Fourth nodal function: */ l1l7[3]=gauss_coord[0]*(1.0+gauss_coord[3])/2.0; /*Fifth nodal function: */ l1l7[4]=gauss_coord[1]*(1.0+gauss_coord[3])/2.0; /*Sixth nodal function: */ l1l7[5]=gauss_coord[2]*(1.0+gauss_coord[3])/2.0; /*Seventh nodal function: */ l1l7[6]=27*gauss_coord[0]*gauss_coord[1]*gauss_coord[2]*(1.0+gauss_coord[3])*(1.0-gauss_coord[3]); } /*}}}*/ /*FUNCTION PentaVertexInput::GetNodalFunctionsP1Derivatives {{{1*/ void PentaVertexInput::GetNodalFunctionsP1Derivatives(double* dh1dh6,double* xyz_list, double* gauss_coord){ /*This routine returns the values of the nodal functions derivatives (with respect to the actual coordinate system: */ int i; const int NDOF3=3; const int numgrids=6; double dh1dh6_ref[NDOF3][numgrids]; double Jinv[NDOF3][NDOF3]; /*Get derivative values with respect to parametric coordinate system: */ GetNodalFunctionsP1DerivativesReference(&dh1dh6_ref[0][0], gauss_coord); /*Get Jacobian invert: */ GetJacobianInvert(&Jinv[0][0], xyz_list, gauss_coord); /*Build dh1dh3: * * [dhi/dx]= Jinv*[dhi/dr] * [dhi/dy] [dhi/ds] * [dhi/dz] [dhi/dn] */ for (i=0;ivalues[i]; /*Process units if requested: */ if(process_units)NodalValuesUnitConversion(&valuescopy[0],numnodes,enum_type,parameters); /*Now, figure out minimum of valuescopy: */ squaremin=pow(valuescopy[0],2); for(i=1;ivalues[i]=this->values[i]+scalar*xpentavertexinput->values[i]; } /*}}}*/ /*FUNCTION PentaVertexInput::Constrain(double cm_min, double cm_max){{{1*/ void PentaVertexInput::Constrain(double cm_min, double cm_max){ int i; const int numgrids=6; if(!isnan(cm_min)) for(i=0;ivalues[i]values[i]=cm_min; if(!isnan(cm_max)) for(i=0;ivalues[i]>cm_max)this->values[i]=cm_max; } /*}}}*/ /*FUNCTION PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){{{1*/ void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){ const int numvertices=6; VecSetValues(vector,numvertices,doflist,(const double*)this->values,ADD_VALUES); } /*}}}*/