From 7d8cd2609925f5414740e4bf100b42d025781344 Mon Sep 17 00:00:00 2001
From: Matteo Cicuttin <datafl4sh@toxicnet.eu>
Date: Wed, 22 Sep 2021 12:11:51 +0200
Subject: [PATCH] Microwave oven example.

---
 share/microwave_oven/oven.geo                 | 16 +++++++++
 share/microwave_oven/params_oven.lua          | 36 +++++++++++++++++++
 .../params_test_maxwell_resonator.lua         |  9 ++---
 share/validation/resonator.geo                |  2 +-
 src/maxwell/maxwell_solver.cpp                |  5 ++-
 5 files changed, 62 insertions(+), 6 deletions(-)
 create mode 100644 share/microwave_oven/oven.geo
 create mode 100644 share/microwave_oven/params_oven.lua

diff --git a/share/microwave_oven/oven.geo b/share/microwave_oven/oven.geo
new file mode 100644
index 0000000..4d5b980
--- /dev/null
+++ b/share/microwave_oven/oven.geo
@@ -0,0 +1,16 @@
+SetFactory("OpenCASCADE");
+
+width = 0.30;
+height = 0.20;
+depth = 0.28;
+
+wg_width = 0.10;
+wg_height = 0.05;
+
+Box(1) = {0.0, 0.0, 0.0, width, height, depth};
+
+Rectangle(100) = { width/2 - wg_width/2, height/2 - wg_height/2, 0 , wg_width, wg_height, 0 };
+
+BooleanFragments{ Volume{1}; Delete; }{ Surface{100}; Delete; }
+
+MeshSize{:} = 0.02;
diff --git a/share/microwave_oven/params_oven.lua b/share/microwave_oven/params_oven.lua
new file mode 100644
index 0000000..1f0459a
--- /dev/null
+++ b/share/microwave_oven/params_oven.lua
@@ -0,0 +1,36 @@
+sim.name = "oven"                       -- simulation name
+sim.dt = 1e-13                          -- timestep size
+sim.timesteps = 100000                   -- num of iterations
+sim.gmsh_model = "oven.geo"            -- gmsh model filename
+sim.use_gpu = 0                         -- 0: cpu, 1: gpu
+sim.approx_order = 1                    -- approximation order
+sim.time_integrator = "leapfrog"
+postpro.silo_output_rate = 100           -- rate at which to write silo files
+postpro.cycle_print_rate = 100           -- console print rate
+
+postpro["H"].silo_mode = "none"
+postpro["J"].silo_mode = "none"
+
+debug = {}
+debug.dump_cell_ranks = true
+
+materials[1] = {}
+materials[1].epsilon = 1
+materials[1].mu = 1
+materials[1].sigma = 0
+
+-- ** Boundary conditions **
+local freq = 2.45e9
+function source(tag, x, y, z, t)
+    local Ex = 0
+    local Ey = math.sin((x-0.1)*math.pi/0.1)*math.sin(2*math.pi*t*freq)
+    local Ez = 0
+    return Ex, Ey, Ez
+end
+
+bndconds[100] = {}
+bndconds[100].kind = "plane_wave_E"
+bndconds[100].source = source
+
+
+
diff --git a/share/validation/params_test_maxwell_resonator.lua b/share/validation/params_test_maxwell_resonator.lua
index 91b365e..9e892bc 100644
--- a/share/validation/params_test_maxwell_resonator.lua
+++ b/share/validation/params_test_maxwell_resonator.lua
@@ -4,14 +4,15 @@
 --[[ Problem setup ]]--
 sim.name = "test_maxwell_resonator"             -- simulation name
 sim.dt = 1e-12                                  -- timestep size
-sim.timesteps = 10001                           -- num of iterations
+sim.timesteps = 8001                           -- num of iterations
 sim.gmsh_model = "resonator.geo"                -- gmsh model filename
-sim.use_gpu = 1                                 -- 0: cpu, 1: gpu
-sim.approx_order = 1                            -- approximation order
+sim.use_gpu = 0                                 -- 0: cpu, 1: gpu
+sim.approx_order = 2                            -- approximation order
 sim.time_integrator = "leapfrog"
 postpro.silo_output_rate = 100
 postpro.cycle_print_rate = 100                  -- console print rate
 
+postpro["E"].silo_mode = "zonal"
 postpro["J"].silo_mode = "none"
 
 local epsr = 1
@@ -65,6 +66,6 @@ function ansol(tag, x, y, z, t)
 end
 
 --debug.analytical_solution = ansol
-
+debug.dump_cell_ranks = true
 
 
diff --git a/share/validation/resonator.geo b/share/validation/resonator.geo
index 3c3f829..36e1979 100644
--- a/share/validation/resonator.geo
+++ b/share/validation/resonator.geo
@@ -1,4 +1,4 @@
 SetFactory("OpenCASCADE");
 Box(1) = {0, 0, 0, 1, 0.1, 1};
 
-MeshSize{:} = 0.05;
+MeshSize{:} = 0.04;
diff --git a/src/maxwell/maxwell_solver.cpp b/src/maxwell/maxwell_solver.cpp
index d99495b..ed39854 100644
--- a/src/maxwell/maxwell_solver.cpp
+++ b/src/maxwell/maxwell_solver.cpp
@@ -383,7 +383,10 @@ void solver_mainloop(const model& mod, State& state, maxwell::parameter_loader&
             tc.tic();
         }
     }
-    std::cout << showcursor << std::endl;
+    #ifdef USE_MPI
+    if (proc_rank == 0)
+    #endif /* USE_MPI */
+        std::cout << showcursor << std::endl;
 }
 
 static void
-- 
GitLab