From bf424796d2fc8490bf77a4af4c1aadc2890931df Mon Sep 17 00:00:00 2001 From: maxfirmbach Date: Wed, 15 Sep 2021 11:30:08 +0200 Subject: [PATCH 01/11] Remove last else-case with error --- CHT/CHT.C | 8 -------- FF/FF.C | 8 -------- 2 files changed, 16 deletions(-) diff --git a/CHT/CHT.C b/CHT/CHT.C index 0c05000d..1e1f2d14 100644 --- a/CHT/CHT.C +++ b/CHT/CHT.C @@ -192,10 +192,6 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName "error"); } } - else - { - adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); - } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data @@ -278,10 +274,6 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName "error"); } } - else - { - adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); - } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data diff --git a/FF/FF.C b/FF/FF.C index 5d016e61..eb8a2c05 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -127,10 +127,6 @@ void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* new Pressure(mesh_, nameP_)); DEBUG(adapterInfo("Added writer: Pressure.")); } - else - { - adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); - } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data @@ -169,10 +165,6 @@ void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* new Pressure(mesh_, nameP_)); DEBUG(adapterInfo("Added reader: Pressure.")); } - else - { - adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); - } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data From 1f3563ba170da650b5c2ca9d795ff8c64e1a7f0c Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 4 Oct 2021 16:59:04 +0200 Subject: [PATCH 02/11] Add an error when read/write data is not known Not known by any or by too many modules. --- Adapter.C | 51 ++++++++++++++++++++++++---------------- CHT/CHT.C | 20 ++++++++++++++-- CHT/CHT.H | 4 ++-- FF/FF.C | 20 ++++++++++++++-- FF/FF.H | 4 ++-- FSI/FSI.C | 20 ++++++++++++++-- FSI/FSI.H | 4 ++-- changelog-entries/197.md | 1 + 8 files changed, 92 insertions(+), 32 deletions(-) create mode 100644 changelog-entries/197.md diff --git a/Adapter.C b/Adapter.C index 111a61ed..ba43c6e1 100644 --- a/Adapter.C +++ b/Adapter.C @@ -259,22 +259,27 @@ void preciceAdapter::Adapter::configure() { std::string dataName = interfacesConfig_.at(i).writeData.at(j); + unsigned int inModules = 0; + // Add CHT-related coupling data writers - if (CHTenabled_) - { - CHT_->addWriters(dataName, interface); - } + if (CHTenabled_ && CHT_->addWriters(dataName, interface)) inModules++; // Add FSI-related coupling data writers - if (FSIenabled_) - { - FSI_->addWriters(dataName, interface); - } + if (FSIenabled_ && FSI_->addWriters(dataName, interface)) inModules++; // Add FF-related coupling data writers - if (FFenabled_) + if (FFenabled_ && FF_->addWriters(dataName, interface)) inModules++; + + if (inModules == 0) + { + adapterInfo("I don't know how to write " + dataName + + ". Maybe this is a typo or maybe you need to enable some adapter module?", "error-deferred"); + } + else if (inModules > 1) { - FF_->addWriters(dataName, interface); + adapterInfo("It looks like more than one modules can write " + dataName + + "and I don't know how to choose. Try disabling one of the modules.", + "error-deferred"); } // NOTE: Add any coupling data writers for your module here. @@ -285,22 +290,28 @@ void preciceAdapter::Adapter::configure() { std::string dataName = interfacesConfig_.at(i).readData.at(j); + unsigned int inModules = 0; + // Add CHT-related coupling data readers - if (CHTenabled_) - { - CHT_->addReaders(dataName, interface); - } + if (CHTenabled_ && CHT_->addReaders(dataName, interface)) inModules++; // Add FSI-related coupling data readers - if (FSIenabled_) - { - FSI_->addReaders(dataName, interface); - } + if (FSIenabled_ && FSI_->addReaders(dataName, interface)) inModules++; // Add FF-related coupling data readers - if (FFenabled_) + if (FFenabled_ && FF_->addReaders(dataName, interface)) inModules++; + + if (inModules == 0) + { + adapterInfo("I don't know how to read " + dataName + + ". Maybe this is a typo or maybe you need to enable some adapter module?", + "error-deferred"); + } + else if (inModules > 1) { - FF_->addReaders(dataName, interface); + adapterInfo("It looks like more than one modules can read " + dataName + + "and I don't know how to choose. Try disabling one of the modules.", + "error-deferred"); } // NOTE: Add any coupling data readers for your module here. diff --git a/CHT/CHT.C b/CHT/CHT.C index 1e1f2d14..30b27696 100644 --- a/CHT/CHT.C +++ b/CHT/CHT.C @@ -118,10 +118,13 @@ std::string preciceAdapter::CHT::ConjugateHeatTransfer::determineSolverType() return solverType; } -void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName, Interface* interface) +bool preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName, Interface* interface) { + bool found = false; + if (dataName.find("Sink-Temperature") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new SinkTemperature(mesh_, nameT_)); @@ -129,6 +132,7 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName } else if (dataName.find("Temperature") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new Temperature(mesh_, nameT_)); @@ -136,6 +140,7 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName } else if (dataName.find("Heat-Flux") == 0) { + found = true; if (solverType_.compare("compressible") == 0) { interface->addCouplingDataWriter( @@ -165,6 +170,7 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName } else if (dataName.find("Heat-Transfer-Coefficient") == 0) { + found = true; if (solverType_.compare("compressible") == 0) { interface->addCouplingDataWriter( @@ -198,12 +204,17 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName // writer here (and as a reader below). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } -void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName, Interface* interface) +bool preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName, Interface* interface) { + bool found = false; + if (dataName.find("Sink-Temperature") == 0) { + found = true; interface->addCouplingDataReader( dataName, new SinkTemperature(mesh_, nameT_)); @@ -211,6 +222,7 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName } else if (dataName.find("Temperature") == 0) { + found = true; interface->addCouplingDataReader( dataName, new Temperature(mesh_, nameT_)); @@ -218,6 +230,7 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName } else if (dataName.find("Heat-Flux") == 0) { + found = true; if (solverType_.compare("compressible") == 0) { interface->addCouplingDataReader( @@ -247,6 +260,7 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName } else if (dataName.find("Heat-Transfer-Coefficient") == 0) { + found = true; if (solverType_.compare("compressible") == 0) { interface->addCouplingDataReader( @@ -280,4 +294,6 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName // reader here (and as a writer above). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } diff --git a/CHT/CHT.H b/CHT/CHT.H index d4bf03fb..2f0c527f 100644 --- a/CHT/CHT.H +++ b/CHT/CHT.H @@ -60,10 +60,10 @@ public: bool configure(const IOdictionary& adapterConfig); //- Add coupling data writers - void addWriters(std::string dataName, Interface* interface); + bool addWriters(std::string dataName, Interface* interface); //- Add coupling data readers - void addReaders(std::string dataName, Interface* interface); + bool addReaders(std::string dataName, Interface* interface); }; } diff --git a/FF/FF.C b/FF/FF.C index eb8a2c05..b6c80608 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -97,10 +97,13 @@ std::string preciceAdapter::FF::FluidFluid::determineSolverType() return solverType; } -void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* interface) +bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* interface) { + bool found = false; + if (dataName.find("VelocityGradient") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new VelocityGradient(mesh_, nameU_)); @@ -108,6 +111,7 @@ void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* } else if (dataName.find("Velocity") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new Velocity(mesh_, nameU_)); @@ -115,6 +119,7 @@ void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* } else if (dataName.find("PressureGradient") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new PressureGradient(mesh_, nameP_)); @@ -122,6 +127,7 @@ void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* } else if (dataName.find("Pressure") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new Pressure(mesh_, nameP_)); @@ -133,12 +139,17 @@ void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* // writer here (and as a reader below). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } -void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* interface) +bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* interface) { + bool found = false; + if (dataName.find("VelocityGradient") == 0) { + found = true; interface->addCouplingDataReader( dataName, new VelocityGradient(mesh_, nameU_)); @@ -146,6 +157,7 @@ void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* } else if (dataName.find("Velocity") == 0) { + found = true; interface->addCouplingDataReader( dataName, new Velocity(mesh_, nameU_)); @@ -153,6 +165,7 @@ void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* } else if (dataName.find("PressureGradient") == 0) { + found = true; interface->addCouplingDataReader( dataName, new PressureGradient(mesh_, nameP_)); @@ -160,6 +173,7 @@ void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* } else if (dataName.find("Pressure") == 0) { + found = true; interface->addCouplingDataReader( dataName, new Pressure(mesh_, nameP_)); @@ -171,4 +185,6 @@ void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* // reader here (and as a writer above). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } diff --git a/FF/FF.H b/FF/FF.H index a8c65582..ded126e0 100644 --- a/FF/FF.H +++ b/FF/FF.H @@ -47,10 +47,10 @@ public: bool configure(const IOdictionary& adapterConfig); //- Add coupling data writers - void addWriters(std::string dataName, Interface* interface); + bool addWriters(std::string dataName, Interface* interface); //- Add coupling data readers - void addReaders(std::string dataName, Interface* interface); + bool addReaders(std::string dataName, Interface* interface); }; } diff --git a/FSI/FSI.C b/FSI/FSI.C index 46d37915..3aa02222 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -109,10 +109,13 @@ std::string preciceAdapter::FSI::FluidStructureInteraction::determineSolverType( } -void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string dataName, Interface* interface) +bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string dataName, Interface* interface) { + bool found = false; + if (dataName.find("Force") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ @@ -121,6 +124,7 @@ void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data } else if (dataName.find("DisplacementDelta") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new DisplacementDelta(mesh_, namePointDisplacement_, nameCellDisplacement_)); @@ -128,6 +132,7 @@ void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data } else if (dataName.find("Displacement") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new Displacement(mesh_, namePointDisplacement_, nameCellDisplacement_)); @@ -135,6 +140,7 @@ void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data } else if (dataName.find("Stress") == 0) { + found = true; interface->addCouplingDataWriter( dataName, new Stress(mesh_, solverType_) /* TODO: Add any other arguments here */ @@ -147,12 +153,17 @@ void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data // writer here (and as a reader below). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } -void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string dataName, Interface* interface) +bool preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string dataName, Interface* interface) { + bool found = false; + if (dataName.find("Force") == 0) { + found = true; interface->addCouplingDataReader( dataName, new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ @@ -161,6 +172,7 @@ void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data } else if (dataName.find("DisplacementDelta") == 0) { + found = true; interface->addCouplingDataReader( dataName, new DisplacementDelta(mesh_, namePointDisplacement_, nameCellDisplacement_)); @@ -168,6 +180,7 @@ void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data } else if (dataName.find("Displacement") == 0) { + found = true; interface->addCouplingDataReader( dataName, new Displacement(mesh_, namePointDisplacement_, nameCellDisplacement_)); @@ -175,6 +188,7 @@ void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data } else if (dataName.find("Stress") == 0) { + found = true; interface->addCouplingDataReader( dataName, new Stress(mesh_, solverType_) /* TODO: Add any other arguments here */ @@ -187,4 +201,6 @@ void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data // writer here (and as a writer above). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } diff --git a/FSI/FSI.H b/FSI/FSI.H index 237a0a9a..3e93d77e 100644 --- a/FSI/FSI.H +++ b/FSI/FSI.H @@ -56,10 +56,10 @@ public: bool configure(const IOdictionary& adapterConfig); //- Add coupling data writers - void addWriters(std::string dataName, Interface* interface); + bool addWriters(std::string dataName, Interface* interface); //- Add coupling data readers - void addReaders(std::string dataName, Interface* interface); + bool addReaders(std::string dataName, Interface* interface); }; } diff --git a/changelog-entries/197.md b/changelog-entries/197.md new file mode 100644 index 00000000..749c0a73 --- /dev/null +++ b/changelog-entries/197.md @@ -0,0 +1 @@ +- Fix a bug that was not allowing more than one module at the same time and add an error message for the case when a dataset is not known by any or too many modules. [#197](https://github.com/precice/openfoam-adapter/pull/197) From c4562051e8e73fd50d919633a1b1e4212b473722 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 4 Oct 2021 17:01:03 +0200 Subject: [PATCH 03/11] Format code --- Adapter.C | 7 ++++--- FSI/FSI.C | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Adapter.C b/Adapter.C index ba43c6e1..abf138f3 100644 --- a/Adapter.C +++ b/Adapter.C @@ -273,12 +273,13 @@ void preciceAdapter::Adapter::configure() if (inModules == 0) { adapterInfo("I don't know how to write " + dataName - + ". Maybe this is a typo or maybe you need to enable some adapter module?", "error-deferred"); + + ". Maybe this is a typo or maybe you need to enable some adapter module?", + "error-deferred"); } else if (inModules > 1) { adapterInfo("It looks like more than one modules can write " + dataName - + "and I don't know how to choose. Try disabling one of the modules.", + + "and I don't know how to choose. Try disabling one of the modules.", "error-deferred"); } @@ -310,7 +311,7 @@ void preciceAdapter::Adapter::configure() else if (inModules > 1) { adapterInfo("It looks like more than one modules can read " + dataName - + "and I don't know how to choose. Try disabling one of the modules.", + + "and I don't know how to choose. Try disabling one of the modules.", "error-deferred"); } diff --git a/FSI/FSI.C b/FSI/FSI.C index 3aa02222..1a3fb3a4 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -153,7 +153,7 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data // writer here (and as a reader below). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. - + return found; } @@ -201,6 +201,6 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data // writer here (and as a writer above). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. - + return found; } From 3ea4bfdc7d83287938023d142bb4ac2d1d39cf2e Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 18:25:29 +0100 Subject: [PATCH 04/11] Update Adapter.C Co-authored-by: David Schneider --- Adapter.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Adapter.C b/Adapter.C index abf138f3..b14235a6 100644 --- a/Adapter.C +++ b/Adapter.C @@ -272,9 +272,9 @@ void preciceAdapter::Adapter::configure() if (inModules == 0) { - adapterInfo("I don't know how to write " + dataName - + ". Maybe this is a typo or maybe you need to enable some adapter module?", - "error-deferred"); + adapterInfo("I don't know how to write \"" + dataName + + "\". Maybe this is a typo or maybe you need to enable some adapter module?", + "error-deferred"); } else if (inModules > 1) { From cd30ffbe97dcce8f6e7d98480ef0980cce9aa207 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 18:25:36 +0100 Subject: [PATCH 05/11] Update Adapter.C Co-authored-by: David Schneider --- Adapter.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adapter.C b/Adapter.C index b14235a6..563d52c6 100644 --- a/Adapter.C +++ b/Adapter.C @@ -278,8 +278,8 @@ void preciceAdapter::Adapter::configure() } else if (inModules > 1) { - adapterInfo("It looks like more than one modules can write " + dataName - + "and I don't know how to choose. Try disabling one of the modules.", + adapterInfo("It looks like more than one modules can write \"" + dataName + + "\" and I don't know how to choose. Try disabling one of the modules.", "error-deferred"); } From 04a047fa113a73280c608290e60f225fa218fe84 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 18:26:04 +0100 Subject: [PATCH 06/11] Update Adapter.C Co-authored-by: David Schneider --- Adapter.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adapter.C b/Adapter.C index 563d52c6..6a21ea4a 100644 --- a/Adapter.C +++ b/Adapter.C @@ -304,8 +304,8 @@ void preciceAdapter::Adapter::configure() if (inModules == 0) { - adapterInfo("I don't know how to read " + dataName - + ". Maybe this is a typo or maybe you need to enable some adapter module?", + adapterInfo("I don't know how to read \"" + dataName + + "\". Maybe this is a typo or maybe you need to enable some adapter module?", "error-deferred"); } else if (inModules > 1) From 429ccc2c555895a7409485d769f8da3630f6ac67 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 18:26:16 +0100 Subject: [PATCH 07/11] Update Adapter.C Co-authored-by: David Schneider --- Adapter.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adapter.C b/Adapter.C index 6a21ea4a..7e96b1a8 100644 --- a/Adapter.C +++ b/Adapter.C @@ -310,8 +310,8 @@ void preciceAdapter::Adapter::configure() } else if (inModules > 1) { - adapterInfo("It looks like more than one modules can read " + dataName - + "and I don't know how to choose. Try disabling one of the modules.", + adapterInfo("It looks like more than one modules can read \"" + dataName + + "\" and I don't know how to choose. Try disabling one of the modules.", "error-deferred"); } From 4afb1216d5a076ad526796eb04634df95f814e4f Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 18:30:46 +0100 Subject: [PATCH 08/11] Add braces around one-line IFs --- Adapter.C | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Adapter.C b/Adapter.C index 7e96b1a8..ad3609a7 100644 --- a/Adapter.C +++ b/Adapter.C @@ -262,13 +262,22 @@ void preciceAdapter::Adapter::configure() unsigned int inModules = 0; // Add CHT-related coupling data writers - if (CHTenabled_ && CHT_->addWriters(dataName, interface)) inModules++; + if (CHTenabled_ && CHT_->addWriters(dataName, interface)) + { + inModules++; + } // Add FSI-related coupling data writers - if (FSIenabled_ && FSI_->addWriters(dataName, interface)) inModules++; + if (FSIenabled_ && FSI_->addWriters(dataName, interface)) + { + inModules++; + } // Add FF-related coupling data writers - if (FFenabled_ && FF_->addWriters(dataName, interface)) inModules++; + if (FFenabled_ && FF_->addWriters(dataName, interface)) + { + inModules++; + } if (inModules == 0) { From d09a4e797fd9b577dd7d803ec31335aaa0265271 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 18:55:21 +0100 Subject: [PATCH 09/11] Set found to true by default --- CHT/CHT.C | 20 ++++++++++---------- FF/FF.C | 20 ++++++++++---------- FSI/FSI.C | 20 ++++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/CHT/CHT.C b/CHT/CHT.C index 30b27696..9204e92b 100644 --- a/CHT/CHT.C +++ b/CHT/CHT.C @@ -120,11 +120,10 @@ std::string preciceAdapter::CHT::ConjugateHeatTransfer::determineSolverType() bool preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName, Interface* interface) { - bool found = false; + bool found = true; // Set to false later, if needed. if (dataName.find("Sink-Temperature") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new SinkTemperature(mesh_, nameT_)); @@ -132,7 +131,6 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName } else if (dataName.find("Temperature") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new Temperature(mesh_, nameT_)); @@ -140,7 +138,6 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName } else if (dataName.find("Heat-Flux") == 0) { - found = true; if (solverType_.compare("compressible") == 0) { interface->addCouplingDataWriter( @@ -170,7 +167,6 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName } else if (dataName.find("Heat-Transfer-Coefficient") == 0) { - found = true; if (solverType_.compare("compressible") == 0) { interface->addCouplingDataWriter( @@ -198,6 +194,10 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName "error"); } } + else + { + found = false; + } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data @@ -210,11 +210,10 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName bool preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName, Interface* interface) { - bool found = false; + bool found = true; // Set to false later, if needed. if (dataName.find("Sink-Temperature") == 0) { - found = true; interface->addCouplingDataReader( dataName, new SinkTemperature(mesh_, nameT_)); @@ -222,7 +221,6 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName } else if (dataName.find("Temperature") == 0) { - found = true; interface->addCouplingDataReader( dataName, new Temperature(mesh_, nameT_)); @@ -230,7 +228,6 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName } else if (dataName.find("Heat-Flux") == 0) { - found = true; if (solverType_.compare("compressible") == 0) { interface->addCouplingDataReader( @@ -260,7 +257,6 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName } else if (dataName.find("Heat-Transfer-Coefficient") == 0) { - found = true; if (solverType_.compare("compressible") == 0) { interface->addCouplingDataReader( @@ -288,6 +284,10 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName "error"); } } + else + { + found = false; + } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data diff --git a/FF/FF.C b/FF/FF.C index b6c80608..00c2b695 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -99,11 +99,10 @@ std::string preciceAdapter::FF::FluidFluid::determineSolverType() bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* interface) { - bool found = false; + bool found = true; // Set to false later, if needed. if (dataName.find("VelocityGradient") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new VelocityGradient(mesh_, nameU_)); @@ -111,7 +110,6 @@ bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* } else if (dataName.find("Velocity") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new Velocity(mesh_, nameU_)); @@ -119,7 +117,6 @@ bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* } else if (dataName.find("PressureGradient") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new PressureGradient(mesh_, nameP_)); @@ -127,12 +124,15 @@ bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* } else if (dataName.find("Pressure") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new Pressure(mesh_, nameP_)); DEBUG(adapterInfo("Added writer: Pressure.")); } + else + { + found = false; + } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data @@ -145,11 +145,10 @@ bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* interface) { - bool found = false; + bool found = true; // Set to false later, if needed. if (dataName.find("VelocityGradient") == 0) { - found = true; interface->addCouplingDataReader( dataName, new VelocityGradient(mesh_, nameU_)); @@ -157,7 +156,6 @@ bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* } else if (dataName.find("Velocity") == 0) { - found = true; interface->addCouplingDataReader( dataName, new Velocity(mesh_, nameU_)); @@ -165,7 +163,6 @@ bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* } else if (dataName.find("PressureGradient") == 0) { - found = true; interface->addCouplingDataReader( dataName, new PressureGradient(mesh_, nameP_)); @@ -173,12 +170,15 @@ bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* } else if (dataName.find("Pressure") == 0) { - found = true; interface->addCouplingDataReader( dataName, new Pressure(mesh_, nameP_)); DEBUG(adapterInfo("Added reader: Pressure.")); } + else + { + found = false; + } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data diff --git a/FSI/FSI.C b/FSI/FSI.C index 1a3fb3a4..91571f62 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -111,11 +111,10 @@ std::string preciceAdapter::FSI::FluidStructureInteraction::determineSolverType( bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string dataName, Interface* interface) { - bool found = false; + bool found = true; // Set to false later, if needed. if (dataName.find("Force") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ @@ -124,7 +123,6 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data } else if (dataName.find("DisplacementDelta") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new DisplacementDelta(mesh_, namePointDisplacement_, nameCellDisplacement_)); @@ -132,7 +130,6 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data } else if (dataName.find("Displacement") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new Displacement(mesh_, namePointDisplacement_, nameCellDisplacement_)); @@ -140,13 +137,16 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data } else if (dataName.find("Stress") == 0) { - found = true; interface->addCouplingDataWriter( dataName, new Stress(mesh_, solverType_) /* TODO: Add any other arguments here */ ); DEBUG(adapterInfo("Added writer: Stress.")); } + else + { + found = false; + } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data @@ -159,11 +159,10 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data bool preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string dataName, Interface* interface) { - bool found = false; + bool found = true; // Set to false later, if needed. if (dataName.find("Force") == 0) { - found = true; interface->addCouplingDataReader( dataName, new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ @@ -172,7 +171,6 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data } else if (dataName.find("DisplacementDelta") == 0) { - found = true; interface->addCouplingDataReader( dataName, new DisplacementDelta(mesh_, namePointDisplacement_, nameCellDisplacement_)); @@ -180,7 +178,6 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data } else if (dataName.find("Displacement") == 0) { - found = true; interface->addCouplingDataReader( dataName, new Displacement(mesh_, namePointDisplacement_, nameCellDisplacement_)); @@ -188,13 +185,16 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data } else if (dataName.find("Stress") == 0) { - found = true; interface->addCouplingDataReader( dataName, new Stress(mesh_, solverType_) /* TODO: Add any other arguments here */ ); DEBUG(adapterInfo("Added reader: Stress.")); } + else + { + found = false; + } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data From 448d540beb3333154a466bfb24f3165ff4c68a41 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 19:10:55 +0100 Subject: [PATCH 10/11] Switch changelog to past --- changelog-entries/197.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog-entries/197.md b/changelog-entries/197.md index 749c0a73..b6a532c8 100644 --- a/changelog-entries/197.md +++ b/changelog-entries/197.md @@ -1 +1 @@ -- Fix a bug that was not allowing more than one module at the same time and add an error message for the case when a dataset is not known by any or too many modules. [#197](https://github.com/precice/openfoam-adapter/pull/197) +- Fixed a bug that was not allowing more than one module at the same time and added an error message for the case when a dataset is not known by any or too many modules. [#197](https://github.com/precice/openfoam-adapter/pull/197) From 631b5bc15634d8f64febe71f03aebeb920d695e9 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 19:13:22 +0100 Subject: [PATCH 11/11] Format code --- Adapter.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adapter.C b/Adapter.C index ad3609a7..cd2386d7 100644 --- a/Adapter.C +++ b/Adapter.C @@ -262,7 +262,7 @@ void preciceAdapter::Adapter::configure() unsigned int inModules = 0; // Add CHT-related coupling data writers - if (CHTenabled_ && CHT_->addWriters(dataName, interface)) + if (CHTenabled_ && CHT_->addWriters(dataName, interface)) { inModules++; } @@ -283,7 +283,7 @@ void preciceAdapter::Adapter::configure() { adapterInfo("I don't know how to write \"" + dataName + "\". Maybe this is a typo or maybe you need to enable some adapter module?", - "error-deferred"); + "error-deferred"); } else if (inModules > 1) {