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