[688] | 1 | #ifndef __MAPPER_HPP__ |
---|
| 2 | #define __MAPPER_HPP__ |
---|
| 3 | #include "parallel_tree.hpp" |
---|
[694] | 4 | #include "mpi.hpp" |
---|
[688] | 5 | |
---|
| 6 | namespace sphereRemap { |
---|
| 7 | |
---|
| 8 | enum verbosity |
---|
| 9 | { |
---|
| 10 | SILENT = 0, |
---|
| 11 | PROGRESS = 1, |
---|
| 12 | DETAILS = 2 |
---|
| 13 | }; |
---|
| 14 | |
---|
| 15 | void cptOffsetsFromLengths(const int *lengths, int *offsets, int sz); |
---|
| 16 | |
---|
| 17 | class Mapper |
---|
| 18 | { |
---|
| 19 | public: |
---|
[1639] | 20 | Mapper(MPI_Comm comm=MPI_COMM_WORLD) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {} |
---|
[688] | 21 | ~Mapper(); |
---|
| 22 | void setVerbosity(verbosity v) {verbose=v ;} |
---|
| 23 | |
---|
[1614] | 24 | void setSourceMesh(const double* boundsLon, const double* boundsLat, const double* area, int nVertex, int nbCells, const double* pole, const long int* globalId=NULL) ; |
---|
| 25 | void setTargetMesh(const double* boundsLon, const double* boundsLat, const double* area, int nVertex, int nbCells, const double* pole, const long int* globalId=NULL) ; |
---|
[688] | 26 | void setSourceValue(const double* val) ; |
---|
| 27 | void getTargetValue(double* val) ; |
---|
| 28 | |
---|
| 29 | double buildSSTree(vector<Node>& srcMsh, vector<Node>& trgMsh) |
---|
| 30 | { |
---|
| 31 | sstree.build(srcMsh, trgMsh); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | /** @param trgElts are the elements of the unstructured target grid |
---|
| 35 | Returns the timings for substeps: */ |
---|
[1158] | 36 | vector<double> computeWeights(int interpOrder, bool renormalize=false, bool quantity=false); |
---|
[688] | 37 | int getNbWeights(void) { return nWeights ; } |
---|
| 38 | /* |
---|
| 39 | void getWeigths(double* weights, double* sourceInd, double* targetInd) ; |
---|
| 40 | void getWeights(vector<double>& weights, vector<double>& sourceInd, vector<double>& targetInd) ; |
---|
| 41 | */ |
---|
| 42 | /* where weights are returned after call to `computeWeights` */ |
---|
| 43 | double *remapMatrix; |
---|
| 44 | int *srcAddress; |
---|
| 45 | int *srcRank; |
---|
| 46 | int *dstAddress; |
---|
| 47 | int nWeights; |
---|
| 48 | long int* sourceWeightId ; |
---|
| 49 | long int* targetWeightId ; |
---|
| 50 | |
---|
| 51 | private: |
---|
| 52 | /** @return number of weights (local to cpu) */ |
---|
[1158] | 53 | int remap(Elt* elements, int nbElements, int order, bool renormalize=false, bool quantity=false); |
---|
[688] | 54 | |
---|
| 55 | void buildMeshTopology(); |
---|
| 56 | void computeGrads(); |
---|
| 57 | void computeIntersection(Elt* elements, int nbElements); |
---|
| 58 | |
---|
| 59 | int verbose; |
---|
| 60 | |
---|
| 61 | /** Holds adaptional leaf nodes as ghost cells for gradient computations (hold neighbour elements from other ranks). |
---|
| 62 | They will be inserted to the local trees but not saved in its leaf array */ |
---|
| 63 | vector<Node> neighbourNodes; |
---|
| 64 | |
---|
| 65 | int nbNeighbourElements; |
---|
| 66 | Elt* neighbourElements; |
---|
| 67 | |
---|
| 68 | CParallelTree sstree; |
---|
[1639] | 69 | MPI_Comm communicator ; |
---|
[688] | 70 | std::vector<Elt> sourceElements ; |
---|
| 71 | std::vector<Node> sourceMesh ; |
---|
| 72 | std::vector<Elt> targetElements ; |
---|
| 73 | std::vector<Node> targetMesh ; |
---|
| 74 | std::vector<long> sourceGlobalId ; |
---|
| 75 | std::vector<long> targetGlobalId ; |
---|
| 76 | |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | } |
---|
| 80 | #endif |
---|