| 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 | :PentaRef(1)
|
|---|
| 28 | {
|
|---|
| 29 |
|
|---|
| 30 | /*Set PentaRef*/
|
|---|
| 31 | this->SetElementType(P1Enum,0);
|
|---|
| 32 | this->element_type=P1Enum;
|
|---|
| 33 |
|
|---|
| 34 | enum_type=in_enum_type;
|
|---|
| 35 | values[0]=in_values[0];
|
|---|
| 36 | values[1]=in_values[1];
|
|---|
| 37 | values[2]=in_values[2];
|
|---|
| 38 | values[3]=in_values[3];
|
|---|
| 39 | values[4]=in_values[4];
|
|---|
| 40 | values[5]=in_values[5];
|
|---|
| 41 | }
|
|---|
| 42 | /*}}}*/
|
|---|
| 43 | /*FUNCTION PentaVertexInput::~PentaVertexInput(){{{1*/
|
|---|
| 44 | PentaVertexInput::~PentaVertexInput(){
|
|---|
| 45 | return;
|
|---|
| 46 | }
|
|---|
| 47 | /*}}}*/
|
|---|
| 48 |
|
|---|
| 49 | /*Object virtual functions definitions:*/
|
|---|
| 50 | /*FUNCTION PentaVertexInput::Echo {{{1*/
|
|---|
| 51 | void PentaVertexInput::Echo(void){
|
|---|
| 52 | this->DeepEcho();
|
|---|
| 53 | }
|
|---|
| 54 | /*}}}*/
|
|---|
| 55 | /*FUNCTION PentaVertexInput::DeepEcho{{{1*/
|
|---|
| 56 | void PentaVertexInput::DeepEcho(void){
|
|---|
| 57 |
|
|---|
| 58 | printf("PentaVertexInput:\n");
|
|---|
| 59 | printf(" enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
|
|---|
| 60 | 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]);
|
|---|
| 61 | }
|
|---|
| 62 | /*}}}*/
|
|---|
| 63 | /*FUNCTION PentaVertexInput::Id{{{1*/
|
|---|
| 64 | int PentaVertexInput::Id(void){ return -1; }
|
|---|
| 65 | /*}}}*/
|
|---|
| 66 | /*FUNCTION PentaVertexInput::MyRank{{{1*/
|
|---|
| 67 | int PentaVertexInput::MyRank(void){
|
|---|
| 68 | extern int my_rank;
|
|---|
| 69 | return my_rank;
|
|---|
| 70 | }
|
|---|
| 71 | /*}}}*/
|
|---|
| 72 | /*FUNCTION PentaVertexInput::Marshall{{{1*/
|
|---|
| 73 | void PentaVertexInput::Marshall(char** pmarshalled_dataset){
|
|---|
| 74 |
|
|---|
| 75 | char* marshalled_dataset=NULL;
|
|---|
| 76 | int enum_value=0;
|
|---|
| 77 |
|
|---|
| 78 | /*recover marshalled_dataset: */
|
|---|
| 79 | marshalled_dataset=*pmarshalled_dataset;
|
|---|
| 80 |
|
|---|
| 81 | /*get enum value of PentaVertexInput: */
|
|---|
| 82 | enum_value=PentaVertexInputEnum;
|
|---|
| 83 |
|
|---|
| 84 | /*marshall enum: */
|
|---|
| 85 | memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
|
|---|
| 86 |
|
|---|
| 87 | /*marshall PentaVertexInput data: */
|
|---|
| 88 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
|---|
| 89 | memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
|
|---|
| 90 |
|
|---|
| 91 | *pmarshalled_dataset=marshalled_dataset;
|
|---|
| 92 | }
|
|---|
| 93 | /*}}}*/
|
|---|
| 94 | /*FUNCTION PentaVertexInput::MarshallSize{{{1*/
|
|---|
| 95 | int PentaVertexInput::MarshallSize(){
|
|---|
| 96 |
|
|---|
| 97 | return sizeof(values)+
|
|---|
| 98 | +sizeof(enum_type)+
|
|---|
| 99 | +sizeof(int); //sizeof(int) for enum value
|
|---|
| 100 | }
|
|---|
| 101 | /*}}}*/
|
|---|
| 102 | /*FUNCTION PentaVertexInput::Demarshall{{{1*/
|
|---|
| 103 | void PentaVertexInput::Demarshall(char** pmarshalled_dataset){
|
|---|
| 104 |
|
|---|
| 105 | char* marshalled_dataset=NULL;
|
|---|
| 106 | int i;
|
|---|
| 107 |
|
|---|
| 108 | /*recover marshalled_dataset: */
|
|---|
| 109 | marshalled_dataset=*pmarshalled_dataset;
|
|---|
| 110 |
|
|---|
| 111 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
|---|
| 112 | *object data (thanks to DataSet::Demarshall):*/
|
|---|
| 113 | memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
|---|
| 114 | memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
|
|---|
| 115 |
|
|---|
| 116 | /*return: */
|
|---|
| 117 | *pmarshalled_dataset=marshalled_dataset;
|
|---|
| 118 | return;
|
|---|
| 119 | }
|
|---|
| 120 | /*}}}*/
|
|---|
| 121 | /*FUNCTION PentaVertexInput::Enum{{{1*/
|
|---|
| 122 | int PentaVertexInput::Enum(void){
|
|---|
| 123 |
|
|---|
| 124 | return PentaVertexInputEnum;
|
|---|
| 125 |
|
|---|
| 126 | }
|
|---|
| 127 | /*}}}*/
|
|---|
| 128 |
|
|---|
| 129 | /*PentaVertexInput management*/
|
|---|
| 130 | /*FUNCTION PentaVertexInput::copy{{{1*/
|
|---|
| 131 | Object* PentaVertexInput::copy() {
|
|---|
| 132 |
|
|---|
| 133 | return new PentaVertexInput(this->enum_type,this->values);
|
|---|
| 134 |
|
|---|
| 135 | }
|
|---|
| 136 | /*}}}*/
|
|---|
| 137 | /*FUNCTION PentaVertexInput::EnumType{{{1*/
|
|---|
| 138 | int PentaVertexInput::EnumType(void){
|
|---|
| 139 |
|
|---|
| 140 | return this->enum_type;
|
|---|
| 141 |
|
|---|
| 142 | }
|
|---|
| 143 | /*}}}*/
|
|---|
| 144 | /*FUNCTION PentaVertexInput::SpawnBeamInput{{{1*/
|
|---|
| 145 | Input* PentaVertexInput::SpawnBeamInput(int* indices){
|
|---|
| 146 |
|
|---|
| 147 | /*output*/
|
|---|
| 148 | BeamVertexInput* outinput=NULL;
|
|---|
| 149 | double newvalues[2];
|
|---|
| 150 |
|
|---|
| 151 | /*Loop over the new indices*/
|
|---|
| 152 | for(int i=0;i<2;i++){
|
|---|
| 153 |
|
|---|
| 154 | /*Check index value*/
|
|---|
| 155 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
|---|
| 156 |
|
|---|
| 157 | /*Assign value to new input*/
|
|---|
| 158 | newvalues[i]=this->values[indices[i]];
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | /*Create new Beam input*/
|
|---|
| 162 | outinput=new BeamVertexInput(this->enum_type,&newvalues[0]);
|
|---|
| 163 |
|
|---|
| 164 | /*Assign output*/
|
|---|
| 165 | return outinput;
|
|---|
| 166 |
|
|---|
| 167 | }
|
|---|
| 168 | /*}}}*/
|
|---|
| 169 | /*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/
|
|---|
| 170 | Input* PentaVertexInput::SpawnTriaInput(int* indices){
|
|---|
| 171 |
|
|---|
| 172 | /*output*/
|
|---|
| 173 | TriaVertexInput* outinput=NULL;
|
|---|
| 174 | double newvalues[3];
|
|---|
| 175 |
|
|---|
| 176 | /*Loop over the new indices*/
|
|---|
| 177 | for(int i=0;i<3;i++){
|
|---|
| 178 |
|
|---|
| 179 | /*Check index value*/
|
|---|
| 180 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
|---|
| 181 |
|
|---|
| 182 | /*Assign value to new input*/
|
|---|
| 183 | newvalues[i]=this->values[indices[i]];
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | /*Create new Tria input*/
|
|---|
| 187 | outinput=new TriaVertexInput(this->enum_type,&newvalues[0]);
|
|---|
| 188 |
|
|---|
| 189 | /*Assign output*/
|
|---|
| 190 | return outinput;
|
|---|
| 191 |
|
|---|
| 192 | }
|
|---|
| 193 | /*}}}*/
|
|---|
| 194 | /*FUNCTION PentaVertexInput::SpawnResult{{{1*/
|
|---|
| 195 | ElementResult* PentaVertexInput::SpawnResult(int step, double time){
|
|---|
| 196 |
|
|---|
| 197 | return new PentaVertexElementResult(this->enum_type,this->values,step,time);
|
|---|
| 198 |
|
|---|
| 199 | }
|
|---|
| 200 | /*}}}*/
|
|---|
| 201 |
|
|---|
| 202 | /*Object functions*/
|
|---|
| 203 | /*FUNCTION PentaVertexInput::GetParameterValue(bool* pvalue) {{{1*/
|
|---|
| 204 | void PentaVertexInput::GetParameterValue(bool* pvalue){ISSMERROR(" not supported yet!");}
|
|---|
| 205 | /*}}}*/
|
|---|
| 206 | /*FUNCTION PentaVertexInput::GetParameterValue(int* pvalue){{{1*/
|
|---|
| 207 | void PentaVertexInput::GetParameterValue(int* pvalue){ISSMERROR(" not supported yet!");}
|
|---|
| 208 | /*}}}*/
|
|---|
| 209 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue){{{1*/
|
|---|
| 210 | void PentaVertexInput::GetParameterValue(double* pvalue){ISSMERROR(" not supported yet!");}
|
|---|
| 211 | /*}}}*/
|
|---|
| 212 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){{{1*/
|
|---|
| 213 | void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){
|
|---|
| 214 |
|
|---|
| 215 | /*Call PentaRef function*/
|
|---|
| 216 | PentaRef::GetParameterValue(pvalue,&values[0],gauss);
|
|---|
| 217 |
|
|---|
| 218 | }
|
|---|
| 219 | /*}}}*/
|
|---|
| 220 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){{{1*/
|
|---|
| 221 | void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss,double defaultvalue){ISSMERROR(" not supported yet!");}
|
|---|
| 222 | /*}}}*/
|
|---|
| 223 | /*FUNCTION PentaVertexInput::GetParameterValues{{{1*/
|
|---|
| 224 | void PentaVertexInput::GetParameterValues(double* values,double* gauss_pointers, int numgauss){
|
|---|
| 225 | /*It is assumed that output values has been correctly allocated*/
|
|---|
| 226 |
|
|---|
| 227 | int i,j;
|
|---|
| 228 | double gauss[4];
|
|---|
| 229 |
|
|---|
| 230 | for (i=0;i<numgauss;i++){
|
|---|
| 231 |
|
|---|
| 232 | /*Get current Gauss point coordinates*/
|
|---|
| 233 | for (j=0;j<4;j++) gauss[j]=gauss_pointers[i*4+j];
|
|---|
| 234 |
|
|---|
| 235 | /*Assign parameter value*/
|
|---|
| 236 | GetParameterValue(&values[i],&gauss[0]);
|
|---|
| 237 | }
|
|---|
| 238 | }
|
|---|
| 239 | /*}}}*/
|
|---|
| 240 | /*FUNCTION PentaVertexInput::GetParameterDerivativeValue{{{1*/
|
|---|
| 241 | void PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, double* gauss){
|
|---|
| 242 |
|
|---|
| 243 | /*Call PentaRef function*/
|
|---|
| 244 | PentaRef::GetParameterDerivativeValue(p,&values[0],xyz_list,gauss);
|
|---|
| 245 | }
|
|---|
| 246 | /*}}}*/
|
|---|
| 247 | /*FUNCTION PentaVertexInput::GetVxStrainRate3d{{{1*/
|
|---|
| 248 | void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, double* gauss){
|
|---|
| 249 | int i,j;
|
|---|
| 250 |
|
|---|
| 251 | const int numgrids=6;
|
|---|
| 252 | const int DOFVELOCITY=3;
|
|---|
| 253 | double B[8][27];
|
|---|
| 254 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 255 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 256 |
|
|---|
| 257 | /*Get B matrix: */
|
|---|
| 258 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 259 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 260 | for (i=0;i<6;i++){
|
|---|
| 261 | for (j=0;j<3;j++){
|
|---|
| 262 | B_reduced[i][j]=B[i][j];
|
|---|
| 263 | }
|
|---|
| 264 | for (j=4;j<7;j++){
|
|---|
| 265 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 266 | }
|
|---|
| 267 | for (j=8;j<11;j++){
|
|---|
| 268 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 269 | }
|
|---|
| 270 | for (j=12;j<15;j++){
|
|---|
| 271 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 272 | }
|
|---|
| 273 | for (j=16;j<19;j++){
|
|---|
| 274 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 275 | }
|
|---|
| 276 | for (j=20;j<23;j++){
|
|---|
| 277 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 278 | }
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | /*Here, we are computing the strain rate of (vx,0,0)*/
|
|---|
| 282 | for(i=0;i<numgrids;i++){
|
|---|
| 283 | velocity[i][0]=this->values[i];
|
|---|
| 284 | velocity[i][1]=0.0;
|
|---|
| 285 | velocity[i][2]=0.0;
|
|---|
| 286 | }
|
|---|
| 287 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 288 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvx,0);
|
|---|
| 289 |
|
|---|
| 290 | }
|
|---|
| 291 | /*}}}*/
|
|---|
| 292 | /*FUNCTION PentaVertexInput::GetVyStrainRate3d{{{1*/
|
|---|
| 293 | void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, double* gauss){
|
|---|
| 294 | int i,j;
|
|---|
| 295 |
|
|---|
| 296 | const int numgrids=6;
|
|---|
| 297 | const int DOFVELOCITY=3;
|
|---|
| 298 | double B[8][27];
|
|---|
| 299 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 300 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 301 |
|
|---|
| 302 | /*Get B matrix: */
|
|---|
| 303 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 304 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 305 | for (i=0;i<6;i++){
|
|---|
| 306 | for (j=0;j<3;j++){
|
|---|
| 307 | B_reduced[i][j]=B[i][j];
|
|---|
| 308 | }
|
|---|
| 309 | for (j=4;j<7;j++){
|
|---|
| 310 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 311 | }
|
|---|
| 312 | for (j=8;j<11;j++){
|
|---|
| 313 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 314 | }
|
|---|
| 315 | for (j=12;j<15;j++){
|
|---|
| 316 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 317 | }
|
|---|
| 318 | for (j=16;j<19;j++){
|
|---|
| 319 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 320 | }
|
|---|
| 321 | for (j=20;j<23;j++){
|
|---|
| 322 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 323 | }
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | /*Here, we are computing the strain rate of (0,vy,0)*/
|
|---|
| 327 | for(i=0;i<numgrids;i++){
|
|---|
| 328 | velocity[i][0]=0.0;
|
|---|
| 329 | velocity[i][1]=this->values[i];
|
|---|
| 330 | velocity[i][2]=0.0;
|
|---|
| 331 | }
|
|---|
| 332 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 333 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvy,0);
|
|---|
| 334 |
|
|---|
| 335 | }
|
|---|
| 336 | /*}}}*/
|
|---|
| 337 | /*FUNCTION PentaVertexInput::GetVzStrainRate3d{{{1*/
|
|---|
| 338 | void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, double* gauss){
|
|---|
| 339 | int i,j;
|
|---|
| 340 |
|
|---|
| 341 | const int numgrids=6;
|
|---|
| 342 | const int DOFVELOCITY=3;
|
|---|
| 343 | double B[8][27];
|
|---|
| 344 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 345 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 346 |
|
|---|
| 347 | /*Get B matrix: */
|
|---|
| 348 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 349 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 350 | for (i=0;i<6;i++){
|
|---|
| 351 | for (j=0;j<3;j++){
|
|---|
| 352 | B_reduced[i][j]=B[i][j];
|
|---|
| 353 | }
|
|---|
| 354 | for (j=4;j<7;j++){
|
|---|
| 355 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 356 | }
|
|---|
| 357 | for (j=8;j<11;j++){
|
|---|
| 358 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 359 | }
|
|---|
| 360 | for (j=12;j<15;j++){
|
|---|
| 361 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 362 | }
|
|---|
| 363 | for (j=16;j<19;j++){
|
|---|
| 364 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 365 | }
|
|---|
| 366 | for (j=20;j<23;j++){
|
|---|
| 367 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 368 | }
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | /*Here, we are computing the strain rate of (0,0,vz)*/
|
|---|
| 372 | for(i=0;i<numgrids;i++){
|
|---|
| 373 | velocity[i][0]=0.0;
|
|---|
| 374 | velocity[i][1]=0.0;
|
|---|
| 375 | velocity[i][2]=this->values[i];
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 379 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvz,0);
|
|---|
| 380 |
|
|---|
| 381 | }
|
|---|
| 382 | /*}}}*/
|
|---|
| 383 | /*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn{{{1*/
|
|---|
| 384 | void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, double* gauss){
|
|---|
| 385 |
|
|---|
| 386 | int i;
|
|---|
| 387 | const int numgrids=6;
|
|---|
| 388 | const int NDOF2=2;
|
|---|
| 389 | double B[5][NDOF2*numgrids];
|
|---|
| 390 | double velocity[numgrids][NDOF2];
|
|---|
| 391 |
|
|---|
| 392 | /*Get B matrix: */
|
|---|
| 393 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
|---|
| 394 |
|
|---|
| 395 | /*Here, we are computing the strain rate of (vx,0)*/
|
|---|
| 396 | for(i=0;i<numgrids;i++){
|
|---|
| 397 | velocity[i][0]=this->values[i];
|
|---|
| 398 | velocity[i][1]=0.0;
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 402 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
|---|
| 403 | &velocity[0][0],NDOF2*numgrids,1,0,
|
|---|
| 404 | epsilonvx,0);
|
|---|
| 405 |
|
|---|
| 406 | }
|
|---|
| 407 | /*}}}*/
|
|---|
| 408 | /*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn{{{1*/
|
|---|
| 409 | void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss){
|
|---|
| 410 |
|
|---|
| 411 | int i;
|
|---|
| 412 | const int numgrids=6;
|
|---|
| 413 | const int NDOF2=2;
|
|---|
| 414 | double B[5][NDOF2*numgrids];
|
|---|
| 415 | double velocity[numgrids][NDOF2];
|
|---|
| 416 |
|
|---|
| 417 | /*Get B matrix: */
|
|---|
| 418 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
|---|
| 419 |
|
|---|
| 420 | /*Here, we are computing the strain rate of (0,vy)*/
|
|---|
| 421 | for(i=0;i<numgrids;i++){
|
|---|
| 422 | velocity[i][0]=0.0;
|
|---|
| 423 | velocity[i][1]=this->values[i];
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 427 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
|---|
| 428 | &velocity[0][0],NDOF2*numgrids,1,0,
|
|---|
| 429 | epsilonvy,0);
|
|---|
| 430 |
|
|---|
| 431 | }
|
|---|
| 432 | /*}}}*/
|
|---|
| 433 | /*FUNCTION PentaVertexInput::ChangeEnum{{{1*/
|
|---|
| 434 | void PentaVertexInput::ChangeEnum(int newenumtype){
|
|---|
| 435 | this->enum_type=newenumtype;
|
|---|
| 436 | }
|
|---|
| 437 | /*}}}*/
|
|---|
| 438 | /*FUNCTION PentaVertexInput::GetParameterAverage{{{1*/
|
|---|
| 439 | void PentaVertexInput::GetParameterAverage(double* pvalue){
|
|---|
| 440 | *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
|
|---|
| 441 | }
|
|---|
| 442 | /*}}}*/
|
|---|
| 443 |
|
|---|
| 444 | /*Intermediary*/
|
|---|
| 445 | /*FUNCTION PentaVertexInput::SquareMin{{{1*/
|
|---|
| 446 | void PentaVertexInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
|
|---|
| 447 |
|
|---|
| 448 | int i;
|
|---|
| 449 | const int numnodes=6;
|
|---|
| 450 | double valuescopy[numnodes];
|
|---|
| 451 | double squaremin;
|
|---|
| 452 |
|
|---|
| 453 | /*First, copy values, to process units if requested: */
|
|---|
| 454 | for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
|
|---|
| 455 |
|
|---|
| 456 | /*Process units if requested: */
|
|---|
| 457 | if(process_units)NodalValuesUnitConversion(&valuescopy[0],numnodes,enum_type,parameters);
|
|---|
| 458 |
|
|---|
| 459 | /*Now, figure out minimum of valuescopy: */
|
|---|
| 460 | squaremin=pow(valuescopy[0],2);
|
|---|
| 461 | for(i=1;i<numnodes;i++){
|
|---|
| 462 | if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
|
|---|
| 463 | }
|
|---|
| 464 | /*Assign output pointers:*/
|
|---|
| 465 | *psquaremin=squaremin;
|
|---|
| 466 | }
|
|---|
| 467 | /*}}}*/
|
|---|
| 468 | /*FUNCTION PentaVertexInput::Scale{{{1*/
|
|---|
| 469 | void PentaVertexInput::Scale(double scale_factor){
|
|---|
| 470 |
|
|---|
| 471 | int i;
|
|---|
| 472 | const int numgrids=6;
|
|---|
| 473 |
|
|---|
| 474 | for(i=0;i<numgrids;i++)values[i]=values[i]*scale_factor;
|
|---|
| 475 | }
|
|---|
| 476 | /*}}}*/
|
|---|
| 477 | /*FUNCTION PentaVertexInput::AXPY{{{1*/
|
|---|
| 478 | void PentaVertexInput::AXPY(Input* xinput,double scalar){
|
|---|
| 479 |
|
|---|
| 480 | int i;
|
|---|
| 481 | const int numgrids=6;
|
|---|
| 482 | PentaVertexInput* xpentavertexinput=NULL;
|
|---|
| 483 |
|
|---|
| 484 | /*xinput is of the same type, so cast it: */
|
|---|
| 485 | xpentavertexinput=(PentaVertexInput*)xinput;
|
|---|
| 486 |
|
|---|
| 487 | /*Carry out the AXPY operation depending on type:*/
|
|---|
| 488 | switch(xinput->Enum()){
|
|---|
| 489 |
|
|---|
| 490 | case PentaVertexInputEnum:
|
|---|
| 491 | for(i=0;i<numgrids;i++)this->values[i]=this->values[i]+scalar*xpentavertexinput->values[i];
|
|---|
| 492 | return;
|
|---|
| 493 |
|
|---|
| 494 | default:
|
|---|
| 495 | ISSMERROR("not implemented yet");
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | }
|
|---|
| 499 | /*}}}*/
|
|---|
| 500 | /*FUNCTION PentaVertexInput::Constrain{{{1*/
|
|---|
| 501 | void PentaVertexInput::Constrain(double cm_min, double cm_max){
|
|---|
| 502 |
|
|---|
| 503 | int i;
|
|---|
| 504 | const int numgrids=6;
|
|---|
| 505 |
|
|---|
| 506 | if(!isnan(cm_min)) for(i=0;i<numgrids;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
|
|---|
| 507 | if(!isnan(cm_max)) for(i=0;i<numgrids;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
|
|---|
| 508 |
|
|---|
| 509 | }
|
|---|
| 510 | /*}}}*/
|
|---|
| 511 | /*FUNCTION PentaVertexInput::Extrude{{{1*/
|
|---|
| 512 | void PentaVertexInput::Extrude(void){
|
|---|
| 513 |
|
|---|
| 514 | int i;
|
|---|
| 515 |
|
|---|
| 516 | /*First 3 values copied on 3 last values*/
|
|---|
| 517 | for(i=0;i<3;i++) this->values[3+i]=this->values[i];
|
|---|
| 518 |
|
|---|
| 519 | }
|
|---|
| 520 | /*}}}*/
|
|---|
| 521 | /*FUNCTION PentaVertexInput::VerticallyIntegrate{{{1*/
|
|---|
| 522 | void PentaVertexInput::VerticallyIntegrate(Input* thickness_input){
|
|---|
| 523 |
|
|---|
| 524 | /*Intermediaries*/
|
|---|
| 525 | int i;
|
|---|
| 526 | const int numgrids = 6;
|
|---|
| 527 | int num_thickness_values;
|
|---|
| 528 | double *thickness_values = NULL;
|
|---|
| 529 |
|
|---|
| 530 | /*Check that input provided is a thickness*/
|
|---|
| 531 | if (thickness_input->EnumType()!=ThicknessEnum) ISSMERROR("Input provided is not a Thickness (enum_type is %s)",EnumAsString(thickness_input->EnumType()));
|
|---|
| 532 |
|
|---|
| 533 | /*Get Thickness value pointer*/
|
|---|
| 534 | thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
|
|---|
| 535 |
|
|---|
| 536 | /*vertically integrate depending on type:*/
|
|---|
| 537 | switch(thickness_input->Enum()){
|
|---|
| 538 |
|
|---|
| 539 | case PentaVertexInputEnum:
|
|---|
| 540 | for(i=0;i<3;i++){
|
|---|
| 541 | this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
|
|---|
| 542 | this->values[i+3]=this->values[i];
|
|---|
| 543 | }
|
|---|
| 544 | return;
|
|---|
| 545 |
|
|---|
| 546 | default:
|
|---|
| 547 | ISSMERROR("not implemented yet");
|
|---|
| 548 | }
|
|---|
| 549 | }
|
|---|
| 550 | /*}}}*/
|
|---|
| 551 | /*FUNCTION PentaVertexInput::PointwiseDivide{{{1*/
|
|---|
| 552 | Input* PentaVertexInput::PointwiseDivide(Input* inputB){
|
|---|
| 553 |
|
|---|
| 554 | /*Ouput*/
|
|---|
| 555 | PentaVertexInput* outinput=NULL;
|
|---|
| 556 |
|
|---|
| 557 | /*Intermediaries*/
|
|---|
| 558 | int i;
|
|---|
| 559 | PentaVertexInput *xinputB = NULL;
|
|---|
| 560 | int B_numvalues;
|
|---|
| 561 | double *B_values = NULL;
|
|---|
| 562 | const int numgrids = 6;
|
|---|
| 563 | double AdotBvalues[numgrids];
|
|---|
| 564 |
|
|---|
| 565 | /*Check that inputB is of the same type*/
|
|---|
| 566 | if (inputB->Enum()!=PentaVertexInputEnum) ISSMERROR("Operation not permitted because inputB is of type %s",EnumAsString(inputB->Enum()));
|
|---|
| 567 | xinputB=(PentaVertexInput*)inputB;
|
|---|
| 568 |
|
|---|
| 569 | /*Create point wise sum*/
|
|---|
| 570 | for(i=0;i<numgrids;i++){
|
|---|
| 571 | ISSMASSERT(xinputB->values[i]!=0);
|
|---|
| 572 | AdotBvalues[i]=this->values[i]/xinputB->values[i];
|
|---|
| 573 | }
|
|---|
| 574 |
|
|---|
| 575 | /*Create new Penta vertex input (copy of current input)*/
|
|---|
| 576 | outinput=new PentaVertexInput(this->enum_type,&AdotBvalues[0]);
|
|---|
| 577 |
|
|---|
| 578 | /*Return output pointer*/
|
|---|
| 579 | return outinput;
|
|---|
| 580 |
|
|---|
| 581 | }
|
|---|
| 582 | /*}}}*/
|
|---|
| 583 | /*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/
|
|---|
| 584 | void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
|
|---|
| 585 |
|
|---|
| 586 | const int numvertices=6;
|
|---|
| 587 | VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
|
|---|
| 588 |
|
|---|
| 589 | } /*}}}*/
|
|---|
| 590 | /*FUNCTION PentaVertexInput::GetValuesPtr{{{1*/
|
|---|
| 591 | void PentaVertexInput::GetValuesPtr(double** pvalues,int* pnum_values){
|
|---|
| 592 |
|
|---|
| 593 | *pvalues=this->values;
|
|---|
| 594 | *pnum_values=6;
|
|---|
| 595 |
|
|---|
| 596 | }
|
|---|
| 597 | /*}}}*/
|
|---|