Issue loading quad4 nodal data from ExodusII #4340
-
summaryTwo nodes in a quadrilateral loaded from ExodusII have the wrong description of problemI checked this with both libMesh 1.7.8 and the development version (as of this morning). I'm loading nodal ExodusII data and, at some point in the process, two nodes of a quadrilateral get each-other's node numbers. More precisely, I start with (via but later on libMesh appears to renumber things. The solitary element is read as i.e., the nodes 2 and 3 have the wrong I have absolutely no idea what causes this. Is this some sort of obscure issue related to not supplying the node number map, or something else in the ExodusII file? exodus fileI narrowed this problem down to a one-element mesh (I started in 3d with hexahedra, the problem is the same there). Here's the test file (via netcdf test {
dimensions:
len_name = 256 ;
time_step = UNLIMITED ; // (1 currently)
num_dim = 2 ;
num_nodes = 4 ;
num_elem = 1 ;
num_el_blk = 1 ;
num_el_in_blk1 = 1 ;
num_nod_per_el1 = 4 ;
num_nod_var = 4 ;
variables:
double time_whole(time_step) ;
int eb_status(num_el_blk) ;
int eb_prop1(num_el_blk) ;
eb_prop1:name = "ID" ;
double coordx(num_nodes) ;
double coordy(num_nodes) ;
char eb_names(num_el_blk, len_name) ;
eb_names:_FillValue = "" ;
char coor_names(num_dim, len_name) ;
coor_names:_FillValue = "" ;
int connect1(num_el_in_blk1, num_nod_per_el1) ;
connect1:elem_type = "QUAD4" ;
char name_nod_var(num_nod_var, len_name) ;
name_nod_var:_FillValue = "" ;
double vals_nod_var1(time_step, num_nodes) ;
double vals_nod_var2(time_step, num_nodes) ;
double vals_nod_var3(time_step, num_nodes) ;
double vals_nod_var4(time_step, num_nodes) ;
// global attributes:
:api_version = 9.04f ;
:version = 9.04f ;
:floating_point_word_size = 8 ;
:file_size = 1 ;
:maximum_name_length = 32 ;
:int64_status = 0 ;
:title = "test" ;
data:
time_whole = 0 ;
eb_status = 1 ;
eb_prop1 = 1 ;
coordx = 0, 1, 0, 1 ;
coordy = 0, 0, 1, 1 ;
eb_names =
"" ;
coor_names =
"",
"" ;
connect1 =
1, 2, 4, 3 ;
name_nod_var =
"X1",
"X2",
"exp",
"monomial" ;
vals_nod_var1 =
0, 1, 0, 1 ;
vals_nod_var2 =
0, 0, 1, 1 ;
vals_nod_var3 =
1, 2.71828182845905, 2.71828182845905, 7.38905609893065 ;
vals_nod_var4 =
0, 0, 0, 1 ;
}source codeThere's probably a better way to do this, but since #include <libmesh/equation_systems.h>
#include <libmesh/exodusII_io.h>
#include <libmesh/elem.h>
#include <libmesh/node.h>
#include <libmesh/numeric_vector.h>
#include <libmesh/replicated_mesh.h>
int main(int argc, char **argv) {
using namespace libMesh;
LibMeshInit init(argc, argv);
ReplicatedMesh mesh(init.comm());
ExodusII_IO exodus_io(mesh);
exodus_io.read("test.e");
mesh.prepare_for_use();
EquationSystems equation_systems(mesh);
System &X1_system = equation_systems.add_system<System>("X1");
X1_system.add_variable("X1", FEType(1));
System &X2_system = equation_systems.add_system<System>("X2");
X2_system.add_variable("X2", FEType(1));
equation_systems.init();
exodus_io.copy_nodal_solution(X1_system, "X1", "X1");
exodus_io.copy_nodal_solution(X2_system, "X2", "X2");
const auto &X1 = *X1_system.solution;
const auto &X2 = *X2_system.solution;
const Elem *elem = mesh.elem_ptr(0);
std::cout << "volume = " << elem->volume() << std::endl;
for (unsigned int node_n = 0; node_n < elem->n_nodes(); ++node_n)
{
elem->node_ptr(node_n)->print_info(std::cout);
}
for (const auto *node : mesh.node_ptr_range()) {
std::cout << "id = " << node->id() << std::endl;
std::cout << "node = " << (*node)(0) << ", " << (*node)(1) << std::endl;
std::cout << "field = " << X1(node->dof_number(X1_system.number(), 0, 0))
<< ", " << X2(node->dof_number(X2_system.number(), 0, 0))
<< std::endl;
}
}executable output |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
It looks to me like the mesh has been automatically renumbered, which libmesh does during before reading in the exo file? I don't know exactly what version of libmesh we first settled on that API, but it should definitely work in the latest master. |
Beta Was this translation helpful? Give feedback.
It looks to me like the mesh has been automatically renumbered, which libmesh does during
prepare_for_use()unless you explicitly tell it not to. Did you try callingbefore reading in the exo file? I don't know exactly what version of libmesh we first settled on that API, but it should definitely work in the latest master.