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