| 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,EnumToString(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::SpawnTriaInput{{{1*/
|
|---|
| 145 | Input* PentaVertexInput::SpawnTriaInput(int* indices){
|
|---|
| 146 |
|
|---|
| 147 | /*output*/
|
|---|
| 148 | TriaVertexInput* outinput=NULL;
|
|---|
| 149 | double newvalues[3];
|
|---|
| 150 |
|
|---|
| 151 | /*Loop over the new indices*/
|
|---|
| 152 | for(int i=0;i<3;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 Tria input*/
|
|---|
| 162 | outinput=new TriaVertexInput(this->enum_type,&newvalues[0]);
|
|---|
| 163 |
|
|---|
| 164 | /*Assign output*/
|
|---|
| 165 | return outinput;
|
|---|
| 166 |
|
|---|
| 167 | }
|
|---|
| 168 | /*}}}*/
|
|---|
| 169 | /*FUNCTION PentaVertexInput::SpawnResult{{{1*/
|
|---|
| 170 | ElementResult* PentaVertexInput::SpawnResult(int step, double time){
|
|---|
| 171 |
|
|---|
| 172 | return new PentaVertexElementResult(this->enum_type,this->values,step,time);
|
|---|
| 173 |
|
|---|
| 174 | }
|
|---|
| 175 | /*}}}*/
|
|---|
| 176 |
|
|---|
| 177 | /*Object functions*/
|
|---|
| 178 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){{{1*/
|
|---|
| 179 | void PentaVertexInput::GetParameterValue(double* pvalue,double* gauss){
|
|---|
| 180 |
|
|---|
| 181 | /*Call PentaRef function*/
|
|---|
| 182 | PentaRef::GetParameterValue(pvalue,&values[0],gauss);
|
|---|
| 183 |
|
|---|
| 184 | }
|
|---|
| 185 | /*}}}*/
|
|---|
| 186 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,GaussPenta* gauss){{{1*/
|
|---|
| 187 | void PentaVertexInput::GetParameterValue(double* pvalue,GaussPenta* gauss){
|
|---|
| 188 |
|
|---|
| 189 | /*Call PentaRef function*/
|
|---|
| 190 | PentaRef::GetParameterValue(pvalue,&values[0],gauss);
|
|---|
| 191 |
|
|---|
| 192 | }
|
|---|
| 193 | /*}}}*/
|
|---|
| 194 | /*FUNCTION PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, double* gauss){{{1*/
|
|---|
| 195 | void PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, double* gauss){
|
|---|
| 196 |
|
|---|
| 197 | /*Call PentaRef function*/
|
|---|
| 198 | PentaRef::GetParameterDerivativeValue(p,&values[0],xyz_list,gauss);
|
|---|
| 199 | }
|
|---|
| 200 | /*}}}*/
|
|---|
| 201 | /*FUNCTION PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){{{1*/
|
|---|
| 202 | void PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){
|
|---|
| 203 |
|
|---|
| 204 | /*Call PentaRef function*/
|
|---|
| 205 | PentaRef::GetParameterDerivativeValue(p,&values[0],xyz_list,gauss);
|
|---|
| 206 | }
|
|---|
| 207 | /*}}}*/
|
|---|
| 208 | /*FUNCTION PentaVertexInput::GetVxStrainRate3d{{{1*/
|
|---|
| 209 | void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
|
|---|
| 210 | int i,j;
|
|---|
| 211 |
|
|---|
| 212 | const int numgrids=6;
|
|---|
| 213 | const int DOFVELOCITY=3;
|
|---|
| 214 | double B[8][27];
|
|---|
| 215 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 216 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 217 |
|
|---|
| 218 | /*Get B matrix: */
|
|---|
| 219 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 220 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 221 | for (i=0;i<6;i++){
|
|---|
| 222 | for (j=0;j<3;j++){
|
|---|
| 223 | B_reduced[i][j]=B[i][j];
|
|---|
| 224 | }
|
|---|
| 225 | for (j=4;j<7;j++){
|
|---|
| 226 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 227 | }
|
|---|
| 228 | for (j=8;j<11;j++){
|
|---|
| 229 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 230 | }
|
|---|
| 231 | for (j=12;j<15;j++){
|
|---|
| 232 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 233 | }
|
|---|
| 234 | for (j=16;j<19;j++){
|
|---|
| 235 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 236 | }
|
|---|
| 237 | for (j=20;j<23;j++){
|
|---|
| 238 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 239 | }
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | /*Here, we are computing the strain rate of (vx,0,0)*/
|
|---|
| 243 | for(i=0;i<numgrids;i++){
|
|---|
| 244 | velocity[i][0]=this->values[i];
|
|---|
| 245 | velocity[i][1]=0.0;
|
|---|
| 246 | velocity[i][2]=0.0;
|
|---|
| 247 | }
|
|---|
| 248 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 249 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvx,0);
|
|---|
| 250 |
|
|---|
| 251 | }
|
|---|
| 252 | /*}}}*/
|
|---|
| 253 | /*FUNCTION PentaVertexInput::GetVyStrainRate3d{{{1*/
|
|---|
| 254 | void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
|
|---|
| 255 | int i,j;
|
|---|
| 256 |
|
|---|
| 257 | const int numgrids=6;
|
|---|
| 258 | const int DOFVELOCITY=3;
|
|---|
| 259 | double B[8][27];
|
|---|
| 260 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 261 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 262 |
|
|---|
| 263 | /*Get B matrix: */
|
|---|
| 264 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 265 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 266 | for (i=0;i<6;i++){
|
|---|
| 267 | for (j=0;j<3;j++){
|
|---|
| 268 | B_reduced[i][j]=B[i][j];
|
|---|
| 269 | }
|
|---|
| 270 | for (j=4;j<7;j++){
|
|---|
| 271 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 272 | }
|
|---|
| 273 | for (j=8;j<11;j++){
|
|---|
| 274 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 275 | }
|
|---|
| 276 | for (j=12;j<15;j++){
|
|---|
| 277 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 278 | }
|
|---|
| 279 | for (j=16;j<19;j++){
|
|---|
| 280 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 281 | }
|
|---|
| 282 | for (j=20;j<23;j++){
|
|---|
| 283 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 284 | }
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | /*Here, we are computing the strain rate of (0,vy,0)*/
|
|---|
| 288 | for(i=0;i<numgrids;i++){
|
|---|
| 289 | velocity[i][0]=0.0;
|
|---|
| 290 | velocity[i][1]=this->values[i];
|
|---|
| 291 | velocity[i][2]=0.0;
|
|---|
| 292 | }
|
|---|
| 293 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 294 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvy,0);
|
|---|
| 295 |
|
|---|
| 296 | }
|
|---|
| 297 | /*}}}*/
|
|---|
| 298 | /*FUNCTION PentaVertexInput::GetVzStrainRate3d{{{1*/
|
|---|
| 299 | void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
|
|---|
| 300 | int i,j;
|
|---|
| 301 |
|
|---|
| 302 | const int numgrids=6;
|
|---|
| 303 | const int DOFVELOCITY=3;
|
|---|
| 304 | double B[8][27];
|
|---|
| 305 | double B_reduced[6][DOFVELOCITY*numgrids];
|
|---|
| 306 | double velocity[numgrids][DOFVELOCITY];
|
|---|
| 307 |
|
|---|
| 308 | /*Get B matrix: */
|
|---|
| 309 | GetBStokes(&B[0][0], xyz_list, gauss);
|
|---|
| 310 | /*Create a reduced matrix of B to get rid of pressure */
|
|---|
| 311 | for (i=0;i<6;i++){
|
|---|
| 312 | for (j=0;j<3;j++){
|
|---|
| 313 | B_reduced[i][j]=B[i][j];
|
|---|
| 314 | }
|
|---|
| 315 | for (j=4;j<7;j++){
|
|---|
| 316 | B_reduced[i][j-1]=B[i][j];
|
|---|
| 317 | }
|
|---|
| 318 | for (j=8;j<11;j++){
|
|---|
| 319 | B_reduced[i][j-2]=B[i][j];
|
|---|
| 320 | }
|
|---|
| 321 | for (j=12;j<15;j++){
|
|---|
| 322 | B_reduced[i][j-3]=B[i][j];
|
|---|
| 323 | }
|
|---|
| 324 | for (j=16;j<19;j++){
|
|---|
| 325 | B_reduced[i][j-4]=B[i][j];
|
|---|
| 326 | }
|
|---|
| 327 | for (j=20;j<23;j++){
|
|---|
| 328 | B_reduced[i][j-5]=B[i][j];
|
|---|
| 329 | }
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | /*Here, we are computing the strain rate of (0,0,vz)*/
|
|---|
| 333 | for(i=0;i<numgrids;i++){
|
|---|
| 334 | velocity[i][0]=0.0;
|
|---|
| 335 | velocity[i][1]=0.0;
|
|---|
| 336 | velocity[i][2]=this->values[i];
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 340 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numgrids,0,&velocity[0][0],DOFVELOCITY*numgrids,1,0,epsilonvz,0);
|
|---|
| 341 |
|
|---|
| 342 | }
|
|---|
| 343 | /*}}}*/
|
|---|
| 344 | /*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn{{{1*/
|
|---|
| 345 | void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
|
|---|
| 346 |
|
|---|
| 347 | int i;
|
|---|
| 348 | const int numgrids=6;
|
|---|
| 349 | const int NDOF2=2;
|
|---|
| 350 | double B[5][NDOF2*numgrids];
|
|---|
| 351 | double velocity[numgrids][NDOF2];
|
|---|
| 352 |
|
|---|
| 353 | /*Get B matrix: */
|
|---|
| 354 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
|---|
| 355 |
|
|---|
| 356 | /*Here, we are computing the strain rate of (vx,0)*/
|
|---|
| 357 | for(i=0;i<numgrids;i++){
|
|---|
| 358 | velocity[i][0]=this->values[i];
|
|---|
| 359 | velocity[i][1]=0.0;
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|
| 362 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 363 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
|---|
| 364 | &velocity[0][0],NDOF2*numgrids,1,0,
|
|---|
| 365 | epsilonvx,0);
|
|---|
| 366 |
|
|---|
| 367 | }
|
|---|
| 368 | /*}}}*/
|
|---|
| 369 | /*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn{{{1*/
|
|---|
| 370 | void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
|
|---|
| 371 |
|
|---|
| 372 | int i;
|
|---|
| 373 | const int numgrids=6;
|
|---|
| 374 | const int NDOF2=2;
|
|---|
| 375 | double B[5][NDOF2*numgrids];
|
|---|
| 376 | double velocity[numgrids][NDOF2];
|
|---|
| 377 |
|
|---|
| 378 | /*Get B matrix: */
|
|---|
| 379 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
|---|
| 380 |
|
|---|
| 381 | /*Here, we are computing the strain rate of (0,vy)*/
|
|---|
| 382 | for(i=0;i<numgrids;i++){
|
|---|
| 383 | velocity[i][0]=0.0;
|
|---|
| 384 | velocity[i][1]=this->values[i];
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | /*Multiply B by velocity, to get strain rate: */
|
|---|
| 388 | MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0,
|
|---|
| 389 | &velocity[0][0],NDOF2*numgrids,1,0,
|
|---|
| 390 | epsilonvy,0);
|
|---|
| 391 |
|
|---|
| 392 | }
|
|---|
| 393 | /*}}}*/
|
|---|
| 394 | /*FUNCTION PentaVertexInput::ChangeEnum{{{1*/
|
|---|
| 395 | void PentaVertexInput::ChangeEnum(int newenumtype){
|
|---|
| 396 | this->enum_type=newenumtype;
|
|---|
| 397 | }
|
|---|
| 398 | /*}}}*/
|
|---|
| 399 | /*FUNCTION PentaVertexInput::GetParameterAverage{{{1*/
|
|---|
| 400 | void PentaVertexInput::GetParameterAverage(double* pvalue){
|
|---|
| 401 | *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
|
|---|
| 402 | }
|
|---|
| 403 | /*}}}*/
|
|---|
| 404 |
|
|---|
| 405 | /*Intermediary*/
|
|---|
| 406 | /*FUNCTION PentaVertexInput::SquareMin{{{1*/
|
|---|
| 407 | void PentaVertexInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
|
|---|
| 408 |
|
|---|
| 409 | int i;
|
|---|
| 410 | const int numnodes=6;
|
|---|
| 411 | double valuescopy[numnodes];
|
|---|
| 412 | double squaremin;
|
|---|
| 413 |
|
|---|
| 414 | /*First, copy values, to process units if requested: */
|
|---|
| 415 | for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
|
|---|
| 416 |
|
|---|
| 417 | /*Process units if requested: */
|
|---|
| 418 | if(process_units)UnitConversion(&valuescopy[0],numnodes,IuToExtEnum,enum_type,parameters);
|
|---|
| 419 |
|
|---|
| 420 | /*Now, figure out minimum of valuescopy: */
|
|---|
| 421 | squaremin=pow(valuescopy[0],2);
|
|---|
| 422 | for(i=1;i<numnodes;i++){
|
|---|
| 423 | if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
|
|---|
| 424 | }
|
|---|
| 425 | /*Assign output pointers:*/
|
|---|
| 426 | *psquaremin=squaremin;
|
|---|
| 427 | }
|
|---|
| 428 | /*}}}*/
|
|---|
| 429 | /*FUNCTION PentaVertexInput::ConstrainMin{{{1*/
|
|---|
| 430 | void PentaVertexInput::ConstrainMin(double minimum){
|
|---|
| 431 |
|
|---|
| 432 | int i;
|
|---|
| 433 | const int numgrids=6;
|
|---|
| 434 |
|
|---|
| 435 | for(i=0;i<numgrids;i++) if (values[i]<minimum) values[i]=minimum;
|
|---|
| 436 | }
|
|---|
| 437 | /*}}}*/
|
|---|
| 438 | /*FUNCTION PentaVertexInput::InfinityNorm{{{1*/
|
|---|
| 439 | double PentaVertexInput::InfinityNorm(void){
|
|---|
| 440 |
|
|---|
| 441 | /*Output*/
|
|---|
| 442 | const int numgrids=6;
|
|---|
| 443 | double norm=0;
|
|---|
| 444 |
|
|---|
| 445 | for(int i=0;i<numgrids;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
|
|---|
| 446 | return norm;
|
|---|
| 447 | }
|
|---|
| 448 | /*}}}*/
|
|---|
| 449 | /*FUNCTION PentaVertexInput::Max{{{1*/
|
|---|
| 450 | double PentaVertexInput::Max(void){
|
|---|
| 451 |
|
|---|
| 452 | const int numgrids=6;
|
|---|
| 453 | double max=values[0];
|
|---|
| 454 |
|
|---|
| 455 | for(int i=1;i<numgrids;i++){
|
|---|
| 456 | if(values[i]>max) max=values[i];
|
|---|
| 457 | }
|
|---|
| 458 | return max;
|
|---|
| 459 | }
|
|---|
| 460 | /*}}}*/
|
|---|
| 461 | /*FUNCTION PentaVertexInput::MaxAbs{{{1*/
|
|---|
| 462 | double PentaVertexInput::MaxAbs(void){
|
|---|
| 463 |
|
|---|
| 464 | const int numgrids=6;
|
|---|
| 465 | double max=fabs(values[0]);
|
|---|
| 466 |
|
|---|
| 467 | for(int i=1;i<numgrids;i++){
|
|---|
| 468 | if(fabs(values[i])>max) max=fabs(values[i]);
|
|---|
| 469 | }
|
|---|
| 470 | return max;
|
|---|
| 471 | }
|
|---|
| 472 | /*}}}*/
|
|---|
| 473 | /*FUNCTION PentaVertexInput::Min{{{1*/
|
|---|
| 474 | double PentaVertexInput::Min(void){
|
|---|
| 475 |
|
|---|
| 476 | const int numgrids=6;
|
|---|
| 477 | double min=values[0];
|
|---|
| 478 |
|
|---|
| 479 | for(int i=1;i<numgrids;i++){
|
|---|
| 480 | if(values[i]<min) min=values[i];
|
|---|
| 481 | }
|
|---|
| 482 | return min;
|
|---|
| 483 | }
|
|---|
| 484 | /*}}}*/
|
|---|
| 485 | /*FUNCTION PentaVertexInput::MinAbs{{{1*/
|
|---|
| 486 | double PentaVertexInput::MinAbs(void){
|
|---|
| 487 |
|
|---|
| 488 | const int numgrids=6;
|
|---|
| 489 | double min=fabs(values[0]);
|
|---|
| 490 |
|
|---|
| 491 | for(int i=1;i<numgrids;i++){
|
|---|
| 492 | if(fabs(values[i])<min) min=fabs(values[i]);
|
|---|
| 493 | }
|
|---|
| 494 | return min;
|
|---|
| 495 | }
|
|---|
| 496 | /*}}}*/
|
|---|
| 497 | /*FUNCTION PentaVertexInput::Scale{{{1*/
|
|---|
| 498 | void PentaVertexInput::Scale(double scale_factor){
|
|---|
| 499 |
|
|---|
| 500 | int i;
|
|---|
| 501 | const int numgrids=6;
|
|---|
| 502 |
|
|---|
| 503 | for(i=0;i<numgrids;i++)values[i]=values[i]*scale_factor;
|
|---|
| 504 | }
|
|---|
| 505 | /*}}}*/
|
|---|
| 506 | /*FUNCTION PentaVertexInput::AXPY{{{1*/
|
|---|
| 507 | void PentaVertexInput::AXPY(Input* xinput,double scalar){
|
|---|
| 508 |
|
|---|
| 509 | int i;
|
|---|
| 510 | const int numgrids=6;
|
|---|
| 511 | PentaVertexInput* xpentavertexinput=NULL;
|
|---|
| 512 |
|
|---|
| 513 | /*xinput is of the same type, so cast it: */
|
|---|
| 514 | xpentavertexinput=(PentaVertexInput*)xinput;
|
|---|
| 515 |
|
|---|
| 516 | /*Carry out the AXPY operation depending on type:*/
|
|---|
| 517 | switch(xinput->Enum()){
|
|---|
| 518 |
|
|---|
| 519 | case PentaVertexInputEnum:
|
|---|
| 520 | for(i=0;i<numgrids;i++)this->values[i]=this->values[i]+scalar*xpentavertexinput->values[i];
|
|---|
| 521 | return;
|
|---|
| 522 |
|
|---|
| 523 | default:
|
|---|
| 524 | ISSMERROR("not implemented yet");
|
|---|
| 525 | }
|
|---|
| 526 |
|
|---|
| 527 | }
|
|---|
| 528 | /*}}}*/
|
|---|
| 529 | /*FUNCTION PentaVertexInput::Constrain{{{1*/
|
|---|
| 530 | void PentaVertexInput::Constrain(double cm_min, double cm_max){
|
|---|
| 531 |
|
|---|
| 532 | int i;
|
|---|
| 533 | const int numgrids=6;
|
|---|
| 534 |
|
|---|
| 535 | if(!isnan(cm_min)) for(i=0;i<numgrids;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
|
|---|
| 536 | if(!isnan(cm_max)) for(i=0;i<numgrids;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
|
|---|
| 537 |
|
|---|
| 538 | }
|
|---|
| 539 | /*}}}*/
|
|---|
| 540 | /*FUNCTION PentaVertexInput::Extrude{{{1*/
|
|---|
| 541 | void PentaVertexInput::Extrude(void){
|
|---|
| 542 |
|
|---|
| 543 | int i;
|
|---|
| 544 |
|
|---|
| 545 | /*First 3 values copied on 3 last values*/
|
|---|
| 546 | for(i=0;i<3;i++) this->values[3+i]=this->values[i];
|
|---|
| 547 |
|
|---|
| 548 | }
|
|---|
| 549 | /*}}}*/
|
|---|
| 550 | /*FUNCTION PentaVertexInput::VerticallyIntegrate{{{1*/
|
|---|
| 551 | void PentaVertexInput::VerticallyIntegrate(Input* thickness_input){
|
|---|
| 552 |
|
|---|
| 553 | /*Intermediaries*/
|
|---|
| 554 | int i;
|
|---|
| 555 | const int numgrids = 6;
|
|---|
| 556 | int num_thickness_values;
|
|---|
| 557 | double *thickness_values = NULL;
|
|---|
| 558 |
|
|---|
| 559 | /*Check that input provided is a thickness*/
|
|---|
| 560 | if (thickness_input->EnumType()!=ThicknessEnum) ISSMERROR("Input provided is not a Thickness (enum_type is %s)",EnumToString(thickness_input->EnumType()));
|
|---|
| 561 |
|
|---|
| 562 | /*Get Thickness value pointer*/
|
|---|
| 563 | thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
|
|---|
| 564 |
|
|---|
| 565 | /*vertically integrate depending on type:*/
|
|---|
| 566 | switch(thickness_input->Enum()){
|
|---|
| 567 |
|
|---|
| 568 | case PentaVertexInputEnum:
|
|---|
| 569 | for(i=0;i<3;i++){
|
|---|
| 570 | this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
|
|---|
| 571 | this->values[i+3]=this->values[i];
|
|---|
| 572 | }
|
|---|
| 573 | return;
|
|---|
| 574 |
|
|---|
| 575 | default:
|
|---|
| 576 | ISSMERROR("not implemented yet");
|
|---|
| 577 | }
|
|---|
| 578 | }
|
|---|
| 579 | /*}}}*/
|
|---|
| 580 | /*FUNCTION PentaVertexInput::PointwiseDivide{{{1*/
|
|---|
| 581 | Input* PentaVertexInput::PointwiseDivide(Input* inputB){
|
|---|
| 582 |
|
|---|
| 583 | /*Ouput*/
|
|---|
| 584 | PentaVertexInput* outinput=NULL;
|
|---|
| 585 |
|
|---|
| 586 | /*Intermediaries*/
|
|---|
| 587 | int i;
|
|---|
| 588 | PentaVertexInput *xinputB = NULL;
|
|---|
| 589 | int B_numvalues;
|
|---|
| 590 | double *B_values = NULL;
|
|---|
| 591 | const int numgrids = 6;
|
|---|
| 592 | double AdotBvalues[numgrids];
|
|---|
| 593 |
|
|---|
| 594 | /*Check that inputB is of the same type*/
|
|---|
| 595 | if (inputB->Enum()!=PentaVertexInputEnum) ISSMERROR("Operation not permitted because inputB is of type %s",EnumToString(inputB->Enum()));
|
|---|
| 596 | xinputB=(PentaVertexInput*)inputB;
|
|---|
| 597 |
|
|---|
| 598 | /*Create point wise sum*/
|
|---|
| 599 | for(i=0;i<numgrids;i++){
|
|---|
| 600 | ISSMASSERT(xinputB->values[i]!=0);
|
|---|
| 601 | AdotBvalues[i]=this->values[i]/xinputB->values[i];
|
|---|
| 602 | }
|
|---|
| 603 |
|
|---|
| 604 | /*Create new Penta vertex input (copy of current input)*/
|
|---|
| 605 | outinput=new PentaVertexInput(this->enum_type,&AdotBvalues[0]);
|
|---|
| 606 |
|
|---|
| 607 | /*Return output pointer*/
|
|---|
| 608 | return outinput;
|
|---|
| 609 |
|
|---|
| 610 | }
|
|---|
| 611 | /*}}}*/
|
|---|
| 612 | /*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/
|
|---|
| 613 | void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
|
|---|
| 614 |
|
|---|
| 615 | const int numvertices=6;
|
|---|
| 616 | VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
|
|---|
| 617 |
|
|---|
| 618 | } /*}}}*/
|
|---|
| 619 | /*FUNCTION PentaVertexInput::GetValuesPtr{{{1*/
|
|---|
| 620 | void PentaVertexInput::GetValuesPtr(double** pvalues,int* pnum_values){
|
|---|
| 621 |
|
|---|
| 622 | *pvalues=this->values;
|
|---|
| 623 | *pnum_values=6;
|
|---|
| 624 |
|
|---|
| 625 | }
|
|---|
| 626 | /*}}}*/
|
|---|