Added RigResultAccessor2d

This commit is contained in:
Magne Sjaastad 2014-08-10 14:55:27 +02:00
parent 0440e21f27
commit 85d4de6746
4 changed files with 174 additions and 0 deletions

View File

@ -30,6 +30,8 @@ ${CEE_CURRENT_LIST_DIR}RigNNCData.h
${CEE_CURRENT_LIST_DIR}cvfGeometryTools.h
${CEE_CURRENT_LIST_DIR}cvfGeometryTools.inl
${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h
${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -55,6 +57,7 @@ ${CEE_CURRENT_LIST_DIR}RigWellPath.cpp
${CEE_CURRENT_LIST_DIR}RigFault.cpp
${CEE_CURRENT_LIST_DIR}RigNNCData.cpp
${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, 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
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector2.h"
#include "cvfStructGrid.h"
//==================================================================================================
///
//==================================================================================================
class RigResultAccessor2d : public cvf::Object
{
public:
virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex) const = 0;
virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const = 0;
virtual QString resultName() const = 0;
};

View File

@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, 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 "RigTernaryResultAccessor2d.h"
#include "RigResultAccessor.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigTernaryResultAccessor::RigTernaryResultAccessor()
{
}
//--------------------------------------------------------------------------------------------------
/// Requires at least two data objects present, asserts if more than one data accessor is NULL
//--------------------------------------------------------------------------------------------------
void RigTernaryResultAccessor::setTernaryResultAccessors(RigResultAccessor* soil, RigResultAccessor* sgas, RigResultAccessor* swat)
{
m_soilAccessor = soil;
m_sgasAccessor = sgas;
m_swatAccessor = swat;
int nullPointerCount = 0;
if (!soil) nullPointerCount++;
if (!sgas) nullPointerCount++;
if (!swat) nullPointerCount++;
CVF_ASSERT(nullPointerCount <= 1);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec2d RigTernaryResultAccessor::cellScalar(size_t gridLocalCellIndex)
{
double soil = 0.0;
double swat = 0.0;
if (m_soilAccessor.notNull())
{
soil = m_soilAccessor->cellScalar(gridLocalCellIndex);
if (m_swatAccessor.notNull())
{
swat = m_swatAccessor->cellScalar(gridLocalCellIndex);
}
else
{
swat = 1.0 - soil - m_sgasAccessor->cellScalar(gridLocalCellIndex);
}
}
else
{
swat = m_swatAccessor->cellScalar(gridLocalCellIndex);
soil = 1.0 - swat - m_sgasAccessor->cellScalar(gridLocalCellIndex);
}
return cvf::Vec2d(soil, swat);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec2d RigTernaryResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId)
{
return cellScalar(gridLocalCellIndex);
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, 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 "RigResultAccessor2d.h"
class RigResultAccessor;
//==================================================================================================
///
//==================================================================================================
class RigTernaryResultAccessor : public RigResultAccessor2d
{
public:
RigTernaryResultAccessor();
/// Requires two of the arguments to be present
void setTernaryResultAccessors(RigResultAccessor* soil, RigResultAccessor* sgas, RigResultAccessor* swat);
/// Returns [SOil, SWat] regardless of which one of the three is missing. if Soil or SWat is missing, it is calculated
/// based on the two others
virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex);
virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId);;
private:
cvf::ref<RigResultAccessor> m_soilAccessor;
cvf::ref<RigResultAccessor> m_sgasAccessor;
cvf::ref<RigResultAccessor> m_swatAccessor;
};