2015-04-23 06:24:15 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "RifOdbReader.h"
|
|
|
|
#include "RigGeoMechCaseData.h"
|
|
|
|
|
2015-04-30 02:31:33 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2015-04-23 06:24:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
TEST(OdbReaderTest, BasicTests)
|
|
|
|
{
|
2015-04-28 02:22:31 -05:00
|
|
|
std::cout << TEST_FILE << std::endl;
|
|
|
|
std::cout << std::endl;
|
2015-04-23 06:24:15 -05:00
|
|
|
cvf::ref<RifOdbReader> reader = new RifOdbReader;
|
2015-04-27 03:25:04 -05:00
|
|
|
cvf::ref<RigGeoMechCaseData> femCase = new RigGeoMechCaseData;
|
|
|
|
cvf::ref<RigFemPartCollection> femData = femCase->femParts();
|
2015-04-30 09:35:21 -05:00
|
|
|
|
2015-04-28 02:22:31 -05:00
|
|
|
reader->readFemParts(TEST_FILE, femData.p());
|
2015-04-30 09:35:21 -05:00
|
|
|
|
2015-04-23 08:43:11 -05:00
|
|
|
EXPECT_EQ(1, femData->partCount());
|
2015-04-30 02:31:33 -05:00
|
|
|
EXPECT_EQ(4320, femData->part(0)->elementCount());
|
|
|
|
EXPECT_EQ(HEX8, femData->part(0)->elementType(0));
|
|
|
|
|
2015-04-30 09:35:21 -05:00
|
|
|
std::map<std::string, std::vector<std::string> > scalarNodeFieldsMap = reader->scalarNodeFieldAndComponentNames();
|
|
|
|
EXPECT_EQ(3, scalarNodeFieldsMap.size());
|
|
|
|
|
|
|
|
cvf::ref<RigGeoMechCaseData> femCase2 = new RigGeoMechCaseData;
|
|
|
|
cvf::ref<RigFemPartCollection> femData2 = femCase->femParts();
|
|
|
|
|
2015-04-30 02:31:33 -05:00
|
|
|
cvf::ref<RifOdbReader> reader2 = new RifOdbReader;
|
2015-04-30 09:35:21 -05:00
|
|
|
EXPECT_EQ(true, reader2->readFemParts(TEST_FILE, femData2.p()));
|
2015-04-30 06:59:34 -05:00
|
|
|
EXPECT_EQ(true, reader2->stepNames().size() == 1);
|
2015-04-30 02:31:33 -05:00
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
std::vector<std::string> steps = reader2->stepNames();
|
2015-04-30 02:31:33 -05:00
|
|
|
EXPECT_EQ(true, steps.at(0).find("Date_20100930") >= 0);
|
2015-04-30 06:59:34 -05:00
|
|
|
EXPECT_EQ(2, reader2->frameTimes(0).size());
|
|
|
|
EXPECT_EQ(1.0, reader2->frameTimes(0)[1]);
|
2015-04-30 02:31:33 -05:00
|
|
|
|
2015-04-30 09:35:21 -05:00
|
|
|
scalarNodeFieldsMap = reader2->scalarNodeFieldAndComponentNames();
|
2015-04-30 06:59:34 -05:00
|
|
|
EXPECT_EQ(3, scalarNodeFieldsMap.size());
|
|
|
|
|
|
|
|
std::map<std::string, std::vector<std::string> > scalarElementNodeFieldsMap = reader2->scalarElementNodeFieldAndComponentNames();
|
|
|
|
EXPECT_EQ(0, scalarElementNodeFieldsMap.size());
|
|
|
|
|
|
|
|
std::map<std::string, std::vector<std::string> > scalarIntegrationPointFieldsMap = reader2->scalarIntegrationPointFieldAndComponentNames();
|
|
|
|
EXPECT_EQ(6, scalarIntegrationPointFieldsMap.size());
|
2015-04-30 02:31:33 -05:00
|
|
|
|
|
|
|
std::vector<float> displacementValues;
|
2015-04-30 06:59:34 -05:00
|
|
|
reader2->readScalarNodeField("U", "U2", 0, 0, 1, &displacementValues);
|
2015-04-30 02:31:33 -05:00
|
|
|
EXPECT_EQ(5168, displacementValues.size());
|
2015-04-23 06:24:15 -05:00
|
|
|
|
2015-04-30 09:35:21 -05:00
|
|
|
reader = NULL;
|
|
|
|
|
2015-04-30 02:31:33 -05:00
|
|
|
std::vector<cvf::Vec3f> displacements;
|
|
|
|
reader2->readDisplacements(0, 0, 1, &displacements);
|
2015-04-30 09:35:21 -05:00
|
|
|
reader2 = NULL;
|
2015-04-30 02:31:33 -05:00
|
|
|
EXPECT_EQ(5168, displacements.size());
|
|
|
|
EXPECT_FLOAT_EQ(0.047638997, displacements[1].y());
|
2015-04-23 06:24:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|