diff --git a/share/examples/capacitor/capacitor.geo b/share/examples/capacitor/capacitor.geo index 3a2306b212ef89647147b81b13ab669689d57781..b20a1d3c68b5d4940068f681f601063814b87ab2 100644 --- a/share/examples/capacitor/capacitor.geo +++ b/share/examples/capacitor/capacitor.geo @@ -11,4 +11,10 @@ Cylinder(3) = {0, 0, -d/2-t, 0, 0, t, R}; Sphere(4) = {0, 0, 0, 2*R, -Pi/2, Pi/2, 2*Pi}; Coherence; +Physical Volume(1000) = {1, 3}; +Physical Volume(1001) = {2}; +Physical Volume(1002) = {4}; + +Physical Surface(2000) = {1}; + MeshSize{ PointsOf{ Volume{2}; } } = 0.0003; diff --git a/share/examples/capacitor2/params_capacitor.lua b/share/examples/capacitor2/params_capacitor.lua index c1bc00acb52754f87738f07d82ec3a2a78b86a51..f1f2abfccce1e8a568c6d58ef8573546c48846e3 100644 --- a/share/examples/capacitor2/params_capacitor.lua +++ b/share/examples/capacitor2/params_capacitor.lua @@ -38,11 +38,11 @@ for i,v in ipairs(air) do end -- ** Boundary conditions ** -local absorbing_bcs = {1} -for i,v in ipairs(absorbing_bcs) do - bndconds[v] = {} - bndconds[v].kind = "impedance" -end +--local absorbing_bcs = {1} +--for i,v in ipairs(absorbing_bcs) do +-- bndconds[v] = {} +-- bndconds[v].kind = "impedance" +--end local R = 0.01 -- Capacitor disk radius (must match capacitor.geo) local d = 0.001 -- Dielectric thickness (must match capacitor.geo) diff --git a/src/libgmshdg/gmsh_io.cpp b/src/libgmshdg/gmsh_io.cpp index 23f5fb7225fb0b35689990da4999362e00b1eb97..6d6372b2461801307a2d29617284388dcaf0ec0b 100644 --- a/src/libgmshdg/gmsh_io.cpp +++ b/src/libgmshdg/gmsh_io.cpp @@ -10,6 +10,9 @@ #include "common/mpi_helpers.h" #endif /* USE_MPI */ +#include "sgr.hpp" +using namespace sgr; + std::string quadrature_name(int order) { @@ -252,13 +255,14 @@ model::import_gmsh_entities_rank0(void) flux_base_world += e.num_fluxes(); index_base_world += e.num_cells(); - /* Send entity to the appropriate process */ assert(tag_partition > 0); int rank = tag_partition - 1; - e.mpi_send(rank, MPI_COMM_WORLD); #ifdef ENABLE_DEBUG_PRINT - std::cout << "Sending entity " << tag << " to " << rank << " " << e.num_dofs() << std::endl; + std::cout << "Sending entity " << tag << " to " << rank << ", "; + std::cout << e.num_dofs() << " DoFs" << std::endl; #endif /* ENABLE_DEBUG_PRINT */ + /* Send entity to the appropriate process */ + e.mpi_send(rank, MPI_COMM_WORLD); /* Save locally the entity */ remote_entities[tag_partition].push_back( std::move(e) ); all_entities_tags.push_back(tag); @@ -341,13 +345,14 @@ model::import_gmsh_entities_rankN(void) for (auto& rtag : partition_map.at(mp)) { entity e; - e.mpi_recv(0, MPI_COMM_WORLD); - #ifdef ENABLE_DEBUG_PRINT - std::cout << "Receiving " << rtag << ", rank " << mp-1 << " "; - std::cout << e.num_dofs() << std::endl; + std::cout << "Receiving " << rtag << ", rank " << mp-1 << ", "; #endif /* ENABLE_DEBUG_PRINT */ (void) rtag; + e.mpi_recv(0, MPI_COMM_WORLD); +#ifdef ENABLE_DEBUG_PRINT + std::cout << e.num_dofs() << " DoFs" << std::endl; +#endif /* ENABLE_DEBUG_PRINT */ for (size_t i = 0; i < e.num_cells(); i++) { @@ -405,17 +410,38 @@ model::get_facekey_tag_pairs(void) void model::map_boundaries(void) { -#ifdef USE_MPI - //ASSERT_MPI_RANK_0; -#endif /* USE_MPI */ std::vector<bfk_t> bfk = get_facekey_tag_pairs(); for (size_t i = 1; i < bfk.size(); i++) { if ( bfk[i-1].first == bfk[i].first ) { - std::cout << bfk[i-1].second << " " << bfk[i].second << std::endl; + std::cout << redfg << Bon << "WARNING: " << nofg << __FILE__; + std::cout << "(" << __LINE__ << "): Face identified by "; + std::cout << bfk[i].first << " was found on interfaces "; + std::cout << bfk[i-1].second; +#ifdef USE_MPI + if ( is_interprocess_boundary(bfk[i-1].second) ) + std::cout << " (IP)"; +#endif + std::cout << " and " << bfk[i].second; +#ifdef USE_MPI + if ( is_interprocess_boundary(bfk[i].second) ) + std::cout << " (IP)"; + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + std::cout << " [MPI rank " << rank << "]"; +#endif + std::cout << ". " << reset << std::endl; + /* +#ifdef USE_MPI + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if (rank == 0) +#endif + gmsh::write("crash.msh"); throw 42; + */ } } diff --git a/src/maxwell/maxwell_solver.cpp b/src/maxwell/maxwell_solver.cpp index 179afbcb2d57edc34abeb1336b0eb06e23b92d42..6a3e29a2ff0f5fcbf59fb4086a9d08e086da46ec 100644 --- a/src/maxwell/maxwell_solver.cpp +++ b/src/maxwell/maxwell_solver.cpp @@ -198,6 +198,18 @@ void solver_mainloop(const model& mod, State& state, maxwell::parameter_loader& } #endif /* USE_MPI */ +#ifdef USE_MPI + size_t my_num_dofs = 6*mod.num_dofs(); + size_t num_dofs; + MPI_Reduce(&my_num_dofs, &num_dofs, 1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); + if (proc_rank == 0) + std::cout << "Model has " << num_dofs << " DoFs" << std::endl; +#else /* USE_MPI */ + size_t num_dofs = 6*mod.num_dofs(); + std::cout << "Model has " << num_dofs << " DoFs" << std::endl; +#endif /* USE_MPI */ + + mpl.call_initialization_callback(); #ifdef ENABLE_EXP_GEOMETRIC_DIODE #ifdef USE_MPI @@ -238,7 +250,7 @@ void solver_mainloop(const model& mod, State& state, maxwell::parameter_loader& #else /* USE_MPI */ std::cout << hidecursor << clrline << "Cycle " << i << ": t = "; std::cout << state.curr_time << " s" << ", DOFs/s: "; - std::cout << dofs_s_proc << cr << std::flush; + std::cout << dofs_s_proc << ", avg time: " << time/cycle_print_rate << " s" << cr << std::flush; #endif /* USE_MPI */ tc.tic(); } @@ -369,6 +381,7 @@ int main(int argc, char *argv[]) #ifdef USE_MPI if (comm_rank == 0) { + std::cout << "Generating mesh..." << std::flush; if (scaled) mod.generate_mesh(sf); else @@ -376,20 +389,24 @@ int main(int argc, char *argv[]) if (comm_size > 1) mod.partition_mesh(comm_size); - + std::cout << "done" << std::endl; + std::cout << "Distributing mesh partitions..." << std::flush; mod.populate_from_gmsh(); + std::cout << "done" << std::endl; } else { mod.populate_from_gmsh(); } #else /* USE_MPI */ + std::cout << "Generating mesh..." << std::flush; if (scaled) mod.build(sf); else mod.build(); + std::cout << "done" << std::endl; #endif /* USE_MPI */ - + if ( not mpl.validate_model_params(mod) )