mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use "origin" for searchable sphere etc. (#1060)
- replaces "centre", using the same keyword as other objects (eg, plane, rotatedBox, coordinateSystem etc).
This commit is contained in:
@ -129,7 +129,7 @@ FoamFile
|
||||
// source sphereToCell;
|
||||
// sourceInfo
|
||||
// {
|
||||
// centre (0.2 0.2 -10);
|
||||
// origin (0.2 0.2 -10);
|
||||
// radius 5.0;
|
||||
// }
|
||||
//
|
||||
@ -394,7 +394,7 @@ FoamFile
|
||||
// sourceInfo
|
||||
// {
|
||||
// surface searchableSphere;
|
||||
// centre (0.05 0.05 0.005);
|
||||
// origin (0.05 0.05 0.005);
|
||||
// radius 0.025;
|
||||
// //name sphere.stl; // Optional name if surface triSurfaceMesh
|
||||
// }
|
||||
|
||||
@ -97,7 +97,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
shapeSelector::shapeTypeNames.get("type", dict)
|
||||
);
|
||||
const vector centre(dict.get<vector>("centre"));
|
||||
const vector origin(dict.getCompat<vector>("origin", {{"centre", 1806}}));
|
||||
const word fieldName(dict.get<word>("field"));
|
||||
|
||||
Info<< "Reading field " << fieldName << "\n" << endl;
|
||||
@ -114,7 +114,7 @@ int main(int argc, char *argv[])
|
||||
mesh
|
||||
);
|
||||
|
||||
scalar f0 = 0.0;
|
||||
scalar f0 = 0;
|
||||
scalarField f(mesh.points().size());
|
||||
|
||||
Info<< "Processing type '" << shapeSelector::shapeTypeNames[surfType]
|
||||
@ -126,15 +126,15 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const vector direction(dict.get<vector>("direction"));
|
||||
|
||||
f = -(mesh.points() - centre) & (direction/mag(direction));
|
||||
f0 = 0.0;
|
||||
f = -(mesh.points() - origin) & (direction/mag(direction));
|
||||
f0 = 0;
|
||||
break;
|
||||
}
|
||||
case shapeSelector::shapeType::SPHERE:
|
||||
{
|
||||
const scalar radius(dict.get<scalar>("radius"));
|
||||
|
||||
f = -mag(mesh.points() - centre);
|
||||
f = -mag(mesh.points() - origin);
|
||||
f0 = -radius;
|
||||
break;
|
||||
}
|
||||
@ -145,8 +145,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
f = -sqrt
|
||||
(
|
||||
sqr(mag(mesh.points() - centre))
|
||||
- sqr(mag((mesh.points() - centre) & direction))
|
||||
sqr(mag(mesh.points() - origin))
|
||||
- sqr(mag((mesh.points() - origin) & direction))
|
||||
);
|
||||
f0 = -radius;
|
||||
break;
|
||||
@ -160,9 +160,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
const scalarField xx
|
||||
(
|
||||
(mesh.points() - centre) & direction/mag(direction)
|
||||
(mesh.points() - origin) & direction/mag(direction)
|
||||
);
|
||||
const scalarField zz((mesh.points() - centre) & up/mag(up));
|
||||
const scalarField zz((mesh.points() - origin) & up/mag(up));
|
||||
|
||||
f = amplitude*Foam::sin(2*mathematical::pi*xx/period) - zz;
|
||||
f0 = 0;
|
||||
|
||||
@ -75,7 +75,7 @@ cylindricalInletVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF, dict),
|
||||
origin_(dict.lookupCompat("origin", {{"centre", 1712}})),
|
||||
origin_(dict.getCompat<vector>("origin", {{"centre", 1712}})),
|
||||
axis_(dict.lookup("axis")),
|
||||
axialVelocity_(Function1<scalar>::New("axialVelocity", dict)),
|
||||
radialVelocity_(Function1<scalar>::New("radialVelocity", dict)),
|
||||
|
||||
@ -57,18 +57,18 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest
|
||||
{
|
||||
pointIndexHit info(false, sample, -1);
|
||||
|
||||
const vector n(sample - centre_);
|
||||
const vector n(sample - origin_);
|
||||
scalar magN = mag(n);
|
||||
|
||||
if (nearestDistSqr >= sqr(magN - radius_))
|
||||
{
|
||||
if (magN < ROOTVSMALL)
|
||||
{
|
||||
info.rawPoint() = centre_ + vector(1,0,0)*radius_;
|
||||
info.rawPoint() = origin_ + vector(1,0,0)*radius_;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.rawPoint() = centre_ + n/magN*radius_;
|
||||
info.rawPoint() = origin_ + n/magN*radius_;
|
||||
}
|
||||
info.setHit();
|
||||
info.setIndex(0);
|
||||
@ -95,7 +95,7 @@ void Foam::searchableSphere::findLineAll
|
||||
|
||||
if (magSqrDir > ROOTVSMALL)
|
||||
{
|
||||
const vector toCentre(centre_-start);
|
||||
const vector toCentre(origin_ - start);
|
||||
scalar magSqrToCentre = magSqr(toCentre);
|
||||
|
||||
dir /= Foam::sqrt(magSqrDir);
|
||||
@ -135,18 +135,18 @@ void Foam::searchableSphere::findLineAll
|
||||
Foam::searchableSphere::searchableSphere
|
||||
(
|
||||
const IOobject& io,
|
||||
const point& centre,
|
||||
const point& origin,
|
||||
const scalar radius
|
||||
)
|
||||
:
|
||||
searchableSurface(io),
|
||||
centre_(centre),
|
||||
origin_(origin),
|
||||
radius_(radius)
|
||||
{
|
||||
bounds() = boundBox
|
||||
(
|
||||
centre_ - radius_*vector::one,
|
||||
centre_ + radius_*vector::one
|
||||
origin_ - radius_*vector::one,
|
||||
origin_ + radius_*vector::one
|
||||
);
|
||||
}
|
||||
|
||||
@ -157,23 +157,20 @@ Foam::searchableSphere::searchableSphere
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
searchableSurface(io),
|
||||
centre_(dict.get<point>("centre")),
|
||||
radius_(dict.get<scalar>("radius"))
|
||||
{
|
||||
bounds() = boundBox
|
||||
searchableSphere
|
||||
(
|
||||
centre_ - radius_*vector::one,
|
||||
centre_ + radius_*vector::one
|
||||
);
|
||||
}
|
||||
io,
|
||||
dict.getCompat<vector>("origin", {{"centre", 1806}}),
|
||||
dict.get<scalar>("radius")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::searchableSphere::overlaps(const boundBox& bb) const
|
||||
{
|
||||
return bb.overlaps(centre_, sqr(radius_));
|
||||
return bb.overlaps(origin_, sqr(radius_));
|
||||
}
|
||||
|
||||
|
||||
@ -181,8 +178,8 @@ const Foam::wordList& Foam::searchableSphere::regions() const
|
||||
{
|
||||
if (regions_.empty())
|
||||
{
|
||||
regions_.setSize(1);
|
||||
regions_[0] = "region0";
|
||||
regions_.resize(1);
|
||||
regions_.first() = "region0";
|
||||
}
|
||||
return regions_;
|
||||
}
|
||||
@ -195,10 +192,10 @@ void Foam::searchableSphere::boundingSpheres
|
||||
scalarField& radiusSqr
|
||||
) const
|
||||
{
|
||||
centres.setSize(1);
|
||||
centres[0] = centre_;
|
||||
centres.resize(1);
|
||||
centres[0] = origin_;
|
||||
|
||||
radiusSqr.setSize(1);
|
||||
radiusSqr.resize(1);
|
||||
radiusSqr[0] = Foam::sqr(radius_);
|
||||
|
||||
// Add a bit to make sure all points are tested inside
|
||||
@ -336,7 +333,7 @@ void Foam::searchableSphere::getNormal
|
||||
{
|
||||
if (info[i].hit())
|
||||
{
|
||||
normal[i] = normalised(info[i].hitPoint() - centre_);
|
||||
normal[i] = normalised(info[i].hitPoint() - origin_);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -362,7 +359,7 @@ void Foam::searchableSphere::getVolumeType
|
||||
|
||||
volType[pointi] =
|
||||
(
|
||||
(magSqr(pt - centre_) <= rad2)
|
||||
(magSqr(pt - origin_) <= rad2)
|
||||
? volumeType::INSIDE : volumeType::OUTSIDE
|
||||
);
|
||||
}
|
||||
|
||||
@ -29,10 +29,11 @@ Description
|
||||
|
||||
\heading Dictionary parameters
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | sphere / searchableSphere | selector |
|
||||
centre | The sphere centre | yes |
|
||||
radius | The (outside) radius of sphere | yes |
|
||||
Property | Description | Required | Default
|
||||
type | sphere / searchableSphere | selector |
|
||||
origin | The origin (centre) of the sphere | yes |
|
||||
radius | The (outside) radius of sphere | yes |
|
||||
centre | Alternative for 'origin' | no |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
@ -64,7 +65,7 @@ private:
|
||||
// Private Member Data
|
||||
|
||||
//- Centre point of the sphere
|
||||
const point centre_;
|
||||
const point origin_;
|
||||
|
||||
//- The outer radius of the sphere
|
||||
const scalar radius_;
|
||||
@ -151,7 +152,7 @@ public:
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual tmp<pointField> coordinates() const
|
||||
{
|
||||
return tmp<pointField>::New(1, centre_);
|
||||
return tmp<pointField>::New(1, origin_);
|
||||
}
|
||||
|
||||
//- Get bounding spheres (centre and radius squared), one per element.
|
||||
|
||||
@ -55,7 +55,7 @@ void Foam::sphereToCell::combine(topoSet& set, const bool add) const
|
||||
|
||||
forAll(ctrs, celli)
|
||||
{
|
||||
if (magSqr(ctrs[celli] - centre_) <= rad2)
|
||||
if (magSqr(ctrs[celli] - origin_) <= rad2)
|
||||
{
|
||||
addOrDelete(set, celli, add);
|
||||
}
|
||||
@ -68,12 +68,12 @@ void Foam::sphereToCell::combine(topoSet& set, const bool add) const
|
||||
Foam::sphereToCell::sphereToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const point& centre,
|
||||
const point& origin,
|
||||
const scalar radius
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
centre_(centre),
|
||||
origin_(origin),
|
||||
radius_(radius)
|
||||
{}
|
||||
|
||||
@ -84,9 +84,12 @@ Foam::sphereToCell::sphereToCell
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
centre_(dict.get<point>("centre")),
|
||||
radius_(dict.get<scalar>("radius"))
|
||||
sphereToCell
|
||||
(
|
||||
mesh,
|
||||
dict.getCompat<vector>("origin", {{"centre", 1806}}),
|
||||
dict.get<scalar>("radius")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -97,7 +100,7 @@ Foam::sphereToCell::sphereToCell
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
centre_(checkIs(is)),
|
||||
origin_(checkIs(is)),
|
||||
radius_(readScalar(checkIs(is)))
|
||||
{}
|
||||
|
||||
@ -112,15 +115,15 @@ void Foam::sphereToCell::applyToSet
|
||||
{
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||
{
|
||||
Info<< " Adding cells with centre within sphere, with centre = "
|
||||
<< centre_ << " and radius = " << radius_ << endl;
|
||||
Info<< " Adding cells within a sphere with centre = "
|
||||
<< origin_ << " and radius = " << radius_ << endl;
|
||||
|
||||
combine(set, true);
|
||||
}
|
||||
else if (action == topoSetSource::DELETE)
|
||||
{
|
||||
Info<< " Removing cells with centre within sphere, with centre = "
|
||||
<< centre_ << " and radius = " << radius_ << endl;
|
||||
Info<< " Removing cells within a sphere with centre = "
|
||||
<< origin_ << " and radius = " << radius_ << endl;
|
||||
|
||||
combine(set, false);
|
||||
}
|
||||
|
||||
@ -29,9 +29,10 @@ Description
|
||||
|
||||
\heading Dictionary parameters
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
centre | The sphere centre | yes |
|
||||
radius | The (outside) radius of sphere | yes |
|
||||
Property | Description | Required | Default
|
||||
origin | The origin (centre) of the sphere | yes |
|
||||
radius | The (outside) radius of sphere | yes |
|
||||
centre | Alternative for 'origin' | no |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
@ -64,7 +65,7 @@ class sphereToCell
|
||||
static addToUsageTable usage_;
|
||||
|
||||
//- Centre point of the sphere
|
||||
point centre_;
|
||||
point origin_;
|
||||
|
||||
//- The outer radius of the sphere
|
||||
scalar radius_;
|
||||
@ -87,7 +88,7 @@ public:
|
||||
sphereToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const point& centre,
|
||||
const point& origin,
|
||||
const scalar radius
|
||||
);
|
||||
|
||||
@ -104,7 +105,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual sourceType setType() const
|
||||
virtual topoSetSource::sourceType setType() const
|
||||
{
|
||||
return CELLSETSOURCE;
|
||||
}
|
||||
|
||||
@ -25,8 +25,8 @@ actions
|
||||
source sphereToCell;
|
||||
sourceInfo
|
||||
{
|
||||
centre (0.125 0.375 0.05);
|
||||
radius 0.005;
|
||||
origin (0.125 0.375 0.05);
|
||||
radius 0.005;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@ -110,7 +110,7 @@ actions
|
||||
source sphereToCell;
|
||||
sourceInfo
|
||||
{
|
||||
centre (-0.3 -0.3 -0.3);
|
||||
origin (-0.3 -0.3 -0.3);
|
||||
radius 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ FoamFile
|
||||
// // Cells with centre within sphere
|
||||
// source sphereToCell;
|
||||
// {
|
||||
// centre (0.2 0.2 -10);
|
||||
// origin (0.2 0.2 -10);
|
||||
// radius 5.0;
|
||||
// }
|
||||
//
|
||||
|
||||
@ -27,8 +27,9 @@ regions
|
||||
(
|
||||
sphereToCell
|
||||
{
|
||||
centre (0.5 0.5 0);
|
||||
radius 0.1;
|
||||
centre (0.5 0.5 0);
|
||||
radius 0.1;
|
||||
|
||||
fieldValues
|
||||
(
|
||||
volScalarFieldValue alpha.water 0
|
||||
|
||||
@ -27,8 +27,9 @@ regions
|
||||
(
|
||||
sphereToCell
|
||||
{
|
||||
centre (0.5 0.5 0.5);
|
||||
radius 0.1;
|
||||
origin (0.5 0.5 0.5);
|
||||
radius 0.1;
|
||||
|
||||
fieldValues
|
||||
(
|
||||
volScalarFieldValue alpha.water 0
|
||||
|
||||
Reference in New Issue
Block a user