Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added tests for sequential read/write.
* Tests revealed that the sequential read/write wasn't really working. Now fixed! * Removed mpi-h5py as a dependency. Now any h5py will do. * Removed HDF5 as a config package. * Removed H5PY self-build option. * Added info on compiling mpi-h5py in `COMPILE.md`. * Added barrier to end of read/writes for safety.
- Loading branch information
Showing
13 changed files
with
130 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,73 @@ | ||
''' | ||
This script contains auxiliary mesh related tests. | ||
This script contains auxiliary mesh related tests. | ||
We test saving and loading of mesh and mesh variable objects. | ||
We also tests creation/load/save of non-partitioned mesh and | ||
variables. I'll leave this in for now, but I'm not sure if | ||
load/save of non-partitioned mesh is useful or even a good | ||
idea. Effectively, in parallel, we're saying that each process | ||
has its own distinct mesh object, but then we're saving it to | ||
a single global file. Sequentially this is fine (and each proc | ||
*could* specify its own filename), but collectively this doesn't | ||
make sense as we use COMM_WORLD but the mesh only is aware of | ||
COMM_SELF. Note that the test passes, but I've disabled it in | ||
any case as it doesn't make sense. | ||
''' | ||
import underworld as uw | ||
import numpy as np | ||
|
||
def meshtest(res, partitioned): | ||
mesh = uw.mesh.FeMesh_Cartesian(elementRes=(res,res),partitioned=partitioned) | ||
|
||
resp1 = res + 1 | ||
if not partitioned: | ||
if (len(mesh.data) != (resp1*resp1)): | ||
raise RuntimeError("A non-partitioned mesh should report identical vertex count "\ | ||
"independent of processor count.") | ||
# test save/load of mesh | ||
with mesh.deform_mesh(): | ||
mesh.data[:] *= 2. | ||
|
||
# Simple test to check non-parallel decomposed meshing is working. | ||
# Note that we are only really testing this parameter when we | ||
# run this test in parallel. | ||
mesh1 = uw.mesh.FeMesh_Cartesian(elementRes=(4,4),partitioned=False) | ||
|
||
if len(mesh1.data) != 25: | ||
raise RuntimeError("A non-partitioned mesh should report identical vertex count \ | ||
independent of processor count.") | ||
|
||
mesh2 = uw.mesh.FeMesh_Cartesian(elementRes=(10,10),partitioned=True) | ||
var = uw.mesh.MeshVariable( mesh2, nodeDofCount=2 ) | ||
var2 = uw.mesh.MeshVariable( mesh2, nodeDofCount=2 ) | ||
|
||
for ind, coord in enumerate(mesh2.data): | ||
var.data[ind] = [coord[1]+5., coord[0]*-2.] | ||
cpy = mesh.data.copy() | ||
mesh.save('temp.h5') | ||
mesh.reset() | ||
if np.allclose(mesh.data, cpy): | ||
raise RuntimeError("These arrays should be different.") | ||
mesh.load('temp.h5') | ||
if not np.allclose(mesh.data, cpy): | ||
raise RuntimeError("These arrays should be identical.") | ||
|
||
var.save('temp.h5') | ||
var2.load('temp.h5') | ||
# test save/load of meshvariable | ||
var = uw.mesh.MeshVariable( mesh, nodeDofCount=2 ) | ||
for ind, coord in enumerate(mesh.data): | ||
var.data[ind] = [coord[1]+5., coord[0]*-2.] | ||
|
||
checkpoint_pass = np.allclose(var.data, var2.data) | ||
var.syncronise() | ||
cpy = var.data.copy() | ||
var.save('temp2.h5') | ||
var.data[:] = 0. | ||
if np.allclose(var.data, cpy): | ||
raise RuntimeError("These arrays should be different.") | ||
var.load('temp2.h5') | ||
if not np.allclose(var.data, cpy): | ||
if uw.mpi.rank==0: | ||
print("VAR") | ||
print(var.data[:]) | ||
print("CPY") | ||
print(cpy) | ||
raise RuntimeError("These arrays should be identical.") | ||
|
||
if( not checkpoint_pass ): | ||
raise RuntimeError("Error in a checkpoint test") | ||
if __name__ == '__main__': | ||
import underworld as uw | ||
uw.utils._io.PATTERN=1 # sequential | ||
meshtest(16,True) | ||
meshtest(8, True) # second run to make sure we're deleting datasets where different sizes | ||
meshtest(16,False) | ||
uw.utils._io.PATTERN=2 # collective | ||
meshtest(16,True) | ||
meshtest(8, True) | ||
# meshtest(16,False) # this isn't a good idea, so we shouldn't do it. | ||
if uw.mpi.rank==0: | ||
import os | ||
os.remove('temp.h5') | ||
os.remove('temp2.h5') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.