adhishm / dd2d_Matryoshka

A set of classes defining the behaviour of crystalline defects, with the final goal of carrying out dislocation dynamics simulations in two dimensions.
Other
5 stars 4 forks source link

Logical order of vector creation in SlipPlane #24

Closed adhishm closed 11 years ago

adhishm commented 11 years ago

In the constructors of the class SlipPlane, there are several redundant operations which write to the std::vector<Defect*> defects repeatedly. There should be a logical order of calling the various functions like SlipPlane::setExtremities, SlipPlane::createDefects, etc., amd also a clean up of the operations each of those functions carries out, in order to remove redundancy and conflicts.

This bug may also be responsible for the other bug about wrong/changing defectType for the slip plane extremities.

adhishm commented 11 years ago

Updating the constructor for SlipPlane and the function void SlipPlane::setExtremities (Vector3d *ends)

// Default axes for the extremities // The extremities take the same axes as the slip plane Vector3d *axes = new Vector3d[3]; axes[0] = Vector3d(1.0, 0.0, 0.0); axes[1] = Vector3d(0.0, 1.0, 0.0); axes[2] = Vector3d(0.0, 0.0, 1.0);

this->extremities[0] = Defect(GRAINBOUNDARY, ends[0], axes, this->coordinateSystem.getBase());
this->extremities[0] = Defect(GRAINBOUNDARY, ends[1], axes, this->coordinateSystem.getBase());
this->defects.insert(this->defects.begin(),1,this->extremities);
this->defects.insert(this->defects.end(),1,this->extremities+1);

By doing this, the two extremities are explicitly set to have the defectType=GRAINBOUNDARY, and their co-ordinate systems are defined too.

adhishm commented 11 years ago

The operations of reading in data are carried out in the following order:

Henceforth, care must be taken to call sortDislocations and sortDislocationSources functions every time a new dislocation or a new dislocation source is inserted or removed. The updateDefects function must then be called to update the defects list.

adhishm commented 11 years ago

The function SlipPlane::updateDefects() has been fixed. It now clears the entire defects vector and rebuilds it using the data available. In the end the list is sorted.