From 1462d6870c85f47676924eae278a7f829e4cea64 Mon Sep 17 00:00:00 2001
From: Matteo Cicuttin <datafl4sh@toxicnet.eu>
Date: Tue, 20 Jul 2021 18:08:58 +0200
Subject: [PATCH] Line integration part 2.

---
 src/maxwell_solver.cpp | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/maxwell_solver.cpp b/src/maxwell_solver.cpp
index aee2197..60887a5 100644
--- a/src/maxwell_solver.cpp
+++ b/src/maxwell_solver.cpp
@@ -9,6 +9,8 @@
 #include <omp.h>
 #endif
 
+#include <fstream>
+
 #include "gmsh.h"
 #include "silo_output.hpp"
 #include "maxwell_interface.h"
@@ -115,6 +117,21 @@ public:
     }
 };
 
+double
+integrate(const model& mod, const maxwell::solver_state& state, line_integrator& lint)
+{
+    return lint.integrate(mod, state.emf_curr.Ex);
+}
+
+double
+integrate(const model& mod, const maxwell::solver_state_gpu& state, line_integrator& lint)
+{
+    maxwell::field f;
+    f.resize( mod.num_dofs() );
+    state.emf_curr.copyout(f);
+    return lint.integrate(mod, f.Ex);
+}
+
 template<typename State>
 void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl)
 {
@@ -139,6 +156,8 @@ void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl)
     point_3d end(46e-9, 0.0, 38e-9);
     line_integrator lint(start, end, 50);
 
+    std::ofstream ofs("voltage.dat");
+
     timecounter tc;
     tc.tic();
     prepare_sources(mod, state, mpl);
@@ -160,7 +179,7 @@ void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl)
             std::cout << "Cycle " << i << ": t = " << state.curr_time << " s";
             std::cout << ", DOFs/s: " << (mod.num_dofs()*6*cycle_print_rate)/(time) << std::endl;
             tc.tic();
-            std::cout << "Voltage = " << lint.integrate(mod, state.emf_curr.Ex) << std::endl;
+            ofs << state.curr_time << " " << integrate(mod, state, lint) << std::endl;
         }
     }
 }
-- 
GitLab