Changeset 3702


Ignore:
Timestamp:
05/11/10 08:28:18 (15 years ago)
Author:
Eric.Larour
Message:

Back to splitting the files

Location:
issm/trunk/src/c/DataSet
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/DataSet/DataSet.cpp

    r3699 r3702  
    1717
    1818#include "./DataSet.h"
     19#include "../objects/objects.h"
    1920#include "../shared/shared.h"
    2021#include "../include/macros.h"
     
    2324using namespace std;
    2425/*}}}*/
    25 /*DataSet: {{{1*/
     26
    2627/*Constructors/Destructors*/
    27 /*FUNCTION DataSet::DataSet(){{{2*/
     28/*FUNCTION DataSet::DataSet(){{{1*/
    2829DataSet::DataSet(){
    2930       
     
    3435}
    3536/*}}}*/
    36 /*FUNCTION DataSet::DataSet(int dataset_enum){{{2*/
     37/*FUNCTION DataSet::DataSet(int dataset_enum){{{1*/
    3738DataSet::DataSet(int dataset_enum){
    3839        enum_type=dataset_enum;
     
    4445}
    4546/*}}}*/
    46 /*FUNCTION DataSet::Copy{{{2*/
     47/*FUNCTION DataSet::Copy{{{1*/
    4748DataSet*   DataSet::Copy(void){
    4849
     
    7576}
    7677/*}}}*/
    77 /*FUNCTION DataSet::~DataSet{{{2*/
     78/*FUNCTION DataSet::~DataSet{{{1*/
    7879DataSet::~DataSet(){
    7980        clear();
     
    8485
    8586/*I/O*/
    86 /*FUNCTION DataSet::Marshall{{{2*/
     87/*FUNCTION DataSet::Marshall{{{1*/
    8788char* DataSet::Marshall(){
    8889
     
    131132}
    132133/*}}}*/
    133 /*FUNCTION DataSet::MarshallSize{{{2*/
     134/*FUNCTION DataSet::MarshallSize{{{1*/
    134135int DataSet::MarshallSize(){
    135136
     
    152153}
    153154/*}}}*/
    154 /*FUNCTION DataSet::Demarshall{{{2*/
     155/*FUNCTION DataSet::Demarshall{{{1*/
    155156DataSet* DataSetDemarshall(char* marshalled_dataset){
    156157
     
    159160}
    160161/*}}}*/
    161 /*FUNCTION DataSet::DemarshallRaw{{{2*/
     162/*FUNCTION DataSet::DemarshallRaw{{{1*/
    162163DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset){
    163164
     
    311312}
    312313/*}}}*/
    313 /*FUNCTION DataSet::Spawn{{{2*/
     314/*FUNCTION DataSet::Spawn{{{1*/
    314315DataSet* DataSet::Spawn(int* indices, int num){
    315316        ISSMERROR(" not supported yet!");
     
    318319
    319320/*Specific methods*/
    320 /*FUNCTION DataSet::AddObject{{{2*/
     321/*FUNCTION DataSet::AddObject{{{1*/
    321322int  DataSet::AddObject(Object* object){
    322323
     
    326327}
    327328/*}}}*/
    328 /*FUNCTION DataSet::clear{{{2*/
     329/*FUNCTION DataSet::clear{{{1*/
    329330void  DataSet::clear(){
    330331
     
    337338}
    338339/*}}}*/
    339 /*FUNCTION DataSet::DeleteObject{{{2*/
     340/*FUNCTION DataSet::DeleteObject{{{1*/
    340341int  DataSet::DeleteObject(Object* object){
    341342
     
    350351}
    351352/*}}}*/
    352 /*FUNCTION DataSet::DeepEcho{{{2*/
     353/*FUNCTION DataSet::DeepEcho{{{1*/
    353354void DataSet::DeepEcho(){
    354355
     
    369370}
    370371/*}}}*/
    371 /*FUNCTION DataSet::Echo{{{2*/
     372/*FUNCTION DataSet::Echo{{{1*/
    372373void DataSet::Echo(){
    373374
     
    388389}
    389390/*}}}*/
    390 /*FUNCTION DataSet::FindResult(Vec* presult,char* name){{{2*/
     391/*FUNCTION DataSet::FindResult(Vec* presult,char* name){{{1*/
    391392int   DataSet::FindResult(Vec* presult,char* name){
    392393
     
    418419}
    419420/*}}}*/
    420 /*FUNCTION DataSet::FindResult(void* pvalue, char* name){{{2*/
     421/*FUNCTION DataSet::FindResult(void* pvalue, char* name){{{1*/
    421422int   DataSet::FindResult(void* pvalue, char* name){
    422423
     
    450451}
    451452/*}}}*/
    452 /*FUNCTION DataSet::GetEnum{{{2*/
     453/*FUNCTION DataSet::GetEnum{{{1*/
    453454int  DataSet::GetEnum(){
    454455        return enum_type;
    455456}
    456457/*}}}*/
    457 /*FUNCTION DataSet::GetEnum(int offset){{{2*/
     458/*FUNCTION DataSet::GetEnum(int offset){{{1*/
    458459int   DataSet::GetEnum(int offset){
    459460
     
    462463}
    463464/*}}}*/
    464 /*FUNCTION DataSet::GetObjectByOffset{{{2*/
     465/*FUNCTION DataSet::GetObjectByOffset{{{1*/
    465466Object* DataSet::GetObjectByOffset(int offset){
    466467
     
    469470}
    470471/*}}}*/
    471 /*FUNCTION DataSet::GetObjectById{{{2*/
     472/*FUNCTION DataSet::GetObjectById{{{1*/
    472473Object* DataSet::GetObjectById(int* poffset,int eid){
    473474
     
    493494}
    494495/*}}}*/
    495 /*FUNCTION DataSet::Ranks{{{2*/
     496/*FUNCTION DataSet::Ranks{{{1*/
    496497void   DataSet::Ranks(int* ranks){
    497498
     
    516517}
    517518/*}}}*/
    518 /*FUNCTION DataSet::Presort{{{2*/
     519/*FUNCTION DataSet::Presort{{{1*/
    519520void DataSet::Presort(){
    520521
     
    536537}
    537538/*}}}*/
    538 /*FUNCTION DataSet::SetSorting{{{2*/
     539/*FUNCTION DataSet::SetSorting{{{1*/
    539540void DataSet::SetSorting(int* in_sorted_ids,int* in_id_offsets){
    540541
     
    544545}
    545546/*}}}*/
    546 /*FUNCTION DataSet::Size{{{2*/
     547/*FUNCTION DataSet::Size{{{1*/
    547548int  DataSet::Size(void){
    548549
     
    550551}
    551552/*}}}*/
    552 /*FUNCTION DataSet::Sort{{{2*/
     553/*FUNCTION DataSet::Sort{{{1*/
    553554void DataSet::Sort(){
    554555
     
    561562
    562563/*Objects methods*/
    563 /*FUNCTION DataSet::ComputeBasalStress{{{2*/
     564/*FUNCTION DataSet::ComputeBasalStress{{{1*/
    564565void DataSet::ComputeBasalStress(Vec sigma_b,int analysis_type,int sub_analysis_type){
    565566
     
    578579}
    579580/*}}}*/
    580 /*FUNCTION DataSet::ComputePressure{{{2*/
     581/*FUNCTION DataSet::ComputePressure{{{1*/
    581582void DataSet::ComputePressure(Vec p_g,int analysis_type,int sub_analysis_type){
    582583
     
    595596}
    596597/*}}}*/
    597 /*FUNCTION DataSet::ComputeStrainRate{{{2*/
     598/*FUNCTION DataSet::ComputeStrainRate{{{1*/
    598599void DataSet::ComputeStrainRate(Vec eps,int analysis_type,int sub_analysis_type){
    599600
     
    612613}
    613614/*}}}*/
    614 /*FUNCTION DataSet::Configure{{{2*/
     615/*FUNCTION DataSet::Configure{{{1*/
    615616void DataSet::Configure(DataSet* elements,DataSet* loads, DataSet* nodes, DataSet* vertices, DataSet* materials,Parameters* parameters){
    616617
     
    640641}
    641642/*}}}*/
    642 /*FUNCTION DataSet::CostFunction{{{2*/
     643/*FUNCTION DataSet::CostFunction{{{1*/
    643644void  DataSet::CostFunction(double* pJ,int analysis_type,int sub_analysis_type){
    644645
     
    663664}
    664665/*}}}*/
    665 /*FUNCTION DataSet::CreateKMatrix{{{2*/
     666/*FUNCTION DataSet::CreateKMatrix{{{1*/
    666667void  DataSet::CreateKMatrix(Mat Kgg,int analysis_type,int sub_analysis_type){
    667668
     
    686687}
    687688/*}}}*/
    688 /*FUNCTION DataSet::CreatePartitioningVector{{{2*/
     689/*FUNCTION DataSet::CreatePartitioningVector{{{1*/
    689690void  DataSet::CreatePartitioningVector(Vec* ppartition,int numberofobjects){
    690691
     
    714715}
    715716/*}}}*/
    716 /*FUNCTION DataSet::CreatePVector{{{2*/
     717/*FUNCTION DataSet::CreatePVector{{{1*/
    717718void  DataSet::CreatePVector(Vec pg,int analysis_type,int sub_analysis_type){
    718719
     
    737738}
    738739/*}}}*/
    739 /*FUNCTION DataSet::DistributeDofs{{{2*/
     740/*FUNCTION DataSet::DistributeDofs{{{1*/
    740741void  DataSet::DistributeDofs(int numberofobjects,int numberofdofsperobject){
    741742
     
    819820}
    820821/*}}}*/
    821 /*FUNCTION DataSet::Du{{{2*/
     822/*FUNCTION DataSet::Du{{{1*/
    822823void  DataSet::Du(Vec du_g,int analysis_type,int sub_analysis_type){
    823824
     
    838839}
    839840/*}}}*/
    840 /*FUNCTION DataSet::FieldAverageOntoVertices{{{2*/
     841/*FUNCTION DataSet::FieldAverageOntoVertices{{{1*/
    841842void DataSet::FieldAverageOntoVertices(Vec fieldsum,Vec connectivity,double* field){
    842843
     
    855856}
    856857/*}}}*/
    857 /*FUNCTION DataSet::FieldDepthAverageAtBase{{{2*/
     858/*FUNCTION DataSet::FieldDepthAverageAtBase{{{1*/
    858859void  DataSet::FieldDepthAverageAtBase(Vec field,double* field_serial,char* fieldname){
    859860
     
    872873}
    873874/*}}}*/
    874 /*FUNCTION DataSet::FieldExtrude{{{2*/
     875/*FUNCTION DataSet::FieldExtrude{{{1*/
    875876void  DataSet::FieldExtrude(Vec field,double* field_serial,char* field_name, int collapse){
    876877
     
    897898}
    898899/*}}}*/
    899 /*FUNCTION DataSet::FlagClones{{{2*/
     900/*FUNCTION DataSet::FlagClones{{{1*/
    900901void  DataSet::FlagClones(int numberofobjects){
    901902
     
    938939}
    939940/*}}}*/
    940 /*FUNCTION DataSet::FlagNodeSets{{{2*/
     941/*FUNCTION DataSet::FlagNodeSets{{{1*/
    941942void DataSet::FlagNodeSets(Vec pv_g, Vec pv_m, Vec pv_n, Vec pv_f, Vec pv_s){
    942943
     
    975976}
    976977/*}}}*/
    977 /*FUNCTION DataSet::Gradj{{{2*/
     978/*FUNCTION DataSet::Gradj{{{1*/
    978979void  DataSet::Gradj(Vec grad_g,int analysis_type,int sub_analysis_type,char* control_type){
    979980
     
    994995}               
    995996/*}}}*/
    996 /*FUNCTION DataSet::MeltingIsPresent{{{2*/
     997/*FUNCTION DataSet::MeltingIsPresent{{{1*/
    997998int   DataSet::MeltingIsPresent(){
    998999
     
    10191020}
    10201021/*}}}*/
    1021 /*FUNCTION DataSet::MeltingConstraints{{{2*/
     1022/*FUNCTION DataSet::MeltingConstraints{{{1*/
    10221023void  DataSet::MeltingConstraints(int* pconverged, int* pnum_unstable_constraints,int analysis_type,int sub_analysis_type){
    10231024
     
    10611062}
    10621063/*}}}*/
    1063 /*FUNCTION DataSet::Misfit{{{2*/
     1064/*FUNCTION DataSet::Misfit{{{1*/
    10641065void  DataSet::Misfit(double* pJ,int analysis_type,int sub_analysis_type){
    10651066
     
    10841085}
    10851086/*}}}*/
    1086 /*FUNCTION DataSet::NumberOfDofs{{{2*/
     1087/*FUNCTION DataSet::NumberOfDofs{{{1*/
    10871088int   DataSet::NumberOfDofs(){
    10881089
     
    11161117}
    11171118/*}}}*/
    1118 /*FUNCTION DataSet::NumberOfRgbs{{{2*/
     1119/*FUNCTION DataSet::NumberOfRgbs{{{1*/
    11191120int   DataSet::NumberOfRgbs(){
    11201121
     
    11361137}
    11371138/*}}}*/
    1138 /*FUNCTION DataSet::OutputRifts{{{2*/
     1139/*FUNCTION DataSet::OutputRifts{{{1*/
    11391140void  DataSet::OutputRifts(Vec riftproperties){
    11401141
     
    11551156}
    11561157/*}}}*/
    1157 /*FUNCTION DataSet::PenaltyCreateKMatrix{{{2*/
     1158/*FUNCTION DataSet::PenaltyCreateKMatrix{{{1*/
    11581159void  DataSet::PenaltyCreateKMatrix(Mat Kgg,double kmax,int analysis_type,int sub_analysis_type){
    11591160
     
    11721173}
    11731174/*}}}*/
    1174 /*FUNCTION DataSet::PenaltyCreatePVector{{{2*/
     1175/*FUNCTION DataSet::PenaltyCreatePVector{{{1*/
    11751176void  DataSet::PenaltyCreatePVector(Vec pg,double kmax,int analysis_type,int sub_analysis_type){
    11761177
     
    11891190}
    11901191/*}}}*/
    1191 /*FUNCTION DataSet::RiftIsPresent{{{2*/
     1192/*FUNCTION DataSet::RiftIsPresent{{{1*/
    11921193int   DataSet::RiftIsPresent(){
    11931194
     
    12171218}
    12181219/*}}}*/
    1219 /*FUNCTION DataSet::SetupMpcs{{{2*/
     1220/*FUNCTION DataSet::SetupMpcs{{{1*/
    12201221void DataSet::SetupMpcs(Mat Rmg,DataSet* nodes){
    12211222
     
    12851286}
    12861287/*}}}*/
    1287 /*FUNCTION DataSet::SetupSpcs{{{2*/
     1288/*FUNCTION DataSet::SetupSpcs{{{1*/
    12881289void   DataSet::SetupSpcs(DataSet* nodes,Vec yg){
    12891290
     
    13241325}
    13251326/*}}}*/
    1326 /*FUNCTION DataSet::SurfaceArea{{{2*/
     1327/*FUNCTION DataSet::SurfaceArea{{{1*/
    13271328void  DataSet::SurfaceArea(double* pS,int analysis_type,int sub_analysis_type){
    13281329
    1329         double S=0;;
     1330        double S=0;
    13301331
    13311332        vector<Object*>::iterator object;
     
    13471348}
    13481349/*}}}*/
    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*/
     1351void  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*/
     1368void  DataSet::UpdateInputsFromVector(double* vec, int name, int type){
     1369
     1370        vector<Object*>::iterator object;
     1371       
    13531372        Element* element=NULL;
    13541373        Node* node=NULL;
     
    13561375        Load* load=NULL;
    13571376        Material* material=NULL;
    1358         Param* param=NULL:
     1377        Param* param=NULL;
    13591378
    13601379        for ( object=objects.begin() ; object < objects.end(); object++ ){
     
    13631382
    13641383                        element=(Element*)(*object);
    1365                         element->UpdateInputsFromVector(vector,name,type);
     1384                        element->UpdateInputsFromVector(vec,name,type);
    13661385                }
    13671386                else if(((*object)->Enum()==NodeEnum)){
    13681387
    13691388                        node=(Node*)(*object);
    1370                         node->UpdateInputsFromVector(vector,name,type);
     1389                        node->UpdateInputsFromVector(vec,name,type);
    13711390                }
    13721391                else if(((*object)->Enum()==VertexEnum)){
    13731392
    13741393                        vertex=(Vertex*)(*object);
    1375                         vertex->UpdateInputsFromVector(vector,name,type);
     1394                        vertex->UpdateInputsFromVector(vec,name,type);
    13761395                }
    13771396                else if(EnumIsLoad((*object)->Enum())){
    13781397
    13791398                        load=(Load*)(*object);
    1380                         load->UpdateInputsFromVector(vector,name,type);
     1399                        load->UpdateInputsFromVector(vec,name,type);
    13811400                }
    13821401                else if(EnumIsMaterial((*object)->Enum())){
    13831402
    13841403                        material=(Material*)(*object);
    1385                         material->UpdateInputsFromVector(vector,name,type);
     1404                        material->UpdateInputsFromVector(vec,name,type);
    13861405                }
    13871406                else if(((*object)->Enum()==ParamEnum)){
    13881407
    13891408                        param=(Param*)(*object);
    1390                         param->UpdateInputsFromVector(vector,name,type);
     1409                        param->UpdateInputsFromVector(vec,name,type);
    13911410                }
    13921411                else ISSMERROR("%s%i%s"," object with id: ",(*object)->Id()," is not an element, in a function that deals only with elements!");
     
    13941413}
    13951414/*}}}*/
    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*/
    14141416void  DataSet::AddInput(double value, int enum_type){
    14151417
     
    14281430}
    14291431/*}}}*/
    1430 /*FUNCTION DataSet::UpdateVertexPositions{{{2*/
     1432/*FUNCTION DataSet::UpdateVertexPositions{{{1*/
    14311433void  DataSet::UpdateVertexPositions(double* thickness,double* bed){
    14321434
     
    14441446}
    14451447/*}}}*/
    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 input
    1776          * with the same name is already in. If so, erase the corresponding
    1777          * 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* object
    1824          *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* object
    1855          *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* object
    1885          *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* object
    1916          *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* object
    1947          *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* object
    1978          *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* object
    2009          *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* object
    2040          *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* object
    2071          *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.