2015-04-23 06:24:15 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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"
|
|
|
|
|
2015-04-27 03:25:04 -05:00
|
|
|
#include "RigFemPartCollection.h"
|
2015-04-23 06:24:15 -05:00
|
|
|
#include "RigFemPart.h"
|
|
|
|
|
|
|
|
#include <odb_API.h>
|
|
|
|
|
2015-04-23 08:43:11 -05:00
|
|
|
#include <map>
|
2015-04-28 02:21:27 -05:00
|
|
|
#include <iostream>
|
2015-04-23 08:43:11 -05:00
|
|
|
|
|
|
|
std::map<std::string, RigElementType> initFemTypeMap()
|
|
|
|
{
|
|
|
|
std::map<std::string, RigElementType> typeMap;
|
|
|
|
typeMap["C3D8R"] = HEX8;
|
2015-04-28 02:21:27 -05:00
|
|
|
typeMap["C3D8"] = HEX8;
|
|
|
|
typeMap["C3D8P"] = HEX8;
|
2015-04-23 08:43:11 -05:00
|
|
|
typeMap["CAX4"] = CAX4;
|
|
|
|
|
|
|
|
return typeMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::map<std::string, RigElementType> odbElmTypeToRigElmTypeMap = initFemTypeMap();
|
2015-04-23 06:24:15 -05:00
|
|
|
|
2015-04-30 02:31:33 -05:00
|
|
|
bool RifOdbReader::sm_odbAPIInitialized = false;
|
|
|
|
|
2015-04-23 06:24:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RifOdbReader::RifOdbReader()
|
|
|
|
{
|
2015-04-30 02:31:33 -05:00
|
|
|
m_odb = NULL;
|
2015-04-23 06:24:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RifOdbReader::~RifOdbReader()
|
|
|
|
{
|
2015-04-30 02:31:33 -05:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RifOdbReader::initializeOdbAPI()
|
|
|
|
{
|
|
|
|
if (!sm_odbAPIInitialized)
|
|
|
|
{
|
|
|
|
odb_initializeAPI();
|
|
|
|
sm_odbAPIInitialized = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RifOdbReader::finalizeOdbAPI()
|
|
|
|
{
|
|
|
|
if (sm_odbAPIInitialized)
|
|
|
|
{
|
|
|
|
odb_finalizeAPI();
|
|
|
|
sm_odbAPIInitialized = false;
|
|
|
|
}
|
|
|
|
}
|
2015-04-23 06:24:15 -05:00
|
|
|
|
2015-04-30 02:31:33 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RifOdbReader::close()
|
|
|
|
{
|
|
|
|
if (m_odb)
|
|
|
|
{
|
|
|
|
m_odb->close();
|
|
|
|
m_odb = NULL;
|
|
|
|
}
|
2015-04-23 06:24:15 -05:00
|
|
|
}
|
|
|
|
|
2015-04-30 02:31:33 -05:00
|
|
|
|
2015-04-30 09:35:21 -05:00
|
|
|
void RifOdbReader::readOdbFile(const std::string& fileName, RigFemPartCollection* femParts)
|
2015-04-23 06:24:15 -05:00
|
|
|
{
|
2015-04-27 03:25:04 -05:00
|
|
|
CVF_ASSERT(femParts);
|
2015-04-23 06:24:15 -05:00
|
|
|
|
|
|
|
odb_String path = fileName.c_str();
|
|
|
|
|
|
|
|
odb_Odb& odb = openOdb(path);
|
2015-04-30 09:35:21 -05:00
|
|
|
m_odb = &odb;
|
2015-04-23 06:24:15 -05:00
|
|
|
|
|
|
|
odb_Assembly& rootAssembly = odb.rootAssembly();
|
2015-04-23 08:43:11 -05:00
|
|
|
odb_InstanceRepository instanceRepository = odb.rootAssembly().instances();
|
|
|
|
|
|
|
|
odb_InstanceRepositoryIT iter(instanceRepository);
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2015-04-23 08:43:11 -05:00
|
|
|
for (iter.first(); !iter.isDone(); iter.next())
|
|
|
|
{
|
|
|
|
odb_Instance& inst = instanceRepository[iter.currentKey()];
|
|
|
|
|
|
|
|
RigFemPart* femPart = new RigFemPart;
|
|
|
|
|
2015-04-27 06:47:41 -05:00
|
|
|
// Extract nodes
|
2015-04-23 08:43:11 -05:00
|
|
|
const odb_SequenceNode& odbNodes = inst.nodes();
|
|
|
|
|
2015-04-27 06:47:41 -05:00
|
|
|
std::map<int, int> nodeIdToIdxMap;
|
|
|
|
|
2015-04-23 08:43:11 -05:00
|
|
|
int nodeCount = odbNodes.size();
|
|
|
|
femPart->nodes().nodeIds.resize(nodeCount);
|
|
|
|
femPart->nodes().coordinates.resize(nodeCount);
|
|
|
|
|
|
|
|
for (int nIdx = 0; nIdx < nodeCount; ++nIdx)
|
|
|
|
{
|
|
|
|
const odb_Node odbNode = odbNodes.node(nIdx);
|
|
|
|
femPart->nodes().nodeIds[nIdx] = odbNode.label();
|
|
|
|
const float * pos = odbNode.coordinates();
|
|
|
|
femPart->nodes().coordinates[nIdx].set(pos[0], pos[1], pos[2]);
|
2015-04-27 06:47:41 -05:00
|
|
|
nodeIdToIdxMap[odbNode.label()] = nIdx;
|
2015-04-23 08:43:11 -05:00
|
|
|
}
|
|
|
|
|
2015-04-27 06:47:41 -05:00
|
|
|
// Extract elements
|
2015-04-23 08:43:11 -05:00
|
|
|
const odb_SequenceElement& elements = inst.elements();
|
2015-04-23 06:24:15 -05:00
|
|
|
|
2015-04-23 08:43:11 -05:00
|
|
|
int elmCount = elements.size();
|
|
|
|
femPart->preAllocateElementStorage(elmCount);
|
|
|
|
std::map<std::string, RigElementType>::const_iterator it;
|
2015-04-27 06:47:41 -05:00
|
|
|
std::vector<int> indexBasedConnectivities;
|
|
|
|
|
2015-04-23 08:43:11 -05:00
|
|
|
for (int elmIdx = 0; elmIdx < elmCount; ++elmIdx)
|
|
|
|
{
|
|
|
|
const odb_Element odbElm = elements.element(elmIdx);
|
2015-04-27 06:47:41 -05:00
|
|
|
|
|
|
|
// Get the type
|
2015-04-23 08:43:11 -05:00
|
|
|
it = odbElmTypeToRigElmTypeMap.find(odbElm.type().cStr());
|
2015-04-23 06:24:15 -05:00
|
|
|
|
2015-04-28 02:21:27 -05:00
|
|
|
if (it == odbElmTypeToRigElmTypeMap.end())
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
std::cout << "Unsupported element type :" << odbElm.type().cStr() << std::endl;
|
|
|
|
#endif
|
|
|
|
continue; // Unsupported type
|
|
|
|
}
|
2015-04-23 06:24:15 -05:00
|
|
|
|
2015-04-23 08:43:11 -05:00
|
|
|
RigElementType elmType = it->second;
|
2015-04-27 06:47:41 -05:00
|
|
|
|
2015-04-23 08:43:11 -05:00
|
|
|
int nodeCount = 0;
|
2015-04-27 06:47:41 -05:00
|
|
|
const int* idBasedConnectivities = odbElm.connectivity(nodeCount);
|
2015-04-27 08:04:05 -05:00
|
|
|
CVF_TIGHT_ASSERT(nodeCount == RigFemTypes::elmentNodeCount(elmType));
|
2015-04-27 06:47:41 -05:00
|
|
|
|
|
|
|
indexBasedConnectivities.resize(nodeCount);
|
|
|
|
for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx)
|
|
|
|
{
|
|
|
|
indexBasedConnectivities[lnIdx] = nodeIdToIdxMap[idBasedConnectivities[lnIdx]];
|
|
|
|
}
|
|
|
|
|
|
|
|
femPart->appendElement(elmType, odbElm.label(), indexBasedConnectivities.data());
|
2015-04-23 08:43:11 -05:00
|
|
|
}
|
2015-04-23 06:24:15 -05:00
|
|
|
|
2015-04-27 03:25:04 -05:00
|
|
|
femPart->setElementPartId(femParts->partCount());
|
|
|
|
femParts->addFemPart(femPart);
|
2015-04-23 08:43:11 -05:00
|
|
|
}
|
2015-04-23 06:24:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(odb_Odb* odb, odb_Enum::odb_ResultPositionEnum resultPosition)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(odb != NULL);
|
|
|
|
|
|
|
|
std::map<std::string, std::vector<std::string> > resultNamesMap;
|
|
|
|
|
|
|
|
odb_StepRepository stepRepository = odb->steps();
|
|
|
|
odb_StepRepositoryIT sIter(stepRepository);
|
|
|
|
for (sIter.first(); !sIter.isDone(); sIter.next())
|
|
|
|
{
|
|
|
|
odb_SequenceFrame& stepFrames = stepRepository[sIter.currentKey()].frames();
|
|
|
|
|
|
|
|
int numFrames = stepFrames.size();
|
|
|
|
for (int f = 0; f < numFrames; f++)
|
|
|
|
{
|
|
|
|
odb_Frame frame = stepFrames.constGet(f);
|
|
|
|
|
|
|
|
odb_FieldOutputRepository& fieldCon = frame.fieldOutputs();
|
|
|
|
odb_FieldOutputRepositoryIT fieldConIT(fieldCon);
|
|
|
|
for (fieldConIT.first(); !fieldConIT.isDone(); fieldConIT.next())
|
|
|
|
{
|
|
|
|
odb_FieldOutput& field = fieldCon[fieldConIT.currentKey()];
|
|
|
|
|
|
|
|
odb_SequenceFieldLocation fieldLocations = field.locations();
|
|
|
|
for (int loc = 0; loc < fieldLocations.size(); loc++)
|
|
|
|
{
|
|
|
|
const odb_FieldLocation& fieldLocation = fieldLocations.constGet(loc);
|
|
|
|
if (fieldLocation.position() == resultPosition || resultPosition == odb_Enum::odb_ResultPositionEnum::UNDEFINED_POSITION)
|
|
|
|
{
|
|
|
|
std::string fieldName = field.name().CStr();
|
|
|
|
odb_SequenceString components = field.componentLabels();
|
|
|
|
|
|
|
|
std::vector<std::string> compVec;
|
|
|
|
|
|
|
|
int numComp = components.size();
|
|
|
|
for (int comp = 0; comp < numComp; comp++)
|
|
|
|
{
|
|
|
|
compVec.push_back(components[comp].CStr());
|
|
|
|
}
|
|
|
|
|
|
|
|
resultNamesMap.insert(std::make_pair(fieldName, compVec));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return resultNamesMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-23 06:24:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-04-27 03:25:04 -05:00
|
|
|
bool RifOdbReader::readFemParts(const std::string& fileName, RigFemPartCollection* femParts)
|
2015-04-23 06:24:15 -05:00
|
|
|
{
|
2015-04-30 07:05:46 -05:00
|
|
|
initializeOdbAPI();
|
|
|
|
|
2015-04-23 06:24:15 -05:00
|
|
|
int status = 0;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2015-04-30 09:35:21 -05:00
|
|
|
this->readOdbFile(fileName, femParts);
|
2015-04-23 06:24:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-04-30 06:59:34 -05:00
|
|
|
std::vector<std::string> RifOdbReader::stepNames()
|
2015-04-30 02:31:33 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT(m_odb != NULL);
|
|
|
|
|
|
|
|
std::vector<std::string> stepNames;
|
|
|
|
|
|
|
|
odb_StepRepository stepRepository = m_odb->steps();
|
|
|
|
odb_StepRepositoryIT sIter(stepRepository);
|
|
|
|
for (sIter.first(); !sIter.isDone(); sIter.next())
|
|
|
|
{
|
|
|
|
stepNames.push_back(stepRepository[sIter.currentKey()].name().CStr());
|
|
|
|
}
|
|
|
|
|
|
|
|
return stepNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-04-30 06:59:34 -05:00
|
|
|
std::vector<double> RifOdbReader::frameTimes(int stepIndex)
|
2015-04-30 02:31:33 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT(m_odb != NULL);
|
|
|
|
|
|
|
|
odb_StepRepository& stepRepository = m_odb->steps();
|
|
|
|
|
|
|
|
odb_StepList stepList = stepRepository.stepList();
|
|
|
|
odb_Step& step = stepList.Get(stepIndex);
|
|
|
|
|
|
|
|
odb_SequenceFrame& stepFrames = step.frames();
|
|
|
|
|
|
|
|
std::vector<double> frameValues;
|
|
|
|
|
|
|
|
int numFrames = stepFrames.size();
|
|
|
|
for (int f = 0; f < numFrames; f++)
|
|
|
|
{
|
|
|
|
odb_Frame frame = stepFrames.constGet(f);
|
|
|
|
frameValues.push_back(frame.frameValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
return frameValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-04-30 06:59:34 -05:00
|
|
|
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarNodeFieldAndComponentNames() const
|
2015-04-23 06:24:15 -05:00
|
|
|
{
|
2015-04-30 06:59:34 -05:00
|
|
|
return scalarFieldAndComponentNames(m_odb, odb_Enum::odb_ResultPositionEnum::NODAL);
|
|
|
|
}
|
2015-04-30 02:31:33 -05:00
|
|
|
|
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarElementNodeFieldAndComponentNames() const
|
|
|
|
{
|
|
|
|
return scalarFieldAndComponentNames(m_odb, odb_Enum::odb_ResultPositionEnum::ELEMENT_NODAL);
|
|
|
|
}
|
2015-04-30 02:31:33 -05:00
|
|
|
|
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarIntegrationPointFieldAndComponentNames() const
|
|
|
|
{
|
|
|
|
return scalarFieldAndComponentNames(m_odb, odb_Enum::odb_ResultPositionEnum::INTEGRATION_POINT);
|
2015-04-30 02:31:33 -05:00
|
|
|
}
|
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
|
2015-04-30 02:31:33 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
odb_Frame RifOdbReader::stepFrame(int stepIndex, int frameIndex) const
|
|
|
|
{
|
|
|
|
CVF_ASSERT(m_odb);
|
|
|
|
|
|
|
|
odb_StepRepository& stepRepository = m_odb->steps();
|
|
|
|
odb_StepList stepList = stepRepository.stepList();
|
|
|
|
odb_Step& step = stepList.Get(stepIndex);
|
|
|
|
odb_SequenceFrame& stepFrames = step.frames();
|
|
|
|
|
|
|
|
return stepFrames.constGet(frameIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Get the number of result items (== #nodes or #elements)
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-04-30 06:59:34 -05:00
|
|
|
size_t RifOdbReader::resultItemCount(const std::string& fieldName, int stepIndex, int frameIndex) const
|
2015-04-30 02:31:33 -05:00
|
|
|
{
|
|
|
|
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
|
|
|
const odb_FieldOutputRepository& fieldOutputRepo = frame.fieldOutputs();
|
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
odb_String fieldNameStr = fieldName.c_str();
|
|
|
|
CVF_ASSERT(fieldOutputRepo.isMember(fieldNameStr));
|
2015-04-30 02:31:33 -05:00
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
const odb_FieldOutput& fieldOutput = fieldOutputRepo[fieldNameStr];
|
2015-04-30 02:31:33 -05:00
|
|
|
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
|
|
|
|
|
|
|
size_t resultItemCount = 0;
|
|
|
|
int numBlocks = seqFieldBulkData.size();
|
|
|
|
|
|
|
|
for (int block = 0; block < numBlocks; block++)
|
|
|
|
{
|
|
|
|
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
|
|
|
|
resultItemCount += bulkData.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
return resultItemCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-04-30 06:59:34 -05:00
|
|
|
int RifOdbReader::componentIndex(const std::string& fieldName, const std::string& componentName) const
|
2015-04-30 02:31:33 -05:00
|
|
|
{
|
2015-04-30 06:59:34 -05:00
|
|
|
std::map<std::string, std::vector<std::string> > resultCompMap = scalarFieldAndComponentNames(m_odb, odb_Enum::odb_ResultPositionEnum::UNDEFINED_POSITION);
|
|
|
|
|
|
|
|
std::vector<std::string> comps;
|
2015-04-30 02:31:33 -05:00
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
auto mapIt = resultCompMap.find(fieldName);
|
|
|
|
if (mapIt != resultCompMap.end())
|
|
|
|
{
|
|
|
|
comps = mapIt->second;
|
|
|
|
}
|
2015-04-30 02:31:33 -05:00
|
|
|
|
|
|
|
for (size_t i = 0; i < comps.size(); i++)
|
|
|
|
{
|
|
|
|
if (comps[i] == componentName)
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-04-30 06:59:34 -05:00
|
|
|
void RifOdbReader::readScalarNodeField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
|
2015-04-30 02:31:33 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT(resultValues);
|
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
size_t dataSize = resultItemCount(fieldName, stepIndex, frameIndex);
|
2015-04-30 02:31:33 -05:00
|
|
|
if (dataSize > 0)
|
|
|
|
{
|
|
|
|
resultValues->resize(dataSize);
|
|
|
|
}
|
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
int compIndex = componentIndex(fieldName, componentName);
|
2015-04-30 02:31:33 -05:00
|
|
|
CVF_ASSERT(compIndex >= 0);
|
|
|
|
|
|
|
|
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
2015-04-30 06:59:34 -05:00
|
|
|
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()];
|
2015-04-30 02:31:33 -05:00
|
|
|
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
|
|
|
|
|
|
|
size_t dataIndex = 0;
|
|
|
|
int numBlocks = seqFieldBulkData.size();
|
|
|
|
for (int block = 0; block < numBlocks; block++)
|
|
|
|
{
|
|
|
|
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
|
|
|
|
|
|
|
|
if (bulkData.numberOfNodes() > 0)
|
|
|
|
{
|
|
|
|
int numNodes = bulkData.length();
|
|
|
|
int numComp = bulkData.width();
|
|
|
|
float* data = bulkData.data();
|
|
|
|
|
|
|
|
for (int i = 0; i < numNodes; i++)
|
|
|
|
{
|
|
|
|
(*resultValues)[dataIndex++] = data[i*numComp + compIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-30 06:59:34 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RifOdbReader::readScalarElementNodeField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(resultValues);
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// Need example files containing element node results for testing
|
|
|
|
// Or, consider reporting integration point results as element node results too, and extrapolate when requested
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RifOdbReader::readScalarIntegrationPointField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(resultValues);
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-30 02:31:33 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RifOdbReader::readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector<cvf::Vec3f>* displacements)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(displacements);
|
|
|
|
|
|
|
|
size_t dataSize = resultItemCount("U", stepIndex, frameIndex);
|
|
|
|
if (dataSize > 0)
|
|
|
|
{
|
|
|
|
displacements->resize(dataSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
|
|
|
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()["U"];
|
|
|
|
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
|
|
|
|
|
|
|
size_t dataIndex = 0;
|
|
|
|
int numBlocks = seqFieldBulkData.size();
|
|
|
|
for (int block = 0; block < numBlocks; block++)
|
|
|
|
{
|
|
|
|
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
|
|
|
|
|
|
|
|
if (bulkData.numberOfNodes() > 0)
|
|
|
|
{
|
|
|
|
int numNodes = bulkData.length();
|
|
|
|
int numComp = bulkData.width();
|
|
|
|
float* data = bulkData.data();
|
|
|
|
|
|
|
|
for (int i = 0; i < numNodes; i++)
|
|
|
|
{
|
|
|
|
(*displacements)[i + dataIndex].set(data[i*numComp], data[i*numComp + 1], data[i*numComp + 2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
dataIndex += numNodes*numComp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|