Changeset 4873


Ignore:
Timestamp:
07/29/10 10:07:56 (15 years ago)
Author:
Mathieu Morlighem
Message:

outputfile is now loaded step by step to save memory. the file is open once and closed at the end of the solution

Location:
issm/trunk/src
Files:
42 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Container/Parameters.cpp

    r4855 r4873  
    309309}
    310310/*}}}*/
     311/*FUNCTION Parameters::FindParam(FILE** pfid,int enum_type){{{1*/
     312int   Parameters::FindParam(FILE** pfid,int enum_type){
     313
     314        /*Go through a dataset, and find a Param* object
     315         *which parameter name is "name" : */
     316
     317        vector<Object*>::iterator object;
     318        Param* param=NULL;
     319
     320        int found=0;
     321
     322        for ( object=objects.begin() ; object < objects.end(); object++ ){
     323
     324                /*Ok, this object is a parameter, recover it and ask which name it has: */
     325                param=(Param*)(*object);
     326
     327                if(param->EnumType()==enum_type){
     328                        /*Ok, this is the one! Recover the value of this parameter: */
     329                        param->GetParameterValue(pfid);
     330                        found=1;
     331                        break;
     332                }
     333        }
     334        return found;
     335}
     336/*}}}*/
    311337
    312338/*FUNCTION Parameters::SetParam(bool boolean,int enum_type);{{{1*/
     
    418444}
    419445/*}}}*/
     446/*FUNCTION Parameters::SetParam(FILE* fid,int enum_type);{{{1*/
     447void   Parameters::SetParam(FILE* fid,int enum_type){
     448
     449        Param* param=NULL;
     450
     451        /*first, figure out if the param has already been created: */
     452        param=(Param*)this->FindParamObject(enum_type);
     453
     454        if(param) param->SetValue(fid); //already exists, just set it.
     455        else this->AddObject(new FileParam(enum_type,fid)); //just add the new parameter.
     456}
     457/*}}}*/
    420458
    421459/*FUNCTION Parameters::FindParamObject{{{1*/
  • issm/trunk/src/c/Container/Parameters.h

    r4855 r4873  
    3636                int   FindParam(Vec* pvec,int enum_type);
    3737                int   FindParam(Mat* pmat,int enum_type);
     38                int   FindParam(FILE** pfid,int enum_type);
    3839               
    3940                void  SetParam(bool boolean,int enum_type);
     
    4647                void  SetParam(Vec vec,int enum_type);
    4748                void  SetParam(Mat mat,int enum_type);
     49                void  SetParam(FILE* fid,int enum_type);
    4850
    4951                Object* FindParamObject(int enum_type);
  • issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp

    r4857 r4873  
    121121                case DoubleVecParamEnum : return "DoubleVecParam";
    122122                case IntParamEnum : return "IntParam";
     123                case FileParamEnum : return "FileParam";
    123124                case PetscMatParamEnum : return "PetscMatParam";
    124125                case PetscVecParamEnum : return "PetscVecParam";
     
    291292                case NumberOfVerticesEnum : return "NumberOfVertices";
    292293                case OptScalEnum : return "OptScal";
    293                 case OutputFileNameEnum : return "OutputFileName";
     294                case OutputFilePointerEnum : return "OutputFilePointer";
    294295                case ParameterOutputEnum : return "ParameterOutput";
    295296                case PenaltyMeltingEnum : return "PenaltyMelting";
  • issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h

    r4855 r4873  
    139139        DoubleVecParamEnum,
    140140        IntParamEnum,
     141        FileParamEnum,
    141142        PetscMatParamEnum,
    142143        PetscVecParamEnum,
     
    328329        NumberOfVerticesEnum,
    329330        OptScalEnum,
    330         OutputFileNameEnum,
     331        OutputFilePointerEnum,
    331332        ParameterOutputEnum,
    332333        PenaltyMeltingEnum,
  • issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp

    r4857 r4873  
    119119        else if (strcmp(name,"DoubleVecParam")==0) return DoubleVecParamEnum;
    120120        else if (strcmp(name,"IntParam")==0) return IntParamEnum;
     121        else if (strcmp(name,"FileParam")==0) return FileParamEnum;
    121122        else if (strcmp(name,"PetscMatParam")==0) return PetscMatParamEnum;
    122123        else if (strcmp(name,"PetscVecParam")==0) return PetscVecParamEnum;
     
    289290        else if (strcmp(name,"NumberOfVertices")==0) return NumberOfVerticesEnum;
    290291        else if (strcmp(name,"OptScal")==0) return OptScalEnum;
    291         else if (strcmp(name,"OutputFileName")==0) return OutputFileNameEnum;
     292        else if (strcmp(name,"OutputFilePointer")==0) return OutputFilePointerEnum;
    292293        else if (strcmp(name,"ParameterOutput")==0) return ParameterOutputEnum;
    293294        else if (strcmp(name,"PenaltyMelting")==0) return PenaltyMeltingEnum;
  • issm/trunk/src/c/Makefile.am

    r4853 r4873  
    188188                                        ./objects/Params/DoubleParam.cpp\
    189189                                        ./objects/Params/DoubleParam.h\
     190                                        ./objects/Params/FileParam.cpp\
     191                                        ./objects/Params/FileParam.h\
    190192                                        ./objects/Params/PetscMatParam.cpp\
    191193                                        ./objects/Params/PetscMatParam.h\
     
    750752                                        ./objects/Params/DoubleParam.cpp\
    751753                                        ./objects/Params/DoubleParam.h\
     754                                        ./objects/Params/FileParam.cpp\
     755                                        ./objects/Params/FileParam.h\
    752756                                        ./objects/Params/PetscMatParam.cpp\
    753757                                        ./objects/Params/PetscMatParam.h\
  • issm/trunk/src/c/io/pfclose.cpp

    r3775 r4873  
    2121        }
    2222}
    23 
  • issm/trunk/src/c/modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp

    r4781 r4873  
    4747        xfree((void**)&iomodel->elementonwater);
    4848        xfree((void**)&iomodel->elementonbed);
     49        xfree((void**)&iomodel->elementonsurface);
    4950}
  • issm/trunk/src/c/modules/OutputResultsx/ElementResultsToPatch.cpp

    r4508 r4873  
    1515#include "../../objects/objects.h"
    1616               
    17 void ElementResultsToPatch(Elements* elements,  Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,DataSet* results){
     17void ElementResultsToPatch(Elements* elements,  Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,DataSet* results,int step, double time){
    1818
    1919        int i;
     
    9696        patch->MPI_Gather();
    9797
    98         /*create result object and add to results dataset: */
    99         results->AddObject(new       IntExternalResult(results->Size()+1,PatchVerticesEnum,patch->maxvertices,1,0));
    100         results->AddObject(new       IntExternalResult(results->Size()+1,PatchNodesEnum,   patch->maxnodes,1,0));
    101         results->AddObject(new DoubleMatExternalResult(results->Size()+1,PatchEnum,patch->values,patch->numrows,patch->numcols,1,0));
     98        /*create result object and add to results dataset (if not empty): */
     99        if (patch->maxvertices && patch->maxnodes){
     100                results->AddObject(new       IntExternalResult(results->Size()+1,PatchVerticesEnum,patch->maxvertices,step,time));
     101                results->AddObject(new       IntExternalResult(results->Size()+1,PatchNodesEnum,   patch->maxnodes,step,time));
     102                results->AddObject(new DoubleMatExternalResult(results->Size()+1,PatchEnum,patch->values,patch->numrows,patch->numcols,step,time));
     103        }
    102104
    103105        /*Free ressources:*/
  • issm/trunk/src/c/modules/OutputResultsx/FileWriteResults.cpp

    r4316 r4873  
    1818        int         i;
    1919        extern int  my_rank;
    20         char       *filename     = NULL;
    2120        FILE       *fid          = NULL;
    2221
    2322        //Recover file name:
    24         parameters->FindParam(&filename,OutputFileNameEnum);
    25 
    26         //Open filename for writing only on cpu 0
    27         if(my_rank==0)fid=pfopen(filename,"wb");
     23        parameters->FindParam(&fid,OutputFilePointerEnum);
    2824
    2925        for(i=0;i<results->Size();i++){
     
    3329                result->WriteData(fid);
    3430        }
    35 
    36         /*Close file: */
    37         if(my_rank==0) pfclose(fid,filename);
    38 
    39         /*Free ressources:*/
    40         xfree((void**)&filename);
    4131}
  • issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp

    r4573 r4873  
    1717               
    1818#ifdef _SERIAL_
    19 void OutputResultsx(mxArray** pdataref, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,DataSet* results){
    20 #else
    21 void OutputResultsx(                    Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,DataSet* results){
     19void OutputResultsx(mxArray** pdataref, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,DataSet** presults, int step, double time){
     20#else                                                                                                                                                                                             
     21void OutputResultsx(                    Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,DataSet** presults, int step, double time){
    2222#endif
    2323
    24         int  solutiontype;
     24        /*Intermediaries*/
     25        int      i;
     26        int      solutiontype;
     27        DataSet *results;
     28        Element *element;
     29
     30        /*Recover results*/
     31        results=*presults;
    2532       
    2633        /*Transfer element results into the femmodel->results dataset: */
    27         ElementResultsToPatch( elements,  nodes,  vertices,  loads, materials, parameters,results);
     34        ElementResultsToPatch( elements,  nodes,  vertices,  loads, materials, parameters,results,step,time);
    2835
    2936        #ifdef _PARALLEL_
     
    3643        /*Write data to matlab structure or filename: */
    3744        #ifdef _SERIAL_
     45                /*Write Matlab structure*/
    3846                MatlabWriteResults(pdataref,parameters,results);
     47
     48                /*DO NOT delete results serially*/
    3949        #else
     50                /*Write File*/
    4051                FileWriteResults(parameters,results);
     52
     53                /*Now delete results (ElementResults and ExternalResults)*/
     54                delete results;
     55                for (i=0;i<elements->Size();i++){
     56                        element=(Element*)elements->GetObjectByOffset(i);
     57                        element->DeleteResults();
     58                }
    4159        #endif
     60
     61
     62
     63        /*We have to reinitialize results for next step*/
     64        results=new DataSet();
     65        *presults=results;
     66
    4267}
  • issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h

    r4236 r4873  
    1616#ifdef _SERIAL_
    1717#include <mex.h>
    18 void OutputResultsx(mxArray** pdataref, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads,  Materials* materials, Parameters* parameters,DataSet* results);
     18void OutputResultsx(mxArray** pdataref, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads,  Materials* materials, Parameters* parameters,DataSet** results,int step=0,double time=0);
    1919void MatlabWriteResults(mxArray** pdataref, Parameters* parameters, DataSet* results);
    2020#else
    21 void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads,  Materials* materials, Parameters* parameters,DataSet* results);
     21void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads,  Materials* materials, Parameters* parameters,DataSet** results,int step=0,double time=0);
    2222void FileWriteResults(Parameters* parameters, DataSet* results);
    2323#endif
    2424
    2525/* local prototypes: */
    26 void ElementResultsToPatch(Elements* elements,  Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,DataSet* results);
     26void ElementResultsToPatch(Elements* elements,  Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,DataSet* results,int step, double time);
    2727
    2828#endif  /* _OUTPUTRESULTS_H */
  • issm/trunk/src/c/objects/Elements/Beam.cpp

    r4839 r4873  
    284284                ISSMERROR("analysis %i (%s) not supported yet",analysis_type,EnumAsString(analysis_type));
    285285        }
     286
     287}
     288/*}}}*/
     289/*FUNCTION Beam::DeleteResults {{{1*/
     290void  Beam::DeleteResults(void){
     291
     292        ISSMERROR("not implemented yet");
    286293
    287294}
  • issm/trunk/src/c/objects/Elements/Beam.h

    r4780 r4873  
    7070                void       CreateKMatrix(Mat Kgg);
    7171                void       CreatePVector(Vec pg);
    72                 void       Du(Vec du_g);
     72                void   DeleteResults(void);
    7373                void       GetBedList(double* bed_list);
    7474                void*      GetMatPar();
  • issm/trunk/src/c/objects/Elements/Element.h

    r4839 r4873  
    5050                virtual void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes)=0;
    5151                virtual void   PatchFill(int* pcount, Patch* patch)=0;
     52                virtual void   DeleteResults(void)=0;
    5253                virtual void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type)=0;
    5354                virtual void   UpdateGeometry(void)=0;
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r4846 r4873  
    828828        }
    829829        else ISSMERROR("analysis %i (%s) not supported yet",analysis_type,EnumAsString(analysis_type));
     830
     831}
     832/*}}}*/
     833/*FUNCTION Penta::DeleteResults {{{1*/
     834void  Penta::DeleteResults(void){
     835
     836        /*Delete and reinitialize results*/
     837        delete this->results;
     838        this->results=new Results();
    830839
    831840}
  • issm/trunk/src/c/objects/Elements/Penta.h

    r4839 r4873  
    7373                void   CreateKMatrix(Mat Kgg);
    7474                void   CreatePVector(Vec pg);
     75                void   DeleteResults(void);
    7576                void   GetBedList(double* bed_list);
    7677                void*  GetMatPar();
  • issm/trunk/src/c/objects/Elements/Sing.cpp

    r4839 r4873  
    255255                ISSMERROR("analysis %i (%s) not supported yet",analysis_type,EnumAsString(analysis_type));
    256256        }
     257
     258}
     259/*}}}*/
     260/*FUNCTION Sing::DeleteResults {{{1*/
     261void  Sing::DeleteResults(void){
     262
     263        ISSMERROR("not implemented yet");
    257264
    258265}
  • issm/trunk/src/c/objects/Elements/Sing.h

    r4780 r4873  
    7070                void   CreateKMatrix(Mat Kgg);
    7171                void   CreatePVector(Vec pg);
    72                 void   Du(Vec du_g);
     72                void   DeleteResults(void);
    7373                void   GetBedList(double* bed_list);
    7474                void*  GetMatPar();
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r4846 r4873  
    747747                ISSMERROR("analysis %i (%s) not supported yet",analysis_type,EnumAsString(analysis_type));
    748748        }
     749
     750}
     751/*}}}*/
     752/*FUNCTION Tria::DeleteResults {{{1*/
     753void  Tria::DeleteResults(void){
     754
     755        /*Delete and reinitialize results*/
     756        delete this->results;
     757        this->results=new Results();
    749758
    750759}
  • issm/trunk/src/c/objects/Elements/Tria.h

    r4839 r4873  
    2828                int  id;
    2929
    30                 Node** nodes; // 3 nodes
    31                 Matice* matice;  // 1 material ice
    32                 Matpar* matpar;  // 1 material parameter
    33  
    34                 Parameters* parameters; //pointer to solution parameters
    35                 Inputsinputs;
    36                 Results*  results;
     30                Node   **nodes;    // 3 nodes
     31                Matice  *matice;   // 1 material ice
     32                Matpar  *matpar;   // 1 material parameter
     33
     34                Parameters *parameters;  //pointer to solution parameters
     35                Inputs     *inputs;
     36                Results    *results;
    3737
    3838                /*Tria constructors, destructors {{{1*/
     
    8888                void   InputScale(int enum_type,double scale_factor);
    8989                void   InputToResult(int enum_type,int step,double time);
     90                void   DeleteResults(void);
    9091                void   MaterialUpdateFromTemperature(void){ISSMERROR("not implemented yet");};
    9192                double MassFlux(double* segment);
  • issm/trunk/src/c/objects/Params/BoolParam.h

    r4852 r4873  
    6363                void  GetParameterValue(Vec* pvec){ISSMERROR("Bool param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
    6464                void  GetParameterValue(Mat* pmat){ISSMERROR("Bool param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
     65                void  GetParameterValue(FILE** pfid){ISSMERROR("Bool param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6566
    6667                void  SetValue(bool boolean){this->value=boolean;}
     
    7374                void  SetValue(Vec vec){ISSMERROR("Bool param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7475                void  SetValue(Mat mat){ISSMERROR("Bool param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     76                void  SetValue(FILE* fid){ISSMERROR("Bool param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7577                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("Bool param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    76 
    7778               
    7879                char* GetParameterName(void);
  • issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h

    r4853 r4873  
    6666                void  GetParameterValue(Vec* pvec){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
    6767                void  GetParameterValue(Mat* pmat){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
     68                void  GetParameterValue(FILE** pfid){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6869
    6970                void  SetValue(bool boolean){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
     
    7677                void  SetValue(Vec vec){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7778                void  SetValue(Mat mat){ISSMERROR("DoubleMatArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     79                void  SetValue(FILE* fid){ISSMERROR("Bool param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7880                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array);
    7981
  • issm/trunk/src/c/objects/Params/DoubleMatParam.h

    r4852 r4873  
    6565                void  GetParameterValue(Vec* pvec){ISSMERROR("DoubleMat param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
    6666                void  GetParameterValue(Mat* pmat){ISSMERROR("DoubleMat param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
     67                void  GetParameterValue(FILE** pfid){ISSMERROR("DoubleMat param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6768
    6869                void  SetValue(bool boolean){ISSMERROR("DoubleMat param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
     
    7576                void  SetValue(Vec vec){ISSMERROR("DoubleMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7677                void  SetValue(Mat mat){ISSMERROR("DoubleMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     78                void  SetValue(FILE* fid){ISSMERROR("DoubleMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7779                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("DoubleMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    7880
  • issm/trunk/src/c/objects/Params/DoubleParam.h

    r4852 r4873  
    6464                void  GetParameterValue(Vec* pvec){ISSMERROR("Double param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
    6565                void  GetParameterValue(Mat* pmat){ISSMERROR("Double param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
     66                void  GetParameterValue(FILE** pfid){ISSMERROR("Double param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6667
    6768                void  SetValue(bool boolean){this->value=(double)boolean;}
     
    7475                void  SetValue(Vec vec){ISSMERROR("Double param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7576                void  SetValue(Mat mat){ISSMERROR("Double param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     77                void  SetValue(FILE* fid){ISSMERROR("Double param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7678                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("Double param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    7779
  • issm/trunk/src/c/objects/Params/DoubleVecParam.h

    r4852 r4873  
    6464                void  GetParameterValue(Vec* pvec){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
    6565                void  GetParameterValue(Mat* pmat){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
     66                void  GetParameterValue(FILE** pfid){ISSMERROR("DoubleVec param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6667
    6768                void  SetValue(bool boolean){ISSMERROR("DoubleVec param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
     
    7475                void  SetValue(Vec vec){ISSMERROR("DoubleVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7576                void  SetValue(Mat mat){ISSMERROR("DoubleVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     77                void  SetValue(FILE* fid){ISSMERROR("DoubleVec param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7678                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("DoubleVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    7779               
  • issm/trunk/src/c/objects/Params/IntParam.h

    r4852 r4873  
    6363                void  GetParameterValue(Vec* pvec){ISSMERROR("Int param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
    6464                void  GetParameterValue(Mat* pmat){ISSMERROR("Int param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
     65                void  GetParameterValue(FILE** pfid){ISSMERROR("Int param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6566
    6667                void  SetValue(bool boolean){this->value=(int)boolean;}
     
    7374                void  SetValue(Vec vec){ISSMERROR("Int param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7475                void  SetValue(Mat mat){ISSMERROR("Int param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     76                void  SetValue(FILE* fid){ISSMERROR("Int param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7577                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("Int param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    7678
  • issm/trunk/src/c/objects/Params/Param.h

    r4852 r4873  
    4242                virtual void  GetParameterValue(Vec* pvec)=0;
    4343                virtual void  GetParameterValue(Mat* pmat)=0;
     44                virtual void  GetParameterValue(FILE** pfid)=0;
    4445               
    4546                virtual void  SetValue(bool boolean)=0;
     
    5253                virtual void  SetValue(Vec vec)=0;
    5354                virtual void  SetValue(Mat mat)=0;
     55                virtual void  SetValue(FILE* fid)=0;
    5456                virtual void  SetValue(double** array, int M, int* mdim_array, int* ndim_array)=0;
    5557
  • issm/trunk/src/c/objects/Params/PetscMatParam.h

    r4852 r4873  
    6464                void  GetParameterValue(Vec* pvec){ISSMERROR("PetscMat param of enum %i (%s) cannot return a vec",enum_type,EnumAsString(enum_type));}
    6565                void  GetParameterValue(Mat* poutput);
     66                void  GetParameterValue(FILE** pfid){ISSMERROR("PetscMat param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6667
    6768                void  SetValue(bool boolean){ISSMERROR("PetscMat param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
     
    7475                void  SetValue(Vec vec){ISSMERROR("PetscMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7576                void  SetValue(Mat mat);
     77                void  SetValue(FILE* fid){ISSMERROR("PetscMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7678                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("PetscMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    7779
  • issm/trunk/src/c/objects/Params/PetscVecParam.h

    r4852 r4873  
    6464                void  GetParameterValue(Mat* pmat){ISSMERROR("PetscVec param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
    6565                void  GetParameterValue(Vec* poutput);
     66                void  GetParameterValue(FILE** pfid){ISSMERROR("PetscVec of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6667
    67                 void  SetValue(bool boolean){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
    68                 void  SetValue(int integer){ISSMERROR("PetscVec param of enum %i (%s) cannot hold an integer",enum_type,EnumAsString(enum_type));}
    69                 void  SetValue(double scalar){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a scalar",enum_type,EnumAsString(enum_type));}
    70                 void  SetValue(char* string){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a string",enum_type,EnumAsString(enum_type));}
    71                 void  SetValue(char** stringarray,int M){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a string array",enum_type,EnumAsString(enum_type));}
    72                 void  SetValue(double* doublearray,int M){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a double array",enum_type,EnumAsString(enum_type));}
    73                 void  SetValue(double* pdoublearray,int M,int N){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a double array",enum_type,EnumAsString(enum_type));}
     68                void  SetValue(bool boolean){ISSMERROR("PetscVec of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
     69                void  SetValue(int integer){ISSMERROR("PetscVec of enum %i (%s) cannot hold an integer",enum_type,EnumAsString(enum_type));}
     70                void  SetValue(double scalar){ISSMERROR("PetscVec of enum %i (%s) cannot hold a scalar",enum_type,EnumAsString(enum_type));}
     71                void  SetValue(char* string){ISSMERROR("PetscVec of enum %i (%s) cannot hold a string",enum_type,EnumAsString(enum_type));}
     72                void  SetValue(char** stringarray,int M){ISSMERROR("PetscVec of enum %i (%s) cannot hold a string array",enum_type,EnumAsString(enum_type));}
     73                void  SetValue(double* doublearray,int M){ISSMERROR("PetscVec of enum %i (%s) cannot hold a double array",enum_type,EnumAsString(enum_type));}
     74                void  SetValue(double* pdoublearray,int M,int N){ISSMERROR("PetscVec of enum %i (%s) cannot hold a double array",enum_type,EnumAsString(enum_type));}
    7475                void  SetValue(Vec vec);
    75                 void  SetValue(Mat mat){ISSMERROR("PetscVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     76                void  SetValue(Mat mat){ISSMERROR("PetscVec of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     77                void  SetValue(FILE* fid){ISSMERROR("PetscVec of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7678                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("PetscVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    7779
  • issm/trunk/src/c/objects/Params/StringArrayParam.h

    r4852 r4873  
    6666                void  GetParameterValue(Vec* pvec){ISSMERROR("StringArray param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
    6767                void  GetParameterValue(Mat* pmat){ISSMERROR("StringArray param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
     68                void  GetParameterValue(FILE** pfid){ISSMERROR("StringArray param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6869
    6970                void  SetValue(bool boolean){ISSMERROR("StringArray param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
     
    7677                void  SetValue(Vec vec){ISSMERROR("StringArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7778                void  SetValue(Mat mat){ISSMERROR("StringArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     79                void  SetValue(FILE* fid){ISSMERROR("StringArray param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7880                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("StringArray param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    7981
  • issm/trunk/src/c/objects/Params/StringParam.h

    r4852 r4873  
    6464                void  GetParameterValue(Vec* pvec){ISSMERROR("String param of enum %i (%s) cannot return a Vec",enum_type,EnumAsString(enum_type));}
    6565                void  GetParameterValue(Mat* pmat){ISSMERROR("String param of enum %i (%s) cannot return a Mat",enum_type,EnumAsString(enum_type));}
     66                void  GetParameterValue(FILE** pfid){ISSMERROR("Bool param of enum %i (%s) cannot return a FILE",enum_type,EnumAsString(enum_type));}
    6667
    6768                void  SetValue(bool boolean){ISSMERROR("String param of enum %i (%s) cannot hold a boolean",enum_type,EnumAsString(enum_type));}
     
    7475                void  SetValue(Vec vec){ISSMERROR("String param of enum %i (%s) cannot hold a Vec",enum_type,EnumAsString(enum_type));}
    7576                void  SetValue(Mat mat){ISSMERROR("String param of enum %i (%s) cannot hold a Mat",enum_type,EnumAsString(enum_type));}
     77                void  SetValue(FILE* fid){ISSMERROR("String param of enum %i (%s) cannot hold a FILE",enum_type,EnumAsString(enum_type));}
    7678                void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){ISSMERROR("String param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumAsString(enum_type));}
    7779
  • issm/trunk/src/c/objects/Patch.cpp

    r4546 r4873  
    125125        #endif
    126126       
    127        
    128127        /*First, figure out total number of rows combining all the cpus: */
    129128        MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
    130129        MPI_Bcast(&total_numrows,1,MPI_INT,0,MPI_COMM_WORLD);
     130
     131        /*return if patch empty*/
     132        if(total_numrows==0) return;
    131133
    132134        /*Now, allocate buffer to holds all the values, on node 0: */
  • issm/trunk/src/c/objects/objects.h

    r4853 r4873  
    8383#include "./Params/DoubleVecParam.h"
    8484#include "./Params/IntParam.h"
     85#include "./Params/FileParam.h"
    8586#include "./Params/Param.h"
    8687#include "./Params/PetscMatParam.h"
  • issm/trunk/src/c/solutions/controlrestart.cpp

    r4211 r4873  
    2222
    2323        /*write to disk: */
    24         OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
     24        OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,&femmodel->results);
    2525
    2626}
  • issm/trunk/src/c/solutions/issm.cpp

    r4574 r4873  
    1212
    1313        /*I/O: */
    14         FILE     *fid              = NULL;
     14        FILE     *input_fid        = NULL;
     15        FILE     *output_fid       = NULL;
    1516        char     *inputfilename    = NULL;
    1617        char     *outputfilename   = NULL;
     
    4849        MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
    4950
    50         _printf_("recover input and output file names:\n");
     51        _printf_("recover solution and file names:\n");
    5152        solution_type=StringAsEnum(argv[1]);
    5253        inputfilename=argv[3];
     
    6061        SolutionConfiguration(&analyses,&numanalyses,&solutioncore,solution_type);
    6162
    62         /*Open handle to data on disk: */
    63         fid=pfopen(inputfilename,"rb");
     63        /*Open input file to process model
     64         * and ouput file to start unload results*/
     65        input_fid =pfopen(inputfilename ,"rb");
     66        output_fid=pfopen(outputfilename,"wb");
    6467
    6568        _printf_("create finite element model:\n");
    66         femmodel=new FemModel(fid,solution_type,analyses,numanalyses);
     69        femmodel=new FemModel(input_fid,solution_type,analyses,numanalyses);
    6770
    68         /*add outputfilename in parameters: */
    69         femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename));
     71        /*add output_fid to parameters: */
     72        femmodel->parameters->SetParam(output_fid,OutputFilePointerEnum);
    7073       
    7174        /*get parameters: */
     
    9699
    97100                _printf_("write results to disk:\n");
    98                 OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
     101                OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,&femmodel->results);
    99102        }
    100103        else{
     
    111114        }
    112115
     116        /*Close output file and write lock file if requested*/
     117        pfclose(output_fid,outputfilename);
    113118        if (waitonlock>0){
    114119                _printf_("write lock file:\n");
  • issm/trunk/src/c/solutions/transient2d_core.cpp

    r4728 r4873  
    6262                        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceEnum,step,time);
    6363                        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedEnum,step,time);
     64
     65                        /*unload results*/
     66                        if(verbose)_printf_("%s","      saving temporary results...");
     67                        OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,&femmodel->results,step,time);
    6468                }
    6569        }
  • issm/trunk/src/c/solutions/transient3d_core.cpp

    r4747 r4873  
    7777                        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum,step,time);
    7878                        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,MeltingRateEnum,step,time);
    79                 }
    8079
    81                 if (step%5==0){
     80                        /*unload results*/
    8281                        if(verbose)_printf_("%s","      saving temporary results...");
    83                         OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
     82                        OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,&femmodel->results,step,time);
    8483                }
    8584        }
  • issm/trunk/src/m/classes/public/display/displaymesh.m

    r3994 r4873  
    3636
    3737disp(sprintf('\n      Properties:'));
    38 fielddisplay(md,'type','mesh type');
     38fielddisplay(md,'dim','mesh dimension (2d or 3d)');
    3939fielddisplay(md,'numlayers','number of extrusion layers');
    4040fielddisplay(md,'extrusionexponent','exponent for extrusion');
    41 fielddisplay(md,'dof','maximum number of dofs solved');
    4241fielddisplay(md,'bamg','Geometry and 2d mesh properties (if generated by Bamg)');
    4342fielddisplay(md,'penalties','penalties list');
  • issm/trunk/src/m/classes/public/display/fielddisplay.m

    r1277 r4873  
    4747
    4848        else
    49                 error('displayline error message: type not supported yet');
     49                displayunit(offset,name,'not displayed',comment),
     50
    5051        end
    5152end %function
  • issm/trunk/src/m/solutions/MatlabProcessPatch.m

    r4439 r4873  
    55%      Result=ProcessPatch(Result);
    66
    7 %Get out if no Patch
     7%return if there is no fiel Patch
    88if (~isfield(structure,'Patch')),
    99        return;
    10 else
    11         Patch=structure(1).Patch;
    12         numvertices=structure(1).PatchVertices;
    1310end
    1411
    15 %Get number of fields;
    16 fields=unique(Patch(:,1));
    17 steps=unique(Patch(:,2));
     12%loop over steps
     13for i=1:length(structure),
    1814
    19 %parse steps
    20 for j=1:length(steps),
     15        %Get Patch for current step
     16        Patch=structure(i).Patch;
     17        numvertices=structure(i).PatchVertices;
    2118
    22         posstep=find(Patch(:,2)==steps(j));
    23        
    24         %Take all the lines of the Patch for this timestep
    25         temporarypatch=Patch(posstep,:);
    26         time=temporarypatch(1,3);
    27         step=temporarypatch(1,2);
     19        %check that Patch is not empty
     20        if length(Patch)==0 continue; end
    2821
    29         %parse fields
    30         for i=1:length(fields),
     22        %Get number of fields;
     23        fields=unique(Patch(:,1));
     24        steps=unique(Patch(:,2));
    3125
    32                 %get name
    33                 fieldname=EnumAsString(fields(i));
     26        %parse steps
     27        for j=1:length(steps),
    3428
    35                 %get line positions
    36                 pos=find(temporarypatch(:,1)==fields(i));
     29                posstep=find(Patch(:,2)==steps(j));
    3730
    38                 %Fill Result structure
    39                 structure(step).steps=step;
    40                 structure(step).time=time;
    41                 structure(step).(fieldname).element=temporarypatch(pos,4);
    42                 structure(step).(fieldname).interpolation=temporarypatch(pos,5);
    43                 structure(step).(fieldname).index=temporarypatch(pos,6:5+numvertices);
    44                 structure(step).(fieldname).value=temporarypatch(pos,6+numvertices:end);
     31                %Take all the lines of the Patch for this timestep
     32                temporarypatch=Patch(posstep,:);
     33                time=temporarypatch(1,3);
     34                step=temporarypatch(1,2);
    4535
     36                %parse fields
     37                for i=1:length(fields),
     38
     39                        %get name
     40                        fieldname=EnumAsString(fields(i));
     41
     42                        %get line positions
     43                        pos=find(temporarypatch(:,1)==fields(i));
     44
     45                        %Fill Result structure
     46                        structure(step).steps=step;
     47                        structure(step).time=time;
     48                        structure(step).(fieldname).element=temporarypatch(pos,4);
     49                        structure(step).(fieldname).interpolation=temporarypatch(pos,5);
     50                        structure(step).(fieldname).index=temporarypatch(pos,6:5+numvertices);
     51                        structure(step).(fieldname).value=temporarypatch(pos,6+numvertices:end);
     52
     53                end
    4654        end
    4755end
  • issm/trunk/src/mex/OutputResults/OutputResults.cpp

    r4573 r4873  
    4343
    4444        /*Call "x" code layer: */
    45         OutputResultsx(&dataref, elements,nodes,vertices,loads,materials,parameters,results);
     45        OutputResultsx(&dataref, elements,nodes,vertices,loads,materials,parameters,&results);
    4646
    4747        /*write output datasets: */
Note: See TracChangeset for help on using the changeset viewer.