after using the GiDpost library in our code we experience still some trouble with mesh groups and the definition of Gausspointsets.
The basic question is:
Should the Gausspointset definition be inside the mesh group or outside? Or somewhere else??
Here is a small example explaining the problems we experience with both possibilities:
First the mesh file, the same for both variants:
Code: Select all
Group "Mesh 1"
MESH "TestMsh" dimension 2 ElemType Triangle Nnode 3
# color 0 0.99 0
Coordinates
1 0 0 0
2 0 1 0
3 0 2 0
4 1 0 0
5 1 1 0
6 1 2 0
7 2 0 0
8 2 1 0
9 2 2 0
End Coordinates
Elements
1 1 5 4 2
2 1 2 5 2
3 2 6 5 2
4 2 3 6 2
5 4 8 7 2
6 4 5 8 2
7 5 9 8 2
8 5 6 9 2
End Elements
End Group
Group "Mesh 2"
MESH "TestMsh" dimension 2 ElemType Quadrilateral Nnode 9
# color 0 0.99 0
Coordinates
1 0 0 0
2 0 1 0
3 0 2 0
4 1 0 0
5 1 1 0
6 1 2 0
7 2 0 0
8 2 1 0
9 2 2 0
End Coordinates
Elements
1 1 7 9 3 4 8 6 2 5 2
End Elements
End Group
The corresponding result file:
Code: Select all
GiD Post Results File 1.0
GaussPoints "GPTri" ElemType Triangle "TestMsh"
Number Of Gauss Points: 1
Natural Coordinates: Internal
End GaussPoints
OnGroup "Mesh 1"
Result "Scalar on GP" "Analysis" 1 Scalar OnGaussPoints "GPTri"
Values
1 0.00125126
2 0.563585
3 0.193304
4 0.808741
5 0.585009
6 0.479873
7 0.350291
8 0.895962
End Values
End OnGroup
GaussPoints "GPQuad" ElemType Quadrilateral "TestMsh"
Number Of Gauss Points: 1
Natural Coordinates: Internal
End GaussPoints
OnGroup "Mesh 2"
Result "Scalar on GP" "Analysis" 2 Scalar OnGaussPoints "GPQuad"
Values
1 0.82284
End Values
End OnGroup
VARIANT B: Inside the mesh group:
Moving the Gausspointset definition into the group definition the res file looks like:
Code: Select all
GiD Post Results File 1.0
OnGroup "Mesh 1"
GaussPoints "GPTri" ElemType Triangle "TestMsh"
Number Of Gauss Points: 1
Natural Coordinates: Internal
End GaussPoints
Result "Scalar on GP" "Analysis" 1 Scalar OnGaussPoints "GPTri"
Values
1 0.00125126
2 0.563585
3 0.193304
4 0.808741
5 0.585009
6 0.479873
7 0.350291
8 0.895962
End Values
End OnGroup
OnGroup "Mesh 2"
GaussPoints "GPQuad" ElemType Quadrilateral "TestMsh"
Number Of Gauss Points: 1
Natural Coordinates: Internal
End GaussPoints
Result "Scalar on GP" "Analysis" 2 Scalar OnGaussPoints "GPQuad"
Values
1 0.82284
End Values
End OnGroup
But trying to create the file in this order with GiDpost we get an runtime error for the call of "GiD_fBeginGaussPoint":
Code: Select all
Assertion failed: CheckState( POST_S0, File ), file M:\NumPro\tools\GiDPost\gidpost2.3_src\source\gidpost.c, line 1263
invalid state 'OnGroup block' should be 'TOP level'
Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include "gidpost.h"
#define ASCII_FORMAT
typedef struct {
int id;
float x, y, z;
} SCoord;
typedef struct {
int id;
int n1, n2, n3;
} SElem;
SCoord nodes[9];
SElem elems[8];
void GenMesh()
{
int i, j, idx;
SCoord * node;
SElem * elm1, * elm2;
idx = 1;
for ( i = 0; i < 3; i++ ) {
for ( j = 0; j < 3; j++, idx++ ) {
node = nodes + idx -1;
node->id = idx;
node->x = (float)(i);
node->y = (float)(j);
node->z = 0;
}
}
idx = 0;
for ( i = 0; i < 2; i++ ) {
for ( j = 0; j < 2; j++, idx+=2 ) {
elm1 = elems + idx;
elm2 = elm1 + 1;
elm1->id = idx+1;
elm1->n1 = i*3 + j + 1;
elm1->n3 = i*3 + j + 1 + 3 ;
elm1->n2 = elm1->n3 + 1;
elm2->id = idx+2;
elm2->n1 = elm1->n1;
elm2->n2 = elm1->n1 + 1;
elm2->n3 = elm1->n2;
}
}
}
float Random()
{
return rand()/(float)(RAND_MAX);
}
int main()
{
int i;
SCoord * node;
SElem * elm;
int elmi[4];
int elmi2[10];
GiD_FILE fdm, fdr;
GenMesh();
GiD_PostInit();
#if defined(ASCII_FORMAT)
fdm = GiD_fOpenPostMeshFile( "test_fd.post.msh", GiD_PostAscii);
fdr = GiD_fOpenPostResultFile( "test_fd.post.res", GiD_PostAscii);
#else
fdm = fdr = GiD_fOpenPostResultFile( "test_fd.post.bin", GiD_PostBinary);
#endif
/* write mesh for first time step */
GiD_fBeginMeshGroup(fdm, "Mesh 1");
GiD_fBeginMeshColor(fdm, "TestMsh", GiD_2D, GiD_Triangle, 3, 0, 0.99, 0);
/* coordinates */
GiD_fBeginCoordinates(fdm);
for ( i = 0; i < 9; i++ ) {
node = nodes + i;
GiD_fWriteCoordinates(fdm, node->id, node->x, node->y, node->z );
}
GiD_fEndCoordinates(fdm);
/* elements */
GiD_fBeginElements(fdm);
for ( i = 0; i < 8; i++ ) {
elm = elems + i;
elmi[0] = elm->n1;
elmi[1] = elm->n2;
elmi[2] = elm->n3;
elmi[3] = 2;
GiD_fWriteElementMat(fdm, elm->id, elmi);
}
GiD_fEndElements(fdm);
GiD_fEndMesh(fdm);
GiD_fEndMeshGroup(fdm);
// A: outside group
//GiD_fBeginGaussPoint(fdr, "GPTri", GiD_Triangle, "TestMsh", 1, 0, 1);
//GiD_fEndGaussPoint(fdr);
/* now results for first time step */
GiD_fBeginOnMeshGroup(fdr, "Mesh 1");
// B: inside group
GiD_fBeginGaussPoint(fdr, "GPTri", GiD_Triangle, "TestMsh", 1, 0, 1);
GiD_fEndGaussPoint(fdr);
// Result
GiD_fBeginResult(fdr, "Scalar on GP", "Analysis", 1.0, GiD_Scalar, GiD_OnGaussPoints, "GPTri", NULL, 0, NULL);
for ( i = 0; i < 8; i++ ) {
GiD_fWriteScalar(fdr, i+1, Random());
}
GiD_fEndResult(fdr);
GiD_fEndOnMeshGroup(fdr);
/* write mesh for second time step */
GiD_fBeginMeshGroup(fdm, "Mesh 2");
GiD_fBeginMeshColor(fdm, "TestMsh", GiD_2D, GiD_Quadrilateral, 9, 0, 0.99, 0);
/* coordinates */
GiD_fBeginCoordinates(fdm);
for ( i = 0; i < 9; i++ ) {
node = nodes + i;
GiD_fWriteCoordinates(fdm, node->id, node->x, node->y, node->z );
}
GiD_fEndCoordinates(fdm);
/* elements */
GiD_fBeginElements(fdm);
elmi2[0] = 1;
elmi2[1] = 7;
elmi2[2] = 9;
elmi2[3] = 3;
elmi2[4] = 4;
elmi2[5] = 8;
elmi2[6] = 6;
elmi2[7] = 2;
elmi2[8] = 5;
elmi2[9] = 2;
GiD_fWriteElementMat(fdm, 1, elmi2);
GiD_fEndElements(fdm);
GiD_fEndMesh(fdm);
GiD_fEndMeshGroup(fdm);
// A: outside group
//GiD_fBeginGaussPoint(fdr, "GPQuad", GiD_Quadrilateral, "TestMsh", 1, 0, 1);
//GiD_fEndGaussPoint(fdr);
/* now results for second time step */
GiD_fBeginOnMeshGroup(fdr, "Mesh 2");
// B: inside group
GiD_fBeginGaussPoint(fdr, "GPQuad", GiD_Quadrilateral, "TestMsh", 1, 0, 1);
GiD_fEndGaussPoint(fdr);
// Result
GiD_fBeginResult(fdr, "Scalar on GP", "Analysis", 1.0, GiD_Scalar, GiD_OnGaussPoints, "GPQuad", NULL, 0, NULL);
GiD_fWriteScalar(fdr, 1, Random());
GiD_fEndResult(fdr);
GiD_fEndOnMeshGroup(fdr);
// Close file(s)
#ifdef ASCII_FORMAT
GiD_fClosePostMeshFile(fdm);
#endif
GiD_fClosePostResultFile(fdr);
GiD_PostDone();
printf("Finished normally!!");
return 0;
}
Is this a bug in GiD not finding the correct mesh in the group if the Gausspoints are defined outside or a bug in GiDpost requiring the wrong state for GiD_fBeginGaussPoint? Or is there a third variant that will solve both problems?
Thanks a lot for your help.
Malte