diff --git a/tests/samplers/MultiCellSampler/testMultiCellSampler.C b/tests/samplers/MultiCellSampler/testMultiCellSampler.C index e3b3e59..5287fad 100644 --- a/tests/samplers/MultiCellSampler/testMultiCellSampler.C +++ b/tests/samplers/MultiCellSampler/testMultiCellSampler.C @@ -32,6 +32,7 @@ TEST_F(MultiCellSamplerTest, ConstructorDefaults) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cell"); ASSERT_EQ(sampler.cellFinderType(), "Tree"); + ASSERT_EQ(sampler.lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), false); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -64,6 +65,7 @@ TEST_F(MultiCellSamplerTest, ConstructorCellCrawling) 3.0, "cell", "Crawling", + "CubeRootVol", true ); @@ -107,6 +109,7 @@ TEST_F(MultiCellSamplerTest, ConstructorAttemptCellPoint) 3.0, "cellPoint", "Crawling", + "CubeRootVol", false ); }, @@ -138,6 +141,7 @@ TEST_F(MultiCellSamplerTest, ConstructorAttemptTreeHIsIndex) 3.0, "cell", "Tree", + "CubeRootVol", true ); }, @@ -173,6 +177,7 @@ TEST_F(MultiCellSamplerTest, ConstructorTree) 3.0, "cell", "Tree", + "CubeRootVol", false ); @@ -218,6 +223,7 @@ TEST_F(MultiCellSamplerTest, AttemptInvalidCellFinderName) 3.0, "cell", "RandomName", + "CubeRootCol", true ); }, @@ -226,6 +232,35 @@ TEST_F(MultiCellSamplerTest, AttemptInvalidCellFinderName) } +TEST_F(MultiCellSamplerTest, AttemptInvalidLengthScaleName) +{ + extern argList * mainArgs; + const argList & args = *mainArgs; + Time runTime(Foam::Time::controlDictName, args); + + autoPtr meshPtr = createMesh(runTime); + const fvMesh & mesh = meshPtr(); + createSamplingHeightField(mesh); + + const fvPatch & patch = mesh.boundary()["bottomWall"]; + + ASSERT_DEATH + ( + { + MultiCellSampler sampler + ( + "MultiCellSampler", + patch, + 3.0, + "cell", + "Tree", + "RandomName", + true + ); + }, + "FATAL ERROR" + ); +} TEST_F(MultiCellSamplerTest, Sample) { extern argList * mainArgs; @@ -260,6 +295,7 @@ TEST_F(MultiCellSamplerTest, Sample) 0.02, "cell", "Crawling", + "CubeRootVol", 3 ); @@ -309,6 +345,7 @@ TEST_F(MultiCellSamplerTest, AddField) 0.02, "cell", "Crawling", + "CubeRootVol", 3 ); diff --git a/tests/samplers/Sampler/testSampler.C b/tests/samplers/Sampler/testSampler.C index 51ba1df..83ee000 100644 --- a/tests/samplers/Sampler/testSampler.C +++ b/tests/samplers/Sampler/testSampler.C @@ -22,12 +22,13 @@ namespace Foam scalar averagingTime, const word interpolationType, const word cellFinderType, + const word lengthScaleType, bool hIsIndex ) : Sampler(p, averagingTime, interpolationType, cellFinderType, - hIsIndex) + lengthScaleType, hIsIndex) {} DummySampler @@ -37,11 +38,12 @@ namespace Foam scalar averagingTime, const word interpolationType, const word cellFinderType, + const word lengthScaleType, bool hIsIndex ) : Sampler(p, averagingTime, interpolationType, cellFinderType, - hIsIndex) + lengthScaleType, hIsIndex) {} DummySampler(const DummySampler &) = default; @@ -83,6 +85,7 @@ TEST_F(SamplerTest, FullConstructor) 3.0, "cell", "crawling", + "CubeRootVol", false ); @@ -90,6 +93,7 @@ TEST_F(SamplerTest, FullConstructor) ASSERT_EQ(sampler.Sampler::averagingTime(), 3.0); ASSERT_EQ(sampler.Sampler::interpolationType(), "cell"); ASSERT_EQ(sampler.Sampler::cellFinderType(), "crawling"); + ASSERT_EQ(sampler.Sampler::lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.Sampler::hIsIndex(), false); ASSERT_EQ(&sampler.Sampler::mesh(), &mesh); ASSERT_EQ(sampler.Sampler::nSampledFields(), 0); @@ -121,6 +125,7 @@ TEST_F(SamplerTest, NewNamePatchAveragingTime) 3.0, "cell", "crawling", + "CubeRootVol", false ) ); @@ -130,6 +135,7 @@ TEST_F(SamplerTest, NewNamePatchAveragingTime) ASSERT_EQ(sampler().Sampler::averagingTime(), 3.0); ASSERT_EQ(sampler().Sampler::interpolationType(), "cell"); ASSERT_EQ(sampler().Sampler::cellFinderType(), "crawling"); + ASSERT_EQ(sampler().Sampler::lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler().Sampler::hIsIndex(), false); ASSERT_EQ(&sampler().Sampler::mesh(), &mesh); ASSERT_EQ(sampler().Sampler::nSampledFields(), 0); @@ -193,6 +199,7 @@ TEST_F(SamplerTest, CreateFields) 3.0, "cell", "crawling", + "CubeRootVol", false ); @@ -217,6 +224,7 @@ TEST_F(SamplerTest, Copy) 3.0, "cell", "crawling", + "CubeRootVol", false ); sampler.addField(new SampledVelocityField(patch)); @@ -272,6 +280,7 @@ TEST_F(SamplerTest, AddField) 3.0, "cell", "crawling", + "CubeRootVol", false ); diff --git a/tests/samplers/SingleCellSampler/testSingleCellSampler.C b/tests/samplers/SingleCellSampler/testSingleCellSampler.C index 844b875..ebb0922 100644 --- a/tests/samplers/SingleCellSampler/testSingleCellSampler.C +++ b/tests/samplers/SingleCellSampler/testSingleCellSampler.C @@ -33,6 +33,7 @@ TEST_F(SingleCellSamplerTest, ConstructorDefaults) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cell"); ASSERT_EQ(sampler.cellFinderType(), "Tree"); + ASSERT_EQ(sampler.lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), false); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -58,6 +59,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellCrawlingHIsIndex) 3.0, "cell", "Crawling", + "CubeRootVol", true ); @@ -65,6 +67,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellCrawlingHIsIndex) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cell"); ASSERT_EQ(sampler.cellFinderType(), "Crawling"); + ASSERT_EQ(sampler.lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), true); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -96,6 +99,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellCrawlingHIsDistance) 3.0, "cell", "Crawling", + "CubeRootVol", false ); @@ -103,6 +107,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellCrawlingHIsDistance) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cell"); ASSERT_EQ(sampler.cellFinderType(), "Crawling"); + ASSERT_EQ(sampler.lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), false); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -135,6 +140,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointCrawlingHIsIndex) 3.0, "cellPoint", "Crawling", + "CubeRootVol", true ); @@ -142,6 +148,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointCrawlingHIsIndex) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cell"); ASSERT_EQ(sampler.cellFinderType(), "Crawling"); + ASSERT_EQ(sampler.lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), true); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -181,6 +188,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointCrawlingHIsDistance) 3.0, "cellPoint", "Crawling", + "WallNormalDistance", false ); @@ -188,6 +196,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointCrawlingHIsDistance) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cellPoint"); ASSERT_EQ(sampler.cellFinderType(), "Crawling"); + ASSERT_EQ(sampler.lengthScaleType(), "WallNormalDistance"); ASSERT_EQ(sampler.hIsIndex(), false); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -228,6 +237,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointCrawlingHIsDistanceFirstCell) 3.0, "cellPoint", "Crawling", + "CubeRootVol", false ); @@ -235,6 +245,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointCrawlingHIsDistanceFirstCell) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cellPoint"); ASSERT_EQ(sampler.cellFinderType(), "Crawling"); + ASSERT_EQ(sampler.cellFinderType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), false); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -270,6 +281,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellTreeHIsIndex) 3.0, "cell", "Tree", + "CubeRootVol", true ); }, @@ -296,6 +308,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellTreeHIsDistance) 3.0, "cell", "Tree", + "CubeRootVol", false ); @@ -303,6 +316,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellTreeHIsDistance) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cell"); ASSERT_EQ(sampler.cellFinderType(), "Tree"); + ASSERT_EQ(sampler.lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), false); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -341,6 +355,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointTreeHIsDistance) 3.0, "cellPoint", "Tree", + "CubeRootVol", false ); @@ -348,6 +363,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointTreeHIsDistance) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cellPoint"); ASSERT_EQ(sampler.cellFinderType(), "Tree"); + ASSERT_EQ(sampler.lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), false); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -388,6 +404,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointTreeHIsDistanceFirstCell) 3.0, "cellPoint", "Tree", + "CubeRootVol", false ); @@ -395,6 +412,7 @@ TEST_F(SingleCellSamplerTest, ConstructorCellPointTreeHIsDistanceFirstCell) ASSERT_EQ(sampler.averagingTime(), 3.0); ASSERT_EQ(sampler.interpolationType(), "cellPoint"); ASSERT_EQ(sampler.cellFinderType(), "Tree"); + ASSERT_EQ(sampler.lengthScaleType(), "CubeRootVol"); ASSERT_EQ(sampler.hIsIndex(), false); ASSERT_EQ(&sampler.mesh(), &mesh); ASSERT_EQ(sampler.indexList().size(), patch.size()); @@ -443,6 +461,7 @@ TEST_F(SingleCellSamplerTest, Sample) 0.02, "cell", "Crawling", + "CubeRootVol", 3 ); @@ -492,6 +511,7 @@ TEST_F(SingleCellSamplerTest, AddField) 0.02, "cell", "Crawling", + "CubeRootVol", 3 ); @@ -499,4 +519,39 @@ TEST_F(SingleCellSamplerTest, AddField) ASSERT_EQ(sampler.nSampledFields(), 3); ASSERT_TRUE(sampler.db().foundObject("pGrad")); +} + + +TEST_F(SingleCellSamplerTest, CreateLengthList) +{ + extern argList * mainArgs; + const argList & args = *mainArgs; + Time runTime(Foam::Time::controlDictName, args); + + autoPtr meshPtr = createMesh(runTime); + const fvMesh & mesh = meshPtr(); + createSamplingHeightField(mesh); + + volScalarField & h = const_cast + ( + mesh.thisDb().lookupObject("h") + ); + + const fvPatch & patch = mesh.boundary()["bottomWall"]; + + h.boundaryFieldRef()[patch.index()] == 0.5; + + SingleCellSampler sampler + ( + "SingleCellSampler", + patch, + 3.0 + ); + + ASSERT_EQ(sampler.lengthList().size(), patch.size()); + + for (int i=0; i< sampler.lengthList().size(); i++) + { + ASSERT_FLOAT_EQ(sampler.lengthList()[i], 0.2); + } } \ No newline at end of file