Changeset 4037


Ignore:
Timestamp:
06/10/10 19:10:44 (15 years ago)
Author:
Eric.Larour
Message:

New results framework. Now, elements have results datasets,
which they fill up as they wish with results found in the inputs.
Then, the results dataset will be processed in OutputResults, to output
something to disk. We ended up putting the results inside the elements,
because they depend on the interpolation, this avoids partitioning of vectors,
and inputs cannot hold different time steps for the same enum!

Location:
issm/trunk/src/c
Files:
16 added
2 deleted
37 edited

Legend:

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

    r4034 r4037  
    9292
    9393
     94/********************************************************INPUT************************************************/
    9495
    95 /********************************************************INPUTS************************************************/
    9696class Input;
    9797class Node;
    98 #include "./DataSet.h"
    99 #include "../objects/objects.h"
    10098
    10199class Inputs: public DataSet{
     
    139137
    140138
     139
     140
    141141/********************************************************PARAMETERS************************************************/
    142142
     
    165165};
    166166
     167
    167168/********************************************************RESULTS************************************************/
    168169
     
    176177                ~Results();
    177178                /*}}}*/
    178                 /*methods: {{{1*/
    179                 int   FindResult(Vec* presult,char* name);
    180                 int   FindResult(void* pvalue, char* name);
     179                /*numerics: {{{1*/
     180                Results* SpawnTriaResults(int* indices);
     181                Results* SpawnBeamResults(int* indices);
     182                Results* SpawnSingResults(int  index  );
    181183                /*}}}*/
    182184
     
    184186
    185187
     188
    186189#endif
  • issm/trunk/src/c/DataSet/Results.cpp

    r3956 r4037  
    3131/*}}}*/
    3232/*FUNCTION Results::Results(int in_enum){{{1*/
    33 Results::Results(int in_enum): DataSet(in_enum){
     33Results::Results(int in_enum): DataSet(in_enum) {
    3434        //do nothing;
    3535        return;
     
    4242/*}}}*/
    4343
    44 /*Object methods*/
    45 /*FUNCTION Results::FindResult(Vec* presult,char* name){{{1*/
    46 int   Results::FindResult(Vec* presult,char* name){
     44/*Object management*/
     45/*FUNCTION Results::SpawnBeamResults{{{1*/
     46Results* Results::SpawnBeamResults(int* indices){
    4747
    48         /*Go through a dataset, and find a Result* object
    49          *whith result name is "name" : */
    50        
     48        /*Intermediary*/
    5149        vector<Object*>::iterator object;
    52         Result* result=NULL;
     50        Result* resultin=NULL;
     51        Result* resultout=NULL;
    5352
    54         int found=0;
     53        /*Output*/
     54        Results* newresults=new Results();
    5555
     56        /*Go through results and call Spawn function*/
    5657        for ( object=objects.begin() ; object < objects.end(); object++ ){
    5758
    58                 /*Find param type objects: */
    59                 if((*object)->Enum()==ResultEnum){
     59                /*Create new result*/
     60                resultin=(Result*)(*object);
     61                resultout=resultin->SpawnBeamResult(indices);
    6062
    61                         /*Ok, this object is a result,recover it and ask which name it has: */
    62                         result=(Result*)(*object);
     63                /*Add result to new results*/
     64                newresults->AddObject(resultout);
     65        }
    6366
    64                         if (strcmp(result->GetFieldName(),name)==0){
    65                                 /*Ok, this is the one! Recover the value of this result: */
    66                                 result->GetField(presult);
    67                                 found=1;
    68                                 break;
    69                         }
    70                 }
    71         }
    72         return found;
     67        /*Assign output pointer*/
     68        return newresults;
    7369}
    7470/*}}}*/
    75 /*FUNCTION Results::FindResult(void* pvalue, char* name){{{1*/
    76 int   Results::FindResult(void* pvalue, char* name){
     71/*FUNCTION Results::SpawnSingResults{{{1*/
     72Results* Results::SpawnSingResults(int index){
    7773
    78         /*Go through a dataset, and find a Result* object
    79          *which field name is "name" : */
    80        
     74        /*Intermediary*/
    8175        vector<Object*>::iterator object;
    82         Result* result=NULL;
     76        Result* resultin=NULL;
     77        Result* resultout=NULL;
    8378
    84         int found=0;
     79        /*Output*/
     80        Results* newresults=new Results();
    8581
     82        /*Go through results and call Spawn function*/
    8683        for ( object=objects.begin() ; object < objects.end(); object++ ){
    8784
    88                 /*Find param type objects: */
    89                 if((*object)->Enum()==ResultEnum){
     85                /*Create new result*/
     86                resultin=(Result*)(*object);
     87                resultout=resultin->SpawnSingResult(index);
    9088
    91                         /*Ok, this object is a result, recover it and ask which name it has: */
    92                         result=(Result*)(*object);
     89                /*Add result to new results*/
     90                newresults->AddObject(resultout);
     91        }
    9392
    94                         if (strcmp(result->GetFieldName(),name)==0){
    95                                 /*Ok, this is the one! Recover the value of this result: */
    96                                 double** field=NULL;
    97                                 field=(double**)pvalue; //not very safe, but hey!
    98                                 result->GetField(field);
    99                                 found=1;
    100                                 break;
    101                         }
    102                 }
    103         }
    104         return found;
     93        /*Assign output pointer*/
     94        return newresults;
    10595}
    10696/*}}}*/
     97/*FUNCTION Results::SpawnTriaResults{{{1*/
     98Results* Results::SpawnTriaResults(int* indices){
     99
     100        /*Intermediary*/
     101        vector<Object*>::iterator object;
     102        Result* resultin=NULL;
     103        Result* resultout=NULL;
     104
     105        /*Output*/
     106        Results* newresults=new Results();
     107
     108        /*Go through results and call Spawn function*/
     109        for ( object=objects.begin() ; object < objects.end(); object++ ){
     110
     111                /*Create new result*/
     112                resultin=(Result*)(*object);
     113                resultout=resultin->SpawnTriaResult(indices);
     114
     115                /*Add result to new results*/
     116                newresults->AddObject(resultout);
     117        }
     118
     119        /*Assign output pointer*/
     120        return newresults;
     121}
     122/*}}}*/
  • issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h

    r4034 r4037  
    235235        /*}}}*/
    236236        /*Results{{{1*/
    237         StringResultEnum,
    238         DoubleVecResultEnum,
    239         DoubleMatResultEnum,
     237        DoubleResultEnum,
     238        TriaVertexResultEnum,
     239        PentaVertexResultEnum,
    240240        /*}}}*/
    241241        /*Parameters{{{1*/
  • issm/trunk/src/c/Makefile.am

    r4031 r4037  
    103103                                        ./objects/Node.h\
    104104                                        ./objects/Node.cpp\
    105                                         ./objects/Results/Result.h\
    106                                         ./objects/Results/DoubleVecResult.h\
    107                                         ./objects/Results/DoubleVecResult.cpp\
    108                                         ./objects/Results/DoubleMatResult.h\
    109                                         ./objects/Results/DoubleMatResult.cpp\
    110                                         ./objects/Results/StringResult.h\
    111                                         ./objects/Results/StringResult.cpp\
     105                                        ./objects/Results/DoubleResults.h\
     106                                        ./objects/Results/DoubleResults.cpp\
     107                                        ./objects/Results/TriaVertexResults.h\
     108                                        ./objects/Results/TriaVertexResults.cpp\
     109                                        ./objects/Results/PentaVertexResults.h\
     110                                        ./objects/Results/PentaVertexResults.cpp\
    112111                                        ./objects/Elements/Tria.h\
    113112                                        ./objects/Elements/Tria.cpp\
     
    471470                                        ./modules/InputToResultx/InputToResultx.cpp\
    472471                                        ./modules/InputToResultx/InputToResultx.h\
    473                                         ./modules/InputToResultx/PatchesSize.cpp\
    474                                         ./modules/InputToResultx/InputToPatches.cpp\
    475472                                        ./modules/ExtrudeInputx/ExtrudeInputx.cpp\
    476473                                        ./modules/ExtrudeInputx/ExtrudeInputx.h\
     
    574571                                        ./objects/Hook.h\
    575572                                        ./objects/Hook.cpp\
    576                                         ./objects/Results/Result.h\
    577                                         ./objects/Results/DoubleVecResult.h\
    578                                         ./objects/Results/DoubleVecResult.cpp\
    579                                         ./objects/Results/DoubleMatResult.h\
    580                                         ./objects/Results/DoubleMatResult.cpp\
    581                                         ./objects/Results/StringResult.h\
    582                                         ./objects/Results/StringResult.cpp\
     573                                        ./objects/Results/DoubleResults.h\
     574                                        ./objects/Results/DoubleResults.cpp\
     575                                        ./objects/Results/TriaVertexResults.h\
     576                                        ./objects/Results/TriaVertexResults.cpp\
     577                                        ./objects/Results/PentaVertexResults.h\
     578                                        ./objects/Results/PentaVertexResults.cpp\
    583579                                        ./objects/Elements/Tria.h\
    584580                                        ./objects/Elements/Tria.cpp\
     
    935931                                        ./modules/InputToResultx/InputToResultx.cpp\
    936932                                        ./modules/InputToResultx/InputToResultx.h\
    937                                         ./modules/InputToResultx/PatchesSize.cpp\
    938                                         ./modules/InputToResultx/InputToPatches.cpp\
    939933                                        ./modules/ExtrudeInputx/ExtrudeInputx.cpp\
    940934                                        ./modules/ExtrudeInputx/ExtrudeInputx.h\
  • issm/trunk/src/c/modules/UpdateInputsFromSolutionx/UpdateInputsFromSolutionx.cpp

    r3969 r4037  
    99#include "../../EnumDefinitions/EnumDefinitions.h"
    1010
    11 void UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,Vec solution, int analysis_type, int sub_analysis_type){
     11void UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,Vec solution, int analysis_type, int sub_analysis_type,int step=0){
    1212
    1313        double* serial_solution=NULL;
     
    1717
    1818        /*Call overloaded form of UpdateInputsFromSolutionx: */
    19         UpdateInputsFromSolutionx( elements, nodes,  vertices,  loads,  materials,  parameters,serial_solution, analysis_type, sub_analysis_type);
     19        UpdateInputsFromSolutionx( elements, nodes,  vertices,  loads,  materials,  parameters,serial_solution, analysis_type, sub_analysis_type,step);
    2020
    2121        /*Free ressources:*/
     
    4444
    4545}
     46
     47/*Same routines, with additional timestep argument: */
     48void UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,Vec solution, int analysis_type, int sub_analysis_type,int timestep){
     49       
     50       
     51        double* serial_solution=NULL;
     52
     53        /*Serialize solution, so that elements can index into it on every CPU: */
     54        VecToMPISerial(&serial_solution,solution);
     55
     56        /*Call overloaded form of UpdateInputsFromSolutionx: */
     57        UpdateInputsFromSolutionx( elements, nodes,  vertices,  loads,  materials,  parameters,serial_solution, analysis_type, sub_analysis_type,int timestep);
     58
     59        /*Free ressources:*/
     60        xfree((void**)&serial_solution);
     61
     62}
     63
     64
     65
     66void UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,double* solution, int analysis_type, int sub_analysis_type,int timestep){
     67
     68        /*Intermediary*/
     69        int i;
     70        Element* element=NULL;
     71
     72        /*First, get elements and loads configured: */
     73        elements->  Configure(elements,loads, nodes,vertices, materials,parameters);
     74        loads->     Configure(elements,loads, nodes,vertices, materials,parameters);
     75        nodes->     Configure(elements,loads, nodes,vertices, materials,parameters);
     76        parameters->Configure(elements,loads, nodes,vertices, materials,parameters);
     77       
     78        /*Elements drive the update: */
     79        for (i=0;i<elements->Size();i++){
     80                element=(Element*)elements->GetObjectByOffset(i);
     81                element->UpdateInputsFromSolution(solution,analysis_type,sub_analysis_type,timestep);
     82        }
     83
     84}
  • issm/trunk/src/c/modules/UpdateInputsFromSolutionx/UpdateInputsFromSolutionx.h

    r3922 r4037  
    1313void        UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,double* solution, int analysis_type, int sub_analysis_type);
    1414
     15//with timestep
     16void            UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials,  Parameters* parameters,Vec solution, int analysis_type, int sub_analysis_type,int timestep);
     17void        UpdateInputsFromSolutionx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,double* solution, int analysis_type, int sub_analysis_type,int timestep);
     18
    1519#endif  /* _UPDATEINPUTSFROMSOLUTIONXX_H */
    1620
  • issm/trunk/src/c/objects/Elements/Beam.cpp

    r4025 r4037  
    137137/*FUNCTION Beam::GetSolutionFromInputs(Vec solution,  int analysis_type,int sub_analysis_type);{{{1*/
    138138void  Beam::GetSolutionFromInputs(Vec solution,  int analysis_type,int sub_analysis_type){
     139        ISSMERROR(" not supported yet!");
     140}
     141/*}}}*/
     142/*FUNCTION Beam::InputToResult(int enum_type,int step,double time){{{1*/
     143void  Beam::InputToResult(int enum_type,int step,double time){
    139144        ISSMERROR(" not supported yet!");
    140145}
  • issm/trunk/src/c/objects/Elements/Beam.h

    r4034 r4037  
    6161                void  UpdateInputsFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
    6262                void  UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
    63 
    6463                void  UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type);
    65 
    66                 void   DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");};
     64                void  DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");};
     65                void  InputToResult(int enum_type,int step,double time);
    6766                /*}}}*/
    6867                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Elements/Element.h

    r4034 r4037  
    5050                virtual void   PatchFill(int* pcount, double* patches,int numcols,int max_vertices,int enum_type)=0;
    5151                virtual void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type)=0;
     52                virtual void   InputToResult(int enum_type,int step,double time);
    5253
    5354                /*Implementation: */
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r4034 r4037  
    3030       
    3131        this->inputs=NULL;
     32        this->results=NULL;
    3233        this->parameters=NULL;
    3334}
     
    3637Penta::~Penta(){
    3738        delete inputs;
     39        delete results;
    3840        this->parameters=NULL;
    3941        xfree((void**)&collapse);
     
    7779        this->parameters=NULL;
    7880
     81        /*intialize inputs and results: */
     82        this->inputs=new Inputs();
     83        this->results=new Results();
     84
    7985        //collpase flags
    8086        collapse=(bool*)xcalloc(nummodels,sizeof(bool));
     
    109115        this->SetHookNodes(penta_node_ids,analysis_counter); this->nodes=NULL; //set hook to nodes, for this analysis type
    110116
    111         //intialize inputs, and add as many inputs per element as requested:
    112         this->inputs=new Inputs();
     117        //add as many inputs per element as requested:
    113118        if (iomodel->thickness) {
    114119                for(i=0;i<6;i++)nodeinputs[i]=iomodel->thickness[penta_vertex_ids[i]-1];
     
    241246                penta->inputs=new Inputs();
    242247        }
     248        if(this->results){
     249                penta->results=(Results*)this->results->Copy();
     250        }
     251        else{
     252                penta->results=new Results();
     253        }
    243254        /*point parameters: */
    244255        penta->parameters=this->parameters;
     
    319330        neighbors=NULL;
    320331       
    321         /*demarshall inputs: */
     332        /*demarshall inputs and results: */
    322333        inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);
     334        results=(Results*)DataSetDemarshallRaw(&marshalled_dataset);
    323335
    324336        /*demarshall internal parameters: */
     
    353365        printf("   inputs\n");
    354366        inputs->DeepEcho();
     367        printf("   results\n");
     368        results->DeepEcho();
    355369        printf("   collapse: \n   ");
    356370        for(i=0;i<numanalyses;i++)printf("%s|",collapse[i]?"true":"false");
     
    379393        char* marshalled_inputs=NULL;
    380394        int   marshalled_inputs_size;
     395        char* marshalled_results=NULL;
     396        int   marshalled_results_size;
    381397
    382398        /*recover marshalled_dataset: */
     
    399415        hneighbors.Marshall(&marshalled_dataset);
    400416
    401         /*Marshall inputs: */
     417        /*Marshall inputs and results: */
    402418        marshalled_inputs_size=inputs->MarshallSize();
    403419        marshalled_inputs=inputs->Marshall();
     
    405421        marshalled_dataset+=marshalled_inputs_size;
    406422
     423        marshalled_results_size=results->MarshallSize();
     424        marshalled_results=results->Marshall();
     425        memcpy(marshalled_dataset,marshalled_results,marshalled_results_size*sizeof(char));
     426        marshalled_dataset+=marshalled_results_size;
     427
    407428        /*marshall internal parameters: */
    408429        memcpy(marshalled_dataset,collapse,numanalyses*sizeof(bool));marshalled_dataset+=numanalyses*sizeof(bool);
     
    411432
    412433        xfree((void**)&marshalled_inputs);
     434        xfree((void**)&marshalled_results);
    413435
    414436        *pmarshalled_dataset=marshalled_dataset;
     
    430452                +hneighbors.MarshallSize()
    431453                +inputs->MarshallSize()
     454                +results->MarshallSize()
    432455                +numanalyses*sizeof(bool)
    433456                +sizeof(int); //sizeof(int) for enum type
     
    445468        Parameters* tria_parameters=NULL;
    446469        Inputs* tria_inputs=NULL;
     470        Results* tria_results=NULL;
    447471
    448472        indices[0]=g0;
     
    452476        tria_parameters=this->parameters;
    453477        tria_inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices);
     478        tria_results=(Results*)this->results->SpawnTriaResults(indices);
    454479       
    455480        tria=new Tria();
    456481        tria->id=this->id;
    457482        tria->inputs=tria_inputs;
     483        tria->results=tria_results;
    458484        tria->parameters=tria_parameters;
    459485
     
    478504        Parameters *beam_parameters = NULL;
    479505        Inputs     *beam_inputs     = NULL;
     506        Results     *beam_results     = NULL;
    480507
    481508        indices[0]=g0;
     
    484511        beam_parameters=this->parameters;
    485512        beam_inputs=(Inputs*)this->inputs->SpawnBeamInputs(indices);
     513        beam_results=(Results*)this->results->SpawnBeamResults(indices);
    486514
    487515        beam=new Beam();
    488516        beam->id=this->id;
    489517        beam->inputs=beam_inputs;
     518        beam->results=beam_results;
    490519        beam->parameters=beam_parameters;
    491520
     
    506535        Parameters *sing_parameters = NULL;
    507536        Inputs     *sing_inputs     = NULL;
     537        Results     *sing_results     = NULL;
    508538
    509539        sing_parameters=this->parameters;
    510540        sing_inputs=(Inputs*)this->inputs->SpawnSingInputs(index);
     541        sing_results=(Results*)this->results->SpawnSingResults(index);
    511542
    512543        sing=new Sing();
    513544        sing->id=this->id;
    514545        sing->inputs=sing_inputs;
     546        sing->results=sing_results;
    515547        sing->parameters=sing_parameters;
    516548
     
    560592        /*output error if not found*/
    561593        ISSMERROR("Node not found in Penta");
     594}
     595/*}}}*/
     596/*FUNCTION Penta::InputToResult(int enum_type,int step,double time){{{1*/
     597void  Penta::InputToResult(int enum_type,int step,double time){
     598
     599        int    i;
     600        bool   found = false;
     601        Input *input = NULL;
     602
     603        /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */
     604        for (i=0;i<this->inputs->Size();i++){
     605                input=(Input*)this->inputs->GetObjectByOffset(i);
     606                if (input->EnumType()==enum_type){
     607                        found=true;
     608                        break;
     609                }
     610        }
     611
     612        /*If we don't find it, no big deal, just don't do the transfer. Otherwise, build a new Result
     613         * object out of the input, with the additional step and time information: */
     614        this->results->AddObject(input->SpawnResult(step,time));
     615
    562616}
    563617/*}}}*/
  • issm/trunk/src/c/objects/Elements/Penta.h

    r4034 r4037  
    3636                Parameters  *parameters;   //pointer to solution parameters
    3737                Inputs      *inputs;
     38                Results      *results;
    3839
    3940                /*internal parameters: */
     
    6061                int   MarshallSize();
    6162                int   MyRank();
    62                 void*  SpawnSing(int g0);
    63                 void*  SpawnBeam(int g0, int g1);
    64                 void*  SpawnTria(int g0, int g1, int g2);
     63                void* SpawnSing(int g0);
     64                void* SpawnBeam(int g0, int g1);
     65                void* SpawnTria(int g0, int g1, int g2);
    6566                void  SetClone(int* minranks);
    6667                double* GaussFromNode(Node* node);
     68                void  InputToResult(int enum_type,int step,double time);
    6769
    6870                /*}}}*/
  • issm/trunk/src/c/objects/Elements/Sing.cpp

    r4034 r4037  
    134134/*FUNCTION Sing::GetSolutionFromInputs(Vec solution,  int analysis_type,int sub_analysis_type);{{{1*/
    135135void  Sing::GetSolutionFromInputs(Vec solution,  int analysis_type,int sub_analysis_type){
     136        ISSMERROR(" not supported yet!");
     137}
     138/*}}}*/
     139/*FUNCTION Sing::InputToResult(int enum_type,int step,double time){{{1*/
     140void  Sing::InputToResult(int enum_type,int step,double time){
    136141        ISSMERROR(" not supported yet!");
    137142}
  • issm/trunk/src/c/objects/Elements/Sing.h

    r4034 r4037  
    6161                void  UpdateInputsFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");}
    6262                void  UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");}
    63 
    6463                void  UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type);
    65 
    6664                void  DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");};
     65                void  InputToResult(int enum_type,int step,double time);
    6766                /*}}}*/
    6867                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r4034 r4037  
    2828        this->inputs=NULL;
    2929        this->parameters=NULL;
     30        this->results=NULL;
    3031}
    3132/*}}}*/
     
    3334Tria::~Tria(){
    3435        delete inputs;
     36        delete results;
    3537        this->parameters=NULL;
    3638}
     
    6062        this->parameters=NULL;
    6163
     64        /*intialize inputs and results: */
     65        this->inputs=new Inputs();
     66        this->results=new Results();
     67
    6268}
    6369/*}}}*/
     
    98104        this->SetHookNodes(tria_node_ids,analysis_counter); this->nodes=NULL; //set hook to nodes, for this analysis type
    99105       
    100         /*intialize inputs, and add as many inputs per element as requested:*/
    101         this->inputs=new Inputs();
    102        
     106        /*add as many inputs per element as requested:*/
    103107        if (iomodel->thickness) {
    104108                for(i=0;i<3;i++)nodeinputs[i]=iomodel->thickness[tria_vertex_ids[i]-1];
     
    224228        else{
    225229                tria->inputs=new Inputs();
     230        }
     231        if(this->results){
     232                tria->results=(Results*)this->results->Copy();
     233        }
     234        else{
     235                tria->results=new Results();
    226236        }
    227237        /*point parameters: */
     
    299309        /*demarshall inputs: */
    300310        inputs=(Inputs*)DataSetDemarshallRaw(&marshalled_dataset);
     311        results=(Results*)DataSetDemarshallRaw(&marshalled_dataset);
    301312
    302313        /*parameters: may not exist even yet, so let Configure handle it: */
     
    334345        if (inputs) inputs->DeepEcho();
    335346        else printf("inputs=NULL\n");
     347
     348        if (results) results->DeepEcho();
     349        else printf("results=NULL\n");
    336350       
    337351        return;
     
    352366        char* marshalled_inputs=NULL;
    353367        int   marshalled_inputs_size;
     368        char* marshalled_results=NULL;
     369        int   marshalled_results_size;
    354370
    355371        /*recover marshalled_dataset: */
     
    378394        marshalled_dataset+=marshalled_inputs_size;
    379395
     396        /*Marshall results: */
     397        marshalled_results_size=results->MarshallSize();
     398        marshalled_results=results->Marshall();
     399        memcpy(marshalled_dataset,marshalled_results,marshalled_results_size*sizeof(char));
     400        marshalled_dataset+=marshalled_results_size;
     401
    380402        /*parameters: don't do anything about it. parameters are marshalled somewhere else!*/
    381403
    382404        xfree((void**)&marshalled_inputs);
     405        xfree((void**)&marshalled_results);
    383406
    384407        *pmarshalled_dataset=marshalled_dataset;
     
    400423                +hmatpar.MarshallSize()
    401424                +inputs->MarshallSize()
     425                +results->MarshallSize()
    402426                +sizeof(int); //sizeof(int) for enum type
    403427}
     
    414438        Parameters *beam_parameters = NULL;
    415439        Inputs     *beam_inputs     = NULL;
     440        Results     *beam_results     = NULL;
    416441
    417442        indices[0]=g0;
     
    420445        beam_parameters=this->parameters;
    421446        beam_inputs=(Inputs*)this->inputs->SpawnBeamInputs(indices);
     447        beam_results=(Results*)this->results->SpawnBeamResults(indices);
    422448
    423449        beam=new Beam();
    424450        beam->id=this->id;
    425451        beam->inputs=beam_inputs;
     452        beam->results=beam_results;
    426453        beam->parameters=beam_parameters;
    427454
     
    443470        Parameters *sing_parameters = NULL;
    444471        Inputs     *sing_inputs     = NULL;
     472        Results     *sing_results     = NULL;
    445473
    446474        sing_parameters=this->parameters;
    447475        sing_inputs=(Inputs*)this->inputs->SpawnSingInputs(index);
     476        sing_results=(Results*)this->results->SpawnSingResults(index);
    448477
    449478        sing=new Sing();
    450479        sing->id=this->id;
    451480        sing->inputs=sing_inputs;
     481        sing->results=sing_results;
    452482        sing->parameters=sing_parameters;
    453483
     
    458488       
    459489        return sing;
     490}
     491/*}}}*/
     492/*FUNCTION Tria::InputToResult(int enum_type,int step,double time){{{1*/
     493void  Tria::InputToResult(int enum_type,int step,double time){
     494
     495        int    i;
     496        bool   found = false;
     497        Input *input = NULL;
     498
     499        /*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */
     500        for (i=0;i<this->inputs->Size();i++){
     501                input=(Input*)this->inputs->GetObjectByOffset(i);
     502                if (input->EnumType()==enum_type){
     503                        found=true;
     504                        break;
     505                }
     506        }
     507
     508        /*If we don't find it, no big deal, just don't do the transfer. Otherwise, build a new Result
     509         * object out of the input, with the additional step and time information: */
     510        this->results->AddObject(input->SpawnResult(step,time));
     511
    460512}
    461513/*}}}*/
  • issm/trunk/src/c/objects/Elements/Tria.h

    r4036 r4037  
    5858                void*  SpawnSing(int g0);
    5959                void*  SpawnBeam(int g0, int g1);
     60                void  InputToResult(int enum_type,int step,double time);
    6061                /*}}}*/
    6162                /*FUNCTION element numerical routines {{{1*/
  • issm/trunk/src/c/objects/Inputs/BeamVertexInput.cpp

    r3956 r4037  
    167167}
    168168/*}}}*/
     169/*FUNCTION BeamVertexInput::SpawnResult{{{1*/
     170Result* BeamVertexInput::SpawnResult(int step, double time){
     171
     172        return new BeamVertexResult(this->enum_type,this->values,step,time);
     173
     174}
     175/*}}}*/
    169176
    170177/*Object functions*/
  • issm/trunk/src/c/objects/Inputs/BeamVertexInput.h

    r3956 r4037  
    5050                Input* SpawnBeamInput(int* indices);
    5151                Input* SpawnTriaInput(int* indices);
     52                Result* SpawnResult(int step, double time);
     53
    5254                /*}}}*/
    5355                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Inputs/BoolInput.cpp

    r3956 r4037  
    175175}
    176176/*}}}*/
     177/*FUNCTION BoolInput::SpawnResult{{{1*/
     178Result* BoolInput::SpawnResult(int step, double time){
     179
     180        return new BoolResult(this->enum_type,this->value,step,time);
     181
     182}
     183/*}}}*/
    177184
    178185/*Object functions*/
  • issm/trunk/src/c/objects/Inputs/BoolInput.h

    r3956 r4037  
    5050                Input* SpawnBeamInput(int* indices);
    5151                Input* SpawnTriaInput(int* indices);
     52                Result* SpawnResult(int step, double time);
     53
    5254                /*}}}*/
    5355                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Inputs/DoubleInput.cpp

    r3956 r4037  
    175175}
    176176/*}}}*/
     177/*FUNCTION DoubleInput::SpawnResult{{{1*/
     178Result* DoubleInput::SpawnResult(int step, double time){
     179
     180        return new DoubleResult(this->enum_type,this->value,step,time);
     181
     182}
     183/*}}}*/
    177184
    178185/*Object functions*/
  • issm/trunk/src/c/objects/Inputs/DoubleInput.h

    r3956 r4037  
    5050                Input* SpawnBeamInput(int* indices);
    5151                Input* SpawnTriaInput(int* indices);
     52                Result* SpawnResult(int step, double time);
     53
    5254                /*}}}*/
    5355                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Inputs/Input.h

    r3956 r4037  
    1111#include "../Object.h"
    1212class Node;
     13class Result;
    1314#include "../Node.h"
    1415/*}}}*/
     
    4445                virtual void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, double* gauss)=0;
    4546                virtual void ChangeEnum(int newenumtype)=0;
     47               
    4648                virtual Input* SpawnSingInput(int  index)=0;
    4749                virtual Input* SpawnBeamInput(int* indices)=0;
    4850                virtual Input* SpawnTriaInput(int* indices)=0;
     51                virtual Result* SpawnResult(int step, double time)=0;
    4952                virtual int  PatchSize(void)=0;
    5053                virtual void PatchFill(double* patch, int max_vertices,Parameters* parameters)=0;
     54
     55
    5156                /*}}}*/
    5257
  • issm/trunk/src/c/objects/Inputs/IntInput.cpp

    r3956 r4037  
    172172}
    173173/*}}}*/
     174/*FUNCTION IntInput::SpawnResult{{{1*/
     175Result* IntInput::SpawnResult(int step, double time){
     176
     177        return new IntResult(this->enum_type,this->value,step,time);
     178
     179}
     180/*}}}*/
    174181
    175182/*Object functions*/
  • issm/trunk/src/c/objects/Inputs/IntInput.h

    r3956 r4037  
    5050                Input* SpawnBeamInput(int* indices);
    5151                Input* SpawnTriaInput(int* indices);
     52                Result* SpawnResult(int step, double time);
     53
    5254                /*}}}*/
    5355                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Inputs/PentaVertexInput.cpp

    r3956 r4037  
    197197        /*Assign output*/
    198198        return outinput;
     199
     200}
     201/*}}}*/
     202/*FUNCTION PentaVertexInput::SpawnResult{{{1*/
     203Result* PentaVertexInput::SpawnResult(int step, double time){
     204
     205        return new PentaVertexResult(this->enum_type,this->values,step,time);
    199206
    200207}
  • issm/trunk/src/c/objects/Inputs/PentaVertexInput.h

    r3956 r4037  
    4949                Input* SpawnBeamInput(int* indices);
    5050                Input* SpawnTriaInput(int* indices);
     51                Result* SpawnResult(int step, double time);
     52
    5153                /*}}}*/
    5254                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Inputs/SingVertexInput.cpp

    r3956 r4037  
    158158}
    159159/*}}}*/
     160/*FUNCTION SingVertexInput::SpawnResult{{{1*/
     161Result* SingVertexInput::SpawnResult(int step, double time){
     162
     163        return new SingVertexResult(this->enum_type,this->value,step,time);
     164
     165}
     166/*}}}*/
    160167
    161168/*Object functions*/
  • issm/trunk/src/c/objects/Inputs/SingVertexInput.h

    r3956 r4037  
    4949                Input* SpawnBeamInput(int* indices);
    5050                Input* SpawnTriaInput(int* indices);
     51                Result* SpawnResult(int step, double time);
     52
    5153                /*}}}*/
    5254                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/Inputs/TriaVertexInput.cpp

    r3956 r4037  
    183183        /*Assign output*/
    184184        return outinput;
     185
     186}
     187/*}}}*/
     188/*FUNCTION TriaVertexInput::SpawnResult{{{1*/
     189Result* TriaVertexInput::SpawnResult(int step, double time){
     190
     191        return new TriaVertexResult(this->enum_type,this->values,step,time);
    185192
    186193}
  • issm/trunk/src/c/objects/Inputs/TriaVertexInput.h

    r4015 r4037  
    4949                Input* SpawnBeamInput(int* indices);
    5050                Input* SpawnTriaInput(int* indices);
     51                Result* SpawnResult(int step, double time);
     52
    5153                /*}}}*/
    5254                /*numerics: {{{1*/
  • issm/trunk/src/c/objects/objects.h

    r4001 r4037  
    1515#include "./Node.h"
    1616#include "./NodeSets.h"
    17 #include "./Result.h"
    1817#include "./IoModel.h"
    1918
     
    5251/*Results: */
    5352#include "./Results/Result.h"
    54 #include "./Results/StringResult.h"
    55 #include "./Results/DoubleVecResult.h"
    56 #include "./Results/DoubleMatResult.h"
     53#include "./Results/DoubleResult.h"
     54#include "./Results/TriaVertexResult.h"
     55#include "./Results/PentaVertexResult.h"
    5756
    5857/*Materials: */
  • issm/trunk/src/c/solutions/bedslope_core.cpp

    r4030 r4037  
    11/*!\file: bedslope_core.cpp
    2  * \brief: core of the bed slope solution
     2 * \brief: core of the slope solution
    33 */
    44
     
    1717        bool ishutter;
    1818
    19         Vec slopex=NULL;
    20         Vec slopey=NULL;
    21 
    2219        /*Recover some parameters: */
    2320        femmodel->parameters->FindParam(&verbose,VerboseEnum);
     
    2724
    2825        /*Call on core computations: */
    29         solver_linear(&slopex,femmodel,SlopeComputeAnalysisEnum,BedSlopeXAnalysisEnum);
    30         solver_linear(&slopey,femmodel,SlopeComputeAnalysisEnum,BedSlopeYAnalysisEnum);
     26        solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,BedSlopeXAnalysisEnum);
     27        solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,BedSlopeYAnalysisEnum);
    3128       
    32         /*Plug solution into inputs: */
    33         UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,slopex,SlopeComputeAnalysisEnum,BedSlopeXAnalysisEnum);
    34         UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,slopey,SlopeComputeAnalysisEnum,BedSlopeYAnalysisEnum);
    35 
    36         /*extrude if we are in 3D: */
     29        /*extrude inputs if we are in 3D: */
    3730        if (dim==3){
    3831                if(verbose)_printf_("%s\n","extruding slope in 3d...");
     
    4033                InputsExtrudex( femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeYEnum,0);
    4134        }
    42 
    43         /*Free ressources:*/
    44         VecFree(&slopex);
    45         VecFree(&slopey);
    4635}
  • issm/trunk/src/c/solutions/diagnostic.cpp

    r4028 r4037  
    2626        bool  qmu_analysis=false;
    2727        bool  control_analysis=false;
     28        bool waitonlock=false;
    2829
    2930        /*FemModel: */
    3031        FemModel* femmodel=NULL;
    3132
    32         /*Results: */
    33         bool waitonlock=false;
    34        
    3533        /*time*/
    3634        double   start, finish;
     
    6664        fid=pfopen(inputfilename,"rb");
    6765
    68         _printf_("create finite element model, using analyses types statically defined above:\n");
     66        _printf_("create finite element model:\n");
    6967        femmodel=new FemModel(fid,solution_type,analyses,5);
    7068       
     
    9694
    9795                _printf_("write results to disk:\n");
    98                 OutputResults(femmodel,outputfilename,DiagnosticAnalysisEnum);
     96                OutputResults(femmodel,outputfilename,DiagnosticSolutionEnum);
    9997        }
    10098        else{
  • issm/trunk/src/c/solutions/diagnostic_core.cpp

    r4029 r4037  
    4646                       
    4747                if(verbose)_printf_("%s\n"," computing hutter velocities...");
    48                 solver_linear(NULL,femmodel,DiagnosticAnalysisEnum,HutterAnalysisEnum);
     48                solver_linear(NULL,femmodel,DiagnosticAnalysisEnum,HutterAnalysisEnum); 
    4949               
    5050                if (ismacayealpattyn) ResetBoundaryConditions(femmodel,DiagnosticAnalysisEnum,HorizAnalysisEnum);
     
    7676                }
    7777        }
     78
     79        if(verbose)_printf_("saving results:\n");
     80        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
     81        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum);
     82        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum);
     83        if(dim==3) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
     84
     85       
    7886}
  • issm/trunk/src/c/solutions/surfaceslope_core.cpp

    r4030 r4037  
    1717        bool ishutter;
    1818
    19         Vec slopex=NULL;
    20         Vec slopey=NULL;
    21 
    2219        /*Recover some parameters: */
    2320        femmodel->parameters->FindParam(&verbose,VerboseEnum);
     
    2724
    2825        /*Call on core computations: */
    29         solver_linear(&slopex,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeXAnalysisEnum);
    30         solver_linear(&slopey,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeYAnalysisEnum);
     26        solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeXAnalysisEnum);
     27        solver_linear(NULL,femmodel,SlopeComputeAnalysisEnum,SurfaceSlopeYAnalysisEnum);
    3128       
    32         /*Plug solution into inputs: */
    33         UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,slopex,SlopeComputeAnalysisEnum,SurfaceSlopeXAnalysisEnum);
    34         UpdateInputsFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,slopey,SlopeComputeAnalysisEnum,SurfaceSlopeYAnalysisEnum);
    35 
    36         /*extrude if we are in 3D: */
     29        /*extrude inputs if we are in 3D: */
    3730        if (dim==3){
    3831                if(verbose)_printf_("%s\n","extruding slope in 3d...");
     
    4033                InputsExtrudex( femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeYEnum,0);
    4134        }
    42 
    43         /*Free ressources:*/
    44         VecFree(&slopex);
    45         VecFree(&slopey);
    4635}
  • issm/trunk/src/c/solutions/thermal.cpp

    r3938 r4037  
    2727        char* lockname=NULL;
    2828        bool  qmu_analysis=false;
    29         int   numberofnodes;
    3029        bool  waitonlock=false;
    3130
    32         /*Model: */
    33         Model* model=NULL;
    34 
    35         /*Results: */
    36         Results* results=NULL;
     31        /*FemModel: */
     32        FemModel* femmodel=NULL;
    3733       
    38         Param*           param=NULL;
    39         double  dt;
    40         double  yts;
    41 
    4234        /*time*/
    4335        double   start, finish;
    4436        double   start_core, finish_core;
    4537        double   start_init, finish_init;
    46                
     38
     39        int analyses[2]={ThermalAnalysisEnum,MeltingAnalysisEnum};
     40        int solution_type=ThermalSolutionEnum;
     41
    4742        MODULEBOOT();
    4843
     
    5954        MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
    6055
     56        _printf_("recover , input file name and output file name:\n");
    6157        inputfilename=argv[2];
    6258        outputfilename=argv[3];
    6359        lockname=argv[4];
    6460
     61        /*Initialize femmodel structure: */
     62        MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
     63
    6564        /*Open handle to data on disk: */
    6665        fid=pfopen(inputfilename,"rb");
    6766
    68         /*Initialize model structure: */
    69         MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
    70         model=new Model();
     67        _printf_("create finite element model:\n");
     68        femmodel=new FemModel(fid,solution_type,analyses,2);
    7169
    72         _printf_("read and create thermal finite element model:\n");
    73         model->AddFormulation(fid,ThermalAnalysisEnum);
    74         _printf_("read and create melting finite element model:\n");
    75         model->AddFormulation(fid,MeltingAnalysisEnum);
    76 
    77         /*recover parameters: */
    78         model->FindParam(&waitonlock,WaitOnLockEnum);
    79         model->FindParam(&qmu_analysis,QmuAnalysisEnum);
     70        /*get parameters: */
     71        femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
     72        femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum);
    8073
    8174        MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
     
    8780                _printf_("call computational core:\n");
    8881                MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
    89                 results=thermal_core(model);
     82                thermal_core(femmodel);
    9083                MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
     84               
     85               
     86                _printf_("write results to disk:\n");
     87                OutputResults(femmodel,outputfilename,ThermalSolutionEnum);
    9188
    92                 _printf_("write results to disk:\n");
    93                 OutputResults(results,outputfilename);
    9489        }
    9590        else{
     91       
    9692                /*run qmu analysis: */
    9793                _printf_("calling qmu analysis on thermal core:\n");
     
    112108
    113109        /*Free ressources */
    114         delete model;
    115         delete results;
     110        delete femmodel;
    116111
    117112        /*Get finish time and close*/
  • issm/trunk/src/c/solutions/thermal_core.cpp

    r3941 r4037  
    99#include "./solutions.h"
    1010#include "../modules/modules.h"
     11#include "../include/include.h"
    1112
    12 Results* thermal_core(Model* model){
     13void thermal_core(FemModel* femmodel){
    1314
    14         extern int my_rank;
    1515        int i;
    1616
    17         /*fem models: */
    18         FemModel* fem_t=NULL;
    19         FemModel* fem_m=NULL;
    20 
    21         /*output: */
    22         Results* results=NULL;
    23         Result*  result=NULL;
    24 
    25         /*solutions vectors: */
    26         Vec*    t_g=NULL;
    27         Vec*    m_g=NULL;
    28         double* time=NULL;
    29         double* t_g_serial=NULL;
    30         double* m_g_serial=NULL;
    31 
    3217        /*intermediary*/
    33         Vec Vect=NULL;
    34         Vec Vecm=NULL;
    35 
    36         /*flags: */
    37         int    verbose=0;
    38         int    numberofdofspernode;
    39         int    numberofnodes;
     18        double time;
     19        int    verbose;
    4020        int    nsteps;
    4121        double ndt;
    4222        double dt;
    43 
    44         int    sub_analysis_type;
    4523        double melting_offset;
    4624
    47         //initialize results
    48         results=new Results();
     25        //first recover parameters common to all solutions
     26        femmodel->parameters->FindParam(&verbose,VerboseEnum);
     27        femmodel->parameters->FindParam(&ndt,NdtEnum);
     28        femmodel->parameters->FindParam(&dt,DtEnum);
    4929
    50         /*recover fem models: */
    51         fem_t=model->GetFormulation(ThermalAnalysisEnum);
    52         fem_m=model->GetFormulation(MeltingAnalysisEnum);
     30        /*Compute number of time steps: */
     31        if((dt==0)|| (ndt==0)){
     32                dt=0;
     33                nsteps=1;
     34        }
     35        else nsteps=(int)(ndt/dt);
    5336
    54         //first recover parameters common to all solutions
    55         fem_t->parameters->FindParam(&numberofnodes,NumberOfNodesEnum);
    56         fem_t->parameters->FindParam(&sub_analysis_type,SubAnalysisTypeEnum);
    57         fem_t->parameters->FindParam(&verbose,VerboseEnum);
    58         fem_t->parameters->FindParam(&ndt,NdtEnum);
    59         fem_t->parameters->FindParam(&dt,DtEnum);
    60 
    61         if(dt==0){
    62 
    63                 time=(double*)xmalloc(sizeof(double));
    64                 time[0]=0;
    65 
    66                 /*allocate t_g and m_g arrays: */
    67                 t_g=(Vec*)xmalloc(sizeof(Vec));
    68                 m_g=(Vec*)xmalloc(sizeof(Vec));
     37        /*Loop through time: */
     38        for(i=0;i<nsteps;i++){
     39               
     40                if(verbose)_printf_("time step: %i/%i\n",i+1,nsteps);
     41                time=(i+1)*dt;
    6942
    7043                if(verbose)_printf_("computing temperatures:\n");
    71                 thermal_core_nonlinear(&t_g[0],&melting_offset,fem_t,ThermalAnalysisEnum,NoneAnalysisEnum);
    72                 model->UpdateInputsFromVector(t_g[0],TemperatureEnum,VertexEnum);
    73                 model->UpdateInputsFromConstant(melting_offset,MeltingOffsetEnum);
    74                
     44                solver_thermal_nonlinear(NULL,NULL,femmodel,ThermalAnalysisEnum,NoneAnalysisEnum);
     45
    7546                if(verbose)_printf_("computing melting:\n");
    76                 diagnostic_core_linear(&m_g[0],fem_m,MeltingAnalysisEnum,NoneAnalysisEnum);
     47                solver_linear(NULL,femmodel,MeltingAnalysisEnum,NoneAnalysisEnum);
     48
     49                if(verbose)_printf_("saving results:\n");
     50                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum,i,time);
     51                InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,MeltingRateEnum,i,time);
     52
    7753        }
    78         else{
    79                
    80                 nsteps=(int)(ndt/dt);
    81                 time=(double*)xmalloc((nsteps)*sizeof(double));
    82 
    83                 /*allocate t_g and m_g arrays: */
    84                 t_g=(Vec*)xmalloc((nsteps)*sizeof(Vec));
    85                 m_g=(Vec*)xmalloc((nsteps)*sizeof(Vec));
    86 
    87                 for(i=0;i<nsteps;i++){
    88                         if(verbose)_printf_("time step: %i/%i\n",i+1,nsteps);
    89                         time[i]=(i+1)*dt;
    90                        
    91                         if(verbose)_printf_("computing temperatures:\n");
    92                         thermal_core_nonlinear(&t_g[i],&melting_offset,fem_t,ThermalAnalysisEnum,NoneAnalysisEnum);
    93                        
    94                         if(verbose)_printf_("computing melting:\n");
    95                         model->UpdateInputsFromVector(t_g[i],TemperatureEnum,VertexEnum);
    96                         model->UpdateInputsFromConstant(melting_offset,MeltingOffsetEnum);
    97                         diagnostic_core_linear(&m_g[i],fem_m,MeltingAnalysisEnum,NoneAnalysisEnum);
    98                 }
    99         }
    100        
    101         /*Plug results into output dataset: */
    102         if(dt==0){
    103                 InputToResultx(&result,fem_t->elements,fem_t->nodes,fem_t->vertices, fem_t->loads, fem_t->materials,fem_t->parameters,TemperatureEnum,results->Size()+1,0,1); results->AddObject(result);
    104                 InputToResultx(&result,fem_m->elements,fem_m->nodes,fem_m->vertices, fem_m->loads, fem_m->materials,fem_m->parameters,MeltingRateEnum,results->Size()+1,0,1); results->AddObject(result);
    105 
    106                 /*free ressource*/
    107                 Vect=t_g[0];    Vecm=m_g[0];
    108                 VecFree(&Vect); VecFree(&Vecm);
    109         }
    110         else{
    111                 for(i=0;i<nsteps;i++){
    112                         /*To be moved inside the loop!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    113                         InputToResultx(&result,fem_t->elements,fem_t->nodes,fem_t->vertices, fem_t->loads, fem_t->materials,fem_t->parameters,TemperatureEnum,results->Size()+1,time[i],i+1); results->AddObject(result);
    114                         InputToResultx(&result,fem_m->elements,fem_m->nodes,fem_m->vertices, fem_m->loads, fem_m->materials,fem_m->parameters,MeltingRateEnum,results->Size()+1,time[i],i+1); results->AddObject(result);
    115 
    116                         /*free ressource*/
    117                         Vect=t_g[i];    Vecm=m_g[i];
    118                         VecFree(&Vect); VecFree(&Vecm);
    119                 }
    120         }
    121         /*Add analysis_type to results: */
    122         results->AddObject(new StringResult(results->Size()+1,AnalysisTypeEnum,0,1,EnumAsString(ThermalAnalysisEnum)));
    123 
    124         /*free ressource*/
    125         xfree((void**)&t_g);
    126         xfree((void**)&m_g);
    127         xfree((void**)&time);
    128        
    129         //return:
    130         return results;
    131 
    13254}
Note: See TracChangeset for help on using the changeset viewer.