Page 1 of 1

field_gradient_scalar error

Posted: Fri Mar 23, 2018 12:08 pm
by daniele
Hello,

I would like to add a source term (to a user defined scalar) being the gradient of a given quantity.
In the cs_user_source_terms.f90, I wrote:

Code: Select all

  allocate(grad(3,ncelet))
  allocate(wtest(ncel))
  allocate(term(ncel))
  
  do iel = 1, ncel
      wtest(iel) = 0.1d0
    term(iel) = cpro_crom(iel)*wtest(iel)
    enddo
    
  call field_get_val_s_by_name('term_grad', grad_term)
 
    do iel = 1, ncel
      grad_term(iel) = term(iel)
    enddo
    
  call field_get_id('term_grad',f_id)
  
  inc = 1
  iccocg = 1
  call field_gradient_scalar(f_id, 0, imrgra, inc, iccocg, grad)
  
  do iel = 1, ncel
      crvexp(iel)=grad(1,iel)
    enddo

 deallocate...
Where "term_grad" is an additional field I created.

The compilation gives me the following error:
cs_user_source_terms.f90:(.text+0x3a7): undefined reference to `field_gradient_scalar_'
collect2: error: ld returned 1 exit status


Do you have any idea of the problem?

Many thanks in advance.

Best regards,

Daniele

Re: field_gradient_scalar error

Posted: Fri Mar 23, 2018 1:56 pm
by Yvan Fournier
Hello,

Yes, you need to add "use field_operator" in the section of the subroutine where modules used are declared.

Regards,

Yvan

Re: field_gradient_scalar error

Posted: Mon Mar 26, 2018 11:28 am
by daniele
Dear Yvan,

Thank you very much!
Nevertheless, I still have a problem in my set-up, since I get the following error in the listing:

Field "term_grad" with type flag 17
has no value associated with key 37 ("var_cal_opt").


The "use optcal" is present at the begin of the subroutine.

Any idea?
Thank you in advance for your help.

Best regards,

Daniele

Re: field_gradient_scalar error

Posted: Mon Mar 26, 2018 2:34 pm
by Yvan Fournier
Hello,

Yes, the operator is not functional yet for non-solved variables (because you need to define boundary conditions). So the solution right now is to use the lower-level gradient functions (not field_gradient, but gradient_s).

Regards,

Yvan

Re: field_gradient_scalar error

Posted: Wed Mar 28, 2018 10:19 am
by daniele
Thank you Yvan!

I see that the gradient_s routine requires a lot of arguments, and I am not sure to understand them completely...
We can maybe discuss more in detail at the User Meeting...

Best regards,

Daniele