We consider a Markov-modulated fluid flow production model under the D-policy, that is, as soon as the storage reaches level 0, the machine becomes idle until the total storage exceeds a predetermined threshold D. Thus, the production process alternates between a busy and an idle machine. During the busy period, the storage decreases linearly due to continuous production and increases due to supply; during the idle period, no production is rendered by the machine and the storage level increases by only supply arrivals. We consider two types of model with different supply process patterns: continuous inflows with linear rates (fluid type), and batch inflows, where the supplies arrive according to a Markov additive process (MAP) and their sizes are independent and have phase-type distributions depending on the type of arrival (MAP type). Four types of cost are considered: a setup cost, a production cost, a penalty cost for an idle machine, and a storage cost. Using tools from multidimensional martingale and hitting time theory, we derive explicit formulae for these cost functionals in the discounted case. Numerical examples, a sensitivity analysis, and insights are provided.