From 478ff7630b4b409d313c783e6220d4e93e82e496 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 21 Nov 2022 13:51:58 +0100 Subject: [PATCH 01/10] Merge `initializeData` into `initialize` --- Adapter.C | 13 ++++--------- Adapter.H | 1 - 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Adapter.C b/Adapter.C index cab5ae92..dd9ba648 100644 --- a/Adapter.C +++ b/Adapter.C @@ -532,10 +532,6 @@ void preciceAdapter::Adapter::initialize() { DEBUG(adapterInfo("Initializing the preCICE solver interface...")); SETUP_TIMER(); - timestepPrecice_ = precice_->initialize(); - ACCUMULATE_TIMER(timeInInitialize_); - - preciceInitialized_ = true; if (precice_->isActionRequired(precice::constants::actionWriteInitialData())) { @@ -544,9 +540,9 @@ void preciceAdapter::Adapter::initialize() } DEBUG(adapterInfo("Initializing preCICE data...")); - REUSE_TIMER(); - precice_->initializeData(); - ACCUMULATE_TIMER(timeInInitializeData_); + timestepPrecice_ = precice_->initialize(); + preciceInitialized_ = true; + ACCUMULATE_TIMER(timeInInitialize_); adapterInfo("preCICE was configured and initialized", "info"); @@ -1660,9 +1656,8 @@ preciceAdapter::Adapter::~Adapter() Info << " (I) writing checkpoints: " << timeInCheckpointingWrite_.str() << nl; Info << " (I) reading checkpoints: " << timeInCheckpointingRead_.str() << nl; Info << " (I) writing OpenFOAM results: " << timeInWriteResults_.str() << " (at the end of converged time windows)" << nl << nl; - Info << "Time exclusively in preCICE: " << (timeInInitialize_ + timeInInitializeData_ + timeInAdvance_ + timeInFinalize_).str() << nl; + Info << "Time exclusively in preCICE: " << (timeInInitialize_ + timeInAdvance_ + timeInFinalize_).str() << nl; Info << " (S) initialize(): " << timeInInitialize_.str() << nl; - Info << " (S) initializeData(): " << timeInInitializeData_.str() << nl; Info << " (I) advance(): " << timeInAdvance_.str() << nl; Info << " (I) finalize(): " << timeInFinalize_.str() << nl; Info << " These times include time waiting for other participants." << nl; diff --git a/Adapter.H b/Adapter.H index f94fd9c5..5dacf841 100644 --- a/Adapter.H +++ b/Adapter.H @@ -54,7 +54,6 @@ private: clockValue timeInPreciceConstruct_; clockValue timeInMeshSetup_; clockValue timeInInitialize_; - clockValue timeInInitializeData_; clockValue timeInCheckpointingSetup_; clockValue timeInWrite_; clockValue timeInAdvance_; From 70be8913c00f851eed58641f7331b1ab7ac0abdd Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 21 Nov 2022 13:55:48 +0100 Subject: [PATCH 02/10] Add changelog --- docs/changelog-entries/262.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changelog-entries/262.md diff --git a/docs/changelog-entries/262.md b/docs/changelog-entries/262.md new file mode 100644 index 00000000..7609e361 --- /dev/null +++ b/docs/changelog-entries/262.md @@ -0,0 +1 @@ +- Merged `initializeData` into `initialize` [#262](https://github.com/precice/openfoam-adapter/pull/262). From 25bc3d4daaff57a8897aff6d4954ed42e8a718ef Mon Sep 17 00:00:00 2001 From: David Schneider Date: Fri, 9 Dec 2022 15:29:25 +0100 Subject: [PATCH 03/10] Replace actions by explicit calls --- Adapter.C | 35 ++++++++--------------------------- Adapter.H | 10 ++-------- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/Adapter.C b/Adapter.C index dd9ba648..bd341dfb 100644 --- a/Adapter.C +++ b/Adapter.C @@ -350,7 +350,7 @@ void preciceAdapter::Adapter::configure() // If checkpointing is required, specify the checkpointed fields // and write the first checkpoint - if (isWriteCheckpointRequired()) + if (requiresWritingCheckpoint()) { checkpointing_ = true; @@ -359,7 +359,6 @@ void preciceAdapter::Adapter::configure() // Write checkpoint (for the first iteration) writeCheckpoint(); - fulfilledWriteCheckpoint(); } // Adjust the timestep for the first iteration, if it is fixed @@ -421,10 +420,9 @@ void preciceAdapter::Adapter::execute() advance(); // Read checkpoint if required - if (isReadCheckpointRequired()) + if (requiresReadingCheckpoint()) { readCheckpoint(); - fulfilledReadCheckpoint(); } // Adjust the timestep, if it is fixed @@ -434,10 +432,9 @@ void preciceAdapter::Adapter::execute() } // Write checkpoint if required - if (isWriteCheckpointRequired()) + if (requiresWritingCheckpoint()) { writeCheckpoint(); - fulfilledWriteCheckpoint(); } // As soon as OpenFOAM writes the results, it will not try to write again @@ -533,11 +530,8 @@ void preciceAdapter::Adapter::initialize() DEBUG(adapterInfo("Initializing the preCICE solver interface...")); SETUP_TIMER(); - if (precice_->isActionRequired(precice::constants::actionWriteInitialData())) - { + if (precice_->requiresInitialData()) writeCouplingData(); - precice_->markActionFulfilled(precice::constants::actionWriteInitialData()); - } DEBUG(adapterInfo("Initializing preCICE data...")); timestepPrecice_ = precice_->initialize(); @@ -704,29 +698,16 @@ bool preciceAdapter::Adapter::isCouplingTimeWindowComplete() return precice_->isTimeWindowComplete(); } -bool preciceAdapter::Adapter::isReadCheckpointRequired() +bool preciceAdapter::Adapter::requiresReadingCheckpoint() { - return precice_->isActionRequired(precice::constants::actionReadIterationCheckpoint()); + return precice_->requiresReadingCheckpoint(); } -bool preciceAdapter::Adapter::isWriteCheckpointRequired() +bool preciceAdapter::Adapter::requiresWritingCheckpoint() { - return precice_->isActionRequired(precice::constants::actionWriteIterationCheckpoint()); + return precice_->requiresWritingCheckpoint(); } -void preciceAdapter::Adapter::fulfilledReadCheckpoint() -{ - precice_->markActionFulfilled(precice::constants::actionReadIterationCheckpoint()); - - return; -} - -void preciceAdapter::Adapter::fulfilledWriteCheckpoint() -{ - precice_->markActionFulfilled(precice::constants::actionWriteIterationCheckpoint()); - - return; -} void preciceAdapter::Adapter::storeCheckpointTime() { diff --git a/Adapter.H b/Adapter.H index 5dacf841..73a05d94 100644 --- a/Adapter.H +++ b/Adapter.H @@ -279,16 +279,10 @@ private: bool isCouplingTimeWindowComplete(); //- Determine if a checkpoint must be read - bool isReadCheckpointRequired(); + bool requiresReadingCheckpoint(); //- Determine if a checkpoint must be written - bool isWriteCheckpointRequired(); - - //- Tell preCICE that the checkpoint has been read - void fulfilledReadCheckpoint(); - - //- Tell preCICE that the checkpoint has been written - void fulfilledWriteCheckpoint(); + bool requiresWritingCheckpoint(); // Methods for checkpointing From 2904355a49e173056b433addc455e3b60c161b9e Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 15:08:59 +0100 Subject: [PATCH 04/10] Port data and mesh IDs to actual names --- CouplingDataUser.C | 10 ++++------ CouplingDataUser.H | 12 ++++++------ Interface.C | 25 +++++++++++++------------ 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/CouplingDataUser.C b/CouplingDataUser.C index 7e84250d..7aeaf8ad 100644 --- a/CouplingDataUser.C +++ b/CouplingDataUser.C @@ -14,16 +14,14 @@ bool preciceAdapter::CouplingDataUser::hasVectorData() return dataType_ == vector; } -void preciceAdapter::CouplingDataUser::setDataID(int dataID) +void preciceAdapter::CouplingDataUser::setDataName(std::string dataName) { - dataID_ = dataID; - - return; + dataName_ = std::move(dataName); } -int preciceAdapter::CouplingDataUser::dataID() +const std::string& preciceAdapter::CouplingDataUser::dataName() { - return dataID_; + return dataName_; } void preciceAdapter::CouplingDataUser::setPatchIDs(std::vector patchIDs) diff --git a/CouplingDataUser.H b/CouplingDataUser.H index 3c994790..ea69537b 100644 --- a/CouplingDataUser.H +++ b/CouplingDataUser.H @@ -32,8 +32,8 @@ protected: //- OpenFOAM patches that form the interface std::vector patchIDs_; - //- preCICE data ID - int dataID_; + //- data name + std::string dataName_; //- location type of the interface LocationType locationType_ = LocationType::none; @@ -48,11 +48,11 @@ public: //- Returns true if the data are vector bool hasVectorData(); - //- Set the preCICE data ID - void setDataID(int dataID); + //- Set the data name + void setDataName(std::string dataName); - //- Get the preCICE data ID - int dataID(); + //- Get the data name + const std::string& dataName(); //- Set the patch IDs that form the interface void setPatchIDs(std::vector patchIDs); diff --git a/Interface.C b/Interface.C index 694f2b54..34fe7669 100644 --- a/Interface.C +++ b/Interface.C @@ -21,9 +21,6 @@ preciceAdapter::Interface::Interface( meshConnectivity_(meshConnectivity), restartFromDeformed_(restartFromDeformed) { - // Get the meshID from preCICE - meshID_ = precice_.getMeshID(meshName_); - dim_ = precice_.getDimensions(); if (dim_ == 2 && meshConnectivity_ == true) @@ -181,7 +178,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } // Pass the mesh vertices information to preCICE - precice_.setMeshVertices(meshID_, numDataLocations_, vertices, vertexIDs_); + precice_.setMeshVertices(meshName_, numDataLocations_, vertices, vertexIDs_); } else if (locationType_ == LocationType::faceNodes) { @@ -242,7 +239,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } // Pass the mesh vertices information to preCICE - precice_.setMeshVertices(meshID_, numDataLocations_, vertices, vertexIDs_); + precice_.setMeshVertices(meshName_, numDataLocations_, vertices, vertexIDs_); // meshConnectivity for prototype neglected // Only set the triangles, if necessary @@ -325,8 +322,8 @@ void preciceAdapter::Interface::addCouplingDataWriter( std::string dataName, CouplingDataUser* couplingDataWriter) { - // Set the dataID (from preCICE) - couplingDataWriter->setDataID(precice_.getDataID(dataName, meshID_)); + // Set the data name (from preCICE) + couplingDataWriter->setDataName(dataName); // Set the patchIDs of the patches that form the interface couplingDataWriter->setPatchIDs(patchIDs_); @@ -350,7 +347,7 @@ void preciceAdapter::Interface::addCouplingDataReader( preciceAdapter::CouplingDataUser* couplingDataReader) { // Set the patchIDs of the patches that form the interface - couplingDataReader->setDataID(precice_.getDataID(dataName, meshID_)); + couplingDataReader->setDataName(dataName); // Add the CouplingDataUser to the list of readers couplingDataReader->setPatchIDs(patchIDs_); @@ -426,7 +423,8 @@ void preciceAdapter::Interface::readCouplingData() if (couplingDataReader->hasVectorData()) { precice_.readBlockVectorData( - couplingDataReader->dataID(), + meshName_, + couplingDataReader->dataName(), numDataLocations_, vertexIDs_, dataBuffer_); @@ -434,7 +432,8 @@ void preciceAdapter::Interface::readCouplingData() else { precice_.readBlockScalarData( - couplingDataReader->dataID(), + meshName_, + couplingDataReader->dataName(), numDataLocations_, vertexIDs_, dataBuffer_); @@ -465,7 +464,8 @@ void preciceAdapter::Interface::writeCouplingData() if (couplingDataWriter->hasVectorData()) { precice_.writeBlockVectorData( - couplingDataWriter->dataID(), + meshName_, + couplingDataWriter->dataName(), numDataLocations_, vertexIDs_, dataBuffer_); @@ -473,7 +473,8 @@ void preciceAdapter::Interface::writeCouplingData() else { precice_.writeBlockScalarData( - couplingDataWriter->dataID(), + meshName_, + couplingDataWriter->dataName(), numDataLocations_, vertexIDs_, dataBuffer_); From fca99c6e87a0415d55fb798b275e8b1e4518ea0d Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 3 Jul 2023 14:29:35 +0200 Subject: [PATCH 05/10] Latest changes from develop --- Adapter.C | 17 +++++++----- Adapter.H | 6 ++--- Interface.C | 77 ++++++++++++++++------------------------------------- Interface.H | 12 ++++----- 4 files changed, 42 insertions(+), 70 deletions(-) diff --git a/Adapter.C b/Adapter.C index bd341dfb..0835d62b 100644 --- a/Adapter.C +++ b/Adapter.C @@ -246,7 +246,7 @@ void preciceAdapter::Adapter::configure() DEBUG(adapterInfo("Creating the preCICE solver interface...")); DEBUG(adapterInfo(" Number of processes: " + std::to_string(Pstream::nProcs()))); DEBUG(adapterInfo(" MPI rank: " + std::to_string(Pstream::myProcNo()))); - precice_ = new precice::SolverInterface(participantName_, preciceConfigFilename_, Pstream::myProcNo(), Pstream::nProcs()); + precice_ = new precice::Participant(participantName_, preciceConfigFilename_, Pstream::myProcNo(), Pstream::nProcs()); DEBUG(adapterInfo(" preCICE solver interface was created.")); ACCUMULATE_TIMER(timeInPreciceConstruct_); @@ -346,7 +346,7 @@ void preciceAdapter::Adapter::configure() initialize(); // Read the received coupling data - readCouplingData(); + readCouplingData(runTime_.deltaT().value()); // If checkpointing is required, specify the checkpointed fields // and write the first checkpoint @@ -459,7 +459,8 @@ void preciceAdapter::Adapter::execute() ACCUMULATE_TIMER(timeInWriteResults_); // Read the received coupling data from the buffer - readCouplingData(); + // Fits to an implicit Euler + readCouplingData(runTime_.deltaT().value()); // If the coupling is not going to continue, tear down everything // and stop the simulation. @@ -495,14 +496,14 @@ void preciceAdapter::Adapter::adjustTimeStep() return; } -void preciceAdapter::Adapter::readCouplingData() +void preciceAdapter::Adapter::readCouplingData(double relativeReadTime) { SETUP_TIMER(); DEBUG(adapterInfo("Reading coupling data...")); for (uint i = 0; i < interfaces_.size(); i++) { - interfaces_.at(i)->readCouplingData(); + interfaces_.at(i)->readCouplingData(relativeReadTime); } ACCUMULATE_TIMER(timeInRead_); @@ -534,7 +535,8 @@ void preciceAdapter::Adapter::initialize() writeCouplingData(); DEBUG(adapterInfo("Initializing preCICE data...")); - timestepPrecice_ = precice_->initialize(); + precice_->initialize(); + timestepPrecice_ = precice_->getMaxTimeStepSize(); preciceInitialized_ = true; ACCUMULATE_TIMER(timeInInitialize_); @@ -572,7 +574,8 @@ void preciceAdapter::Adapter::advance() DEBUG(adapterInfo("Advancing preCICE...")); SETUP_TIMER(); - timestepPrecice_ = precice_->advance(timestepSolver_); + precice_->advance(timestepSolver_); + timestepPrecice_ = precice_->getMaxTimeStepSize(); ACCUMULATE_TIMER(timeInAdvance_); return; diff --git a/Adapter.H b/Adapter.H index 73a05d94..0f5ef548 100644 --- a/Adapter.H +++ b/Adapter.H @@ -22,7 +22,7 @@ #include "fvMesh.H" // preCICE Solver Interface -#include "precice/SolverInterface.hpp" +#include namespace preciceAdapter { @@ -105,7 +105,7 @@ private: std::vector interfaces_; //- preCICE solver interface - precice::SolverInterface* precice_ = NULL; + precice::Participant* precice_ = NULL; //- preCICE solver interface initialized bool preciceInitialized_ = false; @@ -264,7 +264,7 @@ private: void advance(); //- Read the coupling data at each interface - void readCouplingData(); + void readCouplingData(double relativeReadTime); //- Write the coupling data at each interface void writeCouplingData(); diff --git a/Interface.C b/Interface.C index 34fe7669..d070f63a 100644 --- a/Interface.C +++ b/Interface.C @@ -6,7 +6,7 @@ using namespace Foam; preciceAdapter::Interface::Interface( - precice::SolverInterface& precice, + precice::Participant& precice, const fvMesh& mesh, std::string meshName, std::string locationsType, @@ -21,7 +21,7 @@ preciceAdapter::Interface::Interface( meshConnectivity_(meshConnectivity), restartFromDeformed_(restartFromDeformed) { - dim_ = precice_.getDimensions(); + dim_ = precice_.getMeshDimensions(meshName); if (dim_ == 2 && meshConnectivity_ == true) { @@ -97,11 +97,11 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str // Array of the mesh vertices. // One mesh is used for all the patches and each vertex has 3D coordinates. - double vertices[dim_ * numDataLocations_]; + std::vector vertices(dim_ * numDataLocations_); // Array of the indices of the mesh vertices. // Each vertex has one index, but three coordinates. - vertexIDs_ = new int[numDataLocations_]; + vertexIDs_.resize(numDataLocations_); // Initialize the index of the vertices array int verticesIndex = 0; @@ -178,7 +178,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } // Pass the mesh vertices information to preCICE - precice_.setMeshVertices(meshName_, numDataLocations_, vertices, vertexIDs_); + precice_.setMeshVertices(meshName_, vertices, vertexIDs_); } else if (locationType_ == LocationType::faceNodes) { @@ -198,11 +198,11 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str // Array of the mesh vertices. // One mesh is used for all the patches and each vertex has 3D coordinates. - double vertices[dim_ * numDataLocations_]; + std::vector vertices(dim_ * numDataLocations_); // Array of the indices of the mesh vertices. // Each vertex has one index, but three coordinates. - vertexIDs_ = new int[numDataLocations_]; + vertexIDs_.resize(numDataLocations_); // Initialize the index of the vertices array int verticesIndex = 0; @@ -239,7 +239,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } // Pass the mesh vertices information to preCICE - precice_.setMeshVertices(meshName_, numDataLocations_, vertices, vertexIDs_); + precice_.setMeshVertices(meshName_, vertices, vertexIDs_); // meshConnectivity for prototype neglected // Only set the triangles, if necessary @@ -406,10 +406,10 @@ void preciceAdapter::Interface::createBuffer() // scalar and vector coupling data users in an interface. With the current // preCICE implementation, it should work as, when writing scalars, // it should only use the first 1/3 elements of the buffer. - dataBuffer_ = new double[dataBufferSize](); + dataBuffer_.resize(dataBufferSize); } -void preciceAdapter::Interface::readCouplingData() +void preciceAdapter::Interface::readCouplingData(double relativeReadTime) { // Make every coupling data reader read for (uint i = 0; i < couplingDataReaders_.size(); i++) @@ -420,27 +420,15 @@ void preciceAdapter::Interface::readCouplingData() // Make preCICE read vector or scalar data // and fill the adapter's buffer - if (couplingDataReader->hasVectorData()) - { - precice_.readBlockVectorData( - meshName_, - couplingDataReader->dataName(), - numDataLocations_, - vertexIDs_, - dataBuffer_); - } - else - { - precice_.readBlockScalarData( - meshName_, - couplingDataReader->dataName(), - numDataLocations_, - vertexIDs_, - dataBuffer_); - } + precice_.readData( + meshName_, + couplingDataReader->dataName(), + vertexIDs_, + relativeReadTime, + dataBuffer_); // Read the received data from the buffer - couplingDataReader->read(dataBuffer_, dim_); + couplingDataReader->read(dataBuffer_.data(), dim_); } } @@ -458,27 +446,14 @@ void preciceAdapter::Interface::writeCouplingData() couplingDataWriter = couplingDataWriters_.at(i); // Write the data into the adapter's buffer - couplingDataWriter->write(dataBuffer_, meshConnectivity_, dim_); + couplingDataWriter->write(dataBuffer_.data(), meshConnectivity_, dim_); // Make preCICE write vector or scalar data - if (couplingDataWriter->hasVectorData()) - { - precice_.writeBlockVectorData( - meshName_, - couplingDataWriter->dataName(), - numDataLocations_, - vertexIDs_, - dataBuffer_); - } - else - { - precice_.writeBlockScalarData( - meshName_, - couplingDataWriter->dataName(), - numDataLocations_, - vertexIDs_, - dataBuffer_); - } + precice_.writeData( + meshName_, + couplingDataWriter->dataName(), + vertexIDs_, + dataBuffer_); } // } } @@ -498,10 +473,4 @@ preciceAdapter::Interface::~Interface() delete couplingDataWriters_.at(i); } couplingDataWriters_.clear(); - - // Delete the vertexIDs_ - delete[] vertexIDs_; - - // Delete the shared data buffer - delete[] dataBuffer_; } diff --git a/Interface.H b/Interface.H index 3d05329e..27221030 100644 --- a/Interface.H +++ b/Interface.H @@ -5,7 +5,7 @@ #include #include "fvCFD.H" #include "CouplingDataUser.H" -#include "precice/SolverInterface.hpp" +#include #include "pointPatchField.H" @@ -16,7 +16,7 @@ class Interface { protected: //- preCICE solver interface - precice::SolverInterface& precice_; + precice::Participant& precice_; //- Mesh name used in the preCICE configuration std::string meshName_; @@ -37,10 +37,10 @@ protected: int numDataLocations_ = 0; //- Vertex IDs assigned by preCICE - int* vertexIDs_; + std::vector vertexIDs_; //- Buffer for the coupling data - double* dataBuffer_; + std::vector dataBuffer_; //- Vector of CouplingDataReaders std::vector couplingDataReaders_; @@ -66,7 +66,7 @@ protected: public: //- Constructor Interface( - precice::SolverInterface& precice, + precice::Participant& precice, const Foam::fvMesh& mesh, std::string meshName, std::string locationsType, @@ -94,7 +94,7 @@ public: //- Call read() on each registered couplingDataReader to read the coupling // data from the buffer and apply the boundary conditions - void readCouplingData(); + void readCouplingData(double relativeReadTime); //- Call write() on each registered couplingDataWriter to extract the boundary // data and write them into the buffer From 6ea621fad7cd194a1c45ab0dd932ee04df10e896 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 27 Jul 2023 11:03:40 +0200 Subject: [PATCH 06/10] Add changelog entry --- {docs/changelog-entries => changelog-entries}/262.md | 0 changelog-entries/285.md | 1 + 2 files changed, 1 insertion(+) rename {docs/changelog-entries => changelog-entries}/262.md (100%) create mode 100644 changelog-entries/285.md diff --git a/docs/changelog-entries/262.md b/changelog-entries/262.md similarity index 100% rename from docs/changelog-entries/262.md rename to changelog-entries/262.md diff --git a/changelog-entries/285.md b/changelog-entries/285.md new file mode 100644 index 00000000..e45be422 --- /dev/null +++ b/changelog-entries/285.md @@ -0,0 +1 @@ +- Ported the adapter to preCICE v3. The adapter is not compatible with v2 anymore. [#285](https://github.com/precice/openfoam-adapter/pull/285) From 7036e40834b7f8cd25ba6507fe025fc8c0e40385 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 27 Jul 2023 11:06:25 +0200 Subject: [PATCH 07/10] Update documentation --- docs/get.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/get.md b/docs/get.md index d9c3e708..b2fb53f9 100644 --- a/docs/get.md +++ b/docs/get.md @@ -8,7 +8,7 @@ summary: "Get the code from GitHub and run ./Allwmake. If this fails, look into To build the adapter, you need to install a few dependencies and then execute the `Allwmake` script. 1. Install [a compatible OpenFOAM distribution](https://precice.org/adapter-openfoam-support.html). -2. Install [preCICE](https://precice.org/installation-overview.html). +2. Install [preCICE v3](https://precice.org/installation-overview.html). In case you need preCICE v2, please install an older version of the adapter (v1.2.3 is the latest release to support preCICE v2). 3. [Download the latest release](https://github.com/precice/openfoam-adapter/releases/latest) for your OpenFOAM version. 4. Execute the build script: `./Allwmake`. * See and adjust the configuration in the beginning of the script first, if needed. From decba3237dfb75c89d4068e574305827af6772a2 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 27 Jul 2023 11:08:14 +0200 Subject: [PATCH 08/10] Convert NULL to nullptr --- Adapter.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adapter.H b/Adapter.H index 0f5ef548..2e56e21e 100644 --- a/Adapter.H +++ b/Adapter.H @@ -105,7 +105,7 @@ private: std::vector interfaces_; //- preCICE solver interface - precice::Participant* precice_ = NULL; + precice::Participant* precice_ = nullptr; //- preCICE solver interface initialized bool preciceInitialized_ = false; From 9d67e13d346cf84985878fa3ea704ced00ff7fdb Mon Sep 17 00:00:00 2001 From: David Schneider Date: Thu, 27 Jul 2023 20:07:30 +0200 Subject: [PATCH 09/10] Re-arrange read data if adjustable time-step sizes are used --- Adapter.C | 30 +++++++++++++++--------------- Adapter.H | 3 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Adapter.C b/Adapter.C index 0835d62b..0e1eb8db 100644 --- a/Adapter.C +++ b/Adapter.C @@ -345,9 +345,6 @@ void preciceAdapter::Adapter::configure() // Initialize preCICE and exchange the first coupling data initialize(); - // Read the received coupling data - readCouplingData(runTime_.deltaT().value()); - // If checkpointing is required, specify the checkpointed fields // and write the first checkpoint if (requiresWritingCheckpoint()) @@ -364,7 +361,7 @@ void preciceAdapter::Adapter::configure() // Adjust the timestep for the first iteration, if it is fixed if (!adjustableTimestep_) { - adjustSolverTimeStep(); + adjustSolverTimeStepAndReadData(); } // If the solver tries to end before the coupling is complete, @@ -425,12 +422,6 @@ void preciceAdapter::Adapter::execute() readCheckpoint(); } - // Adjust the timestep, if it is fixed - if (!adjustableTimestep_) - { - adjustSolverTimeStep(); - } - // Write checkpoint if required if (requiresWritingCheckpoint()) { @@ -458,9 +449,11 @@ void preciceAdapter::Adapter::execute() } ACCUMULATE_TIMER(timeInWriteResults_); - // Read the received coupling data from the buffer - // Fits to an implicit Euler - readCouplingData(runTime_.deltaT().value()); + // Adjust the timestep, if it is fixed + if (!adjustableTimestep_) + { + adjustSolverTimeStepAndReadData(); + } // If the coupling is not going to continue, tear down everything // and stop the simulation. @@ -489,9 +482,10 @@ void preciceAdapter::Adapter::execute() return; } + void preciceAdapter::Adapter::adjustTimeStep() { - adjustSolverTimeStep(); + adjustSolverTimeStepAndReadData(); return; } @@ -581,7 +575,7 @@ void preciceAdapter::Adapter::advance() return; } -void preciceAdapter::Adapter::adjustSolverTimeStep() +void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() { DEBUG(adapterInfo("Adjusting the solver's timestep...")); @@ -677,6 +671,12 @@ void preciceAdapter::Adapter::adjustSolverTimeStep() // TODO: Keep this in mind if any relevant problem appears. const_cast(runTime_).setDeltaT(timestepSolver_, false); + DEBUG(adapterInfo("Reading coupling data associated to the calculated time-step size...")); + + // Read the received coupling data from the buffer + // Fits to an implicit Euler + readCouplingData(runTime_.deltaT().value()); + return; } diff --git a/Adapter.H b/Adapter.H index 2e56e21e..694d810d 100644 --- a/Adapter.H +++ b/Adapter.H @@ -270,7 +270,8 @@ private: void writeCouplingData(); //- Adjust the timestep of the solver according to preCICE - void adjustSolverTimeStep(); + // and read data associated to the calculated time step length + void adjustSolverTimeStepAndReadData(); //- Determine if the coupling is still happening bool isCouplingOngoing(); From 98814e0d3b1523878c9d80f8ea8dc34fd30f35ba Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 7 Aug 2023 12:39:02 +0200 Subject: [PATCH 10/10] Add changelog entry --- changelog-entries/298.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog-entries/298.md diff --git a/changelog-entries/298.md b/changelog-entries/298.md new file mode 100644 index 00000000..8163f04b --- /dev/null +++ b/changelog-entries/298.md @@ -0,0 +1 @@ +- Renamed the `adjustSolverTimeStep()` method to `adjustSolverTimeStepAndReadData()`, changing the behavior to always read data at the determined time step size. [#298](https://github.com/precice/openfoam-adapter/pull/298)