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