1 | #ifndef __MAPPER_HPP__ |
---|
2 | #define __MAPPER_HPP__ |
---|
3 | #include "parallel_tree.hpp" |
---|
4 | #include "mpi.hpp" |
---|
5 | #include "timerRemap.hpp" |
---|
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: |
---|
21 | Mapper(MPI_Comm comm=MPI_COMM_WORLD) : communicator(comm), verbose(SILENT), neighbourElements(NULL), sstree(comm) {} |
---|
22 | ~Mapper(); |
---|
23 | void setVerbosity(verbosity v) {verbose=v ;} |
---|
24 | |
---|
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) ; |
---|
27 | void setSourceValue(const double* val) ; |
---|
28 | void getTargetValue(double* val) ; |
---|
29 | |
---|
30 | void buildSSTree(vector<NodePtr>& srcMsh, vector<NodePtr>& 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: */ |
---|
37 | vector<double> computeWeights(int interpOrder, bool renormalize=false, bool quantity=false); |
---|
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) */ |
---|
54 | int remap(Elt* elements, int nbElements, int order, bool renormalize=false, bool quantity=false); |
---|
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<NodePtr> neighbourNodes; |
---|
65 | |
---|
66 | int nbNeighbourElements; |
---|
67 | Elt* neighbourElements; |
---|
68 | |
---|
69 | CParallelTree sstree; |
---|
70 | MPI_Comm communicator ; |
---|
71 | std::vector<Elt> sourceElements ; |
---|
72 | std::vector<NodePtr> sourceMesh ; |
---|
73 | std::vector<Elt> targetElements ; |
---|
74 | std::vector<NodePtr> targetMesh ; |
---|
75 | std::vector<long> sourceGlobalId ; |
---|
76 | std::vector<long> targetGlobalId ; |
---|
77 | |
---|
78 | }; |
---|
79 | |
---|
80 | } |
---|
81 | #endif |
---|