Page 1 of 1

Usage of user_physical_properties.c

Posted: Wed Aug 29, 2018 7:18 am
by senartcon
Dear users,

I have entered my formulation for spatially varying density inside:

Code: Select all

void
cs_user_physical_properties(const cs_mesh_t             *mesh,
                            const cs_mesh_quantities_t  *mesh_quantities)
{

}
Now how to return the output (density) to the corresponding property variable, as we do in the Fortran subroutine using propce(iel, ipcrom)? Could not find any example.
Thanks.

Re: Usage of user_physical_properties.c

Posted: Wed Aug 29, 2018 7:08 pm
by Yvan Fournier
Hello,

Yes, we are still missing examples here, but examples for postprocessing may be helpful in showing how to access field values and properties.

In the case of pressure:
cs_real_t cvar_rho = CS_F_(rho)->val;
(adding "cs_field_pointer.h" to the includes section if missing)

or
cs_real_t cvar_rho = cs_field_b_name("density")->val;
Should provide access to the cell values array for density. The other examples (postprocessing/extra operations) may help you see how to access other variables you may need to determine density values.

Regards,

Yvan

Re: Usage of user_physical_properties.c

Posted: Thu Aug 30, 2018 7:06 am
by senartcon
Hello Yvan,

thanks for your reply. In fact I found that all variable references can be found here:
https://www.code-saturne.org/cms/sites/ ... field.html

However, the variable density is not effected in the simulation., although this subroutine is compiled. I am using CS ver. 5.0.
My code is:

Code: Select all

void
cs_user_physical_properties(const cs_mesh_t             *mesh,
                            const cs_mesh_quantities_t  *mesh_quantities)
{
	cs_real_t *cvar_rho = CS_F_(rho)->val;
	
	for(cs_int_t cell_id=0; cell_id < mesh->n_cells; cell_id++)
	{
		x = mesh_quantities->cell_cen[3*cell_id];
		y = mesh_quantities->cell_cen[3*cell_id+1];
		...
		cvar_rho[cell_id] = f(x, y ...);
	}
	return;
}

Re: Usage of user_physical_properties.c

Posted: Thu Aug 30, 2018 8:01 pm
by Yvan Fournier
Hello,

I don't remember the keyword to activate variable density (maybe irovar), but in the GUI, you can define the density as being variable (so that the field is defined), with a simple (constant) mathematical expression, the use your user function to set the actual values.

Regards,

Yvan