Example #1
0
visit_handle
SimGetMesh(int domain, const char *name, void *cbdata)
{
    visit_handle h = VISIT_INVALID_HANDLE;

    if(strcmp(name, "mesh2d") == 0)
    {
        if(VisIt_RectilinearMesh_alloc(&h) == VISIT_OKAY)
        {
            int i;
            visit_handle x,y;

            /* Initialize X coords. */
            for(i = 0; i < NX; ++i)
            {
                float t = (float)i / (float)(NX-1);
                rmesh_x[i] = (1.f-t)*XMIN + t*XMAX;
            }
            /* Initialize Y coords. */
            for(i = 0; i < NY; ++i) 
            {
                float t = (float)i / (float)(NY-1);
                rmesh_y[i] = (1.f-t)*YMIN + t*YMAX;
            }

            VisIt_VariableData_alloc(&x);
            VisIt_VariableData_alloc(&y);
            VisIt_VariableData_setDataF(x, VISIT_OWNER_SIM, 1, NX, rmesh_x);
            VisIt_VariableData_setDataF(y, VISIT_OWNER_SIM, 1, NY, rmesh_y);
            VisIt_RectilinearMesh_setCoordsXY(h, x, y);
        }
    }
    else if(strcmp(name, "ucdmesh") == 0)
    {
        visit_handle c, hc;
        if(VisIt_UnstructuredMesh_alloc(&h) == VISIT_OKAY &&
           VisIt_VariableData_alloc(&c) == VISIT_OKAY &&
           VisIt_VariableData_alloc(&hc) == VISIT_OKAY)
        {
            int nnodes, nzones;
            nnodes = (NX * NY);
            nzones = (NX-1)*(NY-1);
            VisIt_VariableData_setDataF(c, VISIT_OWNER_SIM, 2, nnodes, (float*)coords2d);
            VisIt_VariableData_setDataI(hc, VISIT_OWNER_SIM, 1, 5*nzones,
                connectivity);
            VisIt_UnstructuredMesh_setCoords(h, c);
            VisIt_UnstructuredMesh_setConnectivity(h, nzones, hc);
        }
    }

    return h;
}
Example #2
0
visit_handle
SimGetMesh(int domain, const char *name, void *cbdata)
{
    visit_handle h = VISIT_INVALID_HANDLE;

    if(strcmp(name, "amr") == 0)
    {
        if(VisIt_RectilinearMesh_alloc(&h) != VISIT_ERROR)
        {
            visit_handle x, y;
            int   i, nx, ny;
            float cx[100], cy[100], t;

            /* Create the X coordinates */
            nx = rmxext[domain][1] - rmxext[domain][0]+1+1;
            for(i = 0; i < nx; ++i)
            {
                t = (float)i / (float)(nx-1);
                cx[i] = (1.-t)*rmx[domain][0] + t*rmx[domain][1];
            }

            /* Create the Y coordinates */
            ny = rmyext[domain][1] - rmyext[domain][0]+1+1;
            for(i = 0; i < ny; ++i)
            {
                t = (float)i / (float)(ny-1);
                cy[i] = (1.-t)*rmy[domain][0] + t*rmy[domain][1];
            }

            VisIt_VariableData_alloc(&x);
            VisIt_VariableData_alloc(&y);
            VisIt_VariableData_setDataF(x, VISIT_OWNER_COPY, 1, nx, cx);
            VisIt_VariableData_setDataF(y, VISIT_OWNER_COPY, 1, ny, cy);
            VisIt_RectilinearMesh_setCoordsXY(h, x, y);
        }
    }

    return h;
}
Example #3
0
visit_handle
SimGetMesh(int domain, const char *name, void *cbdata)
{
    visit_handle h = VISIT_INVALID_HANDLE;

    if(strcmp(name, "mesh2d") == 0)
    {
        if(VisIt_RectilinearMesh_alloc(&h) != VISIT_ERROR)
        {
            visit_handle hxc, hyc;
            VisIt_VariableData_alloc(&hxc);
            VisIt_VariableData_alloc(&hyc);
            VisIt_VariableData_setDataF(hxc, VISIT_OWNER_SIM, 1, rmesh_dims[0], rmesh_x);
            VisIt_VariableData_setDataF(hyc, VISIT_OWNER_SIM, 1, rmesh_dims[1], rmesh_y);
            VisIt_RectilinearMesh_setCoordsXY(h, hxc, hyc);
        }
    }
    else if(strcmp(name, "mesh3d") == 0)
    {
        if(VisIt_CurvilinearMesh_alloc(&h) != VISIT_ERROR)
        {
            int nn;
            visit_handle hxc, hyc, hzc;
            nn = cmesh_dims[0] * cmesh_dims[1] * cmesh_dims[2];
            VisIt_VariableData_alloc(&hxc);
            VisIt_VariableData_alloc(&hyc);
            VisIt_VariableData_alloc(&hzc);
            VisIt_VariableData_setDataF(hxc, VISIT_OWNER_SIM, 1, nn, (float*)cmesh_x);
            VisIt_VariableData_setDataF(hyc, VISIT_OWNER_SIM, 1, nn, (float*)cmesh_y);
            VisIt_VariableData_setDataF(hzc, VISIT_OWNER_SIM, 1, nn, (float*)cmesh_z);
            VisIt_CurvilinearMesh_setCoordsXYZ(h, cmesh_dims, hxc, hyc, hzc);
        }
    }

    return h;
}
Example #4
0
visit_handle
SimGetMesh(int domain, const char *name, void *cbdata)
{
    visit_handle h = VISIT_INVALID_HANDLE;
    simulation_data *sim = (simulation_data *)cbdata;

    if(strcmp(name, "rect_blank") == 0)
    {
        if(VisIt_RectilinearMesh_alloc(&h) != VISIT_ERROR)
        {
            int ncells;
            visit_handle hx, hy, gc;

            VisIt_VariableData_alloc(&hx);
            VisIt_VariableData_alloc(&hy);
            VisIt_VariableData_setDataF(hx, VISIT_OWNER_SIM, 1, sim->blankRectMesh.dims[0], sim->blankRectMesh.x);
            VisIt_VariableData_setDataF(hy, VISIT_OWNER_SIM, 1, sim->blankRectMesh.dims[1], sim->blankRectMesh.y);
            VisIt_RectilinearMesh_setCoordsXY(h, hx, hy);

            /* Attach ghost cells to blank out certain cells*/
            VisIt_VariableData_alloc(&gc);
            ncells = (sim->blankRectMesh.dims[0]-1) * (sim->blankRectMesh.dims[1]-1);
            VisIt_VariableData_setDataI(gc, VISIT_OWNER_SIM, 1, ncells, sim->blankRectMesh.ghostCells);
            VisIt_RectilinearMesh_setGhostCells(h, gc);
        }
    }
    else if(strcmp(name, "curv_blank") == 0)
    {
        if(VisIt_CurvilinearMesh_alloc(&h) != VISIT_ERROR)
        {
            int ncells, nnodes;
            visit_handle hx, hy, gc;

            nnodes = sim->blankCurvMesh.dims[0] * sim->blankCurvMesh.dims[1];
            ncells = (sim->blankCurvMesh.dims[0]-1) * (sim->blankCurvMesh.dims[1]-1);

            VisIt_VariableData_alloc(&hx);
            VisIt_VariableData_alloc(&hy);
            VisIt_VariableData_setDataF(hx, VISIT_OWNER_SIM, 1, nnodes, sim->blankCurvMesh.x);
            VisIt_VariableData_setDataF(hy, VISIT_OWNER_SIM, 1, nnodes, sim->blankCurvMesh.y);
            VisIt_CurvilinearMesh_setCoordsXY(h, sim->blankCurvMesh.dims, hx, hy);

            /* Attach ghost cells to blank out certain cells*/
            VisIt_VariableData_alloc(&gc);
            VisIt_VariableData_setDataI(gc, VISIT_OWNER_SIM, 1, ncells, sim->blankCurvMesh.ghostCells);
            VisIt_CurvilinearMesh_setGhostCells(h, gc);
        }
    }
    else if(strcmp(name, "ucd_blank") == 0)
    {
        if(VisIt_UnstructuredMesh_alloc(&h) != VISIT_ERROR)
        {
            visit_handle hxyz, hc, gc;

            VisIt_VariableData_alloc(&hxyz);
            VisIt_VariableData_setDataF(hxyz, VISIT_OWNER_SIM, 3, sim->blankUcdMesh.nnodes, sim->blankUcdMesh.xyz);
            VisIt_UnstructuredMesh_setCoords(h, hxyz);

            VisIt_VariableData_alloc(&hc);
            VisIt_VariableData_setDataI(hc, VISIT_OWNER_SIM, 1, sim->blankUcdMesh.connectivityLen,
                sim->blankUcdMesh.connectivity);
            VisIt_UnstructuredMesh_setConnectivity(h, sim->blankUcdMesh.ncells, hc);

            /* Attach ghost cells to blank out certain cells*/
            VisIt_VariableData_alloc(&gc);
            VisIt_VariableData_setDataI(gc, VISIT_OWNER_SIM, 1, sim->blankUcdMesh.ncells, sim->blankUcdMesh.ghostCells);
            VisIt_UnstructuredMesh_setGhostCells(h, gc);
        }
    }
    else if(strncmp(name, "multi_domain", 12) == 0)
    {
        if(VisIt_RectilinearMesh_alloc(&h) != VISIT_ERROR)
        {
            int ncells;
            visit_handle hx, hy, gc;

            VisIt_VariableData_alloc(&hx);
            VisIt_VariableData_alloc(&hy);
            VisIt_VariableData_setDataF(hx, VISIT_OWNER_SIM, 1, sim->multidomain[domain].m.dims[0], sim->multidomain[domain].m.x);
            VisIt_VariableData_setDataF(hy, VISIT_OWNER_SIM, 1, sim->multidomain[domain].m.dims[1], sim->multidomain[domain].m.y);
            VisIt_RectilinearMesh_setCoordsXY(h, hx, hy);

            if(strcmp(name, "multi_domain") == 0)
            {
                /* Do ghost cells using a ghost cells array. */
                VisIt_VariableData_alloc(&gc);
                ncells = (sim->multidomain[domain].m.dims[0]-1) * (sim->multidomain[domain].m.dims[1]-1);
                VisIt_VariableData_setDataI(gc, VISIT_OWNER_SIM, 1, ncells, sim->multidomain[domain].m.ghostCells);
                VisIt_RectilinearMesh_setGhostCells(h, gc);
            }
            else
            {
                /* Do ghost cells using indices. Note: other mesh types can also 
                 * designate ghost cells using indices.
                 */
                VisIt_RectilinearMesh_setRealIndices(h, sim->multidomain[domain].minReal, 
                    sim->multidomain[domain].maxReal);
            }
        }
    }
    else if(strcmp(name, "multi_types") == 0)
    {
        if(domain < 4 && VisIt_RectilinearMesh_alloc(&h) != VISIT_ERROR)
        {
            int ncells;
            visit_handle hx, hy, hz, gc;

            VisIt_VariableData_alloc(&hx);
            VisIt_VariableData_alloc(&hy);
            VisIt_VariableData_alloc(&hz);
            VisIt_VariableData_setDataF(hx, VISIT_OWNER_SIM, 1, sim->multipletypes[domain].dims[0], sim->multipletypes[domain].x);
            VisIt_VariableData_setDataF(hy, VISIT_OWNER_SIM, 1, sim->multipletypes[domain].dims[1], sim->multipletypes[domain].y);
            VisIt_VariableData_setDataF(hz, VISIT_OWNER_SIM, 1, sim->multipletypes[domain].dims[2], sim->multipletypes[domain].z);
            VisIt_RectilinearMesh_setCoordsXYZ(h, hx, hy, hz);

            /* Do ghost cells using a ghost cells array. */
            VisIt_VariableData_alloc(&gc);
            ncells = (sim->multipletypes[domain].dims[0]-1) *
                     (sim->multipletypes[domain].dims[1]-1) *
                     (sim->multipletypes[domain].dims[2]-1);
            VisIt_VariableData_setDataI(gc, VISIT_OWNER_SIM, 1, ncells, sim->multipletypes[domain].ghostCells);
            VisIt_RectilinearMesh_setGhostCells(h, gc);
        }
    }
    return h;
}