/*============================================================================ * This function is called each time step to define physical properties *============================================================================*/ /* code_saturne version 6.2-alpha */ /* This file is part of Code_Saturne, a general-purpose CFD tool. Copyright (C) 1998-2020 EDF S.A. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /*----------------------------------------------------------------------------*/ #include "cs_defs.h" /*---------------------------------------------------------------------------- * Standard C library headers *----------------------------------------------------------------------------*/ #include #include #include #if defined(HAVE_MPI) #include #endif /*---------------------------------------------------------------------------- * Local headers *----------------------------------------------------------------------------*/ #include "cs_headers.h" /*----------------------------------------------------------------------------*/ BEGIN_C_DECLS /*----------------------------------------------------------------------------*/ /*! * \file cs_user_physical_properties.c * * \brief User definition of physical properties. */ /*----------------------------------------------------------------------------*/ /*============================================================================ * User function definitions *============================================================================*/ /*----------------------------------------------------------------------------*/ /*! * \brief Function called at each time step to define physical properties. * * \param[in, out] domain pointer to a cs_domain_t structure */ /*----------------------------------------------------------------------------*/ void cs_user_physical_properties(cs_domain_t *domain) { CS_UNUSED(domain); /* Check fields exists */ const cs_mesh_t *mesh = cs_glob_mesh; const cs_mesh_t *m = domain->mesh; const cs_mesh_quantities_t *mq = cs_glob_mesh_quantities; const cs_real_3_t *cell_cen = (const cs_real_3_t *)mq->cell_cen; cs_fluid_properties_t *phys_pro = cs_get_glob_fluid_properties(); cs_physical_constants_t *pc = cs_get_glob_physical_constants(); /* Pressure */ cs_real_t *cvar_pr = CS_F_(p)->val; /* Temperature */ cs_real_t *cvar_t = cs_field_by_name_try("temperature")->val; /* Density */ cs_real_t *cvar_rho = CS_F_(rho) -> val; /* Equation of state for air */ for (cs_lnum_t cell_id = 0; cell_id < m->n_cells; cell_id++){ cs_real_t xx = cell_cen[cell_id][0]; cs_real_t yy = cell_cen[cell_id][1]; cs_real_t zz = cell_cen[cell_id][2]; cvar_rho[cell_id] = (phys_pro->p0 + cvar_pr[cell_id]) /(cvar_t[cell_id]*phys_pro->r_pg_cnst); } } /*----------------------------------------------------------------------------*/ END_C_DECLS