Changeset 4369


Ignore:
Timestamp:
06/30/10 16:05:31 (15 years ago)
Author:
Eric.Larour
Message:

PentaHook can now spawn a TriaHook. Will fix the SpawnTria created leak

Location:
issm/trunk/src/c/objects
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r4367 r4369  
    996996       
    997997        /*Do nothing if we  don't find it: */
    998         if(!input) return;
     998        if(!input)return;
    999999
    10001000        /*Constrain input using cm_min and cm_max: */
     
    10451045        /*Make a copy of the original input: */
    10461046        original=(Input*)this->inputs->GetInput(original_enum);
    1047         if(!original)ISSMERROR(" could not find old input with enum: %s",EnumAsString(original_enum));
    10481047        copy=(Input*)original->copy();
    10491048
     
    10621061        /*Make a copy of the original input: */
    10631062        input=(Input*)this->inputs->GetInput(enum_type);
    1064         if(!input)ISSMERROR(" could not find old input with enum: %s",EnumAsString(enum_type));
    10651063
    10661064        /*Scale: */
     
    17651763
    17661764        int i;
     1765        int analysis_counter;
     1766       
     1767        /*go into parameters and get the analysis_counter: */
     1768        this->parameters->FindParam(&analysis_counter,AnalysisCounterEnum);
    17671769
    17681770        /*out of grids g0,g1 and g2 from Penta, build a tria element: */
     
    17871789        tria->results=tria_results;
    17881790        tria->parameters=tria_parameters;
     1791        this->SpawnTriaHook(dynamic_cast<TriaHook*>(tria),&indices[0]);
     1792
     1793        /*recover nodes, matice and matpar: */
     1794        this->nodes=(Node**)this->hnodes[analysis_counter].deliverp();
     1795        this->matice=(Matice*)this->hmatice.delivers();
     1796        this->matpar=(Matpar*)this->hmatpar.delivers();
    17891797       
    1790         /*now deal with nodes, matice and matpar: */
    1791         tria->nodes=(Node**)xmalloc(3*sizeof(Node*));
    1792         for(i=0;i<3;i++)tria->nodes[i]=this->nodes[indices[i]];
    1793         tria->matice=this->matice;
    1794         tria->matpar=this->matpar;
    1795 
    17961798        return tria;
    17971799}
  • issm/trunk/src/c/objects/Elements/PentaHook.cpp

    r4236 r4369  
    6262}
    6363/*}}}*/
     64/*FUNCTION PentaHook::SpawnTriaHook(TriaHook* triahook,int* indices);{{{1*/
     65void PentaHook::SpawnTriaHook(TriaHook* triahook,int* indices){
     66
     67        int i;
     68        int zero=0;
     69
     70        triahook->numanalyses=this->numanalyses;
     71        triahook->hnodes=new Hook[this->numanalyses];
     72
     73        for(i=0;i<this->numanalyses;i++){
     74                this->hnodes[i].Spawn(&triahook->hnodes[i],indices,3);
     75        }
     76       
     77        this->hmatice.copy(&triahook->hmatice);
     78        this->hmatpar.copy(&triahook->hmatpar);
     79}
     80/*}}}*/
  • issm/trunk/src/c/objects/Elements/PentaHook.h

    r4249 r4369  
    77
    88class Hook;
     9class TriaHook;
    910
    1011class PentaHook{
     
    2526                void InitHookMatpar(int matpar_id);
    2627                void InitHookNeighbors(int* element_ids);
     28                void SpawnTriaHook(TriaHook* triahook,int* indices);
    2729                /*}}}*/
    28 
    2930};
    3031
  • issm/trunk/src/c/objects/Hook.cpp

    r4248 r4369  
    363363/*}}}*/
    364364/*FUNCTION Hook::Spawn{{{1*/
    365 Hook* Hook::Spawn(int* indices, int numindices){
    366 
    367         int i;
    368         Object** subobjects=NULL;
    369         int       subnum;
    370         int*      suboffsets=NULL;
    371         int*      subids=NULL;
     365void Hook::Spawn(Hook* spawnedhook, int* indices, int numindices){
     366
     367        int i;
    372368
    373369        /*go pickup the correct objects, ids and offsets :*/
    374         subnum=numindices;
    375         if(subnum<1) ISSMERROR("Trying to spawn an empty ElementProperties!");
    376 
    377         subobjects=(Object**)xmalloc(subnum*sizeof(Object*));
    378         subids=(int*)xmalloc(subnum*sizeof(int));
    379         suboffsets=(int*)xmalloc(subnum*sizeof(int));
    380 
    381         for(i=0;i<subnum;i++){
    382                 subobjects[i]=this->objects[indices[i]];
    383                 subids[i]=this->ids[indices[i]];
    384                 suboffsets[i]=this->offsets[indices[i]];
    385         }
    386 
    387         return new Hook(subobjects,subids,suboffsets,subnum);
    388 }
    389 /*}}}*/
     370        spawnedhook->num=numindices;
     371        if(spawnedhook->num<1) ISSMERROR("Trying to spawn an empty ElementProperties!");
     372
     373        spawnedhook->objects=(Object**)xmalloc(spawnedhook->num*sizeof(Object*));
     374        spawnedhook->ids=(int*)xmalloc(spawnedhook->num*sizeof(int));
     375        spawnedhook->offsets=(int*)xmalloc(spawnedhook->num*sizeof(int));
     376
     377        for(i=0;i<spawnedhook->num;i++){
     378                spawnedhook->objects[i]=this->objects[indices[i]];
     379                spawnedhook->ids[i]=this->ids[indices[i]];
     380                spawnedhook->offsets[i]=this->offsets[indices[i]];
     381        }
     382}
     383/*}}}*/
  • issm/trunk/src/c/objects/Hook.h

    r4248 r4369  
    4646                Object**   deliverp(void); //deliver all objects
    4747                void       configure(DataSet* dataset);
    48                 Hook*      Spawn(int* indices, int numindices);
     48                void       Spawn(Hook* spawnedhook, int* indices, int numindices);
    4949                Object**   GetObjects(void);
    5050                int*       Ids(void);
Note: See TracChangeset for help on using the changeset viewer.