diff --git a/appl/coupling-ff-pm/iterative/main_ff.cc b/appl/coupling-ff-pm/iterative/main_ff.cc index faee282d19c8148c140db2dc584f57a5177553d6..c7f3942209a3822950e1b8ede5f2c6d7aaf95056 100644 --- a/appl/coupling-ff-pm/iterative/main_ff.cc +++ b/appl/coupling-ff-pm/iterative/main_ff.cc @@ -105,9 +105,6 @@ int main(int argc, char** argv) try couplingInterface.announceSolver( "FreeFlow", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size() ); - const auto velocityId = couplingInterface.announceQuantity( "Velocity" ); - const auto pressureId = couplingInterface.announceQuantity( "Pressure" ); - const int dim = couplingInterface.getDimensions(); std::cout << dim << " " << int(FreeFlowFVGridGeometry::GridView::dimension) << std::endl; if (dim != int(FreeFlowFVGridGeometry::GridView::dimension)) @@ -146,6 +143,10 @@ int main(int argc, char** argv) try coords, coupledScvfIndices ); + const auto velocityId = couplingInterface.announceQuantity( "Velocity" ); + const auto pressureId = couplingInterface.announceQuantity( "Pressure" ); + + freeFlowProblem->updatePreciceDataIds(); // apply initial solution for instationary problems freeFlowProblem->applyInitialSolution(sol); diff --git a/appl/coupling-ff-pm/iterative/main_pm.cc b/appl/coupling-ff-pm/iterative/main_pm.cc index 6874f094a7b5faaab0062d0590a40e00b5e56260..0eb19353498f5e2524b52fdaa69d99ea7357b194 100644 --- a/appl/coupling-ff-pm/iterative/main_pm.cc +++ b/appl/coupling-ff-pm/iterative/main_pm.cc @@ -166,9 +166,6 @@ int main(int argc, char** argv) try couplingInterface.announceSolver( "Darcy", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size() ); - const auto velocityId = couplingInterface.announceQuantity( "Velocity" ); - const auto pressureId = couplingInterface.announceQuantity( "Pressure" ); - const int dim = couplingInterface.getDimensions(); std::cout << dim << " " << int(DarcyFVGridGeometry::GridView::dimension) << std::endl; if (dim != int(DarcyFVGridGeometry::GridView::dimension)) @@ -202,11 +199,15 @@ int main(int argc, char** argv) try } const auto numberOfPoints = coords.size() / dim; - const double preciceDt = couplingInterface.setMeshAndInitialize( "darcyMesh", + const double preciceDt = couplingInterface.setMeshAndInitialize( "DarcyMesh", numberOfPoints, coords, coupledScvfIndices ); + const auto velocityId = couplingInterface.announceQuantity( "Velocity" ); + const auto pressureId = couplingInterface.announceQuantity( "Pressure" ); + + darcyProblem->updatePreciceDataIds(); darcyProblem->applyInitialSolution(sol); diff --git a/appl/coupling-ff-pm/monolithic/ffproblem.hh b/appl/coupling-ff-pm/monolithic/ffproblem.hh index 7907372d27a404c53df031081a7dd6772f6a9c65..d336848ee3ba0b04c117d0e7797b3ddc71e33d47 100644 --- a/appl/coupling-ff-pm/monolithic/ffproblem.hh +++ b/appl/coupling-ff-pm/monolithic/ffproblem.hh @@ -125,8 +125,9 @@ public: : ParentType(fvGridGeometry, "Stokes"), eps_(1e-6), couplingInterface_(precice_adapter::PreciceAdapter::getInstance() ), - pressureId_(couplingInterface_.getIdFromName( "Pressure" ) ), - velocityId_(couplingInterface_.getIdFromName( "Velocity" ) ) + pressureId_(0), + velocityId_(0), + dataIdsWereSet_(false) #endif { deltaP_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.PressureDifference"); @@ -196,6 +197,7 @@ public: } #else // // TODO do preCICE stuff in analogy to heat transfer + assert( dataIdsWereSet_ ); const auto faceId = scvf.index(); if ( couplingInterface_.isCoupledEntity(faceId) ) { @@ -246,6 +248,7 @@ public: values[Indices::momentumYBalanceIdx] = couplingManager().couplingData().momentumCouplingCondition(element, fvGeometry, elemVolVars, elemFaceVars, scvf); } #else + assert( dataIdsWereSet_ ); const auto faceId = scvf.index(); if( couplingInterface_.isCoupledEntity( faceId ) ) { @@ -355,6 +358,15 @@ public: return analyticalVelocityX_; } +#if !ENABLEMONOLITHIC + void updatePreciceDataIds() + { + pressureId_ = couplingInterface_.getIdFromName( "Pressure" ); + velocityId_ = couplingInterface_.getIdFromName( "Velocity" ); + dataIdsWereSet_ = true; + } +#endif + // \} private: @@ -377,8 +389,9 @@ private: std::shared_ptr<CouplingManager> couplingManager_; #else precice_adapter::PreciceAdapter& couplingInterface_; - const size_t pressureId_; - const size_t velocityId_; + size_t pressureId_; + size_t velocityId_; + bool dataIdsWereSet_; #endif mutable std::vector<Scalar> analyticalVelocityX_; diff --git a/appl/coupling-ff-pm/monolithic/pmproblem.hh b/appl/coupling-ff-pm/monolithic/pmproblem.hh index 479bca7beb3b2b1385fd02d884623589d763c514..bbec14c383514fc62035059df797eb5f5eeef2a5 100644 --- a/appl/coupling-ff-pm/monolithic/pmproblem.hh +++ b/appl/coupling-ff-pm/monolithic/pmproblem.hh @@ -128,8 +128,9 @@ public: DarcySubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry) : ParentType(fvGridGeometry, "Darcy"), eps_(1e-7), couplingInterface_(precice_adapter::PreciceAdapter::getInstance() ), - pressureId_(couplingInterface_.getIdFromName( "Pressure" ) ), - velocityId_(couplingInterface_.getIdFromName( "Velocity" ) ) + pressureId_(0), + velocityId_(0), + dataIdsWereSet_(false) #endif {} @@ -214,6 +215,7 @@ DarcySubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry) if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf)) values[Indices::conti0EqIdx] = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf); #else + assert( dataIdsWereSet_ ); const auto faceId = scvf.index(); if ( couplingInterface_.isCoupledEntity(faceId) ) { @@ -266,6 +268,15 @@ DarcySubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry) // \} +#if !ENABLEMONOLITHIC + void updatePreciceDataIds() + { + pressureId_ = couplingInterface_.getIdFromName( "Pressure" ); + velocityId_ = couplingInterface_.getIdFromName( "Velocity" ); + dataIdsWereSet_ = true; + } +#endif + #if ENABLEMONOLITHIC //! Get the coupling manager const CouplingManager& couplingManager() const @@ -291,8 +302,10 @@ private: std::shared_ptr<CouplingManager> couplingManager_; #else precice_adapter::PreciceAdapter& couplingInterface_; - const size_t pressureId_; - const size_t velocityId_; + size_t pressureId_; + size_t velocityId_; + bool dataIdsWereSet_; + #endif }; } //end namespace