diff --git a/changelog-entries/699.md b/changelog-entries/699.md new file mode 100644 index 000000000..93d664189 --- /dev/null +++ b/changelog-entries/699.md @@ -0,0 +1 @@ +- Adhered to the participant, data, and mesh naming rules in the two-scale heat conduction case [#699](https://github.com/precice/tutorials/pull/699) diff --git a/two-scale-heat-conduction/images/tutorials-two-scale-heat-conduction-precice-config.png b/two-scale-heat-conduction/images/tutorials-two-scale-heat-conduction-precice-config.png index b798f6fe3..f2cc2ad5e 100644 Binary files a/two-scale-heat-conduction/images/tutorials-two-scale-heat-conduction-precice-config.png and b/two-scale-heat-conduction/images/tutorials-two-scale-heat-conduction-precice-config.png differ diff --git a/two-scale-heat-conduction/macro-dumux/appl/main.cc b/two-scale-heat-conduction/macro-dumux/appl/main.cc index 5bbd1dd9c..5fdc0538c 100644 --- a/two-scale-heat-conduction/macro-dumux/appl/main.cc +++ b/two-scale-heat-conduction/macro-dumux/appl/main.cc @@ -94,7 +94,7 @@ int main(int argc, char **argv) // - What rank of how many ranks this instance is // Configure preCICE. For now the config file is hardcoded. std::string preciceConfigFilename = "../precice-config.xml"; - const std::string meshName = "macro-mesh"; + const std::string meshName = "Macro-Mesh"; if (argc > 2) preciceConfigFilename = argv[argc - 1]; @@ -103,7 +103,7 @@ int main(int argc, char **argv) const auto runWithCoupling = getParam("Precice.RunWithCoupling"); if (runWithCoupling) { - couplingParticipant.announceSolver("macro-heat", preciceConfigFilename, + couplingParticipant.announceSolver("Macro", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); // verify that dimensions match const int preciceDim = couplingParticipant.getMeshDimensions(meshName); @@ -151,13 +151,12 @@ int main(int argc, char **argv) } // initialize the coupling data - const std::string readDatak00 = "k_00"; - const std::string readDatak01 = "k_01"; - const std::string readDatak10 = "k_10"; - const std::string readDatak11 = "k_11"; - const std::string readDataPorosity = "porosity"; - const std::string writeDataConcentration = "concentration"; - // const std::string writeDataTemperature = "temperature"; + const std::string readDatak00 = "K00"; + const std::string readDatak01 = "K01"; + const std::string readDatak10 = "K10"; + const std::string readDatak11 = "K11"; + const std::string readDataPorosity = "Porosity"; + const std::string writeDataConcentration = "Concentration"; if (runWithCoupling) { couplingParticipant.announceQuantity(meshName, readDatak00); @@ -166,7 +165,6 @@ int main(int argc, char **argv) couplingParticipant.announceQuantity(meshName, readDatak11); couplingParticipant.announceQuantity(meshName, readDataPorosity); couplingParticipant.announceQuantity(meshName, writeDataConcentration); - // couplingParticipant.announceQuantity(meshName, writeDataTemperature); } // the solution vector (initialized with zeros) NElements x 2(pressure, @@ -214,11 +212,11 @@ int main(int argc, char **argv) problem->name()); IOFields::initOutputModule(vtkWriter); // add model specific output fields - vtkWriter.addField(problem->getPorosity(), "porosity"); - vtkWriter.addField(problem->getK00(), "k00"); - vtkWriter.addField(problem->getK01(), "k01"); - vtkWriter.addField(problem->getK10(), "k10"); - vtkWriter.addField(problem->getK11(), "k11"); + vtkWriter.addField(problem->getPorosity(), "Porosity"); + vtkWriter.addField(problem->getK00(), "K00"); + vtkWriter.addField(problem->getK01(), "K01"); + vtkWriter.addField(problem->getK10(), "K10"); + vtkWriter.addField(problem->getK11(), "K11"); problem->updateVtkOutput(x); vtkWriter.write(0.0); diff --git a/two-scale-heat-conduction/macro-dumux/appl/spatialparams.hh b/two-scale-heat-conduction/macro-dumux/appl/spatialparams.hh index fc123d224..6e6f641bb 100644 --- a/two-scale-heat-conduction/macro-dumux/appl/spatialparams.hh +++ b/two-scale-heat-conduction/macro-dumux/appl/spatialparams.hh @@ -111,15 +111,15 @@ public: for (const auto &scv : scvs(fvGeometry)) { const auto elementIdx = scv.elementIndex(); couplingData_[elementIdx][0] = - couplingParticipant_.getScalarQuantityOnFace("macro-mesh", "porosity", elementIdx); + couplingParticipant_.getScalarQuantityOnFace("Macro-Mesh", "Porosity", elementIdx); couplingData_[elementIdx][1] = - couplingParticipant_.getScalarQuantityOnFace("macro-mesh", "k_00", elementIdx); + couplingParticipant_.getScalarQuantityOnFace("Macro-Mesh", "K00", elementIdx); couplingData_[elementIdx][2] = - couplingParticipant_.getScalarQuantityOnFace("macro-mesh", "k_01", elementIdx); + couplingParticipant_.getScalarQuantityOnFace("Macro-Mesh", "K01", elementIdx); couplingData_[elementIdx][3] = - couplingParticipant_.getScalarQuantityOnFace("macro-mesh", "k_10", elementIdx); + couplingParticipant_.getScalarQuantityOnFace("Macro-Mesh", "K10", elementIdx); couplingData_[elementIdx][4] = - couplingParticipant_.getScalarQuantityOnFace("macro-mesh", "k_11", elementIdx); + couplingParticipant_.getScalarQuantityOnFace("Macro-Mesh", "K11", elementIdx); } } // Trigger exchange of coupling data between neighboring ranks, if the domain is partitioned diff --git a/two-scale-heat-conduction/macro-dumux/params.input b/two-scale-heat-conduction/macro-dumux/params.input index 37508f98f..6a20f5909 100644 --- a/two-scale-heat-conduction/macro-dumux/params.input +++ b/two-scale-heat-conduction/macro-dumux/params.input @@ -20,7 +20,7 @@ MaxDt = 0.004 InitialDt = 0.01 [Problem] -Name = macro-heat +Name = Macro EnableGravity = false Permeability = 1.0 DefaultPorosity = 0.5 diff --git a/two-scale-heat-conduction/macro-nutils/macro.py b/two-scale-heat-conduction/macro-nutils/macro.py index a0ebc9d09..5f4479a7e 100644 --- a/two-scale-heat-conduction/macro-nutils/macro.py +++ b/two-scale-heat-conduction/macro-nutils/macro.py @@ -41,8 +41,8 @@ def main(): ns.uinitial = 0.5 if is_coupled_case: - participant = precice.Participant("macro-heat", "../precice-config.xml", 0, 1) - mesh_name = "macro-mesh" + participant = precice.Participant("Macro", "../precice-config.xml", 0, 1) + mesh_name = "Macro-Mesh" # Define Gauss points on entire domain as coupling mesh (volume coupling from macro side) couplingsample = topo.sample('gauss', degree=2) # mesh vertices are Gauss points @@ -68,7 +68,7 @@ def main(): if is_coupled_case: if participant.requires_initial_data(): concentrations = couplingsample.eval('u' @ ns, solu=solu0) - participant.write_data(mesh_name, "concentration", vertex_ids, concentrations) + participant.write_data(mesh_name, "Concentration", vertex_ids, concentrations) participant.initialize() dt = solver_dt = participant.get_max_time_step_size() @@ -107,16 +107,16 @@ def main(): dt = min(precice_dt, solver_dt) # Read porosity and apply it to the existing solution - poro_data = participant.read_data(mesh_name, "porosity", vertex_ids, dt) + poro_data = participant.read_data(mesh_name, "Porosity", vertex_ids, dt) poro_coupledata = couplingsample.asfunction(poro_data) sqrphi = couplingsample.integral((ns.phi - poro_coupledata) ** 2) solphi = solver.optimize('solphi', sqrphi, droptol=1E-12) # Read conductivity and apply it to the existing solution - k_00_c = couplingsample.asfunction(participant.read_data(mesh_name, "k_00", vertex_ids, dt)) - k_01_c = couplingsample.asfunction(participant.read_data(mesh_name, "k_01", vertex_ids, dt)) - k_10_c = couplingsample.asfunction(participant.read_data(mesh_name, "k_10", vertex_ids, dt)) - k_11_c = couplingsample.asfunction(participant.read_data(mesh_name, "k_11", vertex_ids, dt)) + k_00_c = couplingsample.asfunction(participant.read_data(mesh_name, "K00", vertex_ids, dt)) + k_01_c = couplingsample.asfunction(participant.read_data(mesh_name, "K01", vertex_ids, dt)) + k_10_c = couplingsample.asfunction(participant.read_data(mesh_name, "K10", vertex_ids, dt)) + k_11_c = couplingsample.asfunction(participant.read_data(mesh_name, "K11", vertex_ids, dt)) conductivity = function.asarray([[k_00_c, k_01_c], [k_10_c, k_11_c]]) sqrk = couplingsample.integral(((ns.k - conductivity) * (ns.k - conductivity)).sum([0, 1])) @@ -128,7 +128,7 @@ def main(): if is_coupled_case: # Collect values of field u and write them to preCICE concentration = couplingsample.eval('u' @ ns, solu=solu) - participant.write_data(mesh_name, "concentration", vertex_ids, concentration) + participant.write_data(mesh_name, "Concentration", vertex_ids, concentration) participant.advance(dt) diff --git a/two-scale-heat-conduction/micro-dumux/appl/micro_sim.cpp b/two-scale-heat-conduction/micro-dumux/appl/micro_sim.cpp index 217543954..00d2b2635 100644 --- a/two-scale-heat-conduction/micro-dumux/appl/micro_sim.cpp +++ b/two-scale-heat-conduction/micro-dumux/appl/micro_sim.cpp @@ -202,9 +202,9 @@ py::dict MicroSimulation::initialize() py::dict micro_write_data; // add micro_scalar_data and micro_vector_data to micro_write_data - micro_write_data["k_00"] = _k_00; - micro_write_data["k_11"] = _k_11; - micro_write_data["porosity"] = _porosity; + micro_write_data["K00"] = _k_00; + micro_write_data["K11"] = _k_11; + micro_write_data["Porosity"] = _porosity; return micro_write_data; } @@ -227,7 +227,7 @@ py::dict MicroSimulation::solve(py::dict macro_write_data, double dt) _timeLoop->setTimeStepSize(dt); // read concentration from preCICE - double conc = macro_write_data["concentration"].cast(); + double conc = macro_write_data["Concentration"].cast(); // input macro concentration into allen-cahn problem _acProblem->updateConcentration(conc); @@ -259,12 +259,12 @@ py::dict MicroSimulation::solve(py::dict macro_write_data, double dt) py::dict micro_write_data; // add micro_scalar_data and micro_vector_data to micro_write_data - micro_write_data["k_00"] = _k_00; - micro_write_data["k_10"] = _k_10; - micro_write_data["k_01"] = _k_01; - micro_write_data["k_11"] = _k_11; - micro_write_data["porosity"] = _porosity; - micro_write_data["grain_size"] = std::sqrt((1 - _porosity) / pi_); + micro_write_data["K00"] = _k_00; + micro_write_data["K10"] = _k_10; + micro_write_data["K01"] = _k_01; + micro_write_data["K11"] = _k_11; + micro_write_data["Porosity"] = _porosity; + micro_write_data["Grain-Size"] = std::sqrt((1 - _porosity) / pi_); // write current primary variables to previous primary variables _acGridVariables->advanceTimeStep(); diff --git a/two-scale-heat-conduction/micro-dumux/micro-manager-config.json b/two-scale-heat-conduction/micro-dumux/micro-manager-config.json index 7008e3e79..0042ff687 100644 --- a/two-scale-heat-conduction/micro-dumux/micro-manager-config.json +++ b/two-scale-heat-conduction/micro-dumux/micro-manager-config.json @@ -3,9 +3,9 @@ "coupling_params": { "participant_name": "Micro-Manager", "precice_config_file_name": "../precice-config.xml", - "macro_mesh_name": "macro-mesh", - "write_data_names": ["k_00", "k_01", "k_10", "k_11", "porosity"], - "read_data_names": ["concentration"] + "macro_mesh_name": "Macro-Mesh", + "write_data_names": ["K00", "K01", "K10", "K11", "Porosity"], + "read_data_names": ["Concentration"] }, "simulation_params": { "micro_dt": 0.01, @@ -14,7 +14,7 @@ "adaptivity": true, "adaptivity_settings": { "type": "global", - "data": ["k_00", "k_11", "porosity", "concentration"], + "data": ["K00", "K11", "Porosity", "Concentration"], "history_param": 0.1, "coarsening_constant": 0.2, "refining_constant": 0.05, @@ -22,6 +22,6 @@ } }, "diagnostics": { - "data_from_micro_sims": ["grain_size"] + "data_from_micro_sims": ["Grain-Size"] } } diff --git a/two-scale-heat-conduction/micro-nutils/micro-manager-config.json b/two-scale-heat-conduction/micro-nutils/micro-manager-config.json index 5569daab1..b326c4c74 100644 --- a/two-scale-heat-conduction/micro-nutils/micro-manager-config.json +++ b/two-scale-heat-conduction/micro-nutils/micro-manager-config.json @@ -3,9 +3,9 @@ "coupling_params": { "participant_name": "Micro-Manager", "precice_config_file_name": "../precice-config.xml", - "macro_mesh_name": "macro-mesh", - "write_data_names": ["k_00", "k_01", "k_10", "k_11", "porosity"], - "read_data_names": ["concentration"] + "macro_mesh_name": "Macro-Mesh", + "write_data_names": ["K00", "K01", "K10", "K11", "Porosity"], + "read_data_names": ["Concentration"] }, "simulation_params": { "micro_dt": 0.01, @@ -14,7 +14,7 @@ "adaptivity": true, "adaptivity_settings": { "type": "global", - "data": ["k_00", "k_11", "porosity", "concentration"], + "data": ["K00", "K11", "Porosity", "Concentration"], "history_param": 0.1, "coarsening_constant": 0.2, "refining_constant": 0.05, @@ -22,6 +22,6 @@ } }, "diagnostics": { - "data_from_micro_sims": ["grain_size"] + "data_from_micro_sims": ["Grain-Size"] } } diff --git a/two-scale-heat-conduction/micro-nutils/micro.py b/two-scale-heat-conduction/micro-nutils/micro.py index 9da25e1f9..6fff2aa38 100644 --- a/two-scale-heat-conduction/micro-nutils/micro.py +++ b/two-scale-heat-conduction/micro-nutils/micro.py @@ -82,9 +82,9 @@ def initialize(self): self._solu = solu # Save solution for output output_data = dict() - output_data["k_00"] = k[0][0] - output_data["k_11"] = k[1][1] - output_data["porosity"] = psi + output_data["K00"] = k[0][0] + output_data["K11"] = k[1][1] + output_data["Porosity"] = psi return output_data @@ -237,7 +237,7 @@ def solve(self, macro_data, dt): assert ((solphi >= 0.0) & (solphi <= 1.0)).all() - solphi = self._solve_allen_cahn(topo, solphi, macro_data["concentration"], dt) + solphi = self._solve_allen_cahn(topo, solphi, macro_data["Concentration"], dt) psi = self._get_avg_porosity(topo, solphi) solu = self._solve_heat_cell_problem(topo, solphi) @@ -255,12 +255,12 @@ def solve(self, macro_data, dt): psi = self._psi_nm1 output_data = dict() - output_data["k_00"] = k[0][0] - output_data["k_01"] = k[0][1] - output_data["k_10"] = k[1][0] - output_data["k_11"] = k[1][1] - output_data["porosity"] = psi - output_data["grain_size"] = math.sqrt((1 - psi) / math.pi) + output_data["K00"] = k[0][0] + output_data["K01"] = k[0][1] + output_data["K10"] = k[1][0] + output_data["K11"] = k[1][1] + output_data["Porosity"] = psi + output_data["Grain-Size"] = math.sqrt((1 - psi) / math.pi) return output_data @@ -275,7 +275,7 @@ def main(): concentration = dict() for conc in concentrations: - concentration["concentration"] = conc + concentration["Concentration"] = conc micro_sim_output = micro_problem.solve(concentration, dt) diff --git a/two-scale-heat-conduction/precice-config.xml b/two-scale-heat-conduction/precice-config.xml index 79c4f27b5..e1328fda1 100644 --- a/two-scale-heat-conduction/precice-config.xml +++ b/two-scale-heat-conduction/precice-config.xml @@ -6,82 +6,78 @@ - - - - - - - - - + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + + + + + - + - + - - - - - + + + + + - - - - + + + + - - - + + +