Skip to content
Snippets Groups Projects
Commit 0ef75899 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BUG: sampledMeshSurface sampling on "empty" patch fails

- requires a field size check when copying into the flat boundary
parent e651d635
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -39,7 +39,11 @@ Foam::sampledMeshedSurface::sampleOnFaces ...@@ -39,7 +39,11 @@ Foam::sampledMeshedSurface::sampleOnFaces
{ {
const Type deflt const Type deflt
( (
defaultValues_.getOrDefault<Type>(sampler.psi().name(), Zero) defaultValues_.getOrDefault<Type>
(
sampler.psi().name(),
Foam::zero{}
)
); );
const labelList& elements = sampleElements_; const labelList& elements = sampleElements_;
...@@ -71,13 +75,16 @@ Foam::sampledMeshedSurface::sampleOnFaces ...@@ -71,13 +75,16 @@ Foam::sampledMeshedSurface::sampleOnFaces
const polyBoundaryMesh& pbm = mesh().boundaryMesh(); const polyBoundaryMesh& pbm = mesh().boundaryMesh();
Field<Type> bVals(mesh().nBoundaryFaces(), Zero); Field<Type> bVals(mesh().nBoundaryFaces(), deflt);
const auto& bField = sampler.psi().boundaryField(); const auto& bField = sampler.psi().boundaryField();
forAll(bField, patchi) forAll(bField, patchi)
{ {
SubList<Type>(bVals, pbm[patchi].range()) = bField[patchi]; // Note: restrict transcribing to actual size of the patch field
// - handles "empty" patch type etc.
const auto& pfld = bField[patchi];
SubList<Type>(bVals, pfld.size(), pbm[patchi].offset()) = pfld;
} }
// Sample within the flat boundary field // Sample within the flat boundary field
...@@ -109,7 +116,11 @@ Foam::sampledMeshedSurface::sampleOnPoints ...@@ -109,7 +116,11 @@ Foam::sampledMeshedSurface::sampleOnPoints
{ {
const Type deflt const Type deflt
( (
defaultValues_.getOrDefault<Type>(interpolator.psi().name(), Zero) defaultValues_.getOrDefault<Type>
(
interpolator.psi().name(),
Foam::zero{}
)
); );
const labelList& elements = sampleElements_; const labelList& elements = sampleElements_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment