Skip to content
Permalink
Browse files

Lagrangian: Removed more instances of random-number-based perpendicul…

…ar vector calculations

Perpendicular vectors should be generated using the global
"perpendicular" function, which guarantees a non-zero result without a
random number generator and without looping.
  • Loading branch information...
Will Bainbridge
Will Bainbridge committed May 28, 2019
1 parent aaed269 commit 68e9c8eac2bfc45a0b2f88347e24bd349d7ed8b9
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -173,20 +173,7 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles()
{
// Set 4 quadrants for single sector cases
nS = 4;

vector tangent = Zero;
scalar magTangent = 0.0;

Random rnd(1234);
while (magTangent < small)
{
vector v = rnd.sample01<vector>();

tangent = v - (v & normal_[0])*normal_[0];
magTangent = mag(tangent);
}

refDir = tangent/magTangent;
refDir = normalised(perpendicular(normal_[0]));
}

scalar dTheta = 5.0;
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -83,26 +83,6 @@ Foam::word Foam::ThermoSurfaceFilm<CloudType>::interactionTypeStr

// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //

template<class CloudType>
Foam::vector Foam::ThermoSurfaceFilm<CloudType>::tangentVector
(
const vector& v
) const
{
vector tangent = Zero;
scalar magTangent = 0.0;

while (magTangent < small)
{
vector vTest = rndGen_.sample01<vector>();
tangent = vTest - (vTest & v)*v;
magTangent = mag(tangent);
}

return tangent/magTangent;
}


template<class CloudType>
Foam::vector Foam::ThermoSurfaceFilm<CloudType>::splashDirection
(
@@ -358,7 +338,7 @@ void Foam::ThermoSurfaceFilm<CloudType>::splashInteraction
const vector& nf = pp.faceNormals()[facei];

// Determine direction vectors tangential to patch normal
const vector tanVec1 = tangentVector(nf);
const vector tanVec1 = normalised(perpendicular(nf));
const vector tanVec2 = nf^tanVec1;

// Retrieve parcel properties
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -151,9 +151,6 @@ protected:

// Protected Member Functions

//- Return a vector tangential to input vector, v
vector tangentVector(const vector& v) const;

//- Return splashed parcel direction
vector splashDirection
(

0 comments on commit 68e9c8e

Please sign in to comment.
You can’t perform that action at this time.