Changeset 14678


Ignore:
Timestamp:
04/19/13 16:57:07 (12 years ago)
Author:
Eric.Larour
Message:

CHG: took out a dangerous link in the header files between GenericOption and Container.h
Added new Bucket object, which is there to collect values during the SetValues operation of
a parallel matrix in the ISSM toolkit.

Location:
issm/trunk-jpl/src/c
Files:
1 added
5 edited

Legend:

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

    r14570 r14678  
    44#include <vector>
    55#include "../classes/objects/Object.h"
    6 #include "../toolkits/toolkits.h"
    76#include "../EnumDefinitions/EnumDefinitions.h"
    87
  • issm/trunk-jpl/src/c/Makefile.am

    r14656 r14678  
    5353                                        ./classes/IoModel.h\
    5454                                        ./classes/IoModel.cpp\
     55                                        ./classes/objects/Bucket.h\
    5556                                        ./classes/objects/Node.h\
    5657                                        ./classes/objects/Node.cpp\
  • issm/trunk-jpl/src/c/classes/objects/Options/GenericOption.h

    r14647 r14678  
    1717#include "../../../include/include.h"
    1818#include "../../../shared/Exceptions/exceptions.h"
     19#include "../../../shared/Alloc/alloc.h"
     20#include "../../../shared/MemOps/xMemCpy.h"
    1921#include "../../../io/io.h"
    2022#include "../../../EnumDefinitions/EnumDefinitions.h"
  • issm/trunk-jpl/src/c/classes/objects/objects.h

    r13534 r14678  
    1717#include "./IndependentObject.h"
    1818#include "./Segment.h"
     19#include "./Bucket.h"
    1920
    2021/*Constraints: */
  • issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h

    r14671 r14678  
    2222#include "../../shared/Alloc/alloc.h"
    2323#include "../../include/macros.h"
     24#include "../../Container/DataSet.h"
     25#include "../../classes/IssmComm.h"
     26#include "../../classes/objects/Bucket.h"
    2427#include <math.h>
    2528
     
    3841        public:
    3942
    40                 int M,N;
     43                int M,N;  //global size
     44                int m;    //local number of rows
    4145                doubletype* matrix;  /*here, doubletype is either IssmDouble or IssmPDouble*/
     46                DataSet*    buckets;  /*here, we store buckets of values that we will Assemble into a global matrix.*/
    4247
    4348                /*IssmMpiDenseMat constructors, destructors*/
    4449                /*FUNCTION IssmMpiDenseMat(){{{*/
    4550                IssmMpiDenseMat(){
    46                         _error_("not supported yet!");
     51                        this->M=0;
     52                        this->N=0;
     53                        this->m=0;
     54                        this->matrix=NULL;
     55                        this->buckets=new DataSet();
    4756                }
    4857                /*}}}*/
    4958                /*FUNCTION IssmMpiDenseMat(int M,int N){{{*/
    50                 IssmMpiDenseMat(int pM,int pN){
    51                         _error_("not supported yet!");
     59                IssmMpiDenseMat(int Min,int Nin){
     60                        this->Init(Min,Nin);
    5261                }
    5362                /*}}}*/
    5463                /*FUNCTION IssmMpiDenseMat(int M,int N, doubletype sparsity){{{*/
    5564                IssmMpiDenseMat(int pM,int pN, doubletype sparsity){
    56                         _error_("not supported yet!");
     65                        /*no sparsity involved here, we are fully dense, so just use the previous constructor: */
     66                        this->Init(pM,pN);
    5767                }
    5868                /*}}}*/
    5969                /*FUNCTION IssmMpiDenseMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/
    6070                IssmMpiDenseMat(int m,int n,int pM,int pN,int* d_nnz,int* o_nnz){
    61                         _error_("not supported yet!");
     71                        /*not needed, we are fully dense!: */
     72                        this->Init(pM,pN);
    6273                }
    6374                /*}}}*/
    6475                /*FUNCTION IssmMpiDenseMat(doubletype* serial_mat,int M,int N,doubletype sparsity){{{*/
    65                 IssmMpiDenseMat(doubletype* serial_mat,int pM,int pN,doubletype sparsity){
    66                         _error_("not supported yet!");
     76                IssmMpiDenseMat(doubletype* serial_mat,int Min,int Nin,doubletype sparsity){
     77                       
     78                        /*Here, we assume that the serial_mat is local to the local cpu, and that it has
     79                         * the correct size (m rows by N colums), n determined by DetermineLocalSize: */
     80                        this->buckets=new DataSet();
     81                        this->M=Min;
     82                        this->N=Nin;
     83                        this->m=DetermineLocalSize(this->M,IssmComm::GetComm());
     84
     85                        this->matrix=NULL;
     86                        if(m*N){
     87                                this->matrix=xNewZeroInit<doubletype>(m*N);
     88                                xMemCpy<doubletype>(this->matrix,serial_mat,m*N);
     89                        }
    6790                }
    6891                /*}}}*/
    6992                /*FUNCTION IssmMpiDenseMat(int M,int N, int connectivity, int numberofdofspernode){{{*/
    7093                IssmMpiDenseMat(int pM,int pN, int connectivity,int numberofdofspernode){
    71                         _error_("not supported yet!");
     94                        /*not needed, we are fully dense!: */
     95                        this->Init(pM,pN);
    7296                }
    7397                /*}}}*/
    7498                /*FUNCTION ~IssmMpiDenseMat(){{{*/
    7599                ~IssmMpiDenseMat(){
    76                         _error_("not supported yet!");
     100                        xDelete<doubletype>(this->matrix);
     101                        M=0;
     102                        N=0;
     103                        m=0;
     104                        delete this->buckets;
     105                }
     106                /*}}}*/
     107                /*FUNCTION IssmMpiDenseMat::Init(int Min,int Nin){{{*/
     108                void Init(int Min,int Nin){
     109
     110                        this->buckets=new DataSet();
     111                       
     112                        this->M=Min;
     113                        this->N=Nin;
     114                       
     115                        /*Figure out local number of rows: */
     116                        this->m=DetermineLocalSize(this->M,IssmComm::GetComm());
     117                       
     118                        /*Initialize pointer: */
     119                        this->matrix=NULL;
     120
     121                        /*Allocate: */
     122                        if (m*N)this->matrix=xNewZeroInit<doubletype>(this->m*N);
    77123                }
    78124                /*}}}*/
     
    81127                /*FUNCTION Echo{{{*/
    82128                void Echo(void){
    83                         _error_("not supported yet!");
     129
     130                        int my_rank;
     131                        int i,j,k;
     132
     133                        /*Do a synchronized dump across all the rows: */
     134                        my_rank=IssmComm::GetRank();
     135                        for(i=0;i<IssmComm::GetSize();i++){
     136                                if (my_rank==i){
     137                                        printf("cpu %i #rows: %i\n",i,this->m);
     138                                        for (j=0;j<this->m;j++){
     139                                                printf("row %i ",j);
     140                                                for (k=0;k<this->N;k++){
     141                                                        printf("%g ",this->matrix[j*this->N+k]);
     142                                                }
     143                                        }
     144                                }
     145                                MPI_Barrier(IssmComm::GetComm());
     146                        }
     147
    84148                }
    85149                /*}}}*/
     
    120184                /*}}}*/
    121185                /*FUNCTION SetValues{{{*/
    122                 void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode){
    123                         _error_("not supported yet!");
     186                void SetValues(int min,int* idxm,int nin,int* idxn,doubletype* values,InsMode mode){
     187
     188                        /*we need to store all the values we collect here in order to Assemble later.
     189                         * Indeed, the values we are collecting here most of the time will not belong
     190                         * to us, but to another part of the matrix on another cpu: */
     191                        _assert_(buckets);
     192
     193                        buckets->AddObject(new Bucket<doubletype>(min,idxm,nin,idxn,values,mode));
     194
    124195                }
    125196                /*}}}*/
    126197                /*FUNCTION Convert{{{*/
    127198                void Convert(MatrixType type){
    128                         _error_("not supported yet!");
     199                        /*do nothing: */
    129200                }
    130201                /*}}}*/         
Note: See TracChangeset for help on using the changeset viewer.