void applyBoundary(float[][] t) {

		if (boundary instanceof DirichletThermalBoundary) {
			DirichletThermalBoundary b = (DirichletThermalBoundary) boundary;
			float tUpper = b.getTemperatureAtBorder(Boundary.UPPER);
			float tLower = b.getTemperatureAtBorder(Boundary.LOWER);
			float tLeft = b.getTemperatureAtBorder(Boundary.LEFT);
			float tRight = b.getTemperatureAtBorder(Boundary.RIGHT);
			for (int i = 0; i < nx; i++) {
				t[i][0] = tUpper;
				t[i][ny1] = tLower;
			}
			for (int j = 0; j < ny; j++) {
				t[0][j] = tLeft;
				t[nx1][j] = tRight;
			}
		} else if (boundary instanceof ComplexDirichletThermalBoundary) {
			ComplexDirichletThermalBoundary b = (ComplexDirichletThermalBoundary) boundary;
			float[] tUpper = b.getTemperaturesAtBorder(Boundary.UPPER);
			float[] tLower = b.getTemperaturesAtBorder(Boundary.LOWER);
			float[] tLeft = b.getTemperaturesAtBorder(Boundary.LEFT);
			float[] tRight = b.getTemperaturesAtBorder(Boundary.RIGHT);
			for (int i = 0; i < nx; i++) {
				t[i][0] = tUpper[i];
				t[i][ny1] = tLower[i];
			}
			for (int j = 0; j < ny; j++) {
				t[0][j] = tLeft[j];
				t[nx1][j] = tRight[j];
			}
		} else if (boundary instanceof NeumannThermalBoundary) {
			NeumannThermalBoundary b = (NeumannThermalBoundary) boundary;
			float fN = b.getFluxAtBorder(Boundary.UPPER);
			float fS = b.getFluxAtBorder(Boundary.LOWER);
			float fW = b.getFluxAtBorder(Boundary.LEFT);
			float fE = b.getFluxAtBorder(Boundary.RIGHT);
			// very small conductivity at the border could cause strange behaviors (e.g., huge number of isotherm lines), so impose a minimum
			float minConductivity = 0.001f;
			for (int i = 0; i < nx; i++) {
				t[i][0] = t[i][1] + fN * deltaY / Math.max(conductivity[i][0], minConductivity);
				t[i][ny1] = t[i][ny2] - fS * deltaY / Math.max(conductivity[i][ny1], minConductivity);
			}
			for (int j = 0; j < ny; j++) {
				t[0][j] = t[1][j] - fW * deltaX / Math.max(conductivity[0][j], minConductivity);
				t[nx1][j] = t[nx2][j] + fE * deltaX / Math.max(conductivity[nx1][j], minConductivity);
			}
		}

	}