source: XIOS/trunk/extern/remap/src/mapper.hpp @ 688

Last change on this file since 688 was 688, checked in by mhnguyen, 9 years ago

Integrating remap library into XIOS

+) Change name of some files of remap library to be compatible with XIOS
+) Implement function to fill in automatically boundary longitude and latitude

Test
+) On Curie
+) test_remap correct

File size: 2.6 KB
Line 
1#ifndef  __MAPPER_HPP__
2#define __MAPPER_HPP__
3#include "parallel_tree.hpp"
4#include <mpi.h>
5//#include "mpi.h"
6
7namespace sphereRemap {
8
9enum verbosity
10{
11       SILENT = 0,
12       PROGRESS = 1,
13       DETAILS = 2
14};
15
16void cptOffsetsFromLengths(const int *lengths, int *offsets, int sz);
17
18class Mapper
19{
20public:
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, int nVertex, int nbCells, const double* pole, const long int* globalId=NULL) ;
26       void setTargetMesh(const double* boundsLon, const double* boundsLat, 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       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: */
37       vector<double> computeWeights(int interpOrder);
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
52private:
53       /** @return number of weights (local to cpu) */
54       int remap(Elt* elements, int nbElements, int order);
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;
70       MPI_Comm communicator ;
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
Note: See TracBrowser for help on using the repository browser.