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

Remove last else-cases in FF and CHT #197

Merged
merged 11 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from 7 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
52 changes: 32 additions & 20 deletions Adapter.C
Original file line number Diff line number Diff line change
Expand Up @@ -259,22 +259,28 @@ 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++;
MakisH marked this conversation as resolved.
Show resolved Hide resolved
MakisH marked this conversation as resolved.
Show resolved Hide resolved

// 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.
Expand All @@ -285,22 +291,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.",
MakisH marked this conversation as resolved.
Show resolved Hide resolved
"error-deferred");
}

// NOTE: Add any coupling data readers for your module here.
Expand Down
28 changes: 18 additions & 10 deletions CHT/CHT.C
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,29 @@ 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;
MakisH marked this conversation as resolved.
Show resolved Hide resolved

if (dataName.find("Sink-Temperature") == 0)
{
found = true;
MakisH marked this conversation as resolved.
Show resolved Hide resolved
interface->addCouplingDataWriter(
dataName,
new SinkTemperature(mesh_, nameT_));
DEBUG(adapterInfo("Added writer: Sink Temperature."));
}
else if (dataName.find("Temperature") == 0)
{
found = true;
interface->addCouplingDataWriter(
dataName,
new Temperature(mesh_, nameT_));
DEBUG(adapterInfo("Added writer: Temperature."));
}
else if (dataName.find("Heat-Flux") == 0)
{
found = true;
if (solverType_.compare("compressible") == 0)
{
interface->addCouplingDataWriter(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -192,36 +198,39 @@ 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
// 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_));
DEBUG(adapterInfo("Added reader: Sink Temperature."));
}
else if (dataName.find("Temperature") == 0)
{
found = true;
interface->addCouplingDataReader(
dataName,
new Temperature(mesh_, nameT_));
DEBUG(adapterInfo("Added reader: Temperature."));
}
else if (dataName.find("Heat-Flux") == 0)
{
found = true;
if (solverType_.compare("compressible") == 0)
{
interface->addCouplingDataReader(
Expand Down Expand Up @@ -251,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(
Expand Down Expand Up @@ -278,14 +288,12 @@ 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
// 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;
}
4 changes: 2 additions & 2 deletions CHT/CHT.H
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

}
Expand Down
28 changes: 18 additions & 10 deletions FF/FF.C
Original file line number Diff line number Diff line change
Expand Up @@ -97,86 +97,94 @@ 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_));
DEBUG(adapterInfo("Added writer: Velocity Gradient."));
}
else if (dataName.find("Velocity") == 0)
{
found = true;
interface->addCouplingDataWriter(
dataName,
new Velocity(mesh_, nameU_));
DEBUG(adapterInfo("Added writer: Velocity."));
}
else if (dataName.find("PressureGradient") == 0)
{
found = true;
interface->addCouplingDataWriter(
dataName,
new PressureGradient(mesh_, nameP_));
DEBUG(adapterInfo("Added writer: Pressure Gradient."));
}
else if (dataName.find("Pressure") == 0)
{
found = true;
interface->addCouplingDataWriter(
dataName,
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
// 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_));
DEBUG(adapterInfo("Added reader: VelocityGradient."));
}
else if (dataName.find("Velocity") == 0)
{
found = true;
interface->addCouplingDataReader(
dataName,
new Velocity(mesh_, nameU_));
DEBUG(adapterInfo("Added reader: Velocity."));
}
else if (dataName.find("PressureGradient") == 0)
{
found = true;
interface->addCouplingDataReader(
dataName,
new PressureGradient(mesh_, nameP_));
DEBUG(adapterInfo("Added reader: Pressure Gradient."));
}
else if (dataName.find("Pressure") == 0)
{
found = true;
interface->addCouplingDataReader(
dataName,
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
// 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;
}
4 changes: 2 additions & 2 deletions FF/FF.H
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

}
Expand Down
Loading