Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added compatibility with foam-extend #302

Open
wants to merge 5 commits into
base: foam-extend
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
lnInclude/
Make/linux64GccDPInt32Opt/
Make/darwin64ClangDPInt32Opt/
*.dep

# Editors
.cproject
Expand Down
118 changes: 60 additions & 58 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_ = word(preciceDict.lookup("preciceConfig"));
DEBUG(adapterInfo(" precice-config-file : " + preciceConfigFilename_));

// Read and display the participant name
participantName_ = preciceDict.get<word>("participant");
participantName_ = 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_ = 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 @@ -83,15 +83,17 @@ bool preciceAdapter::Adapter::configFileRead()
return false;
}
else
{
for (const entry& interfaceDictEntry : *interfaceDictPtr)
{
wordList entries = interfaceDictPtr->toc();

forAll (entries, i)
{
if (interfaceDictEntry.isDict())
if (interfaceDictPtr->lookupEntryPtr(entries[i],false,false)->isDict())
{
const dictionary& interfaceDict = interfaceDictEntry.dict();
const dictionary& interfaceDict = interfaceDictPtr->lookupEntryPtr(entries[i],false,false)->dict();
struct InterfaceConfig interfaceConfig;

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

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

DEBUG(adapterInfo(" patches : "));
auto patches = interfaceDict.get<wordList>("patches");
auto patches = wordList(interfaceDict.lookup("patches"));
for (auto patch : patches)
{
interfaceConfig.patchNames.push_back(patch);
DEBUG(adapterInfo(" - " + patch));
}

DEBUG(adapterInfo(" writeData : "));
auto writeData = interfaceDict.get<wordList>("writeData");
auto writeData = 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 = wordList(interfaceDict.lookup("readData"));
for (auto readDatum : readData)
{
interfaceConfig.readData.push_back(readDatum);
Expand Down Expand Up @@ -844,15 +846,15 @@ void preciceAdapter::Adapter::setupMeshVolCheckpointing()
// Add the V0 and the V00 to the list of checkpointed fields.
// For V0
addVolCheckpointField(
const_cast<volScalarField::Internal&>(
const_cast<volScalarField::DimensionedInternalField&>(
mesh_.V0()));
#ifdef ADAPTER_DEBUG_MODE
adapterInfo(
"Added " + mesh_.V0().name() + " in the list of checkpointed fields.");
#endif
// For V00
addVolCheckpointField(
const_cast<volScalarField::Internal&>(
const_cast<volScalarField::DimensionedInternalField&>(
mesh_.V00()));
#ifdef ADAPTER_DEBUG_MODE
adapterInfo(
Expand Down Expand Up @@ -897,9 +899,9 @@ void preciceAdapter::Adapter::setupCheckpointing()
#undef doLocalCode
#define doLocalCode(GeomField) \
/* Checkpoint registered GeomField objects */ \
for (const word& obj : mesh_.sortedNames<GeomField>()) \
for (const word& obj : mesh_.sortedNames("GeomField")) \
{ \
addCheckpointField(mesh_.thisDb().getObjectPtr<GeomField>(obj)); \
addCheckpointField(mesh_.thisDb().lookupObject<GeomField>(obj)); \
DEBUG(adapterInfo("Checkpoint " + obj + " : " #GeomField)); \
}

Expand Down Expand Up @@ -951,105 +953,105 @@ void preciceAdapter::Adapter::addMeshCheckpointField(volVectorField& field)
}

// TODO Internal field for the V0 (volume old) and V00 (volume old-old) fields
void preciceAdapter::Adapter::addVolCheckpointField(volScalarField::Internal& field)
void preciceAdapter::Adapter::addVolCheckpointField(volScalarField::DimensionedInternalField& field)
{
{
volScalarInternalFields_.push_back(&field);
volScalarInternalFieldCopies_.push_back(new volScalarField::Internal(field));
volScalarInternalFieldCopies_.push_back(new volScalarField::DimensionedInternalField(field));
}
}


void preciceAdapter::Adapter::addCheckpointField(volScalarField* field)
void preciceAdapter::Adapter::addCheckpointField(volScalarField field)
{
if (field)
if (notNull<volScalarField>(field))
{
volScalarFields_.push_back(field);
volScalarFieldCopies_.push_back(new volScalarField(*field));
volScalarFields_.push_back(&field);
volScalarFieldCopies_.push_back(new volScalarField(field));
}
}

void preciceAdapter::Adapter::addCheckpointField(volVectorField* field)
void preciceAdapter::Adapter::addCheckpointField(volVectorField field)
{
if (field)
if (notNull<volVectorField>(field))
{
volVectorFields_.push_back(field);
volVectorFieldCopies_.push_back(new volVectorField(*field));
volVectorFields_.push_back(&field);
volVectorFieldCopies_.push_back(new volVectorField(field));
}
}

void preciceAdapter::Adapter::addCheckpointField(surfaceScalarField* field)
void preciceAdapter::Adapter::addCheckpointField(surfaceScalarField field)
{
if (field)
if (notNull<surfaceScalarField>(field))
{
surfaceScalarFields_.push_back(field);
surfaceScalarFieldCopies_.push_back(new surfaceScalarField(*field));
surfaceScalarFields_.push_back(&field);
surfaceScalarFieldCopies_.push_back(new surfaceScalarField(field));
}
}

void preciceAdapter::Adapter::addCheckpointField(surfaceVectorField* field)
void preciceAdapter::Adapter::addCheckpointField(surfaceVectorField field)
{
if (field)
if (notNull<surfaceVectorField>(field))
{
surfaceVectorFields_.push_back(field);
surfaceVectorFieldCopies_.push_back(new surfaceVectorField(*field));
surfaceVectorFields_.push_back(&field);
surfaceVectorFieldCopies_.push_back(new surfaceVectorField(field));
}
}

void preciceAdapter::Adapter::addCheckpointField(pointScalarField* field)
void preciceAdapter::Adapter::addCheckpointField(pointScalarField field)
{
if (field)
if (notNull<pointScalarField>(field))
{
pointScalarFields_.push_back(field);
pointScalarFieldCopies_.push_back(new pointScalarField(*field));
pointScalarFields_.push_back(&field);
pointScalarFieldCopies_.push_back(new pointScalarField(field));
}
}

void preciceAdapter::Adapter::addCheckpointField(pointVectorField* field)
void preciceAdapter::Adapter::addCheckpointField(pointVectorField field)
{
if (field)
if (notNull<pointVectorField>(field))
{
pointVectorFields_.push_back(field);
pointVectorFieldCopies_.push_back(new pointVectorField(*field));
pointVectorFields_.push_back(&field);
pointVectorFieldCopies_.push_back(new pointVectorField(field));
// TODO: Old time
// pointVectorFieldsOld_.push_back(const_cast<pointVectorField&>(field->oldTime())));
// pointVectorFieldCopiesOld_.push_back(new pointVectorField(field->oldTime()));
}
}

void preciceAdapter::Adapter::addCheckpointField(volTensorField* field)
void preciceAdapter::Adapter::addCheckpointField(volTensorField field)
{
if (field)
if (notNull<volTensorField>(field))
{
volTensorFields_.push_back(field);
volTensorFieldCopies_.push_back(new volTensorField(*field));
volTensorFields_.push_back(&field);
volTensorFieldCopies_.push_back(new volTensorField(field));
}
}

void preciceAdapter::Adapter::addCheckpointField(surfaceTensorField* field)
void preciceAdapter::Adapter::addCheckpointField(surfaceTensorField field)
{
if (field)
if (notNull<surfaceTensorField>(field))
{
surfaceTensorFields_.push_back(field);
surfaceTensorFieldCopies_.push_back(new surfaceTensorField(*field));
surfaceTensorFields_.push_back(&field);
surfaceTensorFieldCopies_.push_back(new surfaceTensorField(field));
}
}

void preciceAdapter::Adapter::addCheckpointField(pointTensorField* field)
void preciceAdapter::Adapter::addCheckpointField(pointTensorField field)
{
if (field)
if (notNull<pointTensorField>(field))
{
pointTensorFields_.push_back(field);
pointTensorFieldCopies_.push_back(new pointTensorField(*field));
pointTensorFields_.push_back(&field);
pointTensorFieldCopies_.push_back(new pointTensorField(field));
}
}

void preciceAdapter::Adapter::addCheckpointField(volSymmTensorField* field)
void preciceAdapter::Adapter::addCheckpointField(volSymmTensorField field)
{
if (field)
if (notNull<volSymmTensorField>(field))
{
volSymmTensorFields_.push_back(field);
volSymmTensorFieldCopies_.push_back(new volSymmTensorField(*field));
volSymmTensorFields_.push_back(&field);
volSymmTensorFieldCopies_.push_back(new volSymmTensorField(field));
}
}

Expand Down
30 changes: 16 additions & 14 deletions Adapter.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
// the respective libraries in the Make/options.

// OpenFOAM header files
#include "Time.H"
#include "foamTime.H"
#include "volFieldsFwd.H"
#include "fvMesh.H"
#include "fileName.H"

// preCICE Solver Interface
#include "precice/SolverInterface.hpp"
Expand Down Expand Up @@ -175,10 +177,10 @@ private:

// TODO checkpoint for the V0 (Old volume) and V00 (Old-Old volume) fields.
//- Checkpointed volScalarField mesh fields
std::vector<Foam::volScalarField::Internal*> volScalarInternalFields_;
std::vector<Foam::volScalarField::InternalField*> volScalarInternalFields_;

//- Checkpointed volScalarField mesh fields (copies)
std::vector<Foam::volScalarField::Internal*> volScalarInternalFieldCopies_;
std::vector<Foam::volScalarField::InternalField*> volScalarInternalFieldCopies_;

// Vectors of pointers to the checkpointed fields and their copies

Expand Down Expand Up @@ -326,43 +328,43 @@ private:

// TODO V0 and V00 checkpointed field.
//- Add the V0 and V00 checkpoint fields
void addVolCheckpointField(volScalarField::Internal& field);
void addVolCheckpointField(volScalarField::DimensionedInternalField& field);
// void addVolCheckpointFieldBuffer(volScalarField::Internal & field);

// Add checkpoint fields, depending on the type

//- Add a volScalarField to checkpoint
void addCheckpointField(volScalarField* field);
void addCheckpointField(volScalarField field);

//- Add a volVectorField to checkpoint
void addCheckpointField(volVectorField* field);
void addCheckpointField(volVectorField field);

//- Add a surfaceScalarField to checkpoint
void addCheckpointField(surfaceScalarField* field);
void addCheckpointField(surfaceScalarField field);

//- Add a surfaceVectorField to checkpoint
void addCheckpointField(surfaceVectorField* field);
void addCheckpointField(surfaceVectorField field);

//- Add a pointScalarField to checkpoint
void addCheckpointField(pointScalarField* field);
void addCheckpointField(pointScalarField field);

//- Add a pointVectorField to checkpoint
void addCheckpointField(pointVectorField* field);
void addCheckpointField(pointVectorField field);

// NOTE: Add here methods to add other object types to checkpoint,
// if needed.

//- Add a volTensorField to checkpoint
void addCheckpointField(volTensorField* field);
void addCheckpointField(volTensorField field);

//- Add a surfaceTensorField to checkpoint
void addCheckpointField(surfaceTensorField* field);
void addCheckpointField(surfaceTensorField field);

//- Add a pointTensorField to checkpoint
void addCheckpointField(pointTensorField* field);
void addCheckpointField(pointTensorField field);

//- Add a volSymmTensorField to checkpoint
void addCheckpointField(volSymmTensorField* field);
void addCheckpointField(volSymmTensorField field);

//- Read the checkpoint - restore the mesh fields and time
void readMeshCheckpoint();
Expand Down
14 changes: 7 additions & 7 deletions Allwmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ if [ -z "${WM_PROJECT:-}" ]; then
fi
# Check if this is a compatible OpenFOAM environment
# For now, only check if it is not foam-extend, the main incompatible variant.
if [ "${WM_PROJECT:-}" = "foam" ]; then
log ""
log "=== ERROR: foam-extend is not compatible with the adapter."
log "Make sure you are using a compatible OpenFOAM version:"
log " ${DOC_COMPATIBILITY}"
exit 1
fi
#if [ "${WM_PROJECT:-}" = "foam" ]; then
# log ""
# log "=== ERROR: foam-extend is not compatible with the adapter."
# log "Make sure you are using a compatible OpenFOAM version:"
# log " ${DOC_COMPATIBILITY}"
# exit 1
#fi

log ""
log "The adapter will be built into ${ADAPTER_TARGET_DIR}"
Expand Down
6 changes: 4 additions & 2 deletions CHT/CHT.H
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
#include "Interface.H"

#include "CHT/Temperature.H"
#include "CHT/HeatFlux.H"
#include "CHT/HeatFlux_incompressible.H"
#include "CHT/HeatFlux_compressible.H"
#include "CHT/SinkTemperature.H"
#include "CHT/HeatTransferCoefficient.H"
#include "CHT/HeatTransferCoefficient_incompressible.H"
#include "CHT/HeatTransferCoefficient_compressible.H"

#include "fvCFD.H"

Expand Down
Loading