mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,7 +36,7 @@ void Foam::clockTime::getTime(timeType& t)
|
||||
|
||||
double Foam::clockTime::timeDifference(const timeType& beg, const timeType& end)
|
||||
{
|
||||
return end.tv_sec - beg.tv_sec + 1E-6*(end.tv_usec - beg.tv_usec);
|
||||
return end.tv_sec - beg.tv_sec + 1e-6*(end.tv_usec - beg.tv_usec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -576,6 +576,13 @@ $(interpolations)/interpolationTable/tableReaders/tableReaders.C
|
||||
$(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C
|
||||
$(interpolations)/interpolationTable/tableReaders/csv/csvTableReaders.C
|
||||
|
||||
interpolationWeights = $(interpolations)/interpolationWeights
|
||||
$(interpolationWeights)/interpolationWeights/interpolationWeights.C
|
||||
$(interpolationWeights)/linearInterpolationWeights/linearInterpolationWeights.C
|
||||
$(interpolationWeights)/splineInterpolationWeights/splineInterpolationWeights.C
|
||||
|
||||
|
||||
|
||||
algorithms/indexedOctree/indexedOctreeName.C
|
||||
algorithms/indexedOctree/treeDataCell.C
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -119,6 +119,12 @@ public:
|
||||
inline void operator=(const T&);
|
||||
|
||||
|
||||
// STL type definitions
|
||||
|
||||
//- Type of values the UList contains.
|
||||
typedef T value_type;
|
||||
|
||||
|
||||
// Ostream operator
|
||||
|
||||
//- Write UIndirectList to Ostream
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -151,9 +151,25 @@ Foam::wordList Foam::objectRegistry::sortedNames(const word& ClassName) const
|
||||
|
||||
const Foam::objectRegistry& Foam::objectRegistry::subRegistry
|
||||
(
|
||||
const word& name
|
||||
const word& name,
|
||||
const bool forceCreate
|
||||
) const
|
||||
{
|
||||
if (forceCreate && !foundObject<objectRegistry>(name))
|
||||
{
|
||||
objectRegistry* fieldsCachePtr = new objectRegistry
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
time().constant(),
|
||||
*this,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
fieldsCachePtr->store();
|
||||
}
|
||||
return lookupObject<objectRegistry>(name);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -147,8 +147,13 @@ public:
|
||||
template<class Type>
|
||||
wordList names() const;
|
||||
|
||||
//- Lookup and return a const sub-objectRegistry
|
||||
const objectRegistry& subRegistry(const word& name) const;
|
||||
//- Lookup and return a const sub-objectRegistry. Optionally create
|
||||
// it if it does not exist.
|
||||
const objectRegistry& subRegistry
|
||||
(
|
||||
const word& name,
|
||||
const bool forceCreate = false
|
||||
) const;
|
||||
|
||||
//- Lookup and return all objects of the given Type
|
||||
template<class Type>
|
||||
|
||||
@ -131,6 +131,16 @@ dimensioned<Type>::dimensioned
|
||||
token nextToken(is);
|
||||
is.putBack(nextToken);
|
||||
|
||||
// Check if the original format is used in which the name is provided
|
||||
// and reset the name to that read
|
||||
if (nextToken.isWord())
|
||||
{
|
||||
is >> name_;
|
||||
is >> nextToken;
|
||||
is.putBack(nextToken);
|
||||
}
|
||||
|
||||
// If the dimensions are provided compare with the argument
|
||||
if (nextToken == token::BEGIN_SQR)
|
||||
{
|
||||
dimensionSet dims(is);
|
||||
@ -391,8 +401,26 @@ dimensioned<Type> min
|
||||
template <class Type>
|
||||
Istream& operator>>(Istream& is, dimensioned<Type>& dt)
|
||||
{
|
||||
// do a stream read op for a Type and a dimensions()et
|
||||
is >> dt.name_ >> dt.dimensions_ >> dt.value_;
|
||||
token nextToken(is);
|
||||
is.putBack(nextToken);
|
||||
|
||||
// Check if the original format is used in which the name is provided
|
||||
// and reset the name to that read
|
||||
if (nextToken.isWord())
|
||||
{
|
||||
is >> dt.name_;
|
||||
is >> nextToken;
|
||||
is.putBack(nextToken);
|
||||
}
|
||||
|
||||
// If the dimensions are provided reset the dimensions to those read
|
||||
if (nextToken == token::BEGIN_SQR)
|
||||
{
|
||||
is >> dt.dimensions_;
|
||||
}
|
||||
|
||||
// Read the value
|
||||
is >> dt.value_;
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, dimensioned<Type>&)");
|
||||
|
||||
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class GeoField>
|
||||
Foam::tmp<GeoField> Foam::uniformInterpolate
|
||||
(
|
||||
const HashPtrTable<GeoField, label, Hash<label> >& fields,
|
||||
const labelList& indices,
|
||||
const scalarField& weights
|
||||
)
|
||||
{
|
||||
const GeoField& field0 = *(*fields.begin());
|
||||
|
||||
// Interpolate
|
||||
tmp<GeoField> tfld
|
||||
(
|
||||
new GeoField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"uniformInterpolate(" + field0.name() + ')',
|
||||
field0.time().timeName(),
|
||||
field0.db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
weights[0]*(*fields[indices[0]])
|
||||
)
|
||||
);
|
||||
GeoField& fld = tfld();
|
||||
|
||||
for (label i = 1; i < indices.size(); ++i)
|
||||
{
|
||||
fld += weights[i]*(*fields[indices[i]]);
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
Foam::tmp<GeoField> Foam::uniformInterpolate
|
||||
(
|
||||
const IOobject& fieldIO,
|
||||
const word& fieldName,
|
||||
const wordList& times,
|
||||
const scalarField& weights,
|
||||
const objectRegistry& fieldsCache
|
||||
)
|
||||
{
|
||||
// Look up the first field
|
||||
const objectRegistry& time0Fields = fieldsCache.lookupObject
|
||||
<
|
||||
const objectRegistry
|
||||
>
|
||||
(
|
||||
times[0]
|
||||
);
|
||||
const GeoField& field0 = time0Fields.lookupObject
|
||||
<
|
||||
const GeoField
|
||||
>
|
||||
(
|
||||
fieldName
|
||||
);
|
||||
|
||||
|
||||
// Interpolate
|
||||
tmp<GeoField> tfld(new GeoField(fieldIO, weights[0]*field0));
|
||||
GeoField& fld = tfld();
|
||||
|
||||
for (label i = 1; i < times.size(); ++i)
|
||||
{
|
||||
const objectRegistry& timeIFields = fieldsCache.lookupObject
|
||||
<
|
||||
const objectRegistry
|
||||
>
|
||||
(
|
||||
times[i]
|
||||
);
|
||||
const GeoField& fieldI = timeIFields.lookupObject
|
||||
<
|
||||
const GeoField
|
||||
>
|
||||
(
|
||||
fieldName
|
||||
);
|
||||
|
||||
fld += weights[i]*fieldI;
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
Foam::tmp<GeoField> Foam::uniformInterpolate
|
||||
(
|
||||
const IOobject& fieldIO,
|
||||
const word& fieldName,
|
||||
const wordList& times,
|
||||
const scalarField& weights,
|
||||
const word& registryName
|
||||
)
|
||||
{
|
||||
return uniformInterpolate<GeoField>
|
||||
(
|
||||
fieldIO,
|
||||
fieldName,
|
||||
times,
|
||||
weights,
|
||||
fieldIO.db().subRegistry(registryName, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,83 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GeometricField.H"
|
||||
#include "HashPtrTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Interpolate selected fields (given by indices and corresponding weights)
|
||||
// (boundary type becomes calculated). Fields stored per index. Field gets name
|
||||
// "uniformInterpolate(" + fld.name() + ')'.
|
||||
template<class GeoField>
|
||||
tmp<GeoField> uniformInterpolate
|
||||
(
|
||||
const HashPtrTable<GeoField, label, Hash<label> >& fields,
|
||||
const labelList& indices,
|
||||
const scalarField& weights
|
||||
);
|
||||
|
||||
//- Interpolate fields. fieldsCache contains per timeName all loaded fields.
|
||||
// Resulting field gets properties according to fieldIO
|
||||
template<class GeoField>
|
||||
tmp<GeoField> uniformInterpolate
|
||||
(
|
||||
const IOobject& fieldIO,
|
||||
const word& fieldName,
|
||||
const wordList& times,
|
||||
const scalarField& weights,
|
||||
const objectRegistry& fieldsCache
|
||||
);
|
||||
|
||||
//- Interpolate fields. fieldsCache contains per timeName all loaded fields.
|
||||
// Resulting field gets properties according to fieldIO
|
||||
template<class GeoField>
|
||||
tmp<GeoField> uniformInterpolate
|
||||
(
|
||||
const IOobject& fieldIO,
|
||||
const word& fieldName,
|
||||
const wordList& times,
|
||||
const scalarField& weights,
|
||||
const word& registryName = "fieldsCache"
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "uniformInterpolate.C"
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -127,4 +127,134 @@ Foam::wordList Foam::ReadFields
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void Foam::ReadFields
|
||||
(
|
||||
const word& fieldName,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const wordList& timeNames,
|
||||
objectRegistry& fieldsCache
|
||||
)
|
||||
{
|
||||
// Collect all times that are no longer used
|
||||
{
|
||||
HashSet<word> usedTimes(timeNames);
|
||||
|
||||
DynamicList<word> unusedTimes(fieldsCache.size());
|
||||
|
||||
forAllIter(objectRegistry, fieldsCache, timeIter)
|
||||
{
|
||||
const word& tm = timeIter.key();
|
||||
if (!usedTimes.found(tm))
|
||||
{
|
||||
unusedTimes.append(tm);
|
||||
}
|
||||
}
|
||||
|
||||
//Info<< "Unloading times " << unusedTimes << endl;
|
||||
|
||||
forAll(unusedTimes, i)
|
||||
{
|
||||
objectRegistry& timeCache = const_cast<objectRegistry&>
|
||||
(
|
||||
fieldsCache.lookupObject<objectRegistry>(unusedTimes[i])
|
||||
);
|
||||
fieldsCache.checkOut(timeCache);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load any new fields
|
||||
forAll(timeNames, i)
|
||||
{
|
||||
const word& tm = timeNames[i];
|
||||
|
||||
// Create if not found
|
||||
if (!fieldsCache.found(tm))
|
||||
{
|
||||
//Info<< "Creating registry for time " << tm << endl;
|
||||
|
||||
// Create objectRegistry if not found
|
||||
objectRegistry* timeCachePtr = new objectRegistry
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
tm,
|
||||
tm,
|
||||
fieldsCache,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
timeCachePtr->store();
|
||||
}
|
||||
|
||||
// Obtain cache for current time
|
||||
const objectRegistry& timeCache =
|
||||
fieldsCache.lookupObject<objectRegistry>
|
||||
(
|
||||
tm
|
||||
);
|
||||
|
||||
// Store field if not found
|
||||
if (!timeCache.found(fieldName))
|
||||
{
|
||||
//Info<< "Loading field " << fieldName
|
||||
// << " for time " << tm << endl;
|
||||
|
||||
GeoField loadedFld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
tm,
|
||||
mesh.thisDb(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
// Transfer to timeCache (new objectRegistry and store flag)
|
||||
GeoField* fldPtr = new GeoField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
tm,
|
||||
timeCache,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
loadedFld
|
||||
);
|
||||
fldPtr->store();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void Foam::ReadFields
|
||||
(
|
||||
const word& fieldName,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const wordList& timeNames,
|
||||
const word& registryName
|
||||
)
|
||||
{
|
||||
ReadFields<GeoField>
|
||||
(
|
||||
fieldName,
|
||||
mesh,
|
||||
timeNames,
|
||||
const_cast<objectRegistry&>
|
||||
(
|
||||
mesh.thisDb().subRegistry(registryName, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -55,6 +55,28 @@ wordList ReadFields
|
||||
const bool syncPar = true
|
||||
);
|
||||
|
||||
//- Helper routine to read GeometricFields. The fieldsCache is per time
|
||||
// an objectRegistry of all stored fields
|
||||
template<class GeoField>
|
||||
static void ReadFields
|
||||
(
|
||||
const word& fieldName,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const wordList& timeNames,
|
||||
objectRegistry& fieldsCache
|
||||
);
|
||||
|
||||
//- Helper routine to read GeometricFields. The fieldsCache is per time
|
||||
// an objectRegistry of all stored fields
|
||||
template<class GeoField>
|
||||
static void ReadFields
|
||||
(
|
||||
const word& fieldName,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const wordList& timeNames,
|
||||
const word& registryName = "fieldsCache"
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -0,0 +1,121 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "interpolationWeights.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(interpolationWeights, 0);
|
||||
defineRunTimeSelectionTable(interpolationWeights, word);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
interpolationWeights::interpolationWeights
|
||||
(
|
||||
const scalarField& samples
|
||||
)
|
||||
:
|
||||
samples_(samples)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
autoPtr<interpolationWeights> interpolationWeights::New
|
||||
(
|
||||
const word& type,
|
||||
const scalarField& samples
|
||||
)
|
||||
{
|
||||
Info<< nl << "Selecting interpolationWeights "
|
||||
<< type << endl;
|
||||
|
||||
wordConstructorTable::iterator cstrIter =
|
||||
wordConstructorTablePtr_->find(type);
|
||||
|
||||
if (cstrIter == wordConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"interpolationWeights::New(const word&, "
|
||||
"const scalarField&)"
|
||||
) << "Unknown interpolationWeights type "
|
||||
<< type
|
||||
<< endl << endl
|
||||
<< "Valid interpolationWeights types are :" << endl
|
||||
<< wordConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<interpolationWeights>(cstrIter()(samples));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
interpolationWeights::~interpolationWeights()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
//objectRegistry& interpolationWeights::registry
|
||||
//(
|
||||
// const objectRegistry& obr,
|
||||
// const word& name
|
||||
//)
|
||||
//{
|
||||
// if (!obr.foundObject<objectRegistry>(name))
|
||||
// {
|
||||
// objectRegistry* fieldsCachePtr = new objectRegistry
|
||||
// (
|
||||
// IOobject
|
||||
// (
|
||||
// name,
|
||||
// obr.time().constant(),
|
||||
// obr,
|
||||
// IOobject::NO_READ,
|
||||
// IOobject::NO_WRITE
|
||||
// )
|
||||
// );
|
||||
// fieldsCachePtr->store();
|
||||
// }
|
||||
// return const_cast<objectRegistry&>(obr.subRegistry(name));
|
||||
//}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,159 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::interpolationWeights
|
||||
|
||||
Description
|
||||
Abstract base class for interpolating in 1D
|
||||
|
||||
SourceFiles
|
||||
interpolationWeights.C
|
||||
interpolationWeightsTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef interpolationWeights_H
|
||||
#define interpolationWeights_H
|
||||
|
||||
#include "scalarField.H"
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "pointField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class fvMesh;
|
||||
class objectRegistry;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class interpolationWeights Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class interpolationWeights
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
interpolationWeights(const interpolationWeights&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const interpolationWeights&);
|
||||
|
||||
protected:
|
||||
|
||||
const scalarField& samples_;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("interpolationWeights");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
interpolationWeights,
|
||||
word,
|
||||
(
|
||||
const scalarField& samples
|
||||
),
|
||||
(samples)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
interpolationWeights(const scalarField& samples);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected interpolationWeights
|
||||
static autoPtr<interpolationWeights> New
|
||||
(
|
||||
const word& type,
|
||||
const scalarField& samples
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~interpolationWeights();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate weights and indices to calculate t from samples.
|
||||
// Returns true if indices changed.
|
||||
virtual bool valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const = 0;
|
||||
|
||||
//- Calculate weights and indices to calculate integrand of t1..t2
|
||||
// from samples. Returns true if indices changed.
|
||||
virtual bool integrationWeights
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const = 0;
|
||||
|
||||
//- Helper: weighted sum
|
||||
template<class ListType1, class ListType2>
|
||||
static typename outerProduct
|
||||
<
|
||||
typename ListType1::value_type,
|
||||
typename ListType2::value_type
|
||||
>::type
|
||||
weightedSum(const ListType1& f1, const ListType2& f2);
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "interpolationWeightsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,77 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "interpolationWeights.H"
|
||||
#include "ListOps.H"
|
||||
#include "IOobject.H"
|
||||
#include "HashSet.H"
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ListType1, class ListType2>
|
||||
typename Foam::outerProduct
|
||||
<
|
||||
typename ListType1::value_type,
|
||||
typename ListType2::value_type
|
||||
>::type
|
||||
Foam::interpolationWeights::weightedSum
|
||||
(
|
||||
const ListType1& f1,
|
||||
const ListType2& f2
|
||||
)
|
||||
{
|
||||
typedef typename outerProduct
|
||||
<
|
||||
typename ListType1::value_type,
|
||||
typename ListType2::value_type
|
||||
>::type returnType;
|
||||
|
||||
if (f1.size())
|
||||
{
|
||||
returnType SumProd = f1[0]*f2[0];
|
||||
for (label i = 1; i < f1.size(); ++i)
|
||||
{
|
||||
SumProd += f1[i]*f2[i];
|
||||
}
|
||||
return SumProd;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pTraits<returnType>::zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,249 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "linearInterpolationWeights.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "ListOps.H"
|
||||
#include "Pair.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(linearInterpolationWeights, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
interpolationWeights,
|
||||
linearInterpolationWeights,
|
||||
word
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
|
||||
(
|
||||
const label i,
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
// t is in range samples_[i] .. samples_[i+1]
|
||||
|
||||
scalar s = (t-samples_[i])/(samples_[i+1]-samples_[i]);
|
||||
|
||||
if (s < -SMALL || s > 1+SMALL)
|
||||
{
|
||||
FatalErrorIn("linearInterpolationWeights::integrationWeights(..)")
|
||||
<< "Value " << t << " outside range " << samples_[i]
|
||||
<< " .. " << samples_[i+1]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
scalar d = samples_[i+1]-t;
|
||||
|
||||
return Pair<scalar>(d*0.5*(1-s), d*0.5*(1+s));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
linearInterpolationWeights::linearInterpolationWeights
|
||||
(
|
||||
const scalarField& samples
|
||||
)
|
||||
:
|
||||
interpolationWeights(samples),
|
||||
index_(-1)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool linearInterpolationWeights::valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const
|
||||
{
|
||||
bool indexChanged = false;
|
||||
|
||||
// Check if current timeIndex is still valid
|
||||
if
|
||||
(
|
||||
index_ >= 0
|
||||
&& index_ < samples_.size()
|
||||
&& (
|
||||
samples_[index_] <= t
|
||||
&& (index_ == samples_.size()-1 || t <= samples_[index_+1])
|
||||
)
|
||||
)
|
||||
{
|
||||
// index_ still at correct slot
|
||||
}
|
||||
else
|
||||
{
|
||||
// search for correct index
|
||||
index_ = findLower(samples_, t);
|
||||
indexChanged = true;
|
||||
}
|
||||
|
||||
|
||||
if (index_ == -1)
|
||||
{
|
||||
// Use first element only
|
||||
indices.setSize(1);
|
||||
weights.setSize(1);
|
||||
indices[0] = 0;
|
||||
weights[0] = 1.0;
|
||||
}
|
||||
else if (index_ == samples_.size()-1)
|
||||
{
|
||||
// Use last element only
|
||||
indices.setSize(1);
|
||||
weights.setSize(1);
|
||||
indices[0] = samples_.size()-1;
|
||||
weights[0] = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Interpolate
|
||||
indices.setSize(2);
|
||||
weights.setSize(2);
|
||||
|
||||
indices[0] = index_;
|
||||
indices[1] = index_+1;
|
||||
|
||||
scalar t0 = samples_[indices[0]];
|
||||
scalar t1 = samples_[indices[1]];
|
||||
scalar deltaT = t1-t0;
|
||||
|
||||
weights[0] = (t1-t)/deltaT;
|
||||
weights[1] = 1.0-weights[0];
|
||||
}
|
||||
|
||||
return indexChanged;
|
||||
}
|
||||
|
||||
|
||||
bool linearInterpolationWeights::integrationWeights
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const
|
||||
{
|
||||
if (t2 < t1-VSMALL)
|
||||
{
|
||||
FatalErrorIn("linearInterpolationWeights::integrationWeights(..)")
|
||||
<< "Integration should be in positive direction."
|
||||
<< " t1:" << t1 << " t2:" << t2
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Currently no fancy logic on cached index
|
||||
label i1 = findLower(samples_, t1);
|
||||
label i2 = findLower(samples_, t2);
|
||||
|
||||
// For now just fail if any outside table
|
||||
if (i1 == -1 || i2 == samples_.size()-1)
|
||||
{
|
||||
FatalErrorIn("linearInterpolationWeights::integrationWeights(..)")
|
||||
<< "Integrating outside table " << samples_[0] << ".."
|
||||
<< samples_.last() << " not implemented."
|
||||
<< " t1:" << t1 << " t2:" << t2 << exit(FatalError);
|
||||
}
|
||||
|
||||
label nIndices = i2-i1+2;
|
||||
|
||||
|
||||
// Determine if indices already correct
|
||||
bool anyChanged = false;
|
||||
|
||||
if (nIndices != indices.size())
|
||||
{
|
||||
anyChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Closer check
|
||||
|
||||
label index = i1;
|
||||
forAll(indices, i)
|
||||
{
|
||||
if (indices[i] != index)
|
||||
{
|
||||
anyChanged = true;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
indices.setSize(nIndices);
|
||||
weights.setSize(nIndices);
|
||||
weights = 0.0;
|
||||
|
||||
// Sum from i1+1 to i2+1
|
||||
for (label i = i1+1; i <= i2; i++)
|
||||
{
|
||||
scalar d = samples_[i+1]-samples_[i];
|
||||
indices[i-i1] = i;
|
||||
weights[i-i1] += 0.5*d;
|
||||
indices[i+1-i1] = i+1;
|
||||
weights[i+1-i1] += 0.5*d;
|
||||
}
|
||||
|
||||
// Add from i1 to t1
|
||||
{
|
||||
Pair<scalar> i1Tot1 = integrationWeights(i1, t1);
|
||||
indices[0] = i1;
|
||||
weights[0] += i1Tot1.first();
|
||||
indices[1] = i1+1;
|
||||
weights[1] += i1Tot1.second();
|
||||
}
|
||||
|
||||
// Subtract from t2 to i2+1
|
||||
{
|
||||
Pair<scalar> wghts = integrationWeights(i2, t2);
|
||||
indices[i2-i1] = i2;
|
||||
weights[i2-i1] += -wghts.first();
|
||||
indices[i2-i1+1] = i2+1;
|
||||
weights[i2-i1+1] += -wghts.second();
|
||||
}
|
||||
|
||||
return anyChanged;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::linearInterpolationWeights
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
linearInterpolationWeights.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef linearInterpolationWeights_H
|
||||
#define linearInterpolationWeights_H
|
||||
|
||||
#include "interpolationWeights.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class linearInterpolationWeights Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class linearInterpolationWeights
|
||||
:
|
||||
public interpolationWeights
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Cached index in samples from previous invocation
|
||||
mutable label index_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Get weights of i and i+1 to calculate integration from t to
|
||||
// samples_[i+1]
|
||||
Pair<scalar> integrationWeights
|
||||
(
|
||||
const label i,
|
||||
const scalar t
|
||||
) const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("linear");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
linearInterpolationWeights
|
||||
(
|
||||
const scalarField& samples
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~linearInterpolationWeights()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate weights and indices to calculate t from samples.
|
||||
// Returns true if indices changed.
|
||||
virtual bool valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const;
|
||||
|
||||
//- Calculate weights and indices to calculate integrand of t1..t2
|
||||
// from samples. Returns true if indices changed.
|
||||
virtual bool integrationWeights
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,228 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "splineInterpolationWeights.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "ListOps.H"
|
||||
#include "linearInterpolationWeights.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(splineInterpolationWeights, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
interpolationWeights,
|
||||
splineInterpolationWeights,
|
||||
word
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
splineInterpolationWeights::splineInterpolationWeights
|
||||
(
|
||||
const scalarField& samples,
|
||||
const bool checkEqualDistance
|
||||
)
|
||||
:
|
||||
interpolationWeights(samples),
|
||||
index_(-1)
|
||||
{
|
||||
if (checkEqualDistance && samples_.size() > 2)
|
||||
{
|
||||
const scalar interval = samples_[1]-samples[0];
|
||||
for (label i = 2; i < samples_.size(); i++)
|
||||
{
|
||||
scalar d = samples_[i]-samples[i-1];
|
||||
|
||||
if (mag(d-interval) > SMALL)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"splineInterpolationWeights::splineInterpolationWeights"
|
||||
"(const scalarField&)"
|
||||
) << "Spline interpolation only valid for constant intervals."
|
||||
<< nl
|
||||
<< "Interval 0-1 : " << interval << nl
|
||||
<< "Interval " << i-1 << '-' << i << " : "
|
||||
<< d << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool splineInterpolationWeights::valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const
|
||||
{
|
||||
bool indexChanged = false;
|
||||
|
||||
// linear interpolation
|
||||
if (samples_.size() <= 2)
|
||||
{
|
||||
return linearInterpolationWeights(samples_).valueWeights
|
||||
(
|
||||
t,
|
||||
indices,
|
||||
weights
|
||||
);
|
||||
}
|
||||
|
||||
// Check if current timeIndex is still valid
|
||||
if
|
||||
(
|
||||
index_ >= 0
|
||||
&& index_ < samples_.size()
|
||||
&& (
|
||||
samples_[index_] <= t
|
||||
&& (index_ == samples_.size()-1 || t <= samples_[index_+1])
|
||||
)
|
||||
)
|
||||
{
|
||||
// index_ still at correct slot
|
||||
}
|
||||
else
|
||||
{
|
||||
// search for correct index
|
||||
index_ = findLower(samples_, t);
|
||||
indexChanged = true;
|
||||
}
|
||||
|
||||
|
||||
// Clamp if outside table
|
||||
if (index_ == -1)
|
||||
{
|
||||
indices.setSize(1);
|
||||
weights.setSize(1);
|
||||
|
||||
indices[0] = 0;
|
||||
weights[0] = 1;
|
||||
return indexChanged;
|
||||
}
|
||||
else if (index_ == samples_.size()-1)
|
||||
{
|
||||
indices.setSize(1);
|
||||
weights.setSize(1);
|
||||
|
||||
indices[0] = samples_.size()-1;
|
||||
weights[0] = 1;
|
||||
return indexChanged;
|
||||
}
|
||||
|
||||
|
||||
|
||||
label lo = index_;
|
||||
label hi = index_+1;
|
||||
|
||||
// weighting
|
||||
scalar mu = (t - samples_[lo])/(samples_[hi] - samples_[lo]);
|
||||
|
||||
scalar w0 = 0.5*(mu*(-1+mu*(2-mu))); // coeff of lo-1
|
||||
scalar w1 = 0.5*(2+mu*(mu*(-5 + mu*(3)))); // coeff of lo
|
||||
scalar w2 = 0.5*(mu*(1 + mu*(4 + mu*(-3)))); // coeff of hi
|
||||
scalar w3 = 0.5*(mu*mu*(-1 + mu)); // coeff of hi+1
|
||||
|
||||
if (lo > 0)
|
||||
{
|
||||
if (hi < samples_.size()-1)
|
||||
{
|
||||
// Four points available
|
||||
indices.setSize(4);
|
||||
weights.setSize(4);
|
||||
|
||||
indices[0] = lo-1;
|
||||
indices[1] = lo;
|
||||
indices[2] = hi;
|
||||
indices[3] = hi+1;
|
||||
|
||||
weights[0] = w0;
|
||||
weights[1] = w1;
|
||||
weights[2] = w2;
|
||||
weights[3] = w3;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No y3 available. Extrapolate: y3=3*y2-y1
|
||||
indices.setSize(3);
|
||||
weights.setSize(3);
|
||||
|
||||
indices[0] = lo-1;
|
||||
indices[1] = lo;
|
||||
indices[2] = hi;
|
||||
|
||||
weights[0] = w0;
|
||||
weights[1] = w1 - w3;
|
||||
weights[2] = w2 + 2*w3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No y0 available. Extrapolate: y0=2*y1-y2;
|
||||
if (hi < samples_.size()-1)
|
||||
{
|
||||
indices.setSize(3);
|
||||
weights.setSize(3);
|
||||
|
||||
indices[0] = lo;
|
||||
indices[1] = hi;
|
||||
indices[2] = hi+1;
|
||||
|
||||
weights[0] = w1 + 2*w0;
|
||||
weights[1] = w2 - w0;
|
||||
weights[2] = w3;
|
||||
}
|
||||
else
|
||||
{
|
||||
indices.setSize(2);
|
||||
weights.setSize(2);
|
||||
|
||||
indices[0] = lo;
|
||||
indices[1] = hi;
|
||||
|
||||
weights[0] = w1 + 2*w0 - w3;
|
||||
weights[1] = w2 - w0 + 2*w3;
|
||||
}
|
||||
}
|
||||
|
||||
return indexChanged;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,121 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::splineInterpolationWeights
|
||||
|
||||
Description
|
||||
Catmull-Rom spline interpolation.
|
||||
|
||||
SourceFiles
|
||||
splineInterpolationWeights.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef splineInterpolationWeights_H
|
||||
#define splineInterpolationWeights_H
|
||||
|
||||
#include "interpolationWeights.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class splineInterpolationWeights Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class splineInterpolationWeights
|
||||
:
|
||||
public interpolationWeights
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Cached index in samples from previous invocation
|
||||
mutable label index_;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("spline");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components. By default make sure samples are
|
||||
// equidistant.
|
||||
splineInterpolationWeights
|
||||
(
|
||||
const scalarField& samples,
|
||||
const bool checkEqualDistance = true
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~splineInterpolationWeights()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate weights and indices to calculate t from samples.
|
||||
// Returns true if indices changed.
|
||||
virtual bool valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const;
|
||||
|
||||
//- Calculate weights and indices to calculate integrand of t1..t2
|
||||
// from samples. Returns true if indices changed.
|
||||
virtual bool integrationWeights
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2,
|
||||
labelList& indices,
|
||||
scalarField& weights
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"splineInterpolationWeights::integrationWeights(..)"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -180,7 +180,7 @@ bool Foam::mergePoints
|
||||
const bool verbose,
|
||||
labelList& pointMap,
|
||||
List<Type>& newPoints,
|
||||
const Type& origin = Type::zero
|
||||
const Type& origin
|
||||
)
|
||||
{
|
||||
label nUnique = mergePoints
|
||||
|
||||
@ -44,7 +44,7 @@ License
|
||||
defineTypeNameAndDebug(Foam::globalMeshData, 0);
|
||||
|
||||
// Geometric matching tolerance. Factor of mesh bounding box.
|
||||
const Foam::scalar Foam::globalMeshData::matchTol_ = 1E-8;
|
||||
const Foam::scalar Foam::globalMeshData::matchTol_ = 1e-8;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
@ -893,7 +893,7 @@ Foam::polyMesh::cellTree() const
|
||||
|
||||
Random rndGen(261782);
|
||||
|
||||
overallBb = overallBb.extend(rndGen, 1E-4);
|
||||
overallBb = overallBb.extend(rndGen, 1e-4);
|
||||
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -34,7 +34,7 @@ namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(coupledPolyPatch, 0);
|
||||
|
||||
const scalar coupledPolyPatch::defaultMatchTol_ = 1E-4;
|
||||
const scalar coupledPolyPatch::defaultMatchTol_ = 1e-4;
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<coupledPolyPatch::transformType, 4>::names[] =
|
||||
|
||||
@ -26,6 +26,29 @@ License
|
||||
#include "TableBase.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::interpolationWeights& Foam::TableBase<Type>::interpolator() const
|
||||
{
|
||||
if (interpolatorPtr_.empty())
|
||||
{
|
||||
// Re-work table into linear list
|
||||
tableSamples_.setSize(table_.size());
|
||||
forAll(table_, i)
|
||||
{
|
||||
tableSamples_[i] = table_[i].first();
|
||||
}
|
||||
interpolatorPtr_ = interpolationWeights::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
tableSamples_
|
||||
);
|
||||
}
|
||||
return interpolatorPtr_();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -39,6 +62,10 @@ Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict)
|
||||
dict.lookupOrDefault<word>("outOfBounds", "clamp")
|
||||
)
|
||||
),
|
||||
interpolationScheme_
|
||||
(
|
||||
dict.lookupOrDefault<word>("interpolationScheme", "linear")
|
||||
),
|
||||
table_(),
|
||||
dimensions_(dimless)
|
||||
{}
|
||||
@ -49,8 +76,11 @@ Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
|
||||
:
|
||||
name_(tbl.name_),
|
||||
boundsHandling_(tbl.boundsHandling_),
|
||||
interpolationScheme_(tbl.interpolationScheme_),
|
||||
table_(tbl.table_),
|
||||
dimensions_(tbl.dimensions_)
|
||||
dimensions_(tbl.dimensions_),
|
||||
tableSamples_(tbl.tableSamples_),
|
||||
interpolatorPtr_(tbl.interpolatorPtr_)
|
||||
{}
|
||||
|
||||
|
||||
@ -307,6 +337,9 @@ void Foam::TableBase<Type>::convertTimeBase(const Time& t)
|
||||
scalar value = table_[i].first();
|
||||
table_[i].first() = t.userTimeToTime(value);
|
||||
}
|
||||
|
||||
tableSamples_.clear();
|
||||
interpolatorPtr_.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -325,88 +358,104 @@ Type Foam::TableBase<Type>::value(const scalar x) const
|
||||
return table_.last().second();
|
||||
}
|
||||
|
||||
// Find i such that x(i) < xDash < x(i+1)
|
||||
label i = 0;
|
||||
while ((table_[i+1].first() < xDash) && (i+1 < table_.size()))
|
||||
// Use interpolator
|
||||
interpolator().valueWeights(x, currentIndices_, currentWeights_);
|
||||
|
||||
Type t = currentWeights_[0]*table_[currentIndices_[0]].second();
|
||||
for (label i = 1; i < currentIndices_.size(); i++)
|
||||
{
|
||||
i++;
|
||||
t += currentWeights_[i]*table_[currentIndices_[i]].second();
|
||||
}
|
||||
return t;
|
||||
|
||||
Info <<
|
||||
(xDash - table_[i].first())/(table_[i+1].first() - table_[i].first())
|
||||
* (table_[i+1].second() - table_[i].second())
|
||||
+ table_[i].second() << endl;
|
||||
|
||||
// Linear interpolation to find value
|
||||
return Type
|
||||
(
|
||||
(xDash - table_[i].first())/(table_[i+1].first() - table_[i].first())
|
||||
* (table_[i+1].second() - table_[i].second())
|
||||
+ table_[i].second()
|
||||
);
|
||||
//// Find i such that x(i) < xDash < x(i+1)
|
||||
//label i = 0;
|
||||
//while ((table_[i+1].first() < xDash) && (i+1 < table_.size()))
|
||||
//{
|
||||
// i++;
|
||||
//}
|
||||
//
|
||||
//// Linear interpolation to find value
|
||||
//return Type
|
||||
//(
|
||||
// (xDash - table_[i].first())/(table_[i+1].first() - table_[i].first())
|
||||
// * (table_[i+1].second() - table_[i].second())
|
||||
// + table_[i].second()
|
||||
//);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::TableBase<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
{
|
||||
// Initialise return value
|
||||
Type sum = pTraits<Type>::zero;
|
||||
// Use interpolator
|
||||
interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
|
||||
|
||||
// Return zero if out of bounds
|
||||
if ((x1 > table_.last().first()) || (x2 < table_[0].first()))
|
||||
Type sum = currentWeights_[0]*table_[currentIndices_[0]].second();
|
||||
for (label i = 1; i < currentIndices_.size(); i++)
|
||||
{
|
||||
return sum;
|
||||
sum += currentWeights_[i]*table_[currentIndices_[i]].second();
|
||||
}
|
||||
|
||||
// Find next index greater than x1
|
||||
label id1 = 0;
|
||||
while ((table_[id1].first() < x1) && (id1 < table_.size()))
|
||||
{
|
||||
id1++;
|
||||
}
|
||||
|
||||
// Find next index less than x2
|
||||
label id2 = table_.size() - 1;
|
||||
while ((table_[id2].first() > x2) && (id2 >= 1))
|
||||
{
|
||||
id2--;
|
||||
}
|
||||
|
||||
if ((id1 - id2) == 1)
|
||||
{
|
||||
// x1 and x2 lie within 1 interval
|
||||
sum = 0.5*(value(x1) + value(x2))*(x2 - x1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// x1 and x2 cross multiple intervals
|
||||
|
||||
// Integrate table body
|
||||
for (label i=id1; i<id2; i++)
|
||||
{
|
||||
sum +=
|
||||
(table_[i].second() + table_[i+1].second())
|
||||
* (table_[i+1].first() - table_[i].first());
|
||||
}
|
||||
sum *= 0.5;
|
||||
|
||||
// Add table ends (partial segments)
|
||||
if (id1 > 0)
|
||||
{
|
||||
sum += 0.5
|
||||
* (value(x1) + table_[id1].second())
|
||||
* (table_[id1].first() - x1);
|
||||
}
|
||||
if (id2 < table_.size() - 1)
|
||||
{
|
||||
sum += 0.5
|
||||
* (table_[id2].second() + value(x2))
|
||||
* (x2 - table_[id2].first());
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
|
||||
|
||||
//// Initialise return value
|
||||
//Type sum = pTraits<Type>::zero;
|
||||
//
|
||||
//// Return zero if out of bounds
|
||||
//if ((x1 > table_.last().first()) || (x2 < table_[0].first()))
|
||||
//{
|
||||
// return sum;
|
||||
//}
|
||||
//
|
||||
//// Find next index greater than x1
|
||||
//label id1 = 0;
|
||||
//while ((table_[id1].first() < x1) && (id1 < table_.size()))
|
||||
//{
|
||||
// id1++;
|
||||
//}
|
||||
//
|
||||
//// Find next index less than x2
|
||||
//label id2 = table_.size() - 1;
|
||||
//while ((table_[id2].first() > x2) && (id2 >= 1))
|
||||
//{
|
||||
// id2--;
|
||||
//}
|
||||
//
|
||||
//if ((id1 - id2) == 1)
|
||||
//{
|
||||
// // x1 and x2 lie within 1 interval
|
||||
// sum = 0.5*(value(x1) + value(x2))*(x2 - x1);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// // x1 and x2 cross multiple intervals
|
||||
//
|
||||
// // Integrate table body
|
||||
// for (label i=id1; i<id2; i++)
|
||||
// {
|
||||
// sum +=
|
||||
// (table_[i].second() + table_[i+1].second())
|
||||
// * (table_[i+1].first() - table_[i].first());
|
||||
// }
|
||||
// sum *= 0.5;
|
||||
//
|
||||
// // Add table ends (partial segments)
|
||||
// if (id1 > 0)
|
||||
// {
|
||||
// sum += 0.5
|
||||
// * (value(x1) + table_[id1].second())
|
||||
// * (table_[id1].first() - x1);
|
||||
// }
|
||||
// if (id2 < table_.size() - 1)
|
||||
// {
|
||||
// sum += 0.5
|
||||
// * (table_[id2].second() + value(x2))
|
||||
// * (x2 - table_[id2].first());
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//return sum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
#include "DataEntry.H"
|
||||
#include "Tuple2.H"
|
||||
#include "dimensionSet.H"
|
||||
#include "interpolationWeights.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -80,10 +81,13 @@ protected:
|
||||
// Protected data
|
||||
|
||||
//- Table name
|
||||
word name_;
|
||||
const word name_;
|
||||
|
||||
//- Enumeration for handling out-of-bound values
|
||||
boundsHandling boundsHandling_;
|
||||
const boundsHandling boundsHandling_;
|
||||
|
||||
//- Interpolation type
|
||||
const word interpolationScheme_;
|
||||
|
||||
//- Table data
|
||||
List<Tuple2<scalar, Type> > table_;
|
||||
@ -91,9 +95,24 @@ protected:
|
||||
//- The dimension set
|
||||
dimensionSet dimensions_;
|
||||
|
||||
//- Extracted values
|
||||
mutable scalarField tableSamples_;
|
||||
|
||||
//- Interpolator method
|
||||
mutable autoPtr<interpolationWeights> interpolatorPtr_;
|
||||
|
||||
//- Cached indices and weights
|
||||
mutable labelList currentIndices_;
|
||||
|
||||
mutable scalarField currentWeights_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
|
||||
//- Return (demand driven) interpolator
|
||||
const interpolationWeights& interpolator() const;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const TableBase<Type>&);
|
||||
|
||||
|
||||
@ -45,6 +45,15 @@ Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict)
|
||||
fileName expandedFile(fName_);
|
||||
IFstream is(expandedFile.expand());
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"TableFile<Type>::TableFile(const word&, const dictionary&)",
|
||||
is
|
||||
) << "Cannot open file." << exit(FatalIOError);
|
||||
}
|
||||
|
||||
is >> this->table_;
|
||||
|
||||
TableBase<Type>::check();
|
||||
|
||||
@ -31,9 +31,10 @@ Description
|
||||
<entryName> tableFile;
|
||||
tableFileCoeffs
|
||||
{
|
||||
dimensions [0 0 1 0 0]; // optional dimensions
|
||||
fileName dataFile; // name of data file
|
||||
outOfBounds clamp; // optional out-of-bounds handling
|
||||
dimensions [0 0 1 0 0]; // optional dimensions
|
||||
fileName dataFile; // name of data file
|
||||
outOfBounds clamp; // optional out-of-bounds handling
|
||||
interpolationScheme linear; // optional interpolation method
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -48,7 +48,7 @@ Description
|
||||
release.
|
||||
|
||||
If the turbulent fluctuation of the mixture fraction at the sub-grid level
|
||||
is large (>1E-04) then a beta pdf is used for filtering.
|
||||
is large (>1e-04) then a beta pdf is used for filtering.
|
||||
|
||||
At the moment the flame area combustion model is only fit to work in a LES
|
||||
frame work. In RAS the subgrid fluctiuation has to be solved by an extra
|
||||
|
||||
@ -240,10 +240,15 @@ Foam::dynamicRefineFvMesh::refine
|
||||
}
|
||||
}
|
||||
|
||||
// // Remove the stored tet base points
|
||||
// tetBasePtIsPtr_.clear();
|
||||
// // Remove the cell tree
|
||||
// cellTreePtr_.clear();
|
||||
|
||||
// Update fields
|
||||
updateMesh(map);
|
||||
|
||||
|
||||
// Move mesh
|
||||
/*
|
||||
pointField newPoints;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -43,7 +43,7 @@ defineTypeNameAndDebug(Foam::boundaryMesh, 0);
|
||||
const Foam::vector Foam::boundaryMesh::splitNormal_(3, 2, 1);
|
||||
|
||||
// Distance to face tolerance for getNearest
|
||||
const Foam::scalar Foam::boundaryMesh::distanceTol_ = 1E-2;
|
||||
const Foam::scalar Foam::boundaryMesh::distanceTol_ = 1e-2;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -871,11 +871,11 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
||||
{
|
||||
scalar sign = mesh().faceNormals()[bFaceI] & splitNormal_;
|
||||
|
||||
if (sign > -1E-5)
|
||||
if (sign > -1e-5)
|
||||
{
|
||||
rightFaces.append(bFaceI);
|
||||
}
|
||||
if (sign < 1E-5)
|
||||
if (sign < 1e-5)
|
||||
{
|
||||
leftFaces.append(bFaceI);
|
||||
}
|
||||
@ -909,7 +909,7 @@ Foam::labelList Foam::boundaryMesh::getNearest
|
||||
|
||||
// Extend domain slightly (also makes it 3D if was 2D)
|
||||
// Note asymmetry to avoid having faces align with octree cubes.
|
||||
scalar tol = 1E-6 * overallBb.avgDim();
|
||||
scalar tol = 1e-6 * overallBb.avgDim();
|
||||
|
||||
point& bbMin = overallBb.min();
|
||||
bbMin.x() -= tol;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,7 +39,7 @@ License
|
||||
|
||||
// Extension factor of edges to make sure we catch intersections through
|
||||
// edge endpoints
|
||||
const Foam::scalar Foam::geomCellLooper::pointEqualTol_ = 1E-3;
|
||||
const Foam::scalar Foam::geomCellLooper::pointEqualTol_ = 1e-3;
|
||||
|
||||
|
||||
// Snap cuts through edges onto edge endpoints. Fraction of edge length.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -125,7 +125,7 @@ void Foam::directions::check2D
|
||||
{
|
||||
if (correct2DPtr)
|
||||
{
|
||||
if (mag(correct2DPtr->planeNormal() & vec) > 1E-6)
|
||||
if (mag(correct2DPtr->planeNormal() & vec) > 1e-6)
|
||||
{
|
||||
FatalErrorIn("check2D") << "Specified vector " << vec
|
||||
<< "is not normal to plane defined in dynamicMeshDict."
|
||||
|
||||
@ -900,7 +900,7 @@ Foam::tmp<Foam::scalarField> Foam::motionSmoother::movePoints
|
||||
{
|
||||
Pout<< "motionSmoother::movePoints : testing sync of newPoints."
|
||||
<< endl;
|
||||
testSyncPositions(newPoints, 1E-6*mesh_.bounds().mag());
|
||||
testSyncPositions(newPoints, 1e-6*mesh_.bounds().mag());
|
||||
}
|
||||
|
||||
// Move actual mesh points. Make sure to delete tetBasePtIs so it
|
||||
@ -1051,7 +1051,7 @@ bool Foam::motionSmoother::scaleMesh
|
||||
totalDisplacement,
|
||||
maxMagEqOp(),
|
||||
vector::zero, // null value
|
||||
1E-6*mesh_.bounds().mag()
|
||||
1e-6*mesh_.bounds().mag()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,7 +54,7 @@ namespace Foam
|
||||
|
||||
|
||||
// Tolerance used as fraction of minimum edge length.
|
||||
const Foam::scalar Foam::perfectInterface::tol_ = 1E-3;
|
||||
const Foam::scalar Foam::perfectInterface::tol_ = 1e-3;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,7 +36,7 @@ License
|
||||
|
||||
defineTypeNameAndDebug(Foam::faceCoupleInfo, 0);
|
||||
|
||||
const Foam::scalar Foam::faceCoupleInfo::angleTol_ = 1E-3;
|
||||
const Foam::scalar Foam::faceCoupleInfo::angleTol_ = 1e-3;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -1014,7 +1014,7 @@ void Foam::faceCoupleInfo::findSlavesCoveringMaster
|
||||
mesh0,
|
||||
bndFaces // boundary faces only
|
||||
),
|
||||
overallBb.extend(rndGen, 1E-4), // overall search domain
|
||||
overallBb.extend(rndGen, 1e-4), // overall search domain
|
||||
8, // maxLevel
|
||||
10, // leafsize
|
||||
3.0 // duplicity
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -277,7 +277,7 @@ void Foam::faceCollapser::setRefinement
|
||||
if (w <= dist[fpMin1])
|
||||
{
|
||||
// Offset.
|
||||
w = dist[fpMin1] + 1E-6*(dist[fpB] - dist[fpA]);
|
||||
w = dist[fpMin1] + 1e-6*(dist[fpB] - dist[fpA]);
|
||||
|
||||
point newPoint
|
||||
(
|
||||
@ -330,7 +330,7 @@ void Foam::faceCollapser::setRefinement
|
||||
if (w <= dist[fpMin1])
|
||||
{
|
||||
// Offset.
|
||||
w = dist[fpMin1] + 1E-6*(dist[fpB] - dist[fpA]);
|
||||
w = dist[fpMin1] + 1e-6*(dist[fpB] - dist[fpA]);
|
||||
|
||||
point newPoint
|
||||
(
|
||||
|
||||
@ -4452,7 +4452,7 @@ void Foam::hexRef8::distribute(const mapDistributePolyMesh& map)
|
||||
|
||||
void Foam::hexRef8::checkMesh() const
|
||||
{
|
||||
const scalar smallDim = 1E-6 * mesh_.bounds().mag();
|
||||
const scalar smallDim = 1e-6 * mesh_.bounds().mag();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -923,7 +923,7 @@ Foam::extendedFeatureEdgeMesh::pointTree() const
|
||||
// geometry there are less face/edge aligned items.
|
||||
treeBoundBox bb
|
||||
(
|
||||
treeBoundBox(points()).extend(rndGen, 1E-4)
|
||||
treeBoundBox(points()).extend(rndGen, 1e-4)
|
||||
);
|
||||
|
||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
@ -963,7 +963,7 @@ Foam::extendedFeatureEdgeMesh::edgeTree() const
|
||||
// geometry there are less face/edge aligned items.
|
||||
treeBoundBox bb
|
||||
(
|
||||
treeBoundBox(points()).extend(rndGen, 1E-4)
|
||||
treeBoundBox(points()).extend(rndGen, 1e-4)
|
||||
);
|
||||
|
||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
@ -1007,7 +1007,7 @@ Foam::extendedFeatureEdgeMesh::edgeTreesByType() const
|
||||
// geometry there are less face/edge aligned items.
|
||||
treeBoundBox bb
|
||||
(
|
||||
treeBoundBox(points()).extend(rndGen, 1E-4)
|
||||
treeBoundBox(points()).extend(rndGen, 1e-4)
|
||||
);
|
||||
|
||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
@ -628,7 +628,7 @@ void Foam::rotorDiskSource::addSup(fvMatrix<vector>& eqn, const label fieldI)
|
||||
|
||||
const volVectorField& U = eqn.psi();
|
||||
|
||||
const vectorField Uin = inflowVelocity(U);
|
||||
const vectorField Uin(inflowVelocity(U));
|
||||
|
||||
trim_->correct(Uin, force);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -38,9 +38,10 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
fixedGradientFvPatchScalarField(p, iF),
|
||||
UName_("U"),
|
||||
phiHbyAName_("phiHbyA"),
|
||||
phiName_("phi"),
|
||||
rhoName_("rho"),
|
||||
DpName_("Dp"),
|
||||
adjoint_(false)
|
||||
{}
|
||||
|
||||
@ -54,9 +55,10 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
|
||||
UName_(ptf.UName_),
|
||||
phiHbyAName_(ptf.phiHbyAName_),
|
||||
phiName_(ptf.phiName_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
DpName_(ptf.rhoName_),
|
||||
adjoint_(ptf.adjoint_)
|
||||
{}
|
||||
|
||||
@ -69,10 +71,11 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
fixedGradientFvPatchScalarField(p, iF),
|
||||
UName_(dict.lookupOrDefault<word>("U", "U")),
|
||||
phiHbyAName_(dict.lookupOrDefault<word>("phiHbyA", "phiHbyA")),
|
||||
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
|
||||
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
|
||||
adjoint_(dict.lookup("adjoint"))
|
||||
DpName_(dict.lookupOrDefault<word>("Dp", "Dp")),
|
||||
adjoint_(dict.lookupOrDefault<Switch>("adjoint", false))
|
||||
{
|
||||
if (dict.found("gradient"))
|
||||
{
|
||||
@ -94,9 +97,10 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
fixedGradientFvPatchScalarField(wbppsf),
|
||||
UName_(wbppsf.UName_),
|
||||
phiHbyAName_(wbppsf.phiHbyAName_),
|
||||
phiName_(wbppsf.phiName_),
|
||||
rhoName_(wbppsf.rhoName_),
|
||||
DpName_(wbppsf.DpName_),
|
||||
adjoint_(wbppsf.adjoint_)
|
||||
{}
|
||||
|
||||
@ -108,9 +112,10 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
fixedGradientFvPatchScalarField(wbppsf, iF),
|
||||
UName_(wbppsf.UName_),
|
||||
phiHbyAName_(wbppsf.phiHbyAName_),
|
||||
phiName_(wbppsf.phiName_),
|
||||
rhoName_(wbppsf.rhoName_),
|
||||
DpName_(wbppsf.DpName_),
|
||||
adjoint_(wbppsf.adjoint_)
|
||||
{}
|
||||
|
||||
@ -124,15 +129,19 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
const fvPatchField<vector>& Up =
|
||||
patch().lookupPatchField<volVectorField, vector>(UName_);
|
||||
const surfaceScalarField& phiHbyA =
|
||||
db().lookupObject<surfaceScalarField>(phiHbyAName_);
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
db().lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
fvsPatchField<scalar> phiHbyAp =
|
||||
patch().patchField<surfaceScalarField, scalar>(phiHbyA);
|
||||
|
||||
fvsPatchField<scalar> phip =
|
||||
patch().patchField<surfaceScalarField, scalar>(phi);
|
||||
|
||||
/*
|
||||
if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
|
||||
{
|
||||
const fvPatchField<scalar>& rhop =
|
||||
@ -141,16 +150,38 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs()
|
||||
phip /= rhop;
|
||||
}
|
||||
|
||||
const fvPatchField<scalar>& rAp =
|
||||
patch().lookupPatchField<volScalarField, scalar>("(1|A("+UName_+"))");
|
||||
if (phiHbyA.dimensions() == dimDensity*dimVelocity*dimArea)
|
||||
{
|
||||
const fvPatchField<scalar>& rhop =
|
||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
||||
|
||||
phiHbyAp /= rhop;
|
||||
}
|
||||
*/
|
||||
|
||||
const scalarField *DppPtr = NULL;
|
||||
|
||||
if (db().foundObject<volScalarField>(DpName_))
|
||||
{
|
||||
DppPtr =
|
||||
&patch().lookupPatchField<volScalarField, scalar>(DpName_);
|
||||
}
|
||||
else if (db().foundObject<surfaceScalarField>(DpName_))
|
||||
{
|
||||
const surfaceScalarField& Dp =
|
||||
db().lookupObject<surfaceScalarField>(DpName_);
|
||||
|
||||
DppPtr =
|
||||
&patch().patchField<surfaceScalarField, scalar>(Dp);
|
||||
}
|
||||
|
||||
if (adjoint_)
|
||||
{
|
||||
gradient() = ((patch().Sf() & Up) - phip)/patch().magSf()/rAp;
|
||||
gradient() = (phip - phiHbyAp)/patch().magSf()/(*DppPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
gradient() = (phip - (patch().Sf() & Up))/patch().magSf()/rAp;
|
||||
gradient() = (phiHbyAp - phip)/patch().magSf()/(*DppPtr);
|
||||
}
|
||||
|
||||
fixedGradientFvPatchScalarField::updateCoeffs();
|
||||
@ -160,9 +191,10 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs()
|
||||
void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
writeEntryIfDifferent<word>(os, "U", "U", UName_);
|
||||
writeEntryIfDifferent<word>(os, "phiHbyA", "phiHbyA", phiHbyAName_);
|
||||
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
|
||||
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
|
||||
writeEntryIfDifferent<word>(os, "Dp", "Dp", rhoName_);
|
||||
os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl;
|
||||
gradient().writeEntry("gradient", os);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,14 @@ Class
|
||||
Foam::fixedFluxPressureFvPatchScalarField
|
||||
|
||||
Description
|
||||
Foam::fixedFluxPressureFvPatchScalarField
|
||||
Adjusts the pressure gradient such that the flux on the boundary is that
|
||||
specified by the velocity boundary condition.
|
||||
|
||||
The predicted flux to be compensated by the pressure gradient is evaluated
|
||||
as (phi - phiHbyA), both of which are looked-up from the database as is
|
||||
the pressure diffusivity Dp used to calculate the gradient.
|
||||
|
||||
The names of the phi, phiHbyA and Dp fields may be optionally specified.
|
||||
|
||||
SourceFiles
|
||||
fixedFluxPressureFvPatchScalarField.C
|
||||
@ -54,8 +61,8 @@ class fixedFluxPressureFvPatchScalarField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of the velocity field
|
||||
word UName_;
|
||||
//- Name of the predicted flux transporting the field
|
||||
word phiHbyAName_;
|
||||
|
||||
//- Name of the flux transporting the field
|
||||
word phiName_;
|
||||
@ -64,6 +71,9 @@ class fixedFluxPressureFvPatchScalarField
|
||||
// if neccessary
|
||||
word rhoName_;
|
||||
|
||||
//- Name of the pressure diffusivity field
|
||||
word DpName_;
|
||||
|
||||
//- Is the pressure adjoint, i.e. has the opposite sign
|
||||
Switch adjoint_;
|
||||
|
||||
|
||||
@ -136,6 +136,7 @@ void Foam::multiphaseFixedFluxPressureFvPatchScalarField::updateCoeffs()
|
||||
fvsPatchField<scalar> phip =
|
||||
patch().patchField<surfaceScalarField, scalar>(phi);
|
||||
|
||||
/*
|
||||
if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
|
||||
{
|
||||
const fvPatchField<scalar>& rhop =
|
||||
@ -144,6 +145,15 @@ void Foam::multiphaseFixedFluxPressureFvPatchScalarField::updateCoeffs()
|
||||
phip /= rhop;
|
||||
}
|
||||
|
||||
if (phiHbyA.dimensions() == dimDensity*dimVelocity*dimArea)
|
||||
{
|
||||
const fvPatchField<scalar>& rhop =
|
||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
||||
|
||||
phiHbyAp /= rhop;
|
||||
}
|
||||
*/
|
||||
|
||||
const fvsPatchField<scalar>& Dpp =
|
||||
patch().lookupPatchField<surfaceScalarField, scalar>("Dp");
|
||||
|
||||
|
||||
@ -25,7 +25,14 @@ Class
|
||||
Foam::multiphaseFixedFluxPressureFvPatchScalarField
|
||||
|
||||
Description
|
||||
Foam::multiphaseFixedFluxPressureFvPatchScalarField
|
||||
Adjusts the pressure gradient such that the flux on the boundary is that
|
||||
specified by the velocity boundary condition.
|
||||
|
||||
The predicted flux to be compensated by the pressure gradient is evaluated
|
||||
as (phi - phiHbyA), both of which are looked-up from the database as is
|
||||
the pressure diffusivity Dp used to calculate the gradient.
|
||||
|
||||
The names of the phi, phiHbyA and Dp fields may be optionally specified.
|
||||
|
||||
SourceFiles
|
||||
multiphaseFixedFluxPressureFvPatchScalarField.C
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,12 +25,7 @@ License
|
||||
|
||||
#include "timeVaryingMappedFixedValueFvPatchField.H"
|
||||
#include "Time.H"
|
||||
#include "triSurfaceTools.H"
|
||||
#include "triSurface.H"
|
||||
#include "vector2D.H"
|
||||
#include "OFstream.H"
|
||||
#include "AverageIOField.H"
|
||||
#include "Random.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,9 +46,6 @@ timeVaryingMappedFixedValueFvPatchField
|
||||
fieldTableName_(iF.name()),
|
||||
setAverage_(false),
|
||||
perturb_(0),
|
||||
referenceCS_(NULL),
|
||||
nearestVertex_(0),
|
||||
nearestVertexWeight_(0),
|
||||
sampleTimes_(0),
|
||||
startSampleTime_(-1),
|
||||
startSampledValues_(0),
|
||||
@ -78,9 +70,7 @@ timeVaryingMappedFixedValueFvPatchField
|
||||
fieldTableName_(ptf.fieldTableName_),
|
||||
setAverage_(ptf.setAverage_),
|
||||
perturb_(ptf.perturb_),
|
||||
referenceCS_(NULL),
|
||||
nearestVertex_(0),
|
||||
nearestVertexWeight_(0),
|
||||
mapperPtr_(ptf.mapperPtr_),
|
||||
sampleTimes_(0),
|
||||
startSampleTime_(-1),
|
||||
startSampledValues_(0),
|
||||
@ -103,10 +93,8 @@ timeVaryingMappedFixedValueFvPatchField
|
||||
fixedValueFvPatchField<Type>(p, iF),
|
||||
fieldTableName_(iF.name()),
|
||||
setAverage_(readBool(dict.lookup("setAverage"))),
|
||||
perturb_(dict.lookupOrDefault("perturb", 1E-5)),
|
||||
referenceCS_(NULL),
|
||||
nearestVertex_(0),
|
||||
nearestVertexWeight_(0),
|
||||
perturb_(dict.lookupOrDefault("perturb", 1e-5)),
|
||||
mapperPtr_(NULL),
|
||||
sampleTimes_(0),
|
||||
startSampleTime_(-1),
|
||||
startSampledValues_(0),
|
||||
@ -139,9 +127,7 @@ timeVaryingMappedFixedValueFvPatchField
|
||||
fieldTableName_(ptf.fieldTableName_),
|
||||
setAverage_(ptf.setAverage_),
|
||||
perturb_(ptf.perturb_),
|
||||
referenceCS_(ptf.referenceCS_),
|
||||
nearestVertex_(ptf.nearestVertex_),
|
||||
nearestVertexWeight_(ptf.nearestVertexWeight_),
|
||||
mapperPtr_(ptf.mapperPtr_),
|
||||
sampleTimes_(ptf.sampleTimes_),
|
||||
startSampleTime_(ptf.startSampleTime_),
|
||||
startSampledValues_(ptf.startSampledValues_),
|
||||
@ -165,9 +151,7 @@ timeVaryingMappedFixedValueFvPatchField
|
||||
fieldTableName_(ptf.fieldTableName_),
|
||||
setAverage_(ptf.setAverage_),
|
||||
perturb_(ptf.perturb_),
|
||||
referenceCS_(ptf.referenceCS_),
|
||||
nearestVertex_(ptf.nearestVertex_),
|
||||
nearestVertexWeight_(ptf.nearestVertexWeight_),
|
||||
mapperPtr_(ptf.mapperPtr_),
|
||||
sampleTimes_(ptf.sampleTimes_),
|
||||
startSampleTime_(ptf.startSampleTime_),
|
||||
startSampledValues_(ptf.startSampledValues_),
|
||||
@ -192,6 +176,10 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::autoMap
|
||||
startSampledValues_.autoMap(m);
|
||||
endSampledValues_.autoMap(m);
|
||||
}
|
||||
// Clear interpolator
|
||||
mapperPtr_.clear();
|
||||
startSampleTime_ = -1;
|
||||
endSampleTime_ = -1;
|
||||
}
|
||||
|
||||
|
||||
@ -209,295 +197,11 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::rmap
|
||||
|
||||
startSampledValues_.rmap(tiptf.startSampledValues_, addr);
|
||||
endSampledValues_.rmap(tiptf.endSampledValues_, addr);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
|
||||
{
|
||||
// Read the sample points
|
||||
|
||||
pointIOField samplePoints
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
this->db().time().constant(),
|
||||
"boundaryData"/this->patch().name(),
|
||||
this->db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
const fileName samplePointsFile = samplePoints.filePath();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "timeVaryingMappedFixedValueFvPatchField :"
|
||||
<< " Read " << samplePoints.size() << " sample points from "
|
||||
<< samplePointsFile << endl;
|
||||
}
|
||||
|
||||
// Determine coordinate system from samplePoints
|
||||
|
||||
if (samplePoints.size() < 3)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()"
|
||||
) << "Only " << samplePoints.size() << " points read from file "
|
||||
<< samplePoints.objectPath() << nl
|
||||
<< "Need at least three non-colinear samplePoints"
|
||||
<< " to be able to interpolate."
|
||||
<< "\n on patch " << this->patch().name()
|
||||
<< " of points " << samplePoints.name()
|
||||
<< " in file " << samplePoints.objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const point& p0 = samplePoints[0];
|
||||
|
||||
// Find furthest away point
|
||||
vector e1;
|
||||
label index1 = -1;
|
||||
scalar maxDist = -GREAT;
|
||||
|
||||
for (label i = 1; i < samplePoints.size(); i++)
|
||||
{
|
||||
const vector d = samplePoints[i] - p0;
|
||||
scalar magD = mag(d);
|
||||
|
||||
if (magD > maxDist)
|
||||
{
|
||||
e1 = d/magD;
|
||||
index1 = i;
|
||||
maxDist = magD;
|
||||
}
|
||||
}
|
||||
// Find point that is furthest away from line p0-p1
|
||||
const point& p1 = samplePoints[index1];
|
||||
|
||||
label index2 = -1;
|
||||
maxDist = -GREAT;
|
||||
for (label i = 1; i < samplePoints.size(); i++)
|
||||
{
|
||||
if (i != index1)
|
||||
{
|
||||
const point& p2 = samplePoints[i];
|
||||
vector e2(p2 - p0);
|
||||
e2 -= (e2&e1)*e1;
|
||||
scalar magE2 = mag(e2);
|
||||
|
||||
if (magE2 > maxDist)
|
||||
{
|
||||
index2 = i;
|
||||
maxDist = magE2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index2 == -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()"
|
||||
) << "Cannot find points that make valid normal." << nl
|
||||
<< "Have so far points " << p0 << " and " << p1
|
||||
<< "Need at least three sample points which are not in a line."
|
||||
<< "\n on patch " << this->patch().name()
|
||||
<< " of points " << samplePoints.name()
|
||||
<< " in file " << samplePoints.objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
vector n = e1^(samplePoints[index2]-p0);
|
||||
n /= mag(n);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "timeVaryingMappedFixedValueFvPatchField :"
|
||||
<< " Used points " << p0 << ' ' << samplePoints[index1]
|
||||
<< ' ' << samplePoints[index2]
|
||||
<< " to define coordinate system with normal " << n << endl;
|
||||
}
|
||||
|
||||
referenceCS_.reset
|
||||
(
|
||||
new coordinateSystem
|
||||
(
|
||||
"reference",
|
||||
p0, // origin
|
||||
n, // normal
|
||||
e1 // 0-axis
|
||||
)
|
||||
);
|
||||
|
||||
tmp<vectorField> tlocalVertices
|
||||
(
|
||||
referenceCS().localPosition(samplePoints)
|
||||
);
|
||||
vectorField& localVertices = tlocalVertices();
|
||||
|
||||
const boundBox bb(localVertices, true);
|
||||
const point bbMid(bb.midpoint());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "timeVaryingMappedFixedValueFvPatchField :"
|
||||
<< " Perturbing points with " << perturb_
|
||||
<< " fraction of a random position inside " << bb
|
||||
<< " to break any ties on regular meshes."
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
Random rndGen(123456);
|
||||
forAll(localVertices, i)
|
||||
{
|
||||
localVertices[i] +=
|
||||
perturb_
|
||||
*(rndGen.position(bb.min(), bb.max())-bbMid);
|
||||
}
|
||||
|
||||
// Determine triangulation
|
||||
List<vector2D> localVertices2D(localVertices.size());
|
||||
forAll(localVertices, i)
|
||||
{
|
||||
localVertices2D[i][0] = localVertices[i][0];
|
||||
localVertices2D[i][1] = localVertices[i][1];
|
||||
}
|
||||
|
||||
triSurface s(triSurfaceTools::delaunay2D(localVertices2D));
|
||||
|
||||
tmp<pointField> tlocalFaceCentres
|
||||
(
|
||||
referenceCS().localPosition
|
||||
(
|
||||
this->patch().patch().faceCentres()
|
||||
)
|
||||
);
|
||||
const pointField& localFaceCentres = tlocalFaceCentres();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "readSamplePoints :"
|
||||
<<" Dumping triangulated surface to triangulation.stl" << endl;
|
||||
s.write(this->db().time().path()/"triangulation.stl");
|
||||
|
||||
OFstream str(this->db().time().path()/"localFaceCentres.obj");
|
||||
Pout<< "readSamplePoints :"
|
||||
<< " Dumping face centres to " << str.name() << endl;
|
||||
|
||||
forAll(localFaceCentres, i)
|
||||
{
|
||||
const point& p = localFaceCentres[i];
|
||||
str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine interpolation onto face centres.
|
||||
triSurfaceTools::calcInterpolationWeights
|
||||
(
|
||||
s,
|
||||
localFaceCentres, // points to interpolate to
|
||||
nearestVertex_,
|
||||
nearestVertexWeight_
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Read the times for which data is available
|
||||
|
||||
const fileName samplePointsDir = samplePointsFile.path();
|
||||
|
||||
sampleTimes_ = Time::findTimes(samplePointsDir);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "timeVaryingMappedFixedValueFvPatchField : In directory "
|
||||
<< samplePointsDir << " found times " << timeNames(sampleTimes_)
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
wordList timeVaryingMappedFixedValueFvPatchField<Type>::timeNames
|
||||
(
|
||||
const instantList& times
|
||||
)
|
||||
{
|
||||
wordList names(times.size());
|
||||
|
||||
forAll(times, i)
|
||||
{
|
||||
names[i] = times[i].name();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void timeVaryingMappedFixedValueFvPatchField<Type>::findTime
|
||||
(
|
||||
const fileName& instance,
|
||||
const fileName& local,
|
||||
const scalar timeVal,
|
||||
label& lo,
|
||||
label& hi
|
||||
) const
|
||||
{
|
||||
lo = startSampleTime_;
|
||||
hi = -1;
|
||||
|
||||
for (label i = startSampleTime_+1; i < sampleTimes_.size(); i++)
|
||||
{
|
||||
if (sampleTimes_[i].value() > timeVal)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
lo = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (lo == -1)
|
||||
{
|
||||
FatalErrorIn("findTime")
|
||||
<< "Cannot find starting sampling values for current time "
|
||||
<< timeVal << nl
|
||||
<< "Have sampling values for times "
|
||||
<< timeNames(sampleTimes_) << nl
|
||||
<< "In directory "
|
||||
<< this->db().time().constant()/"boundaryData"/this->patch().name()
|
||||
<< "\n on patch " << this->patch().name()
|
||||
<< " of field " << fieldTableName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (lo < sampleTimes_.size()-1)
|
||||
{
|
||||
hi = lo+1;
|
||||
}
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (hi == -1)
|
||||
{
|
||||
Pout<< "findTime : Found time " << timeVal << " after"
|
||||
<< " index:" << lo << " time:" << sampleTimes_[lo].value()
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pout<< "findTime : Found time " << timeVal << " inbetween"
|
||||
<< " index:" << lo << " time:" << sampleTimes_[lo].value()
|
||||
<< " and index:" << hi << " time:" << sampleTimes_[hi].value()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
// Clear interpolator
|
||||
mapperPtr_.clear();
|
||||
startSampleTime_ = -1;
|
||||
endSampleTime_ = -1;
|
||||
}
|
||||
|
||||
|
||||
@ -505,24 +209,86 @@ template<class Type>
|
||||
void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
|
||||
{
|
||||
// Initialise
|
||||
if (startSampleTime_ == -1 && endSampleTime_ == -1)
|
||||
if (mapperPtr_.empty())
|
||||
{
|
||||
readSamplePoints();
|
||||
pointIOField samplePoints
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
this->db().time().constant(),
|
||||
"boundaryData"/this->patch().name(),
|
||||
this->db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
const fileName samplePointsFile = samplePoints.filePath();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "timeVaryingMappedFixedValueFvPatchField :"
|
||||
<< " Read " << samplePoints.size() << " sample points from "
|
||||
<< samplePointsFile << endl;
|
||||
}
|
||||
|
||||
// Allocate the interpolator
|
||||
mapperPtr_.reset
|
||||
(
|
||||
new pointToPointPlanarInterpolation
|
||||
(
|
||||
samplePoints,
|
||||
this->patch().patch().faceCentres(),
|
||||
perturb_
|
||||
)
|
||||
);
|
||||
|
||||
// Read the times for which data is available
|
||||
const fileName samplePointsDir = samplePointsFile.path();
|
||||
sampleTimes_ = Time::findTimes(samplePointsDir);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "timeVaryingMappedFixedValueFvPatchField : In directory "
|
||||
<< samplePointsDir << " found times "
|
||||
<< pointToPointPlanarInterpolation::timeNames(sampleTimes_)
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find current time in sampleTimes
|
||||
label lo = -1;
|
||||
label hi = -1;
|
||||
|
||||
findTime
|
||||
bool foundTime = mapperPtr_().findTime
|
||||
(
|
||||
this->db().time().constant(),
|
||||
"boundaryData"/this->patch().name(),
|
||||
sampleTimes_,
|
||||
startSampleTime_,
|
||||
this->db().time().value(),
|
||||
lo,
|
||||
hi
|
||||
);
|
||||
|
||||
if (!foundTime)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingMappedFixedValueFvPatchField<Type>::checkTable"
|
||||
) << "Cannot find starting sampling values for current time "
|
||||
<< this->db().time().value() << nl
|
||||
<< "Have sampling values for times "
|
||||
<< pointToPointPlanarInterpolation::timeNames(sampleTimes_) << nl
|
||||
<< "In directory "
|
||||
<< this->db().time().constant()/"boundaryData"/this->patch().name()
|
||||
<< "\n on patch " << this->patch().name()
|
||||
<< " of field " << fieldTableName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Update sampled data fields.
|
||||
|
||||
if (lo != startSampleTime_)
|
||||
@ -573,7 +339,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
|
||||
);
|
||||
|
||||
startAverage_ = vals.average();
|
||||
startSampledValues_ = interpolate(vals);
|
||||
startSampledValues_ = mapperPtr_().interpolate(vals);
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,61 +383,22 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
|
||||
)
|
||||
);
|
||||
endAverage_ = vals.average();
|
||||
endSampledValues_ = interpolate(vals);
|
||||
endSampledValues_ = mapperPtr_().interpolate(vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type> > timeVaryingMappedFixedValueFvPatchField<Type>::interpolate
|
||||
(
|
||||
const Field<Type>& sourceFld
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type> > tfld(new Field<Type>(nearestVertex_.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
forAll(fld, i)
|
||||
{
|
||||
const FixedList<label, 3>& verts = nearestVertex_[i];
|
||||
const FixedList<scalar, 3>& w = nearestVertexWeight_[i];
|
||||
|
||||
if (verts[2] == -1)
|
||||
{
|
||||
if (verts[1] == -1)
|
||||
{
|
||||
// Use vertex0 only
|
||||
fld[i] = sourceFld[verts[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use vertex 0,1
|
||||
fld[i] =
|
||||
w[0]*sourceFld[verts[0]]
|
||||
+ w[1]*sourceFld[verts[1]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fld[i] =
|
||||
w[0]*sourceFld[verts[0]]
|
||||
+ w[1]*sourceFld[verts[1]]
|
||||
+ w[2]*sourceFld[verts[2]];
|
||||
}
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
checkTable();
|
||||
|
||||
// Interpolate between the sampled data
|
||||
@ -768,7 +495,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<Type>::write(os);
|
||||
os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("peturb") << perturb_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("perturb") << perturb_ << token::END_STATEMENT << nl;
|
||||
|
||||
if (fieldTableName_ != this->dimensionedInternalField().name())
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -45,7 +45,7 @@ Description
|
||||
// Maintain average to that of the supplied values
|
||||
setAverage false;
|
||||
|
||||
// Optional: change perturbation (default 1E-5) to avoid any ties
|
||||
// Optional: change perturbation (default 1e-5) to avoid any ties
|
||||
// in triangulating regular geometries.
|
||||
//perturb 0.0;
|
||||
|
||||
@ -66,9 +66,9 @@ SourceFiles
|
||||
#define timeVaryingMappedFixedValueFvPatchField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "FixedList.H"
|
||||
#include "instantList.H"
|
||||
#include "pointToPointPlanarInterpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -95,16 +95,8 @@ class timeVaryingMappedFixedValueFvPatchField
|
||||
//- Fraction of perturbation (fraction of bounding box) to add
|
||||
scalar perturb_;
|
||||
|
||||
//- Coordinate system
|
||||
autoPtr<coordinateSystem> referenceCS_;
|
||||
|
||||
//- Current interpolation addressing to face centres of underlying
|
||||
// patch
|
||||
List<FixedList<label, 3> > nearestVertex_;
|
||||
|
||||
//- Current interpolation factors to face centres of underlying
|
||||
// patch
|
||||
List<FixedList<scalar, 3> > nearestVertexWeight_;
|
||||
//- 2D interpolation
|
||||
autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
|
||||
|
||||
//- List of boundaryData time directories
|
||||
instantList sampleTimes_;
|
||||
@ -127,31 +119,6 @@ class timeVaryingMappedFixedValueFvPatchField
|
||||
//- If setAverage: end average value
|
||||
Type endAverage_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Get names of times
|
||||
static wordList timeNames(const instantList&);
|
||||
|
||||
//- Find times around current time
|
||||
void findTime
|
||||
(
|
||||
const fileName& instance,
|
||||
const fileName& local,
|
||||
const scalar timeVal,
|
||||
label& lo,
|
||||
label& hi
|
||||
) const;
|
||||
|
||||
|
||||
//- Read boundary points and determine interpolation weights to patch
|
||||
// faceCentres
|
||||
void readSamplePoints();
|
||||
|
||||
//- Do actual interpolation using current weights
|
||||
tmp<Field<Type> > interpolate(const Field<Type>&) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -224,12 +191,6 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the coordinateSystem
|
||||
const coordinateSystem& referenceCS() const
|
||||
{
|
||||
return referenceCS_;
|
||||
}
|
||||
|
||||
//- Return startSampledValues
|
||||
const Field<Type> startSampledValues()
|
||||
{
|
||||
|
||||
@ -26,13 +26,20 @@ motionDiffusivity/manipulators/exponential/exponentialDiffusivity.C
|
||||
fvPatchFields/derived/cellMotion/cellMotionFvPatchFields.C
|
||||
fvPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementFvPatchFields.C
|
||||
|
||||
pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C
|
||||
pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C
|
||||
derivedPoint = pointPatchFields/derived
|
||||
|
||||
$(derivedPoint)/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C
|
||||
$(derivedPoint)/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C
|
||||
|
||||
$(derivedPoint)/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C
|
||||
$(derivedPoint)/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C
|
||||
$(derivedPoint)/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C
|
||||
$(derivedPoint)/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C
|
||||
$(derivedPoint)/waveDisplacement/waveDisplacementPointPatchVectorField.C
|
||||
|
||||
$(derivedPoint)/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.C
|
||||
$(derivedPoint)/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C
|
||||
|
||||
|
||||
pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C
|
||||
pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C
|
||||
pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C
|
||||
pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C
|
||||
pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfvMotionSolvers
|
||||
|
||||
@ -0,0 +1,482 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeVaryingMappedFixedValuePointPatchField.H"
|
||||
#include "Time.H"
|
||||
#include "AverageIOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingMappedFixedValuePointPatchField<Type>::
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF),
|
||||
fieldTableName_(iF.name()),
|
||||
setAverage_(false),
|
||||
perturb_(0),
|
||||
sampleTimes_(0),
|
||||
startSampleTime_(-1),
|
||||
startSampledValues_(0),
|
||||
startAverage_(pTraits<Type>::zero),
|
||||
endSampleTime_(-1),
|
||||
endSampledValues_(0),
|
||||
endAverage_(pTraits<Type>::zero)
|
||||
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingMappedFixedValuePointPatchField<Type>::
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingMappedFixedValuePointPatchField<Type>& ptf,
|
||||
const pointPatch& p,
|
||||
const DimensionedField<Type, pointMesh>& iF,
|
||||
const pointPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
|
||||
fieldTableName_(ptf.fieldTableName_),
|
||||
setAverage_(ptf.setAverage_),
|
||||
perturb_(ptf.perturb_),
|
||||
mapperPtr_(ptf.mapperPtr_),
|
||||
sampleTimes_(0),
|
||||
startSampleTime_(-1),
|
||||
startSampledValues_(0),
|
||||
startAverage_(pTraits<Type>::zero),
|
||||
endSampleTime_(-1),
|
||||
endSampledValues_(0),
|
||||
endAverage_(pTraits<Type>::zero)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingMappedFixedValuePointPatchField<Type>::
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<Type, pointMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF),
|
||||
fieldTableName_(iF.name()),
|
||||
setAverage_(readBool(dict.lookup("setAverage"))),
|
||||
perturb_(dict.lookupOrDefault("perturb", 1e-5)),
|
||||
mapperPtr_(NULL),
|
||||
sampleTimes_(0),
|
||||
startSampleTime_(-1),
|
||||
startSampledValues_(0),
|
||||
startAverage_(pTraits<Type>::zero),
|
||||
endSampleTime_(-1),
|
||||
endSampledValues_(0),
|
||||
endAverage_(pTraits<Type>::zero)
|
||||
{
|
||||
dict.readIfPresent("fieldTableName", fieldTableName_);
|
||||
updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingMappedFixedValuePointPatchField<Type>::
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingMappedFixedValuePointPatchField<Type>& ptf
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf),
|
||||
fieldTableName_(ptf.fieldTableName_),
|
||||
setAverage_(ptf.setAverage_),
|
||||
perturb_(ptf.perturb_),
|
||||
mapperPtr_(ptf.mapperPtr_),
|
||||
sampleTimes_(ptf.sampleTimes_),
|
||||
startSampleTime_(ptf.startSampleTime_),
|
||||
startSampledValues_(ptf.startSampledValues_),
|
||||
startAverage_(ptf.startAverage_),
|
||||
endSampleTime_(ptf.endSampleTime_),
|
||||
endSampledValues_(ptf.endSampledValues_),
|
||||
endAverage_(ptf.endAverage_)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingMappedFixedValuePointPatchField<Type>::
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingMappedFixedValuePointPatchField<Type>& ptf,
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, iF),
|
||||
fieldTableName_(ptf.fieldTableName_),
|
||||
setAverage_(ptf.setAverage_),
|
||||
perturb_(ptf.perturb_),
|
||||
mapperPtr_(ptf.mapperPtr_),
|
||||
sampleTimes_(ptf.sampleTimes_),
|
||||
startSampleTime_(ptf.startSampleTime_),
|
||||
startSampledValues_(ptf.startSampledValues_),
|
||||
startAverage_(ptf.startAverage_),
|
||||
endSampleTime_(ptf.endSampleTime_),
|
||||
endSampledValues_(ptf.endSampledValues_),
|
||||
endAverage_(ptf.endAverage_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::checkTable()
|
||||
{
|
||||
// Initialise
|
||||
if (startSampleTime_ == -1 && endSampleTime_ == -1)
|
||||
{
|
||||
const polyMesh& pMesh = this->patch().boundaryMesh().mesh()();
|
||||
|
||||
// Read the initial point position
|
||||
pointField meshPts;
|
||||
|
||||
if (pMesh.pointsInstance() == pMesh.facesInstance())
|
||||
{
|
||||
meshPts = pointField(pMesh.points(), this->patch().meshPoints());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load points from facesInstance
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Reloading points0 from " << pMesh.facesInstance()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
pointIOField points0
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
pMesh.facesInstance(),
|
||||
polyMesh::meshSubDir,
|
||||
pMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
meshPts = pointField(points0, this->patch().meshPoints());
|
||||
}
|
||||
|
||||
pointIOField samplePoints
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
this->db().time().constant(),
|
||||
"boundaryData"/this->patch().name(),
|
||||
this->db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
mapperPtr_.reset
|
||||
(
|
||||
new pointToPointPlanarInterpolation
|
||||
(
|
||||
samplePoints,
|
||||
meshPts,
|
||||
perturb_
|
||||
)
|
||||
);
|
||||
|
||||
// Read the times for which data is available
|
||||
|
||||
const fileName samplePointsFile = samplePoints.filePath();
|
||||
const fileName samplePointsDir = samplePointsFile.path();
|
||||
sampleTimes_ = Time::findTimes(samplePointsDir);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "timeVaryingMappedFixedValuePointPatchField : In directory "
|
||||
<< samplePointsDir << " found times "
|
||||
<< pointToPointPlanarInterpolation::timeNames(sampleTimes_)
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Find current time in sampleTimes
|
||||
label lo = -1;
|
||||
label hi = -1;
|
||||
|
||||
bool foundTime = mapperPtr_().findTime
|
||||
(
|
||||
sampleTimes_,
|
||||
startSampleTime_,
|
||||
this->db().time().value(),
|
||||
lo,
|
||||
hi
|
||||
);
|
||||
|
||||
if (!foundTime)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingMappedFixedValuePointPatchField<Type>::checkTable"
|
||||
) << "Cannot find starting sampling values for current time "
|
||||
<< this->db().time().value() << nl
|
||||
<< "Have sampling values for times "
|
||||
<< pointToPointPlanarInterpolation::timeNames(sampleTimes_) << nl
|
||||
<< "In directory "
|
||||
<< this->db().time().constant()/"boundaryData"/this->patch().name()
|
||||
<< "\n on patch " << this->patch().name()
|
||||
<< " of field " << fieldTableName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Update sampled data fields.
|
||||
|
||||
if (lo != startSampleTime_)
|
||||
{
|
||||
startSampleTime_ = lo;
|
||||
|
||||
if (startSampleTime_ == endSampleTime_)
|
||||
{
|
||||
// No need to reread since are end values
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "checkTable : Setting startValues to (already read) "
|
||||
<< "boundaryData"
|
||||
/this->patch().name()
|
||||
/sampleTimes_[startSampleTime_].name()
|
||||
<< endl;
|
||||
}
|
||||
startSampledValues_ = endSampledValues_;
|
||||
startAverage_ = endAverage_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "checkTable : Reading startValues from "
|
||||
<< "boundaryData"
|
||||
/this->patch().name()
|
||||
/sampleTimes_[lo].name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Reread values and interpolate
|
||||
AverageIOField<Type> vals
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldTableName_,
|
||||
this->db().time().constant(),
|
||||
"boundaryData"
|
||||
/this->patch().name()
|
||||
/sampleTimes_[startSampleTime_].name(),
|
||||
this->db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
startAverage_ = vals.average();
|
||||
startSampledValues_ = mapperPtr_().interpolate(vals);
|
||||
}
|
||||
}
|
||||
|
||||
if (hi != endSampleTime_)
|
||||
{
|
||||
endSampleTime_ = hi;
|
||||
|
||||
if (endSampleTime_ == -1)
|
||||
{
|
||||
// endTime no longer valid. Might as well clear endValues.
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "checkTable : Clearing endValues" << endl;
|
||||
}
|
||||
endSampledValues_.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "checkTable : Reading endValues from "
|
||||
<< "boundaryData"
|
||||
/this->patch().name()
|
||||
/sampleTimes_[endSampleTime_].name()
|
||||
<< endl;
|
||||
}
|
||||
// Reread values and interpolate
|
||||
AverageIOField<Type> vals
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldTableName_,
|
||||
this->db().time().constant(),
|
||||
"boundaryData"
|
||||
/this->patch().name()
|
||||
/sampleTimes_[endSampleTime_].name(),
|
||||
this->db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
endAverage_ = vals.average();
|
||||
endSampledValues_ = mapperPtr_().interpolate(vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
checkTable();
|
||||
|
||||
// Interpolate between the sampled data
|
||||
|
||||
Type wantedAverage;
|
||||
|
||||
if (endSampleTime_ == -1)
|
||||
{
|
||||
// only start value
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "updateCoeffs : Sampled, non-interpolated values"
|
||||
<< " from start time:"
|
||||
<< sampleTimes_[startSampleTime_].name() << nl;
|
||||
}
|
||||
|
||||
this->operator==(startSampledValues_);
|
||||
wantedAverage = startAverage_;
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar start = sampleTimes_[startSampleTime_].value();
|
||||
scalar end = sampleTimes_[endSampleTime_].value();
|
||||
|
||||
scalar s = (this->db().time().value()-start)/(end-start);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "updateCoeffs : Sampled, interpolated values"
|
||||
<< " between start time:"
|
||||
<< sampleTimes_[startSampleTime_].name()
|
||||
<< " and end time:" << sampleTimes_[endSampleTime_].name()
|
||||
<< " with weight:" << s << endl;
|
||||
}
|
||||
|
||||
this->operator==((1-s)*startSampledValues_ + s*endSampledValues_);
|
||||
wantedAverage = (1-s)*startAverage_ + s*endAverage_;
|
||||
}
|
||||
|
||||
// Enforce average. Either by scaling (if scaling factor > 0.5) or by
|
||||
// offsetting.
|
||||
if (setAverage_)
|
||||
{
|
||||
const Field<Type>& fld = *this;
|
||||
|
||||
Type averagePsi = gAverage(fld);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "updateCoeffs :"
|
||||
<< " actual average:" << averagePsi
|
||||
<< " wanted average:" << wantedAverage
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (mag(averagePsi) < VSMALL)
|
||||
{
|
||||
// Field too small to scale. Offset instead.
|
||||
const Type offset = wantedAverage - averagePsi;
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "updateCoeffs :"
|
||||
<< " offsetting with:" << offset << endl;
|
||||
}
|
||||
this->operator==(fld+offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
const scalar scale = mag(wantedAverage)/mag(averagePsi);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "updateCoeffs :"
|
||||
<< " scaling with:" << scale << endl;
|
||||
}
|
||||
this->operator==(scale*fld);
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this) << endl;
|
||||
}
|
||||
|
||||
fixedValuePointPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
fixedValuePointPatchField<Type>::write(os);
|
||||
os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("perturb") << perturb_ << token::END_STATEMENT << nl;
|
||||
|
||||
if (fieldTableName_ != this->dimensionedInternalField().name())
|
||||
{
|
||||
os.writeKeyword("fieldTableName") << fieldTableName_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,195 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::timeVaryingMappedFixedValuePointPatchField
|
||||
|
||||
Description
|
||||
A time-varying form of a mapped fixed value boundary condition.
|
||||
|
||||
See Also
|
||||
Foam::timeVaryingMappedFixedValueFvPatchField
|
||||
|
||||
SourceFiles
|
||||
timeVaryingMappedFixedValuePointPatchField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef timeVaryingMappedFixedValuePointPatchField_H
|
||||
#define timeVaryingMappedFixedValuePointPatchField_H
|
||||
|
||||
#include "fixedValuePointPatchField.H"
|
||||
#include "instantList.H"
|
||||
#include "pointToPointPlanarInterpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class timeVaryingMappedFixedValuePointPatchField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class timeVaryingMappedFixedValuePointPatchField
|
||||
:
|
||||
public fixedValuePointPatchField<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of the field data table, defaults to the name of the field
|
||||
word fieldTableName_;
|
||||
|
||||
//- If true adjust the mapped field to maintain average value
|
||||
bool setAverage_;
|
||||
|
||||
//- Fraction of perturbation (fraction of bounding box) to add
|
||||
scalar perturb_;
|
||||
|
||||
//- 2D interpolation
|
||||
autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
|
||||
|
||||
//- List of boundaryData time directories
|
||||
instantList sampleTimes_;
|
||||
|
||||
//- Current starting index in sampleTimes
|
||||
label startSampleTime_;
|
||||
|
||||
//- Interpolated values from startSampleTime
|
||||
Field<Type> startSampledValues_;
|
||||
|
||||
//- If setAverage: starting average value
|
||||
Type startAverage_;
|
||||
|
||||
//- Current end index in sampleTimes
|
||||
label endSampleTime_;
|
||||
|
||||
//- Interpolated values from endSampleTime
|
||||
Field<Type> endSampledValues_;
|
||||
|
||||
//- If setAverage: end average value
|
||||
Type endAverage_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("timeVaryingMappedFixedValue");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const pointPatch&,
|
||||
const DimensionedField<Type, pointMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const pointPatch&,
|
||||
const DimensionedField<Type, pointMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given patch field onto a new patch
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingMappedFixedValuePointPatchField<Type>&,
|
||||
const pointPatch&,
|
||||
const DimensionedField<Type, pointMesh>&,
|
||||
const pointPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingMappedFixedValuePointPatchField<Type>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<pointPatchField<Type> > clone() const
|
||||
{
|
||||
return autoPtr<pointPatchField<Type> >
|
||||
(
|
||||
new timeVaryingMappedFixedValuePointPatchField<Type>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
timeVaryingMappedFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingMappedFixedValuePointPatchField<Type>&,
|
||||
const DimensionedField<Type, pointMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual autoPtr<pointPatchField<Type> > clone
|
||||
(
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
) const
|
||||
{
|
||||
return autoPtr<pointPatchField<Type> >
|
||||
(
|
||||
new timeVaryingMappedFixedValuePointPatchField<Type>(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Utility functions
|
||||
|
||||
//- Find boundary data inbetween current time and interpolate
|
||||
void checkTable();
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "timeVaryingMappedFixedValuePointPatchField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeVaryingMappedFixedValuePointPatchFields.H"
|
||||
#include "pointPatchFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makePointPatchFields(timeVaryingMappedFixedValue);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InClass
|
||||
Foam::timeVaryingMappedFixedValuePointPatchFields
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
timeVaryingMappedFixedValuePointPatchFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef timeVaryingMappedFixedValuePointPatchFields_H
|
||||
#define timeVaryingMappedFixedValuePointPatchFields_H
|
||||
|
||||
#include "timeVaryingMappedFixedValuePointPatchField.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePointPatchFieldTypedefs(timeVaryingMappedFixedValue);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,291 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "uniformInterpolatedDisplacementPointPatchVectorField.H"
|
||||
#include "pointPatchFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "interpolationWeights.H"
|
||||
#include "uniformInterpolate.H"
|
||||
#include "ReadFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
uniformInterpolatedDisplacementPointPatchVectorField::
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<vector, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF)
|
||||
{}
|
||||
|
||||
|
||||
uniformInterpolatedDisplacementPointPatchVectorField::
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<vector, pointMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF, dict),
|
||||
fieldName_(dict.lookup("fieldName")),
|
||||
interpolationScheme_(dict.lookup("interpolationScheme"))
|
||||
{
|
||||
const pointMesh& pMesh = this->dimensionedInternalField().mesh();
|
||||
|
||||
// Read time values
|
||||
instantList allTimes = Time::findTimes(pMesh().time().path());
|
||||
|
||||
// Only keep those that contain the field
|
||||
DynamicList<word> names(allTimes.size());
|
||||
DynamicList<scalar> values(allTimes.size());
|
||||
|
||||
forAll(allTimes, i)
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
fieldName_,
|
||||
allTimes[i].name(),
|
||||
pMesh(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
if (io.headerOk())
|
||||
{
|
||||
names.append(allTimes[i].name());
|
||||
values.append(allTimes[i].value());
|
||||
}
|
||||
}
|
||||
timeNames_.transfer(names);
|
||||
timeVals_.transfer(values);
|
||||
|
||||
Info<< type() << " : found " << fieldName_ << " for times "
|
||||
<< timeNames_ << endl;
|
||||
|
||||
if (timeNames_.size() < 1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"uniformInterpolatedDisplacementPointPatchVectorField::\n"
|
||||
"uniformInterpolatedDisplacementPointPatchVectorField\n"
|
||||
"(\n"
|
||||
" const pointPatch&,\n"
|
||||
" const DimensionedField<vector, pointMesh>&,\n"
|
||||
" const dictionary&\n"
|
||||
")\n"
|
||||
) << "Did not find any times with " << fieldName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
if (!dict.found("value"))
|
||||
{
|
||||
updateCoeffs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uniformInterpolatedDisplacementPointPatchVectorField::
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
const uniformInterpolatedDisplacementPointPatchVectorField& ptf,
|
||||
const pointPatch& p,
|
||||
const DimensionedField<vector, pointMesh>& iF,
|
||||
const pointPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
|
||||
fieldName_(ptf.fieldName_),
|
||||
interpolationScheme_(ptf.interpolationScheme_),
|
||||
timeNames_(ptf.timeNames_),
|
||||
timeVals_(ptf.timeVals_),
|
||||
interpolatorPtr_(ptf.interpolatorPtr_)
|
||||
{}
|
||||
|
||||
|
||||
uniformInterpolatedDisplacementPointPatchVectorField::
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
const uniformInterpolatedDisplacementPointPatchVectorField& ptf,
|
||||
const DimensionedField<vector, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(ptf, iF),
|
||||
fieldName_(ptf.fieldName_),
|
||||
interpolationScheme_(ptf.interpolationScheme_),
|
||||
timeNames_(ptf.timeNames_),
|
||||
timeVals_(ptf.timeVals_),
|
||||
interpolatorPtr_(ptf.interpolatorPtr_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void uniformInterpolatedDisplacementPointPatchVectorField::updateCoeffs()
|
||||
{
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!interpolatorPtr_.valid())
|
||||
{
|
||||
interpolatorPtr_ = interpolationWeights::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
timeVals_
|
||||
);
|
||||
}
|
||||
|
||||
const pointMesh& pMesh = this->dimensionedInternalField().mesh();
|
||||
const Time& t = pMesh().time();
|
||||
|
||||
// Update indices of times and weights
|
||||
bool timesChanged = interpolatorPtr_->valueWeights
|
||||
(
|
||||
t.timeOutputValue(),
|
||||
currentIndices_,
|
||||
currentWeights_
|
||||
);
|
||||
|
||||
const wordList currentTimeNames
|
||||
(
|
||||
UIndirectList<word>(timeNames_, currentIndices_)
|
||||
);
|
||||
|
||||
|
||||
// Load if necessary fields for this interpolation
|
||||
if (timesChanged)
|
||||
{
|
||||
objectRegistry& fieldsCache = const_cast<objectRegistry&>
|
||||
(
|
||||
pMesh.thisDb().subRegistry("fieldsCache", true)
|
||||
);
|
||||
// Save old times so we now which ones have been loaded and need
|
||||
// 'correctBoundaryConditions'. Bit messy.
|
||||
HashSet<word> oldTimes(fieldsCache.toc());
|
||||
|
||||
ReadFields<pointVectorField>
|
||||
(
|
||||
fieldName_,
|
||||
pMesh,
|
||||
currentTimeNames
|
||||
);
|
||||
|
||||
forAllConstIter(objectRegistry, fieldsCache, fieldsCacheIter)
|
||||
{
|
||||
if (!oldTimes.found(fieldsCacheIter.key()))
|
||||
{
|
||||
// Newly loaded fields. Make sure the internal
|
||||
// values are consistent with the boundary conditions.
|
||||
// This is quite often not the case since these
|
||||
// fields typically are constructed 'by hand'
|
||||
|
||||
const objectRegistry& timeCache = dynamic_cast
|
||||
<
|
||||
const objectRegistry&
|
||||
>(*fieldsCacheIter());
|
||||
|
||||
|
||||
pointVectorField& d = const_cast<pointVectorField&>
|
||||
(
|
||||
timeCache.lookupObject<pointVectorField>
|
||||
(
|
||||
fieldName_
|
||||
)
|
||||
);
|
||||
d.correctBoundaryConditions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Interpolate the whole field
|
||||
pointVectorField result
|
||||
(
|
||||
uniformInterpolate<pointVectorField>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
word("uniformInterpolate(")
|
||||
+ this->dimensionedInternalField().name()
|
||||
+ ')',
|
||||
pMesh.time().timeName(),
|
||||
pMesh.thisDb(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
fieldName_,
|
||||
currentTimeNames,
|
||||
currentWeights_
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Extract back from the internal field
|
||||
this->operator==
|
||||
(
|
||||
this->patchInternalField(result.dimensionedInternalField())
|
||||
);
|
||||
|
||||
fixedValuePointPatchField<vector>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void uniformInterpolatedDisplacementPointPatchVectorField::write(Ostream& os)
|
||||
const
|
||||
{
|
||||
pointPatchField<vector>::write(os);
|
||||
os.writeKeyword("fieldName")
|
||||
<< fieldName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("interpolationScheme")
|
||||
<< interpolationScheme_ << token::END_STATEMENT << nl;
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePointPatchTypeField
|
||||
(
|
||||
pointPatchVectorField,
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,183 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::uniformInterpolatedDisplacementPointPatchVectorField
|
||||
|
||||
Description
|
||||
Interpolates pre-specified motion.
|
||||
|
||||
Motion specified as pointVectorFields. E.g.
|
||||
|
||||
walls
|
||||
{
|
||||
type uniformInterpolatedDisplacement;
|
||||
value uniform (0 0 0);
|
||||
fieldName wantedDisplacement;
|
||||
interpolationScheme linear;
|
||||
}
|
||||
|
||||
This will scan the case for 'wantedDisplacement' pointVectorFields
|
||||
and interpolate those in time (using 'linear' interpolation) to
|
||||
obtain the current displacement.
|
||||
The advantage of specifying displacement in this way is that it
|
||||
automatically works through decomposePar.
|
||||
|
||||
SourceFiles
|
||||
uniformInterpolatedDisplacementPointPatchVectorField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uniformInterpolatedDisplacementPointPatchVectorField_H
|
||||
#define uniformInterpolatedDisplacementPointPatchVectorField_H
|
||||
|
||||
#include "fixedValuePointPatchField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class interpolationWeights;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uniformInterpolatedDisplacementPointPatchVectorField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class uniformInterpolatedDisplacementPointPatchVectorField
|
||||
:
|
||||
public fixedValuePointPatchField<vector>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of displacement field
|
||||
const word fieldName_;
|
||||
|
||||
const word interpolationScheme_;
|
||||
|
||||
//- Times with pre-specified displacement
|
||||
wordList timeNames_;
|
||||
|
||||
//- Times with pre-specified displacement
|
||||
scalarField timeVals_;
|
||||
|
||||
//- User-specified interpolator
|
||||
autoPtr<interpolationWeights> interpolatorPtr_;
|
||||
|
||||
|
||||
//- Cached interpolation times
|
||||
labelList currentIndices_;
|
||||
|
||||
//- Cached interpolation weights
|
||||
scalarField currentWeights_;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("uniformInterpolatedDisplacement");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
const pointPatch&,
|
||||
const DimensionedField<vector, pointMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
const pointPatch&,
|
||||
const DimensionedField<vector, pointMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given patchField<vector> onto a new patch
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
const uniformInterpolatedDisplacementPointPatchVectorField&,
|
||||
const pointPatch&,
|
||||
const DimensionedField<vector, pointMesh>&,
|
||||
const pointPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<pointPatchField<vector> > clone() const
|
||||
{
|
||||
return autoPtr<pointPatchField<vector> >
|
||||
(
|
||||
new uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
*this
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
const uniformInterpolatedDisplacementPointPatchVectorField&,
|
||||
const DimensionedField<vector, pointMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual autoPtr<pointPatchField<vector> > clone
|
||||
(
|
||||
const DimensionedField<vector, pointMesh>& iF
|
||||
) const
|
||||
{
|
||||
return autoPtr<pointPatchField<vector> >
|
||||
(
|
||||
new uniformInterpolatedDisplacementPointPatchVectorField
|
||||
(
|
||||
*this,
|
||||
iF
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1881,7 +1881,7 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map)
|
||||
List<treeBoundBox> meshBb(1);
|
||||
treeBoundBox& bb = meshBb[0];
|
||||
bb = treeBoundBox(mesh_.points());
|
||||
bb = bb.extend(rndGen, 1E-4);
|
||||
bb = bb.extend(rndGen, 1e-4);
|
||||
|
||||
// Distribute all geometry (so refinementSurfaces and shellSurfaces)
|
||||
searchableSurfaces& geometry =
|
||||
|
||||
@ -1073,7 +1073,7 @@ void Foam::meshRefinement::findCellZoneGeometric
|
||||
label nei = faceNeighbour[faceI];
|
||||
const point& neiCc = cellCentres[nei];
|
||||
// Perturbed cc
|
||||
const vector d = 1E-4*(neiCc - ownCc);
|
||||
const vector d = 1e-4*(neiCc - ownCc);
|
||||
candidatePoints[nCandidates++] = ownCc-d;
|
||||
candidatePoints[nCandidates++] = neiCc+d;
|
||||
}
|
||||
@ -1081,7 +1081,7 @@ void Foam::meshRefinement::findCellZoneGeometric
|
||||
{
|
||||
const point& neiFc = mesh_.faceCentres()[faceI];
|
||||
// Perturbed cc
|
||||
const vector d = 1E-4*(neiFc - ownCc);
|
||||
const vector d = 1e-4*(neiFc - ownCc);
|
||||
candidatePoints[nCandidates++] = ownCc-d;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -93,7 +93,7 @@ Foam::refinementFeatures::refinementFeatures
|
||||
|
||||
// Slightly extended bb. Slightly off-centred just so on symmetric
|
||||
// geometry there are less face/edge aligned items.
|
||||
bb = bb.extend(rndGen, 1E-4);
|
||||
bb = bb.extend(rndGen, 1e-4);
|
||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
|
||||
@ -158,6 +158,7 @@ triSurface/triangleFuncs/triangleFuncs.C
|
||||
triSurface/surfaceFeatures/surfaceFeatures.C
|
||||
triSurface/triSurfaceTools/triSurfaceTools.C
|
||||
triSurface/triSurfaceTools/geompack/geompack.C
|
||||
triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C
|
||||
|
||||
twoDPointCorrector/twoDPointCorrector.C
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -146,7 +146,7 @@ Foam::boolList Foam::cellClassification::markFaces
|
||||
treeBoundBox allBb(mesh_.points());
|
||||
|
||||
// Extend domain slightly (also makes it 3D if was 2D)
|
||||
scalar tol = 1E-6 * allBb.avgDim();
|
||||
scalar tol = 1e-6 * allBb.avgDim();
|
||||
|
||||
point& bbMin = allBb.min();
|
||||
bbMin.x() -= tol;
|
||||
@ -187,7 +187,7 @@ Foam::boolList Foam::cellClassification::markFaces
|
||||
|
||||
vector edgeNormal(end - start);
|
||||
const scalar edgeMag = mag(edgeNormal);
|
||||
const vector smallVec = 1E-9*edgeNormal;
|
||||
const vector smallVec = 1e-9*edgeNormal;
|
||||
|
||||
edgeNormal /= edgeMag+VSMALL;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -31,7 +31,7 @@ License
|
||||
|
||||
defineTypeNameAndDebug(Foam::treeDataFace, 0);
|
||||
|
||||
Foam::scalar Foam::treeDataFace::tolSqr = sqr(1E-6);
|
||||
Foam::scalar Foam::treeDataFace::tolSqr = sqr(1e-6);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -38,7 +38,7 @@ template
|
||||
>
|
||||
Foam::scalar
|
||||
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
tolSqr = sqr(1E-6);
|
||||
tolSqr = sqr(1e-6);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -265,7 +265,7 @@ void Foam::mappedPatchBase::findSamples
|
||||
treeBoundBox(pp.points(), pp.meshPoints()).extend
|
||||
(
|
||||
rndGen,
|
||||
1E-4
|
||||
1e-4
|
||||
)
|
||||
);
|
||||
patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
@ -431,7 +431,7 @@ void Foam::mappedPatchBase::calcMapping() const
|
||||
tmp<pointField> patchPoints(facePoints(patch_));
|
||||
|
||||
// Get offsetted points
|
||||
const pointField offsettedPoints = samplePoints(patchPoints());
|
||||
const pointField offsettedPoints(samplePoints(patchPoints()));
|
||||
|
||||
|
||||
// Do a sanity check
|
||||
|
||||
@ -35,7 +35,7 @@ License
|
||||
|
||||
defineTypeNameAndDebug(Foam::meshSearch, 0);
|
||||
|
||||
Foam::scalar Foam::meshSearch::tol_ = 1E-3;
|
||||
Foam::scalar Foam::meshSearch::tol_ = 1e-3;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -567,7 +567,7 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree()
|
||||
|
||||
treeBoundBox& overallBb = overallBbPtr_();
|
||||
// Extend slightly and make 3D
|
||||
overallBb = overallBb.extend(rndGen, 1E-4);
|
||||
overallBb = overallBb.extend(rndGen, 1e-4);
|
||||
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
}
|
||||
@ -620,7 +620,7 @@ const
|
||||
|
||||
treeBoundBox& overallBb = overallBbPtr_();
|
||||
// Extend slightly and make 3D
|
||||
overallBb = overallBb.extend(rndGen, 1E-4);
|
||||
overallBb = overallBb.extend(rndGen, 1e-4);
|
||||
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -185,8 +185,8 @@ Foam::pointIndexHit Foam::searchablePlate::findLine
|
||||
if (info.hit())
|
||||
{
|
||||
treeBoundBox bb(origin_, origin_+span_);
|
||||
bb.min()[normalDir_] -= 1E-6;
|
||||
bb.max()[normalDir_] += 1E-6;
|
||||
bb.min()[normalDir_] -= 1e-6;
|
||||
bb.max()[normalDir_] += 1e-6;
|
||||
|
||||
if (!bb.contains(info.hitPoint()))
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -242,7 +242,7 @@ void Foam::searchableSurfaceWithGaps::findLine
|
||||
// test in pairs: only if both perturbations hit something
|
||||
// do we accept the hit.
|
||||
|
||||
const vectorField smallVec(1E-6*(compactEnd-compactStart));
|
||||
const vectorField smallVec(1e-6*(compactEnd-compactStart));
|
||||
|
||||
List<pointIndexHit> plusInfo;
|
||||
surface().findLine
|
||||
@ -296,7 +296,7 @@ void Foam::searchableSurfaceWithGaps::findLine
|
||||
offset0.setSize(plusMissMap.size());
|
||||
offset1.setSize(plusMissMap.size());
|
||||
|
||||
const vectorField smallVec(1E-6*(compactEnd-compactStart));
|
||||
const vectorField smallVec(1e-6*(compactEnd-compactStart));
|
||||
|
||||
surface().findLine
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -542,7 +542,7 @@ Foam::triSurfaceMesh::tree() const
|
||||
|
||||
// Slightly extended bb. Slightly off-centred just so on symmetric
|
||||
// geometry there are less face/edge aligned items.
|
||||
bb = bb.extend(rndGen, 1E-4);
|
||||
bb = bb.extend(rndGen, 1e-4);
|
||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
@ -594,7 +594,7 @@ Foam::triSurfaceMesh::edgeTree() const
|
||||
// Slightly extended bb. Slightly off-centred just so on symmetric
|
||||
// geometry there are less face/edge aligned items.
|
||||
|
||||
bb = bb.extend(rndGen, 1E-4);
|
||||
bb = bb.extend(rndGen, 1e-4);
|
||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -569,7 +569,7 @@ void Foam::surfaceIntersection::doCutEdges
|
||||
List<DynamicList<label> >& surfEdgeCuts
|
||||
)
|
||||
{
|
||||
scalar oldTol = intersection::setPlanarTol(1E-3);
|
||||
scalar oldTol = intersection::setPlanarTol(1e-3);
|
||||
|
||||
const pointField& surf1Pts = surf1.localPoints();
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,7 +54,7 @@ Foam::triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
|
||||
treeBoundBox(surface_.points(), surface_.meshPoints()).extend
|
||||
(
|
||||
rndGen,
|
||||
1E-4
|
||||
1e-4
|
||||
)
|
||||
);
|
||||
treeBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
@ -1130,8 +1130,8 @@ int dtris2 ( int point_num, double point_xy[], int *tri_num,
|
||||
tri_vert[3*(i-1)+0] = m1;
|
||||
tri_vert[3*(i-1)+1] = m2;
|
||||
tri_vert[3*(i-1)+2] = m;
|
||||
tri_nabe[3*(i-1)+0] = -3 * i;
|
||||
tri_nabe[3*(i-1)+1] = i;
|
||||
tri_nabe[3*(i-2)+0] = -3 * i;
|
||||
tri_nabe[3*(i-2)+1] = i;
|
||||
tri_nabe[3*(i-1)+2] = i - 1;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,322 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pointToPointPlanarInterpolation.H"
|
||||
#include "boundBox.H"
|
||||
#include "Random.H"
|
||||
#include "vector2D.H"
|
||||
#include "triSurface.H"
|
||||
#include "triSurfaceTools.H"
|
||||
#include "OFstream.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::pointToPointPlanarInterpolation, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::coordinateSystem
|
||||
Foam::pointToPointPlanarInterpolation::calcCoordinateSystem
|
||||
(
|
||||
const pointField& points
|
||||
) const
|
||||
{
|
||||
if (points.size() < 3)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"pointToPointPlanarInterpolation::calcCoordinateSystem"
|
||||
"(const pointField&)"
|
||||
) << "Only " << points.size() << " provided." << nl
|
||||
<< "Need at least three non-colinear points"
|
||||
<< " to be able to interpolate."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const point& p0 = points[0];
|
||||
|
||||
// Find furthest away point
|
||||
vector e1;
|
||||
label index1 = -1;
|
||||
scalar maxDist = -GREAT;
|
||||
|
||||
for (label i = 1; i < points.size(); i++)
|
||||
{
|
||||
const vector d = points[i] - p0;
|
||||
scalar magD = mag(d);
|
||||
|
||||
if (magD > maxDist)
|
||||
{
|
||||
e1 = d/magD;
|
||||
index1 = i;
|
||||
maxDist = magD;
|
||||
}
|
||||
}
|
||||
// Find point that is furthest away from line p0-p1
|
||||
const point& p1 = points[index1];
|
||||
|
||||
label index2 = -1;
|
||||
maxDist = -GREAT;
|
||||
for (label i = 1; i < points.size(); i++)
|
||||
{
|
||||
if (i != index1)
|
||||
{
|
||||
const point& p2 = points[i];
|
||||
vector e2(p2 - p0);
|
||||
e2 -= (e2&e1)*e1;
|
||||
scalar magE2 = mag(e2);
|
||||
|
||||
if (magE2 > maxDist)
|
||||
{
|
||||
index2 = i;
|
||||
maxDist = magE2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index2 == -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"pointToPointPlanarInterpolation::calcCoordinateSystem"
|
||||
"(const pointField&)"
|
||||
) << "Cannot find points that make valid normal." << nl
|
||||
<< "Have so far points " << p0 << " and " << p1
|
||||
<< "Need at least three points which are not in a line."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
vector n = e1^(points[index2]-p0);
|
||||
n /= mag(n);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "pointToPointPlanarInterpolation::calcCoordinateSystem :"
|
||||
<< " Used points " << p0 << ' ' << points[index1]
|
||||
<< ' ' << points[index2]
|
||||
<< " to define coordinate system with normal " << n << endl;
|
||||
}
|
||||
|
||||
return coordinateSystem
|
||||
(
|
||||
"reference",
|
||||
p0, // origin
|
||||
n, // normal
|
||||
e1 // 0-axis
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::pointToPointPlanarInterpolation::calcWeights
|
||||
(
|
||||
const pointField& sourcePoints,
|
||||
const pointField& destPoints
|
||||
)
|
||||
{
|
||||
tmp<vectorField> tlocalVertices
|
||||
(
|
||||
referenceCS_.localPosition(sourcePoints)
|
||||
);
|
||||
vectorField& localVertices = tlocalVertices();
|
||||
|
||||
const boundBox bb(localVertices, true);
|
||||
const point bbMid(bb.midpoint());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "pointToPointPlanarInterpolation::readData :"
|
||||
<< " Perturbing points with " << perturb_
|
||||
<< " fraction of a random position inside " << bb
|
||||
<< " to break any ties on regular meshes."
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
Random rndGen(123456);
|
||||
forAll(localVertices, i)
|
||||
{
|
||||
localVertices[i] +=
|
||||
perturb_
|
||||
*(rndGen.position(bb.min(), bb.max())-bbMid);
|
||||
}
|
||||
|
||||
// Determine triangulation
|
||||
List<vector2D> localVertices2D(localVertices.size());
|
||||
forAll(localVertices, i)
|
||||
{
|
||||
localVertices2D[i][0] = localVertices[i][0];
|
||||
localVertices2D[i][1] = localVertices[i][1];
|
||||
}
|
||||
|
||||
triSurface s(triSurfaceTools::delaunay2D(localVertices2D));
|
||||
|
||||
tmp<pointField> tlocalFaceCentres
|
||||
(
|
||||
referenceCS_.localPosition
|
||||
(
|
||||
destPoints
|
||||
)
|
||||
);
|
||||
const pointField& localFaceCentres = tlocalFaceCentres();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "pointToPointPlanarInterpolation::readData :"
|
||||
<<" Dumping triangulated surface to triangulation.stl" << endl;
|
||||
s.write("triangulation.stl");
|
||||
|
||||
OFstream str("localFaceCentres.obj");
|
||||
Pout<< "readSamplePoints :"
|
||||
<< " Dumping face centres to " << str.name() << endl;
|
||||
|
||||
forAll(localFaceCentres, i)
|
||||
{
|
||||
const point& p = localFaceCentres[i];
|
||||
str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine interpolation onto face centres.
|
||||
triSurfaceTools::calcInterpolationWeights
|
||||
(
|
||||
s,
|
||||
localFaceCentres, // points to interpolate to
|
||||
nearestVertex_,
|
||||
nearestVertexWeight_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
|
||||
(
|
||||
const pointField& sourcePoints,
|
||||
const pointField& destPoints,
|
||||
const scalar perturb
|
||||
)
|
||||
:
|
||||
perturb_(perturb),
|
||||
referenceCS_(calcCoordinateSystem(sourcePoints))
|
||||
|
||||
{
|
||||
calcWeights(sourcePoints, destPoints);
|
||||
}
|
||||
|
||||
|
||||
Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation
|
||||
(
|
||||
const coordinateSystem& referenceCS,
|
||||
const pointField& sourcePoints,
|
||||
const pointField& destPoints,
|
||||
const scalar perturb
|
||||
)
|
||||
:
|
||||
perturb_(perturb),
|
||||
referenceCS_(referenceCS)
|
||||
{
|
||||
calcWeights(sourcePoints, destPoints);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wordList Foam::pointToPointPlanarInterpolation::timeNames
|
||||
(
|
||||
const instantList& times
|
||||
)
|
||||
{
|
||||
wordList names(times.size());
|
||||
|
||||
forAll(times, i)
|
||||
{
|
||||
names[i] = times[i].name();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::pointToPointPlanarInterpolation::findTime
|
||||
(
|
||||
const instantList& times,
|
||||
const label startSampleTime,
|
||||
const scalar timeVal,
|
||||
label& lo,
|
||||
label& hi
|
||||
)
|
||||
{
|
||||
lo = startSampleTime;
|
||||
hi = -1;
|
||||
|
||||
for (label i = startSampleTime+1; i < times.size(); i++)
|
||||
{
|
||||
if (times[i].value() > timeVal)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
lo = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (lo == -1)
|
||||
{
|
||||
//FatalErrorIn("findTime(..)")
|
||||
// << "Cannot find starting sampling values for current time "
|
||||
// << timeVal << nl
|
||||
// << "Have sampling values for times "
|
||||
// << timeNames(times) << nl
|
||||
// << exit(FatalError);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lo < times.size()-1)
|
||||
{
|
||||
hi = lo+1;
|
||||
}
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (hi == -1)
|
||||
{
|
||||
Pout<< "findTime : Found time " << timeVal << " after"
|
||||
<< " index:" << lo << " time:" << times[lo].value()
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pout<< "findTime : Found time " << timeVal << " inbetween"
|
||||
<< " index:" << lo << " time:" << times[lo].value()
|
||||
<< " and index:" << hi << " time:" << times[hi].value()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::pointToPointPlanarInterpolation
|
||||
|
||||
Description
|
||||
Interpolates between two sets of unstructured points using 2D Delaunay
|
||||
triangulation. Used in e.g. timeVaryingMapped bcs.
|
||||
|
||||
SourceFiles
|
||||
pointToPointPlanarInterpolation.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pointToPointPlanarInterpolation_H
|
||||
#define pointToPointPlanarInterpolation_H
|
||||
|
||||
#include "FixedList.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "instantList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pointToPointPlanarInterpolation Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pointToPointPlanarInterpolation
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Perturbation factor
|
||||
const scalar perturb_;
|
||||
|
||||
//- Coordinate system
|
||||
coordinateSystem referenceCS_;
|
||||
|
||||
//- Current interpolation addressing to face centres of underlying
|
||||
// patch
|
||||
List<FixedList<label, 3> > nearestVertex_;
|
||||
|
||||
//- Current interpolation factors to face centres of underlying
|
||||
// patch
|
||||
List<FixedList<scalar, 3> > nearestVertexWeight_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate a local coordinate system from set of points
|
||||
coordinateSystem calcCoordinateSystem(const pointField&) const;
|
||||
|
||||
//- Calculate addressing and weights
|
||||
void calcWeights
|
||||
(
|
||||
const pointField& sourcePoints,
|
||||
const pointField& destPoints
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
ClassName("pointToPointPlanarInterpolation");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from 3D locations. Determines local coordinate system
|
||||
// from sourcePoints and maps onto that.
|
||||
pointToPointPlanarInterpolation
|
||||
(
|
||||
const pointField& sourcePoints,
|
||||
const pointField& destPoints,
|
||||
const scalar perturb
|
||||
);
|
||||
|
||||
//- Construct from coordinate system and locations.
|
||||
pointToPointPlanarInterpolation
|
||||
(
|
||||
const coordinateSystem& referenceCS,
|
||||
const pointField& sourcePoints,
|
||||
const pointField& destPoints,
|
||||
const scalar perturb
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the coordinateSystem
|
||||
const coordinateSystem& referenceCS() const
|
||||
{
|
||||
return referenceCS_;
|
||||
}
|
||||
|
||||
// patch
|
||||
const List<FixedList<label, 3> >& nearestVertex() const
|
||||
{
|
||||
return nearestVertex_;
|
||||
}
|
||||
|
||||
//- Current interpolation factors to face centres of underlying
|
||||
// patch
|
||||
const List<FixedList<scalar, 3> >& nearestVertexWeight() const
|
||||
{
|
||||
return nearestVertexWeight_;
|
||||
}
|
||||
|
||||
//- Helper: extract words of times
|
||||
static wordList timeNames(const instantList&);
|
||||
|
||||
//- Helper: find time. Return true if succesful.
|
||||
static bool findTime
|
||||
(
|
||||
const instantList& times,
|
||||
const label startSampleTime,
|
||||
const scalar timeVal,
|
||||
label& lo,
|
||||
label& hi
|
||||
);
|
||||
|
||||
//- Interpolate from field on source points to dest points
|
||||
template<class Type>
|
||||
tmp<Field<Type> > interpolate(const Field<Type>& sourceFld) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "pointToPointPlanarInterpolationTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,71 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "pointToPointPlanarInterpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::pointToPointPlanarInterpolation::interpolate
|
||||
(
|
||||
const Field<Type>& sourceFld
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type> > tfld(new Field<Type>(nearestVertex_.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
forAll(fld, i)
|
||||
{
|
||||
const FixedList<label, 3>& verts = nearestVertex_[i];
|
||||
const FixedList<scalar, 3>& w = nearestVertexWeight_[i];
|
||||
|
||||
if (verts[2] == -1)
|
||||
{
|
||||
if (verts[1] == -1)
|
||||
{
|
||||
// Use vertex0 only
|
||||
fld[i] = sourceFld[verts[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use vertex 0,1
|
||||
fld[i] =
|
||||
w[0]*sourceFld[verts[0]]
|
||||
+ w[1]*sourceFld[verts[1]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fld[i] =
|
||||
w[0]*sourceFld[verts[0]]
|
||||
+ w[1]*sourceFld[verts[1]]
|
||||
+ w[2]*sourceFld[verts[2]];
|
||||
}
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -870,7 +870,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge
|
||||
{
|
||||
d[i] /= norm;
|
||||
|
||||
if (mag(d[i]) < 1E-6)
|
||||
if (mag(d[i]) < 1e-6)
|
||||
{
|
||||
d[i] = 0.0;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::triSurfaceTools
|
||||
|
||||
Description
|
||||
A collection of tools for triSurfaceMesh
|
||||
A collection of tools for triSurface.
|
||||
|
||||
SourceFiles
|
||||
triSurfaceTools.C
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -701,7 +701,7 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
|
||||
label allSize = points.size();
|
||||
reduce(allSize, sumOp<label>());
|
||||
|
||||
const label sizeTol = max(1, label(1E-3*allSize/nProcessors_));
|
||||
const label sizeTol = max(1, label(1e-3*allSize/nProcessors_));
|
||||
|
||||
// Sort recursive
|
||||
sortComponent
|
||||
@ -742,7 +742,7 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
|
||||
label allSize = points.size();
|
||||
reduce(allSize, sumOp<label>());
|
||||
|
||||
const label sizeTol = max(1, label(1E-3*allSize/nProcessors_));
|
||||
const label sizeTol = max(1, label(1e-3*allSize/nProcessors_));
|
||||
|
||||
// Sort recursive
|
||||
sortComponent
|
||||
|
||||
@ -153,14 +153,14 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
}
|
||||
case opAreaAverage:
|
||||
{
|
||||
const scalarField magSf = mag(Sf);
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
result = sum(values*magSf)/sum(magSf);
|
||||
break;
|
||||
}
|
||||
case opAreaIntegrate:
|
||||
{
|
||||
const scalarField magSf = mag(Sf);
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
result = sum(values*magSf);
|
||||
break;
|
||||
@ -177,7 +177,7 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
}
|
||||
case opCoV:
|
||||
{
|
||||
const scalarField magSf = mag(Sf);
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
Type meanValue = sum(values*magSf)/sum(magSf);
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ namespace Foam
|
||||
//
|
||||
// pointHit ph(ln.nearestDist(position()));
|
||||
//
|
||||
// if (ph.distance() > 1E-6)
|
||||
// if (ph.distance() > 1e-6)
|
||||
// {
|
||||
// FatalErrorIn
|
||||
// (
|
||||
|
||||
@ -138,7 +138,7 @@ Foam::labelList Foam::springRenumber::renumber
|
||||
<< " average force:" << average(mag(sumForce)) << endl;
|
||||
|
||||
// Determine displacement.
|
||||
scalarField displacement = deltaT*sumForce;
|
||||
scalarField displacement(deltaT*sumForce);
|
||||
|
||||
//Pout<< "Displacement :" << nl
|
||||
// << " min : " << min(displacement) << nl
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -73,7 +73,7 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
|
||||
|
||||
treeBoundBox overallBb(pp.points());
|
||||
Random rndGen(123456);
|
||||
overallBb = overallBb.extend(rndGen, 1E-4);
|
||||
overallBb = overallBb.extend(rndGen, 1e-4);
|
||||
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ void Foam::patchCloudSet::calcSamples
|
||||
// Not very random
|
||||
Random rndGen(123456);
|
||||
// Make bb asymetric just to avoid problems on symmetric meshes
|
||||
bb = bb.extend(rndGen, 1E-4);
|
||||
bb = bb.extend(rndGen, 1e-4);
|
||||
|
||||
// Make sure bb is 3D.
|
||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
@ -149,7 +149,7 @@ void Foam::patchSeedSet::calcSamples
|
||||
const point& cc = mesh().cellCentres()[cellI];
|
||||
samplingPts.append
|
||||
(
|
||||
info.hitPoint() + 1E-1*(cc-info.hitPoint())
|
||||
info.hitPoint() + 1e-1*(cc-info.hitPoint())
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@ -157,7 +157,7 @@ void Foam::ensightSetWriter<Type>::write
|
||||
<< "coordinates" << nl;
|
||||
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
const scalarField fld = valueSets[setI]->component(cmpt);
|
||||
const scalarField fld(valueSets[setI]->component(cmpt));
|
||||
forAll(fld, i)
|
||||
{
|
||||
if (mag(fld[i]) >= scalar(floatScalarVSMALL))
|
||||
@ -293,7 +293,7 @@ void Foam::ensightSetWriter<Type>::write
|
||||
cmpt++
|
||||
)
|
||||
{
|
||||
const scalarField fld = fieldVals[trackI].component(cmpt);
|
||||
const scalarField fld(fieldVals[trackI].component(cmpt));
|
||||
forAll(fld, i)
|
||||
{
|
||||
if (mag(fld[i]) >= scalar(floatScalarVSMALL))
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -407,7 +407,7 @@ public:
|
||||
const scalarField& pointIsoVals,
|
||||
const scalar iso,
|
||||
const bool regularise,
|
||||
const scalar mergeTol = 1E-6 // fraction of bounding box
|
||||
const scalar mergeTol = 1e-6 // fraction of bounding box
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -336,7 +336,7 @@ public:
|
||||
const scalarField& pointValues,
|
||||
const scalar iso,
|
||||
const bool regularise,
|
||||
const scalar mergeTol = 1E-6 // fraction of bounding box
|
||||
const scalar mergeTol = 1e-6 // fraction of bounding box
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -401,7 +401,7 @@ Foam::sampledIsoSurface::sampledIsoSurface
|
||||
sampledSurface(name, mesh, dict),
|
||||
isoField_(dict.lookup("isoField")),
|
||||
isoVal_(readScalar(dict.lookup("isoValue"))),
|
||||
mergeTol_(dict.lookupOrDefault("mergeTol", 1E-6)),
|
||||
mergeTol_(dict.lookupOrDefault("mergeTol", 1e-6)),
|
||||
regularise_(dict.lookupOrDefault("regularise", true)),
|
||||
average_(dict.lookupOrDefault("average", false)),
|
||||
zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()),
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -262,7 +262,7 @@ Foam::sampledCuttingPlane::sampledCuttingPlane
|
||||
:
|
||||
sampledSurface(name, mesh, dict),
|
||||
plane_(dict),
|
||||
mergeTol_(dict.lookupOrDefault("mergeTol", 1E-6)),
|
||||
mergeTol_(dict.lookupOrDefault("mergeTol", 1e-6)),
|
||||
regularise_(dict.lookupOrDefault("regularise", true)),
|
||||
average_(dict.lookupOrDefault("average", false)),
|
||||
zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()),
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -109,7 +109,7 @@ Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const
|
||||
|
||||
treeBoundBox overallBb(mesh().points());
|
||||
Random rndGen(123456);
|
||||
overallBb = overallBb.extend(rndGen, 1E-4);
|
||||
overallBb = overallBb.extend(rndGen, 1e-4);
|
||||
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -656,6 +656,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces
|
||||
<< " faces" << endl;
|
||||
}
|
||||
faceLst.setSize(newFaceI);
|
||||
faceMap.setSize(newFaceI);
|
||||
remapFaces(faceMap);
|
||||
}
|
||||
faceMap.clear();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,8 +59,8 @@ Foam::twoPhaseMixture::twoPhaseMixture
|
||||
:
|
||||
transportModel(U, phi),
|
||||
|
||||
phase1Name_("phase1"),
|
||||
phase2Name_("phase2"),
|
||||
phase1Name_(found("phases") ? wordList(lookup("phases"))[0] : "phase1"),
|
||||
phase2Name_(found("phases") ? wordList(lookup("phases"))[1] : "phase2"),
|
||||
|
||||
nuModel1_
|
||||
(
|
||||
@ -83,13 +83,24 @@ Foam::twoPhaseMixture::twoPhaseMixture
|
||||
)
|
||||
),
|
||||
|
||||
rho1_(nuModel1_->viscosityProperties().lookup("rho")),
|
||||
rho2_(nuModel2_->viscosityProperties().lookup("rho")),
|
||||
rho1_("rho", dimDensity, nuModel1_->viscosityProperties().lookup("rho")),
|
||||
rho2_("rho", dimDensity, nuModel2_->viscosityProperties().lookup("rho")),
|
||||
|
||||
U_(U),
|
||||
phi_(phi),
|
||||
|
||||
alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)),
|
||||
alpha1_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
found("phases") ? word("alpha" + phase1Name_) : alpha1Name,
|
||||
U_.time().timeName(),
|
||||
U_.db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
U_.mesh()
|
||||
),
|
||||
|
||||
nu_
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -69,7 +69,7 @@ protected:
|
||||
const volVectorField& U_;
|
||||
const surfaceScalarField& phi_;
|
||||
|
||||
const volScalarField& alpha1_;
|
||||
volScalarField alpha1_;
|
||||
|
||||
volScalarField nu_;
|
||||
|
||||
@ -110,6 +110,18 @@ public:
|
||||
return phase2Name_;
|
||||
}
|
||||
|
||||
//- Return the phase-fraction of phase 1
|
||||
const volScalarField& alpha1() const
|
||||
{
|
||||
return alpha1_;
|
||||
}
|
||||
|
||||
//- Return the phase-fraction of phase 1
|
||||
volScalarField& alpha1()
|
||||
{
|
||||
return alpha1_;
|
||||
}
|
||||
|
||||
//- Return const-access to phase1 viscosityModel
|
||||
const viscosityModel& nuModel1() const
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -50,7 +50,7 @@ Foam::viscosityModels::Newtonian::Newtonian
|
||||
)
|
||||
:
|
||||
viscosityModel(name, viscosityProperties, U, phi),
|
||||
nu0_(viscosityProperties_.lookup("nu")),
|
||||
nu0_("nu", dimensionSet(0, 2, -1, 0, 0), viscosityProperties_.lookup("nu")),
|
||||
nu_
|
||||
(
|
||||
IOobject
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::scalar Foam::faceTriangulation::edgeRelTol = 1E-6;
|
||||
const Foam::scalar Foam::faceTriangulation::edgeRelTol = 1e-6;
|
||||
|
||||
|
||||
// Edge to the right of face vertex i
|
||||
|
||||
Reference in New Issue
Block a user