Skip to content
Snippets Groups Projects
Select Git revision
  • 83d6b8c7f82cf6bf5fb60ea069057d4df3e884bd
  • master default protected
  • clem_dev
  • clem_dev_corrected
  • kokkos
  • devel
  • bcast_debug
  • MC/high_order_geometry
  • MC/mpi_nonblocking
  • MC/multigpu
  • MC/lifting_oneshot
  • MC/physent
  • curls_marco
  • MC/gefpg_lua_binding
  • emdant/dg-cherry-pick-8f1f09f5
  • v0.3.0
  • v0.2.0
  • v0.1.0
18 results

maxwell_solver.cpp

Blame
  • maxwell_solver.cpp 1.60 KiB
    #include "gmsh.h"
    #include "silo_output.hpp"
    #include "maxwell_interface.h"
    
    static void
    make_geometry(int order, double mesh_h)
    {
        gm::add("difftest");
    
        std::vector<std::pair<int,int>> objects;
    
        objects.push_back(
            std::make_pair(3, gmo::addBox(0.0, 0.0, 0.0, 1.0, 1.0, 0.05) )
            );
        objects.push_back(
            std::make_pair(3, gmo::addBox(0.0, 0.0, 0.05, 1.0, 1.0, 0.05) )
            );
    
        std::vector<std::pair<int, int>> tools;
        gmsh::vectorpair odt;
        std::vector<gmsh::vectorpair> odtm;
        gmo::fragment(objects, tools, odt, odtm);
    
        gmo::synchronize();
    
        gvp_t vp;
        gm::getEntities(vp);
        gmm::setSize(vp, mesh_h);
    }
    
    template<typename State>
    void test_it(const model& mod, State& state)
    {
        auto E = [](const point_3d& pt) -> vec3d {
            vec3d ret;
            ret(0) = 0;
            ret(1) = 0;
            ret(2) = std::sin(M_PI*pt.x()) * std::sin(M_PI*pt.y());
            return ret;
        };
    
        maxwell::init_from_model(mod, state);
        maxwell::init_E_field(mod, state, E);
    
        state.delta_t = 0.001;
    
        for(size_t i = 0; i < 10000; i++)
        {
            timestep(state);
            std::stringstream ss;
            ss << "maxwell_" << i << ".silo";
    
            if (i%10 == 0)
                maxwell::export_to_silo(mod, state, ss.str());
            
            std::swap(state.emf_curr, state.emf_next);
        }
    
        
    }
    
    int main(int argc, const char *argv[])
    {
        gmsh::initialize();
        make_geometry(1, 0.1);
    
        model mod(1,3);
        
        maxwell::solver_state state_c;
        test_it(mod, state_c);
    
        //maxwell::solver_state_gpu state_g;
        //test_it(mod, state_g);
    
        //gmsh::finalize();
    
        return 0;
    }