[3683] | 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"
|
---|
[4236] | 16 | #include "../../Container/Container.h"
|
---|
[3775] | 17 | #include "../../include/include.h"
|
---|
[3683] | 18 |
|
---|
[4248] | 19 | /*PentaVertexInput constructors and destructor*/
|
---|
[3683] | 20 | /*FUNCTION PentaVertexInput::PentaVertexInput(){{{1*/
|
---|
| 21 | PentaVertexInput::PentaVertexInput(){
|
---|
| 22 | return;
|
---|
| 23 | }
|
---|
| 24 | /*}}}*/
|
---|
[3847] | 25 | /*FUNCTION PentaVertexInput::PentaVertexInput(int in_enum_type,double* values){{{1*/
|
---|
[4882] | 26 | PentaVertexInput::PentaVertexInput(int in_enum_type,double* in_values)
|
---|
| 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 | /*}}}*/
|
---|
| 43 | /*FUNCTION PentaVertexInput::~PentaVertexInput(){{{1*/
|
---|
| 44 | PentaVertexInput::~PentaVertexInput(){
|
---|
| 45 | return;
|
---|
| 46 | }
|
---|
| 47 | /*}}}*/
|
---|
| 48 |
|
---|
[4248] | 49 | /*Object virtual functions definitions:*/
|
---|
| 50 | /*FUNCTION PentaVertexInput::Echo {{{1*/
|
---|
| 51 | void PentaVertexInput::Echo(void){
|
---|
| 52 | this->DeepEcho();
|
---|
[3683] | 53 | }
|
---|
| 54 | /*}}}*/
|
---|
| 55 | /*FUNCTION PentaVertexInput::DeepEcho{{{1*/
|
---|
| 56 | void PentaVertexInput::DeepEcho(void){
|
---|
| 57 |
|
---|
| 58 | printf("PentaVertexInput:\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 | /*}}}*/
|
---|
[4248] | 63 | /*FUNCTION PentaVertexInput::Id{{{1*/
|
---|
| 64 | int PentaVertexInput::Id(void){ return -1; }
|
---|
[3683] | 65 | /*}}}*/
|
---|
[4248] | 66 | /*FUNCTION PentaVertexInput::MyRank{{{1*/
|
---|
| 67 | int PentaVertexInput::MyRank(void){
|
---|
| 68 | extern int my_rank;
|
---|
| 69 | return my_rank;
|
---|
[3683] | 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 | /*}}}*/
|
---|
[4248] | 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;
|
---|
[3683] | 119 | }
|
---|
| 120 | /*}}}*/
|
---|
[4248] | 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 | /*}}}*/
|
---|
[3847] | 144 | /*FUNCTION PentaVertexInput::SpawnTriaInput{{{1*/
|
---|
| 145 | Input* PentaVertexInput::SpawnTriaInput(int* indices){
|
---|
[3683] | 146 |
|
---|
[3847] | 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*/
|
---|
[6412] | 155 | _assert_(indices[i]>=0 && indices[i]<6);
|
---|
[3847] | 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 | /*}}}*/
|
---|
[4037] | 169 | /*FUNCTION PentaVertexInput::SpawnResult{{{1*/
|
---|
[4050] | 170 | ElementResult* PentaVertexInput::SpawnResult(int step, double time){
|
---|
[3847] | 171 |
|
---|
[4050] | 172 | return new PentaVertexElementResult(this->enum_type,this->values,step,time);
|
---|
[4037] | 173 |
|
---|
| 174 | }
|
---|
| 175 | /*}}}*/
|
---|
| 176 |
|
---|
[3683] | 177 | /*Object functions*/
|
---|
[5647] | 178 | /*FUNCTION PentaVertexInput::GetParameterValue(double* pvalue,GaussPenta* gauss){{{1*/
|
---|
| 179 | void PentaVertexInput::GetParameterValue(double* pvalue,GaussPenta* gauss){
|
---|
[5629] | 180 |
|
---|
| 181 | /*Call PentaRef function*/
|
---|
| 182 | PentaRef::GetParameterValue(pvalue,&values[0],gauss);
|
---|
| 183 |
|
---|
| 184 | }
|
---|
| 185 | /*}}}*/
|
---|
[5647] | 186 | /*FUNCTION PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){{{1*/
|
---|
| 187 | void PentaVertexInput::GetParameterDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){
|
---|
[5629] | 188 |
|
---|
| 189 | /*Call PentaRef function*/
|
---|
| 190 | PentaRef::GetParameterDerivativeValue(p,&values[0],xyz_list,gauss);
|
---|
| 191 | }
|
---|
| 192 | /*}}}*/
|
---|
[4546] | 193 | /*FUNCTION PentaVertexInput::GetVxStrainRate3d{{{1*/
|
---|
[5647] | 194 | void PentaVertexInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
|
---|
| 195 | int i,j;
|
---|
| 196 |
|
---|
[8303] | 197 | const int numnodes=6;
|
---|
[5647] | 198 | const int DOFVELOCITY=3;
|
---|
| 199 | double B[8][27];
|
---|
[8303] | 200 | double B_reduced[6][DOFVELOCITY*numnodes];
|
---|
| 201 | double velocity[numnodes][DOFVELOCITY];
|
---|
[5647] | 202 |
|
---|
| 203 | /*Get B matrix: */
|
---|
| 204 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
| 205 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
| 206 | for (i=0;i<6;i++){
|
---|
| 207 | for (j=0;j<3;j++){
|
---|
| 208 | B_reduced[i][j]=B[i][j];
|
---|
| 209 | }
|
---|
| 210 | for (j=4;j<7;j++){
|
---|
| 211 | B_reduced[i][j-1]=B[i][j];
|
---|
| 212 | }
|
---|
| 213 | for (j=8;j<11;j++){
|
---|
| 214 | B_reduced[i][j-2]=B[i][j];
|
---|
| 215 | }
|
---|
| 216 | for (j=12;j<15;j++){
|
---|
| 217 | B_reduced[i][j-3]=B[i][j];
|
---|
| 218 | }
|
---|
| 219 | for (j=16;j<19;j++){
|
---|
| 220 | B_reduced[i][j-4]=B[i][j];
|
---|
| 221 | }
|
---|
| 222 | for (j=20;j<23;j++){
|
---|
| 223 | B_reduced[i][j-5]=B[i][j];
|
---|
| 224 | }
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | /*Here, we are computing the strain rate of (vx,0,0)*/
|
---|
[8303] | 228 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 229 | velocity[i][0]=this->values[i];
|
---|
| 230 | velocity[i][1]=0.0;
|
---|
| 231 | velocity[i][2]=0.0;
|
---|
| 232 | }
|
---|
| 233 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 234 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvx,0);
|
---|
[5647] | 235 |
|
---|
| 236 | }
|
---|
| 237 | /*}}}*/
|
---|
| 238 | /*FUNCTION PentaVertexInput::GetVyStrainRate3d{{{1*/
|
---|
| 239 | void PentaVertexInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
|
---|
| 240 | int i,j;
|
---|
| 241 |
|
---|
[8303] | 242 | const int numnodes=6;
|
---|
[5647] | 243 | const int DOFVELOCITY=3;
|
---|
| 244 | double B[8][27];
|
---|
[8303] | 245 | double B_reduced[6][DOFVELOCITY*numnodes];
|
---|
| 246 | double velocity[numnodes][DOFVELOCITY];
|
---|
[5647] | 247 |
|
---|
| 248 | /*Get B matrix: */
|
---|
| 249 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
| 250 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
| 251 | for (i=0;i<6;i++){
|
---|
| 252 | for (j=0;j<3;j++){
|
---|
| 253 | B_reduced[i][j]=B[i][j];
|
---|
| 254 | }
|
---|
| 255 | for (j=4;j<7;j++){
|
---|
| 256 | B_reduced[i][j-1]=B[i][j];
|
---|
| 257 | }
|
---|
| 258 | for (j=8;j<11;j++){
|
---|
| 259 | B_reduced[i][j-2]=B[i][j];
|
---|
| 260 | }
|
---|
| 261 | for (j=12;j<15;j++){
|
---|
| 262 | B_reduced[i][j-3]=B[i][j];
|
---|
| 263 | }
|
---|
| 264 | for (j=16;j<19;j++){
|
---|
| 265 | B_reduced[i][j-4]=B[i][j];
|
---|
| 266 | }
|
---|
| 267 | for (j=20;j<23;j++){
|
---|
| 268 | B_reduced[i][j-5]=B[i][j];
|
---|
| 269 | }
|
---|
| 270 | }
|
---|
| 271 |
|
---|
| 272 | /*Here, we are computing the strain rate of (0,vy,0)*/
|
---|
[8303] | 273 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 274 | velocity[i][0]=0.0;
|
---|
| 275 | velocity[i][1]=this->values[i];
|
---|
| 276 | velocity[i][2]=0.0;
|
---|
| 277 | }
|
---|
| 278 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 279 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvy,0);
|
---|
[5647] | 280 |
|
---|
| 281 | }
|
---|
| 282 | /*}}}*/
|
---|
| 283 | /*FUNCTION PentaVertexInput::GetVzStrainRate3d{{{1*/
|
---|
| 284 | void PentaVertexInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
|
---|
| 285 | int i,j;
|
---|
| 286 |
|
---|
[8303] | 287 | const int numnodes=6;
|
---|
[5647] | 288 | const int DOFVELOCITY=3;
|
---|
| 289 | double B[8][27];
|
---|
[8303] | 290 | double B_reduced[6][DOFVELOCITY*numnodes];
|
---|
| 291 | double velocity[numnodes][DOFVELOCITY];
|
---|
[5647] | 292 |
|
---|
| 293 | /*Get B matrix: */
|
---|
| 294 | GetBStokes(&B[0][0], xyz_list, gauss);
|
---|
| 295 | /*Create a reduced matrix of B to get rid of pressure */
|
---|
| 296 | for (i=0;i<6;i++){
|
---|
| 297 | for (j=0;j<3;j++){
|
---|
| 298 | B_reduced[i][j]=B[i][j];
|
---|
| 299 | }
|
---|
| 300 | for (j=4;j<7;j++){
|
---|
| 301 | B_reduced[i][j-1]=B[i][j];
|
---|
| 302 | }
|
---|
| 303 | for (j=8;j<11;j++){
|
---|
| 304 | B_reduced[i][j-2]=B[i][j];
|
---|
| 305 | }
|
---|
| 306 | for (j=12;j<15;j++){
|
---|
| 307 | B_reduced[i][j-3]=B[i][j];
|
---|
| 308 | }
|
---|
| 309 | for (j=16;j<19;j++){
|
---|
| 310 | B_reduced[i][j-4]=B[i][j];
|
---|
| 311 | }
|
---|
| 312 | for (j=20;j<23;j++){
|
---|
| 313 | B_reduced[i][j-5]=B[i][j];
|
---|
| 314 | }
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | /*Here, we are computing the strain rate of (0,0,vz)*/
|
---|
[8303] | 318 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 319 | velocity[i][0]=0.0;
|
---|
| 320 | velocity[i][1]=0.0;
|
---|
| 321 | velocity[i][2]=this->values[i];
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 325 | MatrixMultiply(&B_reduced[0][0],6,DOFVELOCITY*numnodes,0,&velocity[0][0],DOFVELOCITY*numnodes,1,0,epsilonvz,0);
|
---|
[5647] | 326 |
|
---|
| 327 | }
|
---|
| 328 | /*}}}*/
|
---|
| 329 | /*FUNCTION PentaVertexInput::GetVxStrainRate3dPattyn{{{1*/
|
---|
| 330 | void PentaVertexInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
|
---|
| 331 |
|
---|
| 332 | int i;
|
---|
[8303] | 333 | const int numnodes=6;
|
---|
| 334 | double B[5][NDOF2*numnodes];
|
---|
| 335 | double velocity[numnodes][NDOF2];
|
---|
[5647] | 336 |
|
---|
| 337 | /*Get B matrix: */
|
---|
| 338 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
---|
| 339 |
|
---|
| 340 | /*Here, we are computing the strain rate of (vx,0)*/
|
---|
[8303] | 341 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 342 | velocity[i][0]=this->values[i];
|
---|
| 343 | velocity[i][1]=0.0;
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 347 | MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
|
---|
| 348 | &velocity[0][0],NDOF2*numnodes,1,0,
|
---|
[5647] | 349 | epsilonvx,0);
|
---|
| 350 |
|
---|
| 351 | }
|
---|
| 352 | /*}}}*/
|
---|
| 353 | /*FUNCTION PentaVertexInput::GetVyStrainRate3dPattyn{{{1*/
|
---|
| 354 | void PentaVertexInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
|
---|
| 355 |
|
---|
| 356 | int i;
|
---|
[8303] | 357 | const int numnodes=6;
|
---|
| 358 | double B[5][NDOF2*numnodes];
|
---|
| 359 | double velocity[numnodes][NDOF2];
|
---|
[5647] | 360 |
|
---|
| 361 | /*Get B matrix: */
|
---|
| 362 | GetBPattyn(&B[0][0], xyz_list, gauss);
|
---|
| 363 |
|
---|
| 364 | /*Here, we are computing the strain rate of (0,vy)*/
|
---|
[8303] | 365 | for(i=0;i<numnodes;i++){
|
---|
[5647] | 366 | velocity[i][0]=0.0;
|
---|
| 367 | velocity[i][1]=this->values[i];
|
---|
| 368 | }
|
---|
| 369 |
|
---|
| 370 | /*Multiply B by velocity, to get strain rate: */
|
---|
[8303] | 371 | MatrixMultiply( &B[0][0],5,NDOF2*numnodes,0,
|
---|
| 372 | &velocity[0][0],NDOF2*numnodes,1,0,
|
---|
[5647] | 373 | epsilonvy,0);
|
---|
| 374 |
|
---|
| 375 | }
|
---|
| 376 | /*}}}*/
|
---|
[4546] | 377 | /*FUNCTION PentaVertexInput::ChangeEnum{{{1*/
|
---|
[3732] | 378 | void PentaVertexInput::ChangeEnum(int newenumtype){
|
---|
| 379 | this->enum_type=newenumtype;
|
---|
| 380 | }
|
---|
| 381 | /*}}}*/
|
---|
[4546] | 382 | /*FUNCTION PentaVertexInput::GetParameterAverage{{{1*/
|
---|
[3830] | 383 | void PentaVertexInput::GetParameterAverage(double* pvalue){
|
---|
| 384 | *pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
|
---|
| 385 | }
|
---|
| 386 | /*}}}*/
|
---|
[3840] | 387 |
|
---|
| 388 | /*Intermediary*/
|
---|
[4471] | 389 | /*FUNCTION PentaVertexInput::SquareMin{{{1*/
|
---|
[4042] | 390 | void PentaVertexInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
|
---|
| 391 |
|
---|
| 392 | int i;
|
---|
| 393 | const int numnodes=6;
|
---|
| 394 | double valuescopy[numnodes];
|
---|
| 395 | double squaremin;
|
---|
| 396 |
|
---|
| 397 | /*First, copy values, to process units if requested: */
|
---|
| 398 | for(i=0;i<numnodes;i++)valuescopy[i]=this->values[i];
|
---|
| 399 |
|
---|
| 400 | /*Process units if requested: */
|
---|
[8967] | 401 | if(process_units)UnitConversion(&valuescopy[0],numnodes,IuToExtEnum,enum_type);
|
---|
[4042] | 402 |
|
---|
| 403 | /*Now, figure out minimum of valuescopy: */
|
---|
| 404 | squaremin=pow(valuescopy[0],2);
|
---|
| 405 | for(i=1;i<numnodes;i++){
|
---|
| 406 | if(pow(valuescopy[i],2)<squaremin)squaremin=pow(valuescopy[i],2);
|
---|
| 407 | }
|
---|
| 408 | /*Assign output pointers:*/
|
---|
| 409 | *psquaremin=squaremin;
|
---|
| 410 | }
|
---|
| 411 | /*}}}*/
|
---|
[5017] | 412 | /*FUNCTION PentaVertexInput::ConstrainMin{{{1*/
|
---|
| 413 | void PentaVertexInput::ConstrainMin(double minimum){
|
---|
| 414 |
|
---|
| 415 | int i;
|
---|
[8303] | 416 | const int numnodes=6;
|
---|
[5017] | 417 |
|
---|
[8303] | 418 | for(i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
|
---|
[5017] | 419 | }
|
---|
| 420 | /*}}}*/
|
---|
[5513] | 421 | /*FUNCTION PentaVertexInput::InfinityNorm{{{1*/
|
---|
| 422 | double PentaVertexInput::InfinityNorm(void){
|
---|
| 423 |
|
---|
| 424 | /*Output*/
|
---|
[8303] | 425 | const int numnodes=6;
|
---|
[5513] | 426 | double norm=0;
|
---|
| 427 |
|
---|
[8303] | 428 | for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
|
---|
[5513] | 429 | return norm;
|
---|
| 430 | }
|
---|
| 431 | /*}}}*/
|
---|
[5659] | 432 | /*FUNCTION PentaVertexInput::Max{{{1*/
|
---|
| 433 | double PentaVertexInput::Max(void){
|
---|
| 434 |
|
---|
[8303] | 435 | const int numnodes=6;
|
---|
[5659] | 436 | double max=values[0];
|
---|
| 437 |
|
---|
[8303] | 438 | for(int i=1;i<numnodes;i++){
|
---|
[5659] | 439 | if(values[i]>max) max=values[i];
|
---|
| 440 | }
|
---|
| 441 | return max;
|
---|
| 442 | }
|
---|
| 443 | /*}}}*/
|
---|
| 444 | /*FUNCTION PentaVertexInput::MaxAbs{{{1*/
|
---|
| 445 | double PentaVertexInput::MaxAbs(void){
|
---|
| 446 |
|
---|
[8303] | 447 | const int numnodes=6;
|
---|
[5659] | 448 | double max=fabs(values[0]);
|
---|
| 449 |
|
---|
[8303] | 450 | for(int i=1;i<numnodes;i++){
|
---|
[5659] | 451 | if(fabs(values[i])>max) max=fabs(values[i]);
|
---|
| 452 | }
|
---|
| 453 | return max;
|
---|
| 454 | }
|
---|
| 455 | /*}}}*/
|
---|
| 456 | /*FUNCTION PentaVertexInput::Min{{{1*/
|
---|
| 457 | double PentaVertexInput::Min(void){
|
---|
| 458 |
|
---|
[8303] | 459 | const int numnodes=6;
|
---|
[5659] | 460 | double min=values[0];
|
---|
| 461 |
|
---|
[8303] | 462 | for(int i=1;i<numnodes;i++){
|
---|
[5659] | 463 | if(values[i]<min) min=values[i];
|
---|
| 464 | }
|
---|
| 465 | return min;
|
---|
| 466 | }
|
---|
| 467 | /*}}}*/
|
---|
| 468 | /*FUNCTION PentaVertexInput::MinAbs{{{1*/
|
---|
| 469 | double PentaVertexInput::MinAbs(void){
|
---|
| 470 |
|
---|
[8303] | 471 | const int numnodes=6;
|
---|
[5659] | 472 | double min=fabs(values[0]);
|
---|
| 473 |
|
---|
[8303] | 474 | for(int i=1;i<numnodes;i++){
|
---|
[5659] | 475 | if(fabs(values[i])<min) min=fabs(values[i]);
|
---|
| 476 | }
|
---|
| 477 | return min;
|
---|
| 478 | }
|
---|
| 479 | /*}}}*/
|
---|
[4471] | 480 | /*FUNCTION PentaVertexInput::Scale{{{1*/
|
---|
[4047] | 481 | void PentaVertexInput::Scale(double scale_factor){
|
---|
| 482 |
|
---|
| 483 | int i;
|
---|
[8303] | 484 | const int numnodes=6;
|
---|
[4047] | 485 |
|
---|
[8303] | 486 | for(i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
|
---|
[4047] | 487 | }
|
---|
| 488 | /*}}}*/
|
---|
[4471] | 489 | /*FUNCTION PentaVertexInput::AXPY{{{1*/
|
---|
[4048] | 490 | void PentaVertexInput::AXPY(Input* xinput,double scalar){
|
---|
| 491 |
|
---|
| 492 | int i;
|
---|
[8303] | 493 | const int numnodes=6;
|
---|
[4048] | 494 |
|
---|
| 495 | /*xinput is of the same type, so cast it: */
|
---|
| 496 |
|
---|
[4174] | 497 | /*Carry out the AXPY operation depending on type:*/
|
---|
| 498 | switch(xinput->Enum()){
|
---|
[4048] | 499 |
|
---|
[6200] | 500 | case PentaVertexInputEnum:{
|
---|
| 501 | PentaVertexInput* cast_input=(PentaVertexInput*)xinput;
|
---|
[8303] | 502 | for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
|
---|
[4174] | 503 | return;
|
---|
[6200] | 504 | case ControlInputEnum:{
|
---|
| 505 | ControlInput* cont_input=(ControlInput*)xinput;
|
---|
[6412] | 506 | if(cont_input->values->Enum()!=PentaVertexInputEnum) _error_("not supported yet");
|
---|
[6200] | 507 | PentaVertexInput* cast_input=(PentaVertexInput*)cont_input->values;
|
---|
[8303] | 508 | for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
|
---|
[6200] | 509 | return;
|
---|
[4174] | 510 | default:
|
---|
[6412] | 511 | _error_("not implemented yet");
|
---|
[4174] | 512 | }
|
---|
| 513 |
|
---|
[4048] | 514 | }
|
---|
| 515 | /*}}}*/
|
---|
[4471] | 516 | /*FUNCTION PentaVertexInput::Constrain{{{1*/
|
---|
[4048] | 517 | void PentaVertexInput::Constrain(double cm_min, double cm_max){
|
---|
| 518 |
|
---|
| 519 | int i;
|
---|
[8303] | 520 | const int numnodes=6;
|
---|
[4048] | 521 |
|
---|
[8303] | 522 | if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
|
---|
| 523 | if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
|
---|
[4048] | 524 |
|
---|
| 525 | }
|
---|
| 526 | /*}}}*/
|
---|
[4471] | 527 | /*FUNCTION PentaVertexInput::Extrude{{{1*/
|
---|
[4274] | 528 | void PentaVertexInput::Extrude(void){
|
---|
| 529 |
|
---|
| 530 | int i;
|
---|
| 531 |
|
---|
| 532 | /*First 3 values copied on 3 last values*/
|
---|
| 533 | for(i=0;i<3;i++) this->values[3+i]=this->values[i];
|
---|
| 534 |
|
---|
| 535 | }
|
---|
| 536 | /*}}}*/
|
---|
[4471] | 537 | /*FUNCTION PentaVertexInput::VerticallyIntegrate{{{1*/
|
---|
| 538 | void PentaVertexInput::VerticallyIntegrate(Input* thickness_input){
|
---|
| 539 |
|
---|
| 540 | /*Intermediaries*/
|
---|
| 541 | int i;
|
---|
[8303] | 542 | const int numnodes = 6;
|
---|
[4471] | 543 | int num_thickness_values;
|
---|
| 544 | double *thickness_values = NULL;
|
---|
| 545 |
|
---|
| 546 | /*Check that input provided is a thickness*/
|
---|
[8224] | 547 | if (thickness_input->EnumType()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is %s)",EnumToStringx(thickness_input->EnumType()));
|
---|
[4471] | 548 |
|
---|
| 549 | /*Get Thickness value pointer*/
|
---|
| 550 | thickness_input->GetValuesPtr(&thickness_values,&num_thickness_values);
|
---|
| 551 |
|
---|
| 552 | /*vertically integrate depending on type:*/
|
---|
| 553 | switch(thickness_input->Enum()){
|
---|
| 554 |
|
---|
| 555 | case PentaVertexInputEnum:
|
---|
| 556 | for(i=0;i<3;i++){
|
---|
| 557 | this->values[i]=0.5*(this->values[i]+this->values[i+3]) * thickness_values[i];
|
---|
| 558 | this->values[i+3]=this->values[i];
|
---|
| 559 | }
|
---|
| 560 | return;
|
---|
| 561 |
|
---|
| 562 | default:
|
---|
[6412] | 563 | _error_("not implemented yet");
|
---|
[4471] | 564 | }
|
---|
| 565 | }
|
---|
| 566 | /*}}}*/
|
---|
| 567 | /*FUNCTION PentaVertexInput::PointwiseDivide{{{1*/
|
---|
| 568 | Input* PentaVertexInput::PointwiseDivide(Input* inputB){
|
---|
| 569 |
|
---|
| 570 | /*Ouput*/
|
---|
| 571 | PentaVertexInput* outinput=NULL;
|
---|
| 572 |
|
---|
| 573 | /*Intermediaries*/
|
---|
| 574 | int i;
|
---|
| 575 | PentaVertexInput *xinputB = NULL;
|
---|
| 576 | int B_numvalues;
|
---|
[8303] | 577 | const int numnodes = 6;
|
---|
| 578 | double AdotBvalues[numnodes];
|
---|
[4471] | 579 |
|
---|
| 580 | /*Check that inputB is of the same type*/
|
---|
[8224] | 581 | if (inputB->Enum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->Enum()));
|
---|
[4471] | 582 | xinputB=(PentaVertexInput*)inputB;
|
---|
| 583 |
|
---|
| 584 | /*Create point wise sum*/
|
---|
[8303] | 585 | for(i=0;i<numnodes;i++){
|
---|
[6412] | 586 | _assert_(xinputB->values[i]!=0);
|
---|
[4471] | 587 | AdotBvalues[i]=this->values[i]/xinputB->values[i];
|
---|
| 588 | }
|
---|
| 589 |
|
---|
[4899] | 590 | /*Create new Penta vertex input (copy of current input)*/
|
---|
[4471] | 591 | outinput=new PentaVertexInput(this->enum_type,&AdotBvalues[0]);
|
---|
| 592 |
|
---|
| 593 | /*Return output pointer*/
|
---|
| 594 | return outinput;
|
---|
| 595 |
|
---|
| 596 | }
|
---|
| 597 | /*}}}*/
|
---|
[8129] | 598 | /*FUNCTION PentaVertexInput::PointwiseMin{{{1*/
|
---|
| 599 | Input* PentaVertexInput::PointwiseMin(Input* inputB){
|
---|
| 600 |
|
---|
| 601 | /*Ouput*/
|
---|
| 602 | PentaVertexInput* outinput=NULL;
|
---|
| 603 |
|
---|
| 604 | /*Intermediaries*/
|
---|
| 605 | int i;
|
---|
| 606 | PentaVertexInput *xinputB = NULL;
|
---|
| 607 | int B_numvalues;
|
---|
[8303] | 608 | const int numnodes = 6;
|
---|
| 609 | double minvalues[numnodes];
|
---|
[8129] | 610 |
|
---|
| 611 | /*Check that inputB is of the same type*/
|
---|
[8224] | 612 | if (inputB->Enum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->Enum()));
|
---|
[8129] | 613 | xinputB=(PentaVertexInput*)inputB;
|
---|
| 614 |
|
---|
| 615 | /*Create point wise min*/
|
---|
[8303] | 616 | for(i=0;i<numnodes;i++){
|
---|
[8129] | 617 | if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
|
---|
| 618 | else minvalues[i]=this->values[i];
|
---|
| 619 | }
|
---|
| 620 |
|
---|
| 621 | /*Create new Penta vertex input (copy of current input)*/
|
---|
| 622 | outinput=new PentaVertexInput(this->enum_type,&minvalues[0]);
|
---|
| 623 |
|
---|
| 624 | /*Return output pointer*/
|
---|
| 625 | return outinput;
|
---|
| 626 |
|
---|
| 627 | }
|
---|
| 628 | /*}}}*/
|
---|
| 629 | /*FUNCTION PentaVertexInput::PointwiseMax{{{1*/
|
---|
| 630 | Input* PentaVertexInput::PointwiseMax(Input* inputB){
|
---|
| 631 |
|
---|
| 632 | /*Ouput*/
|
---|
| 633 | PentaVertexInput* outinput=NULL;
|
---|
| 634 |
|
---|
| 635 | /*Intermediaries*/
|
---|
| 636 | int i;
|
---|
| 637 | PentaVertexInput *xinputB = NULL;
|
---|
| 638 | int B_numvalues;
|
---|
[8303] | 639 | const int numnodes = 6;
|
---|
| 640 | double maxvalues[numnodes];
|
---|
[8129] | 641 |
|
---|
| 642 | /*Check that inputB is of the same type*/
|
---|
[8224] | 643 | if (inputB->Enum()!=PentaVertexInputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->Enum()));
|
---|
[8129] | 644 | xinputB=(PentaVertexInput*)inputB;
|
---|
| 645 |
|
---|
| 646 | /*Create point wise max*/
|
---|
[8303] | 647 | for(i=0;i<numnodes;i++){
|
---|
[8129] | 648 | if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
|
---|
| 649 | else maxvalues[i]=this->values[i];
|
---|
| 650 | }
|
---|
| 651 |
|
---|
| 652 | /*Create new Penta vertex input (copy of current input)*/
|
---|
| 653 | outinput=new PentaVertexInput(this->enum_type,&maxvalues[0]);
|
---|
| 654 |
|
---|
| 655 | /*Return output pointer*/
|
---|
| 656 | return outinput;
|
---|
| 657 |
|
---|
| 658 | }
|
---|
| 659 | /*}}}*/
|
---|
[4546] | 660 | /*FUNCTION PentaVertexInput::GetVectorFromInputs{{{1*/
|
---|
[4048] | 661 | void PentaVertexInput::GetVectorFromInputs(Vec vector,int* doflist){
|
---|
| 662 |
|
---|
| 663 | const int numvertices=6;
|
---|
[4502] | 664 | VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
|
---|
[4048] | 665 |
|
---|
[4502] | 666 | } /*}}}*/
|
---|
[4546] | 667 | /*FUNCTION PentaVertexInput::GetValuesPtr{{{1*/
|
---|
[4057] | 668 | void PentaVertexInput::GetValuesPtr(double** pvalues,int* pnum_values){
|
---|
[4055] | 669 |
|
---|
| 670 | *pvalues=this->values;
|
---|
| 671 | *pnum_values=6;
|
---|
| 672 |
|
---|
| 673 | }
|
---|
| 674 | /*}}}*/
|
---|
[8363] | 675 | /*FUNCTION PentaVertexInput::Configure{{{1*/
|
---|
| 676 | void PentaVertexInput::Configure(Parameters* parameters){
|
---|
| 677 | /*do nothing: */
|
---|
| 678 | }
|
---|
| 679 | /*}}}*/
|
---|