Commit 3be75593 by Christophe Geuzaine

new ElementTable postoperation format

parent 5cdbc42b
Pipeline #1065 passed with stage
in 9 minutes 46 seconds
......@@ -1519,6 +1519,7 @@ struct PostOpSolutions {
#define FORMAT_NODE_TABLE 20
#define FORMAT_LOOP_ERROR 21
#define FORMAT_GETDP 22
#define FORMAT_ELEMENT_TABLE 23
/* PostSubOperation.Sort */
#define SORT_BY_POSITION 1
......
......@@ -332,6 +332,7 @@ struct StringXDefine PostSubOperation_Format[] = {
{"Table" , FORMAT_SPACE_TABLE },
{"SimpleTable" , FORMAT_SIMPLE_SPACE_TABLE },
{"NodeTable" , FORMAT_NODE_TABLE },
{"ElementTable" , FORMAT_ELEMENT_TABLE },
{"ValueOnly" , FORMAT_VALUE_ONLY },
{"TimeTable" , FORMAT_TIME_TABLE },
{"RegionTable" , FORMAT_REGION_TABLE },
......
......@@ -857,6 +857,50 @@ static void NodeTable_PrintElement(int TimeStep, int NbTimeStep, int NbrHarmonic
}
/* ------------------------------------------------------------------------ */
/* ElementTable format */
/* ------------------------------------------------------------------------ */
// global static map for element table output (cannot be saved incrementally for
// each element)
static int ElementTable_StartNew = 0;
static std::map<int, std::vector<double> > ElementTable;
static void ElementTable_PrintElement(int TimeStep, int NbTimeStep, int NbrHarmonics,
struct PostElement *PE)
{
if(ElementTable_StartNew){
ElementTable_StartNew = 0 ;
ElementTable.clear();
}
int numEle = -1;
if(PE->Index >= 0 && PE->Index < Geo_GetNbrGeoElements()){
numEle = Geo_GetGeoElement(PE->Index)->Num;
int Size = 0;
switch(PE->Value[0].Type){
case SCALAR : Size = 1 ; break ;
case VECTOR : Size = 3 ; break ;
case TENSOR_DIAG : Size = 3 ; break ;
case TENSOR_SYM : Size = 6 ; break ;
case TENSOR : Size = 9 ; break ;
}
if(Size){
ElementTable[numEle].resize
(NbTimeStep * PE->NbrNodes * NbrHarmonics * Size, 0.);
for(int i = 0 ; i < PE->NbrNodes ; i++){
for(int k = 0 ; k < NbrHarmonics ; k++){
for(int j = 0 ; j < Size ; j++){
double val = PE->Value[i].Val[MAX_DIM * k + j];
int idx = TimeStep * PE->NbrNodes * NbrHarmonics * Size +
i * NbrHarmonics * Size + k * Size + j;
ElementTable[numEle][idx] = val;
}
}
}
}
}
}
/* ------------------------------------------------------------------------ */
/* S t o r e P o s t O p R e s u l t */
/* ------------------------------------------------------------------------ */
......@@ -1105,6 +1149,9 @@ void Format_PostHeader(struct PostSubOperation *PSO_P, int NbTimeStep,
case FORMAT_NODE_TABLE :
NodeTable_StartNew = 1 ;
break ;
case FORMAT_ELEMENT_TABLE :
ElementTable_StartNew = 1 ;
break ;
case FORMAT_ADAPT :
if(PostStream) fprintf(PostStream, "$Adapt /* %s */\n", name) ;
break ;
......@@ -1380,6 +1427,33 @@ void Format_PostFooter(struct PostSubOperation *PSO_P, int Store)
PSO_P->Closed);
}
break;
case FORMAT_ELEMENT_TABLE :
if(PostStream){
fprintf(PostStream, "%d\n", (int)ElementTable.size());
for(std::map<int, std::vector<double> >::iterator it = ElementTable.begin();
it != ElementTable.end(); it++){
fprintf(PostStream, "%d", it->first);
for(unsigned int i = 0; i < it->second.size(); i++)
fprintf(PostStream, " %.16g", it->second[i]);
fprintf(PostStream, "\n");
}
}
{
std::vector<double> exp;
exp.push_back(ElementTable.size());
for(std::map<int, std::vector<double> >::iterator it = ElementTable.begin();
it != ElementTable.end(); it++){
exp.push_back(it->first);
for(unsigned int i = 0; i < it->second.size(); i++)
exp.push_back(it->second[i]);
}
GetDPNumbers[CurrentName] = exp;
if(PSO_P->SendToServer && strcmp(PSO_P->SendToServer, "No"))
Message::AddOnelabNumberChoice(PSO_P->SendToServer, exp, PSO_P->Color,
PSO_P->Units, PSO_P->Label, PSO_P->Visible,
PSO_P->Closed);
}
break;
case FORMAT_LOOP_ERROR :
Solutions_L = ((struct PostOpSolutions*)
List_Pointer(Current.PostOpData_L, Current.PostOpDataIndex))->Solutions_L;
......@@ -1552,6 +1626,9 @@ void Format_PostElement(struct PostSubOperation *PSO_P, int Contour, int Store,
case FORMAT_NODE_TABLE :
NodeTable_PrintElement(TimeStep, NbTimeStep, NbrHarmonics, PE);
break;
case FORMAT_ELEMENT_TABLE :
ElementTable_PrintElement(TimeStep, NbTimeStep, NbrHarmonics, PE);
break;
case FORMAT_LOOP_ERROR :
StorePostOpResult(NbrHarmonics, PE);
break;
......
......@@ -86,6 +86,7 @@ eps = 1.e-5;
PostOperation {
{ Name phi ; NameOfPostProcessing MagSta_phi;
Operation {
Print[ phi, OnElementsOf Domain, Format ElementTable, Depth 1] ;
Print[ phi, OnElementsOf Domain, File "phi.pos" ] ;
Print[ hc, OnElementsOf Domain, File "hc.pos" ] ;
Print[ b, OnElementsOf Domain, File "b_phi.pos" ] ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment