Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Mark Olesen
2018-07-13 13:25:11 +02:00
9 changed files with 163 additions and 44 deletions

View File

@ -107,7 +107,7 @@ Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const
forAll(alphaNames_, i) forAll(alphaNames_, i)
{ {
dimensionedScalar aPhase("a", dimless/dimLength, aCoeff_[i]); dimensionedScalar aPhase("a", dimless/dimLength, aCoeff_[i]);
a += max(alpha(alphaNames_[i]), 0.0)*aPhase; a += max(alpha(alphaNames_[i]), scalar(0))*aPhase;
} }
return ta; return ta;
@ -140,7 +140,7 @@ Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const
forAll(alphaNames_, i) forAll(alphaNames_, i)
{ {
dimensionedScalar ePhase("e", dimless/dimLength, eCoeff_[i]); dimensionedScalar ePhase("e", dimless/dimLength, eCoeff_[i]);
e += max(alpha(alphaNames_[i]), 0.0)*ePhase; e += max(alpha(alphaNames_[i]), scalar(0))*ePhase;
} }
return te; return te;
@ -179,7 +179,7 @@ Foam::radiation::localDensityAbsorptionEmission::ECont(const label bandI) const
ECoeff_[i] ECoeff_[i]
); );
E += max(alpha(alphaNames_[i]), 0.0)*EPhase; E += max(alpha(alphaNames_[i]), scalar(0))*EPhase;
} }
return tE; return tE;

View File

@ -139,7 +139,7 @@ bool Foam::functionObjects::vtkCloud::writeCloud
label nTotParcels = pointsPtr->size(); label nTotParcels = pointsPtr->size();
reduce(nTotParcels, sumOp<label>()); reduce(nTotParcels, sumOp<label>());
if (!nTotParcels) if (pruneEmpty_ && !nTotParcels)
{ {
return false; return false;
} }
@ -331,6 +331,7 @@ Foam::functionObjects::vtkCloud::vtkCloud
writeOpts_(vtk::formatType::INLINE_BASE64), writeOpts_(vtk::formatType::INLINE_BASE64),
printf_(), printf_(),
useVerts_(false), useVerts_(false),
pruneEmpty_(false),
selectClouds_(), selectClouds_(),
selectFields_(), selectFields_(),
dirName_("VTK"), dirName_("VTK"),
@ -396,6 +397,7 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
// useTimeName_ = dict.lookupOrDefault<bool>("useTimeName", false); // useTimeName_ = dict.lookupOrDefault<bool>("useTimeName", false);
useVerts_ = dict.lookupOrDefault<bool>("cellData", false); useVerts_ = dict.lookupOrDefault<bool>("cellData", false);
pruneEmpty_ = dict.lookupOrDefault<bool>("prune", false);
// //

View File

@ -59,6 +59,7 @@ Usage
directory | The output directory name | no | VTK directory | The output directory name | no | VTK
width | Padding width for file name | no | 8 width | Padding width for file name | no | 8
format | ascii or binary format | no | binary format | ascii or binary format | no | binary
prune | suppress writing of empty clouds | no | false
writePrecision | write precision in ascii | no | same as IOstream writePrecision | write precision in ascii | no | same as IOstream
\endtable \endtable
@ -125,6 +126,9 @@ class vtkCloud
//- Write lagrangian as cell data (verts) instead of point data //- Write lagrangian as cell data (verts) instead of point data
bool useVerts_; bool useVerts_;
//- Suppress writing of empty clouds
bool pruneEmpty_;
//- Requested names of clouds to process //- Requested names of clouds to process
wordRes selectClouds_; wordRes selectClouds_;

View File

