1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkStructuredAMRNeighbor.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkStructuredAMRNeighbor.h"
#include "vtkStructuredExtent.h"
vtkStructuredAMRNeighbor::vtkStructuredAMRNeighbor()
{
this->GridLevel = -1;
this->NeighborLevel = -1;
this->NeighborID = 0;
this->RelationShip = vtkStructuredAMRNeighbor::UNDEFINED;
for( int i=0; i < 3; ++i )
{
this->Orientation[ i ] = vtkStructuredNeighbor::UNDEFINED;
int minIdx = i*2;
int maxIdx = i*2+1;
this->GridOverlapExtent[minIdx] = this->GridOverlapExtent[maxIdx] =
this->OverlapExtent[minIdx] = this->OverlapExtent[maxIdx] =
this->SendExtent[minIdx] = this->SendExtent[maxIdx] =
this->RcvExtent[minIdx] = this->RcvExtent[maxIdx] = -1;
} // END for all dimensions
}
//-----------------------------------------------------------------------------
vtkStructuredAMRNeighbor::vtkStructuredAMRNeighbor(
const int gridLevel,
const int neiID, const int neighborLevel,
int gridOverlap[6], int neiOverlap[6],
int orient[3],
const int relationShip)
{
this->GridLevel = gridLevel;
this->NeighborID = neiID;
this->NeighborLevel = neighborLevel;
this->RelationShip = relationShip;
for( int i=0; i < 3; ++i )
{
int minIdx = i*2;
int maxIdx = i*2+1;
this->RcvExtent[minIdx] =
this->OverlapExtent[minIdx] = neiOverlap[minIdx];
this->RcvExtent[maxIdx] =
this->OverlapExtent[maxIdx] = neiOverlap[maxIdx];
this->SendExtent[minIdx] =
this->GridOverlapExtent[minIdx] = gridOverlap[minIdx];
this->SendExtent[maxIdx] =
this->GridOverlapExtent[maxIdx] = gridOverlap[maxIdx];
this->Orientation[i] = orient[i];
} // END for all dimensions
}
//-----------------------------------------------------------------------------
vtkStructuredAMRNeighbor& vtkStructuredAMRNeighbor::operator=(
const vtkStructuredAMRNeighbor &N)
{
if( this != &N )
{
this->GridLevel = N.GridLevel;
this->NeighborID = N.NeighborID;
this->NeighborLevel = N.NeighborLevel;
this->RelationShip = N.RelationShip;
for( int i=0; i < 3; ++i )
{
int minIdx = i*2;
int maxIdx = i*2+1;
this->RcvExtent[minIdx] = N.RcvExtent[minIdx];
this->RcvExtent[maxIdx] = N.RcvExtent[maxIdx];
this->SendExtent[minIdx] = N.SendExtent[minIdx];
this->SendExtent[maxIdx] = N.SendExtent[maxIdx];
this->OverlapExtent[minIdx] = N.OverlapExtent[minIdx];
this->OverlapExtent[maxIdx] = N.OverlapExtent[maxIdx];
this->GridOverlapExtent[minIdx] = N.GridOverlapExtent[minIdx];
this->GridOverlapExtent[maxIdx] = N.GridOverlapExtent[maxIdx];
} // END for all dimensions
} // END if
return *this;
}
//-----------------------------------------------------------------------------
std::string vtkStructuredAMRNeighbor::GetRelationShipString()
{
std::string str = "";
switch( this->RelationShip )
{
case PARENT:
str = "PARENT";
break;
case PARTIALLY_OVERLAPPING_PARENT:
str = "PARTIALLY_OVERLAPPING_PARENT";
break;
case CHILD:
str = "CHILD";
break;
case PARTIALLY_OVERLAPPING_CHILD:
str = "PARTIALLY_OVERLAPPING_CHILD";
break;
case SAME_LEVEL_SIBLING:
str = "SAME_LEVEL_SIBLING";
break;
case COARSE_TO_FINE_SIBLING:
str = "COARSE_TO_FINE_SIBLING";
break;
case FINE_TO_COARSE_SIBLING:
str = "FINE_TO_COARSE_SIBLING";
break;
case UNDEFINED: /* intentional fall-through */
default:
str = "UNDEFINED";
} // END switch
return( str );
}
//-----------------------------------------------------------------------------
void vtkStructuredAMRNeighbor::GetReceiveExtentOnGrid(
const int ng, int gridExtent[6], int ext[6])
{
for( int i=0; i < 6; ++i)
{
ext[i]=this->GridOverlapExtent[i];
}
for( int i=0; i < 3; ++i )
{
switch( this->Orientation[i] )
{
case vtkStructuredNeighbor::SUPERSET:
/* NO OP */
break;
case vtkStructuredNeighbor::SUBSET_HI:
case vtkStructuredNeighbor::HI:
ext[i*2+1] += ng;
break;
case vtkStructuredNeighbor::SUBSET_LO:
case vtkStructuredNeighbor::LO:
ext[i*2] -= ng;
break;
case vtkStructuredNeighbor::SUBSET_BOTH:
ext[i*2] -= ng;
ext[i*2+1] += ng;
break;
default:
; /* NO OP */
} // END switch
} // END for all dimensions
vtkStructuredExtent::Clamp(ext,gridExtent);
}
//-----------------------------------------------------------------------------
void vtkStructuredAMRNeighbor::ComputeSendAndReceiveExtent(
int gridRealExtent[6], int* vtkNotUsed(gridGhostedExtent),
int neiRealExtent[6],
int* vtkNotUsed(WholeExtent),
const int N)
{
// TODO: Here we need to make sure that the send/rcv extent between a coarse
// fine boundary will be as such that ghost layers of the fine grid will cover
// the entire lower res cell based on the level difference between the
// grid and its neighbor.
for( int i=0; i < 3; ++i )
{
switch( this->Orientation[i] )
{
case vtkStructuredNeighbor::SUPERSET:
this->SendExtent[i*2] -= N;
this->SendExtent[i*2+1] += N;
break;
case vtkStructuredNeighbor::SUBSET_HI:
case vtkStructuredNeighbor::HI:
this->RcvExtent[i*2+1] += N;
this->SendExtent[i*2] -= N;
break;
case vtkStructuredNeighbor::SUBSET_LO:
case vtkStructuredNeighbor::LO:
this->RcvExtent[i*2] -= N;
this->SendExtent[i*2+1] += N;
break;
case vtkStructuredNeighbor::SUBSET_BOTH:
this->RcvExtent[i*2] -= N;
this->SendExtent[i*2+1] += N;
this->RcvExtent[i*2+1] += N;
this->SendExtent[i*2] -= N;
break;
default:
; /* NO OP */
} // END switch
} // END for all dimensions
// Hmm...restricting receive extent to the real extent of the neighbor
vtkStructuredExtent::Clamp( this->RcvExtent, neiRealExtent );
vtkStructuredExtent::Clamp( this->SendExtent, gridRealExtent );
}
|