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