35 #ifndef SCHNEK_DOMAINSUBDIVISION_HPP 36 #define SCHNEK_DOMAINSUBDIVISION_HPP 38 #include "boundary.hpp" 40 #include <boost/shared_ptr.hpp> 50 template<
class Gr
idType>
53 enum {Rank = GridType::Rank};
55 typedef typename GridType::IndexType LimitType;
56 typedef typename GridType::value_type value_type;
57 typedef typename GridType::CheckingPolicyType CheckingPolicyType;
58 typedef typename GridType::StoragePolicyType StoragePolicyType;
65 typedef boost::shared_ptr<BoundaryType> pBoundaryType;
80 int getDelta() {
return bounds->getDelta(); }
88 virtual void init(
const LimitType &low,
const LimitType &high,
int delta) = 0;
93 void init(
const DomainType &domain,
int delta)
101 void init(
const GridType &grid,
int delta)
103 init(grid.getLo(), grid.getHi(), delta);
109 void init(
const LimitType &size,
int delta)
111 LimitType sizem(size);
112 for (
int i=0; i<Rank; ++i) --sizem[i];
113 init(LimitType(0), sizem, delta);
120 const DomainType &
getDomain()
const {
return bounds->getDomain(); }
122 const LimitType &
getLo()
const {
return bounds->getDomain().getLo();}
124 const LimitType &
getHi()
const {
return bounds->getDomain().getHi();}
129 LimitType
getInnerLo()
const {
return bounds->getInnerDomain().getLo();}
131 LimitType
getInnerHi()
const {
return bounds->getInnerDomain().getHi();}
135 template<
typename T,
template<
int>
class CheckingPolicy>
140 for (
int i=0; i<Rank; ++i)
142 const T &lo = globalExtent.
getLo()[i];
143 T dx = (globalExtent.
getHi()[i]-lo) / (T)(globalGridSize.
getHi()[i] - globalGridSize.
getLo()[i] + 1);
144 localDomainMin[i] = lo + this->
getInnerLo()[i]*dx;
145 localDomainMax[i] = lo + this->
getInnerHi()[i]*dx;
154 template<
typename T,
template<
int>
class CheckingPolicy>
164 virtual void exchange(GridType &grid,
int dim) = 0;
169 virtual void accumulate(GridType &grid,
int dim) = 0;
171 virtual void exchangeData(
int dim,
int orientation, BufferType &in, BufferType &out) = 0;
174 virtual double avgReduce(
double)
const = 0;
180 virtual double sumReduce(
double)
const = 0;
186 virtual double maxReduce(
double)
const = 0;
192 virtual double minReduce(
double)
const = 0;
199 virtual bool master()
const = 0;
202 virtual int procnum()
const = 0;
229 for (
int i=0; i<Rank; ++i)
exchange(grid,i);
233 for (
int i=0; i<Rank; ++i)
accumulate(grid,i);
237 template<
class Gr
idType>
242 typedef typename GridType::value_type value_type;
267 void init(
const LimitType &low,
const LimitType &high,
int delta);
277 void exchange(GridType &grid,
int dim);
284 void exchangeData(
int dim,
int orientation, BufferType &in, BufferType &out);
353 #include "domainsubdivision.t" 355 #endif // SCHNEK_DOMAINSUBDIVISION_HPP Definition: domainsubdivision.hpp:238
virtual bool master() const =0
Return true if this is the master process and false otherwise.
double sumReduce(double val) const
The sum of a single value is the value.
Definition: domainsubdivision.hpp:305
Interface for wrapping and exchanging boundaries .
Definition: domainsubdivision.hpp:51
Definition: boundary.hpp:44
int procnum() const
Returns the comm rank as given by mpi.
Definition: domainsubdivision.hpp:314
virtual double maxReduce(double) const =0
Return the maximum of a single value over all the processes.
int minReduce(int val) const
Return the minimum of a single value over all the processes.
Definition: domainsubdivision.hpp:302
virtual int procnum() const =0
Return the process number.
bool isBoundLo(int)
Definition: domainsubdivision.hpp:332
int getUniqueId() const
returns an ID, which consists of the Dimensions and coordinates
Definition: domainsubdivision.hpp:320
double maxReduce(double val) const
The maximum of a single value is the value.
Definition: domainsubdivision.hpp:293
virtual ~DomainSubdivision()
Virtual destructor.
Definition: domainsubdivision.hpp:78
const DomainType & getDomain() const
Return the local domain size.
Definition: domainsubdivision.hpp:120
DomainType getInnerDomain() const
Return the local inner domain size.
Definition: domainsubdivision.hpp:127
virtual bool isBoundHi(int dim)=0
Range< T, Rank, CheckingPolicy > getInnerExtent(const Range< T, Rank, CheckingPolicy > &globalExtent) const
Return the local inner physical extent.
Definition: domainsubdivision.hpp:136
int procCount() const
Return the total number of processes.
Definition: domainsubdivision.hpp:317
bool isBoundHi(int)
Definition: domainsubdivision.hpp:344
void init(const GridType &grid, int delta)
Definition: domainsubdivision.hpp:101
virtual void init(const LimitType &low, const LimitType &high, int delta)=0
void init(const DomainType &domain, int delta)
Definition: domainsubdivision.hpp:93
virtual double avgReduce(double) const =0
Return the average of a single value over all the processes.
double minReduce(double val) const
Return the minimum of a single value over all the processes.
Definition: domainsubdivision.hpp:299
virtual const DomainType & getGlobalDomain() const =0
Return the global domain size excluding ghost cells.
int sumReduce(int val) const
The sum of a single value is the value.
Definition: domainsubdivision.hpp:308
void init(const LimitType &size, int delta)
Definition: domainsubdivision.hpp:109
LimitType getInnerHi() const
Return the maximum of the local inner domain.
Definition: domainsubdivision.hpp:131
bool master() const
The process with the rank zero is designated master process.
Definition: domainsubdivision.hpp:311
const DomainType & getGlobalDomain() const
Return the global domain size excluding ghost cells.
Definition: domainsubdivision.hpp:270
virtual int getUniqueId() const =0
get a unique Id
const LimitType & getHi() const
Return rectangle maximum.
Definition: range.hpp:77
virtual double sumReduce(double) const =0
Return the average of a single value over all the processes.
double avgReduce(double val) const
The average of a single value is the value.
Definition: domainsubdivision.hpp:287
Range< T, Rank, CheckingPolicy > getInnerExtent(const Array< T, Rank, CheckingPolicy > &globalExtent) const
Definition: domainsubdivision.hpp:155
int avgReduce(int val) const
The average of a single value is the value.
Definition: domainsubdivision.hpp:290
virtual void exchange(GridType &grid, int dim)=0
Exchange the boundaries of a field function in the direction given by dim.
virtual int procCount() const =0
Return the total number of processes.
virtual bool isBoundLo(int dim)=0
LimitType getInnerLo() const
Return the minimum of the local inner domain.
Definition: domainsubdivision.hpp:129
virtual double minReduce(double) const =0
Return the minimum of a single value over all the processes.
const LimitType & getLo() const
Return the minimum of the local domain.
Definition: domainsubdivision.hpp:122
int maxReduce(int val) const
The maximum of a single value is the value.
Definition: domainsubdivision.hpp:296
virtual void accumulate(GridType &grid, int dim)=0
Exchange the boundaries of a field function summing the data from ghost cells and inner cells...
const LimitType & getLo() const
Return rectangle minimum.
Definition: range.hpp:73
const LimitType & getHi() const
Return the maximum of the local domain.
Definition: domainsubdivision.hpp:124
DomainSubdivision()
Default constructor.
Definition: domainsubdivision.hpp:72