Output EP file for Elmer Post

Help
shirazbj
2010-10-22
2013-04-25
  • shirazbj
    shirazbj
    2010-10-22

    Hi,

    I am trting to output an EP file for Elmer Post. An EP file is roughly vertex+cell+n* time step results. I got the mesh displayed well in Elmer, but the pressure is not right. (Using the dam example.)

    Just wondering should I output both values on patch & in element, or just one of them?

    Any sugestion? Thanks in advance.

    Cean

     
  • shirazbj
    shirazbj
    2010-10-22

    part of my code:

    void WriteResultsEP (FILE * fp, int onFace, int inElement, double curtime)
    {
    fprintf (fp, "#Time 1 1 ");
    PrintAsciiTime (fp, curtime);
    if (onFace == LOGICAL_TRUE)
        {
    //printf ("onFACE=%d\n", nbpatches);
            for (i = 0; i < nbpatches; i++)
                    {
                            face=i;
    // Write pressure to file
    if (parameter.fsav == LOGICAL_TRUE)
                            {
            vs = V_GetCmp (&xpf, face + 1);
                             fprintf (fp, "%.3E  ", vs);
                            }
                           fprintf (fp, "\n");
                   }
        }
    if (inElement == LOGICAL_TRUE)
        {
    printf ("inElement=%d\n", nbelements);
            for (i = 0; i < nbelements; i++)
                    {
                            element=i;
    // Write pressure to file
    if (parameter.csav == LOGICAL_TRUE)
                            {
            vs = V_GetCmp (&xp, element + 1);
                             fprintf (fp, "%.3E  ", vs);
                            }
                             fprintf (fp, "\n");
                    }
        }
    }

     
  • Billy Araujo
    Billy Araujo
    2010-10-22

    Why you putting blank lines if no pressure values?

    fprintf (fp, "%.3E ", vs);  -> fprintf (fp, "%.3E\n", vs);

    My advice would be to try only exporting inElement values at first and debug from there. Does it create the file correctly? Where is Elmer format described? Where is the mesh information?

     
  • shirazbj
    shirazbj
    2010-10-23

    It just part of the code. I need to print U,V,W,P,T,S for one cell in one line if needed. So the \n must be printed at the last.

    The Elmer post file format is explained at:
    http://www.nic.funet.fi/pub/sci/physics/elmer/doc/ElmerSolverManual.pdf

    The good side I like EP file is that it is a single file include all time steps and ElmerPost read it without the hard disk spinning madly.

     
  • shirazbj
    shirazbj
    2010-11-01

    ok,know the reason now.

    OpemFVM is cell based, but ElmerPost need values at vertex. I'll try to get the vextes value from the cell centerd value.

     
  • Billy Araujo
    Billy Araujo
    2010-11-01

    Hi,

    Gmsh is also vertex based but I just send the cell center values for each vertex, i.e. the same vertex has several values and then Gmsh smoothes them out for me. Maybe elmer has same functionality.

     
  • shirazbj
    shirazbj
    2010-11-02

    the same vertex has several values ? Which part of code I should look at?

    I go through all the elements, assign the cell center value to all vertexes of that cell. In my case, the vertex value will be the last cell center value who includes that vertex.

    After trying to do this, the program can not finish one iteration. I think the problem is on memory allocation, which one I should use realloc() or calloc()? Where to call them?

    Thanks for help.  

    Bellow is what I have done:

    I defined in mesh.h:

    typedef struct
    {

      double u, v, w,p,T,s;

    } msh_value;
    msh_value *nodesvalue;

    alloced memory in MshImportMSH (char *file) in mesh.c

      nodesvalue = realloc (nodesvalue, nbnodes * sizeof (msh_vector));

    and free(nodesvalue) at the end of simulation().

    added this sub in post.c. It will be called in simulation() when output time is reached.

    void
    WriteAsciiScalarElement_ep (int wnum,FILE *fp_ep)
    {

    int i;
      int j;

    int element;

    double vx,vy,vz;
    double vp,vt,vs;
     
    printf ("In EP\n");
     
    fprintf (fp_ep, "#time 1 1 %d\n",wnum);
      for (i = 0; i < nbelements; i++)
      {
    element = i;
    for (j = 0; j < elements.nbnodes; j++)
    {
    vx = V_GetCmp (&xu, element + 1);
          nodesvalue[elements.node].u=vx;
         
    vy = V_GetCmp (&xv, element + 1);
          nodesvalue[elements.node].v=vy;
         
    vz = V_GetCmp (&xw, element + 1);
          nodesvalue[elements.node].w=vz;
         
    vp = V_GetCmp (&xp, element + 1);
          nodesvalue[elements.node].p=vp;
         
    vt = V_GetCmp (&xT, element + 1);
          nodesvalue[elements.node].T=vt;
         
    vs = V_GetCmp (&xs, element + 1);
          nodesvalue[elements.node].s=vs;
        }
      }

      for (i = 0; i < nbnodes; i++)
      {
         if (parameter.csav == LOGICAL_TRUE)
         { 
           vx=nodesvalue_.u;
         fprintf (fp_ep, "%e ", vx);
         }
         if (parameter.csav == LOGICAL_TRUE)
         { 
           vy=nodesvalue.v;
         fprintf (fp_ep, "%e ", vy);
         }
         if (parameter.csav == LOGICAL_TRUE)
         { 
           vz=nodesvalue.w;
         fprintf (fp_ep, "%e ", vz);
         }
         if (parameter.csav == LOGICAL_TRUE)
         { 
           vp=nodesvalue.p;
         fprintf (fp_ep, "%e ", vp);
         }
         if (parameter.csav == LOGICAL_TRUE)
         { 
           vt=nodesvalue.T;
         fprintf (fp_ep, "%e ", vt);
         }
         if (parameter.csav == LOGICAL_TRUE)
         { 
           vs=nodesvalue.s;
         fprintf (fp_ep, "%e ", vs);
         }
        fprintf (fp_ep, "\n");
      }
     
    printf ("Out EP\n");

    }
    _

     
  • shirazbj
    shirazbj
    2010-11-03

    all right now.

    This line is wrong nodesvalue = realloc (nodesvalue, nbnodes * sizeof (msh_vector));

    not 'msh_vector', but my 'msh_value' and should use malloc like this:

      nodesvalue = calloc (nbnodes,sizeof (msh_value));

    This time I locate this line at the begining of simulation().