GeoMech data model and reader unit test framework.

This commit is contained in:
Jacob Støren 2015-04-23 13:24:15 +02:00
parent 1f2bea106f
commit 4737807b7b
14 changed files with 680 additions and 0 deletions

View File

@ -0,0 +1,17 @@
cmake_minimum_required (VERSION 2.8)
project (RigGeoMechDataModel)
include_directories(
${LibCore_SOURCE_DIR}
)
add_library( ${PROJECT_NAME}
RigFemPart.h
RigFemPart.cpp
RigFemTypes.h
RigGeoMechCaseData.cpp
RigGeoMechCaseData.h
)

View File

@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigFemPart.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPart::RigFemPart()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPart::~RigFemPart()
{
}

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigFemTypes.h"
#include "cvfObject.h"
#include "cvfAssert.h"
#include "cvfVector3.h"
#include <vector>
class RigFemPartNodes
{
public:
std::vector<int> nodeIds;
std::vector<cvf::Vec3f> coordinates;
};
class RigFemPart : public cvf::Object
{
public:
RigFemPart();
virtual ~RigFemPart();
int appendElement(RigElementType elmType, int id, const int* connectivities);
size_t elementCount() const { return m_elementId.size(); }
int elmId(size_t index) const { return m_elementId[index]; }
RigElementType elmentType(size_t index) const { return m_elementTypes[index]; }
const int* connectivities(size_t index) const { return &m_allAlementConnectivities[m_elementConnectivityStartIndices[index]];}
RigFemPartNodes& nodes() {return m_nodes;}
private:
std::vector<int> m_elementId;
std::vector<RigElementType> m_elementTypes;
std::vector<size_t> m_elementConnectivityStartIndices;
std::vector<int> m_allAlementConnectivities;
RigFemPartNodes m_nodes;
};

View File

@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
enum RigElementType
{
HEX8
};
static const int elmentNodeCount(RigElementType elmType)
{
static int elementTypeCounts[1] = {8};
return elementTypeCounts[elmType];
}
static const int elmentFaceCount(RigElementType elmType)
{
const static int elementFaceCounts[1] = {6};
return elementFaceCounts[elmType];
}
// HEX8
// 7---------6
// /| /| |k
// / | / | | /j
// 4---------5 | |/
// | 3------|--2 *---i
// | / | /
// |/ |/
// 0---------1
static const int* elementLocalFaceIndices(RigElementType elmType, int faceIdx, int* faceNodeCount)
{
static const int HEX8_Faces[6][4] = { {1, 2, 6, 5 }, {0,4,7,3}, {3,7,6,2}, {0,1,5,4}, {4,5,6,7} ,{0,3,2,1} };
(*faceNodeCount) = 4;
return HEX8_Faces[faceIdx];
}

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigGeoMechCaseData.h"
#include "RigFemPart.h"
#include <math.h>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGeoMechCaseData::RigGeoMechCaseData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGeoMechCaseData::~RigGeoMechCaseData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::addFemPart(RigFemPart* part)
{
m_femParts.push_back(part);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPart* RigGeoMechCaseData::part(size_t index)
{
return m_femParts[index].p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGeoMechCaseData::partCount()
{
return m_femParts.size();
}

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigFemPart.h"
#include "cvfCollection.h"
class RigGeoMechCaseData: public cvf::Object
{
public:
RigGeoMechCaseData();
~RigGeoMechCaseData();
void addFemPart(RigFemPart* part);
RigFemPart* part(size_t index);
size_t partCount();
private:
cvf::Collection<RigFemPart> m_femParts;
};

View File

@ -0,0 +1,19 @@
cmake_minimum_required (VERSION 2.8)
project (RifOdbReader)
add_definitions(-DHKS_NT)
add_definitions(-DABQ_WIN86_64)
include_directories(
${RI_ODB_API_DIR}/include
${RigGeoMechDataModel_SOURCE_DIR}
${LibCore_SOURCE_DIR}
)
add_library( ${PROJECT_NAME}
RifOdbReader.h
RifOdbReader.cpp
RifGeoMechReaderInterface.h
RifGeoMechReaderInterface.cpp
)

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "RifGeoMechReaderInterface.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifGeoMechReaderInterface::RifGeoMechReaderInterface()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifGeoMechReaderInterface::~RifGeoMechReaderInterface()
{
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include <vector>
class RigGeoMechCaseData;
//==================================================================================================
//
// Data interface base class
//
//==================================================================================================
class RifGeoMechReaderInterface : public cvf::Object
{
public:
RifGeoMechReaderInterface();
virtual ~RifGeoMechReaderInterface();
virtual bool open(const std::string& fileName, RigGeoMechCaseData* geoMechCase) = 0;
virtual void close() = 0;
virtual std::vector<double> timeSteps() = 0;
private:
};

View File

@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "RifOdbReader.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPart.h"
#include <odb_API.h>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifOdbReader::RifOdbReader()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifOdbReader::~RifOdbReader()
{
}
void readOdbFile(const std::string& fileName, RigGeoMechCaseData* geoMechCase)
{
CVF_ASSERT(geoMechCase);
odb_String path = fileName.c_str();
odb_Odb& odb = openOdb(path);
odb_Assembly& rootAssembly = odb.rootAssembly();
RigFemPart* part = new RigFemPart;
const odb_SequenceNode& nodes = rootAssembly.nodes();
const odb_SequenceElement& elements = rootAssembly.elements();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifOdbReader::open(const std::string& fileName, RigGeoMechCaseData* geoMechCase)
{
odb_initializeAPI();
int status = 0;
try
{
readOdbFile(fileName, geoMechCase);
}
catch (const nex_Exception& nex)
{
status = 1;
fprintf(stderr, "%s\n", nex.UserReport().CStr());
fprintf(stderr, "ODB Application exited with error(s)\n");
}
catch (...)
{
status = 1;
fprintf(stderr, "ODB Application exited with error(s)\n");
}
odb_finalizeAPI();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifOdbReader::close()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RifOdbReader::timeSteps()
{
return std::vector<double>();
}

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RifGeoMechReaderInterface.h"
#include <string>
class RigGeoMechCaseData;
//==================================================================================================
//
// Data interface base class
//
//==================================================================================================
class RifOdbReader : public RifGeoMechReaderInterface
{
public:
RifOdbReader();
virtual ~RifOdbReader();
virtual bool open(const std::string& fileName, RigGeoMechCaseData* geoMechCase);
virtual void close();
virtual std::vector<double> timeSteps();
private:
};

View File

@ -0,0 +1,73 @@
cmake_minimum_required (VERSION 2.8)
project ( OdbReader_UnitTests )
set(RI_ODB_API_DIR C:/pfRoot/jjsOnJacobpcCsdep/User/Sigurd/OdbApiExperiments/OdbApi/x64 CACHE PATH "Path tho the ODB api from Simulia")
set(RI_VIZ_FWK_ROOT ../../../Fwk/main/VizFwk CACHE PATH "Path to VizFwk")
set(RI_GTEST_ROOT ../../../ThirdParty CACHE PATH "Path to forlder containing gtest folder")
include(${RI_VIZ_FWK_ROOT}/CMake/Utils/ceeDetermineCompilerFlags.cmake)
add_subdirectory(${RI_VIZ_FWK_ROOT}/LibCore buildVizFwk)
add_subdirectory(../GeoMechDataModel buildGeoMechDataModel)
add_subdirectory(../OdbReader buildOdbReader)
include_directories(${RI_ODB_API_DIR}/include)
include_directories(${RI_VIZ_FWK_ROOT}/LibCore)
include_directories(../GeoMechDataModel)
include_directories(../OdbReader)
include_directories(${RI_GTEST_ROOT})
set( UNIT_TEST_CPP_SOURCES
main.cpp
RifOdbReader-Test.cpp
${RI_GTEST_ROOT}/gtest/gtest-all.cc
)
set( LINK_LIBRARIES
LibCore
RigGeoMechDataModel
RifOdbReader
)
list(APPEND RI_ODB_LIBS
${RI_ODB_API_DIR}/lib/ABQSMAOdbDdbOdb.lib
${RI_ODB_API_DIR}/lib/ABQSMAOdbApi.lib
${RI_ODB_API_DIR}/lib/ABQSMAOdbCore.lib
${RI_ODB_API_DIR}/lib/ABQSMAOdbCoreGeom.lib
${RI_ODB_API_DIR}/lib/ABQSMAOdbAttrEO.lib
${RI_ODB_API_DIR}/lib/ABQSMAAbuBasicUtils.lib
${RI_ODB_API_DIR}/lib/ABQSMABasShared.lib
${RI_ODB_API_DIR}/lib/ABQSMABasCoreUtils.lib
${RI_ODB_API_DIR}/lib/ABQSMAStiCAE_StableTime.lib
${RI_ODB_API_DIR}/lib/ABQSMABasMem.lib
${RI_ODB_API_DIR}/lib/ABQSMAAbuGeom.lib
${RI_ODB_API_DIR}/lib/ABQSMARomDiagEx.lib
${RI_ODB_API_DIR}/lib/ABQSMASspUmaCore.lib
${RI_ODB_API_DIR}/lib/ABQSMASimInterface.lib
${RI_ODB_API_DIR}/lib/ABQSMAMtxCoreModule.lib
)
set( EXTERNAL_LINK_LIBRARIES ${RI_ODB_LIBS})
add_executable( ${PROJECT_NAME} ${UNIT_TEST_CPP_SOURCES} )
target_link_libraries( ${PROJECT_NAME} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
# Copy Dlls
if (MSVC)
file (GLOB ABA_DLLS_FULL ${RI_ODB_API_DIR}/lib/*.dll)
foreach (aDLL ${ABA_DLLS_FULL})
get_filename_component(filenameWithExt ${aDLL} NAME)
list(APPEND ABA_DLLS ${filenameWithExt} )
endforeach(aDLL)
foreach (aDLL ${ABA_DLLS})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RI_ODB_API_DIR}/lib/${aDLL}" "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
endforeach()
endif(MSVC)

View File

@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(OdbReaderTest, BasicTests)
{
cvf::ref<RifOdbReader> reader = new RifOdbReader;
cvf::ref<RigGeoMechCaseData> femData = new RigGeoMechCaseData;
reader->open("testfile.odb", femData.p());
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cvfBase.h"
#include "gtest/gtest.h"
#include <stdio.h>
#include "cvfTrace.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int main(int argc, char **argv)
{
cvf::Assert::setReportMode(cvf::Assert::CONSOLE);
testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
std::cout << "Please press <Enter> to close the window.";
std::cin.get();
return result;
}