-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arpan Sircar (2as)
committed
Mar 30, 2022
0 parents
commit 85d5fac
Showing
378 changed files
with
43,244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,256 @@ | ||
#include "AITS.H" | ||
|
||
#include "Utilities.H" | ||
|
||
using namespace Foam; | ||
|
||
preciceAdapter::AITS::AITSolver::AITSolver | ||
( | ||
const Foam::fvMesh& mesh | ||
) | ||
: | ||
mesh_(mesh) | ||
{} | ||
|
||
bool preciceAdapter::AITS::AITSolver::configure(const IOdictionary& adapterConfig) | ||
{ | ||
DEBUG(adapterInfo("Configuring the AITS module...")); | ||
|
||
// Read the AITS-specific options from the adapter's configuration file | ||
if (!readConfig(adapterConfig)) return false; | ||
|
||
// NOTE: If you want to add a new solver type, which you can manually | ||
// specify in the configuration, add it here. See also the methods | ||
// addWriters() and addReaders(). | ||
// Check the solver type and determine it if needed | ||
cout << "SolverType: |" << solverType_ << "|" << endl; | ||
if ( | ||
solverType_.compare("compressible") == 0 || | ||
solverType_.compare("incompressible") == 0 || | ||
solverType_.compare("basic") == 0 | ||
) | ||
{ | ||
DEBUG(adapterInfo("Known solver type: " + solverType_)); | ||
} | ||
else if (solverType_.compare("none") == 0) | ||
{ | ||
DEBUG(adapterInfo("Determining the solver type...")); | ||
solverType_ = determineSolverType(); | ||
} | ||
else | ||
{ | ||
DEBUG(adapterInfo("Unknown solver type. Determining the solver type...")); | ||
solverType_ = determineSolverType(); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool preciceAdapter::AITS::AITSolver::readConfig(const IOdictionary& adapterConfig) | ||
{ | ||
|
||
const dictionary AITSdict = adapterConfig.subOrEmptyDict("AITS"); | ||
|
||
// Read the solver type (if not specified, it is determined automatically) | ||
solverType_ = AITSdict.lookupOrDefault<word>("solverType", ""); | ||
DEBUG(adapterInfo(" user-defined solver type : " + solverType_)); | ||
|
||
// Read the name of the temperature field (if different) | ||
nameT_ = AITSdict.lookupOrDefault<word>("nameT", "T"); | ||
DEBUG(adapterInfo(" temperature field name : " + nameT_)); | ||
|
||
// Read the name of the velocity field (if different) | ||
nameU_ = AITSdict.lookupOrDefault<word>("nameU", "U"); | ||
DEBUG(adapterInfo(" velocity field name : " + nameU_)); | ||
|
||
// Read the name of the phi field (if different) | ||
namephi_ = AITSdict.lookupOrDefault<word>("namephi", "phi"); | ||
DEBUG(adapterInfo(" phi field name : " + namephi_)); | ||
|
||
// Read the name of the density field (if different) | ||
nameRho_ = AITSdict.lookupOrDefault<word>("nameRho", "rho"); | ||
DEBUG(adapterInfo(" rho field name : " + nameRho_)); | ||
|
||
// Read the name of the turb therm cond field (if different) | ||
nameAlphat_ = AITSdict.lookupOrDefault<word>("nameAlphat", "alphat"); | ||
DEBUG(adapterInfo(" alphat field name : " + nameAlphat_)); | ||
|
||
// Read the name of the dpdt field (if different) | ||
nameDpdt_ = AITSdict.lookupOrDefault<word>("nameDpdt", "Dpdt"); | ||
DEBUG(adapterInfo(" Dpdt field name : " + nameDpdt_)); | ||
|
||
// Read the name of the enthalpy field (if different) | ||
nameEnthalpy_ = AITSdict.lookupOrDefault<word>("nameEnthalpy", "enthalpy"); | ||
DEBUG(adapterInfo(" enthalpy field name : " + nameEnthalpy_)); | ||
|
||
return true; | ||
} | ||
|
||
std::string preciceAdapter::AITS::AITSolver::determineSolverType() | ||
{ | ||
// NOTE: When coupling a different variable, you may want to | ||
// add more cases here. Or you may provide the solverType in the config. | ||
|
||
std::string solverType = "unknown"; | ||
|
||
// Determine the solver type: Compressible, Incompressible or Basic - add pressure dimensions | ||
|
||
solverType = "compressible"; | ||
|
||
return solverType; | ||
} | ||
|
||
void preciceAdapter::AITS::AITSolver::addWriters(std::string dataName, Interface * interface) | ||
{ | ||
if (dataName.find("Temperature") == 0) | ||
{ | ||
interface->addCouplingDataWriter | ||
( | ||
dataName, | ||
new Temperature(mesh_, nameT_) | ||
); | ||
DEBUG(adapterInfo("Added writer: Temperature.")); | ||
} | ||
else if (dataName.find("Velocity") == 0) | ||
{ | ||
interface->addCouplingDataWriter | ||
( | ||
dataName, | ||
new Velocity(mesh_, nameU_) | ||
); | ||
DEBUG(adapterInfo("Added writer: Velocity.")); | ||
} | ||
else if (dataName.find("Flux") == 0) | ||
{ | ||
interface->addCouplingDataWriter | ||
( | ||
dataName, | ||
new Flux(mesh_, namephi_) | ||
); | ||
DEBUG(adapterInfo("Added writer: Flux.")); | ||
} | ||
else if (dataName.find("Rho") == 0) | ||
{ | ||
interface->addCouplingDataWriter | ||
( | ||
dataName, | ||
new Rho(mesh_, nameRho_) | ||
); | ||
DEBUG(adapterInfo("Added writer: Rho.")); | ||
} | ||
else if (dataName.find("Alphat") == 0) | ||
{ | ||
interface->addCouplingDataWriter | ||
( | ||
dataName, | ||
new Alphat(mesh_, nameAlphat_) | ||
); | ||
DEBUG(adapterInfo("Added writer: Alphat.")); | ||
} | ||
else if (dataName.find("Dpdt") == 0) | ||
{ | ||
interface->addCouplingDataWriter | ||
( | ||
dataName, | ||
new Dpdt(mesh_, nameDpdt_) | ||
); | ||
DEBUG(adapterInfo("Added writer: Dpdt.")); | ||
} | ||
else if (dataName.find("Enthalpy") == 0) | ||
{ | ||
interface->addCouplingDataWriter | ||
( | ||
dataName, | ||
new Enthalpy(mesh_, nameEnthalpy_) | ||
); | ||
DEBUG(adapterInfo("Added writer: Enthalpy.")); | ||
} | ||
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. | ||
} | ||
|
||
void preciceAdapter::AITS::AITSolver::addReaders(std::string dataName, Interface * interface) | ||
{ | ||
|
||
if (dataName.find("Temperature") == 0) | ||
{ | ||
interface->addCouplingDataReader | ||
( | ||
dataName, | ||
new Temperature(mesh_, nameT_) | ||
); | ||
DEBUG(adapterInfo("Added reader: Temperature.")); | ||
} | ||
else if (dataName.find("Velocity") == 0) | ||
{ | ||
interface->addCouplingDataReader | ||
( | ||
dataName, | ||
new Velocity(mesh_, nameU_) | ||
); | ||
DEBUG(adapterInfo("Added reader: Velocity.")); | ||
} | ||
else if (dataName.find("Flux") == 0) | ||
{ | ||
interface->addCouplingDataReader | ||
( | ||
dataName, | ||
new Flux(mesh_, namephi_) | ||
); | ||
DEBUG(adapterInfo("Added reader: Flux.")); | ||
} | ||
else if (dataName.find("Rho") == 0) | ||
{ | ||
interface->addCouplingDataReader | ||
( | ||
dataName, | ||
new Rho(mesh_, nameRho_) | ||
); | ||
DEBUG(adapterInfo("Added reader: Rho.")); | ||
} | ||
else if (dataName.find("Alphat") == 0) | ||
{ | ||
interface->addCouplingDataReader | ||
( | ||
dataName, | ||
new Alphat(mesh_, nameAlphat_) | ||
); | ||
DEBUG(adapterInfo("Added reader: Alphat.")); | ||
} | ||
else if (dataName.find("Dpdt") == 0) | ||
{ | ||
interface->addCouplingDataReader | ||
( | ||
dataName, | ||
new Dpdt(mesh_, nameDpdt_) | ||
); | ||
DEBUG(adapterInfo("Added reader: Dpdt.")); | ||
} | ||
else if (dataName.find("Enthalpy") == 0) | ||
{ | ||
interface->addCouplingDataReader | ||
( | ||
dataName, | ||
new Enthalpy(mesh_, nameEnthalpy_) | ||
); | ||
DEBUG(adapterInfo("Added reader: Enthalpy.")); | ||
} | ||
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. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#ifndef AITS_H | ||
#define AITS_H | ||
|
||
#include "Interface.H" | ||
|
||
#include "AITS/TemperatureAIT.H" | ||
#include "AITS/VelocityAIT.H" | ||
#include "AITS/FluxAIT.H" | ||
#include "AITS/RhoAIT.H" | ||
#include "AITS/AlphatAIT.H" | ||
#include "AITS/DpdtAIT.H" | ||
#include "AITS/EnthalpyAIT.H" | ||
#include "fvCFD.H" | ||
|
||
namespace preciceAdapter | ||
{ | ||
namespace AITS | ||
{ | ||
|
||
class AITSolver | ||
{ | ||
|
||
protected: | ||
|
||
//- OpenFOAM fvMesh object | ||
const Foam::fvMesh& mesh_; | ||
|
||
// TODO: Create a struct for all the parameter names | ||
|
||
//- Solver type | ||
std::string solverType_ = "none"; | ||
|
||
//- Name of the temperature field | ||
std::string nameT_ = "T"; | ||
|
||
//- Name of the velocity field | ||
std::string nameU_ = "U"; | ||
|
||
//- Name of the phi field | ||
std::string namephi_ = "phi"; | ||
|
||
//- Name of the density field | ||
std::string nameRho_ = "rho"; | ||
|
||
//- Name of the turb therm cond field | ||
std::string nameAlphat_ = "alphat"; | ||
|
||
//- Name of the Dpdt field | ||
std::string nameDpdt_ = "Dpdt"; | ||
|
||
//- Name of the enthalpy field | ||
std::string nameEnthalpy_ = "enthalpy"; | ||
|
||
protected: | ||
|
||
//- Determine the solver type | ||
std::string determineSolverType(); | ||
|
||
//- Read the AITS-related options from the adapter's configuraiton file | ||
bool readConfig(const IOdictionary& adapterConfig); | ||
|
||
public: | ||
|
||
//- Constructor | ||
AITSolver(const Foam::fvMesh& mesh); | ||
|
||
//- Configure | ||
bool configure(const IOdictionary& adapterConfig); | ||
|
||
//- Add coupling data writers | ||
void addWriters(std::string dataName, Interface * interface); | ||
|
||
//- Add coupling data readers | ||
void addReaders(std::string dataName, Interface * interface); | ||
}; | ||
|
||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.