30 static const char *
topoNames[] = {
"Cartesian",
"Uniform-rectangular",
"Rectilinear",
"Curvilinear",
"Unknown"};
74 halo() : doFill(false), numThreads(1) {};
78 doFill(false), globalGridExtent(inGlobalExtent),
79 globalPartitionExtent(inPartitionExtent), numThreads(1)
85 bool SetFill(
bool yesno){ doFill = yesno;
return(doFill); };
86 bool Fill() {
return(doFill); };
88 void SetLocalBufferSizes(
const std::vector<size_t> &inBufferSizes);
94 std::vector<size_t> &haloSizes);
95 std::vector<pcpp::IndexIntervalType> CreateRemoteHaloExtents(std::vector<size_t> &haloSizes);
99 std::vector<size_t> &haloSizes);
100 std::vector<pcpp::IndexIntervalType> CreateLocalHaloExtents(std::vector<size_t> &haloSizes);
102 int CreateSimpleSendIndices();
103 int CreateSimpleRecvIndices();
107 int CreateThreadSendIndices(
int threadId);
108 int CreateThreadRecvIndices(
int threadId);
109 int UnpackSimpleRecvBuffers(
int threadId);
111 void SetRemoteHaloExtents(
const std::vector<pcpp::IndexIntervalType> haloExtents);
113 void SetNumThreads(
int numThreadsIn);
117 void SetLocalHaloExtents(
const std::vector<pcpp::IndexIntervalType> haloExtents);
118 int DestroyMessageBuffer(
int messageId);
119 int CreateMessageBuffers(
int numComponents,
int componentSize=8);
120 int PackMessageBuffers(
const int messageId,
const int componentId,
121 const int numComponents,
const double *sourceBuffer);
122 int PackMessageBuffers(
const int messageId,
const int componentId,
123 const int numComponents,
const int *sourceBuffer);
124 int PackMessageBuffers(
const int messageId,
const int componentId,
125 const int numComponents,
const double *sourceBuffer,
127 int PackMessageBuffers(
const int messageId,
const int componentId,
128 const int numComponents,
const int *sourceBuffer,
130 int SendMessage(
const int messageId,
const std::vector<int> &neighborRanks,
132 int ReceiveMessage(
const int messageId,
const std::vector<int> &neighborRanks,
134 int UnPackMessageBuffers(
const int messageId,
const int componentId,
135 const int numComponents,
double *targetBuffer);
136 int UnPackMessageBuffers(
const int messageId,
const int componentId,
137 const int numComponents,
double *targetBuffer,
139 int UnPackMessageBuffers(
const int messageId,
const int componentId,
140 const int numComponents,
int *targetBuffer);
141 int UnPackMessageBuffers(
const int messageId,
const int componentId,
142 const int numComponents,
int *targetBuffer,
146 haveNeighbor = inNeighbors;
152 inline std::vector<pcpp::IndexIntervalType> &
RemoteHaloExtents() {
return(remoteHaloExtents); };
153 inline std::vector<pcpp::IndexIntervalType> &
LocalHaloExtents() {
return(localHaloExtents); };
158 const std::vector<std::vector<size_t> > &
SendIndices()
const {
return(sendIndices);};
159 const std::vector<std::vector<size_t> > &
RecvIndices()
const {
return(recvIndices);};
162 { periodicDirs = inPeriodic; };
163 void ReportSimpleBufferContents(std::ostream &outStream);
263 std::string configName(inConfig.
GetValue(
"ConfigName"));
265 std::ostringstream paramNameOut;
266 paramNameOut <<
"Dimension " <<
"GridType " 267 <<
"PhysicalExtent " <<
"NumPoints " 268 <<
"GenerateGrid " <<
"PhysicalDomain " 269 <<
"DecompDirs " <<
"ThreadDecompDirs";
270 std::string configParamNames(paramNameOut.str());
271 std::istringstream paramNameIn(configParamNames);
272 std::string paramName;
273 while(paramNameIn >> paramName){
274 std::string configKey(
ConfigKey(configName,paramName));
275 if(inConfig.
IsSet(configKey)){
276 gridParam.first = paramName;
277 gridParam.second = inConfig.
GetValue(configKey);
278 gridConfig.push_back(gridParam);
295 std::string configName(inConfig.
GetValue(
"ConfigName"));
297 std::ostringstream paramNameOut;
298 paramNameOut <<
"Dimension " <<
"GridType " 299 <<
"PhysicalDomain " <<
"NumPoints " 301 std::string configParamNames(paramNameOut.str());
302 std::istringstream paramNameIn(configParamNames);
303 std::string paramName;
304 while(paramNameIn >> paramName){
305 std::string configKey(
ConfigKey(configName,paramName));
306 if(inConfig.
IsSet(configKey)){
307 gridParam.first = paramName;
308 gridParam.second = inConfig.
GetValue(configKey);
309 gridConfig.push_back(gridParam);
317 std::ostringstream Ostr;
318 Ostr << gridConfig << std::endl;
338 return(base::Configure(inConfig));
347 return(base::ReportConfiguration());
351 {
return(const_cast<fixtures::CommunicatorType &>(gridCommunicator)); };
396 int SetupThreads(std::vector<int> &numThreadPartitions);
399 stencilSet(NULL), stencilConnectivity(NULL),
400 xyzMessageId(-1), metricMessageId(-1),
406 {
return(partitionIntervals.threadPartitionBufferIntervals.size()); };
408 void SetNumThreads(
int numThreads);
411 {
return(partitionIntervals.threadPartitionIntervals); };
414 {
return(partitionIntervals.threadPartitionIntervals); };
417 {
return(partitionIntervals.threadPartitionBufferIntervals); };
420 {
return(partitionIntervals.threadPartitionBufferIntervals); };
423 {
return(partitionIntervals.threadBufferIntervals); };
426 {
return(partitionIntervals.threadBufferIntervals); };
428 int Dimension()
const {
return (partitionIntervals.numDim); };
439 partitionIntervals.decompSizes = inDecomp;
444 return(partitionIntervals.decompSizes);
449 return(partitionIntervals.decompSizes);
454 partitionIntervals.gridSizes = inSize;
455 partitionIntervals.numDim = inSize.size();
456 numDim = partitionIntervals.numDim;
461 return(partitionIntervals.bufferSizes);
466 return(partitionIntervals.bufferSizes);
471 return(partitionIntervals.gridSizes);
476 return(partitionIntervals.gridSizes);
482 partitionIntervals.partitionSizes = inPartSize;
483 numDim = inPartSize.size();
484 partitionIntervals.numDim = numDim;
489 return(partitionIntervals.partitionSizes);
494 dimExtensions = inExtensions;
498 { partitionIntervals.partitionInterval = inInterval; };
508 assert(inDim < numDim);
513 assert(inDim < numDim);
517 int ExchangeCoordinates();
522 int Finalize(
bool allocateCoordinateData =
false);
528 if(gridCoordinates.size() != numAllocate)
529 gridCoordinates.resize(numAllocate);
536 physicalExtent = inExtent;
538 const std::vector<double> &
DX()
const {
return(dX);};
539 std::vector<double> &
DX() {
return(dX);};
544 HaloType &
Halo() {
return(*haloPtr); };
545 int GenerateCoordinates(std::ostream &);
546 int GenerateCoordinates(
int (*)(
const std::vector<size_t> &,std::vector<double> &),
549 const std::vector<double> &,
550 const std::vector<size_t> &,
551 const std::vector<size_t> &,
552 std::vector<double> &),
556 {
return(subRegions); };
559 {
return(subRegions); };
563 std::vector<subregion>::const_iterator regIt = subRegions.begin();
564 while(regIt != subRegions.end()){
565 if(regIt++->regionName == regionName)
577 {
return(periodicDirs); };
579 {
return(periodicDirs); };
581 {
return(decompDirs); };
583 {
return(decompDirs); };
585 { decompDirs = inDecomp; };
587 { periodicDirs = inPeriodic; };
589 { periodicLengths = inLengths; };
591 {
return(threadDecompDirs); };
593 {
return(threadDecompDirs); };
595 { threadDecompDirs = inThread; };
603 { scaleFactor = inScale; };
605 int haloDepth,std::ostream &messageStream);
610 if(flagData.size() != numFlags)
611 flagData.resize(numFlags,0);
621 size_t FlagMask(
int *iMask,
int flagValue = 0,
int flagBit = 1)
const;
629 int ComputeUniformRectangularMetrics(std::ostream &messageStream);
630 int ComputeRectilinearMetrics(std::ostream &messageStream);
631 int ComputeCurvilinearMetrics2D(std::ostream &messageStream);
632 int ComputeCurvilinearMetrics3D(std::ostream &messageStream);
633 int CurvilinearMetrics(std::ostream &messageStream);
634 int ComputeMetrics(std::ostream &messageStream);
635 int ComputeMetricIdentities(std::vector<double> &identityData,std::ostream &messageStream);
638 int ExchangeJacobianMatrix(std::ostream &messageStream);
639 int GradIJK(
int numComponents,
double *sourceBuffer,
640 double *targetBuffer,std::ostream &messageStream,
bool exchange);
641 int ComputeJacobianMatrix(std::ostream &messageStream);
642 int ComputeJacobianMatrix2(std::ostream &messageStream);
644 {
return(gridGenParams); };
646 {
return(gridGenParams); };
648 { gridGenParams = inParams; };
650 {
return(gridGenOptions); };
652 {
return(gridGenOptions); };
654 { gridGenOptions = inOptions; };
686 std::vector<double>
dX;
716 template<
typename Gr
idType>
719 int numDim = inGrid.Dimension();
720 const std::vector<size_t> &
gridSizes(inGrid.GridSizes());
721 const std::vector<size_t> &
bufferSizes(inGrid.BufferSizes());
724 std::vector<double> dX(numDim,0.0);
726 for(
int iDim = 0;iDim < numDim;iDim++)
727 dX[iDim] = (physicalExtent[2*iDim+1] - physicalExtent[2*iDim])/
static_cast<double>(
gridSizes[iDim]-1);
728 inGrid.AllocateCoordinateData();
729 std::vector<double> &gridCoordinates(inGrid.CoordinateData());
734 size_t bufferLine = bufferSizes[0];
736 size_t xStart = partInterval[0].first;
737 size_t xEnd = partInterval[0].second;
738 size_t yStart = partInterval[1].first;
739 size_t yEnd = partInterval[1].second;
740 size_t zStart = partInterval[2].first;
741 size_t zEnd = partInterval[2].second;
743 size_t iStart = partitionBufferInterval[0].first;
744 size_t iEnd = partitionBufferInterval[0].second;
745 size_t jStart = partitionBufferInterval[1].first;
746 size_t jEnd = partitionBufferInterval[1].second;
747 size_t kStart = partitionBufferInterval[2].first;
748 size_t kEnd = partitionBufferInterval[2].second;
750 size_t kIndex = kStart;
751 size_t zIndex = zStart;
753 for(kIndex = kStart,zIndex = zStart;kIndex <= kEnd;kIndex++,zIndex++){
754 size_t jIndex = jStart;
755 size_t yIndex = yStart;
756 size_t bzIndex = kIndex * (bufferPlane);
757 double zCoordinate = zIndex*dX[2] + physicalExtent[4];
758 for(jIndex = jStart,yIndex = yStart;jIndex <= jEnd;jIndex++,yIndex++){
759 size_t iIndex = iStart;
760 size_t xIndex = xStart;
761 size_t byzIndex = bzIndex + jIndex*bufferLine;
762 double yCoordinate = yIndex*dX[1] + physicalExtent[2];
763 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
764 size_t bufferIndex = byzIndex + iIndex;
765 double xCoordinate = xIndex*dX[0] + physicalExtent[0];
766 gridCoordinates[bufferIndex] = xCoordinate;
772 }
else if (numDim == 2) {
776 size_t xStart = partInterval[0].first;
777 size_t xEnd = partInterval[0].second;
778 size_t yStart = partInterval[1].first;
779 size_t yEnd = partInterval[1].second;
781 size_t iStart = partitionBufferInterval[0].first;
782 size_t iEnd = partitionBufferInterval[0].second;
783 size_t jStart = partitionBufferInterval[1].first;
784 size_t jEnd = partitionBufferInterval[1].second;
786 size_t jIndex = jStart;
787 size_t yIndex = yStart;
788 for(jIndex = jStart,yIndex = yStart;jIndex <= jEnd;jIndex++,yIndex++){
789 size_t iIndex = iStart;
790 size_t xIndex = xStart;
791 size_t byIndex = jIndex*bufferLine;
792 double yCoordinate = yIndex*dX[1] + physicalExtent[2];
793 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
794 size_t bufferIndex = byIndex + iIndex;
795 double xCoordinate = xIndex*dX[0] + physicalExtent[0];
796 gridCoordinates[bufferIndex] = xCoordinate;
800 }
else if (numDim == 1) {
803 size_t xStart = partInterval[0].first;
804 size_t xEnd = partInterval[0].second;
806 size_t iStart = partitionBufferInterval[0].first;
807 size_t iEnd = partitionBufferInterval[0].second;
809 size_t iIndex = iStart;
810 size_t xIndex = xStart;
811 for(iIndex = iStart,xIndex = xStart;iIndex <= iEnd;iIndex++,xIndex++){
812 gridCoordinates[iIndex] = xIndex*dX[0] + physicalExtent[0];
std::vector< double > Jacobian() const
std::vector< int * > recvFlagBuffers
void const size_t const size_t const size_t const int const int const double * gridMetric
pcpp::IndexIntervalType partitionBufferInterval
Partition interval wrt the local buffer dimensions.
virtual std::string ReportConfiguration()
std::vector< std::vector< std::vector< size_t > > > threadHaloBufferIndices
void SetPartitionInterval(const pcpp::IndexIntervalType &inInterval)
fixtures::ConfigurationType gridConfig
void SetPartitionSizes(const std::vector< size_t > &inPartSize)
std::vector< double > & Jacobian()
std::vector< double > gridJacobian
void SetPeriodicDirs(const std::vector< bool > &inPeriodic)
void SetPartitionInterval(const pcpp::IndexIntervalType &inExtent)
const std::vector< pcpp::IndexIntervalType > & LocalHaloBufferExtents() const
pcpp::IndexIntervalType partitionInterval
Partition interval wrt the grid dimensions.
const pbsintervals & Intervals() const
std::vector< size_t > partitionSizes
Number of points in each dimension for local partition.
int GenerateGrid(GridType &inGrid, const std::string &gridName, const fixtures::ConfigurationType &inConfig, std::ostream &messageStream)
pcpp::IndexIntervalType regionInterval
pcpp::IndexIntervalType globalInterval
const pcpp::IndexIntervalType & PartitionBufferInterval() const
std::vector< std::vector< size_t > > threadPartitionBufferIndices
std::vector< double > & Metric()
std::vector< double > scaleFactor
Grid scaling factor.
std::vector< int > threadDecompDirs
std::vector< std::vector< std::vector< size_t > > > threadRecvBufferIndices
const std::vector< double > & CoordinateData() const
std::vector< int > & PeriodicDirs()
std::vector< std::vector< std::vector< size_t > > > threadRecvIndices
const std::vector< size_t > & PartitionSizes() const
const std::vector< std::vector< size_t > > & RecvIndices() const
const std::vector< pcpp::IndexIntervalType > & ThreadBufferIntervals() const
std::vector< double > & DX()
std::vector< int * > sendFlagBuffers
static const char * topoNames[]
std::vector< pcpp::IndexIntervalType > threadBufferExtents
pcpp::IndexIntervalType bufferInterval
size_t PartitionSize() const
void SetPeriodicDirs(const std::vector< int > &inPeriodic)
std::vector< size_t > bufferSizes
Buffer size in each dimension.
virtual int ConfigureGrid(fixtures::ConfigurationType &inConfig, std::ostream &messageStream)
const double * CoordinateData(int inDim) const
std::vector< double > Metric() const
const std::vector< double > & DX() const
pcpp::IndexIntervalType & PartitionInterval()
pcpp::IndexIntervalType regionPartitionBufferInterval
std::vector< messagebuffers > & CommunicationBuffers()
std::vector< size_t > & GridSizes()
void const size_t const size_t * gridSizes
std::vector< double > jacobianMatrix2
std::vector< double * > recvBuffers
void SetThreadDecompDirs(const std::vector< int > &inThread)
void SetDimensionExtensions(const std::vector< size_t > &inExtensions)
void const size_t const size_t const size_t const int const int * gridType
std::vector< messagebuffers > communicationBuffers
pcpp::IndexIntervalType regionPartitionInterval
std::vector< size_t > localBufferSizes
const std::vector< pcpp::IndexIntervalType > & ThreadPartitionBufferIntervals() const
std::vector< pcpp::IndexIntervalType > & RemoteHaloExtents()
std::vector< size_t > numPointsSend
size_t BufferSize(int numDim, size_t *dimSize)
std::vector< subregion > & SubRegions()
void SetHalo(halo &inHalo)
std::vector< int > flagData
const std::vector< bool > & PeriodicDirs() const
void SetGridSizes(const std::vector< size_t > &inSize)
std::vector< pcpp::IndexIntervalType > localHaloExtents
std::vector< size_t > gridSizes
Number of points in each dimension for the grid.
std::vector< int > & GridGenerationOptions()
const pcpp::IndexIntervalType & PartitionInterval() const
const std::vector< subregion > & SubRegions() const
int NumberOfThreads() const
void SetGridGenerationOptions(const std::vector< int > &inOptions)
const std::vector< size_t > & BufferSizes() const
const std::vector< std::vector< size_t > > & SendIndices() const
const std::vector< pcpp::IndexIntervalType > & RemoteHaloBufferExtents() const
int InitSubRegionFromString(const std::string &inString, const std::vector< size_t > &gridSizes, subregion &inSubRegion)
std::vector< bool > haveNeighbor
std::vector< std::vector< std::vector< size_t > > > threadSendIndices
std::vector< double > GenerateUniformGrid(GridType &inGrid, const std::vector< double > &physicalExtent)
virtual int Configure(fixtures::ConfigurationType &inConfig)
std::vector< std::vector< size_t > > sendIndices
static const int NUMGRIDTYPES
void SetPeriodicLengths(const std::vector< double > &inLengths)
size_t numPointsPartition
Number of points in the partition.
std::vector< int > & ThreadDecompDirs()
const std::vector< int > & FlagData() const
std::vector< pcpp::IndexIntervalType > & LocalHaloExtents()
virtual int Configure(fixtures::ConfigurationType &inConfig)
const std::vector< pcpp::IndexIntervalType > & ThreadPartitionIntervals() const
std::vector< std::vector< size_t > > recvIndices
std::vector< int > & FlagData()
pcpp::IndexIntervalType & PartitionExtent()
size_t numPointsBuffer
Number of points in the buffer.
const std::vector< int > & GridGenerationOptions() const
const std::vector< double > & GridGenerationParameters() const
std::vector< bool > periodicDirs
pcpp::IndexIntervalType & PartitionBufferInterval()
void SetDecompDirs(const std::vector< int > &inDecomp)
const std::vector< size_t > & GridSizes() const
void SetLocalPartitionExtent(const pcpp::IndexIntervalType &inExtent)
std::vector< pcpp::IndexIntervalType > threadPartitionIntervals
const std::vector< int > & DecompDirs() const
pcpp::IndexIntervalType localInterval
std::vector< pcpp::IndexIntervalType > threadBufferIntervals
pcpp::IndexIntervalType localPartitionExtent
std::vector< int > gridGenOptions
std::vector< size_t > partitionBufferIndices
std::vector< int > decompSizes
Prescribed decomposition.
void SetGridSpacings(const std::vector< double > &inSpacing)
const std::vector< int > & ThreadDecompDirs() const
std::vector< pcpp::IndexIntervalType > threadBufferIntervals
Buffer interval owned by each thread (omp)
void SetNeighbors(const std::vector< bool > &inNeighbors)
void SetDecompSizes(const std::vector< int > &inDecomp)
std::vector< double * > sendBuffers
std::vector< double > jacobianMatrix
Main encapsulation of MPI.
int ResolveTopoName(const std::string &inName)
std::vector< pcpp::IndexIntervalType > remoteHaloExtents
std::string GetValue(const std::string &key) const
Encapsulation for a collection of operator stencils.
TopoType
Geometry/grid topology types.
std::vector< double > gridGenParams
void const size_t const size_t const size_t const int const double * gridJacobian
std::vector< double > physicalExtent
Physical grid extent (when applicable)
std::vector< double > dX
Grid spacing data structure (size depends on gridTopoType)
std::vector< pcpp::IndexIntervalType > & ThreadPartitionIntervals()
void SetGridGenerationParameters(const std::vector< double > &inParams)
parallel_blockstructured()
void const size_t const size_t * bufferSizes
void SetScaleFactor(const std::vector< double > &inScale)
std::vector< subregion > subRegions
Sub-regions and boundaries.
virtual std::string ReportConfiguration()
TopoType gridTopoType
The topology type.
std::string ConfigKey(const std::string &configName, const std::string &keyName)
std::vector< bool > & PeriodicDirs()
std::vector< pcpp::IndexIntervalType > threadExtents
double * CoordinateData(int inDim)
const std::vector< double > & PhysicalExtent() const
std::vector< pcpp::IndexIntervalType > threadPartitionIntervals
Partition intervals owned by thread (omp)
std::vector< std::pair< int, std::vector< size_t > > > haloRecvIndices
std::vector< double > & CoordinateData()
std::vector< int > periodicDirs
pcpp::IndexIntervalType & GlobalExtent()
pbsintervals partitionIntervals
The relevant partition intervals.
std::vector< size_t > dimExtensions
Number of "halo/ghost" points in each (+/-) of the 2*numDim directions.
std::vector< int > & DecompSizes()
halo(const pcpp::IndexIntervalType &inGlobalExtent, const pcpp::IndexIntervalType &inPartitionExtent)
std::vector< pcpp::IndexIntervalType > remoteHaloBufferExtents
virtual int ConfigureGrid(fixtures::ConfigurationType &inConfig, std::ostream &messageStream)
void AllocateCoordinateData()
std::vector< int > decompDirs
std::vector< pcpp::IndexIntervalType > threadPartitionBufferIntervals
Partition buffer interval owned by each thread (omp)
std::vector< pcpp::IndexIntervalType > threadOpIntervals
std::vector< pcpp::RemoteCollisionType > recvCollisions
std::vector< double > & JacobianMatrix()
pcpp::IndexIntervalType patchInterval
pcpp::IndexIntervalType opInterval
std::vector< size_t > numPointsRecv
pcpp::IndexIntervalType ResolveBufferInterval(const pcpp::IndexIntervalType &partitionInterval, const pcpp::IndexIntervalType &partitionBufferInterval, const pcpp::IndexIntervalType &partitionSubInterval)
std::string ResolveTopoType(int inType)
Simple Block Structured Mesh object.
void SetGridInterval(const pcpp::IndexIntervalType &inExtent)
std::vector< pcpp::IndexIntervalType > sendExtents
int * stencilConnectivity
std::vector< pcpp::IndexIntervalType > threadPartitionBufferIntervals
std::vector< double > JacobianMatrix() const
fixtures::CommunicatorType & Communicator() const
std::vector< size_t > & BufferSizes()
std::vector< pcpp::IndexIntervalType > & ThreadBufferIntervals()
void size_t int * numComponents
int ConfigureGrid(const fixtures::ConfigurationType &inConfig, const std::string &gridName, GridType &inGrid, std::ostream &messageStream)
const std::vector< int > & DecompSizes() const
std::vector< double > & GridGenerationParameters()
pcpp::IndexIntervalType globalBufferInterval
The local buffer interval wrt the global grid size [yet unused].
std::vector< pcpp::RemoteCollisionType > sendCollisions
pbsintervals & Intervals()
pcpp::IndexIntervalType globalGridExtent
std::vector< double > gridCoordinates
The coordinate buffer.
void SetPhysicalExtent(const std::vector< double > &inExtent)
std::vector< double > periodicLengths
std::vector< std::vector< std::vector< size_t > > > threadSendBufferIndices
std::vector< pcpp::IndexIntervalType > & ThreadPartitionBufferIntervals()
pcpp::IndexIntervalType globalPartitionExtent
int GetRegionIndex(const std::string ®ionName) const
std::vector< double > gridMetric
Grid metrics (sizes depend on gridTopoType)
std::vector< double > & PhysicalExtent()
void const size_t * numPointsBuffer
size_t BufferSize() const
halo gridHalo
Halo object for communicating data with grid "neighbors".
bool IsSet(const std::string &Key) const
std::vector< int > & DecompDirs()
plascom2::operators::stencilset * stencilSet
Differential operator.
std::vector< pcpp::IndexIntervalType > localHaloBufferExtents