Error in gradient of a property

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Error in gradient of a property

Post by Mohammad »

Hello,

I've defined a property with the name "P1".
I want to call the gradient function for this property with these commands:

Code: Select all

call field_get_id("P1",P1_fid)
call field_gradient_scalar(P1_fid, iprev, imrgra, inc, iccocg, grads)
But the simulation stops with this error:
cs_field.c:3420: Fatal error.
Field "P1" with type flag 72
has no value associated with key 44 ("var_cal_opt").
What's the problem?

Regards,
Mohammad
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Error in gradient of a property

Post by Yvan Fournier »

Hello,

There are missing tests for fields which are only properties and not variables. I'll fix this in upcoming versions.

Dow you have this with v6.0 or v6.1/v6.2 ?

Regards,

Yvan
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: Error in gradient of a property

Post by Mohammad »

Hello,

Thanks for your reply.

I'm using ver 6.0.4.

Is there any temporary solution for this problem? Because It is crucial for me as defining a variable field instead of a property field slows down the code while using a variable field is not necessary.

Regards,
Mohammad
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Error in gradient of a property

Post by Yvan Fournier »

Hello,

I also just pushed of fix in branch 6.0, so if you update from the v6.0 branch on GitHub, you should have a fix. Otherwise, you can try copying the https://github.com/code-saturne/code_sa ... operator.c file directly you a case's SRC directory, to "patch" the code (but be careful: this is a quick solution for testing, but could conflict with future fixes in the same file, so you need to remember it is a temporary solution).

Regards,

Yvan

PS. I just synced the GitHub repo around 5 PM GMT.
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: Error in gradient of a property

Post by Mohammad »

Hello,

Thanks Yvan.
The field id error is gone now, but now I get this error for gradient calculation:
SIGSEGV signal (forbidden memory area access) intercepted!

Call stack:
1: 0x557474f2e40d <cs_field_gradient_scalar+0x11d> (cs_solver)
2: 0x557474f338ac <viswal_+0x1cdf> (cs_solver)
3: 0x7ff54b80eb0b <phyvar_+0x13d5> (libsaturne-6.0.so)
4: 0x7ff54b833123 <tridim_+0xaee> (libsaturne-6.0.so)
5: 0x7ff54b6c0112 <caltri_+0x27c9> (libsaturne-6.0.so)
6: 0x7ff54cdf16ef <cs_run+0x5ef> (libcs_solver-6.0.so)
7: 0x7ff54cdf0fb8 <main+0x178> (libcs_solver-6.0.so)
8: 0x7ff54a5aab97 <__libc_start_main+0xe7> (libc.so.6)
9: 0x557474f2d5fa <_start+0x2a> (cs_solver)
End of stack
Let me provide more details. As I mentioned before, I've defined a property in cs_user_parameters.c file:

Code: Select all

  cs_parameters_add_property("P1",
                           1,
                           CS_MESH_LOCATION_CELLS);
Then I called the gradient of scalar for this property in viswal.f90 file (I changed some codes of this file) as below:

Code: Select all

integer P1_fid
double precision, allocatable, dimension(:,:) :: grads
iprev = 0
inc = 1
iccocg = 1
allocate(grads(3,ncelet))
call field_get_id("P1",P1_fid)
call field_gradient_scalar(P1_fid, iprev, imrgra, inc, iccocg, grads)
Now by running the code those error occur. But if I define the property as a variable like below, it works without any problems:

Code: Select all

cs_parameters_add_variable("P1", 1);
But it slows down the code.

Regards,
Mohammad
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Error in gradient of a property

Post by Yvan Fournier »

Hello,

Sorry, the fix was incomplete (I had tested it for non-regressions, but non wth a property field).

It should be really fixed now, if you take today's version (in either of the master, v6.2, v6.1, or V6.0 branches).

Best regards,

Yvan
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: Error in gradient of a property

Post by Mohammad »

Hello,

Thank you very much dear Yvan, I appreciate your excellent and quick support.
The problem solved.

Kind Regards,
Mohammad
Post Reply