ENH: timeVaryingMapped: added checking

This commit is contained in:
mattijs
2013-02-06 11:37:45 +00:00
parent 5e7a807413
commit d5ef310d43
5 changed files with 79 additions and 7 deletions

View File

@ -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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -343,6 +343,18 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
) )
); );
if (vals.size() != mapperPtr_().sourceSize())
{
FatalErrorIn
(
"timeVaryingMappedFixedValueFvPatchField<Type>::"
"checkTable()"
) << "Number of values (" << vals.size()
<< ") differs from the number of points ("
<< mapperPtr_().sourceSize()
<< ") in file " << vals.objectPath() << exit(FatalError);
}
startAverage_ = vals.average(); startAverage_ = vals.average();
startSampledValues_ = mapperPtr_().interpolate(vals); startSampledValues_ = mapperPtr_().interpolate(vals);
} }
@ -388,6 +400,19 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
false false
) )
); );
if (vals.size() != mapperPtr_().sourceSize())
{
FatalErrorIn
(
"timeVaryingMappedFixedValueFvPatchField<Type>::"
"checkTable()"
) << "Number of values (" << vals.size()
<< ") differs from the number of points ("
<< mapperPtr_().sourceSize()
<< ") in file " << vals.objectPath() << exit(FatalError);
}
endAverage_ = vals.average(); endAverage_ = vals.average();
endSampledValues_ = mapperPtr_().interpolate(vals); endSampledValues_ = mapperPtr_().interpolate(vals);
} }

View File

@ -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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -313,6 +313,18 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::checkTable()
) )
); );
if (vals.size() != mapperPtr_().sourceSize())
{
FatalErrorIn
(
"timeVaryingMappedFixedValuePointPatchField<Type>::"
"checkTable()"
) << "Number of values (" << vals.size()
<< ") differs from the number of points ("
<< mapperPtr_().sourceSize()
<< ") in file " << vals.objectPath() << exit(FatalError);
}
startAverage_ = vals.average(); startAverage_ = vals.average();
startSampledValues_ = mapperPtr_().interpolate(vals); startSampledValues_ = mapperPtr_().interpolate(vals);
} }
@ -357,6 +369,19 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::checkTable()
false false
) )
); );
if (vals.size() != mapperPtr_().sourceSize())
{
FatalErrorIn
(
"timeVaryingMappedFixedValuePointPatchField<Type>::"
"checkTable()"
) << "Number of values (" << vals.size()
<< ") differs from the number of points ("
<< mapperPtr_().sourceSize()
<< ") in file " << vals.objectPath() << exit(FatalError);
}
endAverage_ = vals.average(); endAverage_ = vals.average();
endSampledValues_ = mapperPtr_().interpolate(vals); endSampledValues_ = mapperPtr_().interpolate(vals);
} }

View File

@ -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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -222,7 +222,8 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
) )
: :
perturb_(perturb), perturb_(perturb),
referenceCS_(calcCoordinateSystem(sourcePoints)) referenceCS_(calcCoordinateSystem(sourcePoints)),
nPoints_(sourcePoints.size())
{ {
calcWeights(sourcePoints, destPoints); calcWeights(sourcePoints, destPoints);
@ -238,7 +239,8 @@ Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
) )
: :
perturb_(perturb), perturb_(perturb),
referenceCS_(referenceCS) referenceCS_(referenceCS),
nPoints_(sourcePoints.size())
{ {
calcWeights(sourcePoints, destPoints); calcWeights(sourcePoints, destPoints);
} }

View File

@ -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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -59,6 +59,9 @@ class pointToPointPlanarInterpolation
//- Coordinate system //- Coordinate system
coordinateSystem referenceCS_; coordinateSystem referenceCS_;
//- Number of source points (for checking)
label nPoints_;
//- Current interpolation addressing to face centres of underlying //- Current interpolation addressing to face centres of underlying
// patch // patch
List<FixedList<label, 3> > nearestVertex_; List<FixedList<label, 3> > nearestVertex_;
@ -114,6 +117,12 @@ public:
return referenceCS_; return referenceCS_;
} }
//- Number of source points
label sourceSize() const
{
return nPoints_;
}
// patch // patch
const List<FixedList<label, 3> >& nearestVertex() const const List<FixedList<label, 3> >& nearestVertex() const
{ {

View File

@ -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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,6 +33,17 @@ Foam::tmp<Foam::Field<Type> > Foam::pointToPointPlanarInterpolation::interpolate
const Field<Type>& sourceFld const Field<Type>& sourceFld
) const ) const
{ {
if (nPoints_ != sourceFld.size())
{
FatalErrorIn
(
"pointToPointPlanarInterpolation::interpolate"
"(const Field<Type>&) const"
) << "Number of source points = " << nPoints_
<< " number of values = " << sourceFld.size()
<< exit(FatalError);
}
tmp<Field<Type> > tfld(new Field<Type>(nearestVertex_.size())); tmp<Field<Type> > tfld(new Field<Type>(nearestVertex_.size()));
Field<Type>& fld = tfld(); Field<Type>& fld = tfld();