ViewFactors.c: IntegrateFromGeometry (seg. fault)

Clearly defined bug reports and their fixes
Post Reply
Takala
Posts: 186
Joined: 23 Aug 2009, 23:59

ViewFactors.c: IntegrateFromGeometry (seg. fault)

Post by Takala »

Hello,

I am tracing a bug in ViewFactors.c:
I have the following debug code in the "static void IntegrateFromGeometry"

Code: Select all

         fprintf( stdout, "Debug: ViewFactorCompute: ");
         fflush( stdout );

            (*ViewFactorCompute[Elements[i].GeometryType])( &Elements[i],&Elements[j],0,0 );
  
         fprintf( stdout, "Debug: ComputeViewFactorValue\n: ");
         fflush( stdout );
            Fact = ComputeViewFactorValue( &Elements[i],0 );
         fprintf( stdout, "Debug: ComputeViewFactorValue done\n: ");
         fflush( stdout );
         fprintf( stdout, "Debug: Factor 1 assignment:\n: ");
         fflush( stdout );
            Factors[i*N+j] = Fact / Elements[i].Area;
         fprintf( stdout, "Debug: Factor 1 assignment done\n: ");
         fflush( stdout );
         fprintf( stdout, "Debug: Factor 2 assignment:\n: ");
         fflush( stdout );

         fprintf( stdout, "Debug: N = %d, j*N+i = %d \n:", N, j*N+i);
         fflush( stdout );

         fprintf( stdout, "Debug: j = %d, Fact = %f, Elements[j].area = %f \n:", j, Fact, Elements[j].Area);
         fflush( stdout );

         fprintf( stdout, "Debug: Fact / Elements[j].area = %f \n:", Fact / Elements[j].Area);
         fflush( stdout );
	
            Factors[j*N+i] = Fact / Elements[j].Area;
         fprintf( stdout, "Debug: Factor 2 assignment done\n: ");
         fflush( stdout );
This is what I get for the last functioning step:

Code: Select all

: j =  9717: Debug: ViewFactorCompute: Debug: ComputeViewFactorValue
: Debug: ComputeViewFactorValue done
: Debug: Factor 1 assignment:
: Debug: Factor 1 assignment done
: Debug: Factor 2 assignment:
: Debug: N = 97473, j*N+i = 947145141 
:Debug: j = 9717, Fact = 0.000000, Elements[j].area = 0.000737 
:Debug: Fact / Elements[j].area = 0.000000 
:Segmentation fault (core dumped)
So it seems the Assignment of Factors[j*N+i] fails when j is 9717. I can't come up with a reason for this... There should be enough space N**2 = 9.50099e+09

Please advice!

Cheers,

Eelis
Takala
Posts: 186
Joined: 23 Aug 2009, 23:59

Re: ViewFactors.c: IntegrateFromGeometry (seg. fault)

Post by Takala »

I think I found the problem:
I have too many radiating surface elements. There are in total 97473 elements.

check this out:
This is what I write in the ViewFactors.f90

Code: Select all

!         CALL ViewFactors3D( &
!             N, Surfaces, TYPE, Coords, Normals, &
!             0, Surfaces, TYPE, Coords, Normals, &
!             Factors, AreaEPS, FactEPS, RayEPS, Nrays, 4, 3, CombineInt )


print *, "DEBUG: N =", N
print *, "DEBUG: N*N =", N*N
And this is what I get:
ViewFactors: ... Done
ViewFactors:
ViewFactors: Computing view factors for radiation body 1
ViewFactors: Number of surfaces participating in radiation 97473
ViewFactors: Computing viewfactors...
DEBUG: N = 97473
DEBUG: N*N = 911051137
ViewFactors: View factors computed in time (s): 0.00
Segmentation fault (core dumped)
So I guess the integer is not big enough to support the correct value of the term N*N. It should be
9500985729 and now ViewFactors thinks that it is 911051137.

So what to do? Is my model too ambitious with respect to the number of radiating elements that even if it was made to work, it would calculate eternally. And since I don't have that much time, I should come up with something else?

How about the particle dynamics module? In theory, it should be possible to use something like that. Wouldn't it? I just would need to create a batch of particles with corresponding energies from the radiating surface elements. Then I'd simulate for some time and make the boundaries absorb the particles that collide with the surface elements. Then I'd reduce the corresponding heat energy of the particle batch from the emitting elements and add the absorbed energy to the absorbing surface elements.

How should I proceed?

Cheers,

Eelis
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: ViewFactors.c: IntegrateFromGeometry (seg. fault)

Post by raback »

Hi Eelis

This may be a tough one.

Looking at the code the N^2 character seems to be built quite deeply in the code. I think that basicially the 3D code uses some kind of ray tracing. Of course in cases where F is sparse the memory may be exhausted even though the case would otherwise be computable. If this would be the only problem then letting view factor matrix be sparse would be a possible solution. However, I doubt that.

The particle implementation in Elmer might not be optimal since you need to have mesh to follow the particles and the optimal stepsize should not be too large. The ray tracing implementation is probably better anyway. Ideally, it is also problematic to create the viewfactors as it introduces currently serial character to the computation. In large parallel simulations it would probably make sense to do the computation on-the-fly using MC (particles). It is just that the follow-up of particles should be heavily rewritten to speed things up and avoid the meshing of free space.

Sorry, I can't think of anything quick...

-Peter
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: ViewFactors.c: IntegrateFromGeometry (seg. fault)

Post by raback »

Hi Eelis

This may be a tough one.

Looking at the code the N^2 character seems to be built quite deeply in the code. I think that basicially the 3D code uses some kind of ray tracing. Of course in cases where F is sparse the memory may be exhausted even though the case would otherwise be computable. If this would be the only problem then letting view factor matrix be sparse would be a possible solution. However, I doubt that.

The particle implementation in Elmer might not be optimal since you need to have mesh to follow the particles and the optimal stepsize should not be too large. The ray tracing implementation is probably better anyway. Ideally, it is also problematic to create the viewfactors as it introduces currently serial character to the computation. In large parallel simulations it would probably make sense to do the computation on-the-fly using MC (particles). It is just that the follow-up of particles should be heavily rewritten to speed things up and avoid the meshing of free space.

Sorry, I can't think of anything quick...

-Peter
Takala
Posts: 186
Joined: 23 Aug 2009, 23:59

Re: ViewFactors.c: IntegrateFromGeometry (seg. fault)

Post by Takala »

Hi Peter,

thanks for the answer.

You say that one of the problem is meshing of the free space. At the moment this would not be a problem for me since I do not have mesh free domains in my model. But I guess that doesn't help since the time stepping would be an issue. One would have to calculate several steps with the particle dynamics in one time step. It is a long time since I used the module, but somehow I remember that there should be a keyword for this. However, I guess you meant that it would be too slow as well?

So I have to think "outside the box" now...

Cheers,

Eelis
Post Reply