Skip to content

Commit

Permalink
OpenFOAM4-specific changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MakisH committed Apr 26, 2024
1 parent 74b8719 commit f5e5064
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
28 changes: 14 additions & 14 deletions Adapter.C
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ bool preciceAdapter::Adapter::configFileRead()
IOobject::NO_WRITE));

// Read and display the preCICE configuration file name
preciceConfigFilename_ = preciceDict.get<fileName>("preciceConfig");
preciceConfigFilename_ = static_cast<fileName>(preciceDict.lookup("preciceConfig"));
DEBUG(adapterInfo(" precice-config-file : " + preciceConfigFilename_));

// Read and display the participant name
participantName_ = preciceDict.get<word>("participant");
participantName_ = static_cast<word>(preciceDict.lookup("participant"));
DEBUG(adapterInfo(" participant name : " + participantName_));

// Read and display the list of modules
DEBUG(adapterInfo(" modules requested : "));
auto modules_ = preciceDict.get<wordList>("modules");
auto modules_ = static_cast<wordList>(preciceDict.lookup("modules"));
for (const auto& module : modules_)
{
DEBUG(adapterInfo(" - " + module + "\n"));
Expand All @@ -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
Expand All @@ -91,7 +91,7 @@ bool preciceAdapter::Adapter::configFileRead()
const dictionary& interfaceDict = interfaceDictEntry.dict();
struct InterfaceConfig interfaceConfig;

interfaceConfig.meshName = interfaceDict.get<word>("mesh");
interfaceConfig.meshName = static_cast<word>(interfaceDict.lookup("mesh"));
DEBUG(adapterInfo(" - mesh : " + interfaceConfig.meshName));

// By default, assume "faceCenters" as locationsType
Expand All @@ -112,7 +112,7 @@ bool preciceAdapter::Adapter::configFileRead()
DEBUG(adapterInfo(" connectivity : " + std::to_string(interfaceConfig.meshConnectivity)));

DEBUG(adapterInfo(" patches : "));
auto patches = interfaceDict.get<wordList>("patches");
auto patches = static_cast<wordList>(interfaceDict.lookup("patches"));
for (auto patch : patches)
{
interfaceConfig.patchNames.push_back(patch);
Expand All @@ -138,15 +138,15 @@ bool preciceAdapter::Adapter::configFileRead()
}

DEBUG(adapterInfo(" writeData : "));
auto writeData = interfaceDict.get<wordList>("writeData");
auto writeData = static_cast<wordList>(interfaceDict.lookup("writeData"));
for (auto writeDatum : writeData)
{
interfaceConfig.writeData.push_back(writeDatum);
DEBUG(adapterInfo(" - " + writeDatum));
}

DEBUG(adapterInfo(" readData : "));
auto readData = interfaceDict.get<wordList>("readData");
auto readData = static_cast<wordList>(interfaceDict.lookup("readData"));
for (auto readDatum : readData)
{
interfaceConfig.readData.push_back(readDatum);
Expand Down Expand Up @@ -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<GeomField>()) \
{ \
addCheckpointField(mesh_.thisDb().getObjectPtr<GeomField>(obj)); \
DEBUG(adapterInfo("Checkpoint " + obj + " : " #GeomField)); \
#define doLocalCode(GeomField) \
/* Checkpoint registered GeomField objects */ \
for (const word& obj : mesh_.lookupClass<GeomField>().sortedToc()) \
{ \
addCheckpointField(&(const_cast<GeomField&>(mesh_.thisDb().lookupObject<GeomField>(obj)))); \
DEBUG(adapterInfo("Checkpoint " + obj + " : " #GeomField)); \
}

doLocalCode(volScalarField);
Expand Down
4 changes: 2 additions & 2 deletions FSI/Force.C
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
2 changes: 1 addition & 1 deletion FSI/Force.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private:
Foam::volVectorField* Force_;

//- Force field (owning pointer, we bind to Force_)
std::unique_ptr<Foam::volVectorField> ForceOwning_;
Foam::autoPtr<Foam::volVectorField> ForceOwning_;

public:
//- Constructor
Expand Down
4 changes: 2 additions & 2 deletions FSI/ForceBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Foam::tmp<Foam::volScalarField> preciceAdapter::FSI::ForceBase::rho() const
IOobject::NO_READ,
IOobject::NO_WRITE),
mesh_,
dimensionedScalar(FSIDict.get<dimensionedScalar>("rho"))));
dimensionedScalar(static_cast<dimensionedScalar>(FSIDict.lookup("rho")))));
}
else
{
Expand Down Expand Up @@ -109,7 +109,7 @@ Foam::tmp<Foam::volScalarField> preciceAdapter::FSI::ForceBase::mu() const
const dictionary& FSIDict =
mesh_.lookupObject<IOdictionary>("preciceDict").subOrEmptyDict("FSI");

dimensionedScalar nu(FSIDict.get<dimensionedScalar>("nu"));
dimensionedScalar nu(static_cast<dimensionedScalar>(FSIDict.lookup("nu")));

return tmp<volScalarField>(
new volScalarField(
Expand Down
4 changes: 3 additions & 1 deletion preciceAdapterFunctionObject.H
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f5e5064

Please sign in to comment.