Commit ee2ddc01 authored by Alexander Jaust's avatar Alexander Jaust
Browse files

first version that works

parent 31b6d034
......@@ -187,7 +187,6 @@ int main(int argc, char** argv) try
//const double preciceDt = precice.initialize();
//precice.initializeData();
const double preciceDt = couplingInterface.initialize();
// Read initialdata for heat-flux if available
/*
......@@ -209,6 +208,15 @@ int main(int argc, char** argv) try
GetPropType<FreeFlowTypeTag, Properties::IOFields>::initOutputModule(freeFlowVtkWriter);
freeFlowVtkWriter.write(0.0);
const double preciceDt = couplingInterface.initialize();
couplingInterface.initializeData();
if (couplingInterface.isInitialDataAvailable())
{
couplingInterface.readHeatFluxFromOtherSolver();
}
// instantiate time loop
using Scalar = GetPropType<FreeFlowTypeTag, Properties::Scalar>;
const auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
......
......@@ -195,7 +195,6 @@ int main(int argc, char** argv) try
}
*/
const double preciceDt = couplingInterface.initialize();
// Read initialdata for heat-flux if available
/*
......@@ -217,6 +216,16 @@ int main(int argc, char** argv) try
GetPropType<SolidEnergyTypeTag, Properties::IOFields>::initOutputModule(solidEnergyVtkWriter);
solidEnergyVtkWriter.write(0.0);
const double preciceDt = couplingInterface.initialize();
if ( couplingInterface.hasToWriteInitialData() )
{
getBoundaryTemperatures<GetPropType<SolidEnergyTypeTag, Properties::ThermalConductivityModel>>(*solidEnergyProblem, *solidEnergyGridVariables, sol );
couplingInterface.announceInitialDataWritten();
}
couplingInterface.initializeData();
// instantiate time loop
using Scalar = GetPropType<SolidEnergyTypeTag, Properties::Scalar>;
const auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
......
......@@ -23,17 +23,21 @@
<participant name="FreeFlow">
<use-mesh name="FreeFlowMesh" provide="yes"/>
<use-mesh name="SolidEnergyMesh" from="SolidEnergy"/>
<write-data name="FreeFlow-Heat-Flux" mesh="FreeFlowMesh"/>
<read-data name="Solid-Heat-Flux" mesh="FreeFlowMesh"/>
</participant>
<participant name="SolidEnergy">
<use-mesh name="FreeFlowMesh" from="FreeFlow"/>
<use-mesh name="SolidEnergyMesh" provide="yes"/>
<use-mesh name="FreeFlowMesh" from="FreeFlow"/>
<read-data name="FreeFlow-Heat-Flux" mesh="SolidEnergyMesh"/>
<write-data name="Solid-Heat-Flux" mesh="SolidEnergyMesh"/>
<mapping:nearest-neighbor direction="write" from="SolidEnergyMesh" to="FreeFlowMesh" constraint="consistent"/>
<mapping:nearest-neighbor direction="read" from="FreeFlowMesh" to="SolidEnergyMesh" constraint="consistent"/>
<!--
<mapping:nearest-projection direction="read" from="FreeFlowMesh" to="SolidEnergyMesh" constraint="consistent"/>
......@@ -50,8 +54,8 @@
<max-time value="100"/>
<timestep-length value="1" />
<exchange data="FreeFlow-Heat-Flux" mesh="FreeFlowMesh" from="FreeFlow" to="SolidEnergy" />
<exchange data="Solid-Heat-Flux" mesh="FreeFlowMesh" from="FreeFlow" to="SolidEnergy" initialize="false" />
<exchange data="FreeFlow-Heat-Flux" mesh="FreeFlowMesh" from="FreeFlow" to="SolidEnergy" initialize="false" />
<exchange data="Solid-Heat-Flux" mesh="FreeFlowMesh" from="SolidEnergy" to="FreeFlow" initialize="true" />
</coupling-scheme:parallel-explicit>
</solver-interface>
......
......@@ -85,11 +85,16 @@ double PreciceWrapper::initialize()
timeStepSize_ = precice_->initialize();
assert( timeStepSize_ > 0 );
precice_->initializeData();
preciceWasInitialized_ = true;
return timeStepSize_;
}
void PreciceWrapper::initializeData()
{
assert( preciceWasInitialized_ );
precice_->initializeData();
}
void PreciceWrapper::finalize()
{
assert( wasCreated_ );
......@@ -187,7 +192,7 @@ bool PreciceWrapper::isCoupledEntity(const int faceID) const
std::vector<double>& PreciceWrapper::getHeatFluxToWrite()
{
assert( wasCreated_ );
assert( heatFluxToWrite_ != HeatFluxType::UNDEFINED);
assert( writeHeatFluxType_ != HeatFluxType::UNDEFINED);
if ( writeHeatFluxType_ == HeatFluxType::FreeFlow )
return freeFlowHeatFlux_;
else
......@@ -265,14 +270,14 @@ void PreciceWrapper::actionIsFulfilled(const std::string& condition)
void PreciceWrapper::readBlockScalarDataFromPrecice(const int dataID, std::vector<double> &data)
{
assert( wasCreated_ );
assert( vertexIDs.size() == data.size() );
assert( vertexIDs_.size() == data.size() );
precice_->readBlockScalarData( dataID, vertexIDs_.size(), vertexIDs_.data(), data.data() );
}
void PreciceWrapper::writeBlockScalarDataToPrecice(const int dataID, std::vector<double> &data)
{
assert( wasCreated_ );
assert( vertexIDs.size() == data.size() );
assert( vertexIDs_.size() == data.size() );
precice_->writeBlockScalarData( dataID, vertexIDs_.size(), vertexIDs_.data(), data.data() );
}
......@@ -282,6 +287,19 @@ bool PreciceWrapper::hasToWriteInitialData()
return checkIfActionIsRequired(precice::constants::actionWriteInitialData());
}
void PreciceWrapper::announceInitialDataWritten()
{
assert( wasCreated_ );
writeHeatFluxToOtherSolver();
precice_->fulfilledAction( precice::constants::actionWriteInitialData() );
}
bool PreciceWrapper::isInitialDataAvailable()
{
assert( wasCreated_ );
return precice_->isReadDataAvailable();
}
bool PreciceWrapper::hasToReadIterationCheckpoint()
{
......
......@@ -29,8 +29,6 @@ private:
void readBlockScalarDataFromPrecice( const int dataID, std::vector<double>& data );
void writeBlockScalarDataToPrecice( const int dataID, std::vector<double>& data );
bool hasToWriteInitialData();
bool meshWasCreated_;
bool preciceWasInitialized_;
int meshID_;
......@@ -80,12 +78,18 @@ public:
bool hasToWriteIterationCheckpoint();
void announceIterationCheckpointWritten();
bool hasToWriteInitialData();
void announceInitialDataWritten();
bool isInitialDataAvailable();
void setMesh( const std::string& meshName,
const size_t numPoints,
std::vector<double>& coordinates,
const std::vector<int>& dumuxFaceIDs ) ;
double initialize();
void initializeData();
void finalize();
//static void initializeData();
......@@ -105,6 +109,7 @@ public:
bool isCoupledEntity( const int faceID ) const;
std::vector<double>& getHeatFluxToWrite();
// static void readScalarQuantitiy( const int dataID, std::vector<double>& data );
......
......@@ -230,7 +230,8 @@ public:
const Scalar insideLambda = volVars.effectiveThermalConductivity();
const Scalar boundaryTemperature = couplingInterface.getHeatFluxAtFace(faceId);
// q = -lambda * (t_face - t_cc) / dx
const Scalar qHeat = -insideLambda * (cellCenterTemperature-boundaryTemperature) / distance;
//const Scalar qHeat = -insideLambda * (cellCenterTemperature-boundaryTemperature) / distance;
const Scalar qHeat = insideLambda * (cellCenterTemperature-boundaryTemperature) / distance;
values[Indices::energyEqIdx] = qHeat;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment