/** Kernel (real) entry point **/ void kmain(struct mb_partial_info *mbi) { printk("RAM detected : %uk (lower), %uk (upper)\n", mbi->low_mem, mbi->high_mem); printk("Command line got: %s \n", mbi->cmdline); printk ("Initialize GDT ... "); InitGDT(); asm(" movw $0x18, %ax \n \ movw %ax, %ss \n \ movl $0x1FFF0, %esp"); OkMsg(); LoadIDT(); printk ("IDT loaded éè\n"); InitPIC(); sti; while(1) { } }
void kernel_main() { int i = 0xa0000; for( ; i <= 0xaffff; ++i ){ asm_write_mem( i, 1 ); } // Delete boot sector and temporary data. for( i = 0x1000; i <= 0x9fc00; ++i ){ asm_write_mem( i, 0 ); } init_palette(); i = 0xa0000; for( ; i <= 0xaffff; ++i ){ asm_write_mem( i, 0 ); } asm_disable_intr(); InitGDT(); InitIDT(); InitPIC(); asm_enable_intr(); set_task( 1, task_a, stack[ 0 ] + 2048 ); set_task( 2, task_b, stack[ 1 ] + 2048 ); switch_task_2( TASK_INFO_ADDR, TASK_INFO_ADDR + sizeof( TaskInfo ) ); for(;;){ print_str( 0, 20, "fin" ); asm_halt(); } asm_halt(); }
int TestCoil2D(void) { bool test = true; field f; init_empty_field(&f); init_empty_field(&f); f.model.cfl = 0.2; f.model.m = 7; // num of conservative variables f.model.NumFlux = Maxwell2DCleanNumFlux_upwind; f.model.BoundaryFlux = Coil2DBoundaryFlux; f.model.InitData = Coil2DInitData; f.model.ImposedData = Coil2DImposedData; f.varindex = GenericVarindex; f.interp.interp_param[0] = f.model.m; f.interp.interp_param[1] = 2; // x direction degree f.interp.interp_param[2] = 2; // y direction degree f.interp.interp_param[3] = 0; // z direction degree f.interp.interp_param[4] = 4; // x direction refinement f.interp.interp_param[5] = 4; // y direction refinement f.interp.interp_param[6] = 1; // z direction refinement // Read the gmsh file ReadMacroMesh(&f.macromesh, "../test/testmacromesh.msh"); // Try to detect a 2d mesh Detect2DMacroMesh(&f.macromesh); assert(f.macromesh.is2d); // Mesh preparation BuildConnectivity(&(f.macromesh)); //AffineMapMacroMesh(&(f.macromesh)); // Prepare the initial fields Initfield(&f); f.model.Source = Coil2DSource; f.pre_dtfield = coil_pre_dtfield; //f.dt = 1e-3; // Prudence... CheckMacroMesh(&(f.macromesh), f.interp.interp_param + 1); printf("cfl param =%f\n", f.hmin); // time derivative //dtfield(&f); //Displayfield(&f); // init the particles on a circle PIC pic; InitPIC(&pic, 100); CreateCoil2DParticles(&pic, &f.macromesh); PlotParticles(&pic, &f.macromesh); f.pic = &pic; // time evolution real tmax = 0.1; f.vmax = 1; real dt = set_dt(&f); RK2(&f, tmax, dt); // Save the results and the error //Plotfield(2, false, &f, NULL, "dgvisu.msh"); //Plotfield(2, true, &f, "error", "dgerror.msh"); real dd = L2error(&f); real tolerance = 0.3; test = test && (dd < tolerance); printf("L2 error: %f\n", dd); return test; }
// some unit tests of the macromesh code int TestPICAccumulate(void) { MacroMesh m; bool test=true; int param[]={4, 4, 4, 1, 1, 1, 0}; field f; init_empty_field(&f); // test gmsh file reading ReadMacroMesh(&(f.macromesh), "test/testmacromesh.msh"); BuildConnectivity(&(f.macromesh)); CheckMacroMesh(&(f.macromesh), param); //PrintMacroMesh(&m); PIC pic; InitPIC(&pic,1); CreateParticles(&pic,&(f.macromesh)); PlotParticles(&pic,&(f.macromesh)); f.model.m = 7; // num of conservative variables /* f.model.NumFlux = Maxwell2DNumFlux; */ /* f.model.BoundaryFlux = Maxwell2DBoundaryFlux; */ f.model.InitData = Maxwell2DConstInitData; /* f.model.ImposedData = Maxwell2DImposedData; */ f.varindex = GenericVarindex; f.interp.interp_param[0] = f.model.m; f.interp.interp_param[1] = 1; // x direction degree f.interp.interp_param[2] = 1; // y direction degree f.interp.interp_param[3] = 0; // z direction degree f.interp.interp_param[4] = 1; // x direction refinement f.interp.interp_param[5] = 1; // y direction refinement f.interp.interp_param[6] = 1; // z direction refinement Initfield(&f); // place the particle at (0,1,0) and v=(1,0,0) pic.xv[0]=0; pic.xv[1]=0; pic.xv[2]=0.5; real xref[3]; pic.cell_id[0]=NumElemFromPoint(&f.macromesh,pic.xv,xref); pic.xv[0]=xref[0]; pic.xv[1]=xref[1]; pic.xv[2]=xref[2]; pic.xv[3]=1; pic.xv[4]=0; pic.xv[5]=0; PlotParticles(&pic,&(f.macromesh)); int ie=2; int ipg=2; int iv=4; int imem=f.varindex(f.interp_param, ie, ipg, iv); AccumulateParticles(&pic,&f); printf("w=%f wex=%f\n",f.wn[imem],1/1.96); test = test && (fabs(f.wn[imem]-1/1.96) < 1e-8); Displayfield(&f); return test; }