From f6b1e33faeaf105ab29466842abc47fa0ab42276 Mon Sep 17 00:00:00 2001 From: Alexander Jaust <alexander.jaust@ipvs.uni-stuttgart.de> Date: Wed, 24 Apr 2019 19:21:31 +0200 Subject: [PATCH] renaming everything exhanged quantities in the adapter to 'heatFlux' and 'temperature' to represent the physics better --- .../iterative/CMakeLists.txt | 2 +- .../iterative/main_freeflow.cc | 33 ++++--- .../iterative/main_solidenergy.cc | 39 ++++++--- .../precice-config-serial-implicit.xml | 79 +++++++++++++++++ .../iterative/precice-config.xml | 24 +++--- .../iterative/precicewrapper.cc | 85 ++++++++++--------- .../iterative/precicewrapper.hh | 24 ++++-- .../monolithic/problem_freeflow.hh | 10 +-- .../monolithic/problem_heat.hh | 8 +- 9 files changed, 208 insertions(+), 96 deletions(-) create mode 100644 appl/conjugateheattransfer/iterative/precice-config-serial-implicit.xml diff --git a/appl/conjugateheattransfer/iterative/CMakeLists.txt b/appl/conjugateheattransfer/iterative/CMakeLists.txt index 428d5c1..69179bc 100644 --- a/appl/conjugateheattransfer/iterative/CMakeLists.txt +++ b/appl/conjugateheattransfer/iterative/CMakeLists.txt @@ -1,5 +1,5 @@ add_input_file_links() -dune_symlink_to_source_files(FILES "precice-config.xml") +dune_symlink_to_source_files(FILES "precice-config.xml" "precice-config-serial-implicit.xml") add_executable(test_freeflow EXCLUDE_FROM_ALL main_freeflow.cc precicewrapper.cc dumuxpreciceindexwrapper.cc) add_executable(test_solidenergy EXCLUDE_FROM_ALL main_solidenergy.cc precicewrapper.cc dumuxpreciceindexwrapper.cc) diff --git a/appl/conjugateheattransfer/iterative/main_freeflow.cc b/appl/conjugateheattransfer/iterative/main_freeflow.cc index fcf3563..e454639 100644 --- a/appl/conjugateheattransfer/iterative/main_freeflow.cc +++ b/appl/conjugateheattransfer/iterative/main_freeflow.cc @@ -51,7 +51,7 @@ template<class Problem, class GridVariables, class SolutionVector> -void getBoundaryHeatFluxes(const Problem& problem, +void setBoundaryHeatFluxes(const Problem& problem, const GridVariables& gridVars, const SolutionVector& sol) { @@ -128,9 +128,11 @@ int main(int argc, char** argv) try auto& couplingInterface = precice_wrapper::PreciceWrapper::getInstance(); couplingInterface.announceSolver( "FreeFlow", mpiHelper.rank(), mpiHelper.size() ); //couplingInterface.createInstance( "FreeFlow", mpiHelper.rank(), mpiHelper.size() ); - couplingInterface.configure( "precice-config.xml" ); - couplingInterface.announceHeatFluxToWrite( precice_wrapper::HeatFluxType::FreeFlow ); - couplingInterface.announceHeatFluxToRead( precice_wrapper::HeatFluxType::Solid ); + std::string preciceConfigFilename = "precice-config.xml"; + if (argc == 3) + preciceConfigFilename = argv[2]; + + couplingInterface.configure( preciceConfigFilename ); const int dim = couplingInterface.getDimensions(); std::cout << dim << " " << int(FreeFlowFVGridGeometry::GridView::dimension) << std::endl; @@ -210,13 +212,19 @@ int main(int argc, char** argv) try const double preciceDt = couplingInterface.initialize(); + if ( couplingInterface.hasToWriteInitialData() ) + { + setBoundaryHeatFluxes( *freeFlowProblem, *freeFlowGridVariables, sol ); + couplingInterface.writeHeatFluxToOtherSolver(); + couplingInterface.announceInitialDataWritten(); + } couplingInterface.initializeData(); - +/* if (couplingInterface.isInitialDataAvailable()) { couplingInterface.readHeatFluxFromOtherSolver(); } - +*/ // instantiate time loop using Scalar = GetPropType<FreeFlowTypeTag, Properties::Scalar>; const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); @@ -270,10 +278,16 @@ int main(int argc, char** argv) try // Write heatflux to wrapper //couplingInterface.writeHeatFluxOnFace( ... ) - getBoundaryHeatFluxes( *freeFlowProblem, *freeFlowGridVariables, sol ); + setBoundaryHeatFluxes( *freeFlowProblem, *freeFlowGridVariables, sol ); //Tell wrapper that all values have been written couplingInterface.writeHeatFluxToOtherSolver(); + const double preciceDt = couplingInterface.advance( timeLoop->timeStepSize() ); + + // set new dt as suggested by newton solver + const double newDt = std::min( preciceDt, nonLinearSolver.suggestTimeStepSize( timeLoop->timeStepSize() ) ); + timeLoop->setTimeStepSize( newDt ); + if ( couplingInterface.hasToReadIterationCheckpoint() ) { //Read checkpoint @@ -292,11 +306,6 @@ int main(int argc, char** argv) try // report statistics of this time step timeLoop->reportTimeStep(); - // set new dt as suggested by newton solver - const double preciceDt = couplingInterface.advance( timeLoop->timeStepSize() ); - const double newDt = std::min( preciceDt, nonLinearSolver.suggestTimeStepSize( timeLoop->timeStepSize() ) ); - - timeLoop->setTimeStepSize( newDt ); } } while (!timeLoop->finished() && couplingInterface.isCouplingOngoing()); diff --git a/appl/conjugateheattransfer/iterative/main_solidenergy.cc b/appl/conjugateheattransfer/iterative/main_solidenergy.cc index 891e0cb..380a794 100644 --- a/appl/conjugateheattransfer/iterative/main_solidenergy.cc +++ b/appl/conjugateheattransfer/iterative/main_solidenergy.cc @@ -73,7 +73,7 @@ auto recontructBoundaryTemperature(const Problem& problem, } template<class ThermalConductivityModel, class Problem, class GridVariables, class SolutionVector> -void getBoundaryTemperatures(const Problem& problem, +void setBoundaryTemperatures(const Problem& problem, const GridVariables& gridVars, const SolutionVector& sol) { @@ -94,7 +94,7 @@ void getBoundaryTemperatures(const Problem& problem, if ( couplingInterface.isCoupledEntity( scvf.index() ) ) { //TODO: Actually writes temperature - couplingInterface.writeHeatFluxOnFace( scvf.index(), recontructBoundaryTemperature<ThermalConductivityModel>(problem, element, fvGeometry, elemVolVars, scvf) ); + couplingInterface.writeTemperatureOnFace( scvf.index(), recontructBoundaryTemperature<ThermalConductivityModel>(problem, element, fvGeometry, elemVolVars, scvf) ); } } } @@ -145,9 +145,11 @@ int main(int argc, char** argv) try auto& couplingInterface = precice_wrapper::PreciceWrapper::getInstance(); couplingInterface.announceSolver( "SolidEnergy", mpiHelper.rank(), mpiHelper.size() ); // Configure preCICE. For now the config file is hardcoded. - couplingInterface.configure( "precice-config.xml" ); - couplingInterface.announceHeatFluxToWrite( precice_wrapper::HeatFluxType::Solid ); - couplingInterface.announceHeatFluxToRead( precice_wrapper::HeatFluxType::FreeFlow ); + std::string preciceConfigFilename = "precice-config.xml"; + if (argc == 3) + preciceConfigFilename = argv[2]; + + couplingInterface.configure( preciceConfigFilename ); const int dim = couplingInterface.getDimensions(); if (dim != int(SolidEnergyFVGridGeometry::GridView::dimension)) @@ -220,12 +222,18 @@ int main(int argc, char** argv) try if ( couplingInterface.hasToWriteInitialData() ) { - getBoundaryTemperatures<GetPropType<SolidEnergyTypeTag, Properties::ThermalConductivityModel>>(*solidEnergyProblem, *solidEnergyGridVariables, sol ); + setBoundaryTemperatures<GetPropType<SolidEnergyTypeTag, Properties::ThermalConductivityModel>>(*solidEnergyProblem, *solidEnergyGridVariables, sol ); + couplingInterface.writeTemperatureToOtherSolver(); couplingInterface.announceInitialDataWritten(); } couplingInterface.initializeData(); - +/* + if (couplingInterface.isInitialDataAvailable()) + { + couplingInterface.readHeatFluxFromOtherSolver(); + } + */ // instantiate time loop using Scalar = GetPropType<SolidEnergyTypeTag, Properties::Scalar>; const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); @@ -268,6 +276,7 @@ int main(int argc, char** argv) try // Read heat flux from precice // TODO: Remove // when numPoints is defined // precice.readBlockScalarData( heatFluxId, numPoints, vertexIDs.data(), heatFluxVec.data() ); + couplingInterface.readHeatFluxFromOtherSolver(); // Make use of the heat flux here // TODO @@ -284,8 +293,15 @@ int main(int argc, char** argv) try solOld = sol; solidEnergyGridVariables->advanceTimeStep(); - getBoundaryTemperatures<GetPropType<SolidEnergyTypeTag, Properties::ThermalConductivityModel>>(*solidEnergyProblem, *solidEnergyGridVariables, sol ); - couplingInterface.writeHeatFluxToOtherSolver(); + setBoundaryTemperatures<GetPropType<SolidEnergyTypeTag, Properties::ThermalConductivityModel>>(*solidEnergyProblem, *solidEnergyGridVariables, sol ); + couplingInterface.writeTemperatureToOtherSolver(); + + const double preciceDt = couplingInterface.advance( timeLoop->timeStepSize() ); + + // set new dt as suggested by newton solver + const double newDt = std::min( preciceDt, nonLinearSolver.suggestTimeStepSize( timeLoop->timeStepSize() ) ); + + timeLoop->setTimeStepSize( newDt ); if ( couplingInterface.hasToReadIterationCheckpoint() ) { @@ -309,11 +325,6 @@ int main(int argc, char** argv) try // TODO - // set new dt as suggested by newton solver - const double preciceDt = couplingInterface.advance( timeLoop->timeStepSize() ); - const double newDt = std::min( preciceDt, nonLinearSolver.suggestTimeStepSize( timeLoop->timeStepSize() ) ); - - timeLoop->setTimeStepSize( newDt ); } } while (!timeLoop->finished() && couplingInterface.isCouplingOngoing() ); diff --git a/appl/conjugateheattransfer/iterative/precice-config-serial-implicit.xml b/appl/conjugateheattransfer/iterative/precice-config-serial-implicit.xml new file mode 100644 index 0000000..1bfd651 --- /dev/null +++ b/appl/conjugateheattransfer/iterative/precice-config-serial-implicit.xml @@ -0,0 +1,79 @@ +<?xml version="1.0"?> + +<precice-configuration> + <log> + <sink type="stream" output="stdout" filter= "(%Severity% > debug) or (%Severity% >= trace and %Module% contains SolverInterfaceImpl)" enabled="false" /> + <sink type="stream" output="stdout" enabled="false" /> + </log> + + <solver-interface dimensions="2"> + + <data:scalar name="FreeFlow-Heat-Flux"/> + <data:scalar name="Solid-Heat-Flux"/> + + <mesh name="FreeFlowMesh"> + <use-data name="FreeFlow-Heat-Flux" /> + <use-data name="Solid-Heat-Flux" /> + </mesh> + + <mesh name="SolidEnergyMesh"> + <use-data name="FreeFlow-Heat-Flux" /> + <use-data name="Solid-Heat-Flux" /> + </mesh> + + <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="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"/> + --> + + + </participant> + + <m2n:sockets from="FreeFlow" to="SolidEnergy" distribution-type="gather-scatter" network="lo" exchange-directory="/tmp/coupling" /> + + + <coupling-scheme:serial-implicit> + <max-time value="100"/> + <timestep-length value="1" /> + <max-iterations value="25"/> + + <participants first="FreeFlow" second="SolidEnergy"/> + + <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" /> + + <relative-convergence-measure limit="1.0e-6" data="Solid-Heat-Flux" mesh="FreeFlowMesh"/> + <!-- + <relative-convergence-measure limit="1.0e-2" data="FreeFlow-Heat-Flux" mesh="FreeFlowMesh"/> + --> + + <extrapolation-order value="0"/> + <post-processing:IQN-ILS> + <data mesh="FreeFlowMesh" name="Solid-Heat-Flux" /> + <initial-relaxation value="0.01" /> + <max-used-iterations value="80" /> + <timesteps-reused value="10" /> + <filter type="QR1" limit="1e-8" /> + </post-processing:IQN-ILS> + + </coupling-scheme:serial-implicit> + </solver-interface> +</precice-configuration> + diff --git a/appl/conjugateheattransfer/iterative/precice-config.xml b/appl/conjugateheattransfer/iterative/precice-config.xml index f983ded..0fd714a 100644 --- a/appl/conjugateheattransfer/iterative/precice-config.xml +++ b/appl/conjugateheattransfer/iterative/precice-config.xml @@ -8,33 +8,33 @@ <solver-interface dimensions="2"> - <data:scalar name="FreeFlow-Heat-Flux"/> - <data:scalar name="Solid-Heat-Flux"/> + <data:scalar name="Heat-Flux"/> + <data:scalar name="Temperature"/> <mesh name="FreeFlowMesh"> - <use-data name="FreeFlow-Heat-Flux" /> - <use-data name="Solid-Heat-Flux" /> + <use-data name="Heat-Flux" /> + <use-data name="Temperature" /> </mesh> <mesh name="SolidEnergyMesh"> - <use-data name="FreeFlow-Heat-Flux" /> - <use-data name="Solid-Heat-Flux" /> + <use-data name="Heat-Flux" /> + <use-data name="Temperature" /> </mesh> <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"/> + <write-data name="Heat-Flux" mesh="FreeFlowMesh"/> + <read-data name="Temperature" mesh="FreeFlowMesh"/> </participant> <participant name="SolidEnergy"> <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"/> + <read-data name="Heat-Flux" mesh="SolidEnergyMesh"/> + <write-data name="Temperature" mesh="SolidEnergyMesh"/> <mapping:nearest-neighbor direction="write" from="SolidEnergyMesh" to="FreeFlowMesh" constraint="consistent"/> @@ -54,8 +54,8 @@ <max-time value="100"/> <timestep-length value="1" /> - <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" /> + <exchange data="Heat-Flux" mesh="FreeFlowMesh" from="FreeFlow" to="SolidEnergy" initialize="false" /> + <exchange data="Temperature" mesh="FreeFlowMesh" from="SolidEnergy" to="FreeFlow" initialize="true" /> </coupling-scheme:parallel-explicit> </solver-interface> diff --git a/appl/conjugateheattransfer/iterative/precicewrapper.cc b/appl/conjugateheattransfer/iterative/precicewrapper.cc index 19738d7..c210e03 100644 --- a/appl/conjugateheattransfer/iterative/precicewrapper.cc +++ b/appl/conjugateheattransfer/iterative/precicewrapper.cc @@ -6,7 +6,7 @@ using namespace precice_wrapper; PreciceWrapper::PreciceWrapper(): wasCreated_(false), precice_(nullptr), meshWasCreated_(false), preciceWasInitialized_(false), - meshID_(0), freeFlowHeatFluxID_(0), solidHeatFluxID_(0), timeStepSize_(0.), writeHeatFluxType_(UNDEFINED), readHeatFluxType_(UNDEFINED) + meshID_(0), heatFluxID_(0), temperatureID_(0), timeStepSize_(0.) { } @@ -21,7 +21,7 @@ void PreciceWrapper::configure( const std::string& configurationFileName ) { precice_->configure( configurationFileName ); } - +/* void PreciceWrapper::announceHeatFluxToWrite(const HeatFluxType heatFluxType) { writeHeatFluxType_ = heatFluxType; @@ -31,7 +31,7 @@ void PreciceWrapper::announceHeatFluxToRead(const HeatFluxType heatFluxType) { readHeatFluxType_ = heatFluxType; } - +*/ void PreciceWrapper::announceSolver( const std::string& name, const int rank, const int size ) { assert( precice_ == nullptr ); @@ -76,11 +76,11 @@ double PreciceWrapper::initialize() assert( wasCreated_ ); assert( meshWasCreated_ ); - solidHeatFluxID_ = precice_->getDataID( "Solid-Heat-Flux", meshID_ ); - freeFlowHeatFluxID_ = precice_->getDataID( "FreeFlow-Heat-Flux", meshID_ ); + heatFluxID_ = precice_->getDataID( "Heat-Flux", meshID_ ); + temperatureID_ = precice_->getDataID( "Temperature", meshID_ ); - freeFlowHeatFlux_.resize( getNumberOfVertices() ); - solidHeatFlux_.resize( getNumberOfVertices() ); + heatFlux_.resize( getNumberOfVertices() ); + temperature_.resize( getNumberOfVertices() ); timeStepSize_ = precice_->initialize(); assert( timeStepSize_ > 0 ); @@ -127,21 +127,12 @@ size_t PreciceWrapper::getNumberOfVertices() return vertexIDs_.size(); } -double PreciceWrapper::getHeatFluxAtFace( const int faceID) const +double PreciceWrapper::getHeatFluxOnFace( const int faceID) const { assert( wasCreated_ ); const auto idx = indexMapper_.getPreciceId( faceID ); - assert( readHeatFluxType_ != HeatFluxType::UNDEFINED ); - if (readHeatFluxType_ == HeatFluxType::FreeFlow) - { - assert(idx < freeFlowHeatFlux_.size() ); - return freeFlowHeatFlux_[idx]; - } - else - { - assert(idx < solidHeatFlux_.size() ); - return solidHeatFlux_[idx]; - } + assert(idx < heatFlux_.size() ); + return heatFlux_[idx]; } void PreciceWrapper::writeHeatFluxOnFace(const int faceID, @@ -149,38 +140,48 @@ void PreciceWrapper::writeHeatFluxOnFace(const int faceID, { assert( wasCreated_ ); const auto idx = indexMapper_.getPreciceId( faceID ); - assert( writeHeatFluxType_ != HeatFluxType::UNDEFINED ); - if ( writeHeatFluxType_ == HeatFluxType::FreeFlow ) - { - freeFlowHeatFlux_[idx] = value; - } - else - { - solidHeatFlux_[idx] = value; - } + assert(idx < heatFlux_.size() ); + heatFlux_[idx] = value; } -void PreciceWrapper::writeHeatFluxToOtherSolver() +double PreciceWrapper::getTemperatureOnFace(const int faceID) const { assert( wasCreated_ ); - assert( writeHeatFluxType_ != HeatFluxType::UNDEFINED ); + const auto idx = indexMapper_.getPreciceId( faceID ); + assert(idx < temperature_.size() ); + return temperature_[idx]; +} - if ( writeHeatFluxType_ == HeatFluxType::FreeFlow ) - writeBlockScalarDataToPrecice( freeFlowHeatFluxID_, freeFlowHeatFlux_ ); - else - writeBlockScalarDataToPrecice( solidHeatFluxID_, solidHeatFlux_ ); +void PreciceWrapper::writeTemperatureOnFace(const int faceID, const double value) +{ + assert( wasCreated_ ); + const auto idx = indexMapper_.getPreciceId( faceID ); + assert(idx < temperature_.size() ); + temperature_[idx] = value; +} +void PreciceWrapper::writeHeatFluxToOtherSolver() +{ + assert( wasCreated_ ); + writeBlockScalarDataToPrecice( heatFluxID_, heatFlux_ ); } void PreciceWrapper::readHeatFluxFromOtherSolver() { assert( wasCreated_ ); - assert( readHeatFluxType_ != HeatFluxType::UNDEFINED ); + readBlockScalarDataFromPrecice( heatFluxID_, heatFlux_ ); +} - if ( readHeatFluxType_ == HeatFluxType::FreeFlow ) - readBlockScalarDataFromPrecice( freeFlowHeatFluxID_, freeFlowHeatFlux_ ); - else - readBlockScalarDataFromPrecice( solidHeatFluxID_, solidHeatFlux_ ); +void PreciceWrapper::writeTemperatureToOtherSolver() +{ + assert( wasCreated_ ); + writeBlockScalarDataToPrecice( temperatureID_, temperature_ ); +} + +void PreciceWrapper::readTemperatureFromOtherSolver() +{ + assert( wasCreated_ ); + readBlockScalarDataFromPrecice( temperatureID_, temperature_ ); } bool PreciceWrapper::isCoupledEntity(const int faceID) const @@ -188,7 +189,7 @@ bool PreciceWrapper::isCoupledEntity(const int faceID) const assert( wasCreated_ ); return indexMapper_.isDumuxIdMapped( faceID ); } - +/* std::vector<double>& PreciceWrapper::getHeatFluxToWrite() { assert( wasCreated_ ); @@ -198,7 +199,7 @@ std::vector<double>& PreciceWrapper::getHeatFluxToWrite() else return solidHeatFlux_; } - +*/ //void PreciceWrapper::readScalarQuantitiy(const int dataID, std::vector<double> &data) //{ // assert( wasCreated_ ); @@ -310,7 +311,7 @@ bool PreciceWrapper::hasToReadIterationCheckpoint() void PreciceWrapper::announceIterationCheckpointRead() { assert( wasCreated_ ); - actionIsFulfilled( precice::constants::actionWriteIterationCheckpoint() ); + actionIsFulfilled( precice::constants::actionReadIterationCheckpoint() ); } bool PreciceWrapper::hasToWriteIterationCheckpoint() diff --git a/appl/conjugateheattransfer/iterative/precicewrapper.hh b/appl/conjugateheattransfer/iterative/precicewrapper.hh index abc9b8e..3af4c6c 100644 --- a/appl/conjugateheattransfer/iterative/precicewrapper.hh +++ b/appl/conjugateheattransfer/iterative/precicewrapper.hh @@ -9,10 +9,12 @@ namespace precice_wrapper{ + /* enum HeatFluxType { UNDEFINED, FreeFlow, Solid }; + */ class PreciceWrapper { @@ -33,18 +35,20 @@ private: bool preciceWasInitialized_; int meshID_; int dimension_; - int freeFlowHeatFluxID_; - int solidHeatFluxID_; + int heatFluxID_; + int temperatureID_; double timeStepSize_; + /* HeatFluxType writeHeatFluxType_; HeatFluxType readHeatFluxType_; + */ std::vector<int> vertexIDs_; //should be size_t - std::vector<double> freeFlowHeatFlux_; - std::vector<double> solidHeatFlux_; + std::vector<double> heatFlux_; + std::vector<double> temperature_; DumuxPreciceIndexMapper<int> indexMapper_; @@ -59,8 +63,10 @@ public: void announceSolver( const std::string& name, const int rank, const int size ); void configure( const std::string& configurationFileName ); + /* void announceHeatFluxToWrite( const HeatFluxType heatFluxType ); void announceHeatFluxToRead( const HeatFluxType heatFluxType ); + */ int getDimensions(); // static int getMeshID( const std::string& meshName ); @@ -99,18 +105,24 @@ public: size_t getNumberOfVertices(); - double getHeatFluxAtFace( const int faceID ) const; + double getHeatFluxOnFace( const int faceID ) const; void writeHeatFluxOnFace( const int faceID, const double value ); + double getTemperatureOnFace( const int faceID ) const; + void writeTemperatureOnFace( const int faceID, const double value ); + void writeHeatFluxToOtherSolver(); void readHeatFluxFromOtherSolver(); + void writeTemperatureToOtherSolver(); + void readTemperatureFromOtherSolver(); + bool isCoupledEntity( const int faceID ) const; - std::vector<double>& getHeatFluxToWrite(); +// std::vector<double>& getHeatFluxToWrite(); // static void readScalarQuantitiy( const int dataID, std::vector<double>& data ); // static void writeScalarQuantitiy( const int dataID, std::vector<double>& data ); diff --git a/appl/conjugateheattransfer/monolithic/problem_freeflow.hh b/appl/conjugateheattransfer/monolithic/problem_freeflow.hh index 306f5a7..4c1004e 100644 --- a/appl/conjugateheattransfer/monolithic/problem_freeflow.hh +++ b/appl/conjugateheattransfer/monolithic/problem_freeflow.hh @@ -112,7 +112,7 @@ public: : ParentType(fvGridGeometry, "FreeFlow"), eps_(1e-6), couplingManager_(couplingManager) #else FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry) - : ParentType(fvGridGeometry, "FreeFlow"), eps_(1e-6), couplingInterface(precice_wrapper::PreciceWrapper::getInstance()) + : ParentType(fvGridGeometry, "FreeFlow"), eps_(1e-6), couplingInterface_(precice_wrapper::PreciceWrapper::getInstance()) #endif { problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name"); @@ -177,7 +177,7 @@ public: #else //TODO preCICE const auto faceId = scvf.index(); - if ( couplingInterface.isCoupledEntity(faceId) ) + if ( couplingInterface_.isCoupledEntity(faceId) ) { values.setDirichlet(Indices::velocityXIdx); values.setDirichlet(Indices::velocityYIdx); @@ -220,7 +220,7 @@ public: #else // TODO preCICE const auto faceId = scvf.index(); - if ( couplingInterface.isCoupledEntity( faceId ) ) + if ( couplingInterface_.isCoupledEntity( faceId ) ) { // Actually gets temperature const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); @@ -228,7 +228,7 @@ public: const Scalar cellCenterTemperature = volVars.temperature(); const Scalar distance = (scvf.center() - scv.center()).two_norm(); const Scalar insideLambda = volVars.effectiveThermalConductivity(); - const Scalar boundaryTemperature = couplingInterface.getHeatFluxAtFace(faceId); + const Scalar boundaryTemperature = couplingInterface_.getTemperatureOnFace(faceId); // q = -lambda * (t_face - t_cc) / dx //const Scalar qHeat = -insideLambda * (cellCenterTemperature-boundaryTemperature) / distance; const Scalar qHeat = insideLambda * (cellCenterTemperature-boundaryTemperature) / distance; @@ -297,7 +297,7 @@ private: #if ENABLEMONOLITHIC std::shared_ptr<CouplingManager> couplingManager_; #else - precice_wrapper::PreciceWrapper& couplingInterface; + precice_wrapper::PreciceWrapper& couplingInterface_; #endif }; diff --git a/appl/conjugateheattransfer/monolithic/problem_heat.hh b/appl/conjugateheattransfer/monolithic/problem_heat.hh index 1f426e9..2bdf2dd 100644 --- a/appl/conjugateheattransfer/monolithic/problem_heat.hh +++ b/appl/conjugateheattransfer/monolithic/problem_heat.hh @@ -96,7 +96,7 @@ public: : ParentType(fvGridGeometry, "SolidEnergy"), eps_(1e-7), couplingManager_(couplingManager) #else HeatSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry) - : ParentType(fvGridGeometry, "SolidEnergy"), eps_(1e-7), couplingInterface( precice_wrapper::PreciceWrapper::getInstance() ) + : ParentType(fvGridGeometry, "SolidEnergy"), eps_(1e-7), couplingInterface_( precice_wrapper::PreciceWrapper::getInstance() ) #endif { problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name"); @@ -178,9 +178,9 @@ public: #else //TODO preCICE const auto faceId = scvf.index(); - if ( couplingInterface.isCoupledEntity(faceId) ) + if ( couplingInterface_.isCoupledEntity(faceId) ) { - values[Indices::energyEqIdx] = couplingInterface.getHeatFluxAtFace(faceId) ; + values[Indices::energyEqIdx] = couplingInterface_.getHeatFluxOnFace(faceId) ; } #endif @@ -228,7 +228,7 @@ private: #if ENABLEMONOLITHIC std::shared_ptr<CouplingManager> couplingManager_; #else - precice_wrapper::PreciceWrapper& couplingInterface; + precice_wrapper::PreciceWrapper& couplingInterface_; #endif }; -- GitLab