Skip to content

Commit

Permalink
Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
maceli committed Feb 22, 2016
1 parent a2a2234 commit 899f775
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 47 deletions.
18 changes: 6 additions & 12 deletions applications/DEM_application/custom_conditions/RigidEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,28 +254,22 @@ void RigidEdge3D::Calculate(const Variable<Vector >& rVariable, Vector& Output,

double origin[3] = {Xorigin, Yorigin, Zorigin};

double coord[3], vector1[3], vector2[3];
double vector1[3], vector2[3];
double dist, dist1;

double a[3][3];
double local_vel[3],global_vel[3];

for(unsigned int j = 0; j < number_of_nodes; j++)
{
array_1d<double, 3> Nodecoord;
Nodecoord = this->GetGeometry()[j].Coordinates();

coord[0] = Nodecoord[0];
coord[1] = Nodecoord[1];
coord[2] = Nodecoord[2];

vector1[0] = coord[0] - origin[0];
vector1[1] = coord[1] - origin[1];
vector1[2] = coord[2] - origin[2];
const array_1d<double, 3>& Nodecoord = this->GetGeometry()[j].Coordinates();

vector1[0] = Nodecoord[0] - origin[0];
vector1[1] = Nodecoord[1] - origin[1];
vector1[2] = Nodecoord[2] - origin[2];

dist = fabs(GeometryFunctions::DotProduct(vector1,n));
dist1 = GeometryFunctions::DistanceOfTwoPoint(coord,origin);
dist1 = GeometryFunctions::DistanceOfTwoPoint(Nodecoord,origin);

dist = sqrt( dist1 * dist1 - dist * dist);

Expand Down
18 changes: 6 additions & 12 deletions applications/DEM_application/custom_conditions/RigidFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,28 +243,22 @@ void RigidFace3D::Calculate(const Variable<Vector >& rVariable, Vector& Output,

double origin[3] = {Xorigin, Yorigin, Zorigin};

double coord[3], vector1[3], vector2[3];
double vector1[3], vector2[3];
double dist, dist1;

double a[3][3];
double local_vel[3],global_vel[3];

for(unsigned int j = 0; j < number_of_nodes; j++)
{
array_1d<double, 3> Nodecoord;
Nodecoord = this->GetGeometry()[j].Coordinates();

coord[0] = Nodecoord[0];
coord[1] = Nodecoord[1];
coord[2] = Nodecoord[2];

vector1[0] = coord[0] - origin[0];
vector1[1] = coord[1] - origin[1];
vector1[2] = coord[2] - origin[2];
const array_1d<double, 3>& Nodecoord = this->GetGeometry()[j].Coordinates();

vector1[0] = Nodecoord[0] - origin[0];
vector1[1] = Nodecoord[1] - origin[1];
vector1[2] = Nodecoord[2] - origin[2];

dist = fabs(GeometryFunctions::DotProduct(vector1,n));
dist1 = GeometryFunctions::DistanceOfTwoPoint(coord,origin);
dist1 = GeometryFunctions::DistanceOfTwoPoint(Nodecoord,origin);

dist = sqrt( dist1 * dist1 - dist * dist);

Expand Down
8 changes: 2 additions & 6 deletions applications/DEM_application/custom_elements/cluster3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,8 @@ namespace Kratos {

void Cluster3D::CustomInitialize() {}

void Cluster3D::SetOrientation(const array_1d<double, 3>& euler_angles) {

this->GetGeometry()[0].FastGetSolutionStepValue(EULER_ANGLES)[0] = euler_angles[0];
this->GetGeometry()[0].FastGetSolutionStepValue(EULER_ANGLES)[1] = euler_angles[1];
this->GetGeometry()[0].FastGetSolutionStepValue(EULER_ANGLES)[2] = euler_angles[2];

void Cluster3D::SetOrientation(const array_1d<double, 3>& euler_angles) {
noalias( this->GetGeometry()[0].FastGetSolutionStepValue(EULER_ANGLES) ) = euler_angles;
}

void Cluster3D::CreateParticles(ParticleCreatorDestructor* p_creator_destructor, ModelPart& dem_model_part){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void NanoParticle::ComputeAdditionalForces(array_1d<double, 3>& additionally_app
array_1d<double, 3> van_der_waals_force; van_der_waals_force.clear();
array_1d<double, 3> double_layer_force; double_layer_force.clear();

additionally_applied_force += brownian_motion_force + van_der_waals_force + double_layer_force;
noalias(additionally_applied_force) += brownian_motion_force + van_der_waals_force + double_layer_force;


//Now add the contribution of base class function (gravity or other forces added in upper levels):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ namespace Kratos {
for (unsigned int i = 0; i < mNeighbourElements.size(); i++) {
SphericContinuumParticle* neighbour_iterator = dynamic_cast<SphericContinuumParticle*> (mNeighbourElements[i]);

array_1d<double, 3 > other_to_me_vect = this->GetGeometry()[0].Coordinates() - neighbour_iterator->GetGeometry()[0].Coordinates();
array_1d<double, 3 > other_to_me_vect;
noalias(other_to_me_vect) = this->GetGeometry()[0].Coordinates() - neighbour_iterator->GetGeometry()[0].Coordinates();

double distance = sqrt(other_to_me_vect[0] * other_to_me_vect[0] +
other_to_me_vect[1] * other_to_me_vect[1] +
Expand Down Expand Up @@ -230,14 +231,9 @@ namespace Kratos {

unsigned int neighbour_iterator_id = neighbour_iterator->Id();

array_1d<double, 3> other_to_me_vect = this->GetGeometry()[0].Coordinates() - neighbour_iterator->GetGeometry()[0].Coordinates();
const array_1d<double, 3> other_to_me_vect = this->GetGeometry()[0].Coordinates() - neighbour_iterator->GetGeometry()[0].Coordinates();
const double &other_radius = neighbour_iterator->GetRadius();
array_1d<double, 3> other_ang_vel = neighbour_iterator->GetGeometry()[0].FastGetSolutionStepValue(ANGULAR_VELOCITY);
/*
double distance = sqrt(other_to_me_vect[0] * other_to_me_vect[0] +
other_to_me_vect[1] * other_to_me_vect[1] +
other_to_me_vect[2] * other_to_me_vect[2]);
*/

double distance = DEM_MODULUS_3(other_to_me_vect);
double radius_sum = GetRadius() + other_radius;
double initial_delta = mNeighbourDelta[i_neighbour_count];
Expand Down Expand Up @@ -760,8 +756,11 @@ namespace Kratos {
double DistPToB = RF_Pram[ino1 + 9];
int iNeighborID = static_cast<int> (RF_Pram[ino1 + 14]);
double ini_delta = 0.0;
array_1d<double, 3> neigh_forces = vector_of_zeros;
array_1d<double, 3> neigh_forces_elastic = vector_of_zeros;
array_1d<double, 3> neigh_forces;
noalias(neigh_forces)= vector_of_zeros;
array_1d<double, 3> neigh_forces_elastic;
noalias(neigh_forces_elastic) = vector_of_zeros;

double mapping_new_ini = -1;

for (unsigned int k = 0; k != mFemIniNeighbourIds.size(); k++) {
Expand All @@ -774,8 +773,8 @@ namespace Kratos {

for (unsigned int j = 0; j != mFemOldNeighbourIds.size(); j++) {
if (static_cast<int> ((mFemTempNeighbours[i])->Id()) == mFemOldNeighbourIds[j]) {
neigh_forces_elastic = mNeighbourRigidFacesElasticContactForce[j];
neigh_forces = mNeighbourRigidFacesTotalContactForce[j];
noalias(neigh_forces_elastic) = mNeighbourRigidFacesElasticContactForce[j];
noalias(neigh_forces) = mNeighbourRigidFacesTotalContactForce[j];
break;
}
}
Expand All @@ -789,8 +788,8 @@ namespace Kratos {
fem_temp_neighbours_ids[fem_neighbour_counter] = static_cast<int> ((mFemTempNeighbours[i])->Id());
fem_temp_neighbours_mapping[fem_neighbour_counter] = mapping_new_ini;
fem_temp_neighbours_delta[fem_neighbour_counter] = ini_delta;
fem_temp_neighbours_contact_forces[fem_neighbour_counter] = neigh_forces;
fem_temp_neighbours_elastic_contact_forces[fem_neighbour_counter] = neigh_forces_elastic;
noalias(fem_temp_neighbours_contact_forces[fem_neighbour_counter])= neigh_forces;
noalias(fem_temp_neighbours_elastic_contact_forces[fem_neighbour_counter]) = neigh_forces_elastic;

fem_neighbour_counter++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void SphericParticle::EvaluateDeltaDisplacement(double RelDeltDisp[3],
double RelVel[3],
double LocalCoordSystem[3][3],
double OldLocalCoordSystem[3][3],
array_1d<double, 3>& other_to_me_vect,
const array_1d<double, 3>& other_to_me_vect,
const array_1d<double, 3>& vel,
const array_1d<double, 3>& delta_displ,
SphericParticle* p_neighbour,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ virtual void EvaluateDeltaDisplacement(double DeltDisp[3],
double RelVel[3],
double LocalCoordSystem[3][3],
double OldLocalCoordSystem[3][3],
array_1d<double, 3> &other_to_me_vect,
const array_1d<double, 3> &other_to_me_vect,
const array_1d<double, 3> &vel,
const array_1d<double, 3> &delta_displ,
SphericParticle* neighbour_iterator,
Expand Down

0 comments on commit 899f775

Please sign in to comment.