mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: error with surfMesh transfer from triSurfaceMesh (closes #862)
- face/point ownership is transferred to the surfMesh, so use these directly when sampling the interior.
This commit is contained in:
@ -58,14 +58,14 @@ Foam::sampledTriSurfaceMesh::sampleOnFaces
|
|||||||
auto& values = tvalues.ref();
|
auto& values = tvalues.ref();
|
||||||
|
|
||||||
const polyBoundaryMesh& pbm = mesh().boundaryMesh();
|
const polyBoundaryMesh& pbm = mesh().boundaryMesh();
|
||||||
|
const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
|
||||||
|
|
||||||
// Create flat boundary field
|
// Create flat boundary field
|
||||||
const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
|
|
||||||
|
|
||||||
Field<Type> bVals(nBnd, Zero);
|
Field<Type> bVals(nBnd, Zero);
|
||||||
|
|
||||||
const auto& bField = sampler.psi().boundaryField();
|
const auto& bField = sampler.psi().boundaryField();
|
||||||
|
|
||||||
forAll(bField, patchi)
|
forAll(bField, patchi)
|
||||||
{
|
{
|
||||||
const label bFacei = (pbm[patchi].start() - mesh().nInternalFaces());
|
const label bFacei = (pbm[patchi].start() - mesh().nInternalFaces());
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -91,6 +91,13 @@ class surfMeshSampleDiscrete
|
|||||||
//- Transfer mesh content from SurfaceSource to surfMesh
|
//- Transfer mesh content from SurfaceSource to surfMesh
|
||||||
void transferContent();
|
void transferContent();
|
||||||
|
|
||||||
|
//- Sample field (from volume field) onto surface faces
|
||||||
|
template<class Type>
|
||||||
|
tmp<Field<Type>> sampleOnFaces
|
||||||
|
(
|
||||||
|
const interpolation<Type>& sampler
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Sample field on surface.
|
//- Sample field on surface.
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool sampleType
|
bool sampleType
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -24,11 +24,32 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "surfMeshSampleDiscrete.H"
|
#include "surfMeshSampleDiscrete.H"
|
||||||
#include "dimensionedType.H"
|
|
||||||
#include "error.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::tmp<Foam::Field<Type>>
|
||||||
|
Foam::surfMeshSampleDiscrete::sampleOnFaces
|
||||||
|
(
|
||||||
|
const interpolation<Type>& sampler
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (onBoundary())
|
||||||
|
{
|
||||||
|
return SurfaceSource::sampleOnFaces(sampler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sample cells
|
||||||
|
return surfMeshSample::sampleOnFaces
|
||||||
|
(
|
||||||
|
sampler,
|
||||||
|
sampleElements(), //< sampleElements == meshCells
|
||||||
|
surface().faces(),
|
||||||
|
surface().points()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool Foam::surfMeshSampleDiscrete::sampleType
|
bool Foam::surfMeshSampleDiscrete::sampleType
|
||||||
(
|
(
|
||||||
@ -38,7 +59,7 @@ bool Foam::surfMeshSampleDiscrete::sampleType
|
|||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
|
||||||
const auto volFldPtr =
|
const auto* volFldPtr =
|
||||||
SurfaceSource::mesh().lookupObjectPtr<VolFieldType>(fieldName);
|
SurfaceSource::mesh().lookupObjectPtr<VolFieldType>(fieldName);
|
||||||
|
|
||||||
if (!volFldPtr)
|
if (!volFldPtr)
|
||||||
@ -48,52 +69,11 @@ bool Foam::surfMeshSampleDiscrete::sampleType
|
|||||||
|
|
||||||
auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr);
|
auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr);
|
||||||
|
|
||||||
getOrCreateSurfField<Type>(*volFldPtr).field()
|
getOrCreateSurfField<Type>(*volFldPtr).field() =
|
||||||
= SurfaceSource::sampleOnFaces(*samplerPtr);
|
sampleOnFaces(*samplerPtr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// template<class Type>
|
|
||||||
// Foam::tmp<Foam::DimensionedField<Type, Foam::surfGeoMesh>>
|
|
||||||
// Foam::surfMeshSampleDiscrete::sampleOnFaces
|
|
||||||
// (
|
|
||||||
// const GeometricField<Type, fvPatchField, volMesh>& fld
|
|
||||||
// ) const
|
|
||||||
// {
|
|
||||||
// typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
|
|
||||||
//
|
|
||||||
// tmp<Field<Type>> tfield = SurfaceSource::sampleOnFaces(fld);
|
|
||||||
// SurfFieldType& result = getOrCreateSurfField<Type>(fld);
|
|
||||||
//
|
|
||||||
// // need to verify if this will be needed (in the future)
|
|
||||||
// const surfMesh& s = surface();
|
|
||||||
// if (result.size() != s.size())
|
|
||||||
// {
|
|
||||||
// // maybe resampling changed the surfMesh,
|
|
||||||
// // but the existing surfField wasn't updated
|
|
||||||
//
|
|
||||||
// result.resize(s.size(), Zero);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (result.size() != sampleElements().size())
|
|
||||||
// {
|
|
||||||
// FatalErrorInFunction
|
|
||||||
// << "mismatch in field/mesh sizes "
|
|
||||||
// << result.name() << nl
|
|
||||||
// << " field has " << result.size()
|
|
||||||
// << " but sampleElements has " << sampleElements().size() << nl
|
|
||||||
// << endl
|
|
||||||
// << exit(FatalError);
|
|
||||||
//
|
|
||||||
// Info<< "WARNING: "
|
|
||||||
// << endl;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// result = tfield;
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -744,6 +744,7 @@ bool Foam::discreteSurface::interpolate() const
|
|||||||
return interpolate_;
|
return interpolate_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::discreteSurface::interpolate(bool b)
|
bool Foam::discreteSurface::interpolate(bool b)
|
||||||
{
|
{
|
||||||
if (interpolate_ == b)
|
if (interpolate_ == b)
|
||||||
|
|||||||
@ -175,24 +175,26 @@ Foam::discreteSurface::sampleOnFaces
|
|||||||
|
|
||||||
Field<Type> bVals(nBnd, Zero);
|
Field<Type> bVals(nBnd, Zero);
|
||||||
|
|
||||||
forAll(vField.boundaryField(), patchi)
|
const auto& bField = vField.boundaryField();
|
||||||
|
|
||||||
|
forAll(bField, patchi)
|
||||||
{
|
{
|
||||||
label bFacei = pbm[patchi].start() - mesh().nInternalFaces();
|
const label bFacei = pbm[patchi].start() - mesh().nInternalFaces();
|
||||||
|
|
||||||
SubList<Type>
|
SubList<Type>
|
||||||
(
|
(
|
||||||
bVals,
|
bVals,
|
||||||
vField.boundaryField()[patchi].size(),
|
bField[patchi].size(),
|
||||||
bFacei
|
bFacei
|
||||||
) = vField.boundaryField()[patchi];
|
) = bField[patchi];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample in flat boundary field
|
// Sample in flat boundary field
|
||||||
|
|
||||||
for (label i=0; i < len; ++i)
|
for (label i=0; i < len; ++i)
|
||||||
{
|
{
|
||||||
label facei = elements[i];
|
const label bFacei = (elements[i] - mesh().nInternalFaces());
|
||||||
values[i] = bVals[facei-mesh().nInternalFaces()];
|
values[i] = bVals[bFacei];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +232,7 @@ Foam::discreteSurface::sampleOnPoints
|
|||||||
|
|
||||||
forAll(samplePoints_, pointi)
|
forAll(samplePoints_, pointi)
|
||||||
{
|
{
|
||||||
label facei = sampleElements_[pointi];
|
const label facei = sampleElements_[pointi];
|
||||||
|
|
||||||
values[pointi] = interpolator.interpolate
|
values[pointi] = interpolator.interpolate
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user