CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Paraview & paraFoam (
-   -   Error when trying to display mesh (

Soheyl July 26, 2012 15:44

Error when trying to display mesh
I'm trying to visualize a (rather large) mesh in ParaFoam (3.12.0), but I keep on getting this error message a few seconds after I hit the 'Apply' button:


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-2.1.x/ParaView-3.12.0/VTK/Common/vtkDataArrayTemplate.txx, line 361
vtkIdTypeArray (0x20c7bed0): Unable to allocate 74102619 elements of size 4 bytes.

Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
I thought it might be due to insufficient memory, so I used 'top' to monitor the system resources, and it seems that when I get this message, I still have a lot of free memory. Any idea why this happens? BTW, I'm running it under a 32 bit Ubuntu 12.04.

wyldckat July 26, 2012 16:11

Greetings Soheyl,

Mmm... here's a few questions for trying to diagnose this issue:
  1. How many cells and points does you mesh have? Run checkMesh and see the first statistics, where it tells you how many cells and points the mesh has.
  2. And how many fields does you case have?
  3. Are you using polyhedral decomposition?
  4. Which file extension are you using? ".OpenFOAM" or ".foam"?
Best regards,

Soheyl July 26, 2012 16:23


According to checkMesh:


Mesh stats
points: 5744072
faces: 15409078
internal faces: 14514914
cells: 4852540
boundary patches: 7
point zones: 0
face zones: 0
cell zones: 0

Overall number of cells of each type:
hexahedra: 4348904
prisms: 71061
wedges: 441
pyramids: 0
tet wedges: 556
tetrahedra: 95
polyhedra: 431483
Also, all the checks are OK.

The case will have about 10 fields, but I haven't solved the case yet, and just trying to visualize the mesh. And none of them are selected in ParaFoam.

I am using scotch decomposition, and the file has an auto-generated extension of .OPENFOAM.

wyldckat July 26, 2012 16:47

What I meant by "polyhedral decomposition" was if you had chosen the option to do polyhedral decomposition in ParaView. It's one of the options in the "Object Inspector", which when turned on, shows the mesh as it really is.

Mmm... over 4 million cells... Last time I checked, for each million cells in OpenFOAM, it would require 1 GB of RAM. And if you're using a 32bit Ubuntu installation, then each application should not be able to allocate more than 2GB of RAM, even if you're using PAE!

Therefore, it should only be natural that you aren't able to load the mesh using a single instance of ParaView!

By the way, did you generate the mesh on that machine?

Soheyl July 26, 2012 17:57

That makes sense! I created the mesh on the same machine, but I ran snappyHexMesh on parallel on 4 cores. Well, I guess the only option might be reinstalling a 64 bit Ubuntu! :mad:

Thanks Bruno.

CRI_CFD September 3, 2014 10:28

Hey guys,

Have you solved your problem with memory?

I am making my script with Python-ParaView and I obtain the same error message. It looks like ParaView doesn't liberate memory (I am deleting all objects just when I don't need them).

Does anybody knows what can I do? I am working with high cell count and moreover I am using the Calculator tool. when I don't need it I do "Delete(object)".

gc.collect() is not the solution for me...

Thanks in advance.

wyldckat September 13, 2014 16:58

Greetings CRI_CFD,

I believe you're stepping into a more confusing part of VTK itself, and not as much Python coding.
I say this because VTK uses its own memory management system, due to its pipeline structure.

If you want to really save memory, you'll have to dump the results in between pipeline steps, using specific VTK methods... let's see if I can find them... ah, it's explained in detail here:

Best regards,

CRI_CFD September 14, 2014 07:51

Hey wyldkat,

Thanks for your reply.

I am reviewing my Python code and I am not using VTK anywhere (no import of VTK an the beginning of the script).

I am importing my results with OpenFOAMReader.

Is Paraview using VTK classes and methods and I am not realizing?

If so, is this link still useful?

I'll check it anyway.

Thanks for your help!



wyldckat September 14, 2014 08:14



Originally Posted by CRI_CFD (Post 510276)
I am importing my results with OpenFOAMReader.

Is Paraview using VTK classes and methods and I am not realizing?

The core reader "OpenFOAMReader" is VTK based code, therefore it will use it. Which options are you using with it?

From your description, my guess is that the problem starts right when you import the case with "OpenFOAMReader"? Or do you use any other filters after that?

Best regards,

CRI_CFD September 14, 2014 08:29

I do it this way:


try: paraview.simple
except: from paraview.simple import *


caso_foam = OpenFOAMReader( FileName='pathtofile/caso.foam' )

Then I start to import mesh regions, arrays....

All uses to run fine, except in two mainly cases:

1. Use of "Calculator filter". I try to delete it the faster I can (I guess it is taking a lot of memory resources, because this is a computation in the whole mesh), but as I said previously:



does not seem to solve the problem.

2. When I want to import a new foam case, I do:



try: paraview.simple
except: from paraview.simple import *


caso2_foam = OpenFOAMReader( FileName='pathtofile/caso2.foam' )

The error message I get is:


erminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

or simply


Do you think I can make use of your advices related to VTK with Python?

The script makes use of different filters (for example Velocity magnitude over a range of slices, streamlines, thresholds, calculators, integrate variables...) so I need a way of free memory. Mesh size is also quite big (around 6000000 cells).

Thanks again.

wyldckat October 12, 2014 13:06


I've finally managed to come around to check this.
From the quick tests I've done with ParaView 3.12.0 and 4.1.0, using OpenFOAM's "cavity" tutorial case, on Ubuntu 12.04, both ParaView versions are custom built along with OpenFOAM 2.2.x and 2.3.x... and I have a very bad feeling that there is a memory leak problem in ParaView/VTK.
If you try the steps you're doing manually in ParaView, using the interface and not Python, and monitor the memory occupied after loading and removing each filter and data read, you'll see that the memory occupied very rarely will decrease.

This reminds me of a known bug related to generating animations with ParaView... it's this thread:

Therefore, there seems to be a deeper problem in ParaView, and it's not simply related to using Python. :(

Best regards,

All times are GMT -4. The time now is 10:20.