Changeset 17513


Ignore:
Timestamp:
03/21/14 09:07:07 (11 years ago)
Author:
Mathieu Morlighem
Message:

CHG: working on spawnTria function of Tetra

Location:
issm/trunk-jpl/src/c
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/analyses/L2ProjectionBaseAnalysis.cpp

    r17274 r17513  
    3636void L2ProjectionBaseAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/
    3737
    38         if(iomodel->meshtype==Mesh3DEnum){
     38        if(iomodel->meshtype==Mesh3DEnum || iomodel->meshtype==Mesh3DtetrasEnum){
    3939                iomodel->FetchData(2,MeshVertexonbedEnum,MeshVertexonsurfaceEnum);
    4040        }
     
    8282                        break;
    8383                case Mesh3DEnum:
     84                        if(!element->IsOnBed()) return NULL;
     85                        basalelement = element->SpawnBasalElement();
     86                        break;
     87                case Mesh3DtetrasEnum:
    8488                        if(!element->IsOnBed()) return NULL;
    8589                        basalelement = element->SpawnBasalElement();
     
    141145                        break;
    142146                case Mesh3DEnum:
     147                        if(!element->IsOnBed()) return NULL;
     148                        basalelement = element->SpawnBasalElement();
     149                        break;
     150                case Mesh3DtetrasEnum:
    143151                        if(!element->IsOnBed()) return NULL;
    144152                        basalelement = element->SpawnBasalElement();
     
    213221                        break;
    214222                case Mesh2DverticalEnum:
     223                case Mesh3DtetrasEnum:
    215224                        element->InputUpdateFromSolutionOneDof(solution,inputenum);
    216225                        break;
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/ElementHook.cpp

    r16382 r17513  
    128128}
    129129/*}}}*/
     130/*FUNCTION ElementHook::SpawnTriaHook{{{*/
     131void ElementHook::SpawnTriaHook(ElementHook* triahook,int index1,int index2,int index3){
     132
     133        /*Create arrow of indices depending on location (0=base 1=surface)*/
     134        int indices[3];
     135        indices[0] = index1;
     136        indices[1] = index2;
     137        indices[2] = index3;
     138
     139        triahook->numanalyses=this->numanalyses;
     140
     141        /*Spawn nodes hook*/
     142        triahook->hnodes=new Hook*[this->numanalyses];
     143        for(int i=0;i<this->numanalyses;i++){
     144                /*Do not do anything if Hook is empty*/
     145                if (!this->hnodes[i] || this->hnodes[i]->GetNum()==0){
     146                        triahook->hnodes[i]=NULL;
     147                }
     148                else{
     149                        triahook->hnodes[i]=this->hnodes[i]->Spawn(indices,3);
     150                }
     151        }
     152
     153        /*do not spawn hmaterial. material will be taken care of by Penta*/
     154        triahook->hmaterial=NULL;
     155        triahook->hvertices=(Hook*)this->hvertices->Spawn(indices,3);
     156        triahook->hmatpar=(Hook*)this->hmatpar->copy();
     157}
     158/*}}}*/
    130159/*FUNCTION ElementHook::SpawnSegHook{{{*/
    131160void ElementHook::SpawnSegHook(ElementHook* triahook,int index1,int index2){
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/ElementHook.h

    r16382 r17513  
    2525
    2626                void SetHookNodes(int* node_ids,int numnodes,int analysis_counter);
    27                 void SpawnTriaHook(ElementHook* triahook,int location); //3d only
     27                void SpawnTriaHook(ElementHook* triahook,int location); //3d only TO BE REMOVED (replaced by the one below)
     28                void SpawnTriaHook(ElementHook* triahook,int index1,int index2,int index3); //3d only
    2829                void SpawnSegHook(ElementHook* triahook,int ndex1,int index2); //2d only
    2930                void InitHookNeighbors(int* element_ids);               //3d only
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/Tetra.cpp

    r17511 r17513  
    763763}
    764764/*}}}*/
     765/*FUNCTION Tetra::SpawnBasalElement{{{*/
     766Element*  Tetra::SpawnBasalElement(void){
     767
     768        _assert_(HasFaceOnBed());
     769
     770        int index1,index2,index3;
     771        this->FaceOnBedIndices(&index1,&index2,&index3);
     772        return SpawnTria(index1,index2,index3);
     773}/*}}}*/
     774/*FUNCTION Tetra::SpawnTopElement{{{*/
     775Element*  Tetra::SpawnTopElement(void){
     776
     777        _assert_(HasFaceOnSurface());
     778
     779        int index1,index2,index3;
     780        this->FaceOnSurfaceIndices(&index1,&index2,&index3);
     781        return SpawnTria(index1,index2,index3);
     782}/*}}}*/
     783/*FUNCTION Tetra::SpawnTria{{{*/
     784Tria*  Tetra::SpawnTria(int index1,int index2,int index3){
     785
     786        int analysis_counter;
     787
     788        /*go into parameters and get the analysis_counter: */
     789        this->parameters->FindParam(&analysis_counter,AnalysisCounterEnum);
     790
     791        /*Create Tria*/
     792        Tria* tria=new Tria();
     793        tria->id=this->id;
     794        tria->inputs=(Inputs*)this->inputs->SpawnTriaInputs(index1,index2,index3);
     795        tria->parameters=this->parameters;
     796        tria->element_type=P1Enum; //Only P1 CG for now (TO BE CHANGED)
     797        this->SpawnTriaHook(dynamic_cast<ElementHook*>(tria),index1,index2,index3);
     798
     799        /*Spawn material*/
     800        tria->material=(Material*)this->material->copy2(tria);
     801
     802        /*recover nodes, material and matpar: */
     803        tria->nodes    = (Node**)tria->hnodes[analysis_counter]->deliverp();
     804        tria->vertices = (Vertex**)tria->hvertices->deliverp();
     805        tria->matpar   = (Matpar*)tria->hmatpar->delivers();
     806
     807        /*Return new Tria*/
     808        return tria;
     809}
     810/*}}}*/
    765811/*FUNCTION Tetra::Update {{{*/
    766812void Tetra::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type,int finiteelement_type){
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/Tetra.h

    r17511 r17513  
    112112                int         NumberofNodesVelocity(void);
    113113                int         NumberofNodesPressure(void);
    114            Element*    SpawnBasalElement(void){_error_("not implemented yet");};
    115                 Element*    SpawnTopElement(void){_error_("not implemented yet");};
     114           Element*    SpawnBasalElement(void);
     115                Element*    SpawnTopElement(void);
     116                Tria*       SpawnTria(int index1,int index2,int index3);
    116117                IssmDouble  StabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){_error_("not implemented yet");};
    117118                IssmDouble  PureIceEnthalpy(IssmDouble pressure){_error_("not implemented yet");};
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/BoolInput.cpp

    r16799 r17513  
    7171/*FUNCTION BoolInput::SpawnTriaInput{{{*/
    7272Input* BoolInput::SpawnTriaInput(int location){
     73
     74                /*output*/
     75                BoolInput* outinput=new BoolInput();
     76
     77                /*only copy current value*/
     78                outinput->enum_type=this->enum_type;
     79                outinput->value=this->value;
     80
     81                /*Assign output*/
     82                return outinput;
     83
     84}
     85/*}}}*/
     86/*FUNCTION BoolInput::SpawnTriaInput{{{*/
     87Input* BoolInput::SpawnTriaInput(int index1,int index2,int index3){
    7388
    7489                /*output*/
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/BoolInput.h

    r17100 r17513  
    3131                int   InstanceEnum();
    3232                Input* SpawnTriaInput(int location);
     33                Input* SpawnTriaInput(int index1,int index2,int index3);
    3334                Input* SpawnSegInput(int index1,int index2);
    3435                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp

    r17100 r17513  
    196196        return values->SpawnTriaInput(location);
    197197}/*}}}*/
     198/*FUNCTION ControlInput::SpawnTriaInput{{{*/
     199Input* ControlInput::SpawnTriaInput(int index1,int index2,int index3){
     200        return values->SpawnTriaInput(index1,index2,index3);
     201}/*}}}*/
    198202/*FUNCTION ControlInput::SpawnSegInput{{{*/
    199203Input* ControlInput::SpawnSegInput(int index1,int index2){
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h

    r17100 r17513  
    3939                int    InstanceEnum();
    4040                Input* SpawnTriaInput(int location);
     41                Input* SpawnTriaInput(int index1,int index2,int index3);
    4142                Input* SpawnSegInput(int index1,int index2);
    4243                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp

    r16675 r17513  
    9696}
    9797/*}}}*/
     98/*FUNCTION DatasetInput::SpawnTriaInput{{{*/
     99Input* DatasetInput::SpawnTriaInput(int index1,int index2,int index3){
     100
     101        /*output*/
     102        DatasetInput* outinput=NULL;
     103
     104        /*Create new Datasetinput (copy of current input)*/
     105        outinput=new DatasetInput();
     106        outinput->enum_type=this->enum_type;
     107        outinput->inputs=dynamic_cast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3));
     108        outinput->numids=this->numids;
     109        outinput->ids=xNew<int>(this->numids);
     110        xMemCpy(outinput->ids,this->ids,this->numids);
     111
     112        /*Assign output*/
     113        return outinput;
     114}
     115/*}}}*/
    98116/*FUNCTION DatasetInput::SpawnSegInput{{{*/
    99117Input* DatasetInput::SpawnSegInput(int index1,int index2){
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h

    r17100 r17513  
    3737                int    InstanceEnum();
    3838                Input* SpawnTriaInput(int location);
     39                Input* SpawnTriaInput(int index1,int index2,int index3);
    3940                Input* SpawnSegInput(int index1,int index2);
    4041                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.cpp

    r17094 r17513  
    8484}
    8585/*}}}*/
     86/*FUNCTION DoubleInput::SpawnTriaInput{{{*/
     87Input* DoubleInput::SpawnTriaInput(int index1,int index2,int index3){
     88
     89        /*output*/
     90        DoubleInput* outinput=new DoubleInput();
     91
     92        /*only copy current value*/
     93        outinput->enum_type=this->enum_type;
     94        outinput->value=this->value;
     95
     96        /*Assign output*/
     97        return outinput;
     98
     99}
     100/*}}}*/
    86101/*FUNCTION DoubleInput::SpawnSegInput{{{*/
    87102Input* DoubleInput::SpawnSegInput(int index1,int index2){
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h

    r17100 r17513  
    3434                int   InstanceEnum();
    3535                Input* SpawnTriaInput(int location);
     36                Input* SpawnTriaInput(int index1,int index2,int index3);
    3637                Input* SpawnSegInput(int index1,int index2);
    3738                Input* PointwiseDivide(Input* inputB);
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/Input.h

    r17100 r17513  
    5555
    5656                virtual Input* SpawnTriaInput(int location)=0;
     57                virtual Input* SpawnTriaInput(int index1,int index2,int index3)=0;
    5758                virtual Input* SpawnSegInput(int index1,int index2)=0;
    5859                virtual Input* PointwiseDivide(Input* inputB)=0;
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp

    r16382 r17513  
    395395}
    396396/*}}}*/
     397/*FUNCTION Inputs::SpawnTriaInputs{{{*/
     398Inputs* Inputs::SpawnTriaInputs(int index1,int index2,int index3){
     399
     400        /*Intermediary*/
     401        vector<Object*>::iterator object;
     402        Input* inputin=NULL;
     403        Input* inputout=NULL;
     404
     405        /*Output*/
     406        Inputs* newinputs=new Inputs();
     407
     408        /*Go through inputs and call Spawn function*/
     409        for ( object=objects.begin() ; object < objects.end(); object++ ){
     410
     411                /*Create new input*/
     412                inputin=dynamic_cast<Input*>(*object);
     413                inputout=inputin->SpawnTriaInput(index1,index2,index3);
     414
     415                /*Add input to new inputs*/
     416                newinputs->AddObject(inputout);
     417        }
     418
     419        /*Assign output pointer*/
     420        return newinputs;
     421}
     422/*}}}*/
    397423/*FUNCTION Inputs::SpawnSegInputs{{{*/
    398424Inputs* Inputs::SpawnSegInputs(int index1,int index2){
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/Inputs.h

    r16382 r17513  
    2828                void        DuplicateInput(int original_enum,int new_enum);
    2929                Input*      GetInput(int enum_name);
    30                 Inputs*     SpawnTriaInputs(int position);
     30                Inputs*     SpawnTriaInputs(int position);//TO BE REMOVED (replaced by the other one)
     31                Inputs*     SpawnTriaInputs(int index1,int index2,int index3);
    3132                Inputs*     SpawnSegInputs(int index1,int index2);
    3233                Inputs*     SpawnSegInputs(int position);
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/IntInput.cpp

    r16799 r17513  
    7171/*FUNCTION IntInput::SpawnTriaInput{{{*/
    7272Input* IntInput::SpawnTriaInput(int location){
     73
     74        /*output*/
     75        IntInput* outinput=new IntInput();
     76
     77        /*only copy current value*/
     78        outinput->enum_type=this->enum_type;
     79        outinput->value=this->value;
     80
     81        /*Assign output*/
     82        return outinput;
     83}
     84/*}}}*/
     85/*FUNCTION IntInput::SpawnTriaInput{{{*/
     86Input* IntInput::SpawnTriaInput(int index1,int index2,int index3){
    7387
    7488        /*output*/
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/IntInput.h

    r17100 r17513  
    3535                int   InstanceEnum();
    3636                Input* SpawnTriaInput(int location);
     37                Input* SpawnTriaInput(int index1,int index2,int index3);
    3738                Input* SpawnSegInput(int index1,int index2);
    3839                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp

    r17345 r17513  
    123123}
    124124/*}}}*/
     125/*FUNCTION PentaInput::SpawnTriaInput{{{*/
     126Input* PentaInput::SpawnTriaInput(int index1,int index2,int index3){
     127
     128        /*output*/
     129        TriaInput* outinput=NULL;
     130
     131        if(this->element_type==P0Enum){
     132                outinput=new TriaInput(this->enum_type,&this->values[0],P0Enum);
     133        }
     134        else{
     135                /*Assume P1 interpolation only for now*/
     136                IssmDouble newvalues[3];
     137
     138                /*Create array of indices depending on location (0=base 1=surface)*/
     139                int indices[3];
     140                indices[0] = index1;
     141                indices[1] = index2;
     142                indices[2] = index3;
     143
     144                /*Create new input*/
     145                for(int i=0;i<3;i++){
     146                        _assert_(indices[i]>=0 && indices[i]<6);
     147                        newvalues[i]=this->values[indices[i]];
     148                }
     149                outinput=new TriaInput(this->enum_type,&newvalues[0],P1Enum);
     150        }
     151
     152        /*Assign output*/
     153        return outinput;
     154}
     155/*}}}*/
    125156/*FUNCTION PentaInput::SpawnSegInput{{{*/
    126157Input* PentaInput::SpawnSegInput(int index1,int index2){
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h

    r17345 r17513  
    3535                int   InstanceEnum();
    3636                Input* SpawnTriaInput(int location);
     37                Input* SpawnTriaInput(int index1,int index2,int index3);
    3738                Input* SpawnSegInput(int index1,int index2);
    3839                Input* PointwiseDivide(Input* inputB);
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/SegInput.h

    r17309 r17513  
    3535                int    InstanceEnum();
    3636                Input* SpawnTriaInput(int location){_error_("not supported yet");};
     37                Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not supported yet");};
    3738                Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
    3839                Input* PointwiseDivide(Input* inputB){_error_("not supported yet");};
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp

    r17472 r17513  
    185185}
    186186/*}}}*/
     187/*FUNCTION TetraInput::SpawnTriaInput{{{*/
     188Input* TetraInput::SpawnTriaInput(int index1,int index2,int index3){
     189
     190        /*output*/
     191        TriaInput* outinput=NULL;
     192
     193        if(this->element_type==P0Enum){
     194                outinput=new TriaInput(this->enum_type,&this->values[0],P0Enum);
     195        }
     196        else{
     197                /*Assume P1 interpolation only for now*/
     198                IssmDouble newvalues[3];
     199
     200                /*Create array of indices depending on location (0=base 1=surface)*/
     201                int indices[3];
     202                indices[0] = index1;
     203                indices[1] = index2;
     204                indices[2] = index3;
     205
     206                /*Create new input*/
     207                for(int i=0;i<3;i++){
     208                        _assert_(indices[i]>=0 && indices[i]<4);
     209                        newvalues[i]=this->values[indices[i]];
     210                }
     211                outinput=new TriaInput(this->enum_type,&newvalues[0],P1Enum);
     212        }
     213
     214        /*Assign output*/
     215        return outinput;
     216}
     217/*}}}*/
    187218
    188219/*Intermediary*/
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h

    r17472 r17513  
    3535                int    InstanceEnum();
    3636                Input* SpawnTriaInput(int location){_error_("not supported yet");};
     37                Input* SpawnTriaInput(int index1,int index2,int index3);
    3738                Input* SpawnSegInput(int index1,int index2){_error_("not supported yet");};
    3839                Input* PointwiseDivide(Input* inputB);
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp

    r17100 r17513  
    135135        xMemCpy(outinput->timesteps,this->timesteps,this->numtimesteps);
    136136        outinput->inputs=(Inputs*)this->inputs->SpawnTriaInputs(location);
     137        outinput->parameters=this->parameters;
     138
     139        /*Assign output*/
     140        return outinput;
     141
     142}
     143/*}}}*/
     144/*FUNCTION TransientInput::SpawnTriaInput{{{*/
     145Input* TransientInput::SpawnTriaInput(int index1,int index2,int index3){
     146
     147        /*output*/
     148        TransientInput* outinput=NULL;
     149
     150        /*Create new Transientinput (copy of current input)*/
     151        outinput=new TransientInput();
     152        outinput->enum_type=this->enum_type;
     153        outinput->numtimesteps=this->numtimesteps;
     154        outinput->timesteps=xNew<IssmDouble>(this->numtimesteps);
     155        xMemCpy(outinput->timesteps,this->timesteps,this->numtimesteps);
     156        outinput->inputs=(Inputs*)this->inputs->SpawnTriaInputs(index1,index2,index3);
    137157        outinput->parameters=this->parameters;
    138158
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h

    r17100 r17513  
    4141                int    InstanceEnum();
    4242                Input* SpawnTriaInput(int location);
     43                Input* SpawnTriaInput(int index1,int index2,int index3);
    4344                Input* SpawnSegInput(int index1,int index2);
    4445                Input* PointwiseDivide(Input* forcingB){_error_("not implemented yet");};
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp

    r17321 r17513  
    9595}
    9696/*}}}*/
     97/*FUNCTION TriaInput::SpawnTriaInput{{{*/
     98Input* TriaInput::SpawnTriaInput(int index1,int index2,int index3){
     99
     100        /*output*/
     101        TriaInput* outinput=NULL;
     102
     103        /*Create new Tria input (copy of current input)*/
     104        outinput=new TriaInput(this->enum_type,&this->values[0],this->element_type);
     105
     106        /*Assign output*/
     107        return outinput;
     108
     109}
     110/*}}}*/
    97111/*FUNCTION TriaInput::SpawnSegInput{{{*/
    98112Input* TriaInput::SpawnSegInput(int index1,int index2){
  • TabularUnified issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h

    r17100 r17513  
    3535                int    InstanceEnum();
    3636                Input* SpawnTriaInput(int location);
     37                Input* SpawnTriaInput(int index1,int index2,int index3);
    3738                Input* SpawnSegInput(int index1,int index2);
    3839                Input* PointwiseDivide(Input* inputB);
  • TabularUnified issm/trunk-jpl/src/c/classes/Node.cpp

    r17429 r17513  
    101101                                analysis_enum==ExtrapolationAnalysisEnum
    102102                                ){
    103                 if(iomodel->meshtype==Mesh3DEnum || iomodel->meshtype==Mesh2DverticalEnum){
     103                if(iomodel->meshtype!=Mesh2DhorizontalEnum){
    104104                        /*On a 3d mesh, we may have collapsed elements, hence dead nodes. Freeze them out: */
    105105                        _assert_(iomodel->Data(MeshVertexonbedEnum));
     
    112112                                analysis_enum==FreeSurfaceTopAnalysisEnum
    113113                                ){
    114                 if(iomodel->meshtype==Mesh3DEnum || iomodel->meshtype==Mesh2DverticalEnum){
     114                if(iomodel->meshtype!=Mesh2DhorizontalEnum){
    115115                        /*On a 3d mesh, we may have collapsed elements, hence dead nodes. Freeze them out: */
    116116                        _assert_(iomodel->Data(MeshVertexonsurfaceEnum));
  • TabularUnified issm/trunk-jpl/src/c/shared/Exceptions/exceptions.h

    r16228 r17513  
    6363                return 0;\
    6464        }\
    65         catch (exception& e) {\
     65        catch(exception& e) {\
    6666                _printf_("Standard exception: " << e.what() << "\n\n");\
    6767                return 0;\
Note: See TracChangeset for help on using the changeset viewer.