Пример #1
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="old"></param>
        public CavityDomain(CavityDomain old)
        {
            Nx = old.Nx;
            Ny = old.Ny;
            Nz = old.Nz;

            hx = old.hx;
            hy = old.hy;
            hz = old.hz;

            length_x = old.length_x;
            length_y = old.length_y;
            length_z = old.length_z;

            boundary_cells    = old.boundary_cells;
            obstacle_cells    = old.obstacle_cells;
            boundary_normal_x = old.boundary_normal_x;
            boundary_normal_y = old.boundary_normal_y;
            boundary_normal_z = old.boundary_normal_z;
            boundary_u        = old.boundary_u;
            boundary_v        = old.boundary_v;
            boundary_w        = old.boundary_w;

            outflow_boundary_x = old.outflow_boundary_x;
            outflow_boundary_y = old.outflow_boundary_y;
            outflow_boundary_z = old.outflow_boundary_z;
        }
Пример #2
0
        static void Main()
        {
            // Set mesh parameters, here we ask for Nx cells in the x direction
            // Ny cells in the y direction and Nz cells in the z direction (ignoring ghost cells)
            int Nx = 20;
            int Ny = 20;
            int Nz = 20;

            // Set time step and viscosity
            double dt = 0.01;
            double nu = 1e-2;

            // Set simulation start and finish times
            double tf = 100;
            double t  = 0;

            // Set initial conditions
            double[, ,] u0 = new double[Nx + 1, Ny + 2, Nz + 2];
            double[, ,] v0 = new double[Nx + 2, Ny + 1, Nz + 2];
            double[, ,] w0 = new double[Nx + 2, Ny + 2, Nz + 1];

            // Create empty arrays for body forces
            double[, ,] f_x = new double[Nx + 1, Ny + 2, Nz + 2];
            double[, ,] f_y = new double[Nx + 2, Ny + 1, Nz + 2];
            double[, ,] f_z = new double[Nx + 2, Ny + 2, Nz + 1];

            // Create structure containing solver parameters
            FluidSolver.solver_struct solver_prams = new FluidSolver.solver_struct();

            solver_prams.tol             = 1e-4;
            solver_prams.min_iter        = 0;
            solver_prams.max_iter        = 30;
            solver_prams.verbose         = true;
            solver_prams.backtrace_order = 2;

            // Create domain
            // Pass in the number of cells in x, y and z direction (now including ghost cells)
            CavityDomain omega = new CavityDomain(Nx + 2, Ny + 2, Nz + 2);

            // Create FFD solver
            FluidSolver ffd = new FluidSolver(omega, dt, nu, u0, v0, w0, solver_prams);

            // Create post processor, export intial conditions and geometry information
            PostProcessor pp = new PostProcessor(ffd, omega);

            int tstep = 0;

            pp.export_data_vtk(String.Concat("cavity_", tstep, ".vtk"), 0, false);
            pp.export_geometry_vtk("cavity_geometry.vtk", 0);

            // Begin time loop
            while (t < tf)
            {
                t += dt;
                tstep++;

                Console.WriteLine("Time t = {0}", t);

                // Solve single time step and export results
                ffd.time_step(f_x, f_y, f_z);
                pp.export_data_vtk(String.Concat("cavity_", tstep, ".vtk"), t, false);
            }
        }