@ -424,14 +424,18 @@ void Foam::particle::locate
<< exit(FatalError); << exit(FatalError);
} }
// Put the particle at the cell centre and in a random tet // Put the particle at (almost) the cell centre and in a random tet.
coordinates_ = barycentric(1, 0, 0, 0); // Note perturbing the cell centre to make sure we find at least one
// tet containing it. With start point exactly at the cell centre very
// occasionally it would not get found in any of the tets
coordinates_ = barycentric(1-3*SMALL, SMALL, SMALL, SMALL);
tetFacei_ = mesh_.cells()[celli_][0]; tetFacei_ = mesh_.cells()[celli_][0];
tetPti_ = 1; tetPti_ = 1;
facei_ = -1; facei_ = -1;
// Track to the injection point // Track to the injection point
track(position - mesh_.cellCentres()[celli_], 0); track(position - this->position(), 0);
if (!onFace()) if (!onFace())
{ {
return; return;

View File

@ -235,7 +235,14 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
// Cut source triangle with all inward pointing faces of target triangle // Cut source triangle with all inward pointing faces of target triangle
// - triangles in workTris1 are inside target triangle // - triangles in workTris1 are inside target triangle
const scalar t = sqrt(triArea(src)); const scalar srcArea(triArea(src));
if (srcArea < ROOTVSMALL)
{
return 0.0;
}
// Typical length scale
const scalar t = sqrt(srcArea);
// Edge 0 // Edge 0
{ {
@ -243,10 +250,29 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
// workTris1 list // workTris1 list
scalar s = mag(tgt1 - tgt0); scalar s = mag(tgt1 - tgt0);
//plane pl0(tgt0, tgt1, tgt1 + s*n); if (s < ROOTVSMALL)
plane pl0(tgt0, (tgt0 - tgt1)^(-s*n), true); {
return 0.0;
}
// Note: outer product with n pre-scaled with edge length. This is
// purely to avoid numerical errors because of drastically
// different vector lengths.
const vector n0((tgt0 - tgt1)^(-s*n));
const scalar magSqrN0(magSqr(n0));
if (magSqrN0 < ROOTVSMALL)
{
// Triangle either zero edge length (s == 0) or
// perpendicular to face normal n. In either case zero
// overlap area
return 0.0;
}
else
{
plane pl0(tgt0, n0/Foam::sqrt(magSqrN0), false);
triSliceWithPlane(src, pl0, workTris1, nWorkTris1, t); triSliceWithPlane(src, pl0, workTris1, nWorkTris1, t);
} }
}
if (nWorkTris1 == 0) if (nWorkTris1 == 0)
{ {
@ -259,8 +285,23 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
// workTris2 list (re-use tris storage) // workTris2 list (re-use tris storage)
scalar s = mag(tgt2 - tgt1); scalar s = mag(tgt2 - tgt1);
//plane pl1(tgt1, tgt2, tgt2 + s*n); if (s < ROOTVSMALL)
plane pl1(tgt1, (tgt1 - tgt2)^(-s*n), true); {
return 0.0;
}
const vector n1((tgt1 - tgt2)^(-s*n));
const scalar magSqrN1(magSqr(n1));
if (magSqrN1 < ROOTVSMALL)
{
// Triangle either zero edge length (s == 0) or
// perpendicular to face normal n. In either case zero
// overlap area
return 0.0;
}
else
{
plane pl1(tgt1, n1/Foam::sqrt(magSqrN1), false);
nWorkTris2 = 0; nWorkTris2 = 0;
@ -274,6 +315,7 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
return 0.0; return 0.0;
} }
} }
}
// Edge 2 // Edge 2
{ {
@ -281,8 +323,23 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
// workTris1 list (re-use workTris1 storage) // workTris1 list (re-use workTris1 storage)
scalar s = mag(tgt2 - tgt0); scalar s = mag(tgt2 - tgt0);
//plane pl2(tgt2, tgt0, tgt0 + s*n); if (s < ROOTVSMALL)
plane pl2(tgt2, (tgt2 - tgt0)^(-s*n), true); {
return 0.0;
}
const vector n2((tgt2 - tgt0)^(-s*n));
const scalar magSqrN2(magSqr(n2));
if (magSqrN2 < ROOTVSMALL)
{
// Triangle either zero edge length (s == 0) or
// perpendicular to face normal n. In either case zero
// overlap area
return 0.0;
}
else
{
plane pl2(tgt2, n2/Foam::sqrt(magSqrN2), false);
nWorkTris1 = 0; nWorkTris1 = 0;
@ -313,6 +370,7 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
} }
} }
} }
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,19 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
restore0Dir
runApplication blockMesh
runApplication topoSet
runApplication createBaffles -overwrite
runApplication decomposePar
runParallel $(getApplication)
runApplication reconstructPar
#------------------------------------------------------------------------------

View File

@ -51,5 +51,9 @@ maxCo 1.0;
maxDeltaT 1; maxDeltaT 1;
functions
{
#include "vtkCloud"
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,9 +27,6 @@ preserveFaceZones
coeffs coeffs
{ {
n (2 2 1); n (2 2 1);
//delta 0.001; // default=0.001
//order xyz; // default=xzy
dataFile "";
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,31 @@
// -*- C++ -*-
cloudWrite
{
type vtkCloud;
libs ("liblagrangianFunctionObjects.so");
log true;
writeControl writeTime;
// cloud reactingCloud1;
clouds ( ".*" );
// Fields to output (words or regex)
fields ( U T d "Y.*" );
//- Output format (ascii | binary) - default = binary
// format binary;
// format ascii;
// writePrecision 12;
//- Suppress writing of empty clouds - default = false
// prune true;
//- Output directory name - default = "VTK"
// directory "VTK";
}
// ************************************************************************* //