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

Last change on this file since 1638 was 1638, checked in by yushan, 5 years ago

dev on ADA

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