ENH: timeVaryingMapped: added option to disable interpolation

This commit is contained in:
mattijs
2014-09-03 12:26:40 +01:00
committed by Andrew Heather
parent d4c966de31
commit bf7affba14
4 changed files with 108 additions and 18 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,6 +72,7 @@ timeVaryingMappedFixedValueFvPatchField
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
mapMethod_(ptf.mapMethod_),
mapperPtr_(NULL),
sampleTimes_(0),
startSampleTime_(-1),
@ -102,6 +103,14 @@ timeVaryingMappedFixedValueFvPatchField
fieldTableName_(iF.name()),
setAverage_(readBool(dict.lookup("setAverage"))),
perturb_(dict.lookupOrDefault("perturb", 1e-5)),
mapMethod_
(
dict.lookupOrDefault<word>
(
"mapMethod",
"planarInterpolation"
)
),
mapperPtr_(NULL),
sampleTimes_(0),
startSampleTime_(-1),
@ -112,6 +121,27 @@ timeVaryingMappedFixedValueFvPatchField
endAverage_(pTraits<Type>::zero),
offset_(DataEntry<Type>::New("offset", dict))
{
if
(
mapMethod_ != "planarInterpolation"
&& mapMethod_ != "nearest"
)
{
FatalIOErrorIn
(
"timeVaryingMappedFixedValueFvPatchField<Type>::\n"
"timeVaryingMappedFixedValueFvPatchField\n"
"(\n"
" const fvPatch&\n"
" const DimensionedField<Type, volMesh>&\n"
" const dictionary&\n"
")\n",
dict
) << "mapMethod should be one of 'planarInterpolation'"
<< ", 'nearest'" << exit(FatalIOError);
}
dict.readIfPresent("fieldTableName", fieldTableName_);
if (dict.found("value"))
@ -140,6 +170,7 @@ timeVaryingMappedFixedValueFvPatchField
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
mapMethod_(ptf.mapMethod_),
mapperPtr_(NULL),
sampleTimes_(ptf.sampleTimes_),
startSampleTime_(ptf.startSampleTime_),
@ -169,6 +200,7 @@ timeVaryingMappedFixedValueFvPatchField
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
mapMethod_(ptf.mapMethod_),
mapperPtr_(NULL),
sampleTimes_(ptf.sampleTimes_),
startSampleTime_(ptf.startSampleTime_),
@ -258,6 +290,14 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
<< samplePointsFile << endl;
}
// tbd: run-time selection
bool nearestOnly =
(
!mapMethod_.empty()
&& mapMethod_ != "planarInterpolation"
);
// Allocate the interpolator
mapperPtr_.reset
(
@ -265,7 +305,8 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
(
samplePoints,
this->patch().patch().faceCentres(),
perturb_
perturb_,
nearestOnly
)
);
@ -560,6 +601,18 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::write(Ostream& os) const
<< token::END_STATEMENT << nl;
}
if
(
(
!mapMethod_.empty()
&& mapMethod_ != "planarInterpolation"
)
)
{
os.writeKeyword("mapMethod") << mapMethod_
<< token::END_STATEMENT << nl;
}
offset_->writeData(os);
this->writeEntry("value", os);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,12 +33,13 @@ Description
constant/boundaryData/\<patchname\> where:
- points : pointField with locations
- ddd : supplied values at time ddd
The points should be more or less on a plane since they get triangulated
in 2-D.
The default mode of operation (mapMethod planarInterpolation) is
to project the points onto a plane (constructed from the first threee
points) and construct a 2D triangulation and finds for the face centres
the triangle it is in and the weights to the 3 vertices.
At startup, this condition generates the triangulation and performs a
linear interpolation (triangle it is in and weights to the 3 vertices)
for every face centre.
The optional mapMethod nearest will avoid all projection and
triangulation and just use the value at the nearest vertex.
Values are interpolated linearly between times.
@ -49,6 +50,7 @@ Description
setAverage | flag to activate setting of average value | yes |
perturb | perturb points for regular geometries | no | 1e-5
fieldTableName | alternative field name to sample | no| this field name
mapMethod | type of mapping | no | planarInterpolation
\endtable
/verbatim
@ -61,10 +63,6 @@ Description
}
/endverbatim
Note
Switch on debug flag to have it dump the triangulation (in transformed
space) and transform face centres.
SeeAlso
Foam::fixedValueFvPatchField
@ -107,7 +105,10 @@ class timeVaryingMappedFixedValueFvPatchField
//- Fraction of perturbation (fraction of bounding box) to add
scalar perturb_;
//- 2D interpolation
//- Interpolation scheme to use
word mapMethod_;
//- 2D interpolation (for 'planarInterpolation' mapMethod)
autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
//- List of boundaryData time directories

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,6 +42,7 @@ timeVaryingMappedFixedValuePointPatchField
fieldTableName_(iF.name()),
setAverage_(false),
perturb_(0),
mapperPtr_(NULL),
sampleTimes_(0),
startSampleTime_(-1),
startSampledValues_(0),
@ -68,7 +69,8 @@ timeVaryingMappedFixedValuePointPatchField
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
mapperPtr_(ptf.mapperPtr_),
mapMethod_(ptf.mapMethod_),
mapperPtr_(NULL),
sampleTimes_(0),
startSampleTime_(-1),
startSampledValues_(0),
@ -99,6 +101,14 @@ timeVaryingMappedFixedValuePointPatchField
fieldTableName_(iF.name()),
setAverage_(readBool(dict.lookup("setAverage"))),
perturb_(dict.lookupOrDefault("perturb", 1e-5)),
mapMethod_
(
dict.lookupOrDefault<word>
(
"mapMethod",
"planarInterpolation"
)
),
mapperPtr_(NULL),
sampleTimes_(0),
startSampleTime_(-1),
@ -146,6 +156,7 @@ timeVaryingMappedFixedValuePointPatchField
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
mapMethod_(ptf.mapMethod_),
mapperPtr_(ptf.mapperPtr_),
sampleTimes_(ptf.sampleTimes_),
startSampleTime_(ptf.startSampleTime_),
@ -176,6 +187,7 @@ timeVaryingMappedFixedValuePointPatchField
fieldTableName_(ptf.fieldTableName_),
setAverage_(ptf.setAverage_),
perturb_(ptf.perturb_),
mapMethod_(ptf.mapMethod_),
mapperPtr_(ptf.mapperPtr_),
sampleTimes_(ptf.sampleTimes_),
startSampleTime_(ptf.startSampleTime_),
@ -290,13 +302,22 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::checkTable()
)
);
// tbd: run-time selection
bool nearestOnly =
(
!mapMethod_.empty()
&& mapMethod_ != "planarInterpolation"
);
// Allocate the interpolator
mapperPtr_.reset
(
new pointToPointPlanarInterpolation
(
samplePoints,
meshPts,
perturb_
perturb_,
nearestOnly
)
);
@ -593,6 +614,18 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::write
<< token::END_STATEMENT << nl;
}
if
(
(
!mapMethod_.empty()
&& mapMethod_ != "planarInterpolation"
)
)
{
os.writeKeyword("mapMethod") << mapMethod_
<< token::END_STATEMENT << nl;
}
if (offset_.valid())
{
offset_->writeData(os);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -68,7 +68,10 @@ class timeVaryingMappedFixedValuePointPatchField
//- Fraction of perturbation (fraction of bounding box) to add
scalar perturb_;
//- 2D interpolation
//- Interpolation scheme to use
word mapMethod_;
//- 2D interpolation (for 'planarInterpolation' mapMethod)
autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
//- List of boundaryData time directories