Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
b9fbc76f
Commit
b9fbc76f
authored
Jan 12, 2021
by
Uwe Schulzweida
Browse files
get_no_unique_center_points(): refactored.
parent
d14c47bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Verifygrid.cc
View file @
b9fbc76f
...
...
@@ -339,18 +339,22 @@ print_header(int gridtype, size_t gridsize, size_t nx, int gridno, int ngrids)
}
static
size_t
get_no_unique_center_points
(
size_t
gridsize
,
size_t
nx
,
const
Varray
<
double
>
&
center_
poin
t
)
get_no_unique_center_points
(
size_t
gridsize
,
size_t
nx
,
const
Varray
<
double
>
&
grid_
center_
lon
,
const
Varray
<
double
>
&
grid_center_la
t
)
{
// For performing the first test, an array of all center point coordinates is built.
Varray
<
double
>
center_points
(
gridsize
*
2
);
create_sorted_point_array
(
gridsize
,
grid_center_lon
,
grid_center_lat
,
center_points
);
size_t
no_unique_center_points
=
1
;
for
(
size_t
cell_no
=
0
;
cell_no
<
gridsize
-
1
;
cell_no
++
)
{
if
(
std
::
fabs
(
center_point
[
cell_no
*
2
+
0
]
-
center_point
[(
cell_no
+
1
)
*
2
+
0
])
<
eps
&&
std
::
fabs
(
center_point
[
cell_no
*
2
+
1
]
-
center_point
[(
cell_no
+
1
)
*
2
+
1
])
<
eps
)
if
(
std
::
fabs
(
center_point
s
[
cell_no
*
2
+
0
]
-
center_point
s
[(
cell_no
+
1
)
*
2
+
0
])
<
eps
&&
std
::
fabs
(
center_point
s
[
cell_no
*
2
+
1
]
-
center_point
s
[(
cell_no
+
1
)
*
2
+
1
])
<
eps
)
{
if
(
Options
::
cdoVerbose
)
{
fprintf
(
stdout
,
"Duplicate point [lon=%.5g lat=%.5g] was found in cell no %zu"
,
center_point
[
cell_no
*
2
+
0
],
center_point
[
cell_no
*
2
+
1
],
cell_no
+
1
);
center_point
s
[
cell_no
*
2
+
0
],
center_point
s
[
cell_no
*
2
+
1
],
cell_no
+
1
);
if
(
nx
)
printIndex2D
(
cell_no
,
nx
);
fprintf
(
stdout
,
"
\n
"
);
}
...
...
@@ -467,14 +471,12 @@ verify_grid(size_t gridsize, size_t nx, int ncorner,
/*
First, this function performs the following test:
1) it tests whether there are duplicate cells in the given grid by
comparing their center point
1) it tests whether there are duplicate cells in the given grid by comparing their center point
Additionally, on each cell of a given grid:
2) it tests whether all cells are convex and all cell bounds have the same
orientation, i.e. the corners of the cell are in clockwise or
counterclockwise order
2) it tests whether all cells are convex and all cell bounds have the same orientation,
i.e. the corners of the cell are in clockwise or counterclockwise order
3) it tests whether the center point is within the bounds of the cell
...
...
@@ -494,14 +496,8 @@ verify_grid(size_t gridsize, size_t nx, int ncorner,
std
::
vector
<
int
>
no_cells_with_a_specific_no_of_corners
(
ncorner
,
0
);
// For performing the first test, an array of all center point coordinates is built.
Varray
<
double
>
center_point_array
(
gridsize
*
2
);
create_sorted_point_array
(
gridsize
,
grid_center_lon
,
grid_center_lat
,
center_point_array
);
// Now checking for the number of unique center point coordinates.
const
auto
no_unique_center_points
=
get_no_unique_center_points
(
gridsize
,
nx
,
center_point_array
);
// Checking for the number of unique center point coordinates.
const
auto
no_unique_center_points
=
get_no_unique_center_points
(
gridsize
,
nx
,
grid_center_lon
,
grid_center_lat
);
// used only actual_number_of_corners
std
::
vector
<
bool
>
marked_duplicate_indices
(
ncorner
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment