Skip to content

Commit e27f5d4

Browse files
authored
Use configuration reader in dumux-adapter (#713)
Related PR in the adapter: precice/dumux-adapter#68
1 parent 9894b79 commit e27f5d4

7 files changed

Lines changed: 51 additions & 34 deletions

File tree

changelog-entries/713.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Ported the solvers using the DuMux adapter to configure the adapter via parameter file.

free-flow-over-porous-media/free-flow-dumux/params.input

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@ AddVelocity = 1
3535

3636
[Output]
3737
EnableCSVWriter = false
38+
39+
[precice-adapter-config]
40+
participant_name = Free-Flow
41+
precice_config_file_path = ../precice-config.xml
42+
interfaces.1.mesh_name = Free-Flow-Mesh
43+
interfaces.1.read_data.1.name = Velocity
44+
interfaces.1.write_data.1.name = Pressure

free-flow-over-porous-media/free-flow-dumux/solver-dumux/main.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,10 @@ int main(int argc, char **argv)
353353
std::string preciceConfigFilename = "../precice-config.xml";
354354

355355
auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance();
356-
couplingParticipant.announceSolver("Free-Flow", preciceConfigFilename,
357-
mpiHelper.rank(), mpiHelper.size());
356+
couplingParticipant.announceConfig(mpiHelper.rank(), mpiHelper.size());
358357

359-
const std::string meshName("Free-Flow-Mesh"); // mesh name
360-
const int dim = couplingParticipant.getMeshDimensions(meshName);
358+
const std::string meshName = couplingParticipant.getMeshNames()[0]; // mesh name
359+
const int dim = couplingParticipant.getMeshDimensions(meshName);
361360
std::cout << dim << " " << int(MassGridGeometry::GridView::dimension)
362361
<< std::endl;
363362
if (dim != int(MassGridGeometry::GridView::dimension))
@@ -393,10 +392,8 @@ int main(int argc, char **argv)
393392
couplingParticipant.setMesh(meshName, coords);
394393
couplingParticipant.createIndexMapping(coupledScvfIndices);
395394

396-
const std::string dataNameV("Velocity");
397-
const std::string dataNameP("Pressure");
398-
couplingParticipant.announceQuantity(meshName, dataNameV);
399-
couplingParticipant.announceQuantity(meshName, dataNameP);
395+
const std::string dataNameV = couplingParticipant.getReadDataNamesOnMesh(meshName)[0];
396+
const std::string dataNameP = couplingParticipant.getWriteDataNamesOnMesh(meshName)[0];
400397

401398
// apply initial solution for instationary problems
402399
momentumProblem->applyInitialSolution(sol[momentumIdx]);

free-flow-over-porous-media/porous-media-dumux/params.input

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,10 @@ AlphaBeaversJoseph = 1.0
1616

1717
[Vtk]
1818
AddVelocity = 1
19+
20+
[precice-adapter-config]
21+
participant_name = Porous-Media
22+
precice_config_file_path = ../precice-config.xml
23+
interfaces.1.mesh_name = Porous-Media-Mesh
24+
interfaces.1.read_data.1.name = Pressure
25+
interfaces.1.write_data.1.name = Velocity

free-flow-over-porous-media/porous-media-dumux/solver-dumux/main.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,10 @@ int main(int argc, char **argv)
166166
std::string preciceConfigFilename = "../precice-config.xml";
167167

168168
auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance();
169-
couplingParticipant.announceSolver("Porous-Media", preciceConfigFilename,
170-
mpiHelper.rank(), mpiHelper.size());
169+
couplingParticipant.announceConfig(mpiHelper.rank(), mpiHelper.size());
171170

172-
const std::string meshName("Porous-Media-Mesh");
173-
const int dim = couplingParticipant.getMeshDimensions(meshName);
171+
const std::string meshName = couplingParticipant.getMeshNames()[0];
172+
const int dim = couplingParticipant.getMeshDimensions(meshName);
174173
std::cout << dim << " " << int(DarcyGridGeometry::GridView::dimension)
175174
<< std::endl;
176175
if (dim != int(DarcyGridGeometry::GridView::dimension))
@@ -204,10 +203,8 @@ int main(int argc, char **argv)
204203
couplingParticipant.setMesh(meshName, coords);
205204
couplingParticipant.createIndexMapping(coupledScvfIndices);
206205

207-
const std::string dataNameV("Velocity");
208-
const std::string dataNameP("Pressure");
209-
couplingParticipant.announceQuantity(meshName, dataNameP);
210-
couplingParticipant.announceQuantity(meshName, dataNameV);
206+
const std::string dataNameV = couplingParticipant.getWriteDataNamesOnMesh(meshName)[0];
207+
const std::string dataNameP = couplingParticipant.getReadDataNamesOnMesh(meshName)[0];
211208

212209
darcyProblem->applyInitialSolution(sol);
213210

two-scale-heat-conduction/macro-dumux/appl/main.cc

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,15 @@ int main(int argc, char **argv)
9393
// - Name of solver
9494
// - What rank of how many ranks this instance is
9595
// Configure preCICE. For now the config file is hardcoded.
96-
std::string preciceConfigFilename = "../precice-config.xml";
97-
const std::string meshName = "Macro-Mesh";
98-
if (argc > 2)
99-
preciceConfigFilename = argv[argc - 1];
96+
std::string meshName;
10097

10198
auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance();
10299

103100
const auto runWithCoupling = getParam<bool>("Precice.RunWithCoupling");
104101

105102
if (runWithCoupling) {
106-
couplingParticipant.announceSolver("Macro", preciceConfigFilename,
107-
mpiHelper.rank(), mpiHelper.size());
103+
couplingParticipant.announceConfig(mpiHelper.rank(), mpiHelper.size());
104+
meshName = couplingParticipant.getMeshNames()[0];
108105
// verify that dimensions match
109106
const int preciceDim = couplingParticipant.getMeshDimensions(meshName);
110107
const int dim = int(leafGridView.dimension);
@@ -151,20 +148,20 @@ int main(int argc, char **argv)
151148
}
152149

153150
// initialize the coupling data
154-
const std::string readDatak00 = "K00";
155-
const std::string readDatak01 = "K01";
156-
const std::string readDatak10 = "K10";
157-
const std::string readDatak11 = "K11";
158-
const std::string readDataPorosity = "Porosity";
159-
const std::string writeDataConcentration = "Concentration";
151+
std::string readDatak00;
152+
std::string readDatak01;
153+
std::string readDatak10;
154+
std::string readDatak11;
155+
std::string readDataPorosity;
156+
std::string writeDataConcentration;
160157

161158
if (runWithCoupling) {
162-
couplingParticipant.announceQuantity(meshName, readDatak00);
163-
couplingParticipant.announceQuantity(meshName, readDatak01);
164-
couplingParticipant.announceQuantity(meshName, readDatak10);
165-
couplingParticipant.announceQuantity(meshName, readDatak11);
166-
couplingParticipant.announceQuantity(meshName, readDataPorosity);
167-
couplingParticipant.announceQuantity(meshName, writeDataConcentration);
159+
readDatak00 = couplingParticipant.getReadDataNamesOnMesh(meshName)[0];
160+
readDatak01 = couplingParticipant.getReadDataNamesOnMesh(meshName)[1];
161+
readDatak10 = couplingParticipant.getReadDataNamesOnMesh(meshName)[2];
162+
readDatak11 = couplingParticipant.getReadDataNamesOnMesh(meshName)[3];
163+
readDataPorosity = couplingParticipant.getReadDataNamesOnMesh(meshName)[4];
164+
writeDataConcentration = couplingParticipant.getWriteDataNamesOnMesh(meshName)[0];
168165
}
169166

170167
// the solution vector (initialized with zeros) NElements x 2(pressure,

two-scale-heat-conduction/macro-dumux/params.input

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,14 @@ Pressure = 0.0
4343

4444
[Precice]
4545
RunWithCoupling = true
46+
47+
[precice-adapter-config]
48+
participant_name = Macro
49+
precice_config_file_path = ../precice-config.xml
50+
interfaces.1.mesh_name = Macro-Mesh
51+
interfaces.1.read_data.1.name = K00
52+
interfaces.1.read_data.2.name = K01
53+
interfaces.1.read_data.3.name = K10
54+
interfaces.1.read_data.4.name = K11
55+
interfaces.1.read_data.5.name = Porosity
56+
interfaces.1.write_data.1.name = Concentration

0 commit comments

Comments
 (0)