Back to index

salome-med  6.5.0
Functions
MEDMEMTest_MeshFuse.cxx File Reference
#include "MEDMEMTest.hxx"
#include <cppunit/Message.h>
#include <cppunit/TestAssert.h>
#include "MEDMEM_Grid.hxx"
#include "MEDMEM_MeshFuse.hxx"
#include "MEDMEM_DriverFactory.hxx"
#include <vector>
#include <string>
#include <algorithm>

Go to the source code of this file.

Functions

GRID * makeGrid (double step, double x0, double y0, int nb_x, int nb_y, int nb_z=0, double z0=0.)

Function Documentation

GRID* makeGrid ( double  step,
double  x0,
double  y0,
int  nb_x,
int  nb_y,
int  nb_z = 0,
double  z0 = 0. 
)

Definition at line 70 of file MEDMEMTest_MeshFuse.cxx.

{
  // make grid
  int dim = nb_z ? 3 : 2;
  vector<vector<double> > xyz_array(dim);
  vector<string>          coord_name(dim);
  vector<string>          unit(dim);

  double origin[] = { x0, y0, z0 };
  int    size  [] = { nb_x, nb_y, nb_z };
  char name = 'X';
  for ( int d = 0; d < dim; ++d, ++name )
  {
    vector<double>& coords = xyz_array[d];
    coords.reserve( size[d]+1 );
    coords.push_back( origin[d] );
    for ( int i = 0; i < size[d]; ++i )
      coords.push_back( coords.back() + step );

    coord_name.push_back(string(1,name));
    unit.push_back("m");
  }
  _GRID* grid = new _GRID( xyz_array, coord_name, unit );


  // make group of boundary elements
  SUPPORT* boundary = grid->getBoundaryElements( dim == 3 ? MED_FACE : MED_EDGE );

  GROUP* bnd_group = new GROUP;
  bnd_group->setMesh( grid );
  bnd_group->setEntity( boundary->getEntity() );
  bnd_group->setName(bnd_elem_name);
  bnd_group->setpartial("Bnd",
                        boundary->getNumberOfTypes(),
                        boundary->getNumberOfElements(MED_ALL_ELEMENTS),
                        boundary->getTypes(),
                        boundary->getNumberOfElements(),
                        boundary->getNumber(MED_ALL_ELEMENTS));
  grid->addGroup( bnd_group );
 
  // make group on all bnd_entity's
  GROUP* all_bnd = new GROUP;
  all_bnd->setMesh( grid );
  all_bnd->setEntity( boundary->getEntity() );
  all_bnd->setName(STRING("all bnd #")<<x0<<y0<<nb_x<<nb_x<<nb_z<<z0);
  all_bnd->setAll( true );
  all_bnd->update();
  grid->addGroup( all_bnd );

  boundary->removeReference();
  

  return grid;
}

Here is the call graph for this function: