[688] | 1 | #ifndef __MAPPER_HPP__ |
---|
| 2 | #define __MAPPER_HPP__ |
---|
| 3 | #include "parallel_tree.hpp" |
---|
[694] | 4 | #include "mpi.hpp" |
---|
[2269] | 5 | #include "timerRemap.hpp" |
---|
[688] | 6 | |
---|
| 7 | namespace sphereRemap { |
---|
| 8 | |
---|
| 9 | enum verbosity |
---|
| 10 | { |
---|
| 11 | SILENT = 0, |
---|
| 12 | PROGRESS = 1, |
---|
| 13 | DETAILS = 2 |
---|
| 14 | }; |
---|
| 15 | |
---|
| 16 | void cptOffsetsFromLengths(const int *lengths, int *offsets, int sz); |
---|
| 17 | |
---|
| 18 | class Mapper |
---|
| 19 | { |
---|
| 20 | public: |
---|
[1639] | 21 | Mapper(MPI_Comm comm=MPI_COMM_WORLD) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {} |
---|
[688] | 22 | ~Mapper(); |
---|
| 23 | void setVerbosity(verbosity v) {verbose=v ;} |
---|
| 24 | |
---|
[1614] | 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 | |
---|
[2269] | 30 | void buildSSTree(vector<NodePtr>& srcMsh, vector<NodePtr>& trgMsh) |
---|
[688] | 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` */ |
---|
[2538] | 44 | std::vector<double> remapMatrix; |
---|
| 45 | std::vector<int> srcAddress; |
---|
| 46 | std::vector<int> srcRank; |
---|
| 47 | std::vector<int> dstAddress; |
---|
[688] | 48 | int nWeights; |
---|
[2538] | 49 | std::vector<long int> sourceWeightId ; |
---|
| 50 | std::vector<long int> targetWeightId ; |
---|
[688] | 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 */ |
---|
[2269] | 64 | vector<NodePtr> neighbourNodes; |
---|
[688] | 65 | |
---|
| 66 | int nbNeighbourElements; |
---|
| 67 | Elt* neighbourElements; |
---|
| 68 | |
---|
| 69 | CParallelTree sstree; |
---|
[1639] | 70 | MPI_Comm communicator ; |
---|
[688] | 71 | std::vector<Elt> sourceElements ; |
---|
[2269] | 72 | std::vector<NodePtr> sourceMesh ; |
---|
[688] | 73 | std::vector<Elt> targetElements ; |
---|
[2269] | 74 | std::vector<NodePtr> targetMesh ; |
---|
[688] | 75 | std::vector<long> sourceGlobalId ; |
---|
| 76 | std::vector<long> targetGlobalId ; |
---|
| 77 | |
---|
| 78 | }; |
---|
| 79 | |
---|
| 80 | } |
---|
| 81 | #endif |
---|