ResInsight/ApplicationLibCode/ReservoirDataModel/RigTernaryResultAccessor.cpp

167 lines
5.4 KiB
C++
Raw Normal View History

2014-08-10 07:55:27 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-24 00:14:52 -05:00
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
2014-08-10 07:55:27 -05:00
// 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.
//
2014-08-10 07:55:27 -05:00
// 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>
2014-08-10 07:55:27 -05:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigTernaryResultAccessor.h"
2014-08-10 07:55:27 -05:00
#include "RigResultAccessor.h"
2015-11-24 03:04:02 -06:00
#include <cmath> // Needed for HUGE_VAL on Linux
2014-08-10 07:55:27 -05:00
//--------------------------------------------------------------------------------------------------
///
2014-08-10 07:55:27 -05:00
//--------------------------------------------------------------------------------------------------
RigTernaryResultAccessor::RigTernaryResultAccessor()
{
}
2014-08-10 07:55:27 -05:00
//--------------------------------------------------------------------------------------------------
2018-10-10 03:17:07 -05:00
/// Requires at least two data objects present, asserts if more than one data accessor is nullptr
2014-08-10 07:55:27 -05:00
//--------------------------------------------------------------------------------------------------
void RigTernaryResultAccessor::setTernaryResultAccessors( RigResultAccessor* soil,
RigResultAccessor* sgas,
RigResultAccessor* swat )
2014-08-10 07:55:27 -05:00
{
m_soilAccessor = soil;
m_sgasAccessor = sgas;
m_swatAccessor = swat;
2014-08-10 07:55:27 -05:00
}
//--------------------------------------------------------------------------------------------------
/// If only swat is present, soil is set to (1.0 - swat) and sgas to 0
2014-08-10 07:55:27 -05:00
//--------------------------------------------------------------------------------------------------
cvf::Vec2d RigTernaryResultAccessor::cellScalar( size_t gridLocalCellIndex ) const
2014-08-10 07:55:27 -05:00
{
double soil = 0.0;
double sgas = 0.0;
2014-08-10 07:55:27 -05:00
if ( m_soilAccessor.notNull() )
{
soil = m_soilAccessor->cellScalar( gridLocalCellIndex );
2014-08-10 07:55:27 -05:00
if ( m_sgasAccessor.notNull() )
{
sgas = m_sgasAccessor->cellScalar( gridLocalCellIndex );
}
else if ( m_swatAccessor.notNull() )
{
sgas = 1.0 - soil - m_swatAccessor->cellScalar( gridLocalCellIndex );
}
else
{
sgas = 1.0 - soil;
}
}
else
{
if ( m_sgasAccessor.notNull() )
{
sgas = m_sgasAccessor->cellScalar( gridLocalCellIndex );
2014-08-10 07:55:27 -05:00
if ( m_swatAccessor.notNull() )
{
soil = 1.0 - sgas - m_swatAccessor->cellScalar( gridLocalCellIndex );
}
else
{
soil = 1.0 - sgas;
}
}
else if ( m_swatAccessor.notNull() )
{
soil = 1.0 - m_swatAccessor->cellScalar( gridLocalCellIndex );
}
}
2014-08-10 07:55:27 -05:00
return cvf::Vec2d( soil, sgas );
2014-08-10 07:55:27 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2014-08-10 07:55:27 -05:00
//--------------------------------------------------------------------------------------------------
cvf::Vec2d RigTernaryResultAccessor::cellFaceScalar( size_t gridLocalCellIndex,
cvf::StructGridInterface::FaceType faceId ) const
2014-08-10 07:55:27 -05:00
{
return cellScalar( gridLocalCellIndex );
2014-08-10 07:55:27 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec2d RigTernaryResultAccessor::cellScalarGlobIdx( size_t globCellIndex ) const
{
double soil = 0.0;
double sgas = 0.0;
if ( m_soilAccessor.notNull() )
{
soil = m_soilAccessor->cellScalarGlobIdx( globCellIndex );
if ( soil == HUGE_VAL )
{
return cvf::Vec2d( HUGE_VAL, HUGE_VAL );
}
if ( m_sgasAccessor.notNull() )
{
sgas = m_sgasAccessor->cellScalarGlobIdx( globCellIndex );
}
else if ( m_swatAccessor.notNull() )
{
sgas = 1.0 - soil - m_swatAccessor->cellScalarGlobIdx( globCellIndex );
}
else
{
sgas = 1.0 - soil;
}
}
else
{
if ( m_sgasAccessor.notNull() )
{
sgas = m_sgasAccessor->cellScalarGlobIdx( globCellIndex );
if ( sgas == HUGE_VAL )
{
return cvf::Vec2d( HUGE_VAL, HUGE_VAL );
}
if ( m_swatAccessor.notNull() )
{
soil = 1.0 - sgas - m_swatAccessor->cellScalarGlobIdx( globCellIndex );
}
else
{
soil = 1.0 - sgas;
}
}
else if ( m_swatAccessor.notNull() )
{
double swat = m_swatAccessor->cellScalarGlobIdx( globCellIndex );
if ( swat == HUGE_VAL )
{
return cvf::Vec2d( HUGE_VAL, HUGE_VAL );
}
soil = 1.0 - m_swatAccessor->cellScalarGlobIdx( globCellIndex );
}
}
return cvf::Vec2d( soil, sgas );
}