[11291] | 1 | /*!\file PentaP1Input.c
|
---|
| 2 | * \brief: implementation of the PentaP1Input object
|
---|
[3683] | 3 | */
|
---|
| 4 |
|
---|
| 5 | #ifdef HAVE_CONFIG_H
|
---|
[9320] | 6 | #include <config.h>
|
---|
[3683] | 7 | #else
|
---|
| 8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 9 | #endif
|
---|
| 10 |
|
---|
[15012] | 11 | #include "../classes.h"
|
---|
| 12 | #include "../../shared/shared.h"
|
---|
[3683] | 13 |
|
---|
[11291] | 14 | /*PentaP1Input constructors and destructor*/
|
---|
[12365] | 15 | /*FUNCTION PentaP1Input::PentaP1Input(){{{*/
|
---|
[11291] | 16 | PentaP1Input::PentaP1Input(){
|
---|
[3683] | 17 | return;
|
---|
| 18 | }
|
---|
| 19 | /*}}}*/
|
---|
[12530] | 20 | /*FUNCTION PentaP1Input::PentaP1Input(int in_enum_type,IssmDouble* values){{{*/
|
---|
| 21 | PentaP1Input::PentaP1Input(int in_enum_type,IssmDouble* in_values)
|
---|
[4882] | 22 | :PentaRef(1)
|
---|
| 23 | {
|
---|
[3683] | 24 |
|
---|
[4882] | 25 | /*Set PentaRef*/
|
---|
| 26 | this->SetElementType(P1Enum,0);
|
---|
| 27 | this->element_type=P1Enum;
|
---|
| 28 |
|
---|
[3683] | 29 | enum_type=in_enum_type;
|
---|
| 30 | values[0]=in_values[0];
|
---|
| 31 | values[1]=in_values[1];
|
---|
| 32 | values[2]=in_values[2];
|
---|
| 33 | values[3]=in_values[3];
|
---|
| 34 | values[4]=in_values[4];
|
---|
| 35 | values[5]=in_values[5];
|
---|
| 36 | }
|
---|
| 37 | /*}}}*/
|
---|
[12365] | 38 | /*FUNCTION PentaP1Input::~PentaP1Input(){{{*/
|
---|
[11291] | 39 | PentaP1Input::~PentaP1Input(){
|
---|
[3683] | 40 | return;
|
---|
| 41 | }
|
---|
| 42 | /*}}}*/
|
---|
| 43 |
|
---|
[4248] | 44 | /*Object virtual functions definitions:*/
|
---|
[12365] | 45 | /*FUNCTION PentaP1Input::Echo {{{*/
|
---|
[11291] | 46 | void PentaP1Input::Echo(void){
|
---|
[4248] | 47 | this->DeepEcho();
|
---|
[3683] | 48 | }
|
---|
| 49 | /*}}}*/
|
---|
[12365] | 50 | /*FUNCTION PentaP1Input::DeepEcho{{{*/
|
---|
[11291] | 51 | void PentaP1Input::DeepEcho(void){
|
---|
[3683] | 52 |
|
---|
[12511] | 53 | _printLine_("PentaP1Input:");
|
---|
| 54 | _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
|
---|
| 55 | _printLine_(" values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << " " << this->values[3] << " " << this->values[4] << " " << this->values[5] << "]");
|
---|
[3683] | 56 | }
|
---|
| 57 | /*}}}*/
|
---|
[12365] | 58 | /*FUNCTION PentaP1Input::Id{{{*/
|
---|
[11291] | 59 | int PentaP1Input::Id(void){ return -1; }
|
---|
[3683] | 60 | /*}}}*/
|
---|
[12365] | 61 | /*FUNCTION PentaP1Input::ObjectEnum{{{*/
|
---|
[11291] | 62 | int PentaP1Input::ObjectEnum(void){
|
---|
[4248] | 63 |
|
---|
[11291] | 64 | return PentaP1InputEnum;
|
---|
[4248] | 65 |
|
---|
| 66 | }
|
---|
| 67 | /*}}}*/
|
---|
[13622] | 68 |
|
---|
[11291] | 69 | /*PentaP1Input management*/
|
---|
[12365] | 70 | /*FUNCTION PentaP1Input::copy{{{*/
|
---|
[11291] | 71 | Object* PentaP1Input::copy() {
|
---|
[13622] | 72 |
|
---|
[11291] | 73 | return new PentaP1Input(this->enum_type,this->values);
|
---|
[4248] | 74 |
|
---|
| 75 | }
|
---|
| 76 | /*}}}*/
|
---|
[12365] | 77 | /*FUNCTION PentaP1Input::InstanceEnum{{{*/
|
---|
[11291] | 78 | int PentaP1Input::InstanceEnum(void){
|
---|
[4248] | 79 |
|
---|
| 80 | return this->enum_type;
|
---|
| 81 |
|
---|
| 82 | }
|
---|
| 83 | /*}}}*/
|
---|
[12365] | 84 | /*FUNCTION PentaP1Input::SpawnTriaInput{{{*/
|
---|
[11291] | 85 | Input* PentaP1Input::SpawnTriaInput(int* indices){
|
---|
[3683] | 86 |
|
---|
[3847] | 87 | /*output*/
|
---|
[11291] | 88 | TriaP1Input* outinput=NULL;
|
---|
[12530] | 89 | IssmDouble newvalues[3];
|
---|
[3847] | 90 |
|
---|
| 91 | /*Loop over the new indices*/
|
---|
| 92 | for(int i=0;i<3;i++){
|
---|
| 93 |
|
---|
| 94 | /*Check index value*/
|
---|
[6412] | 95 | _assert_(indices[i]>=0 && indices[i]<6);
|
---|
[3847] | 96 |
|
---|
| 97 | /*Assign value to new input*/
|
---|
| 98 | newvalues[i]=this->values[indices[i]];
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /*Create new Tria input*/
|
---|
[11291] | 102 | outinput=new TriaP1Input(this->enum_type,&newvalues[0]);
|
---|
[3847] | 103 |
|
---|
| 104 | /*Assign output*/
|
---|
| 105 | return outinput;
|
---|
| 106 |
|
---|
| 107 | }
|
---|
| 108 | /*}}}*/
|
---|
[12365] | 109 | /*FUNCTION PentaP1Input::SpawnResult{{{*/
|
---|
[12530] | 110 | ElementResult* PentaP1Input::SpawnResult(int step, IssmDouble time){
|
---|
[3847] | 111 |
|
---|
[11292] | 112 | return new PentaP1ElementResult(this->enum_type,this->values,step,time);
|
---|
[4037] | 113 |
|
---|
| 114 | }
|
---|
| 115 | /*}}}*/
|
---|
| 116 |
|
---|
[3683] | 117 | /*Object functions*/
|
---|
[12530] | 118 | /*FUNCTION PentaP1Input::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
|
---|
| 119 | void PentaP1Input::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){
|
---|
[5629] | 120 |
|
---|
| 121 | /*Call PentaRef function*/
|
---|
[10135] | 122 | PentaRef::GetInputValue(pvalue,&values[0],gauss);
|
---|
[5629] | 123 |
|
---|
| 124 | }
|
---|
| 125 | /*}}}*/
|
---|
[12550] | 126 | /*FUNCTION PentaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
|
---|
| 127 | void PentaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussPenta* gauss){
|
---|
[5629] | 128 |
|
---|
| 129 | /*Call PentaRef function*/
|
---|
[10135] | 130 | PentaRef::GetInputDerivativeValue(p,&values[0],xyz_list,gauss);
|
---|
[5629] | 131 | }
|
---|
| 132 | /*}}}*/
|
---|
[12365] | 133 | /*FUNCTION PentaP1Input::GetVxStrainRate3d{{{*/
|
---|
[12550] | 134 | void PentaP1Input::GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
|
---|
[5647] | 135 | int i,j;
|
---|
| 136 |
|
---|
[8303] | 137 | const int numnodes=6;
|
---|
[5647] | 138 | const int DOFVELOCITY=3;
|
---|
[12530] | 139 | IssmDouble B[8][27];
|
---|
| 140 | IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
|
---|
| 141 | IssmDouble velocity[numnodes][DOFVELOCITY];
|
---|
[5647] | 142 |
|
---|
| 143 | /*Get B matrix: */
|
---|
| 144 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
| 145 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
| 146 | for (i=0;i<6;i++){
|
---|
| 147 | for (j=0;j<3;j++){
|
---|
| 148 | B_reduced[i][j]=B[i][j];
|
---|
| 149 | }
|
---|
| 150 | for (j=4;j<7;j++){
|
---|
| 151 | B_reduced[i][j-1]=B[i][j];
|
---|
| 152 | }
|
---|
| 153 | for (j=8;j<11;j++){
|
---|
| 154 | B_reduced[i][j-2]=B[i][j];
|
---|
| 155 | }
|
---|
| 156 | for (j=12;j<15;j++){
|
---|
| 157 | B_reduced[i][j-3]=B[i][j];
|
---|
| 158 | }
|
---|
| 159 | for (j=16;j<19;j++){
|
---|
| 160 | B_reduced[i][j-4]=B[i][j];
|
---|
| 161 | }
|
---|
| 162 | for (j=20;j<23;j++){
|
---|
| 163 | B_reduced[i][j-5]=B[i][j];
|
---|
| 164 | }
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | /*Here, we are computing the strain rate of (vx,0,0)*/
|
---|
[8303] | 168 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 169 | velocity[i][0]=this->values[i];
|
---|
| 170 | velocity[i][1]=0.0;
|
---|
| 171 | velocity[i][2]=0.0;
|
---|
| 172 | }
|
---|
| 173 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 174 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvx,0);
|
---|
[5647] | 175 |
|
---|
| 176 | }
|
---|
| 177 | /*}}}*/
|
---|
[12365] | 178 | /*FUNCTION PentaP1Input::GetVyStrainRate3d{{{*/
|
---|
[12550] | 179 | void PentaP1Input::GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
|
---|
[5647] | 180 | int i,j;
|
---|
| 181 |
|
---|
[8303] | 182 | const int numnodes=6;
|
---|
[5647] | 183 | const int DOFVELOCITY=3;
|
---|
[12530] | 184 | IssmDouble B[8][27];
|
---|
| 185 | IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
|
---|
| 186 | IssmDouble velocity[numnodes][DOFVELOCITY];
|
---|
[5647] | 187 |
|
---|
| 188 | /*Get B matrix: */
|
---|
| 189 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
| 190 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
| 191 | for (i=0;i<6;i++){
|
---|
| 192 | for (j=0;j<3;j++){
|
---|
| 193 | B_reduced[i][j]=B[i][j];
|
---|
| 194 | }
|
---|
| 195 | for (j=4;j<7;j++){
|
---|
| 196 | B_reduced[i][j-1]=B[i][j];
|
---|
| 197 | }
|
---|
| 198 | for (j=8;j<11;j++){
|
---|
| 199 | B_reduced[i][j-2]=B[i][j];
|
---|
| 200 | }
|
---|
| 201 | for (j=12;j<15;j++){
|
---|
| 202 | B_reduced[i][j-3]=B[i][j];
|
---|
| 203 | }
|
---|
| 204 | for (j=16;j<19;j++){
|
---|
| 205 | B_reduced[i][j-4]=B[i][j];
|
---|
| 206 | }
|
---|
| 207 | for (j=20;j<23;j++){
|
---|
| 208 | B_reduced[i][j-5]=B[i][j];
|
---|
| 209 | }
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | /*Here, we are computing the strain rate of (0,vy,0)*/
|
---|
[8303] | 213 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 214 | velocity[i][0]=0.0;
|
---|
| 215 | velocity[i][1]=this->values[i];
|
---|
| 216 | velocity[i][2]=0.0;
|
---|
| 217 | }
|
---|
| 218 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 219 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvy,0);
|
---|
[5647] | 220 |
|
---|
| 221 | }
|
---|
| 222 | /*}}}*/
|
---|
[12365] | 223 | /*FUNCTION PentaP1Input::GetVzStrainRate3d{{{*/
|
---|
[12550] | 224 | void PentaP1Input::GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){
|
---|
[5647] | 225 | int i,j;
|
---|
| 226 |
|
---|
[8303] | 227 | const int numnodes=6;
|
---|
[5647] | 228 | const int DOFVELOCITY=3;
|
---|
[12530] | 229 | IssmDouble B[8][27];
|
---|
| 230 | IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
|
---|
| 231 | IssmDouble velocity[numnodes][DOFVELOCITY];
|
---|
[5647] | 232 |
|
---|
| 233 | /*Get B matrix: */
|
---|
| 234 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
| 235 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
| 236 | for (i=0;i<6;i++){
|
---|
| 237 | for (j=0;j<3;j++){
|
---|
| 238 | B_reduced[i][j]=B[i][j];
|
---|
| 239 | }
|
---|
| 240 | for (j=4;j<7;j++){
|
---|
| 241 | B_reduced[i][j-1]=B[i][j];
|
---|
| 242 | }
|
---|
| 243 | for (j=8;j<11;j++){
|
---|
| 244 | B_reduced[i][j-2]=B[i][j];
|
---|
| 245 | }
|
---|
| 246 | for (j=12;j<15;j++){
|
---|
| 247 | B_reduced[i][j-3]=B[i][j];
|
---|
| 248 | }
|
---|
| 249 | for (j=16;j<19;j++){
|
---|
| 250 | B_reduced[i][j-4]=B[i][j];
|
---|
| 251 | }
|
---|
| 252 | for (j=20;j<23;j++){
|
---|
| 253 | B_reduced[i][j-5]=B[i][j];
|
---|
| 254 | }
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | /*Here, we are computing the strain rate of (0,0,vz)*/
|
---|
[8303] | 258 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 259 | velocity[i][0]=0.0;
|
---|
| 260 | velocity[i][1]=0.0;
|
---|
| 261 | velocity[i][2]=this->values[i];
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 265 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvz,0);
|
---|
[5647] | 266 |
|
---|
| 267 | }
|
---|
| 268 | /*}}}*/
|
---|
[12365] | 269 | /*FUNCTION PentaP1Input::GetVxStrainRate3dPattyn{{{*/
|
---|
[12550] | 270 | void PentaP1Input::GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
|
---|
[5647] | 271 |
|
---|
| 272 | int i;
|
---|
[8303] | 273 | const int numnodes=6;
|
---|
[12530] | 274 | IssmDouble B[5][NDOF2*numnodes];
|
---|
| 275 | IssmDouble velocity[numnodes][NDOF2];
|
---|
[5647] | 276 |
|
---|
| 277 | /*Get B matrix: */
|
---|
| 278 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
---|
| 279 |
|
---|
| 280 | /*Here, we are computing the strain rate of (vx,0)*/
|
---|
[8303] | 281 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 282 | velocity[i][0]=this->values[i];
|
---|
| 283 | velocity[i][1]=0.0;
|
---|
| 284 | }
|
---|
| 285 |
|
---|
| 286 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 287 | MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
|
---|
| 288 | &velocity[0][0],NDOF2*numnodes,1,0,
|
---|
[5647] | 289 | epsilonvx,0);
|
---|
| 290 |
|
---|
| 291 | }
|
---|
| 292 | /*}}}*/
|
---|
[12365] | 293 | /*FUNCTION PentaP1Input::GetVyStrainRate3dPattyn{{{*/
|
---|
[12550] | 294 | void PentaP1Input::GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
|
---|
[5647] | 295 |
|
---|
| 296 | int i;
|
---|
[8303] | 297 | const int numnodes=6;
|
---|
[12530] | 298 | IssmDouble B[5][NDOF2*numnodes];
|
---|
| 299 | IssmDouble velocity[numnodes][NDOF2];
|
---|
[5647] | 300 |
|
---|
| 301 | /*Get B matrix: */
|
---|
| 302 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
---|
| 303 |
|
---|
| 304 | /*Here, we are computing the strain rate of (0,vy)*/
|
---|
[8303] | 305 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 306 | velocity[i][0]=0.0;
|
---|
| 307 | velocity[i][1]=this->values[i];
|
---|
| 308 | }
|
---|
| 309 |
|
---|
| 310 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 311 | MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
|
---|
| 312 | &velocity[0][0],NDOF2*numnodes,1,0,
|
---|
[5647] | 313 | epsilonvy,0);
|
---|
| 314 |
|
---|
| 315 | }
|
---|
| 316 | /*}}}*/
|
---|
[12365] | 317 | /*FUNCTION PentaP1Input::ChangeEnum{{{*/
|
---|
[11291] | 318 | void PentaP1Input::ChangeEnum(int newenumtype){
|
---|
[3732] | 319 | this->enum_type=newenumtype;
|
---|
| 320 | }
|
---|
| 321 | /*}}}*/
|
---|
[12365] | 322 | /*FUNCTION PentaP1Input::GetInputAverage{{{*/
|
---|
[12530] | 323 | void PentaP1Input::GetInputAverage(IssmDouble* pvalue){
|
---|
[3830] | 324 | *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
|
---|
| 325 | }
|
---|
| 326 | /*}}}*/
|
---|
[3840] | 327 |
|
---|
| 328 | /*Intermediary*/
|
---|
[12365] | 329 | /*FUNCTION PentaP1Input::SquareMin{{{*/
|
---|
[12530] | 330 | void PentaP1Input::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
|
---|
[4042] | 331 |
|
---|
| 332 | int i;
|
---|
| 333 | const int numnodes=6;
|
---|
[12530] | 334 | IssmDouble valuescopy[numnodes];
|
---|
| 335 | IssmDouble squaremin;
|
---|
[4042] | 336 |
|
---|
| 337 | /*First, copy values, to process units if requested: */
|
---|
| 338 | for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
|
---|
| 339 |
|
---|
| 340 | /*Process units if requested: */
|
---|
[8967] | 341 | if(process_units)UnitConversion(&valuescopy[0],numnodes,IuToExtEnum,enum_type);
|
---|
[4042] | 342 |
|
---|
| 343 | /*Now, figure out minimum of valuescopy: */
|
---|
| 344 | squaremin=pow(valuescopy[0],2);
|
---|
| 345 | for(i=1;i<numnodes;i++){
|
---|
| 346 | if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
|
---|
| 347 | }
|
---|
| 348 | /*Assign output pointers:*/
|
---|
| 349 | *psquaremin=squaremin;
|
---|
| 350 | }
|
---|
| 351 | /*}}}*/
|
---|
[12365] | 352 | /*FUNCTION PentaP1Input::ConstrainMin{{{*/
|
---|
[12530] | 353 | void PentaP1Input::ConstrainMin(IssmDouble minimum){
|
---|
[13622] | 354 |
|
---|
[5017] | 355 | int i;
|
---|
[8303] | 356 | const int numnodes=6;
|
---|
[5017] | 357 |
|
---|
[8303] | 358 | for(i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
|
---|
[5017] | 359 | }
|
---|
| 360 | /*}}}*/
|
---|
[12365] | 361 | /*FUNCTION PentaP1Input::InfinityNorm{{{*/
|
---|
[12530] | 362 | IssmDouble PentaP1Input::InfinityNorm(void){
|
---|
[5513] | 363 |
|
---|
| 364 | /*Output*/
|
---|
[8303] | 365 | const int numnodes=6;
|
---|
[12530] | 366 | IssmDouble norm=0;
|
---|
[5513] | 367 |
|
---|
[8303] | 368 | for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
|
---|
[5513] | 369 | return norm;
|
---|
| 370 | }
|
---|
| 371 | /*}}}*/
|
---|
[12365] | 372 | /*FUNCTION PentaP1Input::Max{{{*/
|
---|
[12530] | 373 | IssmDouble PentaP1Input::Max(void){
|
---|
[5659] | 374 |
|
---|
[8303] | 375 | const int numnodes=6;
|
---|
[12530] | 376 | IssmDouble max=values[0];
|
---|
[5659] | 377 |
|
---|
[8303] | 378 | for(int i=1;i<numnodes;i++){
|
---|
[5659] | 379 | if(values[i]>max) max=values[i];
|
---|
| 380 | }
|
---|
| 381 | return max;
|
---|
| 382 | }
|
---|
| 383 | /*}}}*/
|
---|
[12365] | 384 | /*FUNCTION PentaP1Input::MaxAbs{{{*/
|
---|
[12530] | 385 | IssmDouble PentaP1Input::MaxAbs(void){
|
---|
[5659] | 386 |
|
---|
[8303] | 387 | const int numnodes=6;
|
---|
[12530] | 388 | IssmDouble max=fabs(values[0]);
|
---|
[5659] | 389 |
|
---|
[8303] | 390 | for(int i=1;i<numnodes;i++){
|
---|
[5659] | 391 | if(fabs(values[i])>max) max=fabs(values[i]);
|
---|
| 392 | }
|
---|
| 393 | return max;
|
---|
| 394 | }
|
---|
| 395 | /*}}}*/
|
---|
[12365] | 396 | /*FUNCTION PentaP1Input::Min{{{*/
|
---|
[12530] | 397 | IssmDouble PentaP1Input::Min(void){
|
---|
[5659] | 398 |
|
---|
[8303] | 399 | const int numnodes=6;
|
---|
[12530] | 400 | IssmDouble min=values[0];
|
---|
[5659] | 401 |
|
---|
[8303] | 402 | for(int i=1;i<numnodes;i++){
|
---|
[5659] | 403 | if(values[i]<min) min=values[i];
|
---|
| 404 | }
|
---|
| 405 | return min;
|
---|
| 406 | }
|
---|
| 407 | /*}}}*/
|
---|
[12365] | 408 | /*FUNCTION PentaP1Input::MinAbs{{{*/
|
---|
[12530] | 409 | IssmDouble PentaP1Input::MinAbs(void){
|
---|
[5659] | 410 |
|
---|
[8303] | 411 | const int numnodes=6;
|
---|
[12530] | 412 | IssmDouble min=fabs(values[0]);
|
---|
[5659] | 413 |
|
---|
[8303] | 414 | for(int i=1;i<numnodes;i++){
|
---|
[5659] | 415 | if(fabs(values[i])<min) min=fabs(values[i]);
|
---|
| 416 | }
|
---|
| 417 | return min;
|
---|
| 418 | }
|
---|
| 419 | /*}}}*/
|
---|
[12365] | 420 | /*FUNCTION PentaP1Input::Scale{{{*/
|
---|
[12530] | 421 | void PentaP1Input::Scale(IssmDouble scale_factor){
|
---|
[13622] | 422 |
|
---|
[4047] | 423 | int i;
|
---|
[8303] | 424 | const int numnodes=6;
|
---|
[4047] | 425 |
|
---|
[8303] | 426 | for(i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
|
---|
[4047] | 427 | }
|
---|
| 428 | /*}}}*/
|
---|
[12365] | 429 | /*FUNCTION PentaP1Input::AXPY{{{*/
|
---|
[12530] | 430 | void PentaP1Input::AXPY(Input* xinput,IssmDouble scalar){
|
---|
[4048] | 431 |
|
---|
| 432 | int i;
|
---|
[8303] | 433 | const int numnodes=6;
|
---|
[4048] | 434 |
|
---|
| 435 | /*xinput is of the same type, so cast it: */
|
---|
| 436 |
|
---|
[4174] | 437 | /*Carry out the AXPY operation depending on type:*/
|
---|
[9883] | 438 | switch(xinput->ObjectEnum()){
|
---|
[4048] | 439 |
|
---|
[11291] | 440 | case PentaP1InputEnum:{
|
---|
| 441 | PentaP1Input* cast_input=(PentaP1Input*)xinput;
|
---|
[8303] | 442 | for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
|
---|
[4174] | 443 | return;
|
---|
[6200] | 444 | case ControlInputEnum:{
|
---|
| 445 | ControlInput* cont_input=(ControlInput*)xinput;
|
---|
[13056] | 446 | if(cont_input->values->ObjectEnum()!=PentaP1InputEnum) _error_("not supported yet");
|
---|
[11291] | 447 | PentaP1Input* cast_input=(PentaP1Input*)cont_input->values;
|
---|
[8303] | 448 | for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
|
---|
[6200] | 449 | return;
|
---|
[4174] | 450 | default:
|
---|
[13056] | 451 | _error_("not implemented yet");
|
---|
[4174] | 452 | }
|
---|
| 453 |
|
---|
[4048] | 454 | }
|
---|
| 455 | /*}}}*/
|
---|
[12365] | 456 | /*FUNCTION PentaP1Input::Constrain{{{*/
|
---|
[12530] | 457 | void PentaP1Input::Constrain(IssmDouble cm_min, IssmDouble cm_max){
|
---|
[4048] | 458 |
|
---|
| 459 | int i;
|
---|
[8303] | 460 | const int numnodes=6;
|
---|
[13622] | 461 |
|
---|
[12529] | 462 | if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
|
---|
| 463 | if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
|
---|
[4048] | 464 |
|
---|
| 465 | }
|
---|
| 466 | /*}}}*/
|
---|
[12365] | 467 | /*FUNCTION PentaP1Input::Extrude{{{*/
|
---|
[11291] | 468 | void PentaP1Input::Extrude(void){
|
---|
[4274] | 469 |
|
---|
| 470 | int i;
|
---|
| 471 |
|
---|
| 472 | /*First 3 values copied on 3 last values*/
|
---|
| 473 | for(i=0;i<3;i++) this->values[3+i]=this->values[i];
|
---|
| 474 | }
|
---|
| 475 | /*}}}*/
|
---|
[12365] | 476 | /*FUNCTION PentaP1Input::VerticallyIntegrate{{{*/
|
---|
[11291] | 477 | void PentaP1Input::VerticallyIntegrate(Input* thickness_input){
|
---|
[4471] | 478 |
|
---|
| 479 | /*Intermediaries*/
|
---|
| 480 | int i;
|
---|
[8303] | 481 | const int numnodes = 6;
|
---|
[4471] | 482 | int num_thickness_values;
|
---|
[12530] | 483 | IssmDouble *thickness_values = NULL;
|
---|
[4471] | 484 |
|
---|
| 485 | /*Check that input provided is a thickness*/
|
---|
[13056] | 486 | if (thickness_input->InstanceEnum()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is " << EnumToStringx(thickness_input->InstanceEnum()) << ")");
|
---|
[4471] | 487 |
|
---|
| 488 | /*Get Thickness value pointer*/
|
---|
| 489 | thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
|
---|
| 490 |
|
---|
| 491 | /*vertically integrate depending on type:*/
|
---|
[9883] | 492 | switch(thickness_input->ObjectEnum()){
|
---|
[4471] | 493 |
|
---|
[11291] | 494 | case PentaP1InputEnum:
|
---|
[4471] | 495 | for(i=0;i<3;i++){
|
---|
| 496 | this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
|
---|
| 497 | this->values[i+3]=this->values[i];
|
---|
| 498 | }
|
---|
| 499 | return;
|
---|
| 500 |
|
---|
| 501 | default:
|
---|
[13056] | 502 | _error_("not implemented yet");
|
---|
[4471] | 503 | }
|
---|
| 504 | }
|
---|
| 505 | /*}}}*/
|
---|
[12365] | 506 | /*FUNCTION PentaP1Input::PointwiseDivide{{{*/
|
---|
[11291] | 507 | Input* PentaP1Input::PointwiseDivide(Input* inputB){
|
---|
[4471] | 508 |
|
---|
| 509 | /*Ouput*/
|
---|
[11291] | 510 | PentaP1Input* outinput=NULL;
|
---|
[4471] | 511 |
|
---|
| 512 | /*Intermediaries*/
|
---|
[13761] | 513 | PentaP1Input *xinputB = NULL;
|
---|
| 514 | const int numnodes = 6;
|
---|
| 515 | IssmDouble AdotBvalues[numnodes];
|
---|
[4471] | 516 |
|
---|
| 517 | /*Check that inputB is of the same type*/
|
---|
[13056] | 518 | if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
|
---|
[11291] | 519 | xinputB=(PentaP1Input*)inputB;
|
---|
[4471] | 520 |
|
---|
| 521 | /*Create point wise sum*/
|
---|
[13761] | 522 | for(int i=0;i<numnodes;i++){
|
---|
[6412] | 523 | _assert_(xinputB->values[i]!=0);
|
---|
[4471] | 524 | AdotBvalues[i]=this->values[i]/xinputB->values[i];
|
---|
| 525 | }
|
---|
| 526 |
|
---|
[4899] | 527 | /*Create new Penta vertex input (copy of current input)*/
|
---|
[11291] | 528 | outinput=new PentaP1Input(this->enum_type,&AdotBvalues[0]);
|
---|
[4471] | 529 |
|
---|
| 530 | /*Return output pointer*/
|
---|
| 531 | return outinput;
|
---|
| 532 |
|
---|
| 533 | }
|
---|
| 534 | /*}}}*/
|
---|
[12365] | 535 | /*FUNCTION PentaP1Input::PointwiseMin{{{*/
|
---|
[11291] | 536 | Input* PentaP1Input::PointwiseMin(Input* inputB){
|
---|
[8129] | 537 |
|
---|
| 538 | /*Ouput*/
|
---|
[11291] | 539 | PentaP1Input* outinput=NULL;
|
---|
[8129] | 540 |
|
---|
| 541 | /*Intermediaries*/
|
---|
| 542 | int i;
|
---|
[11291] | 543 | PentaP1Input *xinputB = NULL;
|
---|
[8303] | 544 | const int numnodes = 6;
|
---|
[12530] | 545 | IssmDouble minvalues[numnodes];
|
---|
[8129] | 546 |
|
---|
| 547 | /*Check that inputB is of the same type*/
|
---|
[13056] | 548 | if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
|
---|
[11291] | 549 | xinputB=(PentaP1Input*)inputB;
|
---|
[8129] | 550 |
|
---|
| 551 | /*Create point wise min*/
|
---|
[8303] | 552 | for(i=0;i<numnodes;i++){
|
---|
[8129] | 553 | if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
|
---|
| 554 | else minvalues[i]=this->values[i];
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | /*Create new Penta vertex input (copy of current input)*/
|
---|
[11291] | 558 | outinput=new PentaP1Input(this->enum_type,&minvalues[0]);
|
---|
[8129] | 559 |
|
---|
| 560 | /*Return output pointer*/
|
---|
| 561 | return outinput;
|
---|
| 562 |
|
---|
| 563 | }
|
---|
| 564 | /*}}}*/
|
---|
[12365] | 565 | /*FUNCTION PentaP1Input::PointwiseMax{{{*/
|
---|
[11291] | 566 | Input* PentaP1Input::PointwiseMax(Input* inputB){
|
---|
[8129] | 567 |
|
---|
| 568 | /*Ouput*/
|
---|
[11291] | 569 | PentaP1Input* outinput=NULL;
|
---|
[8129] | 570 |
|
---|
| 571 | /*Intermediaries*/
|
---|
| 572 | int i;
|
---|
[11291] | 573 | PentaP1Input *xinputB = NULL;
|
---|
[8303] | 574 | const int numnodes = 6;
|
---|
[12530] | 575 | IssmDouble maxvalues[numnodes];
|
---|
[8129] | 576 |
|
---|
| 577 | /*Check that inputB is of the same type*/
|
---|
[13056] | 578 | if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
|
---|
[11291] | 579 | xinputB=(PentaP1Input*)inputB;
|
---|
[8129] | 580 |
|
---|
| 581 | /*Create point wise max*/
|
---|
[8303] | 582 | for(i=0;i<numnodes;i++){
|
---|
[8129] | 583 | if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
|
---|
| 584 | else maxvalues[i]=this->values[i];
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 | /*Create new Penta vertex input (copy of current input)*/
|
---|
[11291] | 588 | outinput=new PentaP1Input(this->enum_type,&maxvalues[0]);
|
---|
[8129] | 589 |
|
---|
| 590 | /*Return output pointer*/
|
---|
| 591 | return outinput;
|
---|
| 592 |
|
---|
| 593 | }
|
---|
| 594 | /*}}}*/
|
---|
[12365] | 595 | /*FUNCTION PentaP1Input::GetVectorFromInputs{{{*/
|
---|
[13216] | 596 | void PentaP1Input::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){
|
---|
[4048] | 597 |
|
---|
| 598 | const int numvertices=6;
|
---|
[11695] | 599 | vector->SetValues(numvertices,doflist,this->values,INS_VAL);
|
---|
[4048] | 600 |
|
---|
[4502] | 601 | } /*}}}*/
|
---|
[12365] | 602 | /*FUNCTION PentaP1Input::GetValuesPtr{{{*/
|
---|
[12530] | 603 | void PentaP1Input::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
|
---|
[4055] | 604 |
|
---|
| 605 | *pvalues=this->values;
|
---|
| 606 | *pnum_values=6;
|
---|
| 607 |
|
---|
| 608 | }
|
---|
| 609 | /*}}}*/
|
---|
[12365] | 610 | /*FUNCTION PentaP1Input::Configure{{{*/
|
---|
[11291] | 611 | void PentaP1Input::Configure(Parameters* parameters){
|
---|
[8363] | 612 | /*do nothing: */
|
---|
| 613 | }
|
---|
| 614 | /*}}}*/
|
---|