TriangleMesh IsotropicParticleMesher::_polygonizeAll(FragmentedVector<MarkerParticle> &particles, 
	                                                 FluidMaterialGrid &materialGrid) {
	int subd = _subdivisionLevel;
	int width = _isize*subd;
	int height = _jsize*subd;
	int depth = _ksize*subd;
	double dx = _dx / (double)subd;

	ImplicitSurfaceScalarField field(width + 1, height + 1, depth + 1, dx);

	int origsubd = materialGrid.getSubdivisionLevel();
	materialGrid.setSubdivisionLevel(subd);
	field.setMaterialGrid(materialGrid);
	materialGrid.setSubdivisionLevel(origsubd);

	field.setPointRadius(_particleRadius);

    for (unsigned int i = 0; i < particles.size(); i++) {
        field.addPoint(particles[i].position);
    }

    Polygonizer3d polygonizer(&field);
    polygonizer.polygonizeSurface();

    return polygonizer.getTriangleMesh();
}
void IsotropicParticleMesher::_getSliceMaterialGrid(int startidx, int endidx,
		                       FluidMaterialGrid &materialGrid,
		                       FluidMaterialGrid &sliceMaterialGrid) {

	int origsubd = materialGrid.getSubdivisionLevel();
	materialGrid.setSubdivisionLevel(_subdivisionLevel);
	
	Material m;
	for (int k = 0; k < sliceMaterialGrid.depth; k++) {
		for (int j = 0; j < sliceMaterialGrid.height; j++) {
			for (int i = 0; i < sliceMaterialGrid.width; i++) {
				m = materialGrid(startidx + i, j, k);
				sliceMaterialGrid.set(i, j, k, m);
			}
		}
	}

	materialGrid.setSubdivisionLevel(origsubd);
}
Пример #3
0
void TurbulenceField::calculateTurbulenceField(MACVelocityField *vfield,
                                               FluidMaterialGrid &mgrid) {

    GridIndexVector fluidcells(mgrid.width, mgrid.height, mgrid.depth);
    for (int k = 0; k < mgrid.depth; k++) {
        for (int j = 0; j < mgrid.height; j++) {
            for (int i = 0; i < mgrid.width; i++) {
                if (mgrid.isCellFluid(i, j, k)) {
                    fluidcells.push_back(i, j, k);
                }
            }
        }
    }

    calculateTurbulenceField(vfield, fluidcells);
}
Пример #4
0
void ScalarField::setMaterialGrid(FluidMaterialGrid &matGrid) {
    FLUIDSIM_ASSERT(matGrid.width == _isize-1 && 
           matGrid.height == _jsize-1 && 
           matGrid.depth == _ksize-1);

    GridIndex vertices[8];
    for (int k = 0; k < _ksize-1; k++) {
        for (int j = 0; j < _jsize-1; j++) {
            for (int i = 0; i < _isize-1; i++) {
                if (matGrid.isCellSolid(i, j, k)) {
                    Grid3d::getGridIndexVertices(i, j, k, vertices);
                    for (int idx = 0; idx < 8; idx++) {
                        _isVertexSolid.set(vertices[idx], true);
                    }
                }
            }
        }
    }
}
Пример #5
0
GridIndexVector FluidSource::getAirCells(FluidMaterialGrid &materialGrid,
                                                              double dx) {
    int w = materialGrid.width;
    int h = materialGrid.height;
    int d = materialGrid.depth;
    GridIndexVector cells(w, h, d);

    if (!isActive()) {
        return cells;
    }

    GridIndexVector overlappingIndices(w, h, d);
    _getOverlappingCells(overlappingIndices, dx);

    GridIndex g;
    for (unsigned int i = 0; i < overlappingIndices.size(); i++) {
        g = overlappingIndices[i];
        if (materialGrid.isCellAir(g)) {
            cells.push_back(g);
        }
    }

    return cells;
}