Changeset 13916


Ignore:
Timestamp:
11/08/12 15:15:00 (12 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added memory allocation methods for loads

Location:
issm/trunk-jpl/src/c/Container
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Container/Loads.cpp

    r13797 r13916  
    5353}
    5454/*}}}*/
    55 /*FUNCTION Loads::NumberOfLoads{{{*/
     55/*FUNCTION Loads::MaxNumNodes{{{*/
     56int Loads::MaxNumNodes(int analysis_type){
     57
     58        int max=0;
     59        int allmax;
     60        int numnodes=0;
     61
     62        /*Now go through all loads, and get how many nodes they own, unless they are clone nodes: */
     63        for(int i=0;i<this->Size();i++){
     64
     65                Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
     66                if (load->InAnalysis(analysis_type)){
     67                        numnodes=load->GetNumberOfNodes();
     68                        if(numnodes>max)max=numnodes;
     69                }
     70        }
     71
     72        /*Grab max of all cpus: */
     73#ifdef _HAVE_MPI_
     74        MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
     75        max=allmax;
     76#endif
     77
     78        return max;
     79}
     80/*}}}*/
     81/*FUNCTION Loads::NumberOfLoads(){{{*/
    5682int Loads::NumberOfLoads(void){
    5783
     
    7399}
    74100/*}}}*/
     101/*FUNCTION Loads::NumberOfLoads(int analysis){{{*/
     102int Loads::NumberOfLoads(int analysis_type){
     103
     104        int localloads = 0;
     105        int numberofloads;
     106
     107        /*Get number of local loads*/
     108        for(int i=0;i<this->Size();i++){
     109
     110                Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
     111
     112                /*Check that this load corresponds to our analysis currently being carried out: */
     113                if (load->InAnalysis(analysis_type)) localloads++;
     114        }
     115
     116        /*figure out total number of loads combining all the cpus (no clones here)*/
     117#ifdef _HAVE_MPI_
     118        MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
     119        MPI_Bcast(&numberofloads,1,MPI_INT,0,IssmComm::GetComm());
     120#else
     121        numberofloads=localloads;
     122#endif
     123
     124        return numberofloads;
     125}
     126/*}}}*/
     127/*FUNCTION Loads::Size(){{{*/
     128int Loads::Size(void){
     129
     130        return this->DataSet::Size();
     131}
     132/*}}}*/
     133/*FUNCTION Loads::Size(int analysis){{{*/
     134int Loads::Size(int analysis_type){
     135
     136        int localloads = 0;
     137
     138        /*Get number of local loads*/
     139        for(int i=0;i<this->Size();i++){
     140
     141                Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
     142
     143                /*Check that this load corresponds to our analysis currently being carried out: */
     144                if (load->InAnalysis(analysis_type)) localloads++;
     145        }
     146
     147        return localloads;
     148}
     149/*}}}*/
    75150/*FUNCTION Loads::SetCurrentConfiguration{{{*/
    76151void Loads::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
  • issm/trunk-jpl/src/c/Container/Loads.h

    r13797 r13916  
    2626                /*numerics*/
    2727                void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
     28                int   MaxNumNodes(int analysis);
    2829                int   NumberOfLoads(void);
     30                int   NumberOfLoads(int analysis);
    2931                void  SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
     32                int   Size(int analysis);
     33                int   Size(void);
    3034
    3135};
Note: See TracChangeset for help on using the changeset viewer.