-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "MEDFileData.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMemArray.hxx"
+#include "TestInterpKernelUtils.hxx" // getResourceFile()
#ifdef WIN32
-# include <windows.h>
+#include <windows.h>
#else
# include <unistd.h>
#endif
void SauvLoaderTest::testSauv2Med()
{
// read a file containing all types of readable piles
- std::string file = getResourceFile("allPillesTest.sauv");
+ std::string file = INTERP_TEST::getResourceFile("allPillesTest.sauv", 3);
MEDCouplingAutoRefCountObjectPtr<SauvReader> sr=SauvReader::New(file.c_str());
MEDCouplingAutoRefCountObjectPtr<MEDFileData> d2=sr->loadInMEDFileDS();
// write MED
d2->write("allPillesTest.med",0);
- // check
+ // check
CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfMeshes());
CPPUNIT_ASSERT_EQUAL(8+97,d2->getNumberOfFields());
MEDFileMesh * m = d2->getMeshes()->getMeshAtPos(0);
MEDCouplingAutoRefCountObjectPtr<SauvReader> sr=SauvReader::New(sauvFile);
MEDCouplingAutoRefCountObjectPtr<MEDFileData> d2=sr->loadInMEDFileDS();
MEDFileUMesh* m2 = static_cast<MEDFileUMesh*>( d2->getMeshes()->getMeshAtPos(0) );
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> grp1 = m2->getGroup(0, "Group1");
- CPPUNIT_ASSERT_EQUAL(1,(int)grp1->getNumberOfCells());
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> grp2 = m2->getGroup(0, "Group2");
- CPPUNIT_ASSERT_EQUAL(1,(int)grp2->getNumberOfCells());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> group1 = m2->getGroup(0, "Group1");
+ CPPUNIT_ASSERT_EQUAL(1,(int)group1->getNumberOfCells());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> group2 = m2->getGroup(0, "Group2");
+ CPPUNIT_ASSERT_EQUAL(1,(int)group2->getNumberOfCells());
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> grptot = m2->getGroup(0, "Grouptot");
CPPUNIT_ASSERT_EQUAL(2,(int)grptot->getNumberOfCells());
}
void SauvLoaderTest::testSauv2MedOnA3SubsField()
{
// read SAUV
- std::string sauvFile = getResourceFile("portico_3subs.sauv");
+ std::string sauvFile = INTERP_TEST::getResourceFile("portico_3subs.sauv", 3);
MEDCouplingAutoRefCountObjectPtr<SauvReader> sr=SauvReader::New(sauvFile.c_str());
MEDCouplingAutoRefCountObjectPtr<MEDFileData> d2=sr->loadInMEDFileDS();
// check mesh
CPPUNIT_ASSERT_DOUBLES_EQUAL(3, length1dField->accumulate(0), 1e-12);
// check field
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> field =
- d2->getFields()->getFieldWithName("CHAM1D");
+ dynamic_cast<MEDFileFieldMultiTS *>(d2->getFields()->getFieldWithName("CHAM1D"));
std::cout << "Number of components in field: " << field->getInfo().size() << std::endl;
CPPUNIT_ASSERT_EQUAL(6,(int)field->getInfo().size());
std::vector< std::pair<int,int> > timesteps = field->getIterations();
for (int i=0; i < field1d->getNumberOfTuples(); i++)
{
- bool ok = abs(values[i]-field1d->getIJ(i, 0)) < 1e-12;
CPPUNIT_ASSERT_DOUBLES_EQUAL( values[i], field1d->getIJ(i, 0), 1e-12 );
}
}
void SauvLoaderTest::testMed2Sauv()
{
// read pointe.med
- std::string file = getResourceFile("pointe.med");
+ std::string file = INTERP_TEST::getResourceFile("pointe.med", 3);
MEDCouplingAutoRefCountObjectPtr<MEDFileData> pointeMed=MEDFileData::New(file.c_str());
// add 3 faces to pointeMed
MEDFileFields* pointeFields = pointeMed->getFields();
for ( int i = 0; i < pointeFields->getNumberOfFields(); ++i )
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ts = pointeFields->getFieldAtPos(i);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ts = pointeFields->getFieldAtPos(i);
if ( std::string("fieldnodeint") == ts->getName())
{
pointeFields->destroyFieldAtPos( i );
CPPUNIT_ASSERT( std::find(groups.begin(),groups.end(),"groupe5") != groups.end() );
CPPUNIT_ASSERT( std::find(groups.begin(),groups.end(),"maa1") != groups.end() );
CPPUNIT_ASSERT_EQUAL(16,m->getSizeAtLevel(0));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> um0 = m->getGenMeshAtLevel(0);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> um0 = m->getMeshAtLevel(0);
CPPUNIT_ASSERT_EQUAL(12, um0->getNumberOfCellsWithType( INTERP_KERNEL::NORM_TETRA4 ));
CPPUNIT_ASSERT_EQUAL(2, um0->getNumberOfCellsWithType( INTERP_KERNEL::NORM_PYRA5 ));
CPPUNIT_ASSERT_EQUAL(2, um0->getNumberOfCellsWithType( INTERP_KERNEL::NORM_HEXA8 ));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> um1 = m->getGenMeshAtLevel(-1);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> um1 = m->getMeshAtLevel(-1);
CPPUNIT_ASSERT_EQUAL(2, um1->getNumberOfCellsWithType( INTERP_KERNEL::NORM_TRI3 ));
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> pointeUM0 =
- static_cast<MEDCouplingUMesh*>( pointeMedMesh->getGenMeshAtLevel(0));
+ static_cast<MEDCouplingUMesh*>( pointeMedMesh->getMeshAtLevel(0));
DataArrayDouble *coo = m->getCoords();
DataArrayDouble *pointeCoo = pointeMedMesh->getCoords();
CPPUNIT_ASSERT(coo->isEqualWithoutConsideringStr(*pointeCoo,1e-12));
// check fields
// fieldnodedouble
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldnodedoubleTS1 =
- pointeMed->getFields()->getFieldWithName("fieldnodedouble");
+ dynamic_cast<MEDFileFieldMultiTS *>(pointeMed->getFields()->getFieldWithName("fieldnodedouble"));
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldnodedoubleTS2 =
- d2->getFields()->getFieldWithName("fieldnodedouble");
+ dynamic_cast<MEDFileFieldMultiTS *>(d2->getFields()->getFieldWithName("fieldnodedouble"));
CPPUNIT_ASSERT_EQUAL( fieldnodedoubleTS1->getInfo().size(), fieldnodedoubleTS2->getInfo().size());
for ( size_t i = 0; i < fieldnodedoubleTS1->getInfo().size(); ++i )
CPPUNIT_ASSERT_EQUAL( fieldnodedoubleTS1->getInfo()[i], fieldnodedoubleTS2->getInfo()[i]);
}
// fieldcelldoublevector
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldcelldoublevectorTS1 =
- pointeMed->getFields()->getFieldWithName("fieldcelldoublevector");
+ dynamic_cast<MEDFileFieldMultiTS *>(pointeMed->getFields()->getFieldWithName("fieldcelldoublevector"));
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldcelldoublevectorTS2 =
- d2->getFields()->getFieldWithName("fieldcelldoublevector");
+ dynamic_cast<MEDFileFieldMultiTS *>(d2->getFields()->getFieldWithName("fieldcelldoublevector"));
CPPUNIT_ASSERT_EQUAL( fieldcelldoublevectorTS1->getInfo().size(), fieldcelldoublevectorTS2->getInfo().size());
for ( size_t i = 0; i < fieldcelldoublevectorTS1->getInfo().size(); ++i )
CPPUNIT_ASSERT_EQUAL( fieldcelldoublevectorTS1->getInfo()[i], fieldcelldoublevectorTS2->getInfo()[i]);
}
// "Field on 2 faces"
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldOnFaces =
- d2->getFields()->getFieldWithName(f1->getName());
+ dynamic_cast<MEDFileFieldMultiTS *>(d2->getFields()->getFieldWithName(f1->getName().c_str()));
io1 = fieldOnFaces->getIterations();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> fof =
fieldOnFaces->getFieldOnMeshAtLevel(f1->getTypeOfField(),io1[0].first,io1[0].second,um1);
remove(fileToRemove[i]);
}
}
-
-std::string SauvLoaderTest::getResourceFile( const std::string& filename )
-{
- std::string resourceFile = "";
-
- if ( getenv("top_srcdir") ) {
- // we are in 'make check' step
- resourceFile = getenv("top_srcdir");
- resourceFile += "/resources/";
- }
- else if ( getenv("MED_ROOT_DIR") ) {
- // use MED_ROOT_DIR env.var
- resourceFile = getenv("MED_ROOT_DIR");
- resourceFile += "/share/salome/resources/med/";
- }
- resourceFile += filename;
-#ifdef WIN32
- std::string fixedpath = resourceFile;
- for ( int i=0; i < fixedpath.length(); ++i )
- if (fixedpath[i] == '/')
- fixedpath[i] = '\\';
- return fixedpath;
-#endif
- return resourceFile;
-}