From f5e506435c5940afbbf7d78179e442a5012308b0 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 3 May 2021 16:48:31 +0200 Subject: [PATCH] OpenFOAM4-specific changes --- Adapter.C | 28 ++++++++++++++-------------- FSI/Force.C | 4 ++-- FSI/Force.H | 2 +- FSI/ForceBase.C | 4 ++-- preciceAdapterFunctionObject.H | 4 +++- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Adapter.C b/Adapter.C index 203a4f15..1e725679 100644 --- a/Adapter.C +++ b/Adapter.C @@ -38,16 +38,16 @@ bool preciceAdapter::Adapter::configFileRead() IOobject::NO_WRITE)); // Read and display the preCICE configuration file name - preciceConfigFilename_ = preciceDict.get("preciceConfig"); + preciceConfigFilename_ = static_cast(preciceDict.lookup("preciceConfig")); DEBUG(adapterInfo(" precice-config-file : " + preciceConfigFilename_)); // Read and display the participant name - participantName_ = preciceDict.get("participant"); + participantName_ = static_cast(preciceDict.lookup("participant")); DEBUG(adapterInfo(" participant name : " + participantName_)); // Read and display the list of modules DEBUG(adapterInfo(" modules requested : ")); - auto modules_ = preciceDict.get("modules"); + auto modules_ = static_cast(preciceDict.lookup("modules")); for (const auto& module : modules_) { DEBUG(adapterInfo(" - " + module + "\n")); @@ -72,7 +72,7 @@ bool preciceAdapter::Adapter::configFileRead() // Every interface is a subdictionary of "interfaces", // each with an arbitrary name. Read all of them and create // a list (here: pointer) of dictionaries. - const auto* interfaceDictPtr = preciceDict.findDict("interfaces"); + const auto* interfaceDictPtr = preciceDict.subDictPtr("interfaces"); DEBUG(adapterInfo(" interfaces : ")); // Check if we found any interfaces @@ -91,7 +91,7 @@ bool preciceAdapter::Adapter::configFileRead() const dictionary& interfaceDict = interfaceDictEntry.dict(); struct InterfaceConfig interfaceConfig; - interfaceConfig.meshName = interfaceDict.get("mesh"); + interfaceConfig.meshName = static_cast(interfaceDict.lookup("mesh")); DEBUG(adapterInfo(" - mesh : " + interfaceConfig.meshName)); // By default, assume "faceCenters" as locationsType @@ -112,7 +112,7 @@ bool preciceAdapter::Adapter::configFileRead() DEBUG(adapterInfo(" connectivity : " + std::to_string(interfaceConfig.meshConnectivity))); DEBUG(adapterInfo(" patches : ")); - auto patches = interfaceDict.get("patches"); + auto patches = static_cast(interfaceDict.lookup("patches")); for (auto patch : patches) { interfaceConfig.patchNames.push_back(patch); @@ -138,7 +138,7 @@ bool preciceAdapter::Adapter::configFileRead() } DEBUG(adapterInfo(" writeData : ")); - auto writeData = interfaceDict.get("writeData"); + auto writeData = static_cast(interfaceDict.lookup("writeData")); for (auto writeDatum : writeData) { interfaceConfig.writeData.push_back(writeDatum); @@ -146,7 +146,7 @@ bool preciceAdapter::Adapter::configFileRead() } DEBUG(adapterInfo(" readData : ")); - auto readData = interfaceDict.get("readData"); + auto readData = static_cast(interfaceDict.lookup("readData")); for (auto readDatum : readData) { interfaceConfig.readData.push_back(readDatum); @@ -895,12 +895,12 @@ void preciceAdapter::Adapter::setupCheckpointing() DEBUG(adapterInfo("Adding in checkpointed fields...")); #undef doLocalCode -#define doLocalCode(GeomField) \ - /* Checkpoint registered GeomField objects */ \ - for (const word& obj : mesh_.sortedNames()) \ - { \ - addCheckpointField(mesh_.thisDb().getObjectPtr(obj)); \ - DEBUG(adapterInfo("Checkpoint " + obj + " : " #GeomField)); \ +#define doLocalCode(GeomField) \ + /* Checkpoint registered GeomField objects */ \ + for (const word& obj : mesh_.lookupClass().sortedToc()) \ + { \ + addCheckpointField(&(const_cast(mesh_.thisDb().lookupObject(obj)))); \ + DEBUG(adapterInfo("Checkpoint " + obj + " : " #GeomField)); \ } doLocalCode(volScalarField); diff --git a/FSI/Force.C b/FSI/Force.C index d8cbad39..111a8820 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -30,9 +30,9 @@ preciceAdapter::FSI::Force::Force( dimensionedVector( "fdim", dimensionSet(1, 1, -2, 0, 0, 0, 0), - Foam::vector::zero))); + Foam::vector::zero)); - Force_ = ForceOwning_.get(); + Force_ = ForceOwning_.ptr(); } } diff --git a/FSI/Force.H b/FSI/Force.H index 9e763c10..47a3fd52 100644 --- a/FSI/Force.H +++ b/FSI/Force.H @@ -16,7 +16,7 @@ private: Foam::volVectorField* Force_; //- Force field (owning pointer, we bind to Force_) - std::unique_ptr ForceOwning_; + Foam::autoPtr ForceOwning_; public: //- Constructor diff --git a/FSI/ForceBase.C b/FSI/ForceBase.C index 48297cdf..b15b4f2a 100644 --- a/FSI/ForceBase.C +++ b/FSI/ForceBase.C @@ -78,7 +78,7 @@ Foam::tmp preciceAdapter::FSI::ForceBase::rho() const IOobject::NO_READ, IOobject::NO_WRITE), mesh_, - dimensionedScalar(FSIDict.get("rho")))); + dimensionedScalar(static_cast(FSIDict.lookup("rho"))))); } else { @@ -109,7 +109,7 @@ Foam::tmp preciceAdapter::FSI::ForceBase::mu() const const dictionary& FSIDict = mesh_.lookupObject("preciceDict").subOrEmptyDict("FSI"); - dimensionedScalar nu(FSIDict.get("nu")); + dimensionedScalar nu(static_cast(FSIDict.lookup("nu"))); return tmp( new volScalarField( diff --git a/preciceAdapterFunctionObject.H b/preciceAdapterFunctionObject.H index 1cb8792f..c17f59f8 100644 --- a/preciceAdapterFunctionObject.H +++ b/preciceAdapterFunctionObject.H @@ -59,7 +59,9 @@ SourceFiles // OpenFOAM header files #include "fvMeshFunctionObject.H" -#include "clockValue.H" +#ifdef ADAPTER_ENABLE_TIMINGS +#include "clockValue.H" // Not available in OpenFOAM.org, do not enable +#endif // Main adapter header file #include "Adapter.H"