Hello,
This question relates to the usage of preCICE C++ API in an adapter (the in-house implemented for XDEM). Please be patient with the thorough post, as this is not an official adapter I am giving as much info as possible.
Scenario:
I am doing some calculations on the XDEM side, which need to know the coupling time step value.
As these things are to be integrated over the coupling time step.
Hence, I am trying to access time-window-size
in XDEM adapter.
My plan was to pass the precise coupling time step i.e time-window-size
to the Coupling object I have.
Then proceed with Calculations and exchange of data.
General adapter outline
This is similar to the guidelines posted in the step-by-step guide.
// MAIN >>>
// Initialize XDEM
// initialize preCICE
const std::string solverName("XDEM");
precice::SolverInterface precice(solverName, configFileName, commRank, commSize);
const int precice_dimension = precice.getDimensions();
*** Modifications - new place I initialize preCICE***
// Get preCICE dt
double precice_dt = precice.initialize();
std::cout << "Debug: precice_coupling_dt: = " << precice_dt << std::endl;
// Save list of coupled objects = precice.initialize();
// Get XDEM Meshes (for coupling with CFD or FEM)
// Here we create & initialize the coupled object i.e coupled mesh, by passing various variables needed by the object
*** here I want to pass the preCICE coupling dt ***
// initialize preCICE
//double precice_dt = precice.initialize(); //ususal place to initialize preCICE
//time loop
while (!xdem.is_over())
{
// read and apply data
// run XDEM
// compute and write data
// Advance preCICE time
precice_dt = precice.advance( precice_dt );
}
// Finalize preCICE
precice.finalize();
// Finalize XDEM
xdem.finalize();
Issue.
If I want to pass preCICE coupling time step (time-window-size
) to my coupled object, I have to do precice.initialize();
before I do the // Get XDEM Meshes
step.
I then run the adapter, get the expected output,
preCICE: This is preCICE version 2.3.0
preCICE: Revision info: v2.3.0
preCICE: Configuration: Debug
preCICE: Configuring preCICE with configuration "./precice-config.xml"
preCICE: I am participant "XDEM"
preCICE: Setting up master communication to coupling partner/s
preCICE: Masters are connected
preCICE: Setting up preliminary slaves communication to coupling partner/s
preCICE: Prepare partition for mesh Domain
preCICE: Receive global mesh Fluid-Mesh-PV
preCICE: Setting up slaves communication to coupling partner/s
preCICE: Slaves are connected
preCICE: iteration: 1, time-window: 1, time: 0 of 500, time-window-size: 0.2, max-timestep-length: 0.2, ongoing: yes, time-window-complete: no,
Debug: precice_coupling_dt: = 0.2
Deformable Objects in XDEM:
Fluid Volumes in XDEM:
- Domain: Used in preCICE!
Inherited Momentum
Inherited HT
Inherited MT
[XDEM-Adapter] Created all the possible fields list
[XDEM-Adapter] Reading all the available fields for coupling
the error
preCICE:ERROR: This participant attempted to modify the Mesh "Domain" while locked. Mesh modification is only allowed before calling initialize().
The weird thing is, this works if I run in debug mode in QT.
Does not work when I run normally in the terminal.
I think this is just a C++ thing that I am probably messing up.
But maybe there is an alternate solution to using precice.initialize()
for getting time-window-size
.