/*
 * Copyright (C) 2008-2012 Delft University of Technology - All rights reserved.
 *
 * Author: Reijer Idema
 */

/**
 * @file PowerVector.h
 * Power System Power Vector class header.
 */
#ifndef PowerFlower_PowerVector_h
#define PowerFlower_PowerVector_h

#include "../PetscUtils/PetscUtils.h"	// USES PetscUtils
#include "../PowerSystem/PowerSystem.h"	// USES PowerSystem
#include "PowerFlower.def"

POWERFLOWER_NAMESPACE_BEGIN

/**
 * Power System Power Vector class.
 * Implements the power system power vector class,
 * describing the injected complex power in each bus of a power system.
 */
class PowerVector
{
public:
	// LIFECYCLE
	PowerVector(void);
	~PowerVector(void);

	// OPERATIONS
	/**
	 * Clears the power vector object.
	 */
	void Clear(void);

	/**
	 * Builds the power vector.
	 * Sets the vector dimension, allocates the memory,
	 * and sets the power values from the given power system.
	 * @param rPowerSystem power system to get the dimension and power values from.
	 * @return \c true on success, \c false otherwise.
	 */
	bool Build(const POWERSYSTEM_NAMESPACE_NAME::PowerSystem& rPowerSystem);

	// ACCESS

	/**
	 * Gets the real part of the power vector.
	 * @return real part of the power vector.
	 */
	PetscUtils::ConstVec GetReal(void) const;

	/**
	 * Gets the imaginary part of the power vector.
	 * @return imaginary part of the power vector.
	 */
	PetscUtils::ConstVec GetImag(void) const;

private:

	/**
	 * Builds the power vector.
	 * Sets the vector dimension, allocates the memory,
	 * and sets the power values from the given power system.
	 * @param rPowerSystem power system to get the dimension and power values from.
	 * @return \c true on success, \c false otherwise.
	 */
	bool Build_Private(const POWERSYSTEM_NAMESPACE_NAME::PowerSystem& rPowerSystem);

	PetscErrorCode mErr;		///< Most recent PETSc error code.
	Vec mP;						///< Real part of the power vector.
	Vec mQ;						///< Imaginary part of the power vector.
};

POWERFLOWER_NAMESPACE_END

#endif // PowerFlower_PowerVector_h
