Changeset 3702
- Timestamp:
- 05/11/10 08:28:18 (15 years ago)
- Location:
- issm/trunk/src/c/DataSet
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/DataSet/DataSet.cpp
r3699 r3702 17 17 18 18 #include "./DataSet.h" 19 #include "../objects/objects.h" 19 20 #include "../shared/shared.h" 20 21 #include "../include/macros.h" … … 23 24 using namespace std; 24 25 /*}}}*/ 25 /*DataSet: {{{1*/ 26 26 27 /*Constructors/Destructors*/ 27 /*FUNCTION DataSet::DataSet(){{{ 2*/28 /*FUNCTION DataSet::DataSet(){{{1*/ 28 29 DataSet::DataSet(){ 29 30 … … 34 35 } 35 36 /*}}}*/ 36 /*FUNCTION DataSet::DataSet(int dataset_enum){{{ 2*/37 /*FUNCTION DataSet::DataSet(int dataset_enum){{{1*/ 37 38 DataSet::DataSet(int dataset_enum){ 38 39 enum_type=dataset_enum; … … 44 45 } 45 46 /*}}}*/ 46 /*FUNCTION DataSet::Copy{{{ 2*/47 /*FUNCTION DataSet::Copy{{{1*/ 47 48 DataSet* DataSet::Copy(void){ 48 49 … … 75 76 } 76 77 /*}}}*/ 77 /*FUNCTION DataSet::~DataSet{{{ 2*/78 /*FUNCTION DataSet::~DataSet{{{1*/ 78 79 DataSet::~DataSet(){ 79 80 clear(); … … 84 85 85 86 /*I/O*/ 86 /*FUNCTION DataSet::Marshall{{{ 2*/87 /*FUNCTION DataSet::Marshall{{{1*/ 87 88 char* DataSet::Marshall(){ 88 89 … … 131 132 } 132 133 /*}}}*/ 133 /*FUNCTION DataSet::MarshallSize{{{ 2*/134 /*FUNCTION DataSet::MarshallSize{{{1*/ 134 135 int DataSet::MarshallSize(){ 135 136 … … 152 153 } 153 154 /*}}}*/ 154 /*FUNCTION DataSet::Demarshall{{{ 2*/155 /*FUNCTION DataSet::Demarshall{{{1*/ 155 156 DataSet* DataSetDemarshall(char* marshalled_dataset){ 156 157 … … 159 160 } 160 161 /*}}}*/ 161 /*FUNCTION DataSet::DemarshallRaw{{{ 2*/162 /*FUNCTION DataSet::DemarshallRaw{{{1*/ 162 163 DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset){ 163 164 … … 311 312 } 312 313 /*}}}*/ 313 /*FUNCTION DataSet::Spawn{{{ 2*/314 /*FUNCTION DataSet::Spawn{{{1*/ 314 315 DataSet* DataSet::Spawn(int* indices, int num){ 315 316 ISSMERROR(" not supported yet!"); … … 318 319 319 320 /*Specific methods*/ 320 /*FUNCTION DataSet::AddObject{{{ 2*/321 /*FUNCTION DataSet::AddObject{{{1*/ 321 322 int DataSet::AddObject(Object* object){ 322 323 … … 326 327 } 327 328 /*}}}*/ 328 /*FUNCTION DataSet::clear{{{ 2*/329 /*FUNCTION DataSet::clear{{{1*/ 329 330 void DataSet::clear(){ 330 331 … … 337 338 } 338 339 /*}}}*/ 339 /*FUNCTION DataSet::DeleteObject{{{ 2*/340 /*FUNCTION DataSet::DeleteObject{{{1*/ 340 341 int DataSet::DeleteObject(Object* object){ 341 342 … … 350 351 } 351 352 /*}}}*/ 352 /*FUNCTION DataSet::DeepEcho{{{ 2*/353 /*FUNCTION DataSet::DeepEcho{{{1*/ 353 354 void DataSet::DeepEcho(){ 354 355 … … 369 370 } 370 371 /*}}}*/ 371 /*FUNCTION DataSet::Echo{{{ 2*/372 /*FUNCTION DataSet::Echo{{{1*/ 372 373 void DataSet::Echo(){ 373 374 … … 388 389 } 389 390 /*}}}*/ 390 /*FUNCTION DataSet::FindResult(Vec* presult,char* name){{{ 2*/391 /*FUNCTION DataSet::FindResult(Vec* presult,char* name){{{1*/ 391 392 int DataSet::FindResult(Vec* presult,char* name){ 392 393 … … 418 419 } 419 420 /*}}}*/ 420 /*FUNCTION DataSet::FindResult(void* pvalue, char* name){{{ 2*/421 /*FUNCTION DataSet::FindResult(void* pvalue, char* name){{{1*/ 421 422 int DataSet::FindResult(void* pvalue, char* name){ 422 423 … … 450 451 } 451 452 /*}}}*/ 452 /*FUNCTION DataSet::GetEnum{{{ 2*/453 /*FUNCTION DataSet::GetEnum{{{1*/ 453 454 int DataSet::GetEnum(){ 454 455 return enum_type; 455 456 } 456 457 /*}}}*/ 457 /*FUNCTION DataSet::GetEnum(int offset){{{ 2*/458 /*FUNCTION DataSet::GetEnum(int offset){{{1*/ 458 459 int DataSet::GetEnum(int offset){ 459 460 … … 462 463 } 463 464 /*}}}*/ 464 /*FUNCTION DataSet::GetObjectByOffset{{{ 2*/465 /*FUNCTION DataSet::GetObjectByOffset{{{1*/ 465 466 Object* DataSet::GetObjectByOffset(int offset){ 466 467 … … 469 470 } 470 471 /*}}}*/ 471 /*FUNCTION DataSet::GetObjectById{{{ 2*/472 /*FUNCTION DataSet::GetObjectById{{{1*/ 472 473 Object* DataSet::GetObjectById(int* poffset,int eid){ 473 474 … … 493 494 } 494 495 /*}}}*/ 495 /*FUNCTION DataSet::Ranks{{{ 2*/496 /*FUNCTION DataSet::Ranks{{{1*/ 496 497 void DataSet::Ranks(int* ranks){ 497 498 … … 516 517 } 517 518 /*}}}*/ 518 /*FUNCTION DataSet::Presort{{{ 2*/519 /*FUNCTION DataSet::Presort{{{1*/ 519 520 void DataSet::Presort(){ 520 521 … … 536 537 } 537 538 /*}}}*/ 538 /*FUNCTION DataSet::SetSorting{{{ 2*/539 /*FUNCTION DataSet::SetSorting{{{1*/ 539 540 void DataSet::SetSorting(int* in_sorted_ids,int* in_id_offsets){ 540 541 … … 544 545 } 545 546 /*}}}*/ 546 /*FUNCTION DataSet::Size{{{ 2*/547 /*FUNCTION DataSet::Size{{{1*/ 547 548 int DataSet::Size(void){ 548 549 … … 550 551 } 551 552 /*}}}*/ 552 /*FUNCTION DataSet::Sort{{{ 2*/553 /*FUNCTION DataSet::Sort{{{1*/ 553 554 void DataSet::Sort(){ 554 555 … … 561 562 562 563 /*Objects methods*/ 563 /*FUNCTION DataSet::ComputeBasalStress{{{ 2*/564 /*FUNCTION DataSet::ComputeBasalStress{{{1*/ 564 565 void DataSet::ComputeBasalStress(Vec sigma_b,int analysis_type,int sub_analysis_type){ 565 566 … … 578 579 } 579 580 /*}}}*/ 580 /*FUNCTION DataSet::ComputePressure{{{ 2*/581 /*FUNCTION DataSet::ComputePressure{{{1*/ 581 582 void DataSet::ComputePressure(Vec p_g,int analysis_type,int sub_analysis_type){ 582 583 … … 595 596 } 596 597 /*}}}*/ 597 /*FUNCTION DataSet::ComputeStrainRate{{{ 2*/598 /*FUNCTION DataSet::ComputeStrainRate{{{1*/ 598 599 void DataSet::ComputeStrainRate(Vec eps,int analysis_type,int sub_analysis_type){ 599 600 … … 612 613 } 613 614 /*}}}*/ 614 /*FUNCTION DataSet::Configure{{{ 2*/615 /*FUNCTION DataSet::Configure{{{1*/ 615 616 void DataSet::Configure(DataSet* elements,DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials,Parameters* parameters){ 616 617 … … 640 641 } 641 642 /*}}}*/ 642 /*FUNCTION DataSet::CostFunction{{{ 2*/643 /*FUNCTION DataSet::CostFunction{{{1*/ 643 644 void DataSet::CostFunction(double* pJ,int analysis_type,int sub_analysis_type){ 644 645 … … 663 664 } 664 665 /*}}}*/ 665 /*FUNCTION DataSet::CreateKMatrix{{{ 2*/666 /*FUNCTION DataSet::CreateKMatrix{{{1*/ 666 667 void DataSet::CreateKMatrix(Mat Kgg,int analysis_type,int sub_analysis_type){ 667 668 … … 686 687 } 687 688 /*}}}*/ 688 /*FUNCTION DataSet::CreatePartitioningVector{{{ 2*/689 /*FUNCTION DataSet::CreatePartitioningVector{{{1*/ 689 690 void DataSet::CreatePartitioningVector(Vec* ppartition,int numberofobjects){ 690 691 … … 714 715 } 715 716 /*}}}*/ 716 /*FUNCTION DataSet::CreatePVector{{{ 2*/717 /*FUNCTION DataSet::CreatePVector{{{1*/ 717 718 void DataSet::CreatePVector(Vec pg,int analysis_type,int sub_analysis_type){ 718 719 … … 737 738 } 738 739 /*}}}*/ 739 /*FUNCTION DataSet::DistributeDofs{{{ 2*/740 /*FUNCTION DataSet::DistributeDofs{{{1*/ 740 741 void DataSet::DistributeDofs(int numberofobjects,int numberofdofsperobject){ 741 742 … … 819 820 } 820 821 /*}}}*/ 821 /*FUNCTION DataSet::Du{{{ 2*/822 /*FUNCTION DataSet::Du{{{1*/ 822 823 void DataSet::Du(Vec du_g,int analysis_type,int sub_analysis_type){ 823 824 … … 838 839 } 839 840 /*}}}*/ 840 /*FUNCTION DataSet::FieldAverageOntoVertices{{{ 2*/841 /*FUNCTION DataSet::FieldAverageOntoVertices{{{1*/ 841 842 void DataSet::FieldAverageOntoVertices(Vec fieldsum,Vec connectivity,double* field){ 842 843 … … 855 856 } 856 857 /*}}}*/ 857 /*FUNCTION DataSet::FieldDepthAverageAtBase{{{ 2*/858 /*FUNCTION DataSet::FieldDepthAverageAtBase{{{1*/ 858 859 void DataSet::FieldDepthAverageAtBase(Vec field,double* field_serial,char* fieldname){ 859 860 … … 872 873 } 873 874 /*}}}*/ 874 /*FUNCTION DataSet::FieldExtrude{{{ 2*/875 /*FUNCTION DataSet::FieldExtrude{{{1*/ 875 876 void DataSet::FieldExtrude(Vec field,double* field_serial,char* field_name, int collapse){ 876 877 … … 897 898 } 898 899 /*}}}*/ 899 /*FUNCTION DataSet::FlagClones{{{ 2*/900 /*FUNCTION DataSet::FlagClones{{{1*/ 900 901 void DataSet::FlagClones(int numberofobjects){ 901 902 … … 938 939 } 939 940 /*}}}*/ 940 /*FUNCTION DataSet::FlagNodeSets{{{ 2*/941 /*FUNCTION DataSet::FlagNodeSets{{{1*/ 941 942 void DataSet::FlagNodeSets(Vec pv_g, Vec pv_m, Vec pv_n, Vec pv_f, Vec pv_s){ 942 943 … … 975 976 } 976 977 /*}}}*/ 977 /*FUNCTION DataSet::Gradj{{{ 2*/978 /*FUNCTION DataSet::Gradj{{{1*/ 978 979 void DataSet::Gradj(Vec grad_g,int analysis_type,int sub_analysis_type,char* control_type){ 979 980 … … 994 995 } 995 996 /*}}}*/ 996 /*FUNCTION DataSet::MeltingIsPresent{{{ 2*/997 /*FUNCTION DataSet::MeltingIsPresent{{{1*/ 997 998 int DataSet::MeltingIsPresent(){ 998 999 … … 1019 1020 } 1020 1021 /*}}}*/ 1021 /*FUNCTION DataSet::MeltingConstraints{{{ 2*/1022 /*FUNCTION DataSet::MeltingConstraints{{{1*/ 1022 1023 void DataSet::MeltingConstraints(int* pconverged, int* pnum_unstable_constraints,int analysis_type,int sub_analysis_type){ 1023 1024 … … 1061 1062 } 1062 1063 /*}}}*/ 1063 /*FUNCTION DataSet::Misfit{{{ 2*/1064 /*FUNCTION DataSet::Misfit{{{1*/ 1064 1065 void DataSet::Misfit(double* pJ,int analysis_type,int sub_analysis_type){ 1065 1066 … … 1084 1085 } 1085 1086 /*}}}*/ 1086 /*FUNCTION DataSet::NumberOfDofs{{{ 2*/1087 /*FUNCTION DataSet::NumberOfDofs{{{1*/ 1087 1088 int DataSet::NumberOfDofs(){ 1088 1089 … … 1116 1117 } 1117 1118 /*}}}*/ 1118 /*FUNCTION DataSet::NumberOfRgbs{{{ 2*/1119 /*FUNCTION DataSet::NumberOfRgbs{{{1*/ 1119 1120 int DataSet::NumberOfRgbs(){ 1120 1121 … … 1136 1137 } 1137 1138 /*}}}*/ 1138 /*FUNCTION DataSet::OutputRifts{{{ 2*/1139 /*FUNCTION DataSet::OutputRifts{{{1*/ 1139 1140 void DataSet::OutputRifts(Vec riftproperties){ 1140 1141 … … 1155 1156 } 1156 1157 /*}}}*/ 1157 /*FUNCTION DataSet::PenaltyCreateKMatrix{{{ 2*/1158 /*FUNCTION DataSet::PenaltyCreateKMatrix{{{1*/ 1158 1159 void DataSet::PenaltyCreateKMatrix(Mat Kgg,double kmax,int analysis_type,int sub_analysis_type){ 1159 1160 … … 1172 1173 } 1173 1174 /*}}}*/ 1174 /*FUNCTION DataSet::PenaltyCreatePVector{{{ 2*/1175 /*FUNCTION DataSet::PenaltyCreatePVector{{{1*/ 1175 1176 void DataSet::PenaltyCreatePVector(Vec pg,double kmax,int analysis_type,int sub_analysis_type){ 1176 1177 … … 1189 1190 } 1190 1191 /*}}}*/ 1191 /*FUNCTION DataSet::RiftIsPresent{{{ 2*/1192 /*FUNCTION DataSet::RiftIsPresent{{{1*/ 1192 1193 int DataSet::RiftIsPresent(){ 1193 1194 … … 1217 1218 } 1218 1219 /*}}}*/ 1219 /*FUNCTION DataSet::SetupMpcs{{{ 2*/1220 /*FUNCTION DataSet::SetupMpcs{{{1*/ 1220 1221 void DataSet::SetupMpcs(Mat Rmg,DataSet* nodes){ 1221 1222 … … 1285 1286 } 1286 1287 /*}}}*/ 1287 /*FUNCTION DataSet::SetupSpcs{{{ 2*/1288 /*FUNCTION DataSet::SetupSpcs{{{1*/ 1288 1289 void DataSet::SetupSpcs(DataSet* nodes,Vec yg){ 1289 1290 … … 1324 1325 } 1325 1326 /*}}}*/ 1326 /*FUNCTION DataSet::SurfaceArea{{{ 2*/1327 /*FUNCTION DataSet::SurfaceArea{{{1*/ 1327 1328 void DataSet::SurfaceArea(double* pS,int analysis_type,int sub_analysis_type){ 1328 1329 1329 double S=0; ;1330 double S=0; 1330 1331 1331 1332 vector<Object*>::iterator object; … … 1347 1348 } 1348 1349 /*}}}*/ 1349 /*FUNCTION DataSet::UpdateInputsFromVector{{{2*/ 1350 void DataSet::UpdateInputsFromVector(double* vector, int name, int type){ 1351 1352 vector<Object*>::iterator object; 1350 /*FUNCTION DataSet::UpdateInputsFromSolution{{{1*/ 1351 void DataSet::UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ 1352 1353 vector<Object*>::iterator object; 1354 Element* element=NULL; 1355 1356 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1357 1358 if(EnumIsElement((*object)->Enum())){ 1359 1360 element=(Element*)(*object); 1361 element->UpdateInputsFromSolution(solution,analysis_type,sub_analysis_type); 1362 } 1363 else ISSMERROR("%s%i%s"," object with id: ",(*object)->Id()," is not an element, in a function that deals only with elements!"); 1364 } 1365 } 1366 /*}}}*/ 1367 /*FUNCTION DataSet::UpdateInputsFromVector{{{1*/ 1368 void DataSet::UpdateInputsFromVector(double* vec, int name, int type){ 1369 1370 vector<Object*>::iterator object; 1371 1353 1372 Element* element=NULL; 1354 1373 Node* node=NULL; … … 1356 1375 Load* load=NULL; 1357 1376 Material* material=NULL; 1358 Param* param=NULL :1377 Param* param=NULL; 1359 1378 1360 1379 for ( object=objects.begin() ; object < objects.end(); object++ ){ … … 1363 1382 1364 1383 element=(Element*)(*object); 1365 element->UpdateInputsFromVector(vec tor,name,type);1384 element->UpdateInputsFromVector(vec,name,type); 1366 1385 } 1367 1386 else if(((*object)->Enum()==NodeEnum)){ 1368 1387 1369 1388 node=(Node*)(*object); 1370 node->UpdateInputsFromVector(vec tor,name,type);1389 node->UpdateInputsFromVector(vec,name,type); 1371 1390 } 1372 1391 else if(((*object)->Enum()==VertexEnum)){ 1373 1392 1374 1393 vertex=(Vertex*)(*object); 1375 vertex->UpdateInputsFromVector(vec tor,name,type);1394 vertex->UpdateInputsFromVector(vec,name,type); 1376 1395 } 1377 1396 else if(EnumIsLoad((*object)->Enum())){ 1378 1397 1379 1398 load=(Load*)(*object); 1380 load->UpdateInputsFromVector(vec tor,name,type);1399 load->UpdateInputsFromVector(vec,name,type); 1381 1400 } 1382 1401 else if(EnumIsMaterial((*object)->Enum())){ 1383 1402 1384 1403 material=(Material*)(*object); 1385 material->UpdateInputsFromVector(vec tor,name,type);1404 material->UpdateInputsFromVector(vec,name,type); 1386 1405 } 1387 1406 else if(((*object)->Enum()==ParamEnum)){ 1388 1407 1389 1408 param=(Param*)(*object); 1390 param->UpdateInputsFromVector(vec tor,name,type);1409 param->UpdateInputsFromVector(vec,name,type); 1391 1410 } 1392 1411 else ISSMERROR("%s%i%s"," object with id: ",(*object)->Id()," is not an element, in a function that deals only with elements!"); … … 1394 1413 } 1395 1414 /*}}}*/ 1396 /*FUNCTION DataSet::UpdateInputsFromSolution{{{2*/ 1397 void DataSet::UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type){ 1398 1399 vector<Object*>::iterator object; 1400 Element* element=NULL; 1401 1402 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1403 1404 if(EnumIsElement((*object)->Enum())){ 1405 1406 element=(Element*)(*object); 1407 element->UpdateInputsFromSolution(solution,analysis_type,sub_analysis_type); 1408 } 1409 else ISSMERROR("%s%i%s"," object with id: ",(*object)->Id()," is not an element, in a function that deals only with elements!"); 1410 } 1411 } 1412 /*}}}*/ 1413 /*FUNCTION DataSet::AddInput{{{2*/ 1415 /*FUNCTION DataSet::AddInput{{{1*/ 1414 1416 void DataSet::AddInput(double value, int enum_type){ 1415 1417 … … 1428 1430 } 1429 1431 /*}}}*/ 1430 /*FUNCTION DataSet::UpdateVertexPositions{{{ 2*/1432 /*FUNCTION DataSet::UpdateVertexPositions{{{1*/ 1431 1433 void DataSet::UpdateVertexPositions(double* thickness,double* bed){ 1432 1434 … … 1444 1446 } 1445 1447 /*}}}*/ 1446 1447 /*}}}*/1448 /*Inputs: {{{1*/1449 1450 /*Object constructors and destructor*/1451 /*FUNCTION Inputs::Inputs(){{{2*/1452 Inputs::Inputs(){1453 return;1454 }1455 /*}}}*/1456 /*FUNCTION Inputs::Inputs(int in_enum){{{2*/1457 Inputs::Inputs(int in_enum): DataSet(in_enum) {1458 //do nothing;1459 return;1460 }1461 /*}}}*/1462 /*FUNCTION Inputs::~Inputs(){{{2*/1463 Inputs::~Inputs(){1464 return;1465 }1466 /*}}}*/1467 1468 /*Object management*/1469 /*FUNCTION Inputs::GetParameterValue(double* pvalue,double* gauss,int enum_type){{{2*/1470 void Inputs::GetParameterValue(double* pvalue,double* gauss, int enum_type){1471 1472 vector<Object*>::iterator object;1473 Input* input=NULL;1474 1475 /*Go through inputs and check whether any input with the same name is already in: */1476 for ( object=objects.begin() ; object < objects.end(); object++ ){1477 1478 input=(Input*)(*object);1479 if (input->EnumType()==enum_type)break;1480 }1481 1482 if (!input){1483 /*we could not find an input with the correct enum type. No defaults values were provided,1484 * error out: */1485 ISSMERROR("%s%i"," could not find input with enum type ",enum_type);1486 }1487 1488 /*Ok, we have an input if we made it here, request the input to return the values: */1489 input->GetParameterValue(pvalue,gauss);1490 1491 }1492 /*}}}*/1493 /*FUNCTION Inputs::GetParameterValue(double* pvalue,double* gauss,int enum_type,double defaultvalue){{{2*/1494 void Inputs::GetParameterValue(double* pvalue,double* gauss, int enum_type,double defaultvalue){1495 1496 vector<Object*>::iterator object;1497 Input* input=NULL;1498 1499 /*Go through inputs and check whether any input with the same name is already in: */1500 for ( object=objects.begin() ; object < objects.end(); object++ ){1501 1502 input=(Input*)(*object);1503 if (input->EnumType()==enum_type)break;1504 }1505 1506 if (!input){1507 /*we could not find an input with the correct enum type. Return the default value: */1508 *pvalue=defaultvalue;1509 }1510 else{1511 input->GetParameterValue(pvalue,gauss);1512 }1513 }1514 /*}}}*/1515 /*FUNCTION Inputs::GetParameterValues(double* values,double* gauss_pointers, int numgauss,int enum_type){{{2*/1516 void Inputs::GetParameterValues(double* values,double* gauss_pointers, int numgauss,int enum_type){1517 1518 vector<Object*>::iterator object;1519 Input* input=NULL;1520 1521 /*Go through inputs and check whether any input with the same name is already in: */1522 for ( object=objects.begin() ; object < objects.end(); object++ ){1523 1524 input=(Input*)(*object);1525 if (input->EnumType()==enum_type)break;1526 }1527 1528 if (!input){1529 /*we could not find an input with the correct enum type. No defaults values were provided,1530 * error out: */1531 ISSMERROR("%s%i"," could not find input with enum type ",enum_type);1532 }1533 1534 /*Ok, we have an input if we made it here, request the input to return the values: */1535 input->GetParameterValues(values,gauss_pointers,numgauss);1536 1537 }1538 /*}}}*/1539 /*FUNCTION Inputs::GetParameterValue(double* pvalue, Node* node, int enum_type){{{2*/1540 void Inputs::GetParameterValue(double* pvalue,Node* node,int enum_type){1541 1542 /*given a node, instead of a gauss point, we want to recover a value: probably in an element!: */1543 1544 vector<Object*>::iterator object;1545 Input* input=NULL;1546 1547 /*Go through inputs and check whether any input with the same name is already in: */1548 for ( object=objects.begin() ; object < objects.end(); object++ ){1549 1550 input=(Input*)(*object);1551 if (input->EnumType()==enum_type)break;1552 }1553 1554 if (!input){1555 /*we could not find an input with the correct enum type. No defaults values were provided,1556 * error out: */1557 ISSMERROR("%s%i"," could not find input with enum type ",enum_type);1558 }1559 1560 /*Ok, we have an input if we made it here, request the input to return the values: */1561 input->GetParameterValue(pvalue,node);1562 }1563 /*}}}*/1564 /*FUNCTION Inputs::GetParameterValue(double* pvalue, Node* node1, Node* node2,int enum_type){{{2*/1565 void Inputs::GetParameterValue(double* pvalue,Node* node1, Node* node2,double gauss_coord,int enum_type){1566 1567 /*given a node, instead of a gauss point, we want to recover a value: probably in an element!: */1568 1569 vector<Object*>::iterator object;1570 Input* input=NULL;1571 1572 /*Go through inputs and check whether any input with the same name is already in: */1573 for ( object=objects.begin() ; object < objects.end(); object++ ){1574 1575 input=(Input*)(*object);1576 if (input->EnumType()==enum_type)break;1577 }1578 1579 if (!input){1580 /*we could not find an input with the correct enum type. No defaults values were provided,1581 * error out: */1582 ISSMERROR("%s%i"," could not find input with enum type ",enum_type);1583 }1584 1585 /*Ok, we have an input if we made it here, request the input to return the values: */1586 input->GetParameterValue(pvalue,node1,node2,gauss_coord);1587 }1588 /*}}}*/1589 /*FUNCTION Inputs::GetParameterValues(double* values,double* gauss_pointers, int numgauss,int enum_type,double* defaultvalues){{{2*/1590 void Inputs::GetParameterValues(double* values,double* gauss_pointers, int numgauss,int enum_type,double* defaultvalues){1591 1592 int i;1593 vector<Object*>::iterator object;1594 Input* input=NULL;1595 1596 /*Go through inputs and check whether any input with the same name is already in: */1597 for ( object=objects.begin() ; object < objects.end(); object++ ){1598 1599 input=(Input*)(*object);1600 if (input->EnumType()==enum_type)break;1601 }1602 1603 if (!input){1604 /*we could not find an input with the correct enum type. Return the default values: */1605 for(i=0;i<numgauss;i++)values[i]=defaultvalues[i];1606 }1607 else{1608 input->GetParameterValues(values,gauss_pointers,numgauss);1609 }1610 1611 }1612 /*}}}*/1613 /*FUNCTION Inputs::GetParameterValue(bool* pvalue,int enum-type){{{2*/1614 void Inputs::GetParameterValue(bool* pvalue,int enum_type){1615 1616 vector<Object*>::iterator object;1617 Input* input=NULL;1618 1619 /*Go through inputs and check whether any input with the same name is already in: */1620 for ( object=objects.begin() ; object < objects.end(); object++ ){1621 1622 input=(Input*)(*object);1623 if (input->EnumType()==enum_type)break;1624 }1625 1626 if (!input){1627 /*we could not find an input with the correct enum type. No defaults values were provided,1628 * error out: */1629 ISSMERROR("%s%i"," could not find input with enum type ",enum_type);1630 }1631 1632 /*Ok, we have an input if we made it here, request the input to return the value: */1633 input->GetParameterValue(pvalue);1634 1635 }1636 /*}}}*/1637 /*FUNCTION Inputs::GetParameterValue(int* pvalue,int enum-type){{{2*/1638 void Inputs::GetParameterValue(int* pvalue,int enum_type){1639 1640 vector<Object*>::iterator object;1641 Input* input=NULL;1642 1643 /*Go through inputs and check whether any input with the same name is already in: */1644 for ( object=objects.begin() ; object < objects.end(); object++ ){1645 1646 input=(Input*)(*object);1647 if (input->EnumType()==enum_type)break;1648 }1649 1650 if (!input){1651 /*we could not find an input with the correct enum type. No defaults values were provided,1652 * error out: */1653 ISSMERROR("%s%i"," could not find input with enum type ",enum_type);1654 }1655 1656 /*Ok, we have an input if we made it here, request the input to return the value: */1657 input->GetParameterValue(pvalue);1658 1659 }1660 /*}}}*/1661 /*FUNCTION Inputs::GetParameterValue(double* pvalue,int enum-type){{{2*/1662 void Inputs::GetParameterValue(double* pvalue,int enum_type){1663 1664 vector<Object*>::iterator object;1665 Input* input=NULL;1666 1667 /*Go through inputs and check whether any input with the same name is already in: */1668 for ( object=objects.begin() ; object < objects.end(); object++ ){1669 1670 input=(Input*)(*object);1671 if (input->EnumType()==enum_type)break;1672 }1673 1674 if (!input){1675 /*we could not find an input with the correct enum type. No defaults values were provided,1676 * error out: */1677 ISSMERROR("%s%i"," could not find input with enum type ",enum_type);1678 }1679 1680 /*Ok, we have an input if we made it here, request the input to return the value: */1681 input->GetParameterValue(pvalue);1682 1683 }1684 /*}}}*/1685 /*FUNCTION Inputs::GetParameterDerivativeValue(double* derivativevalues, double* xyz_list, double* gauss,int enum_type){{{2*/1686 void Inputs::GetParameterDerivativeValue(double* derivativevalues, double* xyz_list, double* gauss,int enum_type){1687 1688 vector<Object*>::iterator object;1689 Input* input=NULL;1690 1691 /*Go through inputs and check whether any input with the same name is already in: */1692 for ( object=objects.begin() ; object < objects.end(); object++ ){1693 1694 input=(Input*)(*object);1695 if (input->EnumType()==enum_type)break;1696 }1697 1698 if (!input){1699 /*we could not find an input with the correct enum type. No defaults values were provided,1700 * error out: */1701 ISSMERROR("%s%i"," could not find input with enum type ",enum_type);1702 }1703 1704 /*Ok, we have an input if we made it here, request the input to return the value: */1705 input->GetParameterDerivativeValue(derivativevalues,xyz_list,gauss);1706 }1707 /*}}}*/1708 /*FUNCTION Inputs::GetStrainRate(double* epsilon,double* xyz_list, double* gauss, int xenum, int yenum){{{2*/1709 void Inputs::GetStrainRate(double* epsilon,double* xyz_list, double* gauss, int xenum, int yenum){1710 1711 vector<Object*>::iterator object;1712 Input* xinput=NULL;1713 Input* yinput=NULL;1714 1715 /*Go through inputs and find data for xenum: */1716 for ( object=objects.begin() ; object < objects.end(); object++ ){1717 xinput=(Input*)(*object);1718 if (xinput->EnumType()==xenum)break;1719 }1720 /*Go through inputs and find data for yenum: */1721 for ( object=objects.begin() ; object < objects.end(); object++ ){1722 yinput=(Input*)(*object);1723 if (yinput->EnumType()==yenum)break;1724 }1725 1726 if (!xinput | !yinput){1727 /*we could not find one input with the correct enum type. No defaults values were provided,1728 * error out: */1729 ISSMERROR("%s%i%s%i\n"," could not find input with enum type ",xenum," or enum type ",yenum);1730 }1731 1732 /*Ok, we have the inputs, call bilinear operator: */1733 xinput->GetStrainRate(epsilon,yinput,xyz_list,gauss);1734 1735 }1736 /*}}}*/1737 /*FUNCTION Inputs::GetStrainRateStokes(double* epsilon,double* xyz_list, double* gauss, int xenum, int yenum,int zenum){{{2*/1738 void Inputs::GetStrainRateStokes(double* epsilon,double* xyz_list, double* gauss, int xenum, int yenum,int zenum){1739 1740 vector<Object*>::iterator object;1741 Input* xinput=NULL;1742 Input* yinput=NULL;1743 Input* zinput=NULL;1744 1745 /*Go through inputs and find data for xenum: */1746 for ( object=objects.begin() ; object < objects.end(); object++ ){1747 xinput=(Input*)(*object);1748 if (xinput->EnumType()==xenum)break;1749 }1750 /*Go through inputs and find data for yenum: */1751 for ( object=objects.begin() ; object < objects.end(); object++ ){1752 yinput=(Input*)(*object);1753 if (yinput->EnumType()==yenum)break;1754 }1755 /*Go through inputs and find data for zenum: */1756 for ( object=objects.begin() ; object < objects.end(); object++ ){1757 zinput=(Input*)(*object);1758 if (zinput->EnumType()==zenum)break;1759 }1760 1761 if (!xinput | !yinput | !zinput){1762 /*we could not find one input with the correct enum type. No defaults values were provided,1763 * error out: */1764 ISSMERROR("%s%i%s%i%s%i\n"," could not find input with enum type ",xenum," or enum type ",yenum, " or enum type ",zenum);1765 }1766 1767 /*Ok, we have the inputs, call bilinear operator: */1768 xinput->GetStrainRateStokes(epsilon,yinput,zinput,xyz_list,gauss);1769 1770 }1771 /*}}}*/1772 /*FUNCTION Inputs::AddInput{{{2*/1773 int Inputs::AddInput(Input* in_input){1774 1775 /*First, go through dataset of inputs and check whether any input1776 * with the same name is already in. If so, erase the corresponding1777 * object before adding this new one: */1778 vector<Object*>::iterator object;1779 Input* input=NULL;1780 1781 for ( object=objects.begin() ; object < objects.end(); object++ ){1782 1783 input=(Input*)(*object);1784 1785 if (input->EnumType()==in_input->EnumType()){1786 this->DeleteObject(input);1787 break;1788 }1789 }1790 this->AddObject(in_input);1791 }1792 /*}}}*/1793 1794 /*Object functions*/1795 1796 1797 /*}}}*/1798 /*Parameters: {{{1*/1799 1800 1801 /*Object constructors and destructor*/1802 /*FUNCTION Parameters::Parameters(){{{2*/1803 Parameters::Parameters(){1804 return;1805 }1806 /*}}}*/1807 /*FUNCTION Parameters::Parameters(int in_enum){{{2*/1808 Parameters::Parameters(int in_enum): DataSet(in_enum){1809 //do nothing;1810 return;1811 }1812 /*}}}*/1813 /*FUNCTION Parameters::~Parameters(){{{2*/1814 Parameters::~Parameters(){1815 return;1816 }1817 /*}}}*/1818 1819 /*Object management*/1820 /*FUNCTION Parameters::FindParam(double* pscalar, int enum_type){{{2*/1821 int Parameters::FindParam(double* pscalar, int enum_type){1822 1823 /*Go through a dataset, and find a Param* object1824 *which parameter name is "name" : */1825 1826 vector<Object*>::iterator object;1827 Param* param=NULL;1828 1829 int found=0;1830 1831 for ( object=objects.begin() ; object < objects.end(); object++ ){1832 1833 /*Find param type objects: */1834 if((*object)->Enum()==ParamEnum){1835 1836 /*Ok, this object is a parameter, recover it and ask which name it has: */1837 param=(Param*)(*object);1838 1839 if(param->EnumType()==enum_type){1840 /*Ok, this is the one! Recover the value of this parameter: */1841 param->GetParameterValue(pscalar);1842 found=1;1843 break;1844 }1845 }1846 }1847 return found;1848 }1849 /*}}}*/1850 /*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{2*/1851 int Parameters::FindParam(int* pinteger,int enum_type){1852 1853 1854 /*Go through a dataset, and find a Param* object1855 *which parameter name is "name" : */1856 1857 vector<Object*>::iterator object;1858 Param* param=NULL;1859 1860 int found=0;1861 1862 for ( object=objects.begin() ; object < objects.end(); object++ ){1863 1864 /*Find param type objects: */1865 if((*object)->Enum()==ParamEnum){1866 1867 /*Ok, this object is a parameter, recover it and ask which name it has: */1868 param=(Param*)(*object);1869 1870 if(param->EnumType()==enum_type){1871 /*Ok, this is the one! Recover the value of this parameter: */1872 param->GetParameterValue(pinteger);1873 found=1;1874 break;1875 }1876 }1877 }1878 return found;1879 }1880 /*}}}*/1881 /*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{2*/1882 int Parameters::FindParam(char** pstring,int enum_type){1883 1884 /*Go through a dataset, and find a Param* object1885 *which parameter name is "name" : */1886 1887 vector<Object*>::iterator object;1888 Param* param=NULL;1889 1890 int found=0;1891 1892 for ( object=objects.begin() ; object < objects.end(); object++ ){1893 1894 /*Find param type objects: */1895 if((*object)->Enum()==ParamEnum){1896 1897 /*Ok, this object is a parameter, recover it and ask which name it has: */1898 param=(Param*)(*object);1899 1900 if(param->EnumType()==enum_type){1901 /*Ok, this is the one! Recover the value of this parameter: */1902 param->GetParameterValue(pstring);1903 found=1;1904 break;1905 }1906 }1907 }1908 return found;1909 1910 }1911 /*}}}*/1912 /*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{2*/1913 int Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){1914 1915 /*Go through a dataset, and find a Param* object1916 *which parameter name is "name" : */1917 1918 vector<Object*>::iterator object;1919 Param* param=NULL;1920 1921 int found=0;1922 1923 for ( object=objects.begin() ; object < objects.end(); object++ ){1924 1925 /*Find param type objects: */1926 if((*object)->Enum()==ParamEnum){1927 1928 /*Ok, this object is a parameter, recover it and ask which name it has: */1929 param=(Param*)(*object);1930 1931 if(param->EnumType()==enum_type){1932 /*Ok, this is the one! Recover the value of this parameter: */1933 param->GetParameterValue(pstringarray,pM);1934 found=1;1935 break;1936 }1937 }1938 }1939 return found;1940 1941 }1942 /*}}}*/1943 /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM,int enum_type){{{2*/1944 int Parameters::FindParam(double** pdoublearray,int* pM, int enum_type){1945 1946 /*Go through a dataset, and find a Param* object1947 *which parameter name is "name" : */1948 1949 vector<Object*>::iterator object;1950 Param* param=NULL;1951 1952 int found=0;1953 1954 for ( object=objects.begin() ; object < objects.end(); object++ ){1955 1956 /*Find param type objects: */1957 if((*object)->Enum()==ParamEnum){1958 1959 /*Ok, this object is a parameter, recover it and ask which name it has: */1960 param=(Param*)(*object);1961 1962 if(param->EnumType()==enum_type){1963 /*Ok, this is the one! Recover the value of this parameter: */1964 param->GetParameterValue(pdoublearray,pM);1965 found=1;1966 break;1967 }1968 }1969 }1970 return found;1971 1972 }1973 /*}}}*/1974 /*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){{{2*/1975 int Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){1976 1977 /*Go through a dataset, and find a Param* object1978 *which parameter name is "name" : */1979 1980 vector<Object*>::iterator object;1981 Param* param=NULL;1982 1983 int found=0;1984 1985 for ( object=objects.begin() ; object < objects.end(); object++ ){1986 1987 /*Find param type objects: */1988 if((*object)->Enum()==ParamEnum){1989 1990 /*Ok, this object is a parameter, recover it and ask which name it has: */1991 param=(Param*)(*object);1992 1993 if(param->EnumType()==enum_type){1994 /*Ok, this is the one! Recover the value of this parameter: */1995 param->GetParameterValue(pdoublearray,pM,pN);1996 found=1;1997 break;1998 }1999 }2000 }2001 return found;2002 2003 }2004 /*}}}*/2005 /*FUNCTION Parameters::FindParam(Vec* pvec,int enum_type){{{2*/2006 int Parameters::FindParam(Vec* pvec,int enum_type){2007 2008 /*Go through a dataset, and find a Param* object2009 *which parameter name is "name" : */2010 2011 vector<Object*>::iterator object;2012 Param* param=NULL;2013 2014 int found=0;2015 2016 for ( object=objects.begin() ; object < objects.end(); object++ ){2017 2018 /*Find param type objects: */2019 if((*object)->Enum()==ParamEnum){2020 2021 /*Ok, this object is a parameter, recover it and ask which name it has: */2022 param=(Param*)(*object);2023 2024 if(param->EnumType()==enum_type){2025 /*Ok, this is the one! Recover the value of this parameter: */2026 param->GetParameterValue(pvec);2027 found=1;2028 break;2029 }2030 }2031 }2032 return found;2033 2034 }2035 /*}}}*/2036 /*FUNCTION Parameters::FindParamMat* pmat,int enum_type){{{2*/2037 int Parameters::FindParam(Mat* pmat,int enum_type){2038 2039 /*Go through a dataset, and find a Param* object2040 *which parameter name is "name" : */2041 2042 vector<Object*>::iterator object;2043 Param* param=NULL;2044 2045 int found=0;2046 2047 for ( object=objects.begin() ; object < objects.end(); object++ ){2048 2049 /*Find param type objects: */2050 if((*object)->Enum()==ParamEnum){2051 2052 /*Ok, this object is a parameter, recover it and ask which name it has: */2053 param=(Param*)(*object);2054 2055 if(param->EnumType()==enum_type){2056 /*Ok, this is the one! Recover the value of this parameter: */2057 param->GetParameterValue(pmat);2058 found=1;2059 break;2060 }2061 }2062 }2063 return found;2064 2065 }2066 /*}}}*/2067 /*FUNCTION Parameters::FindParamObject{{{2*/2068 Object* Parameters::FindParamObject(int enum_type){2069 2070 /*Go through a dataset, and find a Param* object2071 *which parameter name is "name" : */2072 2073 vector<Object*>::iterator object;2074 Param* param=NULL;2075 2076 for ( object=objects.begin() ; object < objects.end(); object++ ){2077 2078 /*Find param type objects: */2079 if((*object)->Enum()==ParamEnum){2080 2081 /*Ok, this object is a parameter, recover it and ask which name it has: */2082 param=(Param*)(*object);2083 2084 if(param->EnumType()==enum_type){2085 /*Ok, this is the one! Return the object: */2086 return (*object);2087 }2088 }2089 }2090 return NULL;2091 }2092 /*}}}*/2093 2094 /*Object functions*/2095 2096 2097 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.