precice / calculix-adapter

preCICE-adapter for the CSM code CalculiX
GNU General Public License v3.0
52 stars 20 forks source link

Tutorial heat_exchanger CalculiX 2.15 error "There is no Data with ID 66231168" #27

Closed eurocfd closed 3 years ago

eurocfd commented 4 years ago

Hello Team,

I'm working on Centos 7 with shared OpenMPI 4.0.2 library. Using devtoolset-8

Installed from sources : yaml-cpp 0.6.2, petcs 3.12.3, boost 1.69, spooles 2.2, arpack 9.6, preCICE 1.6.1, CalculiX 2.15 & OpenFoam 6. and eigen3-devel-3.3.4-7.el7.noarch from repo

Now, major parts of tutorials FSI are running but not for heat_echanger.

When launching in serial, an error appears in Solid.log :

Initializing coupling data
Adapter writing coupling data...
---[precice] ERROR:  There is no Data with ID 66231168

When launching in parallel, another error appears in Solid.log : 
Initializing coupling data
Adapter writing coupling data...
ASSERTION FAILED
  Location:          void precice::impl::SolverInterfaceImpl::writeBlockScalarData(int, int, const int*, const double*)
  File:              /cm/shared/software/precice/precice-1.6.1/src/precice-1.6.1/src/precice/impl/SolverInterfaceImpl.cpp:1066
  Rank:              0
  Failed expression: valueIndices != nullptr
 0# getStacktrace() in /cm/shared/software/precice/precice-1.6.1/lib/libprecice.so.1.6.1
 1# precice::impl::SolverInterfaceImpl::writeBlockScalarData(int, int, int const*, double const*) in /cm/shared/software/precice/precice-1.6.1/lib/libprecice.so.1.6.1
 2# precicec_writeBlockScalarData in /cm/shared/software/precice/precice-1.6.1/lib/libprecice.so.1.6.1
 3# 0x00000000005C71DD in ccx_preCICE
 4# 0x00000000005C7EE6 in ccx_preCICE
 5# 0x00000000005B40C2 in ccx_preCICE
 6# 0x0000000000412EDA in ccx_preCICE
 7# __libc_start_main in /lib64/libc.so.6
 8# 0x000000000041AEE5 in ccx_preCICE

Thanks for answer. Karim

Inner-Fluid.log Inner-Fluid_decomposePar.log Outer-Fluid.log Outer-Fluid_decomposePar.log Solid.log env.log Inner-Fluid-serial.log Outer-Fluid-serial.log Solid-serial.log

precice-config.txt precice-config_parallel.txt precice-config_serial.txt config.txt

MakisH commented 4 years ago

Thank you for reporting this, @eurocfd! Important to reproduce the issue: we need to build preCICE in Debug mode, as otherwise the assertions are removed from the code.

KyleDavisSA commented 4 years ago

I am unable to reproduce this issue, even in Debug mode. But it seems the CalculiX adapter is sending the wrong data ID to preCICE, even though it is finding all of the write data names in the config file. When I run the example and print out the data ID for all write data names, I get

Write data 'Sink-Temperature-Solid' found 0.
Write data 'Heat-Transfer-Coefficient-Solid' found 1.
Write data 'Sink-Temperature-Solid' found 4.
Write data 'Heat-Transfer-Coefficient-Solid' found 5.

In the PreciceInterface.c, could you change

https://github.com/precice/calculix-adapter/blob/9bb953d8918e60e30dd662e0ad62b93b091aa2e5/adapter/PreciceInterface.c#L547-L557

to add the data ID as well? Just replace the above code with this

else if ( strcmp1( config->writeDataNames[i], "Sink-Temperature-" ) == 0 )
{
        interface->writeData[i] = CONVECTION;
        interface->kDeltaTemperatureWriteDataID = precicec_getDataID( config->writeDataNames[i], interface->faceCentersMeshID );
        printf( "Write data '%s' found %d.\n", config->writeDataNames[i],interface->kDeltaTemperatureWriteDataID );
}
else if ( strcmp1( config->writeDataNames[i], "Heat-Transfer-Coefficient-" ) == 0 )
{
        interface->writeData[i] = CONVECTION;
        interface->kDeltaWriteDataID = precicec_getDataID( config->writeDataNames[i], interface->faceCentersMeshID );
        printf( "Write data '%s' found %d.\n", config->writeDataNames[i],interface->kDeltaWriteDataID );
}

This will output the data ID as well and can help to see where it is going wrong.

uekerman commented 4 years ago

I suspect that it has sth to do with the fact that we use Robin BC in the CCX adapter [Sink-Temperature-Solid, Heat-Transfer-Coefficient-Solid] etc . It is the only case where we do this, right?

Why are these 2 cases treated differently? https://github.com/precice/calculix-adapter/blob/505e90aa736c410da41bfd3578daa0bef7989f64/adapter/PreciceInterface.c#L516-L528

Does this mean that they need to come in a certain order and the other one is wrong?

What does CONVECTION do?

eurocfd commented 4 years ago

@KyleDavisSA

Hi Kyle,

Thx for your message.

We followed our recommandations and modified the file PreciceInterface.c

But when running case --> we dont see any output of ID number.

While an error remain in the Solid.log, note that the ID number has changed : ---[precice] ERROR:  There is no Data with ID 74804032

Solid.log

KyleDavisSA commented 4 years ago

@eurocfd

There is a line in your Solid.log file, line 36

Write data 'Heat-Transfer-Coefficient-Solid' found.

There should be a number after the word "found", or at the least a space. Can you try deleting the bin folder in CalculiX and rebuild? Just to confirm the changes:

https://github.com/precice/calculix-adapter/blob/9bb953d8918e60e30dd662e0ad62b93b091aa2e5/adapter/PreciceInterface.c#L551 Should be replaced by

printf( "Write data '%s' found %d.\n", config->writeDataNames[i],interface->kDeltaTemperatureWriteDataID );

And line: https://github.com/precice/calculix-adapter/blob/9bb953d8918e60e30dd662e0ad62b93b091aa2e5/adapter/PreciceInterface.c#L556 Should be replaced by

printf( "Write data '%s' found %d.\n", config->writeDataNames[i],interface->kDeltaWriteDataID );
eurocfd commented 4 years ago

@KyleDavisSA

Thanks Kyle for answer.

I confirm that we did the modifications in PreciceInterface.c (see attached file). PreciceInterface.txt

I removed the bin directory in the Calculix adapter and do a "make" in order to recreate it.

We now see the ID numbers in the Solid.log. Solid.log

KyleDavisSA commented 4 years ago

Hi,

this is strange as the write data ID's are now found but the read data ID's are the problem. I have modified the PreciceInterface.c file to output the ID's of the read data as well. Could you rebuild the calculix adapter with the attached modified file and look at the read data ID values? You should see something like:

Read data 'Sink-Temperature-Inner-Fluid' found 2.
Read data 'Heat-Transfer-Coefficient-Inner-Fluid' found 3.
...
Read data 'Sink-Temperature-Outer-Fluid' found 6.
Read data 'Heat-Transfer-Coefficient-Outer-Fluid' found 7.
...
...
...
Adapter reading coupling data...
kDeltaTemperatureReadDataID = 2 and kDeltaReadDataID = 3 
kDeltaTemperatureReadDataID = 6 and kDeltaReadDataID = 7 

PreciceInterface.txt

eurocfd commented 4 years ago

Thx @KyleDavisSA

I took directly your file PreciceInterface.c and compiled calculiX-adapter with it.

I ran again the case and obtained this in Solid.log :

...
Read data 'Sink-Temperature-Inner-Fluid' found 2.
Read data 'Heat-Transfer-Coefficient-Inner-Fluid' found 3.
Write data 'Sink-Temperature-Solid' found 0.
Write data 'Heat-Transfer-Coefficient-Solid' found 1.
...
Read data 'Sink-Temperature-Outer-Fluid' found 6.
Read data 'Heat-Transfer-Coefficient-Outer-Fluid' found 7.
Write data 'Sink-Temperature-Solid' found 4.
Write data 'Heat-Transfer-Coefficient-Solid' found 5.
...

Adapter reading coupling data...
kDeltaTemperatureReadDataID = 2 and kDeltaReadDataID = 3 
---[precice] ERROR:  There is no Data with ID 57891648

it's seem the problem is on "kDeltaTemperatureReadDataID = 6 and kDeltaReadDataID = 7 " which is missing for me.

Solid.log

MakisH commented 4 years ago

I tried again and it now works for me, both in serial and in parallel. It was not working for me with preCICE v1.6.1.

I am using preCICE v2.0.0 (Debug build), the tutorials from the latest master (32e10), and the latest CalculiX adapter (505e90aa).

@eurocfd does it work for you if you update to the latest preCICE? I also believe it is a problem in the adapter, but let's try this first.

eurocfd commented 4 years ago

@MakisH I just tried to use Calculix Adapter (505e90a) but make fail with preCICE v1.6.1. I will try with preCICE 2.0.0 and keep you in touch.

MakisH commented 4 years ago

Yes, now the latest state of all the adapters is for preCICE v2, which changed a few things in the API.

eurocfd commented 4 years ago

@MakisH

Hello Gerasimos,

Installed preCICE 2.0.0 and CalculiX 2.15 & OpenFoam 6 adapters. Working tests with FSI tuto but one more again failed with heat_exchanger... Error in the Solid.log : Adapter reading coupling data... ---[precice] ERROR:  There is no Data with ID 61915888

Could it be related to the solver that begin the initialisation of the coupling in the precice-config.xml ?

MakisH commented 4 years ago

Thank you, @eurocfd.

Could it be related to the solver that begin the initialisation of the coupling in the precice-config.xml ?

I don't think so. It must really be a simple bug somewhere.

(by the way: the strange characters you get before and after "ERROR" are ANSI escape codes / color characters. You can display them properly e.g. in less with the -R flag. You can also disable color all together by editing the format of your logger)

fsimonis commented 4 years ago

@KyleDavisSA and I were able to reproduce the bug with the changes in #29 and #31 This, the problem is likely somewhere in configuration parsing.

Stay tuned

fsimonis commented 4 years ago

I found and fixed the issue in #31.

We illegally handled the allocated memory in the C++ parser implementation without constructing the actual objects. The SSI and heat-exchanger tutorials run fine now.

precice-bot commented 4 years ago

This issue has been mentioned on preCICE Forum on Discourse. There might be relevant details there:

https://precice.discourse.group/t/openfoam-calculix-heat-exchanger-cht-tutorial-does-not-run/312/4

prasadadhav commented 4 years ago

System Kubuntu 18.04LTS preCICE v2.1 OpenFOAM v7 CalculiX v2.15 CalculiX adapter (master branch, which I built in April 2020, there have been quite a lot of changes since then)

CalculiX adapter dependencies: yaml-cpp 0.6.2 SPOOLES 2.2 ARPACK 9.6


For the FSI part of the tutorials, I have no issues, everything runs fine.

But when I tried running the heat exchanger tutorial, I get the following error:

ASSERTION FAILED
  Location:          void precice::impl::SolverInterfaceImpl::writeBlockScalarData(int, int, const int*, const double*)
  File:              /home/prasad/Downloads/precice/src/precice/impl/SolverInterfaceImpl.cpp:1116
  Rank:              0
  Failed expression: valueIndices != nullptr
 0# getStacktrace[abi:cxx11]() in /usr/local/lib/libprecice.so.2
 1# precice::impl::SolverInterfaceImpl::writeBlockScalarData(int, int, int const*, double const*) in /usr/local/lib/libprecice.so.2
 2# precice::SolverInterface::writeBlockScalarData(int, int, int const*, double const*) in /usr/local/lib/libprecice.so.2
 3# precicec_writeBlockScalarData in /usr/local/lib/libprecice.so.2
 4# 0x0000555B7CAEA7C5 in ccx_preCICE
 5# 0x0000555B7CAEBB5E in ccx_preCICE
 6# 0x0000555B7CAD54C4 in ccx_preCICE
 7# 0x0000555B7C929D0F in ccx_preCICE
 8# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
 9# 0x0000555B7C93207A in ccx_preCICE

Solid.log Inner-Fluid.log Outer-Fluid.log

I get the same error when I tried running this in parallel(since I read some comments where there were different outcomes).

After this, I modified the perp flap FSI tutorial (OF+CCX). I am able to run the individual simulations but when I try running the coupled simulation I get this error.


Since I am currently working on the FSI part, I am not entirely positive about uninstalling the current CalculiX adapter. (don't fix it if it ain't broke ;P )

But as I did for the OpenFOAM adapter, I am thinking of installing the new version of CCX adapter with a different name.(And keep both versions available).

fsimonis commented 4 years ago

Thank you for the additional report. This looks like we are having some control flow problems in the ccx adapter.

One of the given arrays is nullptr, which should really be caught by the input sanitisation. This in turn should result in an ERROR and not trigger an assertion.

IshaanDesai commented 3 years ago

In the latest tutorials release and the latest CalculiX-Adapter release this issue is no longer observed. This issue can be reopened if it is observed in individual cases.