[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: |
---|
[1355] | 20 | //Mapper(ep_lib::MPI_Comm comm) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {} |
---|
| 21 | Mapper(ep_lib::MPI_Comm comm) : verbose(SILENT), neighbourElements(NULL), sstree(comm) |
---|
| 22 | { |
---|
| 23 | ep_lib::MPI_Comm_dup(comm, &communicator); |
---|
| 24 | } |
---|
| 25 | |
---|
[688] | 26 | ~Mapper(); |
---|
| 27 | void setVerbosity(verbosity v) {verbose=v ;} |
---|
| 28 | |
---|
| 29 | void setSourceMesh(const double* boundsLon, const double* boundsLat, int nVertex, int nbCells, const double* pole, const long int* globalId=NULL) ; |
---|
| 30 | void setTargetMesh(const double* boundsLon, const double* boundsLat, int nVertex, int nbCells, const double* pole, const long int* globalId=NULL) ; |
---|
| 31 | void setSourceValue(const double* val) ; |
---|
| 32 | void getTargetValue(double* val) ; |
---|
| 33 | |
---|
| 34 | double buildSSTree(vector<Node>& srcMsh, vector<Node>& trgMsh) |
---|
| 35 | { |
---|
| 36 | sstree.build(srcMsh, trgMsh); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | /** @param trgElts are the elements of the unstructured target grid |
---|
| 40 | Returns the timings for substeps: */ |
---|
[1114] | 41 | vector<double> computeWeights(int interpOrder, bool renormalize=false, bool quantity=false); |
---|
[688] | 42 | int getNbWeights(void) { return nWeights ; } |
---|
| 43 | /* |
---|
| 44 | void getWeigths(double* weights, double* sourceInd, double* targetInd) ; |
---|
| 45 | void getWeights(vector<double>& weights, vector<double>& sourceInd, vector<double>& targetInd) ; |
---|
| 46 | */ |
---|
| 47 | /* where weights are returned after call to `computeWeights` */ |
---|
| 48 | double *remapMatrix; |
---|
| 49 | int *srcAddress; |
---|
| 50 | int *srcRank; |
---|
| 51 | int *dstAddress; |
---|
| 52 | int nWeights; |
---|
| 53 | long int* sourceWeightId ; |
---|
| 54 | long int* targetWeightId ; |
---|
| 55 | |
---|
| 56 | private: |
---|
| 57 | /** @return number of weights (local to cpu) */ |
---|
[1114] | 58 | int remap(Elt* elements, int nbElements, int order, bool renormalize=false, bool quantity=false); |
---|
[688] | 59 | |
---|
| 60 | void buildMeshTopology(); |
---|
| 61 | void computeGrads(); |
---|
| 62 | void computeIntersection(Elt* elements, int nbElements); |
---|
| 63 | |
---|
| 64 | int verbose; |
---|
| 65 | |
---|
| 66 | /** Holds adaptional leaf nodes as ghost cells for gradient computations (hold neighbour elements from other ranks). |
---|
| 67 | They will be inserted to the local trees but not saved in its leaf array */ |
---|
| 68 | vector<Node> neighbourNodes; |
---|
| 69 | |
---|
| 70 | int nbNeighbourElements; |
---|
| 71 | Elt* neighbourElements; |
---|
| 72 | |
---|
| 73 | CParallelTree sstree; |
---|
[1134] | 74 | ep_lib::MPI_Comm communicator ; |
---|
[688] | 75 | std::vector<Elt> sourceElements ; |
---|
| 76 | std::vector<Node> sourceMesh ; |
---|
| 77 | std::vector<Elt> targetElements ; |
---|
| 78 | std::vector<Node> targetMesh ; |
---|
| 79 | std::vector<long> sourceGlobalId ; |
---|
| 80 | std::vector<long> targetGlobalId ; |
---|
| 81 | |
---|
| 82 | }; |
---|
| 83 | |
---|
| 84 | } |
---|
| 85 | #endif |
---|