| 1 | /*!\file PentaVertexInput.c
|
|---|
| 2 | * \brief: implementation of the PentaVertexInput object
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #ifdef HAVE_CONFIG_H
|
|---|
| 6 | #include "config.h"
|
|---|
| 7 | #else
|
|---|
| 8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
|---|
| 9 | #endif
|
|---|
| 10 |
|
|---|
| 11 | #include "stdio.h"
|
|---|
| 12 | #include <string.h>
|
|---|
| 13 | #include "../objects.h"
|
|---|
| 14 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
|---|
| 15 | #include "../../shared/shared.h"
|
|---|
| 16 | #include "../../Container/Container.h"
|
|---|
| 17 | #include "../../include/include.h"
|
|---|
| 18 |
|
|---|
| 19 | /*PentaVertexInput constructors and destructor*/
|
|---|
| 20 | /*FUNCTION PentaVertexInput::PentaVertexInput(){{{1*/
|
|---|
| 21 | PentaVertexInput::PentaVertexInput(){
|
|---|
| 22 | return;
|
|---|
| 23 | }
|
|---|
| 24 | /*}}}*/
|
|---|
| 25 | /*FUNCTION PentaVertexInput::PentaVertexInput(int in_enum_type,double* values){{{1*/
|
|---|
| 26 | PentaVertexInput::PentaVertexInput(int in_enum_type,double* in_values){
|
|---|
| 27 |
|
|---|
| 28 | enum_type=in_enum_type;
|
|---|
| 29 | values[0]=in_values[0];
|
|---|
| 30 | values[1]=in_values[1];
|
|---|
| 31 | values[2]=in_values[2];
|
|---|
| 32 | values[3]=in_values[3];
|
|---|
| 33 | values[4]=in_values[4];
|
|---|
| 34 | values[5]=in_values[5];
|
|---|
| 35 | }
|
|---|
| 36 | /*}}}*/
|
|---|
| 37 | /*FUNCTION PentaVertexInput::~PentaVertexInput(){{{1*/
|
|---|
| 38 | PentaVertexInput::~PentaVertexInput(){
|
|---|
| 39 | return;
|
|---|
| 40 | }
|
|---|
| 41 | /*}}}*/
|
|---|
| 42 |
|
|---|
| 43 | /*Object virtual functions definitions:*/
|
|---|
| 44 | /*FUNCTION PentaVertexInput::Echo {{{1*/
|
|---|
| 45 | void PentaVertexInput::Echo(void){
|
|---|
| 46 | this->DeepEcho();
|
|---|
| 47 | }
|
|---|
| 48 | /*}}}*/
|
|---|
| 49 | /*FUNCTION PentaVertexInput::DeepEcho{{{1*/
|
|---|
| 50 | void PentaVertexInput::DeepEcho(void){
|
|---|
| 51 |
|
|---|
| 52 | printf("PentaVertexInput:\n");
|
|---|
| 53 | printf(" enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
|
|---|
| 54 | 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]);
|
|---|
| 55 | }
|
|---|
| 56 | /*}}}*/
|
|---|
| 57 | /*FUNCTION PentaVertexInput::Id{{{1*/
|
|---|
| 58 | int PentaVertexInput::Id(void){ return -1; }
|
|---|
| 59 | /*}}}*/
|
|---|
| 60 | /*FUNCTION PentaVertexInput::MyRank{{{1*/
|
|---|
| 61 | int PentaVertexInput::MyRank(void){
|
|---|
| 62 | extern int my_rank;
|
|---|
| 63 | return my_rank;
|
|---|
| 64 | }
|
|---|
| 65 | /*}}}*/
|
|---|
| 66 | /*FUNCTION PentaVertexInput::Marshall{{{1*/
|
|---|
| 67 | void PentaVertexInput::Marshall(char** pmarshalled_dataset){
|
|---|
| 68 |
|
|---|
| 69 | char* marshalled_dataset=NULL;
|
|---|
| 70 | int enum_value=0;
|
|---|
| 71 |
|
|---|
| 72 | /*recover marshalled_dataset: */
|
|---|
| 73 | marshalled_dataset=*pmarshalled_dataset;
|
|---|
| 74 |
|
|---|
| 75 | /*get enum value of PentaVertexInput: */
|
|---|
| 76 | enum_value=PentaVertexInputEnum;
|
|---|
| 77 |
|
|---|
| 78 | /*marshall enum: */
|
|---|
| 79 | memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
|
|---|
| 80 |
|
|---|
| 81 | /*marshall PentaVertexInput data: */
|
|---|
| 82 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
|---|
| 83 | memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
|
|---|
| 84 |
|
|---|
| 85 | *pmarshalled_dataset=marshalled_dataset;
|
|---|
| 86 | }
|
|---|
| 87 | /*}}}*/
|
|---|
| 88 | /*FUNCTION PentaVertexInput::MarshallSize{{{1*/
|
|---|
| 89 | int PentaVertexInput::MarshallSize(){
|
|---|
| 90 |
|
|---|
| 91 | return sizeof(values)+
|
|---|
| 92 | +sizeof(enum_type)+
|
|---|
| 93 | +sizeof(int); //sizeof(int) for enum value
|
|---|
| 94 | }
|
|---|
| 95 | /*}}}*/
|
|---|
| 96 | /*FUNCTION PentaVertexInput::Demarshall{{{1*/
|
|---|
| 97 | void PentaVertexInput::Demarshall(char** pmarshalled_dataset){
|
|---|
| 98 |
|
|---|
| 99 | char* marshalled_dataset=NULL;
|
|---|
| 100 | int i;
|
|---|
| 101 |
|
|---|
| 102 | /*recover marshalled_dataset: */
|
|---|
| 103 | marshalled_dataset=*pmarshalled_dataset;
|
|---|
| 104 |
|
|---|
| 105 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
|---|
| 106 | *object data (thanks to DataSet::Demarshall):*/
|
|---|
| 107 | memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
|---|
| 108 | memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
|
|---|
| 109 |
|
|---|
| 110 | /*return: */
|
|---|
| 111 | *pmarshalled_dataset=marshalled_dataset;
|
|---|
| 112 | return;
|
|---|
| 113 | }
|
|---|
| 114 | /*}}}*/
|
|---|
| 115 | /*FUNCTION PentaVertexInput::Enum{{{1*/
|
|---|
| 116 | int PentaVertexInput::Enum(void){
|
|---|
| 117 |
|
|---|
| 118 | return PentaVertexInputEnum;
|
|---|
| 119 |
|
|---|
| 120 | }
|
|---|
| 121 | /*}}}*/
|
|---|
| 122 |
|
|---|
| 123 | /*PentaVertexInput management*/
|
|---|
| 124 | /*FUNCTION PentaVertexInput::copy{{{1*/
|
|---|
| 125 | Object* PentaVertexInput::copy() {
|
|---|
| 126 |
|
|---|
| 127 | return new PentaVertexInput(this->enum_type,this->values);
|
|---|
| 128 |
|
|---|
| 129 | }
|
|---|
| 130 | /*}}}*/
|
|---|
| 131 | /*FUNCTION PentaVertexInput::EnumType{{{1*/
|
|---|
| 132 | int PentaVertexInput::EnumType(void){
|
|---|
| 133 |
|
|---|
| 134 | return this->enum_type;
|
|---|
| 135 |
|
|---|
| 136 | }
|
|---|
| 137 | /*}}}*/
|
|---|
| 138 | /*FUNCTION PentaVertexInput::SpawnSingInput{{{1*/
|
|---|
| 139 | Input* PentaVertexInput::SpawnSingInput(int index){
|
|---|
| 140 |
|
|---|
| 141 | /*output*/
|
|---|
| 142 | SingVertexInput* outinput=NULL;
|
|---|
| 143 |
|
|---|
| 144 | /*Create new Sing input (copy of current input)*/
|
|---|
| 145 | ISSMASSERT(index<6 && index>=0);
|
|---|
| 146 | outinput=new SingVertexInput(this->enum_type,this->values[index]);
|
|---|
| 147 |
|
|---|
| 148 | /*Assign output*/
|
|---|
| 149 | return outinput;
|
|---|
| 150 |
|
|---|
| 151 | }
|
|---|
| 152 | /*}}}*/
|
|---|
| 153 | /*FUNCTION PentaVertexInput::SpawnBeamInput{{{1*/
|
|---|
| 154 | Input* PentaVertexInput::SpawnBeamInput(int* indices){
|
|---|
| 155 |
|
|---|
| 156 | /*output*/
|
|---|
| 157 | BeamVertexInput* outinput=NULL;
|
|---|
| 158 | double newvalues[2];
|
|---|
| 159 |
|
|---|
| 160 | /*Loop over the new indices*/
|
|---|
| 161 | for(int i=0;i<2;i++){
|
|---|
| 162 |
|
|---|
| 163 | /*Check index value*/
|
|---|
| 164 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
|---|
| 165 |
|
|---|
| 166 | /*Assign value to new input*/
|
|---|
| 167 | newvalues[i]=this->values[indices[i]];
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | /*Create new Beam input*/
|
|---|
| 171 | outinput=new BeamVertexInput(this->enum_type,&newvalues[0]);
|
|---|
| 172 |
|
|---|
| 173 | /*Assign output*/
|
|---|
| 174 | return outinput;
|
|---|
| 175 |
|
|---|
| 176 | }
|
|---|
| 177 | /*}}}*/
|
|---|
| 178 | /*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/
|
|---|
| 179 | Input* PentaVertexInput::SpawnTriaInput(int* indices){
|
|---|
| 180 |
|
|---|
| 181 | /*output*/
|
|---|
| 182 | TriaVertexInput* outinput=NULL;
|
|---|
| 183 | double newvalues[3];
|
|---|
| 184 |
|
|---|
| 185 | /*Loop over the new indices*/
|
|---|
| 186 | for(int i=0;i<3;i++){
|
|---|
| 187 |
|
|---|
| 188 | /*Check index value*/
|
|---|
| 189 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
|---|
| 190 |
|
|---|
| 191 | /*Assign value to new input*/
|
|---|
| 192 | newvalues[i]=this->values[indices[i]];
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | /*Create new Tria input*/
|
|---|
| 196 | outinput=new TriaVertexInput(this->enum_type,&newvalues[0]);
|
|---|
| 197 |
|
|---|
| 198 | /*Assign output*/
|
|---|
| 199 | return outinput;
|
|---|
| 200 |
|
|---|
| 201 | }
|
|---|
| 202 | /*}}}*/
|
|---|
| 203 | /*FUNCTION PentaVertexInput::SpawnResult{{{1*/
|
|---|
| 204 | ElementResult* PentaVertexInput::SpawnResult(int step, double time){
|
|---|
| 205 |
|
|---|
| 206 | return new PentaVertexElementResult(this->enum_type,this->values,step,time);
|
|---|
| 207 |
|
|---|
| 208 | }
|
|---|
| 209 | /*}}}*/
|
|---|
| 210 |
|
|---|
| 211 | /*Object functions*/
|
|---|
| 212 | /*FUNCTION PentaVertexInput::GetParameterValue(bool* pvalue) {{{1*/
|
|---|
| 213 | void PentaVertexInput::GetParameterValue(bool* pvalue){ISSMERROR(" not supported yet!");}
|
|---|
| 214 | /*}}}*/
|
|---|
| 215 | /*FUNCTION PentaVertexInput::GetParameterValue(int* pvalue){{{1*/
|
|---|
| 216 | void PentaVertexInput::GetParameterValue(int* pvalue){ISSMERROR(" not supported yet!");}
|
|---|
| 217 | /*}}}*/
|
|---|
| 218 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue){{{1*/
|
|---|
| 219 | void PentaVertexInput::GetParameterValue(double* pvalue){ISSMERROR(" not supported yet!");}
|
|---|
| 220 | /*}}}*/
|
|---|
| 221 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){{{1*/
|
|---|
| 222 | void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){
|
|---|
| 223 | /*P1 interpolation on Gauss point*/
|
|---|
| 224 |
|
|---|
| 225 | /*intermediary*/
|
|---|
| 226 | double l1l6[6];
|
|---|
| 227 |
|
|---|
| 228 | /*nodal functions: */
|
|---|
| 229 | GetNodalFunctionsP1(&l1l6[0],gauss);
|
|---|
| 230 |
|
|---|
| 231 | /*Assign output pointers:*/
|
|---|
| 232 | *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];
|
|---|
| 233 |
|
|---|
| 234 | }
|
|---|
| 235 | /*}}}*/
|
|---|
| 236 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){{{1*/
|
|---|
| 237 | void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){ISSMERROR(" not supported yet!");}
|
|---|
| 238 | /*}}}*/
|
|---|
| 239 | /*FUNCTION PentaVertexInput::GetParameterValues{{{1*/
|
|---|
| 240 | void PentaVertexInput::GetParameterValues(double* values,double* gauss_pointers, int numgauss){
|
|---|
| 241 | /*It is assumed that output values has been correctly allocated*/
|
|---|
| 242 |
|
|---|
| 243 | int i,j;
|
|---|
| 244 | double gauss[4];
|
|---|
| 245 |
|
|---|
| 246 | for (i=0;i<numgauss;i++){
|
|---|
| 247 |
|
|---|
| 248 | /*Get current Gauss point coordinates*/
|
|---|
| 249 | for (j=0;j<4;j++) gauss[j]=gauss_pointers[i*4+j];
|
|---|
| 250 |
|
|---|
| 251 | /*Assign parameter value*/
|
|---|
| 252 | GetParameterValue(&values[i],&gauss[0]);
|
|---|
| 253 | }
|
|---|
| 254 | }
|
|---|
| 255 | /*}}}*/
|
|---|
| 256 | /*FUNCTION PentaVertexInput::GetParameterDerivativeValue{{{1*/
|
|---|
| 257 | void PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, double* gauss){
|
|---|
| 258 | /*From grid values of parameter p (p_list[0], p_list[1], p_list[2], p_list[3], p_list[4] and p_list[4]), return parameter derivative value at gaussian point specified by gauss_coord:
|
|---|
| 259 | * dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx;
|
|---|
| 260 | * dp/dy=p_list[0]*dh1/dy+p_list[1]*dh2/dy+p_list[2]*dh3/dy+p_list[3]*dh4/dy+p_list[4]*dh5/dy+p_list[5]*dh6/dy;
|
|---|
| 261 | * dp/dz=p_list[0]*dh1/dz+p_list[1]*dh2/dz+p_list[2]*dh3/dz+p_list[3]*dh4/dz+p_list[4]*dh5/dz+p_list[5]*dh6/dz;
|
|---|
| 262 | *
|
|---|
| 263 | * p is a vector of size 3x1 already allocated.
|
|---|
| 264 | */
|
|---|
| 265 |
|
|---|
| 266 | const int NDOF3=3;
|
|---|
| 267 | const int numgrids=6;
|
|---|
| 268 | double dh1dh6[NDOF3][numgrids];
|
|---|
| 269 |
|
|---|
| 270 | /*Get nodal funnctions derivatives in actual coordinate system: */
|
|---|
| 271 | GetNodalFunctionsP1Derivatives(&dh1dh6[0][0],xyz_list, gauss);
|
|---|
| 272 |
|
|---|
| 273 | p[0]=this->values[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];
|
|---|
| 274 | 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];
|
|---|
| 275 | 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];
|
|---|
| 276 |
|
|---|
| 277 | }
|
|---|
| 278 | /*}}}*/
|
|---|
| 279 | /*FUNCTION PentaVertexInput::GetVxStrainRate3d{{{1*/
|
|---|
| 280 | void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, double* gauss){
|
|---|
| 281 | int i,j;
|
|---|
| 282 |
|
|---|
| 283 | const int numgrids=6;
|
|---|
| 284 | const int DOFVELOCITY=3;
|
|---|
| 285 | double B[8][27];
|
|---|
| 286 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 287 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 288 |
|
|---|
| 289 | /*Get B matrix: */
|
|---|
| 290 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 291 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 292 | for (i=0;i<6;i++){
|
|---|
| 293 | for (j=0;j<3;j++){
|
|---|
| 294 | B_reduced[i][j]=B[i][j];
|
|---|
| 295 | }
|
|---|
| 296 | for (j=4;j<7;j++){
|
|---|
| 297 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 298 | }
|
|---|
| 299 | for (j=8;j<11;j++){
|
|---|
| 300 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 301 | }
|
|---|
| 302 | for (j=12;j<15;j++){
|
|---|
| 303 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 304 | }
|
|---|
| 305 | for (j=16;j<19;j++){
|
|---|
| 306 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 307 | }
|
|---|
| 308 | for (j=20;j<23;j++){
|
|---|
| 309 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 310 | }
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | /*Here, we are computing the strain rate of (vx,0,0)*/
|
|---|
| 314 | for(i=0;i<numgrids;i++){
|
|---|
| 315 | velocity[i][0]=this->values[i];
|
|---|
| 316 | velocity[i][1]=0.0;
|
|---|
| 317 | velocity[i][2]=0.0;
|
|---|
| 318 | }
|
|---|
| 319 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 320 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvx,0);
|
|---|
| 321 |
|
|---|
| 322 | }
|
|---|
| 323 | /*}}}*/
|
|---|
| 324 | /*FUNCTION PentaVertexInput::GetVyStrainRate3d{{{1*/
|
|---|
| 325 | void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, double* gauss){
|
|---|
| 326 | int i,j;
|
|---|
| 327 |
|
|---|
| 328 | const int numgrids=6;
|
|---|
| 329 | const int DOFVELOCITY=3;
|
|---|
| 330 | double B[8][27];
|
|---|
| 331 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 332 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 333 |
|
|---|
| 334 | /*Get B matrix: */
|
|---|
| 335 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 336 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 337 | for (i=0;i<6;i++){
|
|---|
| 338 | for (j=0;j<3;j++){
|
|---|
| 339 | B_reduced[i][j]=B[i][j];
|
|---|
| 340 | }
|
|---|
| 341 | for (j=4;j<7;j++){
|
|---|
| 342 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 343 | }
|
|---|
| 344 | for (j=8;j<11;j++){
|
|---|
| 345 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 346 | }
|
|---|
| 347 | for (j=12;j<15;j++){
|
|---|
| 348 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 349 | }
|
|---|
| 350 | for (j=16;j<19;j++){
|
|---|
| 351 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 352 | }
|
|---|
| 353 | for (j=20;j<23;j++){
|
|---|
| 354 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 355 | }
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 | /*Here, we are computing the strain rate of (0,vy,0)*/
|
|---|
| 359 | for(i=0;i<numgrids;i++){
|
|---|
| 360 | velocity[i][0]=0.0;
|
|---|
| 361 | velocity[i][1]=this->values[i];
|
|---|
| 362 | velocity[i][2]=0.0;
|
|---|
| 363 | }
|
|---|
| 364 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 365 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvy,0);
|
|---|
| 366 |
|
|---|
| 367 | }
|
|---|
| 368 | /*}}}*/
|
|---|
| 369 | /*FUNCTION PentaVertexInput::GetVzStrainRate3d{{{1*/
|
|---|
| 370 | void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss){
|
|---|
| 371 | int i,j;
|
|---|
| 372 |
|
|---|
| 373 | const int numgrids=6;
|
|---|
| 374 | const int DOFVELOCITY=3;
|
|---|
| 375 | double B[8][27];
|
|---|
| 376 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 377 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 378 |
|
|---|
| 379 | /*Get B matrix: */
|
|---|
| 380 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 381 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 382 | for (i=0;i<6;i++){
|
|---|
| 383 | for (j=0;j<3;j++){
|
|---|
| 384 | B_reduced[i][j]=B[i][j];
|
|---|
| 385 | }
|
|---|
| 386 | for (j=4;j<7;j++){
|
|---|
| 387 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 388 | }
|
|---|
| 389 | for (j=8;j<11;j++){
|
|---|
| 390 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 391 | }
|
|---|
| 392 | for (j=12;j<15;j++){
|
|---|
| 393 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 394 | }
|
|---|
| 395 | for (j=16;j<19;j++){
|
|---|
| 396 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 397 | }
|
|---|
| 398 | for (j=20;j<23;j++){
|
|---|
| 399 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 400 | }
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | /*Here, we are computing the strain rate of (0,0,vz)*/
|
|---|
| 404 | for(i=0;i<numgrids;i++){
|
|---|
| 405 | velocity[i][0]=0.0;
|
|---|
| 406 | velocity[i][1]=0.0;
|
|---|
| 407 | velocity[i][2]=this->values[i];
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 411 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvz,0);
|
|---|
| 412 |
|
|---|
| 413 | }
|
|---|
| 414 | /*}}}*/
|
|---|
| 415 | /*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn{{{1*/
|
|---|
| 416 | void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, double* gauss){
|
|---|
| 417 |
|
|---|
| 418 | int i;
|
|---|
| 419 | const int numgrids=6;
|
|---|
| 420 | const int NDOF2=2;
|
|---|
| 421 | double B[5][NDOF2*numgrids];
|
|---|
| 422 | double velocity[numgrids][NDOF2];
|
|---|
| 423 |
|
|---|
| 424 | /*Get B matrix: */
|
|---|
| 425 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
|---|
| 426 |
|
|---|
| 427 | /*Here, we are computing the strain rate of (vx,0)*/
|
|---|
| 428 | for(i=0;i<numgrids;i++){
|
|---|
| 429 | velocity[i][0]=this->values[i];
|
|---|
| 430 | velocity[i][1]=0.0;
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 434 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
|---|
| 435 | &velocity[0][0],NDOF2*numgrids,1,0,
|
|---|
| 436 | epsilonvx,0);
|
|---|
| 437 |
|
|---|
| 438 | }
|
|---|
| 439 | /*}}}*/
|
|---|
| 440 | /*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn{{{1*/
|
|---|
| 441 | void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss){
|
|---|
| 442 |
|
|---|
| 443 | int i;
|
|---|
| 444 | const int numgrids=6;
|
|---|
| 445 | const int NDOF2=2;
|
|---|
| 446 | double B[5][NDOF2*numgrids];
|
|---|
| 447 | double velocity[numgrids][NDOF2];
|
|---|
| 448 |
|
|---|
| 449 | /*Get B matrix: */
|
|---|
| 450 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
|---|
| 451 |
|
|---|
| 452 | /*Here, we are computing the strain rate of (0,vy)*/
|
|---|
| 453 | for(i=0;i<numgrids;i++){
|
|---|
| 454 | velocity[i][0]=0.0;
|
|---|
| 455 | velocity[i][1]=this->values[i];
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 459 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
|---|
| 460 | &velocity[0][0],NDOF2*numgrids,1,0,
|
|---|
| 461 | epsilonvy,0);
|
|---|
| 462 |
|
|---|
| 463 | }
|
|---|
| 464 | /*}}}*/
|
|---|
| 465 | /*FUNCTION PentaVertexInput::ChangeEnum{{{1*/
|
|---|
| 466 | void PentaVertexInput::ChangeEnum(int newenumtype){
|
|---|
| 467 | this->enum_type=newenumtype;
|
|---|
| 468 | }
|
|---|
| 469 | /*}}}*/
|
|---|
| 470 | /*FUNCTION PentaVertexInput::GetParameterAverage{{{1*/
|
|---|
| 471 | void PentaVertexInput::GetParameterAverage(double* pvalue){
|
|---|
| 472 | *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
|
|---|
| 473 | }
|
|---|
| 474 | /*}}}*/
|
|---|
| 475 |
|
|---|
| 476 | /*Intermediary*/
|
|---|
| 477 | /*FUNCTION PentaVertexInput::GetNodalFunctionsP1 {{{1*/
|
|---|
| 478 | void PentaVertexInput::GetNodalFunctionsP1(double* l1l6, double* gauss_coord){
|
|---|
| 479 |
|
|---|
| 480 | /*This routine returns the values of the nodal functions at the gaussian point.*/
|
|---|
| 481 |
|
|---|
| 482 | l1l6[0]=gauss_coord[0]*(1-gauss_coord[3])/2.0;
|
|---|
| 483 |
|
|---|
| 484 | l1l6[1]=gauss_coord[1]*(1-gauss_coord[3])/2.0;
|
|---|
| 485 |
|
|---|
| 486 | l1l6[2]=gauss_coord[2]*(1-gauss_coord[3])/2.0;
|
|---|
| 487 |
|
|---|
| 488 | l1l6[3]=gauss_coord[0]*(1+gauss_coord[3])/2.0;
|
|---|
| 489 |
|
|---|
| 490 | l1l6[4]=gauss_coord[1]*(1+gauss_coord[3])/2.0;
|
|---|
| 491 |
|
|---|
| 492 | l1l6[5]=gauss_coord[2]*(1+gauss_coord[3])/2.0;
|
|---|
| 493 |
|
|---|
| 494 | }
|
|---|
| 495 | /*}}}*/
|
|---|
| 496 | /*FUNCTION PentaVertexInput::GetNodalFunctionsMINI{{{1*/
|
|---|
| 497 | void PentaVertexInput::GetNodalFunctionsMINI(double* l1l7, double* gauss_coord){
|
|---|
| 498 |
|
|---|
| 499 | /*This routine returns the values of the nodal functions at the gaussian point.*/
|
|---|
| 500 |
|
|---|
| 501 | /*First nodal function: */
|
|---|
| 502 | l1l7[0]=gauss_coord[0]*(1.0-gauss_coord[3])/2.0;
|
|---|
| 503 |
|
|---|
| 504 | /*Second nodal function: */
|
|---|
| 505 | l1l7[1]=gauss_coord[1]*(1.0-gauss_coord[3])/2.0;
|
|---|
| 506 |
|
|---|
| 507 | /*Third nodal function: */
|
|---|
| 508 | l1l7[2]=gauss_coord[2]*(1.0-gauss_coord[3])/2.0;
|
|---|
| 509 |
|
|---|
| 510 | /*Fourth nodal function: */
|
|---|
| 511 | l1l7[3]=gauss_coord[0]*(1.0+gauss_coord[3])/2.0;
|
|---|
| 512 |
|
|---|
| 513 | /*Fifth nodal function: */
|
|---|
| 514 | l1l7[4]=gauss_coord[1]*(1.0+gauss_coord[3])/2.0;
|
|---|
| 515 |
|
|---|
| 516 | /*Sixth nodal function: */
|
|---|
| 517 | l1l7[5]=gauss_coord[2]*(1.0+gauss_coord[3])/2.0;
|
|---|
| 518 |
|
|---|
| 519 | /*Seventh nodal function: */
|
|---|
| 520 | l1l7[6]=27*gauss_coord[0]*gauss_coord[1]*gauss_coord[2]*(1.0+gauss_coord[3])*(1.0-gauss_coord[3]);
|
|---|
| 521 |
|
|---|
| 522 | }
|
|---|
| 523 | /*}}}*/
|
|---|
| 524 | /*FUNCTION PentaVertexInput::GetNodalFunctionsP1Derivatives {{{1*/
|
|---|
| 525 | void PentaVertexInput::GetNodalFunctionsP1Derivatives(double* dh1dh6,double* xyz_list, double* gauss_coord){
|
|---|
| 526 |
|
|---|
| 527 | /*This routine returns the values of the nodal functions derivatives (with respect to the actual coordinate system: */
|
|---|
| 528 | int i;
|
|---|
| 529 | const int NDOF3=3;
|
|---|
| 530 | const int numgrids=6;
|
|---|
| 531 |
|
|---|
| 532 | double dh1dh6_ref[NDOF3][numgrids];
|
|---|
| 533 | double Jinv[NDOF3][NDOF3];
|
|---|
| 534 |
|
|---|
| 535 | /*Get derivative values with respect to parametric coordinate system: */
|
|---|
| 536 | GetNodalFunctionsP1DerivativesReference(&dh1dh6_ref[0][0], gauss_coord);
|
|---|
| 537 |
|
|---|
| 538 | /*Get Jacobian invert: */
|
|---|
| 539 | GetJacobianInvert(&Jinv[0][0], xyz_list, gauss_coord);
|
|---|
| 540 |
|
|---|
| 541 | /*Build dh1dh3:
|
|---|
| 542 | *
|
|---|
| 543 | * [dhi/dx]= Jinv*[dhi/dr]
|
|---|
| 544 | * [dhi/dy] [dhi/ds]
|
|---|
| 545 | * [dhi/dz] [dhi/dn]
|
|---|
| 546 | */
|
|---|
| 547 |
|
|---|
| 548 | for (i=0;i<numgrids;i++){
|
|---|
| 549 | *(dh1dh6+numgrids*0+i)=Jinv[0][0]*dh1dh6_ref[0][i]+Jinv[0][1]*dh1dh6_ref[1][i]+Jinv[0][2]*dh1dh6_ref[2][i];
|
|---|
| 550 | *(dh1dh6+numgrids*1+i)=Jinv[1][0]*dh1dh6_ref[0][i]+Jinv[1][1]*dh1dh6_ref[1][i]+Jinv[1][2]*dh1dh6_ref[2][i];
|
|---|
| 551 | *(dh1dh6+numgrids*2+i)=Jinv[2][0]*dh1dh6_ref[0][i]+Jinv[2][1]*dh1dh6_ref[1][i]+Jinv[2][2]*dh1dh6_ref[2][i];
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | }
|
|---|
| 555 | /*}}}*/
|
|---|
| 556 | /*FUNCTION PentaVertexInput::GetNodalFunctionsMINIDerivatives{{{1*/
|
|---|
| 557 | void PentaVertexInput::GetNodalFunctionsMINIDerivatives(double* dh1dh7,double* xyz_list, double* gauss_coord){
|
|---|
| 558 |
|
|---|
| 559 | /*This routine returns the values of the nodal functions derivatives (with respect to the
|
|---|
| 560 | * actual coordinate system: */
|
|---|
| 561 |
|
|---|
| 562 | int i;
|
|---|
| 563 |
|
|---|
| 564 | const int numgrids=7;
|
|---|
| 565 | double dh1dh7_ref[3][numgrids];
|
|---|
| 566 | double Jinv[3][3];
|
|---|
| 567 |
|
|---|
| 568 |
|
|---|
| 569 | /*Get derivative values with respect to parametric coordinate system: */
|
|---|
| 570 | GetNodalFunctionsMINIDerivativesReference(&dh1dh7_ref[0][0], gauss_coord);
|
|---|
| 571 |
|
|---|
| 572 | /*Get Jacobian invert: */
|
|---|
| 573 | GetJacobianInvert(&Jinv[0][0], xyz_list, gauss_coord);
|
|---|
| 574 |
|
|---|
| 575 | /*Build dh1dh6:
|
|---|
| 576 | *
|
|---|
| 577 | * [dhi/dx]= Jinv'*[dhi/dr]
|
|---|
| 578 | * [dhi/dy] [dhi/ds]
|
|---|
| 579 | * [dhi/dz] [dhi/dzeta]
|
|---|
| 580 | */
|
|---|
| 581 |
|
|---|
| 582 | for (i=0;i<numgrids;i++){
|
|---|
| 583 | *(dh1dh7+numgrids*0+i)=Jinv[0][0]*dh1dh7_ref[0][i]+Jinv[0][1]*dh1dh7_ref[1][i]+Jinv[0][2]*dh1dh7_ref[2][i];
|
|---|
| 584 | *(dh1dh7+numgrids*1+i)=Jinv[1][0]*dh1dh7_ref[0][i]+Jinv[1][1]*dh1dh7_ref[1][i]+Jinv[1][2]*dh1dh7_ref[2][i];
|
|---|
| 585 | *(dh1dh7+numgrids*2+i)=Jinv[2][0]*dh1dh7_ref[0][i]+Jinv[2][1]*dh1dh7_ref[1][i]+Jinv[2][2]*dh1dh7_ref[2][i];
|
|---|
| 586 | }
|
|---|
| 587 |
|
|---|
| 588 | }
|
|---|
| 589 | /*}}}*/
|
|---|
| 590 | /*FUNCTION PentaVertexInput::GetNodalFunctionsP1DerivativesReference {{{1*/
|
|---|
| 591 | void PentaVertexInput::GetNodalFunctionsP1DerivativesReference(double* dl1dl6,double* gauss_coord){
|
|---|
| 592 |
|
|---|
| 593 | /*This routine returns the values of the nodal functions derivatives (with respect to the
|
|---|
| 594 | * natural coordinate system) at the gaussian point. Those values vary along xi,eta,z */
|
|---|
| 595 |
|
|---|
| 596 | const int numgrids=6;
|
|---|
| 597 | double A1,A2,A3,z;
|
|---|
| 598 |
|
|---|
| 599 | A1=gauss_coord[0]; //first area coordinate value. In term of xi and eta: A1=(1-xi)/2-eta/(2*SQRT3);
|
|---|
| 600 | A2=gauss_coord[1]; //second area coordinate value In term of xi and eta: A2=(1+xi)/2-eta/(2*SQRT3);
|
|---|
| 601 | A3=gauss_coord[2]; //third area coordinate value In term of xi and eta: A3=y/SQRT3;
|
|---|
| 602 | z=gauss_coord[3]; //fourth vertical coordinate value. Corresponding nodal function: (1-z)/2 and (1+z)/2
|
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 | /*First nodal function derivatives. The corresponding nodal function is N=A1*(1-z)/2. Its derivatives follow*/
|
|---|
| 606 | *(dl1dl6+numgrids*0+0)=-0.5*(1.0-z)/2.0;
|
|---|
| 607 | *(dl1dl6+numgrids*1+0)=-0.5/SQRT3*(1.0-z)/2.0;
|
|---|
| 608 | *(dl1dl6+numgrids*2+0)=-0.5*A1;
|
|---|
| 609 |
|
|---|
| 610 | /*Second nodal function: The corresponding nodal function is N=A2*(1-z)/2. Its derivatives follow*/
|
|---|
| 611 | *(dl1dl6+numgrids*0+1)=0.5*(1.0-z)/2.0;
|
|---|
| 612 | *(dl1dl6+numgrids*1+1)=-0.5/SQRT3*(1.0-z)/2.0;
|
|---|
| 613 | *(dl1dl6+numgrids*2+1)=-0.5*A2;
|
|---|
| 614 |
|
|---|
| 615 | /*Third nodal function: The corresponding nodal function is N=A3*(1-z)/2. Its derivatives follow*/
|
|---|
| 616 | *(dl1dl6+numgrids*0+2)=0.0;
|
|---|
| 617 | *(dl1dl6+numgrids*1+2)=1.0/SQRT3*(1.0-z)/2.0;
|
|---|
| 618 | *(dl1dl6+numgrids*2+2)=-0.5*A3;
|
|---|
| 619 |
|
|---|
| 620 | /*Fourth nodal function: The corresponding nodal function is N=A1*(1+z)/2. Its derivatives follow*/
|
|---|
| 621 | *(dl1dl6+numgrids*0+3)=-0.5*(1.0+z)/2.0;
|
|---|
| 622 | *(dl1dl6+numgrids*1+3)=-0.5/SQRT3*(1.0+z)/2.0;
|
|---|
| 623 | *(dl1dl6+numgrids*2+3)=0.5*A1;
|
|---|
| 624 |
|
|---|
| 625 | /*Fifth nodal function: The corresponding nodal function is N=A2*(1+z)/2. Its derivatives follow*/
|
|---|
| 626 | *(dl1dl6+numgrids*0+4)=0.5*(1.0+z)/2.0;
|
|---|
| 627 | *(dl1dl6+numgrids*1+4)=-0.5/SQRT3*(1.0+z)/2.0;
|
|---|
| 628 | *(dl1dl6+numgrids*2+4)=0.5*A2;
|
|---|
| 629 |
|
|---|
| 630 | /*Sixth nodal function: The corresponding nodal function is N=A3*(1+z)/2. Its derivatives follow*/
|
|---|
| 631 | *(dl1dl6+numgrids*0+5)=0.0;
|
|---|
| 632 | *(dl1dl6+numgrids*1+5)=1.0/SQRT3*(1.0+z)/2.0;
|
|---|
| 633 | *(dl1dl6+numgrids*2+5)=0.5*A3;
|
|---|
| 634 | }
|
|---|
| 635 | /*}}}*/
|
|---|
| 636 | /*FUNCTION PentaVertexInput::GetNodalFunctionsMINIDerivativesReference{{{1*/
|
|---|
| 637 | void PentaVertexInput::GetNodalFunctionsMINIDerivativesReference(double* dl1dl7,double* gauss_coord){
|
|---|
| 638 |
|
|---|
| 639 | /*This routine returns the values of the nodal functions derivatives (with respect to the
|
|---|
| 640 | * natural coordinate system) at the gaussian point. */
|
|---|
| 641 |
|
|---|
| 642 | int numgrids=7; //six plus bubble grids
|
|---|
| 643 |
|
|---|
| 644 | double r=gauss_coord[1]-gauss_coord[0];
|
|---|
| 645 | double s=-3.0/SQRT3*(gauss_coord[0]+gauss_coord[1]-2.0/3.0);
|
|---|
| 646 | double zeta=gauss_coord[3];
|
|---|
| 647 |
|
|---|
| 648 | /*First nodal function: */
|
|---|
| 649 | *(dl1dl7+numgrids*0+0)=-0.5*(1.0-zeta)/2.0;
|
|---|
| 650 | *(dl1dl7+numgrids*1+0)=-SQRT3/6.0*(1.0-zeta)/2.0;
|
|---|
| 651 | *(dl1dl7+numgrids*2+0)=-0.5*(-0.5*r-SQRT3/6.0*s+ONETHIRD);
|
|---|
| 652 |
|
|---|
| 653 | /*Second nodal function: */
|
|---|
| 654 | *(dl1dl7+numgrids*0+1)=0.5*(1.0-zeta)/2.0;
|
|---|
| 655 | *(dl1dl7+numgrids*1+1)=-SQRT3/6.0*(1.0-zeta)/2.0;
|
|---|
| 656 | *(dl1dl7+numgrids*2+1)=-0.5*(0.5*r-SQRT3/6.0*s+ONETHIRD);
|
|---|
| 657 |
|
|---|
| 658 | /*Third nodal function: */
|
|---|
| 659 | *(dl1dl7+numgrids*0+2)=0;
|
|---|
| 660 | *(dl1dl7+numgrids*1+2)=SQRT3/3.0*(1.0-zeta)/2.0;
|
|---|
| 661 | *(dl1dl7+numgrids*2+2)=-0.5*(SQRT3/3.0*s+ONETHIRD);
|
|---|
| 662 |
|
|---|
| 663 | /*Fourth nodal function: */
|
|---|
| 664 | *(dl1dl7+numgrids*0+3)=-0.5*(1.0+zeta)/2.0;
|
|---|
| 665 | *(dl1dl7+numgrids*1+3)=-SQRT3/6.0*(1.0+zeta)/2.0;
|
|---|
| 666 | *(dl1dl7+numgrids*2+3)=0.5*(-0.5*r-SQRT3/6.0*s+ONETHIRD);
|
|---|
| 667 |
|
|---|
| 668 | /*Fith nodal function: */
|
|---|
| 669 | *(dl1dl7+numgrids*0+4)=0.5*(1.0+zeta)/2.0;
|
|---|
| 670 | *(dl1dl7+numgrids*1+4)=-SQRT3/6.0*(1.0+zeta)/2.0;
|
|---|
| 671 | *(dl1dl7+numgrids*2+4)=0.5*(0.5*r-SQRT3/6.0*s+ONETHIRD);
|
|---|
| 672 |
|
|---|
| 673 | /*Sixth nodal function: */
|
|---|
| 674 | *(dl1dl7+numgrids*0+5)=0;
|
|---|
| 675 | *(dl1dl7+numgrids*1+5)=SQRT3/3.0*(1.0+zeta)/2.0;
|
|---|
| 676 | *(dl1dl7+numgrids*2+5)=0.5*(SQRT3/3.0*s+ONETHIRD);
|
|---|
| 677 |
|
|---|
| 678 | /*Seventh nodal function: */
|
|---|
| 679 | *(dl1dl7+numgrids*0+6)=9.0/2.0*r*(1.0+zeta)*(zeta-1.0)*(SQRT3*s+1.0);
|
|---|
| 680 | *(dl1dl7+numgrids*1+6)=9.0/4.0*(1+zeta)*(1-zeta)*(SQRT3*pow(s,2.0)-2.0*s-SQRT3*pow(r,2.0));
|
|---|
| 681 | *(dl1dl7+numgrids*2+6)=27*gauss_coord[0]*gauss_coord[1]*gauss_coord[2]*(-2.0*zeta);
|
|---|
| 682 |
|
|---|
| 683 | }
|
|---|
| 684 | /*}}}*/
|
|---|
| 685 | /*FUNCTION PentaVertexInput::GetJacobian {{{1*/
|
|---|
| 686 | void PentaVertexInput::GetJacobian(double* J, double* xyz_list,double* gauss_coord){
|
|---|
| 687 |
|
|---|
| 688 | const int NDOF3=3;
|
|---|
| 689 | int i,j;
|
|---|
| 690 |
|
|---|
| 691 | /*The Jacobian is constant over the element, discard the gaussian points.
|
|---|
| 692 | * J is assumed to have been allocated of size NDOF2xNDOF2.*/
|
|---|
| 693 |
|
|---|
| 694 | double A1,A2,A3; //area coordinates
|
|---|
| 695 | double xi,eta,zi; //parametric coordinates
|
|---|
| 696 |
|
|---|
| 697 | double x1,x2,x3,x4,x5,x6;
|
|---|
| 698 | double y1,y2,y3,y4,y5,y6;
|
|---|
| 699 | double z1,z2,z3,z4,z5,z6;
|
|---|
| 700 |
|
|---|
| 701 | /*Figure out xi,eta and zi (parametric coordinates), for this gaussian point: */
|
|---|
| 702 | A1=gauss_coord[0];
|
|---|
| 703 | A2=gauss_coord[1];
|
|---|
| 704 | A3=gauss_coord[2];
|
|---|
| 705 |
|
|---|
| 706 | xi=A2-A1;
|
|---|
| 707 | eta=SQRT3*A3;
|
|---|
| 708 | zi=gauss_coord[3];
|
|---|
| 709 |
|
|---|
| 710 | x1=*(xyz_list+3*0+0);
|
|---|
| 711 | x2=*(xyz_list+3*1+0);
|
|---|
| 712 | x3=*(xyz_list+3*2+0);
|
|---|
| 713 | x4=*(xyz_list+3*3+0);
|
|---|
| 714 | x5=*(xyz_list+3*4+0);
|
|---|
| 715 | x6=*(xyz_list+3*5+0);
|
|---|
| 716 |
|
|---|
| 717 | y1=*(xyz_list+3*0+1);
|
|---|
| 718 | y2=*(xyz_list+3*1+1);
|
|---|
| 719 | y3=*(xyz_list+3*2+1);
|
|---|
| 720 | y4=*(xyz_list+3*3+1);
|
|---|
| 721 | y5=*(xyz_list+3*4+1);
|
|---|
| 722 | y6=*(xyz_list+3*5+1);
|
|---|
| 723 |
|
|---|
| 724 | z1=*(xyz_list+3*0+2);
|
|---|
| 725 | z2=*(xyz_list+3*1+2);
|
|---|
| 726 | z3=*(xyz_list+3*2+2);
|
|---|
| 727 | z4=*(xyz_list+3*3+2);
|
|---|
| 728 | z5=*(xyz_list+3*4+2);
|
|---|
| 729 | z6=*(xyz_list+3*5+2);
|
|---|
| 730 |
|
|---|
| 731 | *(J+NDOF3*0+0)=0.25*(x1-x2-x4+x5)*zi+0.25*(-x1+x2-x4+x5);
|
|---|
| 732 | *(J+NDOF3*1+0)=SQRT3/12.0*(x1+x2-2*x3-x4-x5+2*x6)*zi+SQRT3/12.0*(-x1-x2+2*x3-x4-x5+2*x6);
|
|---|
| 733 | *(J+NDOF3*2+0)=SQRT3/12.0*(x1+x2-2*x3-x4-x5+2*x6)*eta+1/4*(x1-x2-x4+x5)*xi +0.25*(-x1+x5-x2+x4);
|
|---|
| 734 |
|
|---|
| 735 | *(J+NDOF3*0+1)=0.25*(y1-y2-y4+y5)*zi+0.25*(-y1+y2-y4+y5);
|
|---|
| 736 | *(J+NDOF3*1+1)=SQRT3/12.0*(y1+y2-2*y3-y4-y5+2*y6)*zi+SQRT3/12.0*(-y1-y2+2*y3-y4-y5+2*y6);
|
|---|
| 737 | *(J+NDOF3*2+1)=SQRT3/12.0*(y1+y2-2*y3-y4-y5+2*y6)*eta+0.25*(y1-y2-y4+y5)*xi+0.25*(y4-y1+y5-y2);
|
|---|
| 738 |
|
|---|
| 739 | *(J+NDOF3*0+2)=0.25*(z1-z2-z4+z5)*zi+0.25*(-z1+z2-z4+z5);
|
|---|
| 740 | *(J+NDOF3*1+2)=SQRT3/12.0*(z1+z2-2*z3-z4-z5+2*z6)*zi+SQRT3/12.0*(-z1-z2+2*z3-z4-z5+2*z6);
|
|---|
| 741 | *(J+NDOF3*2+2)=SQRT3/12.0*(z1+z2-2*z3-z4-z5+2*z6)*eta+0.25*(z1-z2-z4+z5)*xi+0.25*(-z1+z5-z2+z4);
|
|---|
| 742 |
|
|---|
| 743 | }
|
|---|
| 744 | /*}}}*/
|
|---|
| 745 | /*FUNCTION PentaVertexInput::GetJacobianInvert {{{1*/
|
|---|
| 746 | void PentaVertexInput::GetJacobianInvert(double* Jinv, double* xyz_list,double* gauss_coord){
|
|---|
| 747 |
|
|---|
| 748 | double Jdet;
|
|---|
| 749 | const int NDOF3=3;
|
|---|
| 750 |
|
|---|
| 751 | /*Call Jacobian routine to get the jacobian:*/
|
|---|
| 752 | GetJacobian(Jinv, xyz_list, gauss_coord);
|
|---|
| 753 |
|
|---|
| 754 | /*Invert Jacobian matrix: */
|
|---|
| 755 | MatrixInverse(Jinv,NDOF3,NDOF3,NULL,0,&Jdet);
|
|---|
| 756 | }
|
|---|
| 757 | /*}}}*/
|
|---|
| 758 | /*FUNCTION PentaVertexInput::GetBPattyn {{{1*/
|
|---|
| 759 | void PentaVertexInput::GetBPattyn(double* B, double* xyz_list, double* gauss_coord){
|
|---|
| 760 | /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
|
|---|
| 761 | * For grid i, Bi can be expressed in the actual coordinate system
|
|---|
| 762 | * by:
|
|---|
| 763 | * Bi=[ dh/dx 0 ]
|
|---|
| 764 | * [ 0 dh/dy ]
|
|---|
| 765 | * [ 1/2*dh/dy 1/2*dh/dx ]
|
|---|
| 766 | * [ 1/2*dh/dz 0 ]
|
|---|
| 767 | * [ 0 1/2*dh/dz ]
|
|---|
| 768 | * where h is the interpolation function for grid i.
|
|---|
| 769 | *
|
|---|
| 770 | * We assume B has been allocated already, of size: 5x(NDOF2*numgrids)
|
|---|
| 771 | */
|
|---|
| 772 |
|
|---|
| 773 | int i;
|
|---|
| 774 | const int numgrids=6;
|
|---|
| 775 | const int NDOF3=3;
|
|---|
| 776 | const int NDOF2=2;
|
|---|
| 777 |
|
|---|
| 778 | double dh1dh6[NDOF3][numgrids];
|
|---|
| 779 |
|
|---|
| 780 | /*Get dh1dh6 in actual coordinate system: */
|
|---|
| 781 | GetNodalFunctionsP1Derivatives(&dh1dh6[0][0],xyz_list, gauss_coord);
|
|---|
| 782 |
|
|---|
| 783 | /*Build B: */
|
|---|
| 784 | for (i=0;i<numgrids;i++){
|
|---|
| 785 | *(B+NDOF2*numgrids*0+NDOF2*i)=dh1dh6[0][i];
|
|---|
| 786 | *(B+NDOF2*numgrids*0+NDOF2*i+1)=0.0;
|
|---|
| 787 |
|
|---|
| 788 | *(B+NDOF2*numgrids*1+NDOF2*i)=0.0;
|
|---|
| 789 | *(B+NDOF2*numgrids*1+NDOF2*i+1)=dh1dh6[1][i];
|
|---|
| 790 |
|
|---|
| 791 | *(B+NDOF2*numgrids*2+NDOF2*i)=(float).5*dh1dh6[1][i];
|
|---|
| 792 | *(B+NDOF2*numgrids*2+NDOF2*i+1)=(float).5*dh1dh6[0][i];
|
|---|
| 793 |
|
|---|
| 794 | *(B+NDOF2*numgrids*3+NDOF2*i)=(float).5*dh1dh6[2][i];
|
|---|
| 795 | *(B+NDOF2*numgrids*3+NDOF2*i+1)=0.0;
|
|---|
| 796 |
|
|---|
| 797 | *(B+NDOF2*numgrids*4+NDOF2*i)=0.0;
|
|---|
| 798 | *(B+NDOF2*numgrids*4+NDOF2*i+1)=(float).5*dh1dh6[2][i];
|
|---|
| 799 | }
|
|---|
| 800 |
|
|---|
| 801 | }
|
|---|
| 802 | /*}}}*/
|
|---|
| 803 | /*FUNCTION PentaVertexInput::GetBStokes {{{1*/
|
|---|
| 804 | void PentaVertexInput::GetBStokes(double* B, double* xyz_list, double* gauss_coord){
|
|---|
| 805 |
|
|---|
| 806 | /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 3*DOFPERGRID.
|
|---|
| 807 | * For grid i, Bi can be expressed in the actual coordinate system
|
|---|
| 808 | * by: Bi=[ dh/dx 0 0 0 ]
|
|---|
| 809 | * [ 0 dh/dy 0 0 ]
|
|---|
| 810 | * [ 0 0 dh/dy 0 ]
|
|---|
| 811 | * [ 1/2*dh/dy 1/2*dh/dx 0 0 ]
|
|---|
| 812 | * [ 1/2*dh/dz 0 1/2*dh/dx 0 ]
|
|---|
| 813 | * [ 0 1/2*dh/dz 1/2*dh/dy 0 ]
|
|---|
| 814 | * [ 0 0 0 h ]
|
|---|
| 815 | * [ dh/dx dh/dy dh/dz 0 ]
|
|---|
| 816 | * where h is the interpolation function for grid i.
|
|---|
| 817 | * Same thing for Bb except the last column that does not exist.
|
|---|
| 818 | */
|
|---|
| 819 |
|
|---|
| 820 | int i;
|
|---|
| 821 | const int calculationdof=3;
|
|---|
| 822 | const int numgrids=6;
|
|---|
| 823 | int DOFPERGRID=4;
|
|---|
| 824 |
|
|---|
| 825 | double dh1dh7[calculationdof][numgrids+1];
|
|---|
| 826 | double l1l6[numgrids];
|
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 | /*Get dh1dh7 in actual coordinate system: */
|
|---|
| 830 | GetNodalFunctionsMINIDerivatives(&dh1dh7[0][0],xyz_list, gauss_coord);
|
|---|
| 831 | GetNodalFunctionsP1(l1l6, gauss_coord);
|
|---|
| 832 |
|
|---|
| 833 | /*Build B: */
|
|---|
| 834 | for (i=0;i<numgrids+1;i++){
|
|---|
| 835 | *(B+(DOFPERGRID*numgrids+3)*0+DOFPERGRID*i)=dh1dh7[0][i]; //B[0][DOFPERGRID*i]=dh1dh6[0][i];
|
|---|
| 836 | *(B+(DOFPERGRID*numgrids+3)*0+DOFPERGRID*i+1)=0;
|
|---|
| 837 | *(B+(DOFPERGRID*numgrids+3)*0+DOFPERGRID*i+2)=0;
|
|---|
| 838 | *(B+(DOFPERGRID*numgrids+3)*1+DOFPERGRID*i)=0;
|
|---|
| 839 | *(B+(DOFPERGRID*numgrids+3)*1+DOFPERGRID*i+1)=dh1dh7[1][i];
|
|---|
| 840 | *(B+(DOFPERGRID*numgrids+3)*1+DOFPERGRID*i+2)=0;
|
|---|
| 841 | *(B+(DOFPERGRID*numgrids+3)*2+DOFPERGRID*i)=0;
|
|---|
| 842 | *(B+(DOFPERGRID*numgrids+3)*2+DOFPERGRID*i+1)=0;
|
|---|
| 843 | *(B+(DOFPERGRID*numgrids+3)*2+DOFPERGRID*i+2)=dh1dh7[2][i];
|
|---|
| 844 | *(B+(DOFPERGRID*numgrids+3)*3+DOFPERGRID*i)=(float).5*dh1dh7[1][i];
|
|---|
| 845 | *(B+(DOFPERGRID*numgrids+3)*3+DOFPERGRID*i+1)=(float).5*dh1dh7[0][i];
|
|---|
| 846 | *(B+(DOFPERGRID*numgrids+3)*3+DOFPERGRID*i+2)=0;
|
|---|
| 847 | *(B+(DOFPERGRID*numgrids+3)*4+DOFPERGRID*i)=(float).5*dh1dh7[2][i];
|
|---|
| 848 | *(B+(DOFPERGRID*numgrids+3)*4+DOFPERGRID*i+1)=0;
|
|---|
| 849 | *(B+(DOFPERGRID*numgrids+3)*4+DOFPERGRID*i+2)=(float).5*dh1dh7[0][i];
|
|---|
| 850 | *(B+(DOFPERGRID*numgrids+3)*5+DOFPERGRID*i)=0;
|
|---|
| 851 | *(B+(DOFPERGRID*numgrids+3)*5+DOFPERGRID*i+1)=(float).5*dh1dh7[2][i];
|
|---|
| 852 | *(B+(DOFPERGRID*numgrids+3)*5+DOFPERGRID*i+2)=(float).5*dh1dh7[1][i];
|
|---|
| 853 | *(B+(DOFPERGRID*numgrids+3)*6+DOFPERGRID*i)=0;
|
|---|
| 854 | *(B+(DOFPERGRID*numgrids+3)*6+DOFPERGRID*i+1)=0;
|
|---|
| 855 | *(B+(DOFPERGRID*numgrids+3)*6+DOFPERGRID*i+2)=0;
|
|---|
| 856 | *(B+(DOFPERGRID*numgrids+3)*7+DOFPERGRID*i)=dh1dh7[0][i];
|
|---|
| 857 | *(B+(DOFPERGRID*numgrids+3)*7+DOFPERGRID*i+1)=dh1dh7[1][i];
|
|---|
| 858 | *(B+(DOFPERGRID*numgrids+3)*7+DOFPERGRID*i+2)=dh1dh7[2][i];
|
|---|
| 859 | }
|
|---|
| 860 |
|
|---|
| 861 | for (i=0;i<numgrids;i++){ //last column not for the bubble function
|
|---|
| 862 | *(B+(DOFPERGRID*numgrids+3)*0+DOFPERGRID*i+3)=0;
|
|---|
| 863 | *(B+(DOFPERGRID*numgrids+3)*1+DOFPERGRID*i+3)=0;
|
|---|
| 864 | *(B+(DOFPERGRID*numgrids+3)*2+DOFPERGRID*i+3)=0;
|
|---|
| 865 | *(B+(DOFPERGRID*numgrids+3)*3+DOFPERGRID*i+3)=0;
|
|---|
| 866 | *(B+(DOFPERGRID*numgrids+3)*4+DOFPERGRID*i+3)=0;
|
|---|
| 867 | *(B+(DOFPERGRID*numgrids+3)*5+DOFPERGRID*i+3)=0;
|
|---|
| 868 | *(B+(DOFPERGRID*numgrids+3)*6+DOFPERGRID*i+3)=l1l6[i];
|
|---|
| 869 | *(B+(DOFPERGRID*numgrids+3)*7+DOFPERGRID*i+3)=0;
|
|---|
| 870 | }
|
|---|
| 871 |
|
|---|
| 872 | }
|
|---|
| 873 | /*}}}*/
|
|---|
| 874 | /*FUNCTION PentaVertexInput::SquareMin{{{1*/
|
|---|
| 875 | void PentaVertexInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
|
|---|
| 876 |
|
|---|
| 877 | int i;
|
|---|
| 878 | const int numnodes=6;
|
|---|
| 879 | double valuescopy[numnodes];
|
|---|
| 880 | double squaremin;
|
|---|
| 881 |
|
|---|
| 882 | /*First, copy values, to process units if requested: */
|
|---|
| 883 | for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
|
|---|
| 884 |
|
|---|
| 885 | /*Process units if requested: */
|
|---|
| 886 | if(process_units)NodalValuesUnitConversion(&valuescopy[0],numnodes,enum_type,parameters);
|
|---|
| 887 |
|
|---|
| 888 | /*Now, figure out minimum of valuescopy: */
|
|---|
| 889 | squaremin=pow(valuescopy[0],2);
|
|---|
| 890 | for(i=1;i<numnodes;i++){
|
|---|
| 891 | if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
|
|---|
| 892 | }
|
|---|
| 893 | /*Assign output pointers:*/
|
|---|
| 894 | *psquaremin=squaremin;
|
|---|
| 895 | }
|
|---|
| 896 | /*}}}*/
|
|---|
| 897 | /*FUNCTION PentaVertexInput::Scale{{{1*/
|
|---|
| 898 | void PentaVertexInput::Scale(double scale_factor){
|
|---|
| 899 |
|
|---|
| 900 | int i;
|
|---|
| 901 | const int numgrids=6;
|
|---|
| 902 |
|
|---|
| 903 | for(i=0;i<numgrids;i++)values[i]=values[i]*scale_factor;
|
|---|
| 904 | }
|
|---|
| 905 | /*}}}*/
|
|---|
| 906 | /*FUNCTION PentaVertexInput::AXPY{{{1*/
|
|---|
| 907 | void PentaVertexInput::AXPY(Input* xinput,double scalar){
|
|---|
| 908 |
|
|---|
| 909 | int i;
|
|---|
| 910 | const int numgrids=6;
|
|---|
| 911 | PentaVertexInput* xpentavertexinput=NULL;
|
|---|
| 912 |
|
|---|
| 913 | /*xinput is of the same type, so cast it: */
|
|---|
| 914 | xpentavertexinput=(PentaVertexInput*)xinput;
|
|---|
| 915 |
|
|---|
| 916 | /*Carry out the AXPY operation depending on type:*/
|
|---|
| 917 | switch(xinput->Enum()){
|
|---|
| 918 |
|
|---|
| 919 | case PentaVertexInputEnum:
|
|---|
| 920 | for(i=0;i<numgrids;i++)this->values[i]=this->values[i]+scalar*xpentavertexinput->values[i];
|
|---|
| 921 | return;
|
|---|
| 922 |
|
|---|
| 923 | default:
|
|---|
| 924 | ISSMERROR("not implemented yet");
|
|---|
| 925 | }
|
|---|
| 926 |
|
|---|
| 927 | }
|
|---|
| 928 | /*}}}*/
|
|---|
| 929 | /*FUNCTION PentaVertexInput::Constrain{{{1*/
|
|---|
| 930 | void PentaVertexInput::Constrain(double cm_min, double cm_max){
|
|---|
| 931 |
|
|---|
| 932 | int i;
|
|---|
| 933 | const int numgrids=6;
|
|---|
| 934 |
|
|---|
| 935 | if(!isnan(cm_min)) for(i=0;i<numgrids;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
|
|---|
| 936 | if(!isnan(cm_max)) for(i=0;i<numgrids;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
|
|---|
| 937 |
|
|---|
| 938 | }
|
|---|
| 939 | /*}}}*/
|
|---|
| 940 | /*FUNCTION PentaVertexInput::Extrude{{{1*/
|
|---|
| 941 | void PentaVertexInput::Extrude(void){
|
|---|
| 942 |
|
|---|
| 943 | int i;
|
|---|
| 944 |
|
|---|
| 945 | /*First 3 values copied on 3 last values*/
|
|---|
| 946 | for(i=0;i<3;i++) this->values[3+i]=this->values[i];
|
|---|
| 947 |
|
|---|
| 948 | }
|
|---|
| 949 | /*}}}*/
|
|---|
| 950 | /*FUNCTION PentaVertexInput::VerticallyIntegrate{{{1*/
|
|---|
| 951 | void PentaVertexInput::VerticallyIntegrate(Input* thickness_input){
|
|---|
| 952 |
|
|---|
| 953 | /*Intermediaries*/
|
|---|
| 954 | int i;
|
|---|
| 955 | const int numgrids = 6;
|
|---|
| 956 | int num_thickness_values;
|
|---|
| 957 | double *thickness_values = NULL;
|
|---|
| 958 |
|
|---|
| 959 | /*Check that input provided is a thickness*/
|
|---|
| 960 | if (thickness_input->EnumType()!=ThicknessEnum) ISSMERROR("Input provided is not a Thickness (enum_type is %s)",EnumAsString(thickness_input->EnumType()));
|
|---|
| 961 |
|
|---|
| 962 | /*Get Thickness value pointer*/
|
|---|
| 963 | thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
|
|---|
| 964 |
|
|---|
| 965 | /*vertically integrate depending on type:*/
|
|---|
| 966 | switch(thickness_input->Enum()){
|
|---|
| 967 |
|
|---|
| 968 | case PentaVertexInputEnum:
|
|---|
| 969 | for(i=0;i<3;i++){
|
|---|
| 970 | this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
|
|---|
| 971 | this->values[i+3]=this->values[i];
|
|---|
| 972 | }
|
|---|
| 973 | return;
|
|---|
| 974 |
|
|---|
| 975 | default:
|
|---|
| 976 | ISSMERROR("not implemented yet");
|
|---|
| 977 | }
|
|---|
| 978 | }
|
|---|
| 979 | /*}}}*/
|
|---|
| 980 | /*FUNCTION PentaVertexInput::PointwiseDivide{{{1*/
|
|---|
| 981 | Input* PentaVertexInput::PointwiseDivide(Input* inputB){
|
|---|
| 982 |
|
|---|
| 983 | /*Ouput*/
|
|---|
| 984 | PentaVertexInput* outinput=NULL;
|
|---|
| 985 |
|
|---|
| 986 | /*Intermediaries*/
|
|---|
| 987 | int i;
|
|---|
| 988 | PentaVertexInput *xinputB = NULL;
|
|---|
| 989 | int B_numvalues;
|
|---|
| 990 | double *B_values = NULL;
|
|---|
| 991 | const int numgrids = 6;
|
|---|
| 992 | double AdotBvalues[numgrids];
|
|---|
| 993 |
|
|---|
| 994 | /*Check that inputB is of the same type*/
|
|---|
| 995 | if (inputB->Enum()!=PentaVertexInputEnum) ISSMERROR("Operation not permitted because inputB is of type %s",EnumAsString(inputB->Enum()));
|
|---|
| 996 | xinputB=(PentaVertexInput*)inputB;
|
|---|
| 997 |
|
|---|
| 998 | /*Create point wise sum*/
|
|---|
| 999 | for(i=0;i<numgrids;i++){
|
|---|
| 1000 | ISSMASSERT(xinputB->values[i]!=0);
|
|---|
| 1001 | AdotBvalues[i]=this->values[i]/xinputB->values[i];
|
|---|
| 1002 | }
|
|---|
| 1003 |
|
|---|
| 1004 | /*Create new Sing input (copy of current input)*/
|
|---|
| 1005 | outinput=new PentaVertexInput(this->enum_type,&AdotBvalues[0]);
|
|---|
| 1006 |
|
|---|
| 1007 | /*Return output pointer*/
|
|---|
| 1008 | return outinput;
|
|---|
| 1009 |
|
|---|
| 1010 | }
|
|---|
| 1011 | /*}}}*/
|
|---|
| 1012 | /*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/
|
|---|
| 1013 | void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
|
|---|
| 1014 |
|
|---|
| 1015 | const int numvertices=6;
|
|---|
| 1016 | VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
|
|---|
| 1017 |
|
|---|
| 1018 | } /*}}}*/
|
|---|
| 1019 | /*FUNCTION PentaVertexInput::GetValuesPtr{{{1*/
|
|---|
| 1020 | void PentaVertexInput::GetValuesPtr(double** pvalues,int* pnum_values){
|
|---|
| 1021 |
|
|---|
| 1022 | *pvalues=this->values;
|
|---|
| 1023 | *pnum_values=6;
|
|---|
| 1024 |
|
|---|
| 1025 | }
|
|---|
| 1026 | /*}}}*/
|
|---|