9.1
general documentation
cs_atmo.cpp File Reference
#include "base/cs_defs.h"
#include <assert.h>
#include <errno.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "bft/bft_error.h"
#include "bft/bft_printf.h"
#include "atmo/cs_air_props.h"
#include "base/cs_array.h"
#include "atmo/cs_atmo_profile_std.h"
#include "base/cs_base.h"
#include "base/cs_boundary_conditions.h"
#include "base/cs_boundary_conditions_set_coeffs.h"
#include "base/cs_boundary_zone.h"
#include "cdo/cs_domain.h"
#include "base/cs_field.h"
#include "base/cs_field_default.h"
#include "base/cs_field_pointer.h"
#include "base/cs_halo.h"
#include "base/cs_log.h"
#include "base/cs_math.h"
#include "base/cs_mem.h"
#include "mesh/cs_mesh.h"
#include "mesh/cs_mesh_location.h"
#include "mesh/cs_mesh_quantities.h"
#include "base/cs_measures_util.h"
#include "base/cs_parall.h"
#include "base/cs_equation_iterative_solve.h"
#include "base/cs_parameters_check.h"
#include "base/cs_physical_constants.h"
#include "pprt/cs_physical_model.h"
#include "base/cs_post.h"
#include "base/cs_prototypes.h"
#include "rayt/cs_rad_transfer.h"
#include "base/cs_thermal_model.h"
#include "turb/cs_turbulence_bc.h"
#include "turb/cs_turbulence_model.h"
#include "base/cs_volume_zone.h"
#include "alge/cs_balance.h"
#include "alge/cs_blas.h"
#include "alge/cs_convection_diffusion.h"
#include "base/cs_parameters.h"
#include "base/cs_porous_model.h"
#include "base/cs_timer.h"
#include "alge/cs_matrix_building.h"
#include "alge/cs_sles.h"
#include "alge/cs_sles_default.h"
#include "alge/cs_face_viscosity.h"
#include "alge/cs_divergence.h"
#include "base/cs_restart.h"
#include "base/cs_restart_default.h"
#include "base/cs_velocity_pressure.h"
#include "atmo/cs_intprf.h"
#include "base/cs_porosity_from_scan.h"
#include "atmo/cs_atmo.h"
#include "atmo/cs_atmo_chemistry.h"
#include "atmo/cs_atmo_imbrication.h"
#include "atmo/cs_atmo_1d_rad.h"
#include "atmo/cs_at_data_assim.h"

Functions

cs_real_t cs_mo_phim (cs_real_t z, cs_real_t dlmo)
 Universal function phim for neutral, stable and unstable. More...
 
cs_real_t cs_mo_phih (cs_real_t z, cs_real_t dlmo, cs_real_t prt)
 Universal function phih for neutral, stable and unstable. More...
 
cs_real_t cs_mo_psim (cs_real_t z, cs_real_t z0, cs_real_t dlmo)
 Universal function psim for neutral, stable and unstable. More...
 
cs_real_t cs_mo_psih (cs_real_t z, cs_real_t z0, cs_real_t dlmo, cs_real_t prt)
 Universal function psih for neutral, stable and unstable. More...
 
void cs_mo_compute_from_thermal_diff (cs_real_t z, cs_real_t z0, cs_real_t du, cs_real_t buoyant_param, cs_real_t dt, cs_real_t *dlmo, cs_real_t *ustar)
 Compute LMO, friction velocity ustar from a thermal difference using Monin Obukhov. More...
 
void cs_mo_compute_from_thermal_flux (cs_real_t z, cs_real_t z0, cs_real_t du, cs_real_t buoyant_param, cs_real_t flux, cs_real_t *dlmo, cs_real_t *ustar)
 Compute LMO, friction velocity ustar from a thermal flux using Monin Obukhov. More...
 
void cs_atmo_fields_init0 (void)
 
void cs_atmo_bcond (void)
 
void cs_atmo_init_meteo_profiles (void)
 Initialize meteo profiles if no meteo file is given. More...
 
void cs_atmo_compute_meteo_profiles (void)
 Compute meteo profiles if no meteo file is given. More...
 
void cs_atmo_z_ground_compute (void)
 Compute the ground elevation. More...
 
void cs_atmo_hydrostatic_profiles_compute (void)
 Compute hydrostatic profiles of density and pressure. More...
 
void cs_atmo_set_meteo_file_name (const char *file_name)
 This function set the file name of the meteo file. More...
 
void cs_atmo_compute_solar_angles (cs_real_t latitude, cs_real_t longitude, cs_real_t squant, cs_real_t utc, int sea_id, cs_real_t *albedo, cs_real_t *za, cs_real_t *muzero, cs_real_t *omega, cs_real_t *fo)
 1D Radiative scheme - Solar data + zenithal angle) More...
 
void cs_atmo_log_setup (void)
 Print the atmospheric module options to setup.log. More...
 
void cs_atmo_read_meteo_profile (int mode)
 Reads the meteo profile data for the atmospheric. More...
 
void cs_atmo_finalize (void)
 Deallocate arrays for atmo module. More...
 
static void _wgs84_to_l93 (cs_real_t lon_deg, cs_real_t lat_deg, cs_real_t *x, cs_real_t *y)
 Convert geographic coordinates (WGS84) to Lambert-93 (RFG93). More...
 
static void _l93_to_wgs84 (cs_real_t x, cs_real_t y, cs_real_t *lon_deg, cs_real_t *lat_deg)
 Convert Lambert-93 (RFG93) coordinates to geographic (WGS84). More...
 
static void _wgs84_to_utm (cs_real_t lon_deg, cs_real_t lat_deg, cs_real_t *x, cs_real_t *y, int fixed_utm_zone)
 Convert geographic coordinates (WGS84) to UTM coordinates. More...
 
static void _utm_to_wgs84 (cs_real_t easting, cs_real_t northing, cs_real_t *lon_deg, cs_real_t *lat_deg, int zone)
 Convert UTM coordinates to geographic coordinates (WGS84). More...
 
static void _wgs84_to_tangential (cs_real_t lon, cs_real_t lat, cs_real_t *x, cs_real_t *y)
 Convert geographic coordinates to local tangential (gnomonic-like) coords. More...
 
static void _tangential_to_wgs84 (cs_real_t x, cs_real_t y, cs_real_t *lon, cs_real_t *lat)
 Inverse of the tangential local projection (NOT IMPLEMENTED). More...
 
void cs_atmo_projection (cs_atmo_projection_t origin_projection, cs_atmo_projection_t target_projection, cs_real_t x_origin, cs_real_t y_origin, cs_real_t *x_target, cs_real_t *y_target, int utm_fixed_zone)
 Reproject coordinates between supported atmosphere projections. More...
 

Function Documentation

◆ _l93_to_wgs84()

static void _l93_to_wgs84 ( cs_real_t  x,
cs_real_t  y,
cs_real_t lon_deg,
cs_real_t lat_deg 
)
static

Convert Lambert-93 (RFG93) coordinates to geographic (WGS84).

Inverse of the Lambert-93 projection: given easting/northing in meters (Lambert-93), compute longitude and latitude in degrees on the WGS84 ellipsoid. Uses an iterative method (Newton-like fixed-point) to recover latitude from the conformal latitude term.

Parameters
[in]xEasting in meters (Lambert-93).
[in]yNorthing in meters (Lambert-93).
[out]lon_degLongitude in degrees (East positive).
[out]lat_degLatitude in degrees.

◆ _tangential_to_wgs84()

static void _tangential_to_wgs84 ( cs_real_t  x,
cs_real_t  y,
cs_real_t lon,
cs_real_t lat 
)
static

Inverse of the tangential local projection (NOT IMPLEMENTED).

This function is a placeholder and currently returns zeros. A proper inverse would recover longitude/latitude from the local tangential coordinates using the same spherical approximation as the forward projection.

Parameters
[in]xLocal tangential X (meters).
[in]yLocal tangential Y (meters).
[out]lonLongitude in degrees (WGS84) (currently set to 0).
[out]latLatitude in degrees (WGS84) (currently set to 0).

◆ _utm_to_wgs84()

static void _utm_to_wgs84 ( cs_real_t  easting,
cs_real_t  northing,
cs_real_t lon_deg,
cs_real_t lat_deg,
int  zone 
)
static

Convert UTM coordinates to geographic coordinates (WGS84).

Inverse of the UTM projection. Assumes zone 31N central meridian when the implementation is used without a zone parameter. Computes latitude and longitude in degrees from Easting (E) and Northing (N) using the standard series expansions for the footprint latitude.

Parameters
[in]EEasting in meters (UTM).
[in]NNorthing in meters (UTM).
[out]lon_degLongitude in degrees (East positive).
[out]lat_degLatitude in degrees.

◆ _wgs84_to_l93()

static void _wgs84_to_l93 ( cs_real_t  lon_deg,
cs_real_t  lat_deg,
cs_real_t x,
cs_real_t y 
)
static

Convert geographic coordinates (WGS84) to Lambert-93 (RFG93).

Converts longitude/latitude in degrees (WGS84) to Lambert-93 (Lambert Conic Conformal) easting/northing in meters using the official IGN constants and the GRS80 ellipsoid parameters. This function follows the forward projection formulas and places the results in the output pointers.

