ENH: sampling: add offsetMode to patchInternalField sampleSurface

This commit is contained in:
mattijs
2011-09-28 11:33:05 +01:00
parent 1a54a0c81b
commit ca358fdc1c
3 changed files with 92 additions and 19 deletions

View File

@ -188,8 +188,25 @@ surfaces
// cell, can be arbitrarily far away. // cell, can be arbitrarily far away.
type patchInternalField; type patchInternalField;
patches ( ".*Wall.*" ); patches ( ".*Wall.*" );
distance 0.0001;
interpolate true; interpolate true;
// Optional: specify how to obtain sampling points from the patch
// face centres (default is 'normal')
//
// //- Specify distance to offset in normal direction
offsetMode normal;
distance 0.1;
//
// //- Specify single uniform offset
// offsetMode uniform;
// offset (0 0 0.0001);
//
// //- Specify offset per patch face
// offsetMode nonuniform;
// offsets ((0 0 0.0001) (0 0 0.0002));
// Optional: whether to leave as faces (=default) or triangulate // Optional: whether to leave as faces (=default) or triangulate
// triangulate false; // triangulate false;
} }

View File

@ -112,6 +112,10 @@ public:
NORMAL // use face normal + distance NORMAL // use face normal + distance
}; };
static const NamedEnum<sampleMode, 4> sampleModeNames_;
static const NamedEnum<offsetMode, 3> offsetModeNames_;
//- Helper class for finding nearest //- Helper class for finding nearest
// Nearest: // Nearest:
@ -146,10 +150,6 @@ private:
// Private data // Private data
static const NamedEnum<sampleMode, 4> sampleModeNames_;
static const NamedEnum<offsetMode, 3> offsetModeNames_;
//- Patch to sample //- Patch to sample
const polyPatch& patch_; const polyPatch& patch_;

View File

@ -58,17 +58,28 @@ Foam::sampledPatchInternalField::sampledPatchInternalField
sampledPatch(name, mesh, dict), sampledPatch(name, mesh, dict),
mappers_(patchIDs().size()) mappers_(patchIDs().size())
{ {
const scalar distance = readScalar(dict.lookup("distance")); mappedPatchBase::offsetMode mode = mappedPatchBase::NORMAL;
if (dict.found("offsetMode"))
{
mode = mappedPatchBase::offsetModeNames_.read
(
dict.lookup("offsetMode")
);
}
switch (mode)
{
case mappedPatchBase::NORMAL:
{
const scalar distance = readScalar(dict.lookup("distance"));
forAll(patchIDs(), i) forAll(patchIDs(), i)
{ {
label patchI = patchIDs()[i];
mappers_.set mappers_.set
( (
i, i,
new mappedPatchBase new mappedPatchBase
( (
mesh.boundaryMesh()[patchI], mesh.boundaryMesh()[patchIDs()[i]],
mesh.name(), // sampleRegion mesh.name(), // sampleRegion
mappedPatchBase::NEARESTCELL, // sampleMode mappedPatchBase::NEARESTCELL, // sampleMode
word::null, // samplePatch word::null, // samplePatch
@ -76,6 +87,51 @@ Foam::sampledPatchInternalField::sampledPatchInternalField
) )
); );
} }
}
break;
case mappedPatchBase::UNIFORM:
{
const point offset(dict.lookup("offset"));
forAll(patchIDs(), i)
{
mappers_.set
(
i,
new mappedPatchBase
(
mesh.boundaryMesh()[patchIDs()[i]],
mesh.name(), // sampleRegion
mappedPatchBase::NEARESTCELL, // sampleMode
word::null, // samplePatch
offset // sample inside my domain
)
);
}
}
break;
case mappedPatchBase::NONUNIFORM:
{
const pointField offsets(dict.lookup("offsets"));
forAll(patchIDs(), i)
{
mappers_.set
(
i,
new mappedPatchBase
(
mesh.boundaryMesh()[patchIDs()[i]],
mesh.name(), // sampleRegion
mappedPatchBase::NEARESTCELL, // sampleMode
word::null, // samplePatch
offsets // sample inside my domain
)
);
}
}
break;
}
} }