Exemple #1
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, "mesh1d") == 0)
    {
        if(VisIt_UnstructuredMesh_alloc(&h) != VISIT_ERROR)
        {
            visit_handle x,y,conn;
            int nzones;

            nzones = sim->npts-1;
            VisIt_VariableData_alloc(&x);
            VisIt_VariableData_alloc(&y);
            VisIt_VariableData_setDataF(x, VISIT_OWNER_SIM, 1, sim->npts, sim->x);
            VisIt_VariableData_setDataF(y, VISIT_OWNER_SIM, 1, sim->npts, sim->y);

            VisIt_VariableData_alloc(&conn);
            VisIt_VariableData_setDataI(conn, VISIT_OWNER_SIM, 1, 
                3*nzones, sim->conn);

            VisIt_UnstructuredMesh_setCoordsXY(h, x, y);
            VisIt_UnstructuredMesh_setConnectivity(h, nzones, conn);
        }
    }

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

    if(strcmp(name, "unstructured3d") == 0)
    {
        if(VisIt_UnstructuredMesh_alloc(&h) != VISIT_ERROR)
        {
            visit_handle x,y,z,conn;

            VisIt_VariableData_alloc(&x);
            VisIt_VariableData_alloc(&y);
            VisIt_VariableData_alloc(&z);
            VisIt_VariableData_setDataD(x, VISIT_OWNER_SIM, 1, umnnodes, umx);
            VisIt_VariableData_setDataD(y, VISIT_OWNER_SIM, 1, umnnodes, umy);
            VisIt_VariableData_setDataD(z, VISIT_OWNER_SIM, 1, umnnodes, umz);

            VisIt_VariableData_alloc(&conn);
            VisIt_VariableData_setDataI(conn, VISIT_OWNER_SIM, 1, 
                lconnectivity, connectivity);

            VisIt_UnstructuredMesh_setCoordsXYZ(h, x, y, z);
            VisIt_UnstructuredMesh_setConnectivity(h, umnzones, conn);
        }
    }

    return h;
}
Exemple #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_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;
}
Exemple #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;
}
Exemple #5
0
visit_handle
SimGetMesh(int domain, const char *name, void *cbdata)
{
    visit_handle h = VISIT_INVALID_HANDLE;
    visit_handle c = VISIT_INVALID_HANDLE;
    int owner = VISIT_OWNER_SIM;
    int dt = VISIT_DATATYPE_FLOAT;

    if(strstr(name, "double") != NULL)
        dt = VISIT_DATATYPE_DOUBLE;
    if(strstr(name, "dynamic") != NULL)
        owner = VISIT_OWNER_VISIT;

    if(strstr(name, "curv") != NULL)
    {
        if(VisIt_CurvilinearMesh_alloc(&h) == VISIT_OKAY &&
           VisIt_VariableData_alloc(&c) == VISIT_OKAY)
        {
            if(strstr(name, "curv2d") != NULL)
            {
                int dims[2];
                dims[0] = NX;
                dims[1] = NY;
                SetData(c, owner, dt, 2, NX*NY, (float*)coords2d);
                VisIt_CurvilinearMesh_setCoords2(h, dims, c);
            }
            else
            {
                int dims[3];
                dims[0] = NX;
                dims[1] = NY;
                dims[2] = NZ;
                SetData(c, owner, dt, 3, NX*NY*NZ, (float*)coords3d);
                VisIt_CurvilinearMesh_setCoords3(h, dims, c);
            }
        }
    }
    else if(strstr(name, "point") != NULL)
    {
        if(VisIt_PointMesh_alloc(&h) == VISIT_OKAY &&
           VisIt_VariableData_alloc(&c) == VISIT_OKAY)
        {
            if(strstr(name, "point2d") != NULL)
                SetData(c, owner, dt, 2, NX*NY, (float*)coords2d);
            else
                SetData(c, owner, dt, 3, NX*NY*NZ, (float*)coords3d);

            VisIt_PointMesh_setCoords(h, c);
        }
    }
    else if(strstr(name, "ucd") != NULL)
    {
        visit_handle hc;
        if(VisIt_UnstructuredMesh_alloc(&h) == VISIT_OKAY &&
           VisIt_VariableData_alloc(&c) == VISIT_OKAY &&
           VisIt_VariableData_alloc(&hc) == VISIT_OKAY)
        {
            int nzones = 0;
            if(strstr(name, "ucd2d") != NULL)
            {
                int i, j, lconnectivity;
                int *connectivity = NULL, *conn = NULL;

                nzones = (NX-1)*(NY-1);
                lconnectivity = 5*nzones;
                conn = connectivity = (int*)malloc(lconnectivity * sizeof(int));
                for(j = 0; j < NY-1; ++j)
                    for(i = 0; i < NX-1; ++i)
                    {
                        *conn++ = VISIT_CELL_QUAD;
                        *conn++ = j*NX + i;
                        *conn++ = j*NX + (i+1);
                        *conn++ = (j+1)*NX + (i+1);
                        *conn++ = (j+1)*NX + i;
                    }
                SetData(c, owner, dt, 2, NX*NY, (float*)coords2d);
                VisIt_VariableData_setDataI(hc, VISIT_OWNER_VISIT, 1, lconnectivity,
                    connectivity);
            }
            else
            {
                int i, j, k, lconnectivity;
                int *connectivity = NULL, *conn = NULL;

                nzones = (NX-1)*(NY-1)*(NZ-1);
                lconnectivity = 9*nzones;
                conn = connectivity = (int*)malloc(lconnectivity * sizeof(int));
                for(k = 0; k < NZ-1; ++k)
                  for(j = 0; j < NY-1; ++j)
                    for(i = 0; i < NX-1; ++i)
                    {
                        *conn++ = VISIT_CELL_HEX;
                        *conn++ = k*NX*NY + j*NX + i;
                        *conn++ = k*NX*NY + j*NX + (i+1);
                        *conn++ = k*NX*NY + (j+1)*NX + (i+1);
                        *conn++ = k*NX*NY + (j+1)*NX + i;
                        *conn++ = (k+1)*NX*NY + j*NX + i;
                        *conn++ = (k+1)*NX*NY + j*NX + (i+1);
                        *conn++ = (k+1)*NX*NY + (j+1)*NX + (i+1);
                        *conn++ = (k+1)*NX*NY + (j+1)*NX + i;
                    }
                SetData(c, owner, dt, 3, NX*NY*NZ, (float*)coords3d);
                VisIt_VariableData_setDataI(hc, VISIT_OWNER_VISIT, 1, lconnectivity,
                    connectivity);
            }

            VisIt_UnstructuredMesh_setCoords(h, c);
            VisIt_UnstructuredMesh_setConnectivity(h, nzones, hc);
        }
    }
    return h;
}