Parameters
[in]lon_degLongitude in degrees (East positive).
[in]lat_degLatitude in degrees.
[out]xEasting in meters (Lambert-93).
[out]yNorthing in meters (Lambert-93).
Note
Uses GRS80 ellipsoid parameters and the standard Lambert-93 standard parallels and false origins.

◆ _wgs84_to_tangential()

static void _wgs84_to_tangential ( cs_real_t  lon,
cs_real_t  lat,
cs_real_t x,
cs_real_t y 
)
static

Convert geographic coordinates to local tangential (gnomonic-like) coords.

Performs a simple tangential (local) projection using a spherical Earth approximation. The projection origin (reference longitude/latitude) is read from the global atmospheric options structure (cs_glob_atmo_option).

Parameters
[in]lonLongitude in degrees (WGS84).
[in]latLatitude in degrees (WGS84).
[out]xLocal tangential X (meters) relative to origin.
[out]yLocal tangential Y (meters) relative to origin.
Note
This uses a simplistic spherical approximation and is intended for small-area local projections. For accurate large-scale conversions prefer UTM or Lambert-93.

◆ _wgs84_to_utm()

static void _wgs84_to_utm ( cs_real_t  lon_deg,
cs_real_t  lat_deg,
cs_real_t x,
cs_real_t y,
int  fixed_utm_zone 
)
static

Convert geographic coordinates (WGS84) to UTM coordinates.

Parameters
[in]lon_degLongitude in degrees (East positive)
[in]lat_degLatitude in degrees
[out]xEasting (m)
[out]yNorthing (m)
[in]fixed_utm_zoneOptional fixed UTM zone (1–60). If <= 0, auto-detect.

◆ cs_atmo_bcond()

void cs_atmo_bcond ( void  )

◆ cs_atmo_compute_meteo_profiles()

void cs_atmo_compute_meteo_profiles ( void  )

Compute meteo profiles if no meteo file is given.

◆ cs_atmo_compute_solar_angles()

void cs_atmo_compute_solar_angles ( cs_real_t  latitude,
cs_real_t  longitude,
cs_real_t  squant,
cs_real_t  utc,
int  sea_id,
cs_real_t albedo,
cs_real_t za,
cs_real_t muzero,
cs_real_t omega,
cs_real_t fo 
)

1D Radiative scheme - Solar data + zenithal angle)

Compute:

  • zenithal angle
  • solar contant (with correction for earth - solar length)
  • albedo if above the sea (Use analytical formulae of Paltrige and Platt dev.in atm. science no 5)
    Parameters
    [in]latitudelatitude
    [in]longitudelongitude
    [in]squantstart day in the year
    [in]utcUniversal time (hour)
    [in]sea_idsea index
    [out]albedoalbedo
    [out]zazenithal angle
    [out]muzerocosin of zenithal angle
    [out]omegasolar azimut angle
    [out]fosolar constant

◆ cs_atmo_fields_init0()

void cs_atmo_fields_init0 ( void  )

◆ cs_atmo_finalize()

void cs_atmo_finalize ( void  )

Deallocate arrays for atmo module.

◆ cs_atmo_hydrostatic_profiles_compute()

void cs_atmo_hydrostatic_profiles_compute ( void  )

Compute hydrostatic profiles of density and pressure.

This function solves the following transport equation on $ \varia $:

\[
 \divs \left( \grad \varia \right)
     = \divs \left( \dfrac{\vect{g}}{c_p \theta} \right)
 \]

where $ \vect{g} $ is the gravity field and $ \theta $ is the potential temperature.

The boundary conditions on $ \varia $ read:

\[
  \varia = \left(\dfrac{P_{sea}}{p_s}\right)^{R/C_p} \textrm{on the ground}
 \]

and Neumann elsewhere.

◆ cs_atmo_init_meteo_profiles()

void cs_atmo_init_meteo_profiles ( void  )

Initialize meteo profiles if no meteo file is given.

◆ cs_atmo_log_setup()

void cs_atmo_log_setup ( void  )

Print the atmospheric module options to setup.log.

◆ cs_atmo_projection()

void cs_atmo_projection ( cs_atmo_projection_t  origin_projection,
cs_atmo_projection_t  target_projection,
cs_real_t  x_origin,
cs_real_t  y_origin,
cs_real_t x_target,
cs_real_t y_target,
int  utm_fixed_zone 
)

Reproject coordinates between supported atmosphere projections.

This convenience wrapper converts coordinates from an origin projection to a target projection. Supported projections include WGS84 (geographic lon/lat in degrees), Lambert-93, UTM and a local tangential projection. The function may perform an intermediate conversion to WGS84 when a direct transformation is not available.

Parameters
[in]origin_projectionInput projection enum (cs_atmo_projection_t).
[in]target_projectionDesired output projection enum (cs_atmo_projection_t).
[in]x_originX coordinate in the origin projection (lon for WGS84).
[in]y_originY coordinate in the origin projection (lat for WGS84).
[out]x_targetResulting X coordinate in the target projection.
[out]y_targetResulting Y coordinate in the target projection.
[in]utm_fixed_zoneOptional forced UTM zone number when converting to UTM.

◆ cs_atmo_read_meteo_profile()

void cs_atmo_read_meteo_profile ( int  mode)

Reads the meteo profile data for the atmospheric.

Parameters
[in]mode0: reading for dimensions and starting time only 1: reading actual meteo data

◆ cs_atmo_set_meteo_file_name()

void cs_atmo_set_meteo_file_name ( const char *  file_name)

This function set the file name of the meteo file.

Parameters
[in]file_namename of the file.

◆ cs_atmo_z_ground_compute()

void cs_atmo_z_ground_compute ( void  )

Compute the ground elevation.

This function computes the ground elevation.

This function solves the following transport equation on $ \varia $:

\[
 \dfrac{\partial \varia}{\partial t} + \divs \left( \varia \vect{g} \right)
     - \divs \left( \vect{V} \right) \varia = 0
 \]

where $ \vect{g} $ is the gravity field

The boundary conditions on $ \varia $ read:

\[
  \varia = z \textrm{ on walls}
 \]

\[
  \dfrac{\partial \varia}{\partial n} = 0 \textrm{ elsewhere}
 \]

Remarks:

  • a steady state is looked for.

◆ cs_mo_compute_from_thermal_diff()

void cs_mo_compute_from_thermal_diff ( cs_real_t  z,
cs_real_t  z0,
cs_real_t  du,
cs_real_t  buoyant_param,
cs_real_t  dt,
cs_real_t dlmo,
cs_real_t ustar 
)

Compute LMO, friction velocity ustar from a thermal difference using Monin Obukhov.

Compute LMO, friction velocity ustar, friction temperature tstar from a thermal difference using Monin Obukhov.

Parameters
[in]zaltitude
[in]z0
[in]duvelocity difference
[in]buoyant_parambeta g
[in]dtthermal difference
[out]dlmoInverse Monin Obukhov length
[out]ustarfriction velocity

◆ cs_mo_compute_from_thermal_flux()

void cs_mo_compute_from_thermal_flux ( cs_real_t  z,
cs_real_t  z0,
cs_real_t  du,
cs_real_t  buoyant_param,
cs_real_t  flux,
cs_real_t dlmo,
cs_real_t ustar 
)

Compute LMO, friction velocity ustar from a thermal flux using Monin Obukhov.

Compute LMO, friction velocity ustar, friction temperature tstar from a thermal flux using Monin Obukhov.

Parameters
[in]zaltitude
[in]z0
[in]duvelocity difference
[in]buoyant_parambeta g
[in]fluxthermal flux
[out]dlmoInverse Monin Obukhov length
[out]ustarfriction velocity

◆ cs_mo_phih()

cs_real_t cs_mo_phih ( cs_real_t  z,
cs_real_t  dlmo,
cs_real_t  prt 
)

Universal function phih for neutral, stable and unstable.

Parameters
[in]zaltitude
[in]dlmoInverse Monin Obukhov length
[in]prtTurbulent Prandtl number
Returns
factor

◆ cs_mo_phim()

cs_real_t cs_mo_phim ( cs_real_t  z,
cs_real_t  dlmo 
)

Universal function phim for neutral, stable and unstable.

Parameters
[in]zaltitude
[in]dlmoInverse Monin Obukhov length
Returns
factor

◆ cs_mo_psih()

cs_real_t cs_mo_psih ( cs_real_t  z,
cs_real_t  z0,
cs_real_t  dlmo,
cs_real_t  prt 
)

Universal function psih for neutral, stable and unstable.

Parameters
[in]zaltitude
[in]z0altitude of the starting point integration
[in]dlmoInverse Monin Obukhov length
[in]prtTurbulent Prandtl number
Returns
factor

◆ cs_mo_psim()

cs_real_t cs_mo_psim ( cs_real_t  z,
cs_real_t  z0,
cs_real_t  dlmo 
)

Universal function psim for neutral, stable and unstable.

Parameters
[in]zaltitude
[in]z0altitude of the starting point integration
[in]dlmoInverse Monin Obukhov length
Returns
factor