/*!\file ComputeStrainRatex
 * \brief: compute pressure according to each element
 */

#include "./ComputeStrainRatex.h"

#include "../../shared/shared.h"
#include "../../toolkits/toolkits.h"

void	ComputeStrainRatex(Vector<IssmDouble>** peps,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,Parameters* parameters){

	/*Intermediary*/
	int      numberofelements;
	Element* element=NULL;

	/*output: */
	Vector<IssmDouble>* eps=NULL;

	/*Recover numberofelements: */
	parameters->FindParam(&numberofelements,MeshNumberofelementsEnum);

	/*Allocate eps on numberofelements (only 1 dof): */
	eps=new Vector<IssmDouble>(numberofelements);

	/*Compute basal stress for each element: */
	for(int i=0;i<elements->Size();i++){
		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
		element->ComputeStrainRate(eps);
	}

	/*Assemble vector: */
	eps->Assemble();

	/*Assign output pointers: */
	*peps=eps;

}
