From 282e9453f35d35d41441e369aeaab8f96f5ca748 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Dec 2023 17:06:35 +0100 Subject: [PATCH 01/19] Remove old .gitlab folder --- .gitlab/issue_templates/template.md | 28 --------------------- .gitlab/merge_request_templates/template.md | 24 ------------------ 2 files changed, 52 deletions(-) delete mode 100644 .gitlab/issue_templates/template.md delete mode 100644 .gitlab/merge_request_templates/template.md diff --git a/.gitlab/issue_templates/template.md b/.gitlab/issue_templates/template.md deleted file mode 100644 index 79b7996..0000000 --- a/.gitlab/issue_templates/template.md +++ /dev/null @@ -1,28 +0,0 @@ -## Description - - - -### Environment - - - -## Steps to reproduce - - - -### Expected behavior - - - -### Actual behavior - - diff --git a/.gitlab/merge_request_templates/template.md b/.gitlab/merge_request_templates/template.md deleted file mode 100644 index 1bd4dd9..0000000 --- a/.gitlab/merge_request_templates/template.md +++ /dev/null @@ -1,24 +0,0 @@ -## Description - - - -## Checklist - - - -- [ ] I made sure that the source files are formatted properly. -- [ ] I added my changes to the changelog (`CHANGELOG.md`) -- [ ] I updated the documentation. - - - -- [ ] I added a test for the new feature. From b4dd453a8b53c48239a69f38d59ba1362ce48dd6 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Dec 2023 17:08:11 +0100 Subject: [PATCH 02/19] Revert to using std::string and std::vector in adapter API functions --- dumux-precice/couplingadapter.cc | 38 ++++++++++++++++---------------- dumux-precice/couplingadapter.hh | 38 ++++++++++++++++---------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/dumux-precice/couplingadapter.cc b/dumux-precice/couplingadapter.cc index e2db8c1..ba2eebf 100644 --- a/dumux-precice/couplingadapter.cc +++ b/dumux-precice/couplingadapter.cc @@ -34,8 +34,8 @@ void CouplingAdapter::announceSolver(const std::string &name, wasCreated_ = true; } -void CouplingAdapter::announceQuantity(const precice::string_view &meshName, - const precice::string_view &dataName) +void CouplingAdapter::announceQuantity(const std::string &meshName, + const std::string &dataName) { assert(meshWasCreated_); const std::string key = meshAndDataKey(meshName, dataName); @@ -49,14 +49,14 @@ void CouplingAdapter::announceQuantity(const precice::string_view &meshName, } int CouplingAdapter::getMeshDimensions( - const precice::string_view &meshName) const + const std::string &meshName) const { assert(wasCreated_); return precice_->getMeshDimensions(meshName); } -void CouplingAdapter::setMesh(const precice::string_view &meshName, - precice::span positions) +void CouplingAdapter::setMesh(const std::string &meshName, + std::vector &positions) { assert(wasCreated_); vertexIDs_ = @@ -119,8 +119,8 @@ size_t CouplingAdapter::getNumberOfVertices() } double CouplingAdapter::getScalarQuantityOnFace( - const precice::string_view &meshName, - const precice::string_view &dataName, + const std::string &meshName, + const std::string &dataName, const int faceID) { assert(wasCreated_); @@ -137,8 +137,8 @@ double CouplingAdapter::getScalarQuantityOnFace( } void CouplingAdapter::writeScalarQuantityOnFace( - const precice::string_view &meshName, - const precice::string_view &dataName, + const std::string &meshName, + const std::string &dataName, const int faceID, const double value) { @@ -156,16 +156,16 @@ void CouplingAdapter::writeScalarQuantityOnFace( } std::vector &CouplingAdapter::getQuantityVector( - const precice::string_view &meshName, - const precice::string_view &dataName) + const std::string &meshName, + const std::string &dataName) { std::string key = meshAndDataKey(meshName, dataName); assert(dataMap_.find(key) != dataMap_.end()); return dataMap_[key]; } -void CouplingAdapter::writeQuantityVector(const precice::string_view &meshName, - const precice::string_view &dataName, +void CouplingAdapter::writeQuantityVector(const std::string &meshName, + const std::string &dataName, std::vector &values) { std::vector &dataVector = getQuantityVector(meshName, dataName); @@ -180,8 +180,8 @@ bool CouplingAdapter::isCoupledEntity(const int faceID) const } std::string CouplingAdapter::meshAndDataKey( - const precice::string_view &meshName, - const precice::string_view &dataName) const + const std::string &meshName, + const std::string &dataName) const { assert(wasCreated_); std::string combinedKey; @@ -203,8 +203,8 @@ void CouplingAdapter::print(std::ostream &os) } void CouplingAdapter::readQuantityFromOtherSolver( - const precice::string_view &meshName, - const precice::string_view &dataName, + const std::string &meshName, + const std::string &dataName, double relativeReadTime) { precice::span dataValuesSpan(getQuantityVector(meshName, dataName)); @@ -213,8 +213,8 @@ void CouplingAdapter::readQuantityFromOtherSolver( } void CouplingAdapter::writeQuantityToOtherSolver( - const precice::string_view &meshName, - const precice::string_view &dataName) + const std::string &meshName, + const std::string &dataName) { precice::span dataValuesSpan( getQuantityVector(meshName, dataName)); diff --git a/dumux-precice/couplingadapter.hh b/dumux-precice/couplingadapter.hh index 06c0630..f55acb9 100644 --- a/dumux-precice/couplingadapter.hh +++ b/dumux-precice/couplingadapter.hh @@ -95,15 +95,15 @@ public: * @param[in] meshName Name of the mesh. * @param[in] dataName Name of the data. */ - void announceQuantity(const precice::string_view &meshName, - const precice::string_view &dataName); + void announceQuantity(const std::string &meshName, + const std::string &dataName); /*! * @brief Get the number of spatial dimensions * * @param[in] meshName Name of the mesh * @return int Number of space dimensions. */ - int getMeshDimensions(const precice::string_view &meshName) const; + int getMeshDimensions(const std::string &meshName) const; /*! * @brief Get the maximum time step size from preCICE * @@ -147,8 +147,8 @@ public: * Example 3D:\n * [x_1, y_1, z_1, x_2, y_2, z_2,...x_numPoints, y_numPoints, z_numPoints] */ - void setMesh(const precice::string_view &meshName, - precice::span positions); + void setMesh(const std::string &meshName, + std::vector &positions); /*! * @brief Initializes the coupling * @@ -201,8 +201,8 @@ public: * @param[in] dataName Name of the data. * @param[in] relativeReadTime The relative time tagged to the data to be read. */ - void readQuantityFromOtherSolver(const precice::string_view &meshName, - const precice::string_view &dataName, + void readQuantityFromOtherSolver(const std::string &meshName, + const std::string &dataName, double relativeReadTime); /*! * @brief Writes full block of data to preCICE. @@ -210,8 +210,8 @@ public: * @param[in] meshName Name of the mesh. * @param[in] dataName Name of the data. */ - void writeQuantityToOtherSolver(const precice::string_view &meshName, - const precice::string_view &dataName); + void writeQuantityToOtherSolver(const std::string &meshName, + const std::string &dataName); /*! * @brief Gets value of a scalar quantity on a finite volume face. * @@ -220,8 +220,8 @@ public: * @param[in] faceID Identifier of the face according to DuMuX' numbering. * @return double Value of scalar quantity. */ - double getScalarQuantityOnFace(const precice::string_view &meshName, - const precice::string_view &dataName, + double getScalarQuantityOnFace(const std::string &meshName, + const std::string &dataName, const int faceID); /*! * @brief Writes value of scalar quantity on a given finite volume face to data map. @@ -231,8 +231,8 @@ public: * @param[in] faceID Identifier of the face according to DuMuX' numbering. * @param[in] value Value of scalar quantity. */ - void writeScalarQuantityOnFace(const precice::string_view &meshName, - const precice::string_view &dataName, + void writeScalarQuantityOnFace(const std::string &meshName, + const std::string &dataName, const int faceID, const double value); /*! @@ -243,8 +243,8 @@ public: * @return The value vector of the quantity. */ std::vector &getQuantityVector( - const precice::string_view &meshName, - const precice::string_view &dataName); + const std::string &meshName, + const std::string &dataName); /*! * @brief Writes the quantity value vector into the data map. * @@ -252,8 +252,8 @@ public: * @param[in] dataName Name of the data. * @param[in] values Value of the scalar or vector quantity. */ - void writeQuantityVector(const precice::string_view &meshName, - const precice::string_view &dataName, + void writeQuantityVector(const std::string &meshName, + const std::string &dataName, std::vector &values); /*! * @brief Checks whether face with given identifier is part of coupling interface. @@ -270,8 +270,8 @@ public: * @param[in] dataName Name of the quantity. * @return size_t Numeric identifier of quantity. */ - std::string meshAndDataKey(const precice::string_view &meshName, - const precice::string_view &dataName) const; + std::string meshAndDataKey(const std::string &meshName, + const std::string &dataName) const; /*! * @brief Prints status of coupling adapter to given output stream. * From 82c09a4d892fa3051cf915cff474af787e40f5b4 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Dec 2023 17:42:29 +0100 Subject: [PATCH 03/19] Correct mistake in std:vectpr --- dumux-precice/couplingadapter.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dumux-precice/couplingadapter.hh b/dumux-precice/couplingadapter.hh index f55acb9..975dc01 100644 --- a/dumux-precice/couplingadapter.hh +++ b/dumux-precice/couplingadapter.hh @@ -148,7 +148,7 @@ public: * [x_1, y_1, z_1, x_2, y_2, z_2,...x_numPoints, y_numPoints, z_numPoints] */ void setMesh(const std::string &meshName, - std::vector &positions); + std::vector &positions); /*! * @brief Initializes the coupling * From f4573df2b0106f8870a63aa540d4626ab8ae2980 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 18 Dec 2023 21:39:32 +0100 Subject: [PATCH 04/19] Formatting --- dumux-precice/couplingadapter.cc | 36 +++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/dumux-precice/couplingadapter.cc b/dumux-precice/couplingadapter.cc index ba2eebf..71da780 100644 --- a/dumux-precice/couplingadapter.cc +++ b/dumux-precice/couplingadapter.cc @@ -48,8 +48,7 @@ void CouplingAdapter::announceQuantity(const std::string &meshName, dataMap_.insert(std::make_pair(key, dataValues)); } -int CouplingAdapter::getMeshDimensions( - const std::string &meshName) const +int CouplingAdapter::getMeshDimensions(const std::string &meshName) const { assert(wasCreated_); return precice_->getMeshDimensions(meshName); @@ -118,10 +117,9 @@ size_t CouplingAdapter::getNumberOfVertices() return vertexIDs_.size(); } -double CouplingAdapter::getScalarQuantityOnFace( - const std::string &meshName, - const std::string &dataName, - const int faceID) +double CouplingAdapter::getScalarQuantityOnFace(const std::string &meshName, + const std::string &dataName, + const int faceID) { assert(wasCreated_); assert(hasIndexMapper_); @@ -136,11 +134,10 @@ double CouplingAdapter::getScalarQuantityOnFace( return dataVector[idx]; } -void CouplingAdapter::writeScalarQuantityOnFace( - const std::string &meshName, - const std::string &dataName, - const int faceID, - const double value) +void CouplingAdapter::writeScalarQuantityOnFace(const std::string &meshName, + const std::string &dataName, + const int faceID, + const double value) { assert(wasCreated_); assert(hasIndexMapper_); @@ -179,9 +176,8 @@ bool CouplingAdapter::isCoupledEntity(const int faceID) const return indexMapper_.isDumuxIdMapped(faceID); } -std::string CouplingAdapter::meshAndDataKey( - const std::string &meshName, - const std::string &dataName) const +std::string CouplingAdapter::meshAndDataKey(const std::string &meshName, + const std::string &dataName) const { assert(wasCreated_); std::string combinedKey; @@ -202,19 +198,17 @@ void CouplingAdapter::print(std::ostream &os) os << indexMapper_; } -void CouplingAdapter::readQuantityFromOtherSolver( - const std::string &meshName, - const std::string &dataName, - double relativeReadTime) +void CouplingAdapter::readQuantityFromOtherSolver(const std::string &meshName, + const std::string &dataName, + double relativeReadTime) { precice::span dataValuesSpan(getQuantityVector(meshName, dataName)); precice_->readData(meshName, dataName, vertexIDsSpan_, relativeReadTime, dataValuesSpan); } -void CouplingAdapter::writeQuantityToOtherSolver( - const std::string &meshName, - const std::string &dataName) +void CouplingAdapter::writeQuantityToOtherSolver(const std::string &meshName, + const std::string &dataName) { precice::span dataValuesSpan( getQuantityVector(meshName, dataName)); From 43c6d01e39bb5090a24b4950531a4236a43077d2 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 09:39:24 +0100 Subject: [PATCH 05/19] Revert to using std::string and std:vector instead of precice:: --- dumux-precice/couplingadapter.hh | 8 +++----- .../flow-over-cube-3d/ffproblem-reversed.hh | 8 ++++---- .../flow-over-cube-3d/main_ff-reversed.cc | 20 +++++++++---------- .../flow-over-cube-3d/main_pm-reversed.cc | 20 +++++++++---------- .../flow-over-cube-3d/pmproblem-reversed.hh | 4 ++-- .../flow-over-square-2d/ffproblem-reversed.hh | 8 ++++---- examples/ff-pm/flow-over-square-2d/main_ff.cc | 16 +++++++-------- examples/ff-pm/flow-over-square-2d/main_pm.cc | 16 +++++++-------- .../flow-over-square-2d/pmproblem-reversed.hh | 4 ++-- 9 files changed, 51 insertions(+), 53 deletions(-) diff --git a/dumux-precice/couplingadapter.hh b/dumux-precice/couplingadapter.hh index 975dc01..298ce54 100644 --- a/dumux-precice/couplingadapter.hh +++ b/dumux-precice/couplingadapter.hh @@ -147,8 +147,7 @@ public: * Example 3D:\n * [x_1, y_1, z_1, x_2, y_2, z_2,...x_numPoints, y_numPoints, z_numPoints] */ - void setMesh(const std::string &meshName, - std::vector &positions); + void setMesh(const std::string &meshName, std::vector &positions); /*! * @brief Initializes the coupling * @@ -242,9 +241,8 @@ public: * @param[in] dataName Name of the data. * @return The value vector of the quantity. */ - std::vector &getQuantityVector( - const std::string &meshName, - const std::string &dataName); + std::vector &getQuantityVector(const std::string &meshName, + const std::string &dataName); /*! * @brief Writes the quantity value vector into the data map. * diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index e27412b..815b7f9 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -219,8 +219,8 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("FreeFlowMesh", 12); - precice::string_view dataNameView_("Velocity", 8); + std::string meshNameView_("FreeFlowMesh"); + std::string dataNameView_("Velocity"); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); @@ -250,8 +250,8 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("FreeFlowMesh", 12); - precice::string_view dataNameView_("Pressure", 8); + std::string meshNameView_("FreeFlowMesh"); + std::string dataNameView_("Pressure"); NumEqVector values(0.0); const auto faceId = scvf.index(); diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index f532b6b..15dbc0d 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -99,8 +99,8 @@ template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const precice::string_view meshNameView, - const precice::string_view dataNameView) + const std::string meshNameView, + const std::string dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -162,7 +162,7 @@ void setInterfaceVelocities(const Problem &problem, template std::tuple writeVelocitiesOnInterfaceToFile( - const precice::string_view &meshNameView, + const std::string &meshNameView, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -223,7 +223,7 @@ template -void writePressuresOnInterfaceToFile(const precice::string_view &meshNameView, +void writePressuresOnInterfaceToFile(const std::string &meshNameView, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -334,7 +334,7 @@ try { couplingParticipant.announceSolver("FreeFlow", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); - const precice::string_view meshNameView("FreeFlowMesh", 12); + const std::string meshNameView("FreeFlowMesh"); const int dim = couplingParticipant.getMeshDimensions(meshNameView); std::cout << dim << " " << int(FreeFlowGridGeometry::GridView::dimension) << std::endl; @@ -367,12 +367,12 @@ try { } const auto numberOfPoints = coords.size() / dim; - precice::span coordsSpan(coords); + std::vector coordsSpan(coords); couplingParticipant.setMesh(meshNameView, coordsSpan); couplingParticipant.createIndexMapping(coupledScvfIndices); - const precice::string_view dataNameViewV("Velocity", 8); - const precice::string_view dataNameViewP("Pressure", 8); + const std::string dataNameViewV("Velocity"); + const std::string dataNameViewP("Pressure"); couplingParticipant.announceQuantity(meshNameView, dataNameViewV); couplingParticipant.announceQuantity(meshNameView, dataNameViewP); diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index e62552f..ca0e12f 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -115,8 +115,8 @@ template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const precice::string_view meshNameView, - const precice::string_view dataNameView) + const std::string meshNameView, + const std::string dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -179,8 +179,8 @@ template std::tuple writeVelocitiesOnInterfaceToFile( - const precice::string_view &meshName, + const std::string &meshName, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -269,7 +269,7 @@ std::tuple writeVelocitiesOnInterfaceToFile( } template -void writePressuresOnInterfaceToFile(const precice::string_view &meshName, +void writePressuresOnInterfaceToFile(const std::string &meshName, std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -369,7 +369,7 @@ try { couplingParticipant.announceSolver("Darcy", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); - const precice::string_view meshNameView("DarcyMesh", 9); + const std::string meshNameView("DarcyMesh"); const int dim = couplingParticipant.getMeshDimensions(meshNameView); std::cout << dim << " " << int(DarcyGridGeometry::GridView::dimension) << std::endl; @@ -402,12 +402,12 @@ try { } const auto numberOfPoints = coords.size() / dim; - precice::span coordsSpan(coords); + std::vector coordsSpan(coords); couplingParticipant.setMesh(meshNameView, coordsSpan); couplingParticipant.createIndexMapping(coupledScvfIndices); - const precice::string_view dataNameViewV("Velocity", 8); - const precice::string_view dataNameViewP("Pressure", 8); + const std::string dataNameViewV("Velocity"); + const std::string dataNameViewP("Pressure"); couplingParticipant.announceQuantity(meshNameView, dataNameViewP); couplingParticipant.announceQuantity(meshNameView, dataNameViewV); diff --git a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh index 21d1c0b..84169bc 100644 --- a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh @@ -181,8 +181,8 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("DarcyMesh", 9); - precice::string_view dataNameView_("Pressure", 8); + std::string meshNameView_("DarcyMesh"); + std::string dataNameView_("Pressure"); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index 14540f2..1aefeee 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -218,8 +218,8 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("FreeFlowMesh", 12); - precice::string_view dataNameView_("Velocity", 8); + std::string meshNameView_("FreeFlowMesh"); + std::string dataNameView_("Velocity"); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); @@ -249,8 +249,8 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("FreeFlowMesh", 12); - precice::string_view dataNameView_("Pressure", 8); + std::string meshNameView_("FreeFlowMesh"); + std::string dataNameView_("Pressure"); NumEqVector values(0.0); const auto faceId = scvf.index(); diff --git a/examples/ff-pm/flow-over-square-2d/main_ff.cc b/examples/ff-pm/flow-over-square-2d/main_ff.cc index 772bd4e..787312a 100644 --- a/examples/ff-pm/flow-over-square-2d/main_ff.cc +++ b/examples/ff-pm/flow-over-square-2d/main_ff.cc @@ -99,8 +99,8 @@ template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const precice::string_view meshNameView, - const precice::string_view dataNameView) + const std::string meshNameView, + const std::string dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -224,7 +224,7 @@ try { couplingParticipant.announceSolver("FreeFlow", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); - const precice::string_view meshNameView("FreeFlowMesh", 12); // mesh name + const std::string meshNameView("FreeFlowMesh"); // mesh name const int dim = couplingParticipant.getMeshDimensions(meshNameView); std::cout << dim << " " << int(FreeFlowGridGeometry::GridView::dimension) << std::endl; @@ -257,12 +257,12 @@ try { } const auto numberOfPoints = coords.size() / dim; - precice::span coordsSpan(coords); + std::vector coordsSpan(coords); couplingParticipant.setMesh(meshNameView, coordsSpan); couplingParticipant.createIndexMapping(coupledScvfIndices); - const precice::string_view dataNameViewV("Velocity", 8); - const precice::string_view dataNameViewP("Pressure", 8); + const std::string dataNameViewV("Velocity"); + const std::string dataNameViewP("Pressure"); couplingParticipant.announceQuantity(meshNameView, dataNameViewV); couplingParticipant.announceQuantity(meshNameView, dataNameViewP); diff --git a/examples/ff-pm/flow-over-square-2d/main_pm.cc b/examples/ff-pm/flow-over-square-2d/main_pm.cc index 938c82d..9f3a2f5 100644 --- a/examples/ff-pm/flow-over-square-2d/main_pm.cc +++ b/examples/ff-pm/flow-over-square-2d/main_pm.cc @@ -115,8 +115,8 @@ template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const precice::string_view meshNameView, - const precice::string_view dataNameView) + const std::string meshNameView, + const std::string dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -179,8 +179,8 @@ template coordsSpan(coords); + std::vector coordsSpan(coords); couplingParticipant.setMesh(meshNameView, coordsSpan); couplingParticipant.createIndexMapping(coupledScvfIndices); - const precice::string_view dataNameViewV("Velocity", 8); - const precice::string_view dataNameViewP("Pressure", 8); + const std::string dataNameViewV("Velocity"); + const std::string dataNameViewP("Pressure"); couplingParticipant.announceQuantity(meshNameView, dataNameViewP); couplingParticipant.announceQuantity(meshNameView, dataNameViewV); diff --git a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh index cfc59e0..a7cdd24 100644 --- a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh @@ -180,8 +180,8 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("DarcyMesh", 9); - precice::string_view dataNameView_("Pressure", 8); + std::string meshNameView_("DarcyMesh"); + std::string dataNameView_("Pressure"); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); From 98727f53284abe111b14178644f3656319af024f Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 09:44:04 +0100 Subject: [PATCH 06/19] Use std::string instead of precice::string_view in the dummy solver --- examples/dummysolver/main_dummysolver.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/dummysolver/main_dummysolver.cc b/examples/dummysolver/main_dummysolver.cc index a2ff0ff..cd3d511 100644 --- a/examples/dummysolver/main_dummysolver.cc +++ b/examples/dummysolver/main_dummysolver.cc @@ -42,7 +42,7 @@ try { getParamFromGroup("preCICE", "ConfigFileName"); const std::string meshName = getParamFromGroup("preCICE", "MeshName"); - const precice::string_view meshNameView(meshName); + const std::string meshNameView(meshName); auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); couplingParticipant.announceSolver(solverName, preciceConfigFilename, @@ -54,13 +54,13 @@ try { const int dimensions = couplingParticipant.getMeshDimensions(meshNameView); assert(dimensions == 3); - const precice::string_view scalarDataWriteName = std::string( + const std::string scalarDataWriteName = std::string( (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"); - const precice::string_view scalarDataReadName = std::string( + const std::string scalarDataReadName = std::string( (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"); - const precice::string_view vectorDataWriteName = std::string( + const std::string vectorDataWriteName = std::string( (solverName == "SolverOne") ? "vectorDataOne" : "vectorDataTwo"); - const precice::string_view vectorDataReadName = std::string( + const std::string vectorDataReadName = std::string( (solverName == "SolverOne") ? "vectorDataTwo" : "vectorDataOne"); const int numberOfVertices = 3; From b3b4db50ebb4acd704fdcbbfce6c48ac59c5cbf9 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 12:28:07 +0100 Subject: [PATCH 07/19] Update dumux-precice/couplingadapter.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> --- dumux-precice/couplingadapter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dumux-precice/couplingadapter.cc b/dumux-precice/couplingadapter.cc index 71da780..caefef8 100644 --- a/dumux-precice/couplingadapter.cc +++ b/dumux-precice/couplingadapter.cc @@ -55,7 +55,7 @@ int CouplingAdapter::getMeshDimensions(const std::string &meshName) const } void CouplingAdapter::setMesh(const std::string &meshName, - std::vector &positions) + const std::vector &positions) { assert(wasCreated_); vertexIDs_ = From fd691040760a1aabf5871b216ce33efb3a8a325f Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 12:29:07 +0100 Subject: [PATCH 08/19] Update examples/dummysolver/main_dummysolver.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> --- examples/dummysolver/main_dummysolver.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/dummysolver/main_dummysolver.cc b/examples/dummysolver/main_dummysolver.cc index cd3d511..60c6f8e 100644 --- a/examples/dummysolver/main_dummysolver.cc +++ b/examples/dummysolver/main_dummysolver.cc @@ -54,8 +54,8 @@ try { const int dimensions = couplingParticipant.getMeshDimensions(meshNameView); assert(dimensions == 3); - const std::string scalarDataWriteName = std::string( - (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"); + const std::string scalarDataWriteName = + (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"; const std::string scalarDataReadName = std::string( (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"); const std::string vectorDataWriteName = std::string( From 35eafa176ac5f66a476563e53113fe69fbe7f291 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 12:48:59 +0100 Subject: [PATCH 09/19] Clean up dummy solver --- examples/dummysolver/main_dummysolver.cc | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/examples/dummysolver/main_dummysolver.cc b/examples/dummysolver/main_dummysolver.cc index 60c6f8e..431d767 100644 --- a/examples/dummysolver/main_dummysolver.cc +++ b/examples/dummysolver/main_dummysolver.cc @@ -52,16 +52,16 @@ try { << preciceConfigFilename << "\", participant name \"" << solverName << "\", and mesh name \"" << meshName << "\".\n"; - const int dimensions = couplingParticipant.getMeshDimensions(meshNameView); + const int dimensions = couplingParticipant.getMeshDimensions(meshName); assert(dimensions == 3); const std::string scalarDataWriteName = (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"; - const std::string scalarDataReadName = std::string( - (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"); - const std::string vectorDataWriteName = std::string( - (solverName == "SolverOne") ? "vectorDataOne" : "vectorDataTwo"); - const std::string vectorDataReadName = std::string( - (solverName == "SolverOne") ? "vectorDataTwo" : "vectorDataOne"); + const std::string scalarDataReadName = + (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"; + const std::string vectorDataWriteName = + (solverName == "SolverOne") ? "vectorDataOne" : "vectorDataTwo"; + const std::string vectorDataReadName = + (solverName == "SolverOne") ? "vectorDataTwo" : "vectorDataOne"; const int numberOfVertices = 3; @@ -82,12 +82,6 @@ try { } } - precice::span writeScalarDataSpan(writeScalarData); - precice::span readScalarDataSpan(readScalarData); - precice::span writeVectorDataSpan(writeVectorData); - precice::span readVectorDataSpan(readVectorData); - precice::span dumuxVertexIDsSpan(dumuxVertexIDs); - std::cout << "DUMMY (" << mpiHelper.rank() << "): Initialize preCICE and set mesh\n"; couplingParticipant.setMesh(meshNameView, vertices); From 8468057d32e173c448878e1932dd2cb4fb348618 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 13:07:02 +0100 Subject: [PATCH 10/19] Using the correct data types --- dumux-precice/couplingadapter.hh | 2 +- examples/dummysolver/main_dummysolver.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dumux-precice/couplingadapter.hh b/dumux-precice/couplingadapter.hh index 298ce54..31ad6d5 100644 --- a/dumux-precice/couplingadapter.hh +++ b/dumux-precice/couplingadapter.hh @@ -147,7 +147,7 @@ public: * Example 3D:\n * [x_1, y_1, z_1, x_2, y_2, z_2,...x_numPoints, y_numPoints, z_numPoints] */ - void setMesh(const std::string &meshName, std::vector &positions); + void setMesh(const std::string &meshName, const std::vector &positions); /*! * @brief Initializes the coupling * diff --git a/examples/dummysolver/main_dummysolver.cc b/examples/dummysolver/main_dummysolver.cc index 431d767..f2c4aef 100644 --- a/examples/dummysolver/main_dummysolver.cc +++ b/examples/dummysolver/main_dummysolver.cc @@ -54,7 +54,7 @@ try { const int dimensions = couplingParticipant.getMeshDimensions(meshName); assert(dimensions == 3); - const std::string scalarDataWriteName = + const std::string scalarDataWriteName = (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"; const std::string scalarDataReadName = (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"; From d08cd9b7f791a8c09ae34eddd5c55dc5fa20849c Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 13:36:39 +0100 Subject: [PATCH 11/19] Further simplifying variable definitions in examples --- dumux-precice/couplingadapter.hh | 3 +- examples/dummysolver/main_dummysolver.cc | 43 +++++++++--------- .../flow-over-cube-3d/ffproblem-reversed.hh | 12 ++--- .../flow-over-cube-3d/main_ff-reversed.cc | 40 ++++++++--------- .../flow-over-cube-3d/main_pm-reversed.cc | 43 +++++++++--------- .../flow-over-cube-3d/pmproblem-reversed.hh | 6 +-- .../flow-over-square-2d/ffproblem-reversed.hh | 12 ++--- examples/ff-pm/flow-over-square-2d/main_ff.cc | 44 +++++++++---------- examples/ff-pm/flow-over-square-2d/main_pm.cc | 44 +++++++++---------- .../flow-over-square-2d/pmproblem-reversed.hh | 6 +-- 10 files changed, 124 insertions(+), 129 deletions(-) diff --git a/dumux-precice/couplingadapter.hh b/dumux-precice/couplingadapter.hh index 31ad6d5..4a56653 100644 --- a/dumux-precice/couplingadapter.hh +++ b/dumux-precice/couplingadapter.hh @@ -147,7 +147,8 @@ public: * Example 3D:\n * [x_1, y_1, z_1, x_2, y_2, z_2,...x_numPoints, y_numPoints, z_numPoints] */ - void setMesh(const std::string &meshName, const std::vector &positions); + void setMesh(const std::string &meshName, + const std::vector &positions); /*! * @brief Initializes the coupling * diff --git a/examples/dummysolver/main_dummysolver.cc b/examples/dummysolver/main_dummysolver.cc index f2c4aef..9d24d95 100644 --- a/examples/dummysolver/main_dummysolver.cc +++ b/examples/dummysolver/main_dummysolver.cc @@ -42,7 +42,6 @@ try { getParamFromGroup("preCICE", "ConfigFileName"); const std::string meshName = getParamFromGroup("preCICE", "MeshName"); - const std::string meshNameView(meshName); auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); couplingParticipant.announceSolver(solverName, preciceConfigFilename, @@ -84,27 +83,27 @@ try { std::cout << "DUMMY (" << mpiHelper.rank() << "): Initialize preCICE and set mesh\n"; - couplingParticipant.setMesh(meshNameView, vertices); + couplingParticipant.setMesh(meshName, vertices); // Create index mapping between DuMuX's index numbering and preCICE's numbering std::cout << "DUMMY (" << mpiHelper.rank() << "): Create index mapping\n"; couplingParticipant.createIndexMapping(dumuxVertexIDs); - couplingParticipant.announceQuantity(meshNameView, scalarDataWriteName); - couplingParticipant.announceQuantity(meshNameView, scalarDataReadName); - couplingParticipant.announceQuantity(meshNameView, vectorDataWriteName); - couplingParticipant.announceQuantity(meshNameView, vectorDataReadName); + couplingParticipant.announceQuantity(meshName, scalarDataWriteName); + couplingParticipant.announceQuantity(meshName, scalarDataReadName); + couplingParticipant.announceQuantity(meshName, vectorDataWriteName); + couplingParticipant.announceQuantity(meshName, vectorDataReadName); if (couplingParticipant.requiresToWriteInitialData()) { std::cout << "DUMMY (" << mpiHelper.rank() << "): Writing initial data\n"; couplingParticipant.writeQuantityVector( - meshNameView, scalarDataWriteName, writeScalarData); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + meshName, scalarDataWriteName, writeScalarData); + couplingParticipant.writeQuantityToOtherSolver(meshName, scalarDataWriteName); couplingParticipant.writeQuantityVector( - meshNameView, vectorDataWriteName, writeVectorData); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + meshName, vectorDataWriteName, writeVectorData); + couplingParticipant.writeQuantityToOtherSolver(meshName, vectorDataWriteName); } std::cout << "DUMMY (" << mpiHelper.rank() << "): Exchange initial\n"; @@ -116,12 +115,12 @@ try { std::cout << "DUMMY (" << mpiHelper.rank() << "): Reading initial data\n"; couplingParticipant.readQuantityFromOtherSolver( - meshNameView, scalarDataReadName, preciceDt); + meshName, scalarDataReadName, preciceDt); couplingParticipant.readQuantityFromOtherSolver( - meshNameView, vectorDataReadName, preciceDt); + meshName, vectorDataReadName, preciceDt); const std::vector &readScalarQuantity = - couplingParticipant.getQuantityVector(meshNameView, + couplingParticipant.getQuantityVector(meshName, scalarDataReadName); std::cout << "DUMMY (" << mpiHelper.rank() << "): Scalar data\n"; @@ -130,7 +129,7 @@ try { std::cout << "\n"; const std::vector &readVectorQuantity = - couplingParticipant.getQuantityVector(meshNameView, + couplingParticipant.getQuantityVector(meshName, vectorDataReadName); std::cout << "DUMMY (" << mpiHelper.rank() << "): Vector data\n"; @@ -175,19 +174,19 @@ try { //Read data std::cout << "DUMMY (" << mpiHelper.rank() << "): Reading data\n"; couplingParticipant.readQuantityFromOtherSolver( - meshNameView, scalarDataReadName, preciceDt); + meshName, scalarDataReadName, preciceDt); couplingParticipant.readQuantityFromOtherSolver( - meshNameView, vectorDataReadName, preciceDt); + meshName, vectorDataReadName, preciceDt); // Check data if (iter > 0) { int offset = (solverName == "SolverOne") ? 0 : 1; const std::vector &readScalarQuantity = - couplingParticipant.getQuantityVector(meshNameView, + couplingParticipant.getQuantityVector(meshName, scalarDataReadName); const std::vector &readVectorQuantity = - couplingParticipant.getQuantityVector(meshNameView, + couplingParticipant.getQuantityVector(meshName, vectorDataReadName); for (int i = 0; i < numberOfVertices; i++) { @@ -234,15 +233,15 @@ try { for (int i = 0; i < numberOfVertices; i++) { const double value = i + iter; couplingParticipant.writeScalarQuantityOnFace( - meshNameView, scalarDataWriteName, dumuxVertexIDs[i], value); + meshName, scalarDataWriteName, dumuxVertexIDs[i], value); } - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + couplingParticipant.writeQuantityToOtherSolver(meshName, scalarDataWriteName); // Write vector data couplingParticipant.writeQuantityVector( - meshNameView, vectorDataWriteName, writeVectorData); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + meshName, vectorDataWriteName, writeVectorData); + couplingParticipant.writeQuantityToOtherSolver(meshName, vectorDataWriteName); preciceDt = couplingParticipant.getMaxTimeStepSize(); couplingParticipant.advance(preciceDt); diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index 815b7f9..d22f663 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -219,8 +219,8 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - std::string meshNameView_("FreeFlowMesh"); - std::string dataNameView_("Velocity"); + std::string meshName_("FreeFlowMesh"); + std::string dataName_("Velocity"); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); @@ -228,7 +228,7 @@ public: if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId); + meshName_, dataName_, faceId); } return values; @@ -250,8 +250,8 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { - std::string meshNameView_("FreeFlowMesh"); - std::string dataNameView_("Pressure"); + std::string meshName_("FreeFlowMesh"); + std::string dataName_("Pressure"); NumEqVector values(0.0); const auto faceId = scvf.index(); @@ -264,7 +264,7 @@ public: values[Indices::momentumYBalanceIdx] = scvf.directionSign() * (couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId) - + meshName_, dataName_, faceId) - initialAtPos(scvf.center())[Indices::pressureIdx]); } return values; diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index 15dbc0d..5af0930 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -99,7 +99,7 @@ template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const std::string meshNameView, + const std::string meshName, const std::string dataNameView) { const auto &gridGeometry = problem.gridGeometry(); @@ -154,7 +154,7 @@ void setInterfaceVelocities(const Problem &problem, const auto v = velocityAtInterface(elemFaceVars, scvf)[scvf.directionIndex()]; couplingParticipant.writeScalarQuantityOnFace( - meshNameView, dataNameView, scvf.index(), v); + meshName, dataNameView, scvf.index(), v); } } } @@ -162,7 +162,7 @@ void setInterfaceVelocities(const Problem &problem, template std::tuple writeVelocitiesOnInterfaceToFile( - const std::string &meshNameView, + const std::string &meshName, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -179,7 +179,7 @@ std::tuple writeVelocitiesOnInterfaceToFile( std::ofstream ofs(filename + ".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; - if (couplingParticipant.getMeshDimensions(meshNameView) == 3) + if (couplingParticipant.getMeshDimensions(meshName) == 3) ofs << "z,"; ofs << "velocityY" << "\n"; @@ -196,7 +196,7 @@ std::tuple writeVelocitiesOnInterfaceToFile( if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); for (int i = 0; - i < couplingParticipant.getMeshDimensions(meshNameView); + i < couplingParticipant.getMeshDimensions(meshName); ++i) { ofs << pos[i] << ","; } @@ -223,7 +223,7 @@ template -void writePressuresOnInterfaceToFile(const std::string &meshNameView, +void writePressuresOnInterfaceToFile(const std::string &meshName, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -241,7 +241,7 @@ void writePressuresOnInterfaceToFile(const std::string &meshNameView, std::ofstream ofs(filename + ".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; - if (couplingParticipant.getMeshDimensions(meshNameView) == 3) + if (couplingParticipant.getMeshDimensions(meshName) == 3) ofs << "z,"; ofs << "pressure" << "\n"; @@ -255,7 +255,7 @@ void writePressuresOnInterfaceToFile(const std::string &meshNameView, if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); for (int i = 0; - i < couplingParticipant.getMeshDimensions(meshNameView); + i < couplingParticipant.getMeshDimensions(meshName); ++i) { ofs << pos[i] << ","; } @@ -334,8 +334,8 @@ try { couplingParticipant.announceSolver("FreeFlow", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); - const std::string meshNameView("FreeFlowMesh"); - const int dim = couplingParticipant.getMeshDimensions(meshNameView); + const std::string meshName("FreeFlowMesh"); + const int dim = couplingParticipant.getMeshDimensions(meshName); std::cout << dim << " " << int(FreeFlowGridGeometry::GridView::dimension) << std::endl; if (dim != int(FreeFlowGridGeometry::GridView::dimension)) @@ -368,13 +368,13 @@ try { const auto numberOfPoints = coords.size() / dim; std::vector coordsSpan(coords); - couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.setMesh(meshName, coordsSpan); couplingParticipant.createIndexMapping(coupledScvfIndices); const std::string dataNameViewV("Velocity"); const std::string dataNameViewP("Pressure"); - couplingParticipant.announceQuantity(meshNameView, dataNameViewV); - couplingParticipant.announceQuantity(meshNameView, dataNameViewP); + couplingParticipant.announceQuantity(meshName, dataNameViewV); + couplingParticipant.announceQuantity(meshName, dataNameViewP); // apply initial solution for instationary problems freeFlowProblem->applyInitialSolution(sol); @@ -401,8 +401,8 @@ try { if (couplingParticipant.requiresToWriteInitialData()) { setInterfacePressures(*freeFlowProblem, *freeFlowGridVariables, sol, - meshNameView, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + meshName, dataNameViewP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameViewP); } couplingParticipant.initialize(); @@ -440,7 +440,7 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshNameView, + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameViewV, dt); // solve the non-linear system nonLinearSolver.solve(sol); @@ -448,8 +448,8 @@ try { // TODO setInterfacePressures(*freeFlowProblem, *freeFlowGridVariables, sol, - meshNameView, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + meshName, dataNameViewP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameViewP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index ca0e12f..3b554e2 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -115,8 +115,8 @@ template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const std::string meshNameView, - const std::string dataNameView) + const std::string meshName, + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -137,7 +137,7 @@ void setInterfacePressures(const Problem &problem, pressureAtInterface(problem, element, gridGeometry, elemVolVars, scvf, elemFluxVarsCache); couplingParticipant.writeScalarQuantityOnFace( - meshNameView, dataNameView, scvf.index(), p); + meshName, dataName, scvf.index(), p); } } } @@ -179,8 +179,8 @@ template coordsSpan(coords); - couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); - const std::string dataNameViewV("Velocity"); - const std::string dataNameViewP("Pressure"); - couplingParticipant.announceQuantity(meshNameView, dataNameViewP); - couplingParticipant.announceQuantity(meshNameView, dataNameViewV); + const std::string dataNameV("Velocity"); + const std::string dataNameP("Pressure"); + couplingParticipant.announceQuantity(meshName, dataNameP); + couplingParticipant.announceQuantity(meshName, dataNameV); darcyProblem->applyInitialSolution(sol); @@ -440,9 +439,9 @@ try { //TODO setInterfaceVelocities(*darcyProblem, *darcyGridVariables, sol, - meshNameView, dataNameViewV); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewV); + meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, + dataNameV); } couplingParticipant.initialize(); @@ -478,16 +477,16 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshNameView, - dataNameViewP, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, + dataNameP, dt); // solve the non-linear system nonLinearSolver.solve(sol); setInterfaceVelocities(*darcyProblem, *darcyGridVariables, sol, - meshNameView, dataNameViewV); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewV); + meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, + dataNameV); couplingParticipant.advance(dt); preciceDt = couplingParticipant.getMaxTimeStepSize(); diff --git a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh index 84169bc..b621aa9 100644 --- a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh @@ -181,8 +181,8 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - std::string meshNameView_("DarcyMesh"); - std::string dataNameView_("Pressure"); + std::string meshName_("DarcyMesh"); + std::string dataName_("Pressure"); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); @@ -190,7 +190,7 @@ public: const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) values = couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId); + meshName_, dataName_, faceId); return values; } diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index 1aefeee..bc2d1e1 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -218,8 +218,8 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - std::string meshNameView_("FreeFlowMesh"); - std::string dataNameView_("Velocity"); + std::string meshName_("FreeFlowMesh"); + std::string dataName_("Velocity"); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); @@ -227,7 +227,7 @@ public: if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId); + meshName_, dataName_, faceId); } return values; @@ -249,8 +249,8 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { - std::string meshNameView_("FreeFlowMesh"); - std::string dataNameView_("Pressure"); + std::string meshName_("FreeFlowMesh"); + std::string dataName_("Pressure"); NumEqVector values(0.0); const auto faceId = scvf.index(); @@ -263,7 +263,7 @@ public: values[Indices::momentumYBalanceIdx] = scvf.directionSign() * (couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId) - + meshName_, dataName_, faceId) - initialAtPos(scvf.center())[Indices::pressureIdx]); } return values; diff --git a/examples/ff-pm/flow-over-square-2d/main_ff.cc b/examples/ff-pm/flow-over-square-2d/main_ff.cc index 787312a..9fb6dc4 100644 --- a/examples/ff-pm/flow-over-square-2d/main_ff.cc +++ b/examples/ff-pm/flow-over-square-2d/main_ff.cc @@ -99,8 +99,8 @@ template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const std::string meshNameView, - const std::string dataNameView) + const std::string meshName, + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -154,7 +154,7 @@ void setInterfaceVelocities(const Problem &problem, const auto v = velocityAtInterface(elemFaceVars, scvf)[scvf.directionIndex()]; couplingParticipant.writeScalarQuantityOnFace( - meshNameView, dataNameView, scvf.index(), v); + meshName, dataName, scvf.index(), v); } } } @@ -224,8 +224,8 @@ try { couplingParticipant.announceSolver("FreeFlow", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); - const std::string meshNameView("FreeFlowMesh"); // mesh name - const int dim = couplingParticipant.getMeshDimensions(meshNameView); + const std::string meshName("FreeFlowMesh"); // mesh name + const int dim = couplingParticipant.getMeshDimensions(meshName); std::cout << dim << " " << int(FreeFlowGridGeometry::GridView::dimension) << std::endl; if (dim != int(FreeFlowGridGeometry::GridView::dimension)) @@ -256,15 +256,13 @@ try { } } - const auto numberOfPoints = coords.size() / dim; - std::vector coordsSpan(coords); - couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); - const std::string dataNameViewV("Velocity"); - const std::string dataNameViewP("Pressure"); - couplingParticipant.announceQuantity(meshNameView, dataNameViewV); - couplingParticipant.announceQuantity(meshNameView, dataNameViewP); + const std::string dataNameV("Velocity"); + const std::string dataNameP("Pressure"); + couplingParticipant.announceQuantity(meshName, dataNameV); + couplingParticipant.announceQuantity(meshName, dataNameP); // apply initial solution for instationary problems freeFlowProblem->applyInitialSolution(sol); @@ -291,9 +289,9 @@ try { if (couplingParticipant.requiresToWriteInitialData()) { setInterfacePressures(*freeFlowProblem, *freeFlowGridVariables, sol, - meshNameView, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewP); + meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, + dataNameP); } couplingParticipant.initialize(); @@ -330,17 +328,17 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshNameView, - dataNameViewV, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, + dataNameV, dt); // solve the non-linear system nonLinearSolver.solve(sol); // TODO setInterfacePressures(*freeFlowProblem, *freeFlowGridVariables, sol, - meshNameView, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewP); + meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, + dataNameP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); vtkTime += 1.; diff --git a/examples/ff-pm/flow-over-square-2d/main_pm.cc b/examples/ff-pm/flow-over-square-2d/main_pm.cc index 9f3a2f5..6481ea4 100644 --- a/examples/ff-pm/flow-over-square-2d/main_pm.cc +++ b/examples/ff-pm/flow-over-square-2d/main_pm.cc @@ -115,8 +115,8 @@ template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const std::string meshNameView, - const std::string dataNameView) + const std::string meshName, + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -137,7 +137,7 @@ void setInterfacePressures(const Problem &problem, pressureAtInterface(problem, element, gridGeometry, elemVolVars, scvf, elemFluxVarsCache); couplingParticipant.writeScalarQuantityOnFace( - meshNameView, dataNameView, scvf.index(), p); + meshName, dataName, scvf.index(), p); } } } @@ -179,8 +179,8 @@ template coordsSpan(coords); - couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); - const std::string dataNameViewV("Velocity"); - const std::string dataNameViewP("Pressure"); - couplingParticipant.announceQuantity(meshNameView, dataNameViewP); - couplingParticipant.announceQuantity(meshNameView, dataNameViewV); + const std::string dataNameV("Velocity"); + const std::string dataNameP("Pressure"); + couplingParticipant.announceQuantity(meshName, dataNameP); + couplingParticipant.announceQuantity(meshName, dataNameV); darcyProblem->applyInitialSolution(sol); @@ -334,9 +332,9 @@ try { //TODO setInterfaceVelocities(*darcyProblem, *darcyGridVariables, sol, - meshNameView, dataNameViewV); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewV); + meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, + dataNameV); } couplingParticipant.initialize(); @@ -372,16 +370,16 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshNameView, - dataNameViewP, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, + dataNameP, dt); // solve the non-linear system nonLinearSolver.solve(sol); setInterfaceVelocities(*darcyProblem, *darcyGridVariables, sol, - meshNameView, dataNameViewV); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewV); + meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, + dataNameV); couplingParticipant.advance(dt); preciceDt = couplingParticipant.getMaxTimeStepSize(); diff --git a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh index a7cdd24..f22c105 100644 --- a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh @@ -180,8 +180,8 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - std::string meshNameView_("DarcyMesh"); - std::string dataNameView_("Pressure"); + std::string meshName_("DarcyMesh"); + std::string dataName_("Pressure"); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); @@ -189,7 +189,7 @@ public: const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) values = couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId); + meshName_, dataName_, faceId); return values; } From 87f0aba3729d221a32f1e00ec39034c8697826a5 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 13:50:18 +0100 Subject: [PATCH 12/19] Formatting --- examples/dummysolver/main_dummysolver.cc | 18 ++++++++--------- .../flow-over-cube-3d/main_ff-reversed.cc | 16 ++++++--------- .../flow-over-cube-3d/main_pm-reversed.cc | 20 ++++++++----------- examples/ff-pm/flow-over-square-2d/main_ff.cc | 20 ++++++++----------- examples/ff-pm/flow-over-square-2d/main_pm.cc | 20 ++++++++----------- 5 files changed, 38 insertions(+), 56 deletions(-) diff --git a/examples/dummysolver/main_dummysolver.cc b/examples/dummysolver/main_dummysolver.cc index 9d24d95..e3e8dbc 100644 --- a/examples/dummysolver/main_dummysolver.cc +++ b/examples/dummysolver/main_dummysolver.cc @@ -97,12 +97,12 @@ try { if (couplingParticipant.requiresToWriteInitialData()) { std::cout << "DUMMY (" << mpiHelper.rank() << "): Writing initial data\n"; - couplingParticipant.writeQuantityVector( - meshName, scalarDataWriteName, writeScalarData); + couplingParticipant.writeQuantityVector(meshName, scalarDataWriteName, + writeScalarData); couplingParticipant.writeQuantityToOtherSolver(meshName, scalarDataWriteName); - couplingParticipant.writeQuantityVector( - meshName, vectorDataWriteName, writeVectorData); + couplingParticipant.writeQuantityVector(meshName, vectorDataWriteName, + writeVectorData); couplingParticipant.writeQuantityToOtherSolver(meshName, vectorDataWriteName); } @@ -120,8 +120,7 @@ try { meshName, vectorDataReadName, preciceDt); const std::vector &readScalarQuantity = - couplingParticipant.getQuantityVector(meshName, - scalarDataReadName); + couplingParticipant.getQuantityVector(meshName, scalarDataReadName); std::cout << "DUMMY (" << mpiHelper.rank() << "): Scalar data\n"; for (const double &value : readScalarQuantity) @@ -129,8 +128,7 @@ try { std::cout << "\n"; const std::vector &readVectorQuantity = - couplingParticipant.getQuantityVector(meshName, - vectorDataReadName); + couplingParticipant.getQuantityVector(meshName, vectorDataReadName); std::cout << "DUMMY (" << mpiHelper.rank() << "): Vector data\n"; for (const double &value : readVectorQuantity) @@ -239,8 +237,8 @@ try { scalarDataWriteName); // Write vector data - couplingParticipant.writeQuantityVector( - meshName, vectorDataWriteName, writeVectorData); + couplingParticipant.writeQuantityVector(meshName, vectorDataWriteName, + writeVectorData); couplingParticipant.writeQuantityToOtherSolver(meshName, vectorDataWriteName); preciceDt = couplingParticipant.getMaxTimeStepSize(); diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index 5af0930..2130bed 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -196,8 +196,7 @@ std::tuple writeVelocitiesOnInterfaceToFile( if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); for (int i = 0; - i < couplingParticipant.getMeshDimensions(meshName); - ++i) { + i < couplingParticipant.getMeshDimensions(meshName); ++i) { ofs << pos[i] << ","; } const double v = problem.dirichlet(element, scvf)[1]; @@ -255,8 +254,7 @@ void writePressuresOnInterfaceToFile(const std::string &meshName, if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); for (int i = 0; - i < couplingParticipant.getMeshDimensions(meshName); - ++i) { + i < couplingParticipant.getMeshDimensions(meshName); ++i) { ofs << pos[i] << ","; } const double p = pressureAtInterface( @@ -402,8 +400,7 @@ try { setInterfacePressures(*freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshName, - dataNameViewP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameViewP); } couplingParticipant.initialize(); @@ -440,8 +437,8 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshName, - dataNameViewV, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameViewV, + dt); // solve the non-linear system nonLinearSolver.solve(sol); @@ -449,8 +446,7 @@ try { setInterfacePressures(*freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshName, - dataNameViewP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameViewP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); vtkTime += 1.; diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index 3b554e2..fdd35e7 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -437,11 +437,9 @@ try { using FluxVariables = GetPropType; if (couplingParticipant.requiresToWriteInitialData()) { //TODO - setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol, - meshName, dataNameV); - couplingParticipant.writeQuantityToOtherSolver(meshName, - dataNameV); + setInterfaceVelocities( + *darcyProblem, *darcyGridVariables, sol, meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameV); } couplingParticipant.initialize(); @@ -477,16 +475,14 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshName, - dataNameP, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameP, + dt); // solve the non-linear system nonLinearSolver.solve(sol); - setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol, - meshName, dataNameV); - couplingParticipant.writeQuantityToOtherSolver(meshName, - dataNameV); + setInterfaceVelocities( + *darcyProblem, *darcyGridVariables, sol, meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameV); couplingParticipant.advance(dt); preciceDt = couplingParticipant.getMaxTimeStepSize(); diff --git a/examples/ff-pm/flow-over-square-2d/main_ff.cc b/examples/ff-pm/flow-over-square-2d/main_ff.cc index 9fb6dc4..7d72f90 100644 --- a/examples/ff-pm/flow-over-square-2d/main_ff.cc +++ b/examples/ff-pm/flow-over-square-2d/main_ff.cc @@ -287,11 +287,9 @@ try { GetPropType; if (couplingParticipant.requiresToWriteInitialData()) { - setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol, - meshName, dataNameP); - couplingParticipant.writeQuantityToOtherSolver(meshName, - dataNameP); + setInterfacePressures( + *freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameP); } couplingParticipant.initialize(); @@ -328,17 +326,15 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshName, - dataNameV, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameV, + dt); // solve the non-linear system nonLinearSolver.solve(sol); // TODO - setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol, - meshName, dataNameP); - couplingParticipant.writeQuantityToOtherSolver(meshName, - dataNameP); + setInterfacePressures( + *freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); vtkTime += 1.; diff --git a/examples/ff-pm/flow-over-square-2d/main_pm.cc b/examples/ff-pm/flow-over-square-2d/main_pm.cc index 6481ea4..29b37cd 100644 --- a/examples/ff-pm/flow-over-square-2d/main_pm.cc +++ b/examples/ff-pm/flow-over-square-2d/main_pm.cc @@ -330,11 +330,9 @@ try { using FluxVariables = GetPropType; if (couplingParticipant.requiresToWriteInitialData()) { //TODO - setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol, - meshName, dataNameV); - couplingParticipant.writeQuantityToOtherSolver(meshName, - dataNameV); + setInterfaceVelocities( + *darcyProblem, *darcyGridVariables, sol, meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameV); } couplingParticipant.initialize(); @@ -370,16 +368,14 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshName, - dataNameP, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameP, + dt); // solve the non-linear system nonLinearSolver.solve(sol); - setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol, - meshName, dataNameV); - couplingParticipant.writeQuantityToOtherSolver(meshName, - dataNameV); + setInterfaceVelocities( + *darcyProblem, *darcyGridVariables, sol, meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameV); couplingParticipant.advance(dt); preciceDt = couplingParticipant.getMaxTimeStepSize(); From 760ec0e48dde9c4d114e2a68c2f4c8f42c02aa4e Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 14:05:10 +0100 Subject: [PATCH 13/19] Formatting --- examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh | 4 ++-- examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index d22f663..3243d70 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -227,8 +227,8 @@ public: const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = - couplingParticipant_.getScalarQuantityOnFace( - meshName_, dataName_, faceId); + couplingParticipant_.getScalarQuantityOnFace(meshName_, + dataName_, faceId); } return values; diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index bc2d1e1..f52b962 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -226,8 +226,8 @@ public: const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = - couplingParticipant_.getScalarQuantityOnFace( - meshName_, dataName_, faceId); + couplingParticipant_.getScalarQuantityOnFace(meshName_, + dataName_, faceId); } return values; From 1c9389386f3a75c72bd19fd2c307f7dbc63376b2 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 14:36:11 +0100 Subject: [PATCH 14/19] Update dumux-precice/couplingadapter.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> --- dumux-precice/couplingadapter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dumux-precice/couplingadapter.cc b/dumux-precice/couplingadapter.cc index caefef8..d8ed375 100644 --- a/dumux-precice/couplingadapter.cc +++ b/dumux-precice/couplingadapter.cc @@ -163,7 +163,7 @@ std::vector &CouplingAdapter::getQuantityVector( void CouplingAdapter::writeQuantityVector(const std::string &meshName, const std::string &dataName, - std::vector &values) + const std::vector &values) { std::vector &dataVector = getQuantityVector(meshName, dataName); assert(dataVector.size() == values.size()); From 16b0bd3732ade7f42bbfff5105eff6fb88223145 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 14:36:22 +0100 Subject: [PATCH 15/19] Update dumux-precice/couplingadapter.hh Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> --- dumux-precice/couplingadapter.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dumux-precice/couplingadapter.hh b/dumux-precice/couplingadapter.hh index 4a56653..7632cf9 100644 --- a/dumux-precice/couplingadapter.hh +++ b/dumux-precice/couplingadapter.hh @@ -253,7 +253,7 @@ public: */ void writeQuantityVector(const std::string &meshName, const std::string &dataName, - std::vector &values); + const std::vector &values); /*! * @brief Checks whether face with given identifier is part of coupling interface. * From d4368412c40c109d27fc5d06adfe4fe374deddd4 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 14:36:30 +0100 Subject: [PATCH 16/19] Update examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> --- examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index 2130bed..f504bef 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -100,7 +100,7 @@ void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, const std::string meshName, - const std::string dataNameView) + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); From 7b824319a3ac8cb65fb2ecb9b4ba34017d34ed9f Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 14:36:38 +0100 Subject: [PATCH 17/19] Update examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> --- examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index fdd35e7..6326004 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -270,7 +270,7 @@ std::tuple writeVelocitiesOnInterfaceToFile( template void writePressuresOnInterfaceToFile(const std::string &meshName, - std::string &filename, + const std::string &filename, const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol) From 2e79346500ae20ee923a755cc3351e568b073e52 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 14:43:46 +0100 Subject: [PATCH 18/19] Removing last traces of _View variables from example codes --- .../flow-over-cube-3d/main_ff-reversed.cc | 34 ++++++++----------- .../flow-over-cube-3d/main_pm-reversed.cc | 1 - 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index f504bef..fcab969 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -123,7 +123,7 @@ void setInterfacePressures(const Problem &problem, problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, elemFluxVarsCache); couplingParticipant.writeScalarQuantityOnFace( - meshName, dataNameView, scvf.index(), p); + meshName, dataName, scvf.index(), p); } } } @@ -134,7 +134,7 @@ void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, const std::string meshName, - const std::string dataNameView) + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -154,7 +154,7 @@ void setInterfaceVelocities(const Problem &problem, const auto v = velocityAtInterface(elemFaceVars, scvf)[scvf.directionIndex()]; couplingParticipant.writeScalarQuantityOnFace( - meshName, dataNameView, scvf.index(), v); + meshName, dataName, scvf.index(), v); } } } @@ -364,15 +364,13 @@ try { } } - const auto numberOfPoints = coords.size() / dim; - std::vector coordsSpan(coords); - couplingParticipant.setMesh(meshName, coordsSpan); + couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); - const std::string dataNameViewV("Velocity"); - const std::string dataNameViewP("Pressure"); - couplingParticipant.announceQuantity(meshName, dataNameViewV); - couplingParticipant.announceQuantity(meshName, dataNameViewP); + const std::string dataNameV("Velocity"); + const std::string dataNameP("Pressure"); + couplingParticipant.announceQuantity(meshName, dataNameV); + couplingParticipant.announceQuantity(meshName, dataNameP); // apply initial solution for instationary problems freeFlowProblem->applyInitialSolution(sol); @@ -397,10 +395,9 @@ try { GetPropType; if (couplingParticipant.requiresToWriteInitialData()) { - setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol, - meshName, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameViewP); + setInterfacePressures( + *freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameP); } couplingParticipant.initialize(); @@ -437,16 +434,15 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameViewV, + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameV, dt); // solve the non-linear system nonLinearSolver.solve(sol); // TODO - setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol, - meshName, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameViewP); + setInterfacePressures( + *freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); vtkTime += 1.; diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index 6326004..cb49357 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -401,7 +401,6 @@ try { } } - const auto numberOfPoints = coords.size() / dim; couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); From 48ad127dbe1e753962137011339c15293ea94a06 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 15:35:20 +0100 Subject: [PATCH 19/19] Use string literals in adapter API of the problem files (*.hh) --- examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh | 10 +++------- examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh | 4 +--- .../ff-pm/flow-over-square-2d/ffproblem-reversed.hh | 10 +++------- .../ff-pm/flow-over-square-2d/pmproblem-reversed.hh | 4 +--- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index 3243d70..df1bce4 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -219,16 +219,14 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - std::string meshName_("FreeFlowMesh"); - std::string dataName_("Velocity"); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = - couplingParticipant_.getScalarQuantityOnFace(meshName_, - dataName_, faceId); + couplingParticipant_.getScalarQuantityOnFace( + "FreeFlowMesh", "Velocity", faceId); } return values; @@ -250,8 +248,6 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { - std::string meshName_("FreeFlowMesh"); - std::string dataName_("Pressure"); NumEqVector values(0.0); const auto faceId = scvf.index(); @@ -264,7 +260,7 @@ public: values[Indices::momentumYBalanceIdx] = scvf.directionSign() * (couplingParticipant_.getScalarQuantityOnFace( - meshName_, dataName_, faceId) - + "FreeFlowMesh", "Pressure", faceId) - initialAtPos(scvf.center())[Indices::pressureIdx]); } return values; diff --git a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh index b621aa9..4413b36 100644 --- a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh @@ -181,8 +181,6 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - std::string meshName_("DarcyMesh"); - std::string dataName_("Pressure"); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); @@ -190,7 +188,7 @@ public: const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) values = couplingParticipant_.getScalarQuantityOnFace( - meshName_, dataName_, faceId); + "DarcyMesh", "Pressure", faceId); return values; } diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index f52b962..4d6109e 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -218,16 +218,14 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - std::string meshName_("FreeFlowMesh"); - std::string dataName_("Velocity"); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = - couplingParticipant_.getScalarQuantityOnFace(meshName_, - dataName_, faceId); + couplingParticipant_.getScalarQuantityOnFace( + "FreeFlowMesh", "Velocity", faceId); } return values; @@ -249,8 +247,6 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { - std::string meshName_("FreeFlowMesh"); - std::string dataName_("Pressure"); NumEqVector values(0.0); const auto faceId = scvf.index(); @@ -263,7 +259,7 @@ public: values[Indices::momentumYBalanceIdx] = scvf.directionSign() * (couplingParticipant_.getScalarQuantityOnFace( - meshName_, dataName_, faceId) - + "FreeFlowMesh", "Pressure", faceId) - initialAtPos(scvf.center())[Indices::pressureIdx]); } return values; diff --git a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh index f22c105..e21868a 100644 --- a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh @@ -180,8 +180,6 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - std::string meshName_("DarcyMesh"); - std::string dataName_("Pressure"); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); @@ -189,7 +187,7 @@ public: const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) values = couplingParticipant_.getScalarQuantityOnFace( - meshName_, dataName_, faceId); + "DarcyMesh", "Pressure", faceId); return values; }