PyMFEM icon indicating copy to clipboard operation
PyMFEM copied to clipboard

First element read by GF is 0 not the value in the file

Open jtristano opened this issue 1 year ago • 4 comments

When reading the mesh and GF attached, the first element gets a value of 0, not 1. When I write the GF back out, there is a difference between the files

mesh = mfem.Mesh(meshfile)
attr = mfem.GridFunction(mesh, attributefile)
attr.Load(self.attributefile, mesh.GetNE())
maxAttr = attr.Max()
logging.info(f"MAX ATTRIBUTE: {maxAttr}")
attr.Save("junk.gf")

jtristano avatar Nov 27 '23 21:11 jtristano

@jtristano, may I ask how you generate self.attributefile? Note that GridFunction does not implement its own Load method. It simply inherits mfem::Vector::Load. Thus, I suspect the right way is to use Print (not Save) to create a file. Then, because of the same reason, mfem::Vector::Print is called.

sshiraiwa avatar Dec 06 '23 21:12 sshiraiwa

If I dont call Save, I dont get the header for GF

Print just dumps a raw file. Why does this work for a solution but not a const fec?

FiniteElementSpace
FiniteElementCollection: Const3D
VDim: 1
Ordering: 0

Which then means I cannot generate the correct FESpace, correct?

jtristano avatar Dec 19 '23 16:12 jtristano

I have the input files attached. There is no 0 attribute elements in the attached attr file

jtristano avatar Dec 20 '23 13:12 jtristano