YetAnotherCoupler 3.2.0_a
Loading...
Searching...
No Matches
Functions
area.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <float.h>
#include "area.h"
#include "basic_grid.h"
#include "clipping.h"
#include "geometry.h"
#include "utils_core.h"
#include "ensure_array_size.h"
Include dependency graph for area.c:

Go to the source code of this file.

Functions

static double scalar_product (double a[], double b[])
 
double yac_triangle_area (struct yac_grid_cell cell)
 Calculate the area of a triangle on a unit sphere.
 
static struct sin_cos_angle tri_area_quarter_angle (struct sin_cos_angle angle)
 
static double tri_area_ (struct sin_cos_angle angle_a, struct sin_cos_angle angle_b, struct sin_cos_angle angle_c)
 
static double tri_area (double u[3], double v[3], double w[3])
 
static int compute_norm_vector (double a[], double b[], double norm[])
 
static double XYZtoLon (double a[3])
 
static double lat_edge_correction (double base_vec[3], double a[3], double b[3])
 
double yac_pole_area (struct yac_grid_cell cell)
 Calculate the area of a cell in a 3d plane on a unit sphere.
 
double yac_planar_3dcell_area (struct yac_grid_cell cell)
 Area calculation on a unit sphere of a planar polygon in 3D.
 
double yac_huiliers_area (struct yac_grid_cell cell)
 Area calculation on a unit sphere taken from ESMF based on L'Huilier's Theorem.
 
static double tri_area_info (double ref[3], double a[3], double b[3], double *barycenter, double sign)
 
double yac_huiliers_area_info (struct yac_grid_cell cell, double *barycenter, double sign)
 

Function Documentation

◆ compute_norm_vector()

static int compute_norm_vector ( double  a[],
double  b[],
double  norm[] 
)
inlinestatic

Definition at line 196 of file area.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lat_edge_correction()

static double lat_edge_correction ( double  base_vec[3],
double  a[3],
double  b[3] 
)
static

Definition at line 218 of file area.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scalar_product()

static double scalar_product ( double  a[],
double  b[] 
)
inlinestatic

Definition at line 533 of file area.c.

Here is the caller graph for this function:

◆ tri_area()

static double tri_area ( double  u[3],
double  v[3],
double  w[3] 
)
static

Definition at line 186 of file area.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tri_area_()

static double tri_area_ ( struct sin_cos_angle  angle_a,
struct sin_cos_angle  angle_b,
struct sin_cos_angle  angle_c 
)
static

area of a spherical triangle based on L'Huilier's Theorem

source code is taken from code by Robert Oehmke of Earth System Modeling Framework (www.earthsystemmodeling.org)

it has been extended by a more accurate computation of vector angles

the license statement for this routine is as follows: Earth System Modeling Framework Copyright 2002-2013, University Corporation for Atmospheric Research, Massachusetts Institute of Technology, Geophysical Fluid Dynamics Laboratory, University of Michigan, National Centers for Environmental Prediction, Los Alamos National Laboratory, Argonne National Laboratory, NASA Goddard Space Flight Center. Licensed under the University of Illinois-NCSA License.

Remarks
all edges are on great circle

Definition at line 134 of file area.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tri_area_info()

static double tri_area_info ( double  ref[3],
double  a[3],
double  b[3],
double *  barycenter,
double  sign 
)
static

Definition at line 451 of file area.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tri_area_quarter_angle()

static struct sin_cos_angle tri_area_quarter_angle ( struct sin_cos_angle  angle)
inlinestatic

Definition at line 105 of file area.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XYZtoLon()

static double XYZtoLon ( double  a[3])
inlinestatic

Definition at line 213 of file area.c.

Here is the caller graph for this function:

◆ yac_huiliers_area()

double yac_huiliers_area ( struct yac_grid_cell  cell)

Area calculation on a unit sphere taken from ESMF based on L'Huilier's Theorem.

(http://mathworld.wolfram.com/LHuiliersTheorem.html)
(http://mathforum.org/library/drmath/view/65316.html)
(http://math.stackexchange.com/questions/9819/area-of-a-spherical-triangle)

The cell in split up into triangles that all have one corner in common, then the area for each of the triangle is computed and summed up to build the area of the cell. L'Huilier's Theorem is used to compute the area of the triangles. This seems to be sufficiently accurate for elements on the Earth surface with edge lengths of approx. 100 m and gives results comparable to our implementation of Huilier's algorithm for edge lengths of up to 1 km.

Examples
test_area.c, test_basic_grid_data.c, test_clipping.c, test_compute_overlap_area.c, test_lat_clipping.c, and test_partial_areas.c.

Definition at line 396 of file area.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_huiliers_area_info()

double yac_huiliers_area_info ( struct yac_grid_cell  cell,
double *  barycenter,
double  sign 
)
Examples
test_compute_overlap_area.c, and test_partial_areas.c.

Definition at line 482 of file area.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_planar_3dcell_area()

double yac_planar_3dcell_area ( struct yac_grid_cell  cell)

Area calculation on a unit sphere of a planar polygon in 3D.

(http://gaim.umbc.edu/2010/06/03/polygon-area)
This area calculation works for any planar polygon (concave or convex) with non-intersecting edges in 3D. It requires vertex coordinates in Carthesian space. In our case this is applicable for very small elements on the sphere.

Examples
test_area.c.

Definition at line 364 of file area.c.

◆ yac_pole_area()

double yac_pole_area ( struct yac_grid_cell  cell)

Calculate the area of a cell in a 3d plane on a unit sphere.

see http://geomalgorithms.com/a01-_area.html

other references:

http://www.mathopenref.com/coordpolygonarea2.html
http://geomalgorithms.com/a01-_area.html
http://stackoverflow.com/questions/2350604/get-the-area-of-a-3d-surface

Parameters
[in]cellcell for which the area shall be calculated
Returns
area of the cell
Examples
test_area.c.

Definition at line 279 of file area.c.

Here is the call graph for this function:

◆ yac_triangle_area()

double yac_triangle_area ( struct yac_grid_cell  cell)

Calculate the area of a triangle on a unit sphere.

Adopted from the ICON code, mo_base_geometry.f90 provided by Luis Kornblueh, MPI-M.

The algorithm is based on Girards' theorem and formula.

Converted to c by Rene Redler, MPI-M.

Vertex coordinates need to be provided as cartesian coordinates

The algorithm is based on Girards' theorem and formula.

R: Earth radius n: number of vertices pi: guess what Theta: Sum of inner angle of the element (in rad)

The Formula reads as

S = [ Theta - (n-2) * pi ] * R*R

Ad with n=3 for triangles simplifies to

S = [ Theta - pi ] * R*R

Parameters
[in]cellcell for which he area shal be calculated
Returns
approximate area of the cell
Examples
test_area.c.

Definition at line 21 of file area.c.

Here is the call graph for this function: