11 #ifndef _BLOCKBASEREGISTERIMPLEM_H_ 12 #define _BLOCKBASEREGISTERIMPLEM_H_ 19 #include "NamespaceHeader.H" 31 m_hasDefinedDataLayouts(false)
34 define( a_mblock, a_grids, a_ghost );
52 CH_TIME(
"BlockBaseRegister<T>::define");
63 Box newBoundingBox( inDomain.domainBox() );
83 int dir(j%CH_SPACEDIM);
115 CH_TIME(
"BlockBaseRegister<T>::store");
134 T& regData( dataRegister[regIndex] );
138 T& inData( const_cast<T&>(a_data) );
139 inData.shiftHalf( a_dir, -
sign(a_side) );
141 Box srcBox( adjCellBox(
m_grids[a_dataIndex], a_dir, a_side, -1 ) );
157 const Box window( srcBox & inData.box() );
158 regData.
copy( inData, window & regData.box() );
164 T& excData( dataExcRegister[excIndex] );
165 const Box excWindow( regData.box() & excData.box() );
166 excData.
copy( regData, excWindow );
173 MayDay::Error(
" BlockBaseRegister<T>::store: BlockBaseRegister<T> is not defined!");
184 CH_TIME(
"BlockBaseRegister<T>::increment");
202 T& regData( dataRegister[regIndex] );
206 T& inData( const_cast<T&>(a_data) );
207 inData.shiftHalf( a_dir, -
sign(a_side) );
209 Box srcBox( adjCellBox(
m_grids[a_dataIndex], a_dir, a_side, -1 ) );
225 const Box window( srcBox & inData.box() );
226 const int n_comp( a_data.nComp() );
227 regData.plus( inData, window & regData.box(), 0, 0, n_comp );
233 T& excData( dataExcRegister[excIndex] );
234 excData.copy( regData, regData.box() & excData.box() );
241 MayDay::Error(
" BlockBaseRegister<T>::increment: BlockBaseRegister<T> is not defined!");
249 CH_TIME(
"BlockBaseRegister<T>::exchange");
261 MayDay::Error(
" BlockBaseRegister<T>::exchange: BlockBaseRegister<T> is not defined!");
272 a_layoutData[dit].setVal( 0.0 );
280 CH_TIME(
"BlockBaseRegister<T>::zeroRegister");
291 MayDay::Error(
" BlockRegister::zeroRegister: Attempt to zero register of unknown component length!");
294 else if ( a_n_comp>0 && a_n_comp !=
m_register[0].nComp() )
309 MayDay::Error(
" BlockRegister::zeroRegister: Attempt to zero undefined register!");
319 CH_TIME(
"BlockBaseRegister<T>::hasInterface");
324 const Box clipBox( adjCellBox( box, a_dir, a_side, 1 ) );
329 const Box blockBdryBox( adjCellBox( blockBox, a_dir, a_side, 1 ) );
350 CH_TIME(
"BlockBaseRegister<T>::fill");
360 const T& regData(
m_register[index][regIndex] );
362 const int srcSide(
sign( a_side ) *
sign( a_sideData ) );
364 Box srcBox( adjCellBox( box, a_dir, a_side, srcSide ) );
365 const int shift(
sign( a_sideData ) );
384 const Box window( srcBox & a_data.box() & regData.box() );
385 a_data.
copy( regData, window );
392 MayDay::Error(
" BlockBaseRegister<T>::fill: BlockBaseRegister<T> is not defined!");
416 return blocks[a_block];
423 const int& a_blockBdryIndex )
const 427 const int neighborBlock( boundary[a_blockBdryIndex].neighbor() );
443 const int& a_blockBdryIndex )
const 447 return boundary[a_blockBdryIndex].getTransformation();
468 mySrcBox.
growLo( neighborDir );
470 const Box intersectBox( mySrcBox & neighborBox );
475 neighborSide = flip( neighborSide );
479 BlockBdryIndexMap::value_type( index, src_index ) );
495 return boundary[index].isInterface();
506 MPI_Comm_rank( Chombo_MPI::comm, &myRank );
508 for (
int i(0); i<a_boxes.
size(); i++)
510 if (a_procs[i]==myRank)
534 const Box&
box( a_layout[dit] );
538 if ( box.
eq( a_boxes[i] ) )
541 a_map[a_indices[i]] = foo;
551 MayDay::Error(
" BlockBaseRegister<T>::createDstBoxLayout: One or more orphaned boxes!");
575 const Box&
box( a_srcLayout[dit] );
579 if ( box.
eq( a_srcBoxes[i] ) )
581 const int dstBlockBdryIndex( a_dstBlockBdryIndices[i] );
582 const DataIndex& gridDataIndex( a_srcDataIndices[i] );
583 const DataIndex& dstDataIndex( a_dstMap[dstBlockBdryIndex][gridDataIndex] );
584 a_srcMap[dstBlockBdryIndex][dstDataIndex] = dit();
592 MayDay::Error(
" BlockBaseRegister<T>::createSrcBoxLayout: One or more orphaned boxes!");
608 a_exchangeLayout.
close();
615 const Box&
box( a_exchangeLayout[dit] );
619 if ( box.
eq( a_boxes[i] ) )
621 const DataIndex& gridDataIndex( a_dataIndices[i] );
622 const DataIndex& dstDataIndex( a_grdToDstMap[gridDataIndex] );
623 a_dstToExcMap[dstDataIndex] = dit();
631 MayDay::Error(
" BlockBaseRegister<T>::createSrcBoxLayout: One or more orphaned boxes!");
689 blockBdryIndexMap[index],
746 registerBox = adjCellBox( box, dir, side, -1 );
747 registerBox.
growDir( dir, side, 1 );
751 else if (a_type==
SRC)
753 registerBox = adjCellBox( box, dir, side, 1 );
775 else if (a_type==
EXC)
777 registerBox = adjCellBox( box, dir, side, -(1+
m_ghost) );
802 MayDay::Error(
" BlockBaseRegister<T>::buildBoxVectors: Unknown use type!");
805 a_boxes[index].push_back( registerBox );
807 a_dataIndex[index].push_back(
DataIndex( lit() ) );
832 a_map[transformedIndex].push_back( index );
857 srcLevelData.
copyTo( dstLevelData );
868 srcLevelData.
copyTo( dstLevelData, copier );
880 for (
int dir(0); dir<
SpaceDim; ++dir)
882 tmp_vec[dir] = a_vec[a_permutation[dir]];
901 for (dit.begin(); dit.ok(); ++dit)
912 const DataIndex& regDataIndex( grdToDst[dit()] );
915 const DataIndex& srcDataIndex( dstToSrc[regDataIndex] );
920 T& dst( dstRegister[regDataIndex] );
921 const T& src( srcRegister[srcDataIndex] );
923 const Box& srcWindow( src.box() );
929 for (
int n(0); n<dst.nComp(); n++)
932 for (bit.
begin(); bit.
ok(); ++bit)
934 const IntVect dst_loc( bit() );
938 dst(dst_loc,n) = src(src_loc,n);
959 pout() <<
"========= dir: " << dir <<
" ";
960 pout() <<
"side: " << side() <<
" ";
962 pout() <<
"block boundary index: " << index << std::endl;
967 for (dit.begin(); dit.ok(); ++dit)
969 const T& data( thisRegister[dit()] );
970 const Box&
box( data.box() );
971 pout() <<
"--------------------------------------" << std::endl;
972 pout() <<
"Box: " <<
box << endl;
973 for (
int ncomp(0); ncomp<data.nComp(); ++ncomp)
975 pout() <<
"Component: " << ncomp << endl;
977 for (bit.
begin(); bit.
ok(); ++bit)
979 pout() << bit() <<
"\t" << data.get( bit(), ncomp ) << std::endl;;
982 pout() <<
"--------------------------------------" << std::endl;
999 pout() <<
"========= dir: " << dir <<
" ";
1000 pout() <<
"side: " << side() <<
" ";
1002 pout() <<
"block boundary index: " << index << std::endl;
1007 for (dit.begin(); dit.ok(); ++dit)
1009 const T& data( thisRegister[dit()] );
1010 const Box&
box( data.box() );
1011 pout() <<
"--------------------------------------" << std::endl;
1012 pout() <<
"Box: " <<
box << endl;
1013 for (
int ncomp(0); ncomp<data.nComp(); ++ncomp)
1015 pout() <<
"Component: " << ncomp << endl;
1017 for (bit.
begin(); bit.
ok(); ++bit)
1019 pout() << bit() <<
"\t" << data( bit(), ncomp ) << std::endl;;
1022 pout() <<
"--------------------------------------" << std::endl;
1033 pout() <<
":::::::::::::::::::::::::::::::::::::::::::::::" << std::endl;
1034 pout() <<
":: Source " <<
m_name <<
" Registers" << std::endl;
1035 pout() <<
":::::::::::::::::::::::::::::::::::::::::::::::" << std::endl;
1038 pout() <<
":::::::::::::::::::::::::::::::::::::::::::::::" << std::endl;
1039 pout() <<
":: Destination " <<
m_name <<
" Registers" << std::endl;
1040 pout() <<
":::::::::::::::::::::::::::::::::::::::::::::::" << std::endl;
1045 #include "NamespaceFooter.H" std::ostream & pout()
Use this in place of std::cout for program output.
bool ok()
Definition: BoxIterator.H:281
void ghostDefine(const DisjointBoxLayout &a_src, const DisjointBoxLayout &a_dest, const ProblemDomain &a_domain, const IntVect &a_srcGhost)
performs the computation necessary for moving from ghost+valid cells to all valid cells in a_dest ...
int m_ghost
Definition: BlockBaseRegister.H:331
void buildSrcRegisterLayout()
Build all box layouts for the source boxes.
Definition: BlockBaseRegisterImplem.H:666
virtual int whichBlock(const Box &a_box) const
returns block number in which a_box is contained in the global index space
int getBlockBdryIndex(const int &a_dir, const Side::LoHiSide &a_side)
Definition: BlockBaseRegisterImplem.H:433
IntVect m_ghostVect
Definition: BlockBaseRegister.H:337
const ProblemDomain & physDomain() const
bool isDefined() const
Returns true if class has been defined, false otherwise.
Definition: BlockBaseRegister.H:71
int getBlockID(const DataIndex &a_dataIndex) const
Returns the integer index of the block in which the box corresponding to the DataIndex resides...
Definition: BlockBaseRegisterImplem.H:404
#define CH_SPACEDIM
Definition: SPACE.H:51
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
void copyToDstRegister()
Local copy of data from exterior source registers to exterior full register.
Definition: BlockBaseRegisterImplem.H:889
void remove(const T &value)
Removes all objects in the List<T> equal to value.
Definition: ListImplem.H:356
int sign(const CH_XD::Side::LoHiSide &a_side)
DisjointBoxLayout m_srcRegisterLayout[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:351
bool m_isDefined
Definition: BlockBaseRegister.H:333
const Box & getNeighborBlockBox(const int &a_block, const int &a_blockBdryIndex) const
Returns the box corresponding to the block opposite to the block specified by the block integer index...
Definition: BlockBaseRegisterImplem.H:422
void zeroBoxLayoutData(BoxLayoutData< T > &a_layoutData)
Definition: BlockBaseRegisterImplem.H:268
LevelData< T > m_register[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:346
int m_verbosity
Definition: BlockBaseRegister.H:332
Class to implement a single data register a mapped multiblock domain block boundary.
Definition: BlockBaseRegister.H:27
LevelData< T > m_excRegister[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:349
void createExchangeBoxLayout(DisjointBoxLayout &a_layout, LayoutData< DataIndex > &a_dstToExcMap, const Vector< Box > &a_boxes, const Vector< int > &a_procs, const Vector< DataIndex > &a_indices, const LayoutData< DataIndex > &a_grdToDstMap)
Build the box layout and associated box mappings for the data exchange.
Definition: BlockBaseRegisterImplem.H:599
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:152
void append(const T &value)
Adds a copy of the value to the end of the List<T>.
Definition: List.H:582
void defineDataLayouts(const int a_ncomp)
Define each of the three internally used data layouts.
Definition: BlockBaseRegisterImplem.H:78
BlockBaseRegister()
Empty constructor.
Definition: BlockBaseRegister.H:39
LayoutData< DataIndex > m_grdToDstMap[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:356
bool m_hasData
Definition: BlockBaseRegister.H:334
DataIterator dataIterator() const
Definition: LayoutDataI.H:78
Definition: BlockBaseRegister.H:228
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:117
Definition: DataIterator.H:190
Box & shiftHalf(int dir, int num_halfs)
const Vector< Box > & mappingBlocks() const
const access to the mapping blocks
Definition: MultiBlockCoordSys.H:263
iterates through the IntVects of a Box
Definition: BoxIterator.H:37
void clearDataLayouts()
Undefine each of the three internally used data layouts.
Definition: BlockBaseRegisterImplem.H:97
Box copy() const
Definition: Box.H:571
void buildExchangeRegisterLayout()
Build all disjoint box layouts for the data exchange.
Definition: BlockBaseRegisterImplem.H:697
An Iterator based on a BoxLayout object.
Definition: LayoutIterator.H:35
Definition: LoHiSide.H:31
void store(const T &a_data, const DataIndex &a_dataIndex, int a_dir, Side::LoHiSide a_side)
Store data on block-boundary faces.
Definition: BlockBaseRegisterImplem.H:110
Definition: BlockBaseRegister.H:226
void zeroRegister(const int a_n_comp=-1)
Definition: BlockBaseRegisterImplem.H:278
const int SpaceDim
Definition: SPACE.H:38
DisjointBoxLayout m_grids
Definition: BlockBaseRegister.H:328
void buildBoxVectors(Vector< Box > a_boxes[2 *CH_SPACEDIM], Vector< int > a_boxProcMap[2 *CH_SPACEDIM], Vector< DataIndex > a_dataIndex[2 *CH_SPACEDIM], const UseType a_type)
Definition: BlockBaseRegisterImplem.H:724
virtual void exchange(void)
Simplest case – do all components.
Definition: LevelDataI.H:467
virtual ~BlockBaseRegister()
virtual destructor
Definition: BlockBaseRegisterImplem.H:39
Definition: EBInterface.H:45
Vector< BlockBdryIndexMap > m_blockBdryIndexMap
Definition: BlockBaseRegister.H:340
void resize(unsigned int isize)
Definition: Vector.H:346
void setVal(int i, int val)
Definition: IntVect.H:838
bool ok() const
Return true if the iterator is not past the end of the list.
Definition: List.H:465
bool isInterface(const int &a_block, const int &a_dir, const Side::LoHiSide &a_side) const
Returns true if the block-boundary in this direction on this side is an interface between blocks...
Definition: BlockBaseRegisterImplem.H:487
std::string m_name
Definition: BlockBaseRegister.H:336
#define CH_TIME(name)
Definition: CH_Timer.H:82
void print(const LevelData< T > a_register[2 *CH_SPACEDIM]) const
Print the specified register.
Definition: BlockBaseRegisterImplem.H:993
A Doubly-Linked List Class.
Definition: List.H:21
static const IntVect Unit
Definition: IntVect.H:663
new code
Definition: BoxLayoutData.H:170
void createSrcBoxLayout(DisjointBoxLayout &a_layout, LayoutData< DataIndex > a_dstToSrcMap[2 *CH_SPACEDIM], const Vector< Box > &a_boxes, const Vector< int > &a_procs, const Vector< DataIndex > &a_indices, const Vector< int > &a_dstBlockBdryIndices, const LayoutData< DataIndex > a_grdToDstMap[2 *CH_SPACEDIM])
Build the box layout and associated box mappings for the source boxes.
Definition: BlockBaseRegisterImplem.H:558
Iterator over a List.
Definition: List.H:20
Data on a BoxLayout.
Definition: BoxLayoutData.H:97
bool hasStorage() const
Definition: BlockBaseRegister.H:326
DisjointBoxLayout m_excRegisterLayout[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:348
Definition: BlockBaseRegister.H:227
Box & growDir(int a_idir, const Side::LoHiSide &a_sd, int a_cell)
Definition: Box.H:2363
ProblemDomain m_domain
Definition: BlockBaseRegister.H:329
Ordered Tuples for Types T.
Definition: Tuple.H:30
virtual void copyTo(const Interval &srcComps, BoxLayoutData< T > &dest, const Interval &destComps) const
Definition: LevelDataI.H:218
LayoutData< DataIndex > m_dstToExcMap[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:357
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
int numBlocks() const
number of blocks
Definition: MultiBlockCoordSys.H:267
virtual bool isDefined() const
Definition: BoxLayoutDataI.H:39
LoHiSide
Definition: LoHiSide.H:27
bool hasInterface(const DataIndex &a_dataIndex, int a_dir, Side::LoHiSide a_side) const
Returns whether or not a box has a block-boundary interface on one of its faces.
Definition: BlockBaseRegisterImplem.H:315
size_t size() const
Definition: Vector.H:192
ListIterator< T > first() const
Returns a ListIterator<T> to the first object in this List<T>.
Definition: List.H:697
bool isNotEmpty() const
Returns true if the List<T> is not empty.
Definition: List.H:627
const Vector< Tuple< BlockBoundary, 2 *SpaceDim > > & boundaries() const
const access to the block boundaries
Definition: MultiBlockCoordSys.H:271
virtual void define(const BoxLayout &a_dp)
Definition: LayoutDataI.H:107
const IntVect & ghostVect() const
Definition: LevelData.H:186
void buildLocalIndexList(List< int > &a_list, const Vector< Box > &a_boxes, const Vector< int > &a_procs)
Definition: BlockBaseRegisterImplem.H:500
virtual interface class encapsulating multi-block mapping API
Definition: MultiBlockCoordSys.H:34
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
int getSrcBlockBdryIndex(const int &a_block, const int &a_dir, const Side::LoHiSide &a_side)
Returns the index of the neighboring block opposite the block in the direction and side spceified...
Definition: BlockBaseRegisterImplem.H:453
void fill(T &a_data, const DataIndex &a_dataIndex, int a_dir, Side::LoHiSide a_side, Side::LoHiSide a_sideData) const
Return data on a block-boundary interface of a box, if hasInterface(a_dataIndex, a_dir, a_side) is true.
Definition: BlockBaseRegisterImplem.H:344
bool m_hasDefinedDataLayouts
Definition: BlockBaseRegister.H:335
IndicesTransformation getTransformation(const int &a_block, const int &a_blockBdryIndex) const
Returns the index transformation box corresponding to the Blockboundary specified by the block intege...
Definition: BlockBaseRegisterImplem.H:441
void define(const Box &a_domBox)
Construct ProblemDomain with a_domBox as computational domain.
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
Iterator for low and high side.
Definition: LoHiSide.H:74
DisjointBoxLayout m_registerLayout[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:345
bool eq(const Box &b) const
Definition: DataIndex.H:114
const DisjointBoxLayout & disjointBoxLayout() const
Definition: LevelData.H:225
void begin()
Definition: BoxIterator.H:150
void buildRegisterLayout()
Build all box layouts for the data register.
Definition: BlockBaseRegisterImplem.H:637
void copyToSrcRegister()
Copy, including parallel exchange, of data from interior exchange registers to exterior source regist...
Definition: BlockBaseRegisterImplem.H:842
void printRegisters() const
Print all registers to pout().
Definition: BlockBaseRegisterImplem.H:1031
void increment(const T &a_flux, const DataIndex &a_dataIndex, int a_dir, Side::LoHiSide a_side)
Increment data on block-boundary faces.
Definition: BlockBaseRegisterImplem.H:179
void createDstBoxLayout(DisjointBoxLayout &a_layout, LayoutData< DataIndex > &a_map, const Vector< Box > &a_boxes, const Vector< int > &a_procs, const Vector< DataIndex > &a_indices)
Build a box layout for the data register given a vector of boxes with processor mappings and related ...
Definition: BlockBaseRegisterImplem.H:520
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: LoHiSide.H:30
void exchange()
Exchange data to fill exterior register regions.
Definition: BlockBaseRegisterImplem.H:247
void define(const MultiBlockCoordSys *a_mblock, const DisjointBoxLayout &a_grids, const int &a_ghost=0)
Define function that matches constructor.
Definition: BlockBaseRegisterImplem.H:46
bool intersectsNotEmpty(const Box &b) const
Box & grow(int i)
grow functions
Definition: Box.H:2263
UseType
Builds an array of vectors of boxes, one for each direction-side combination, that corresponds to eit...
Definition: BlockBaseRegister.H:223
LevelData< T > m_srcRegister[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:352
virtual void define(const Vector< Box > &a_boxes, const Vector< int > &a_procIDs)
Box & growLo(int idir, int n_cell=1)
Definition: Box.H:2349
const Box & getBlockBox(const int &a_block) const
Returns the box corresponding to the block specified by the block integer index.
Definition: BlockBaseRegisterImplem.H:413
LayoutIterator layoutIterator() const
Iterator that processes through ALL the boxes in a BoxLayout.
DataIterator dataIterator() const
Parallel iterator.
bool isEmpty() const
{ Comparison Functions}
Definition: Box.H:1862
LayoutData< DataIndex > m_dstToSrcMap[2 *CH_SPACEDIM]
Definition: BlockBaseRegister.H:358
MultiBlockCoordSys * m_coordsys
Definition: BlockBaseRegister.H:330
void buildInverseBlockBdryIndexMap(Vector< int > a_map[2 *CH_SPACEDIM])
Builds a mapping from the block-boundary index of neighboring block to the local block-boundary index...
Definition: BlockBaseRegisterImplem.H:816
Box & growHi(int idir, int n_cell=1)
Definition: Box.H:2380
bool hasData() const
Returns true if data has been stored in the register, false otherwise.
Definition: BlockBaseRegister.H:172
IntVect permute(const IntVect &a_vec, const IntVect &a_permutation)
Definition: BlockBaseRegisterImplem.H:877
unsigned int procID(const LayoutIndex &a_index) const
Definition: BoxLayout.H:760