Last change
on this file since 1741 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:
963 bytes
|
Rev | Line | |
---|
[688] | 1 | #include <algorithm> |
---|
| 2 | #include "node.hpp" |
---|
| 3 | #include "elt.hpp" |
---|
| 4 | |
---|
| 5 | #include "circle.hpp" |
---|
| 6 | |
---|
| 7 | namespace sphereRemap |
---|
| 8 | { |
---|
| 9 | |
---|
| 10 | /* computes the radius of the smallest circle |
---|
| 11 | around the barycentre `x` of grid element `elt` |
---|
| 12 | which contains all vertices of `elt`. */ |
---|
| 13 | double cptRadius(Elt elt) |
---|
| 14 | { |
---|
| 15 | double squareradius = 0.0; |
---|
| 16 | int argmax = 0; |
---|
| 17 | // use cheep `squaredist` to find farthest vertex and compute radius as arcdistance only once |
---|
| 18 | for (int i = 0; i < elt.n; i++) |
---|
| 19 | { |
---|
| 20 | double dist2 = squaredist(elt.x, elt.vertex[i]); |
---|
| 21 | if (dist2 > squareradius) |
---|
| 22 | { |
---|
| 23 | squareradius = dist2; |
---|
| 24 | argmax = i; |
---|
| 25 | } |
---|
| 26 | } |
---|
| 27 | return arcdist(elt.x, elt.vertex[argmax]) + 1e-10; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | void setCircleAndLink(Elt& elt, Node& leaf) |
---|
| 31 | { |
---|
| 32 | leaf.centre = elt.x; |
---|
| 33 | leaf.radius = cptRadius(elt); |
---|
| 34 | leaf.data = &elt; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | void setCirclesAndLinks(Elt *elts, vector<Node>& nodes) |
---|
| 38 | { |
---|
| 39 | for (int i = 0; i < nodes.size(); i++) |
---|
| 40 | setCircleAndLink(elts[i], nodes[i]); |
---|
| 41 | } |
---|
| 42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.