Back to index

salome-med  6.5.0
Public Member Functions | Private Member Functions | Static Private Member Functions
ParaMEDMEM::MEDCalculatorBasicsTest Class Reference

#include <MEDCalculatorBasicsTest.hxx>

Inheritance diagram for ParaMEDMEM::MEDCalculatorBasicsTest:
Inheritance graph
[legend]
Collaboration diagram for ParaMEDMEM::MEDCalculatorBasicsTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void testLightStruct1 ()
void testRangeSelection1 ()
void testDBField1 ()
void testSPython1 ()
void testSPython2 ()
void testSPython3 ()

Private Member Functions

 CPPUNIT_TEST_SUITE (MEDCalculatorBasicsTest)
 CPPUNIT_TEST (testDBField1)
 CPPUNIT_TEST (testSPython1)
 CPPUNIT_TEST (testSPython2)
 CPPUNIT_TEST (testSPython3)
 CPPUNIT_TEST_SUITE_END ()

Static Private Member Functions

static void generateAFile1 (const char *fName)

Detailed Description

Definition at line 27 of file MEDCalculatorBasicsTest.hxx.


Member Function Documentation

void ParaMEDMEM::MEDCalculatorBasicsTest::generateAFile1 ( const char *  fName) [static, private]

Definition at line 110 of file MEDCalculatorBasicsTest.cxx.

{
  double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
  int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
  MEDCouplingUMesh *m=MEDCouplingUMesh::New();
  m->setName("AMesh");
  m->setMeshDimension(2);
  m->allocateCells(5);
  m->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
  m->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
  m->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
  m->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
  m->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
  m->finishInsertingCells();
  DataArrayDouble *myCoords=DataArrayDouble::New();
  myCoords->alloc(9,2);
  myCoords->setInfoOnComponent(0,"x [cm]");
  myCoords->setInfoOnComponent(1,"y [cm]");
  std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
  m->setCoords(myCoords);
  myCoords->decrRef();
  //
  MEDLoader::WriteUMesh(fName,m,true);
  static const int nbOfTimeSteps=10;
  static const int nbOfComponents=7;
  MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
  f->setName("Power");
  f->setMesh(m);
  DataArrayDouble *da=DataArrayDouble::New();
  da->alloc(5,7);
  f->setArray(da);
  da->setInfoOnComponent(0,"aaa [a]"); da->setInfoOnComponent(1,"bbb [b]"); da->setInfoOnComponent(2,"ccc [c]");
  da->setInfoOnComponent(3,"ddd [d]"); da->setInfoOnComponent(4,"eee [e]"); da->setInfoOnComponent(5,"fff [f]");
  da->setInfoOnComponent(6,"ggg [g]");
  f->checkCoherency();
  for(int i=0;i<nbOfTimeSteps;i++)
    {
      double *pt=da->getPointer();
      for(int j=0;j<5;j++)
        for(int k=0;k<nbOfComponents;k++,pt++)
          *pt=(i+1)*100.+(j+1)*10.+k+1;
      f->setTime(i*0.1,i,-i);
      MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fName,f);
    }
  da->decrRef();
  f->decrRef();
  m->decrRef();
}

Here is the call graph for this function:

Definition at line 83 of file MEDCalculatorBasicsTest.cxx.

{
  const char fName[]="hfile1.med";
  generateAFile1(fName);
  MEDCalculatorBrowserLiteStruct lt(fName);
  lt.selectAllFields();
  MEDCalculatorDBFieldReal *Power=new MEDCalculatorDBFieldReal(lt.getField(0));
  MEDCalculatorDBFieldReal *Power2=new MEDCalculatorDBFieldReal(lt.getField(0));
  MEDCalculatorDBFieldReal *Power3=(MEDCalculatorDBFieldReal *)((*Power)+(*Power2));
  Power3->decrRef();
  Power2->decrRef();
  Power->decrRef();
  //
  MEDCalculatorDBRangeSelection t1("2:4"),t2("6:8");
  MEDCalculatorDBRangeSelection p;
  MEDCalculatorDBRangeSelection c1,c2;
  //
  Power=new MEDCalculatorDBFieldReal(lt.getField(0));
  Power2=(*Power)(t1,p,c1);
  Power3=(*Power)(t2,p,c1);
  MEDCalculatorDBField *Power4=(*Power2)+(*Power3);
  Power4->decrRef();
  Power3->decrRef();
  Power2->decrRef();
  Power->decrRef();
}

Definition at line 36 of file MEDCalculatorBasicsTest.cxx.

{
  const char fname[]="/export/home/geay/MEDStdAlone/Salome5/V5_1_main/MED/MED_INSTALL_DEBUG/share/salome/resources/med/TimeStamps_import22.med";
  MEDCalculatorBrowserLiteStruct lt(fname);
  lt.selectAllFields();
  //std::cout << lt.str() << std::endl;
}

