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