2014-08-06 08:14:01 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-24 00:14:52 -05:00
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2014-08-06 08:14:01 -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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2014-08-06 08:14:01 -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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2014-08-06 08:14:01 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-08-07 07:20:20 -05:00
|
|
|
#include "RigCombTransResultAccessor.h"
|
2014-08-06 08:14:01 -05:00
|
|
|
|
|
|
|
#include "RigGridBase.h"
|
|
|
|
|
2015-08-30 14:25:31 -05:00
|
|
|
#include "RigCell.h"
|
|
|
|
#include "RigMainGrid.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include <cmath>
|
2014-08-06 08:14:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2014-08-06 08:14:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RigCombTransResultAccessor::RigCombTransResultAccessor( const RigGridBase* grid )
|
|
|
|
: m_grid( grid )
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-08-06 09:54:12 -05:00
|
|
|
/// Only sensible to provide the positive values, as the negative ones will never be used.
|
|
|
|
/// The negative faces gets their value from the neighbor cell in that direction
|
2014-08-06 08:14:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RigCombTransResultAccessor::setTransResultAccessors( RigResultAccessor* xTransAccessor,
|
|
|
|
RigResultAccessor* yTransAccessor,
|
|
|
|
RigResultAccessor* zTransAccessor )
|
2014-08-06 09:54:12 -05:00
|
|
|
|
2014-08-07 08:30:12 -05:00
|
|
|
{
|
|
|
|
m_xTransAccessor = xTransAccessor;
|
|
|
|
m_yTransAccessor = yTransAccessor;
|
|
|
|
m_zTransAccessor = zTransAccessor;
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2014-08-06 08:14:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
double RigCombTransResultAccessor::cellScalar( size_t gridLocalCellIndex ) const
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_TIGHT_ASSERT( false );
|
2014-08-06 08:14:01 -05:00
|
|
|
|
2014-08-07 08:30:12 -05:00
|
|
|
return HUGE_VAL;
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
2014-09-09 07:02:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Get tran value from neighbor cell. Return 0.0 on active/inactive cell borders and end of grid
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
double RigCombTransResultAccessor::neighborCellTran( size_t gridLocalCellIndex,
|
|
|
|
cvf::StructGridInterface::FaceType faceId,
|
|
|
|
const RigResultAccessor* transAccessor ) const
|
2014-09-09 07:02:03 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( transAccessor != nullptr )
|
2014-09-09 07:02:03 -05:00
|
|
|
{
|
|
|
|
size_t i, j, k, neighborGridCellIdx;
|
2019-09-06 03:40:57 -05:00
|
|
|
m_grid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k );
|
2014-09-09 07:02:03 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_grid->cellIJKNeighbor( i, j, k, faceId, &neighborGridCellIdx ) )
|
2014-09-09 07:02:03 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double neighborCellValue = transAccessor->cellScalar( neighborGridCellIdx );
|
|
|
|
if ( neighborCellValue == HUGE_VAL && transAccessor->cellScalar( gridLocalCellIndex ) != HUGE_VAL )
|
2014-09-09 07:02:03 -05:00
|
|
|
{
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return neighborCellValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return HUGE_VAL;
|
|
|
|
}
|
2014-08-06 08:14:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2014-08-06 08:14:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:43:15 -06:00
|
|
|
double RigCombTransResultAccessor::cellFaceScalar( size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId ) const
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
switch ( faceId )
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
case cvf::StructGridInterface::POS_I:
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_xTransAccessor.notNull() )
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return m_xTransAccessor->cellScalar( gridLocalCellIndex );
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-09-06 03:40:57 -05:00
|
|
|
case cvf::StructGridInterface::NEG_I:
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return this->neighborCellTran( gridLocalCellIndex, cvf::StructGridInterface::NEG_I, m_xTransAccessor.p() );
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
|
|
|
break;
|
2019-09-06 03:40:57 -05:00
|
|
|
case cvf::StructGridInterface::POS_J:
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_yTransAccessor.notNull() )
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return m_yTransAccessor->cellScalar( gridLocalCellIndex );
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-09-06 03:40:57 -05:00
|
|
|
case cvf::StructGridInterface::NEG_J:
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return this->neighborCellTran( gridLocalCellIndex, cvf::StructGridInterface::NEG_J, m_yTransAccessor.p() );
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
|
|
|
break;
|
2019-09-06 03:40:57 -05:00
|
|
|
case cvf::StructGridInterface::POS_K:
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_zTransAccessor.notNull() )
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return m_zTransAccessor->cellScalar( gridLocalCellIndex );
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-09-06 03:40:57 -05:00
|
|
|
case cvf::StructGridInterface::NEG_K:
|
2014-08-06 08:14:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return this->neighborCellTran( gridLocalCellIndex, cvf::StructGridInterface::NEG_K, m_zTransAccessor.p() );
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
|
|
|
break;
|
2019-09-06 03:40:57 -05:00
|
|
|
default:
|
|
|
|
break;
|
2014-08-06 08:14:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return HUGE_VAL;
|
|
|
|
}
|
|
|
|
|
2015-08-30 14:25:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-30 14:25:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
double RigCombTransResultAccessor::cellScalarGlobIdx( size_t globCellIndex ) const
|
2015-08-30 14:25:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_TIGHT_ASSERT( false );
|
2015-08-30 14:25:31 -05:00
|
|
|
|
|
|
|
return HUGE_VAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-30 14:25:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
double RigCombTransResultAccessor::cellFaceScalarGlobIdx( size_t globCellIndex,
|
|
|
|
cvf::StructGridInterface::FaceType faceId ) const
|
2015-08-30 14:25:31 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
size_t gridLocalCellIndex = m_grid->mainGrid()->cell( globCellIndex ).gridLocalCellIndex();
|
|
|
|
return this->cellFaceScalar( gridLocalCellIndex, faceId );
|
2015-08-30 14:25:31 -05:00
|
|
|
}
|