boyfarrell
Registered
Hi all,
Now this looks a bit messy! But actually it's quite simple. It basically multiplies vectors together. However, I have a vector at a point in 3D space. That's what a PointVector class is. The code is part of a finite element method of solving a problem in material science.
When I run this code I get a a good old 10 (SIGBUS). It has something to with the release of myPtVecTermOnePreFactor (which is an array of Vector* type objects) in the last for loop of the method. When I don't release it the code runs fine?
Any ideas? (Come on Viro it's your time to show off again! )
Now this looks a bit messy! But actually it's quite simple. It basically multiplies vectors together. However, I have a vector at a point in 3D space. That's what a PointVector class is. The code is part of a finite element method of solving a problem in material science.
When I run this code I get a a good old 10 (SIGBUS). It has something to with the release of myPtVecTermOnePreFactor (which is an array of Vector* type objects) in the last for loop of the method. When I don't release it the code runs fine?
Any ideas? (Come on Viro it's your time to show off again! )
Code:
-(PointVector*) calculateTermOneIntegrandMeshPointsWithPtVec: (PointVector*) myPtVecTermOneIntPartCosh
And: (PointVector*) myPtVecSolution
AndChempot: (ChemicalPotential*) myChempot;
{
//Make term one prefactor vectors
Vector *myPtVecTermOnePreFactor[ptsD];
unsigned int q;
for (q=0; q <= (ptsD-1); q++)
{
//fill with term one prefactor
myPtVecTermOnePreFactor[q] = [[Vector alloc] init];
myPtVecTermOnePreFactor[q] = [self termOneFactorAtDepth:q];
//Calculate the Cosh term for different points
[self termOneIntegrandPartCoshForFluxDirectionZAtDepth: q];
//We now want add like frequency elements at different positions to reduce the ptsD number of
//Vector* to one Vector then place this at the correct point of interest in the 'termOneIntegrandPartCosh' instance.
[self termOneIntegrandPartCoshActionSummateLikeFrequencyElementsForFluxDirectionZ: myPtVecTermOneIntPartCosh];
}
//create an instance to hold the brightness values
PointVector *myPtVecBrightnessDistribution = [[PointVector alloc] initAll];
//fill with values
[self termBrightnessWithChemicalPotentialDistribution: myChempot UsingPointVector: myPtVecBrightnessDistribution];
//PointVector muliplication
[myPtVecSolution equalsPointVector: myPtVecTermOneIntPartCosh TimesPointVector: myPtVecBrightnessDistribution];
//times by the prefactor
unsigned int j,i;
for (q=0; q <= (ptsD-1); q++)
for (j=0; j <= (ptsW-1); j++)
for (i=0; i <= (ptsL-1); i++)
{
[myPtVecSolution timesVector: myPtVecTermOnePreFactor[q] ToPointI:i J:j Q:q];
[myPtVecTermOnePreFactor[q] release];
}
[myPtVecBrightnessDistribution release];
return myPtVecSolution;
}