#include "sgm_esl.h"

int SGM_ESL::OutModEleData(char* filename,string data_name,_1dArray data_array){
	if (!strcmp(filename,"NULL")) return 0;

	ofstream outfile(filename,ios::app);
	if (!outfile){
		cerr << BOLDRED << "error ==> " << RESET << "fail to create the file: " << filename << endl;
		return -1;
	}

	outfile<<"$ElementData"<<endl;
	outfile<<1<<endl<<data_name<<endl<<1<<endl<<0.0<<endl<<3<<endl<<0<<endl<<1<<endl<<data_array.size()<<endl;
	for (int i = 0; i < data_array.size(); i++)
	{
		//注意这里我们没有记录稀疏模型的id 所以不适合输出稀疏模型
		outfile << i << " " << setprecision(16) << data_array[i] << endl;
	}
	outfile<<"$EndElementData"<< endl;
	outfile.close();
	return 0;
}