Skip to content
Snippets Groups Projects
Commit 4765d09f authored by Matteo Cicuttin's avatar Matteo Cicuttin
Browse files

Reworked Silo export for MPI.

parent e9865fa6
No related branches found
No related tags found
No related merge requests found
...@@ -275,6 +275,13 @@ option(OPT_DISABLE_TEXTURE_CACHE "On ROCm 4.1 texture stuff is broken, disable i ...@@ -275,6 +275,13 @@ option(OPT_DISABLE_TEXTURE_CACHE "On ROCm 4.1 texture stuff is broken, disable i
if (OPT_DISABLE_TEXTURE_CACHE) if (OPT_DISABLE_TEXTURE_CACHE)
add_definitions(-DDISABLE_TEXTURE_CACHE) add_definitions(-DDISABLE_TEXTURE_CACHE)
endif() endif()
######################################################################
## Enable code to handle geometric diode simulation for UniUD project
option(OPT_ENABLE_EXP_GEOMETRIC_DIODE "Enable Geometric Diode stuff [EXPERIMENTAL][NO GPU]")
if (OPT_ENABLE_EXP_GEOMETRIC_DIODE)
add_definitions(-DENABLE_EXP_GEOMETRIC_DIODE)
endif()
###################################################################### ######################################################################
## Configure targets ## Configure targets
include_directories(contrib/sgr) include_directories(contrib/sgr)
...@@ -312,11 +319,11 @@ endif() ...@@ -312,11 +319,11 @@ endif()
########## mpi testing stuff ########## mpi testing stuff
add_executable(testpart src/testpart.cpp) #add_executable(testpart src/testpart.cpp)
target_link_libraries(testpart gmshdg) #target_link_libraries(testpart gmshdg)
add_executable(testmod src/testmod.cpp) #add_executable(testmod src/testmod.cpp)
target_link_libraries(testmod gmshdg) #target_link_libraries(testmod gmshdg)
########## maxwell solver ########## maxwell solver
set(MAXWELL_SOURCES src/maxwell_interface.cpp set(MAXWELL_SOURCES src/maxwell_interface.cpp
......
...@@ -325,8 +325,7 @@ struct solver_state_gpu ...@@ -325,8 +325,7 @@ struct solver_state_gpu
void init_from_model(const model&, solver_state&); void init_from_model(const model&, solver_state&);
void init_matparams(const model&, solver_state&, const parameter_loader&); void init_matparams(const model&, solver_state&, const parameter_loader&);
//void apply_operator(solver_state&, const field&, field&); //void apply_operator(solver_state&, const field&, field&);
void export_fields_to_silo(const model&, const solver_state&, const parameter_loader&); void export_fields_to_silo(const model&, solver_state&, const parameter_loader&);
void export_fields_to_silo_2(const model&, solver_state&, const parameter_loader&);
void timestep(solver_state&, const parameter_loader&, time_integrator_type); void timestep(solver_state&, const parameter_loader&, time_integrator_type);
void prepare_sources(const model&, maxwell::solver_state&, maxwell::parameter_loader&); void prepare_sources(const model&, maxwell::solver_state&, maxwell::parameter_loader&);
void do_sources(const model&, maxwell::solver_state&, maxwell::parameter_loader&); void do_sources(const model&, maxwell::solver_state&, maxwell::parameter_loader&);
...@@ -339,8 +338,7 @@ void gather_field(const model&, maxwell::field&, int, MPI_Comm); ...@@ -339,8 +338,7 @@ void gather_field(const model&, maxwell::field&, int, MPI_Comm);
void init_from_model(const model&, solver_state_gpu&); void init_from_model(const model&, solver_state_gpu&);
void init_matparams(const model&, solver_state_gpu&, const parameter_loader&); void init_matparams(const model&, solver_state_gpu&, const parameter_loader&);
//void apply_operator(solver_state_gpu&, const field_gpu&, field_gpu&); //void apply_operator(solver_state_gpu&, const field_gpu&, field_gpu&);
void export_fields_to_silo(const model&, const solver_state_gpu&, const parameter_loader&); void export_fields_to_silo(const model&, solver_state_gpu&, const parameter_loader&);
void export_fields_to_silo_2(const model&, solver_state_gpu&, const parameter_loader&);
void timestep(solver_state_gpu&, const parameter_loader&, time_integrator_type); void timestep(solver_state_gpu&, const parameter_loader&, time_integrator_type);
void prepare_sources(const model&, maxwell::solver_state_gpu&, maxwell::parameter_loader&); void prepare_sources(const model&, maxwell::solver_state_gpu&, maxwell::parameter_loader&);
void do_sources(const model&, maxwell::solver_state_gpu&, maxwell::parameter_loader&); void do_sources(const model&, maxwell::solver_state_gpu&, maxwell::parameter_loader&);
......
...@@ -151,12 +151,18 @@ void export_E_field_nodal(const model& mod, silo& sdb, const vecxd& Ex, ...@@ -151,12 +151,18 @@ void export_E_field_nodal(const model& mod, silo& sdb, const vecxd& Ex,
std::vector<double> accum_Ez( sdb.num_nodes(), 0.0 ); std::vector<double> accum_Ez( sdb.num_nodes(), 0.0 );
std::vector<size_t> count( sdb.num_nodes(), 0 ); std::vector<size_t> count( sdb.num_nodes(), 0 );
#ifdef USE_MPI
for (auto& etag : mod.world_entities_tags())
{
auto& e = mod.entity_world_lookup(etag);
#else /* USE_MPI */
for (auto& e : mod) for (auto& e : mod)
{ {
#endif /* USE_MPI */
for (size_t iT = 0; iT < e.num_cells(); iT++) for (size_t iT = 0; iT < e.num_cells(); iT++)
{ {
auto& pe = e.cell(iT); auto& pe = e.cell(iT);
auto cgofs = e.cell_model_dof_offset(iT); auto cgofs = e.cell_world_dof_offset(iT);
auto nodetags = pe.node_tags(); auto nodetags = pe.node_tags();
for (size_t iD = 0; iD < 4; iD++) for (size_t iD = 0; iD < 4; iD++)
{ {
...@@ -191,12 +197,18 @@ void export_H_field_nodal(const model& mod, silo& sdb, const vecxd& Hx, ...@@ -191,12 +197,18 @@ void export_H_field_nodal(const model& mod, silo& sdb, const vecxd& Hx,
std::vector<double> accum_Hz( sdb.num_nodes(), 0.0 ); std::vector<double> accum_Hz( sdb.num_nodes(), 0.0 );
std::vector<size_t> count( sdb.num_nodes(), 0 ); std::vector<size_t> count( sdb.num_nodes(), 0 );
#ifdef USE_MPI
for (auto& etag : mod.world_entities_tags())
{
auto& e = mod.entity_world_lookup(etag);
#else /* USE_MPI */
for (auto& e : mod) for (auto& e : mod)
{ {
#endif /* USE_MPI */
for (size_t iT = 0; iT < e.num_cells(); iT++) for (size_t iT = 0; iT < e.num_cells(); iT++)
{ {
auto& pe = e.cell(iT); auto& pe = e.cell(iT);
auto cgofs = e.cell_model_dof_offset(iT); auto cgofs = e.cell_world_dof_offset(iT);
auto nodetags = pe.node_tags(); auto nodetags = pe.node_tags();
for (size_t iD = 0; iD < 4; iD++) for (size_t iD = 0; iD < 4; iD++)
{ {
...@@ -231,15 +243,20 @@ void export_J_field_nodal(const model& mod, silo& sdb, const vecxd& Ex, ...@@ -231,15 +243,20 @@ void export_J_field_nodal(const model& mod, silo& sdb, const vecxd& Ex,
std::vector<double> accum_Jz( sdb.num_nodes(), 0.0 ); std::vector<double> accum_Jz( sdb.num_nodes(), 0.0 );
std::vector<size_t> count( sdb.num_nodes(), 0 ); std::vector<size_t> count( sdb.num_nodes(), 0 );
#ifdef USE_MPI
for (auto& etag : mod.world_entities_tags())
{
auto& e = mod.entity_world_lookup(etag);
#else /* USE_MPI */
for (auto& e : mod) for (auto& e : mod)
{ {
auto etag = e.material_tag(); #endif /* USE_MPI */
for (size_t iT = 0; iT < e.num_cells(); iT++) for (size_t iT = 0; iT < e.num_cells(); iT++)
{ {
auto& pe = e.cell(iT); auto& pe = e.cell(iT);
auto bar = pe.barycenter(); auto bar = pe.barycenter();
auto sigma = mpl.sigma(etag, bar); auto sigma = mpl.sigma(e.material_tag(), bar);
auto cgofs = e.cell_model_dof_offset(iT); auto cgofs = e.cell_world_dof_offset(iT);
auto nodetags = pe.node_tags(); auto nodetags = pe.node_tags();
for (size_t iD = 0; iD < 4; iD++) for (size_t iD = 0; iD < 4; iD++)
{ {
...@@ -275,17 +292,22 @@ void export_E_field_zonal(const model& mod, silo& sdb, const vecxd& Ex, ...@@ -275,17 +292,22 @@ void export_E_field_zonal(const model& mod, silo& sdb, const vecxd& Ex,
std::vector<double> out_Ey( mod.num_cells() ); std::vector<double> out_Ey( mod.num_cells() );
std::vector<double> out_Ez( mod.num_cells() ); std::vector<double> out_Ez( mod.num_cells() );
for (size_t iE = 0; iE < mod.num_entities(); iE++) #ifdef USE_MPI
for (auto& etag : mod.world_entities_tags())
{
auto& e = mod.entity_world_lookup(etag);
#else /* USE_MPI */
for (auto& e : mod)
{ {
auto& e = mod.entity_at(iE); #endif /* USE_MPI */
for (size_t iT = 0; iT < e.num_cells(); iT++) for (size_t iT = 0; iT < e.num_cells(); iT++)
{ {
auto& pe = e.cell(iT); auto& pe = e.cell(iT);
auto& re = e.cell_refelem(pe); auto& re = e.cell_refelem(pe);
vecxd phi_bar = re.basis_functions({1./3., 1./3., 1./3.}); vecxd phi_bar = re.basis_functions({1./3., 1./3., 1./3.});
auto num_bf = re.num_basis_functions(); auto num_bf = re.num_basis_functions();
auto ofs = e.cell_model_dof_offset(iT); auto ofs = e.cell_world_dof_offset(iT);
auto gi = e.cell_model_index_by_gmsh(iT); auto gi = e.cell_world_index_by_gmsh(iT);
out_Ex[gi] = Ex.segment(ofs, num_bf).dot(phi_bar); out_Ex[gi] = Ex.segment(ofs, num_bf).dot(phi_bar);
out_Ey[gi] = Ey.segment(ofs, num_bf).dot(phi_bar); out_Ey[gi] = Ey.segment(ofs, num_bf).dot(phi_bar);
out_Ez[gi] = Ez.segment(ofs, num_bf).dot(phi_bar); out_Ez[gi] = Ez.segment(ofs, num_bf).dot(phi_bar);
...@@ -305,17 +327,22 @@ void export_H_field_zonal(const model& mod, silo& sdb, const vecxd& Hx, ...@@ -305,17 +327,22 @@ void export_H_field_zonal(const model& mod, silo& sdb, const vecxd& Hx,
std::vector<double> out_Hy( mod.num_cells() ); std::vector<double> out_Hy( mod.num_cells() );
std::vector<double> out_Hz( mod.num_cells() ); std::vector<double> out_Hz( mod.num_cells() );
for (size_t iE = 0; iE < mod.num_entities(); iE++) #ifdef USE_MPI
for (auto& etag : mod.world_entities_tags())
{ {
auto& e = mod.entity_at(iE); auto& e = mod.entity_world_lookup(etag);
#else /* USE_MPI */
for (auto& e : mod)
{
#endif /* USE_MPI */
for (size_t iT = 0; iT < e.num_cells(); iT++) for (size_t iT = 0; iT < e.num_cells(); iT++)
{ {
auto& pe = e.cell(iT); auto& pe = e.cell(iT);
auto& re = e.cell_refelem(pe); auto& re = e.cell_refelem(pe);
vecxd phi_bar = re.basis_functions({1./3., 1./3., 1./3.}); vecxd phi_bar = re.basis_functions({1./3., 1./3., 1./3.});
auto num_bf = re.num_basis_functions(); auto num_bf = re.num_basis_functions();
auto ofs = e.cell_model_dof_offset(iT); auto ofs = e.cell_world_dof_offset(iT);
auto gi = e.cell_model_index_by_gmsh(iT); auto gi = e.cell_world_index_by_gmsh(iT);
out_Hx[gi] = Hx.segment(ofs, num_bf).dot(phi_bar); out_Hx[gi] = Hx.segment(ofs, num_bf).dot(phi_bar);
out_Hy[gi] = Hy.segment(ofs, num_bf).dot(phi_bar); out_Hy[gi] = Hy.segment(ofs, num_bf).dot(phi_bar);
out_Hz[gi] = Hz.segment(ofs, num_bf).dot(phi_bar); out_Hz[gi] = Hz.segment(ofs, num_bf).dot(phi_bar);
...@@ -335,20 +362,24 @@ void export_J_field_zonal(const model& mod, silo& sdb, const vecxd& Ex, ...@@ -335,20 +362,24 @@ void export_J_field_zonal(const model& mod, silo& sdb, const vecxd& Ex,
std::vector<double> out_Jy( mod.num_cells() ); std::vector<double> out_Jy( mod.num_cells() );
std::vector<double> out_Jz( mod.num_cells() ); std::vector<double> out_Jz( mod.num_cells() );
for (size_t iE = 0; iE < mod.num_entities(); iE++) #ifdef USE_MPI
for (auto& etag : mod.world_entities_tags())
{
auto& e = mod.entity_world_lookup(etag);
#else /* USE_MPI */
for (auto& e : mod)
{ {
auto& e = mod.entity_at(iE); #endif /* USE_MPI */
auto etag = e.material_tag();
for (size_t iT = 0; iT < e.num_cells(); iT++) for (size_t iT = 0; iT < e.num_cells(); iT++)
{ {
auto& pe = e.cell(iT); auto& pe = e.cell(iT);
auto& re = e.cell_refelem(pe); auto& re = e.cell_refelem(pe);
auto bar = pe.barycenter(); auto bar = pe.barycenter();
auto sigma = mpl.sigma(etag, bar); auto sigma = mpl.sigma(e.material_tag(), bar);
vecxd phi_bar = re.basis_functions({1./3., 1./3., 1./3.}); vecxd phi_bar = re.basis_functions({1./3., 1./3., 1./3.});
auto num_bf = re.num_basis_functions(); auto num_bf = re.num_basis_functions();
auto ofs = e.cell_model_dof_offset(iT); auto ofs = e.cell_world_dof_offset(iT);
auto gi = e.cell_model_index_by_gmsh(iT); auto gi = e.cell_world_index_by_gmsh(iT);
out_Jx[gi] = sigma*Ex.segment(ofs, num_bf).dot(phi_bar); out_Jx[gi] = sigma*Ex.segment(ofs, num_bf).dot(phi_bar);
out_Jy[gi] = sigma*Ey.segment(ofs, num_bf).dot(phi_bar); out_Jy[gi] = sigma*Ey.segment(ofs, num_bf).dot(phi_bar);
out_Jz[gi] = sigma*Ez.segment(ofs, num_bf).dot(phi_bar); out_Jz[gi] = sigma*Ez.segment(ofs, num_bf).dot(phi_bar);
......
...@@ -609,7 +609,7 @@ gather_field(const model& mod, maxwell::field& in, maxwell::field& out, ...@@ -609,7 +609,7 @@ gather_field(const model& mod, maxwell::field& in, maxwell::field& out,
auto& e = mod.entity_world_lookup(tag); auto& e = mod.entity_world_lookup(tag);
auto base = e.dof_base_world(); auto base = e.dof_base_world();
auto len = e.num_dofs(); auto len = e.num_dofs();
std::cout << "GR: " << tag << " " << len << std::endl; //std::cout << "GR: " << tag << " " << len << std::endl;
receive_field(out, mod.entity_rank(tag), tag, base, len, comm); receive_field(out, mod.entity_rank(tag), tag, base, len, comm);
} }
...@@ -630,14 +630,14 @@ gather_field(const model& mod, maxwell::field& in, maxwell::field& out, ...@@ -630,14 +630,14 @@ gather_field(const model& mod, maxwell::field& in, maxwell::field& out,
{ {
for (auto& e : mod) for (auto& e : mod)
{ {
std::cout << "GS: " << e.gmsh_tag() << " " << e.num_dofs() << std::endl; //std::cout << "GS: " << e.gmsh_tag() << " " << e.num_dofs() << std::endl;
send_field(in, root, e.gmsh_tag(), e.dof_base(), e.num_dofs(), comm); send_field(in, root, e.gmsh_tag(), e.dof_base(), e.num_dofs(), comm);
} }
} }
} }
void void
export_fields_to_silo_2(const model& mod, maxwell::solver_state& state, export_fields_to_silo(const model& mod, maxwell::solver_state& state,
const maxwell::parameter_loader& mpl) const maxwell::parameter_loader& mpl)
{ {
int rank; int rank;
...@@ -658,31 +658,47 @@ export_fields_to_silo_2(const model& mod, maxwell::solver_state& state, ...@@ -658,31 +658,47 @@ export_fields_to_silo_2(const model& mod, maxwell::solver_state& state,
sdb.import_mesh_from_gmsh(); sdb.import_mesh_from_gmsh();
sdb.write_mesh(state.curr_time, state.curr_timestep); sdb.write_mesh(state.curr_time, state.curr_timestep);
std::vector<double> out_Ex( mod.num_cells_world() ); switch( mpl.postpro_fieldExportMode("E") )
std::vector<double> out_Ey( mod.num_cells_world() );
std::vector<double> out_Ez( mod.num_cells_world() );
for (auto& tag : mod.world_entities_tags())
{
auto& e = mod.entity_world_lookup(tag);
for (size_t iT = 0; iT < e.num_cells(); iT++)
{ {
auto& pe = e.cell(iT); case field_export_mode::NONE:
auto& re = e.cell_refelem(pe); break;
vecxd phi_bar = re.basis_functions({1./3., 1./3., 1./3.});
auto num_bf = re.num_basis_functions(); case field_export_mode::NODAL:
auto ofs = e.cell_world_dof_offset(iT); export_E_field_nodal(mod, sdb, f.Ex, f.Ey, f.Ez, mpl);
auto gi = e.cell_world_index_by_gmsh(iT); break;
out_Ex[gi] = f.Ex.segment(ofs, num_bf).dot(phi_bar);
out_Ey[gi] = f.Ey.segment(ofs, num_bf).dot(phi_bar); case field_export_mode::ZONAL:
out_Ez[gi] = f.Ez.segment(ofs, num_bf).dot(phi_bar); export_E_field_zonal(mod, sdb, f.Ex, f.Ey, f.Ez, mpl);
break;
} }
switch( mpl.postpro_fieldExportMode("H") )
{
case field_export_mode::NONE:
break;
case field_export_mode::NODAL:
export_H_field_nodal(mod, sdb, f.Hx, f.Hy, f.Hz, mpl);
break;
case field_export_mode::ZONAL:
export_H_field_zonal(mod, sdb, f.Hx, f.Hy, f.Hz, mpl);
break;
} }
sdb.write_zonal_variable("Ex", out_Ex); switch( mpl.postpro_fieldExportMode("J") )
sdb.write_zonal_variable("Ey", out_Ey); {
sdb.write_zonal_variable("Ez", out_Ez); case field_export_mode::NONE:
sdb.write_vector_expression("E", "{Ex, Ey, Ez}"); break;
case field_export_mode::NODAL:
export_J_field_nodal(mod, sdb, f.Ex, f.Ey, f.Ez, mpl);
break;
case field_export_mode::ZONAL:
export_J_field_zonal(mod, sdb, f.Ex, f.Ey, f.Ez, mpl);
break;
}
} }
else else
{ {
...@@ -690,10 +706,11 @@ export_fields_to_silo_2(const model& mod, maxwell::solver_state& state, ...@@ -690,10 +706,11 @@ export_fields_to_silo_2(const model& mod, maxwell::solver_state& state,
gather_field(mod, state.emf_next, dummy, 0, MPI_COMM_WORLD); gather_field(mod, state.emf_next, dummy, 0, MPI_COMM_WORLD);
} }
} }
#endif /* USE_MPI */
#else /* USE_MPI */
void void
export_fields_to_silo(const model& mod, const maxwell::solver_state& state, export_fields_to_silo(const model &mod, maxwell::solver_state &state,
const maxwell::parameter_loader &mpl) const maxwell::parameter_loader &mpl)
{ {
std::stringstream ss; std::stringstream ss;
...@@ -752,5 +769,6 @@ export_fields_to_silo(const model& mod, const maxwell::solver_state& state, ...@@ -752,5 +769,6 @@ export_fields_to_silo(const model& mod, const maxwell::solver_state& state,
break; break;
} }
} }
#endif /* USE_MPI */
} // namespace maxwell } // namespace maxwell
...@@ -33,7 +33,7 @@ init_matparams(const model& mod, solver_state_gpu& state, ...@@ -33,7 +33,7 @@ init_matparams(const model& mod, solver_state_gpu& state,
auto v_epsilon = mpl.epsilon(etag, bar); auto v_epsilon = mpl.epsilon(etag, bar);
auto v_mu = mpl.mu(etag, bar); auto v_mu = mpl.mu(etag, bar);
auto v_sigma = mpl.sigma(etag, bar); auto v_sigma = mpl.sigma(etag, bar);
auto ofs = e.cell_global_dof_offset(iT); auto ofs = e.cell_model_dof_offset(iT);
for (size_t iD = 0; iD < re.num_basis_functions(); iD++) for (size_t iD = 0; iD < re.num_basis_functions(); iD++)
{ {
...@@ -555,18 +555,21 @@ swap(solver_state_gpu& state, const parameter_loader& mpl) ...@@ -555,18 +555,21 @@ swap(solver_state_gpu& state, const parameter_loader& mpl)
std::swap(state.emf_curr, state.emf_next); std::swap(state.emf_curr, state.emf_next);
} }
#ifdef USE_MPI
void void
gather_field(const model& mod, const maxwell::field_gpu& in, maxwell::field_gpu& f, gather_field(const model& mod, const maxwell::field_gpu& in, maxwell::field_gpu& f,
int root, MPI_Comm comm) int root, MPI_Comm comm)
{} {}
void void
export_fields_to_silo_2(const model& mod, maxwell::solver_state_gpu& state, export_fields_to_silo(const model& mod, maxwell::solver_state_gpu& state,
const maxwell::parameter_loader& mpl) const maxwell::parameter_loader& mpl)
{} {}
#else /* USE_MPI */
void void
export_fields_to_silo(const model& mod, const maxwell::solver_state_gpu& state, export_fields_to_silo(const model& mod, maxwell::solver_state_gpu& state,
const maxwell::parameter_loader& mpl) const maxwell::parameter_loader& mpl)
{ {
std::stringstream ss; std::stringstream ss;
...@@ -623,5 +626,6 @@ export_fields_to_silo(const model& mod, const maxwell::solver_state_gpu& state, ...@@ -623,5 +626,6 @@ export_fields_to_silo(const model& mod, const maxwell::solver_state_gpu& state,
break; break;
} }
} }
#endif /* USE_MPI */
} // namespace maxwell } // namespace maxwell
...@@ -68,6 +68,7 @@ void initialize_solver(const model& mod, State& state, const maxwell::parameter_ ...@@ -68,6 +68,7 @@ void initialize_solver(const model& mod, State& state, const maxwell::parameter_
init_matparams(mod, state, mpl); init_matparams(mod, state, mpl);
} }
#ifdef ENABLE_EXP_GEOMETRIC_DIODE
class integration_line class integration_line
{ {
std::vector<size_t> element_tags; std::vector<size_t> element_tags;
...@@ -187,6 +188,7 @@ reinit_materials(const model& mod, maxwell::solver_state& state, maxwell::parame ...@@ -187,6 +188,7 @@ reinit_materials(const model& mod, maxwell::solver_state& state, maxwell::parame
} }
} }
} }
#endif /* ENABLE_EXP_GEOMETRIC_DIODE */
template<typename State> template<typename State>
void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl) void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl)
...@@ -205,12 +207,12 @@ void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl) ...@@ -205,12 +207,12 @@ void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl)
std::cout << "Time integrator: " << mpl.sim_timeIntegratorName() << std::endl; std::cout << "Time integrator: " << mpl.sim_timeIntegratorName() << std::endl;
mpl.call_initialization_callback(); mpl.call_initialization_callback();
#ifdef ENABLE_EXP_GEOMETRIC_DIODE
auto relmat = [&](){ reinit_materials(mod, state, mpl); }; auto relmat = [&](){ reinit_materials(mod, state, mpl); };
sol::state& lua = mpl.lua_state(); sol::state& lua = mpl.lua_state();
lua["relmat"] = relmat; lua["relmat"] = relmat;
#endif /* ENABLE_EXP_GEOMETRIC_DIODE */
timecounter tc; timecounter tc;
tc.tic(); tc.tic();
prepare_sources(mod, state, mpl); prepare_sources(mod, state, mpl);
...@@ -220,13 +222,8 @@ void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl) ...@@ -220,13 +222,8 @@ void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl)
timestep(state, mpl, ti); timestep(state, mpl, ti);
do_sources(mod, state, mpl); do_sources(mod, state, mpl);
#ifdef USE_MPI
if ( (silo_output_rate != 0) and (i%silo_output_rate == 0) )
export_fields_to_silo_2(mod, state, mpl);
#else
if ( (silo_output_rate != 0) and (i%silo_output_rate == 0) ) if ( (silo_output_rate != 0) and (i%silo_output_rate == 0) )
export_fields_to_silo(mod, state, mpl); export_fields_to_silo(mod, state, mpl);
#endif /* USE_MPI */
swap(state, mpl); swap(state, mpl);
...@@ -243,6 +240,7 @@ void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl) ...@@ -243,6 +240,7 @@ void test_it(const model& mod, State& state, maxwell::parameter_loader& mpl)
void void
register_lua_usertypes(maxwell::parameter_loader& mpl) register_lua_usertypes(maxwell::parameter_loader& mpl)
{ {
#ifdef ENABLE_EXP_GEOMETRIC_DIODE
sol::state& lua = mpl.lua_state(); sol::state& lua = mpl.lua_state();
sol::usertype<point_3d> point_3d_ut = lua.new_usertype<point_3d>("point", sol::usertype<point_3d> point_3d_ut = lua.new_usertype<point_3d>("point",
sol::constructors<point_3d(), point_3d(double, double, double)>() sol::constructors<point_3d(), point_3d(double, double, double)>()
...@@ -252,18 +250,21 @@ register_lua_usertypes(maxwell::parameter_loader& mpl) ...@@ -252,18 +250,21 @@ register_lua_usertypes(maxwell::parameter_loader& mpl)
lua.new_usertype<integration_line>("integration_line", lua.new_usertype<integration_line>("integration_line",
sol::constructors<integration_line(const point_3d&, const point_3d&, size_t)>() sol::constructors<integration_line(const point_3d&, const point_3d&, size_t)>()
); );
#endif /* ENABLE_EXP_GEOMETRIC_DIODE */
} }
void void
register_lua_usertypes_bystate(maxwell::parameter_loader& mpl, register_lua_usertypes_bystate(maxwell::parameter_loader& mpl,
model& mod, maxwell::solver_state& state) model& mod, maxwell::solver_state& state)
{ {
#ifdef ENABLE_EXP_GEOMETRIC_DIODE
sol::state& lua = mpl.lua_state(); sol::state& lua = mpl.lua_state();
lua["internal"] = lua.create_table(); lua["internal"] = lua.create_table();
lua["internal"]["model"] = &mod; lua["internal"]["model"] = &mod;
lua["internal"]["state"] = &state; lua["internal"]["state"] = &state;
lua["integrate_E"] = integrate_electric_field; lua["integrate_E"] = integrate_electric_field;
#endif /*ENABLE_EXP_GEOMETRIC_DIODE */
} }
#ifdef ENABLE_GPU_SOLVER #ifdef ENABLE_GPU_SOLVER
...@@ -273,15 +274,15 @@ register_lua_usertypes_bystate(maxwell::parameter_loader& mpl, ...@@ -273,15 +274,15 @@ register_lua_usertypes_bystate(maxwell::parameter_loader& mpl,
{} {}
#endif #endif
int main(int argc, const char *argv[]) int main(int argc, char *argv[])
{ {
#ifdef USE_MPI #ifdef USE_MPI
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
int rank, size; int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
std::cout << "Running with MPI: " << rank+1 << "/" << size << std::endl; std::cout << "Running with MPI: " << comm_rank+1 << "/" << comm_size << std::endl;
#endif #endif
if (argc != 2) if (argc != 2)
...@@ -312,11 +313,11 @@ int main(int argc, const char *argv[]) ...@@ -312,11 +313,11 @@ int main(int argc, const char *argv[])
model mod( mpl.sim_geomorder(), mpl.sim_approxorder() ); model mod( mpl.sim_geomorder(), mpl.sim_approxorder() );
#ifdef USE_MPI #ifdef USE_MPI
if (rank == 0) if (comm_rank == 0)
{ {
mod.generate_mesh(); mod.generate_mesh();
if (size > 1) if (comm_size > 1)
mod.partition_mesh(size); mod.partition_mesh(comm_size);
mod.populate_from_gmsh(); mod.populate_from_gmsh();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment