Back to index

salome-med  6.5.0
Functions
test_grid.cxx File Reference
#include "MEDMEM_Grid.hxx"
#include <memory>

Go to the source code of this file.

Functions

static void usage (const char *test)
int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 36 of file test_grid.cxx.

                                  {

    /* process the arguments */
    if (argc != 3)
        usage(argv[0]);

    const int SpaceDimension=atoi(argv[1]);
    const int nbMaille=atoi(argv[2]);
    if(SpaceDimension>3 || SpaceDimension<1 || nbMaille<1)
        usage(argv[0]);

    // Creation des tableaux necessaires à la construction de GRID
    std::vector<int> nMaille(SpaceDimension,nbMaille);
    std::vector<double> Origine(SpaceDimension,0.0);
    std::vector<double> pas(SpaceDimension,10.0);
    std::vector<std::vector<double> > XYZ_Array(SpaceDimension);
    for(int i=0;i!=SpaceDimension;++i)
    {
        XYZ_Array[i].resize(nMaille[i]+1); // nbre de noeuds = nbre de mailles +1
        XYZ_Array[i][0]=Origine[i];
        for(int j=1;j!=(int)XYZ_Array[i].size();++j)
            XYZ_Array[i][j]=XYZ_Array[i][j-1] + pas[i];
    }
    
    std::vector<std::string> coord_name(SpaceDimension,"X");
    if(SpaceDimension>=2)
        coord_name[1]="Y";
    if(SpaceDimension>=3)
        coord_name[2]="Z";
    std::vector<std::string> coord_unit(SpaceDimension,"cm");

    // creation du pointeur MESH à partir d'un GRID, test affichage
    MEDMEM::GMESH *grid=(new MEDMEM::GRID( XYZ_Array, coord_name, coord_unit, MED_CARTESIAN) );
    const MEDMEM::MESH* Mesh = grid->convertInMESH(); 
    Mesh->getConnectivityptr();
    std::cout << "Affichage du maillage : " << endl << *Mesh << endl;
    Mesh->removeReference();
    grid->removeReference();
}

Here is the call graph for this function:

static void usage ( const char *  test) [static]

Definition at line 28 of file test_grid.cxx.

{
    cerr << "Usage : " << test
        << " SpaceDimension  nbMaille" << endl << endl
        << "-> Crée une grille cartesienne en dimension SpaceDimension avec nbMaille suivant chaque direction" << endl;
    exit(-1);
}

Here is the caller graph for this function: