Hello,
Actually, CDTVAR is defined in a global Fortran array which is not directly accessible from the C part of the code, so there is no easy way to do this now (except hard-coding the same value in cs_coupling.c than the one you set in the GUI for the scalar).
With the new C "fields" API, mapping some Fortran keywords to C is becoming easier, so CDTVAR could be made more accessible, but still requires 2 steps:
in src/base/fldini.f90, in the loop on user variables starting line 283, after the call to fldsks, you may add a test:
Code: Select all
if if (ii .eq. iscalt) then
name = 'cdtvar'
call fldkid(name, key_cdtvar)
call fldskd(ivarfl(ivar), key_cdtvar, cdtvar(ivar))
endif
(not forgetting to define a local integer variable key_cdtvar in the subroutine)
In src/base_cs_field.c, you may then add, at the end (in cs_field_define_keys_base),
Code: Select all
cs_field_define_key_double("cdtvar", 1, CS_FIELD_VARIABLE);
In src/base_cs_coupling.c, you may then add :
near the top (where other such includes may be found), then:
Code: Select all
double cdtvar_t = cs_field_get_key_double(cs_field_by_name("temperature"), cs_field_key_id("cdtvar"));
ple_coupling_mpi_set_synchronize(*ts * cdtvar);
where you had the previous call to ple_coupling_mpi_set_synchronize (which must be called only once per time step).
Note this is suggested (not tested) code.
Best regards,
Yvan