Definition at line 44 of file MEDCalculatorBasicsTest.cxx.

{
  MEDCalculatorDBRangeSelection sel1(":");
  std::vector<int> v=sel1.getIds(6);
  CPPUNIT_ASSERT_EQUAL(6,(int)v.size());
  const int expected1[6]={0,1,2,3,4,5};
  CPPUNIT_ASSERT(std::equal(expected1,expected1+6,v.begin()));
  MEDCalculatorDBRangeSelection sel2(":-1");
  v=sel2.getIds(6);
  CPPUNIT_ASSERT_EQUAL(5,(int)v.size());
  CPPUNIT_ASSERT(std::equal(expected1,expected1+5,v.begin()));
  MEDCalculatorDBRangeSelection sel3("2:4");
  v=sel3.getIds(6);
  CPPUNIT_ASSERT_EQUAL(2,(int)v.size());
  CPPUNIT_ASSERT(std::equal(expected1+2,expected1+4,v.begin()));
  MEDCalculatorDBRangeSelection sel4(":3");
  v=sel4.getIds(6);
  CPPUNIT_ASSERT_EQUAL(3,(int)v.size());
  CPPUNIT_ASSERT(std::equal(expected1,expected1+3,v.begin()));
  //
  bool exc=false;
  MEDCalculatorDBRangeSelection sel5("2");
  try {  sel5="3:1"; } catch(INTERP_KERNEL::Exception& e) { exc=true; }
  CPPUNIT_ASSERT(exc); exc=false;
  try {  sel5="4:5:7"; } catch(INTERP_KERNEL::Exception& e) { exc=true; }
  CPPUNIT_ASSERT(exc); exc=false;
  try {  sel5="4:5r"; } catch(INTERP_KERNEL::Exception& e) { exc=true; }
  CPPUNIT_ASSERT(exc); exc=false;
  try {  sel5="4:ry5"; } catch(INTERP_KERNEL::Exception& e) { exc=true; }
  CPPUNIT_ASSERT(exc); exc=false;
  try {  sel5="4r:7"; } catch(INTERP_KERNEL::Exception& e) { exc=true; }
  CPPUNIT_ASSERT(exc); exc=false;
  try {  sel5="r4:7"; } catch(INTERP_KERNEL::Exception& e) { exc=true; }
  CPPUNIT_ASSERT(exc); exc=false;
  sel5="3:7";
  try {  v=sel5.getIds(6); } catch(INTERP_KERNEL::Exception& e) { exc=true; }
  CPPUNIT_ASSERT(exc); exc=false;
}

Definition at line 159 of file MEDCalculatorBasicsTest.cxx.

{
  std::string s1,s2;
  bool b;
  s1="12:3";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,s1);
  s1="12:";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,s1);
  s1="12";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(b);
  CPPUNIT_ASSERT_EQUAL(s2,s1);
  s1="";
  CPPUNIT_ASSERT(!ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  s1="          ";
  CPPUNIT_ASSERT(!ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  s1=":";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,s1);
  s1=":12";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,s1);
  s1=":12:";
  CPPUNIT_ASSERT(!ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  s1=":12   23";
  CPPUNIT_ASSERT(!ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  // some ' ' char
  s1="  12  : 3  ";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,std::string("12:3"));
  s1="  12  : 3";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,std::string("12:3"));
  s1="  12  :3  ";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,std::string("12:3"));
  s1="  12: 3  ";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,std::string("12:3"));
  s1="12  : 3  ";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isElementInParenthesisMatching(s1,s2,b));
  CPPUNIT_ASSERT(!b);
  CPPUNIT_ASSERT_EQUAL(s2,std::string("12:3"));
}

Definition at line 214 of file MEDCalculatorBasicsTest.cxx.

{
  std::string s1,s2;
  s1="  12:3  , : ,4  ";
  CPPUNIT_ASSERT(ParaMEDMEM::SPythonParser::isParenthesisMatching(s1,s2));
  CPPUNIT_ASSERT_EQUAL(s2,std::string("\"12:3\",\":\",4"));
}

Definition at line 222 of file MEDCalculatorBasicsTest.cxx.

{
  std::string s1,s2;
  s1="(  12:3  , : ,4  )";
  s2=ParaMEDMEM::SPythonInterpreter::strip(s1);
  CPPUNIT_ASSERT_EQUAL(s2,std::string("(12:3,:,4)"));
  s1=" (  12:3  , : ,4  )  ";
  s2=ParaMEDMEM::SPythonInterpreter::strip(s1);
  CPPUNIT_ASSERT_EQUAL(s2,std::string("(12:3,:,4)"));
}

The documentation for this class was generated from the following files: