FSI: OpenFOAM adapter with interFOAM

I tried a simple FSI example very similar to the dam-break, but with a flexible obstacle. I’m using preCICE 2.0.

image

Unfortunatelly an error message occur, but the log file didn’t exist.

I used the same structure of the flap behind the cylinder and the setting sems ok.

Below the error:

--> FOAM FATAL ERROR: 
Error in the preCICE adapter:
There was a problem while configuring the adapter. See the log for details.

    From function void adapterInfo(std::__cxx11::string, std::__cxx11::string)
    in file Utilities.C at line 32.

FOAM exiting

Do I have to modify something? The file pressure in a interFOAM analysis is wrote in a file called p_rgh, is it reachable by preCICE in order to exchange load with CalculiX?

Hi @bitronteofil

which OpenFOAM version and which adapter version do you currently use?
How do you start your simulation? Do you use one of the shell scripts?
Can you generate a log file, so that we can see better, where things go wrong?

A compressible calculation should be no problem for the adapter.

I’m using OF 1906 and CalculiX v 2.15.

The precice library is: libprecice.so.2.0.0
and I call for it in controlDict with the command:

functions
{
    preCICE_Adapter
    {
        type preciceAdapterFunctionObject;
        libs ("libpreciceAdapterFunctionObject.so");
    }
}

It is very strange, because in order to avoid mistake I used the same structure of the flap behind the cylinder, but the OF participant doesn’t start at all.

The error message is:

---[preciceAdapter] [DEBUG] Adding coupling data writers...
---[preciceAdapter] [DEBUG] Adding coupling data readers...
--> FOAM Warning : 
    From function void adapterInfo(std::__cxx11::string, std::__cxx11::string)
    in file Utilities.C at line 50
    Error (deferred - will exit later) in the preCICE adapter: 

    request for pointVectorField pointDisplacement from objectRegistry region0 failed
    available objects of type pointVectorField are
0()

Courant Number mean: 0 max: 0
Interface Courant Number mean: 0 max: 0
Time = 0.0005

PIMPLE: iteration 1
smoothSolver:  Solving for alpha.water, Initial residual = 0, Final residual = 0, No Iterations 0
Phase-1 volume fraction = 0.169587  Min(alpha.water) = 0  Max(alpha.water) = 1
MULES: Correcting alpha.water
MULES: Correcting alpha.water
Phase-1 volume fraction = 0.169587  Min(alpha.water) = 0  Max(alpha.water) = 1
DICPCG:  Solving for p_rgh, Initial residual = 1, Final residual = 0.0491804, No Iterations 7
time step continuity errors : sum local = 0.00014383, global = -9.10245e-09, cumulative = -9.10245e-09
DICPCG:  Solving for p_rgh, Initial residual = 0.0033825, Final residual = 0.000137417, No Iterations 22
time step continuity errors : sum local = 6.15787e-06, global = -1.58356e-06, cumulative = -1.59266e-06
DICPCG:  Solving for p_rgh, Initial residual = 0.0001798, Final residual = 9.41171e-08, No Iterations 88
time step continuity errors : sum local = 7.8403e-09, global = 1.80596e-10, cumulative = -1.59248e-06
smoothSolver:  Solving for epsilon, Initial residual = 0.0174728, Final residual = 2.46564e-08, No Iterations 3
smoothSolver:  Solving for k, Initial residual = 1, Final residual = 2.39041e-07, No Iterations 4
ExecutionTime = 0.46 s  ClockTime = 0 s



--> FOAM FATAL ERROR: 
Error in the preCICE adapter: 
There was a problem while configuring the adapter. See the log for details.


    From function void adapterInfo(std::__cxx11::string, std::__cxx11::string)
    in file Utilities.C at line 32.

FOAM exiting
---[preciceAdapter] [DEBUG] Adding coupling data writers...
---[preciceAdapter] [DEBUG] Adding coupling data readers...
--> FOAM Warning : 
    From function void adapterInfo(std::__cxx11::string, std::__cxx11::string)
    in file Utilities.C at line 50
    Error (deferred - will exit later) in the preCICE adapter: 

    request for pointVectorField pointDisplacement from objectRegistry region0 failed
    available objects of type pointVectorField are
0()

Courant Number mean: 0 max: 0
Interface Courant Number mean: 0 max: 0
Time = 0.0005

PIMPLE: iteration 1
smoothSolver:  Solving for alpha.water, Initial residual = 0, Final residual = 0, No Iterations 0
Phase-1 volume fraction = 0.169587  Min(alpha.water) = 0  Max(alpha.water) = 1
MULES: Correcting alpha.water
MULES: Correcting alpha.water
Phase-1 volume fraction = 0.169587  Min(alpha.water) = 0  Max(alpha.water) = 1
DICPCG:  Solving for p_rgh, Initial residual = 1, Final residual = 0.0491804, No Iterations 7
time step continuity errors : sum local = 0.00014383, global = -9.10245e-09, cumulative = -9.10245e-09
DICPCG:  Solving for p_rgh, Initial residual = 0.0033825, Final residual = 0.000137417, No Iterations 22
time step continuity errors : sum local = 6.15787e-06, global = -1.58356e-06, cumulative = -1.59266e-06
DICPCG:  Solving for p_rgh, Initial residual = 0.0001798, Final residual = 9.41171e-08, No Iterations 88
time step continuity errors : sum local = 7.8403e-09, global = 1.80596e-10, cumulative = -1.59248e-06
smoothSolver:  Solving for epsilon, Initial residual = 0.0174728, Final residual = 2.46564e-08, No Iterations 3
smoothSolver:  Solving for k, Initial residual = 1, Final residual = 2.39041e-07, No Iterations 4
ExecutionTime = 0.46 s  ClockTime = 0 s



--> FOAM FATAL ERROR: 
Error in the preCICE adapter: 
There was a problem while configuring the adapter. See the log for details.


    From function void adapterInfo(std::__cxx11::string, std::__cxx11::string)
    in file Utilities.C at line 32.

FOAM exiting

Ok the issue is probably triggered through an inappropriate choice of your solver with your OpenFOAM version. I already ran into the same trap and opened up an an issue on github..
Does your solver support dynamic meshes? Or is there maybe an interDyM version of your solver?

I found some stupid errors. Now I fixed them and the couplig start well.
Now I have another trouble with something that you probably already know.
After the first iteration I experience this error message:

--> FOAM FATAL ERROR: 
updateCoeffs(const scalarField& snGradp) MUST be called before updateCoeffs() or evaluate() to set the boundary gradient.

I found some other message in which you suggest to Remove boundary evaluation for checkpointing.
Could you explain this better?

Alex

@bitronteofil we removed the respective functionality and if you get the latest state of the adapter you shouldn’t be getting this error anymore.

my adapter were compiled at the preCICE workshop and I think it is already updated.
How could I verified for this?

I think we updated afterwards.
If you simply run a git pull and recompile the adapter, this error must vanish.

EDIT: Make sure you use the develop branch. I think it is not yet in the master.

I just merged develop into master, now it is.

ok! thank you very much. I recompiled the adapter and now the simulation run fine.
But I would ask for some questions:

  1. when I rebuild the adapter the target dir is:

/home/alex/OpenFOAM/alex-/home/alex/OpenFOAM/alex-v1906/platforms/linux64GccDPInt32Opt/libv1906/platforms/linux64GccDPInt32Opt/lib

is it the right place? It would not be better to copy it in normal openFOAM lib dir like:

/opt/OpenFOAM/OpenFOAM-v1906/platforms/linux64GccDPInt32Opt/lib/

  1. Whrere is written about the adapter target dir? Could I modified the target dir?

This is defined in the Allwmake script. By default, we use FOAM_USER_LIBBIN.

is it the right place? It would not be better to copy it in normal openFOAM lib dir like:

/opt/OpenFOAM/OpenFOAM-v1906/platforms/linux64GccDPInt32Opt/lib/

The standard OpenFOAM practice is to put everything that comes with OpenFOAM in FOAM_LIBBIN and everything that is third-party (i.e. built by the user) in FOAM_USER_LIBBIN. In many cases, as in your example, FOAM_LIBBIN is not even writable by the user (i.e. without sudo).

ok, I agree with you in order to take them separated.

My simple example now run well.

Thank all very much.

image

Unfortunately, the simulation diverge after time 0.5[s].
Moreover, the max Courant number is very low except that in water collision against the wall (more or less at time 0.2[s] to 0.26[s]).

div_gnuplot_2

For this reason I would like to perform some stop and restart for the coupling simulation.
In other discourse, I read that CalculiX wrote restart file only at the end of the simulation. Moreover in my tests it write only if I put:

*RESTART,WRITE,FREQUENCY=1

If I use the same save frequency like the output results (that in my case in 200) even at the end of the simulation CalculiX doesn’t write nothing.

*NODE FILE, FREQUENCY=200
U
*EL FILE, FREQUENCY=200
S
*END STEP

Ok, now I’m trying with this strategies:

  1. start the coupling with a dt=1[ms] till t=0.18[s]. In this case the max Courant is below 0.7.
  2. restart the coupling with a dt=0.05[ms] till t=0.26[s] (ending phase of the water collision).

My question is:

how do I have to consider the max-time in the precice-config.xml?
At the beginning I thought it like a total time, but the coupling didn’t stop at 0.26[s] like I expected.
I beleive to understood that:

  1. OF consider the time like a total time
  2. while CalculiX and preCICE consider it like an additional time.

So I changed my config file in this way:

  1. OF: endTime 0.26;
  2. CalculiX: dt = 0.05e-3; tfin = 0.08
  3. preCICE: max-time value=“0.08”

Is it right?

Regarding max-time: In principle, we need that the solvers don’t stop before preCICE says so. Therefore, we usually set the endTime of each solver to be larger than the max-time defined in preCICE.

In the OpenFOAM adapter, this is overwritten automatically to be GREAT, i.e. infinity in OpenFOAM terms.

so the only that is really relevant is to syncrhonize the timestep?
There are some advice in order to restart an analysis?
The initial relaxation must be set to 1?

At the restart, every time the OF solver break at the second iteration!

I think it would be better to open a new thread just for the restarting question, as it does not seem to be specific to interFoam anymore. :slight_smile:

Then somebody more experienced with restarting could help.

finally I was able to use sub cycling and managing a little bit with tolerances and so on, the coupling proceed well :wink: :wink:.

1 Like