mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Feature patch function1
This commit is contained in:
@ -275,6 +275,9 @@ mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C
|
||||
mappedPatches/mappedPointPatch/mappedPointPatch.C
|
||||
mappedPatches/mappedPointPatch/mappedWallPointPatch.C
|
||||
|
||||
PatchFunction1/makePatchFunction1s.C
|
||||
PatchFunction1/coordinateLabelScaling.C
|
||||
|
||||
meshStructure/meshStructure.C
|
||||
meshStructure/topoDistanceData.C
|
||||
meshStructure/pointTopoDistanceData.C
|
||||
|
||||
118
src/meshTools/PatchFunction1/ConstantField/ConstantField.C
Normal file
118
src/meshTools/PatchFunction1/ConstantField/ConstantField.C
Normal file
@ -0,0 +1,118 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "ConstantField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::ConstantField<Type>::ConstantField
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const Field<Type>& value,
|
||||
const dictionary& dict,
|
||||
const bool faceValues
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(pp, entryName, dict, faceValues),
|
||||
value_(value)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::ConstantField<Type>::ConstantField
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(pp, entryName, dict, faceValues),
|
||||
value_(entryName, dict, pp.size())
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::ConstantField<Type>::ConstantField
|
||||
(
|
||||
const ConstantField<Type>& cnst
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(cnst),
|
||||
value_(cnst.value_)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::ConstantField<Type>::ConstantField
|
||||
(
|
||||
const ConstantField<Type>& cnst,
|
||||
const polyPatch& pp
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(cnst, pp),
|
||||
value_(cnst.value_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::ConstantField<Type>::autoMap
|
||||
(
|
||||
const FieldMapper& mapper
|
||||
)
|
||||
{
|
||||
value_.autoMap(mapper);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::ConstantField<Type>::rmap
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const labelList& addr
|
||||
)
|
||||
{
|
||||
const auto& cst = refCast<const ConstantField<Type>>(pf1);
|
||||
value_.rmap(cst.value_, addr);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::ConstantField<Type>::writeData
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
PatchFunction1<Type>::writeData(os);
|
||||
//os << token::SPACE << value_ << token::END_STATEMENT << nl;
|
||||
value_.writeEntry(this->name_, os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
182
src/meshTools/PatchFunction1/ConstantField/ConstantField.H
Normal file
182
src/meshTools/PatchFunction1/ConstantField/ConstantField.H
Normal file
@ -0,0 +1,182 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::PatchFunction1Types::ConstantField
|
||||
|
||||
Description
|
||||
Templated function that returns a constant value.
|
||||
|
||||
Usage - for entry \<entryName\> returning the value <value>:
|
||||
\verbatim
|
||||
<entryName> constant <value>
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
ConstantField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PatchFunction1Types_ConstantField_H
|
||||
#define PatchFunction1Types_ConstantField_H
|
||||
|
||||
#include "PatchFunction1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace PatchFunction1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ConstantField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class ConstantField
|
||||
:
|
||||
public PatchFunction1<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- ConstantField value
|
||||
Field<Type> value_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const ConstantField<Type>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Runtime type information
|
||||
TypeName("constant");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ConstantField
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const Field<Type>& value,
|
||||
const dictionary& dict = dictionary::null,
|
||||
const bool faceValues = true
|
||||
);
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
ConstantField
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues = true
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
explicit ConstantField(const ConstantField<Type>& cnst);
|
||||
|
||||
//- Copy constructor setting patch
|
||||
explicit ConstantField
|
||||
(
|
||||
const ConstantField<Type>& cnst,
|
||||
const polyPatch& pp
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<PatchFunction1<Type>> clone() const
|
||||
{
|
||||
return tmp<PatchFunction1<Type>>(new ConstantField<Type>(*this));
|
||||
}
|
||||
|
||||
//- Construct and return a clone setting patch
|
||||
virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
|
||||
{
|
||||
return tmp<PatchFunction1<Type>>
|
||||
(
|
||||
new ConstantField<Type>(*this, pp)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ConstantField() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Return constant value
|
||||
virtual inline tmp<Field<Type>> value(const scalar) const;
|
||||
|
||||
//- Integrate between two values
|
||||
virtual inline tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
|
||||
// Mapping
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap(const FieldMapper& mapper);
|
||||
|
||||
//- Reverse map the given PatchFunction1 onto this PatchFunction1
|
||||
virtual void rmap
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const labelList& addr
|
||||
);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace PatchFunction1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "ConstantFieldI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "ConstantField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
67
src/meshTools/PatchFunction1/ConstantField/ConstantFieldI.H
Normal file
67
src/meshTools/PatchFunction1/ConstantField/ConstantFieldI.H
Normal file
@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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 "ConstantField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Foam::tmp<Foam::Field<Type>>
|
||||
Foam::PatchFunction1Types::ConstantField<Type>::value
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
{
|
||||
if (this->coordSys_.active())
|
||||
{
|
||||
return this->transform(value_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::tmp<Foam::Field<Type>>
|
||||
Foam::PatchFunction1Types::ConstantField<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
if (this->coordSys_.active())
|
||||
{
|
||||
return (x2 - x1)* this->transform(value_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (x2 - x1)*value_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
85
src/meshTools/PatchFunction1/MappedFile/AverageField.C
Normal file
85
src/meshTools/PatchFunction1/MappedFile/AverageField.C
Normal file
@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 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 "AverageField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::AverageField<Type>::AverageField(const label size)
|
||||
:
|
||||
Field<Type>(size),
|
||||
average_(Zero)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::AverageField<Type>::AverageField
|
||||
(
|
||||
const Field<Type>& f,
|
||||
const Type& average
|
||||
)
|
||||
:
|
||||
Field<Type>(f),
|
||||
average_(average)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::AverageField<Type>::AverageField(Istream& is)
|
||||
:
|
||||
Field<Type>(is),
|
||||
average_(pTraits<Type>(is))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Type& Foam::AverageField<Type>::average() const
|
||||
{
|
||||
return average_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type&Foam::AverageField<Type>::average()
|
||||
{
|
||||
return average_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::AverageField<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
os << static_cast<const Field<Type>&>(*this)
|
||||
<< token::NL
|
||||
<< average_;
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
98
src/meshTools/PatchFunction1/MappedFile/AverageField.H
Normal file
98
src/meshTools/PatchFunction1/MappedFile/AverageField.H
Normal file
@ -0,0 +1,98 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 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::AverageField
|
||||
|
||||
Description
|
||||
A primitive field with a separate average value.
|
||||
|
||||
SourceFiles
|
||||
AverageField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef AverageField_H
|
||||
#define AverageField_H
|
||||
|
||||
#include "Field.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AverageField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class AverageField
|
||||
:
|
||||
public Field<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- The average of the field
|
||||
Type average_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from size (does not set values)
|
||||
AverageField(const label size);
|
||||
|
||||
//- Construct from components
|
||||
AverageField(const Field<Type>&, const Type& average);
|
||||
|
||||
//- Construct from Istream
|
||||
AverageField(Istream&);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
const Type& average() const;
|
||||
|
||||
Type& average();
|
||||
|
||||
bool writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "AverageField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
638
src/meshTools/PatchFunction1/MappedFile/MappedFile.C
Normal file
638
src/meshTools/PatchFunction1/MappedFile/MappedFile.C
Normal file
@ -0,0 +1,638 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "polyMesh.H"
|
||||
#include "IFstream.H"
|
||||
#include "AverageField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(pp, entryName, dict, faceValues),
|
||||
dictConstructed_(true),
|
||||
fieldTableName_(entryName),
|
||||
setAverage_(dict.lookupOrDefault("setAverage", false)),
|
||||
perturb_(dict.lookupOrDefault("perturb", 1e-5)),
|
||||
pointsName_(dict.lookupOrDefault<word>("points", "points")),
|
||||
mapMethod_
|
||||
(
|
||||
dict.lookupOrDefault<word>
|
||||
(
|
||||
"mapMethod",
|
||||
"planarInterpolation"
|
||||
)
|
||||
),
|
||||
mapperPtr_(nullptr),
|
||||
sampleTimes_(0),
|
||||
startSampleTime_(-1),
|
||||
startSampledValues_(0),
|
||||
startAverage_(Zero),
|
||||
endSampleTime_(-1),
|
||||
endSampledValues_(0),
|
||||
endAverage_(Zero),
|
||||
offset_()
|
||||
{
|
||||
if (dict.found("offset"))
|
||||
{
|
||||
offset_ = Function1<Type>::New("offset", dict);
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
mapMethod_ != "planarInterpolation"
|
||||
&& mapMethod_ != "nearest"
|
||||
)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "mapMethod should be one of 'planarInterpolation'"
|
||||
<< ", 'nearest'" << exit(FatalIOError);
|
||||
}
|
||||
|
||||
dict.readIfPresent("fieldTable", fieldTableName_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const word& fieldTableName,
|
||||
const bool faceValues
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(pp, entryName, dict, faceValues),
|
||||
dictConstructed_(false),
|
||||
fieldTableName_(fieldTableName),
|
||||
setAverage_(dict.lookupOrDefault("setAverage", false)),
|
||||
perturb_(dict.lookupOrDefault("perturb", 1e-5)),
|
||||
pointsName_(dict.lookupOrDefault<word>("points", "points")),
|
||||
mapMethod_
|
||||
(
|
||||
dict.lookupOrDefault<word>
|
||||
(
|
||||
"mapMethod",
|
||||
"planarInterpolation"
|
||||
)
|
||||
),
|
||||
mapperPtr_(nullptr),
|
||||
sampleTimes_(0),
|
||||
startSampleTime_(-1),
|
||||
startSampledValues_(0),
|
||||
startAverage_(Zero),
|
||||
endSampleTime_(-1),
|
||||
endSampledValues_(0),
|
||||
endAverage_(Zero),
|
||||
offset_()
|
||||
{
|
||||
if (dict.found("offset"))
|
||||
{
|
||||
offset_ = Function1<Type>::New("offset", dict);
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
mapMethod_ != "planarInterpolation"
|
||||
&& mapMethod_ != "nearest"
|
||||
)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "mapMethod should be one of 'planarInterpolation'"
|
||||
<< ", 'nearest'" << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
|
||||
(
|
||||
const MappedFile<Type>& ut
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(ut),
|
||||
dictConstructed_(ut.dictConstructed_),
|
||||
fieldTableName_(ut.fieldTableName_),
|
||||
setAverage_(ut.setAverage_),
|
||||
perturb_(ut.perturb_),
|
||||
pointsName_(ut.pointsName_),
|
||||
mapMethod_(ut.mapMethod_),
|
||||
mapperPtr_(ut.mapperPtr_.clone()),
|
||||
sampleTimes_(ut.sampleTimes_),
|
||||
startSampleTime_(ut.startSampleTime_),
|
||||
startSampledValues_(ut.startSampledValues_),
|
||||
startAverage_(ut.startAverage_),
|
||||
endSampleTime_(ut.endSampleTime_),
|
||||
endSampledValues_(ut.endSampledValues_),
|
||||
endAverage_(ut.endAverage_),
|
||||
offset_(ut.offset_.clone())
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::MappedFile<Type>::MappedFile
|
||||
(
|
||||
const MappedFile<Type>& ut,
|
||||
const polyPatch& pp
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(ut, pp),
|
||||
dictConstructed_(ut.dictConstructed_),
|
||||
fieldTableName_(ut.fieldTableName_),
|
||||
setAverage_(ut.setAverage_),
|
||||
perturb_(ut.perturb_),
|
||||
pointsName_(ut.pointsName_),
|
||||
mapMethod_(ut.mapMethod_),
|
||||
mapperPtr_(ut.mapperPtr_.clone()),
|
||||
sampleTimes_(ut.sampleTimes_),
|
||||
startSampleTime_(ut.startSampleTime_),
|
||||
startSampledValues_(ut.startSampledValues_),
|
||||
startAverage_(ut.startAverage_),
|
||||
endSampleTime_(ut.endSampleTime_),
|
||||
endSampledValues_(ut.endSampledValues_),
|
||||
endAverage_(ut.endAverage_),
|
||||
offset_(ut.offset_.clone())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::MappedFile<Type>::autoMap
|
||||
(
|
||||
const FieldMapper& mapper
|
||||
)
|
||||
{
|
||||
PatchFunction1<Type>::autoMap(mapper);
|
||||
|
||||
if (startSampledValues_.size())
|
||||
{
|
||||
startSampledValues_.autoMap(mapper);
|
||||
endSampledValues_.autoMap(mapper);
|
||||
}
|
||||
// Clear interpolator
|
||||
mapperPtr_.clear();
|
||||
startSampleTime_ = -1;
|
||||
endSampleTime_ = -1;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::MappedFile<Type>::rmap
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const labelList& addr
|
||||
)
|
||||
{
|
||||
PatchFunction1<Type>::rmap(pf1, addr);
|
||||
|
||||
const PatchFunction1Types::MappedFile<Type>& tiptf =
|
||||
refCast<const PatchFunction1Types::MappedFile<Type>>(pf1);
|
||||
|
||||
startSampledValues_.rmap(tiptf.startSampledValues_, addr);
|
||||
endSampledValues_.rmap(tiptf.endSampledValues_, addr);
|
||||
|
||||
// Clear interpolator
|
||||
mapperPtr_.clear();
|
||||
startSampleTime_ = -1;
|
||||
endSampleTime_ = -1;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::MappedFile<Type>::checkTable
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
const polyMesh& mesh = this->patch_.boundaryMesh().mesh();
|
||||
|
||||
// Initialise
|
||||
if (mapperPtr_.empty())
|
||||
{
|
||||
// Reread values and interpolate
|
||||
fileName samplePointsFile
|
||||
(
|
||||
mesh.time().path()
|
||||
/mesh.time().caseConstant()
|
||||
/"boundaryData"
|
||||
/this->patch_.name()
|
||||
/pointsName_
|
||||
);
|
||||
|
||||
pointField samplePoints((IFstream(samplePointsFile)()));
|
||||
|
||||
DebugInfo
|
||||
<< "Read " << samplePoints.size() << " sample points from "
|
||||
<< samplePointsFile << endl;
|
||||
|
||||
|
||||
// tbd: run-time selection
|
||||
bool nearestOnly =
|
||||
(
|
||||
!mapMethod_.empty()
|
||||
&& mapMethod_ != "planarInterpolation"
|
||||
);
|
||||
|
||||
// Allocate the interpolator
|
||||
if (this->faceValues_)
|
||||
{
|
||||
mapperPtr_.reset
|
||||
(
|
||||
new pointToPointPlanarInterpolation
|
||||
(
|
||||
samplePoints,
|
||||
this->localPosition(this->patch_.faceCentres()),
|
||||
perturb_,
|
||||
nearestOnly
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
mapperPtr_.reset
|
||||
(
|
||||
new pointToPointPlanarInterpolation
|
||||
(
|
||||
samplePoints,
|
||||
this->localPosition(this->patch_.localPoints()),
|
||||
perturb_,
|
||||
nearestOnly
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Read the times for which data is available
|
||||
const fileName samplePointsDir = samplePointsFile.path();
|
||||
sampleTimes_ = Time::findTimes(samplePointsDir);
|
||||
|
||||
DebugInfo
|
||||
<< "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_,
|
||||
t, //mesh.time().value(),
|
||||
lo,
|
||||
hi
|
||||
);
|
||||
|
||||
if (!foundTime)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot find starting sampling values for index "
|
||||
<< t << nl
|
||||
<< "Have sampling values for "
|
||||
<< pointToPointPlanarInterpolation::timeNames(sampleTimes_) << nl
|
||||
<< "In directory "
|
||||
<< mesh.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
|
||||
fileName valsFile
|
||||
(
|
||||
mesh.time().path()
|
||||
/mesh.time().caseConstant()
|
||||
/"boundaryData"
|
||||
/this->patch_.name()
|
||||
/sampleTimes_[startSampleTime_].name()
|
||||
/fieldTableName_
|
||||
);
|
||||
|
||||
Field<Type> vals;
|
||||
|
||||
if (setAverage_)
|
||||
{
|
||||
AverageField<Type> avals((IFstream(valsFile)()));
|
||||
vals = avals;
|
||||
startAverage_ = avals.average();
|
||||
}
|
||||
else
|
||||
{
|
||||
IFstream(valsFile)() >> vals;
|
||||
}
|
||||
|
||||
if (vals.size() != mapperPtr_().sourceSize())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values (" << vals.size()
|
||||
<< ") differs from the number of points ("
|
||||
<< mapperPtr_().sourceSize()
|
||||
<< ") in file " << valsFile << exit(FatalError);
|
||||
}
|
||||
|
||||
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
|
||||
fileName valsFile
|
||||
(
|
||||
mesh.time().path()
|
||||
/mesh.time().caseConstant()
|
||||
/"boundaryData"
|
||||
/this->patch_.name()
|
||||
/sampleTimes_[endSampleTime_].name()
|
||||
/fieldTableName_
|
||||
);
|
||||
|
||||
Field<Type> vals;
|
||||
|
||||
if (setAverage_)
|
||||
{
|
||||
AverageField<Type> avals((IFstream(valsFile)()));
|
||||
vals = avals;
|
||||
endAverage_ = avals.average();
|
||||
}
|
||||
else
|
||||
{
|
||||
IFstream(valsFile)() >> vals;
|
||||
}
|
||||
|
||||
if (vals.size() != mapperPtr_().sourceSize())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values (" << vals.size()
|
||||
<< ") differs from the number of points ("
|
||||
<< mapperPtr_().sourceSize()
|
||||
<< ") in file " << valsFile << exit(FatalError);
|
||||
}
|
||||
|
||||
endSampledValues_ = mapperPtr_().interpolate(vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::PatchFunction1Types::MappedFile<Type>::value
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
{
|
||||
checkTable(x);
|
||||
|
||||
auto tfld = tmp<Field<Type>>::New(startSampledValues_.size());
|
||||
Field<Type>& fld = tfld.ref();
|
||||
Type wantedAverage;
|
||||
|
||||
if (endSampleTime_ == -1)
|
||||
{
|
||||
// Only start value
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "MappedFile<Type>::value : Sampled, non-interpolated values"
|
||||
<< " from start time:"
|
||||
<< sampleTimes_[startSampleTime_].name() << nl;
|
||||
}
|
||||
|
||||
fld = startSampledValues_;
|
||||
wantedAverage = startAverage_;
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar start = sampleTimes_[startSampleTime_].value();
|
||||
scalar end = sampleTimes_[endSampleTime_].value();
|
||||
|
||||
scalar s = (x - start)/(end - start);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "MappedFile<Type>::value : Sampled, interpolated values"
|
||||
<< " between start time:"
|
||||
<< sampleTimes_[startSampleTime_].name()
|
||||
<< " and end time:" << sampleTimes_[endSampleTime_].name()
|
||||
<< " with weight:" << s << endl;
|
||||
}
|
||||
|
||||
fld = ((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_)
|
||||
{
|
||||
Type averagePsi;
|
||||
if (this->faceValues_)
|
||||
{
|
||||
const scalarField magSf(mag(this->patch_.faceAreas()));
|
||||
averagePsi = gSum(magSf*fld)/gSum(magSf);
|
||||
}
|
||||
else
|
||||
{
|
||||
averagePsi = gAverage(fld);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "MappedFile<Type>::value :"
|
||||
<< " 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<< "MappedFile<Type>::value :"
|
||||
<< " offsetting with:" << offset << endl;
|
||||
}
|
||||
fld += offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
const scalar scale = mag(wantedAverage)/mag(averagePsi);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "MappedFile<Type>::value :"
|
||||
<< " scaling with:" << scale << endl;
|
||||
}
|
||||
fld *= scale;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply offset to mapped values
|
||||
if (offset_.valid())
|
||||
{
|
||||
fld += offset_->value(x);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "MappedFile<Type>::value : set fixedValue to min:" << gMin(fld)
|
||||
<< " max:" << gMax(fld)
|
||||
<< " avg:" << gAverage(fld) << endl;
|
||||
}
|
||||
|
||||
return this->transform(tfld);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::PatchFunction1Types::MappedFile<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::MappedFile<Type>::writeData
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
PatchFunction1<Type>::writeData(os);
|
||||
|
||||
// Check if field name explicitly provided (e.g. through timeVaryingMapped
|
||||
// bc)
|
||||
if (dictConstructed_)
|
||||
{
|
||||
os.writeKeyword(this->name()) << type();
|
||||
os << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeEntryIfDifferent
|
||||
(
|
||||
"fieldTable",
|
||||
this->name(),
|
||||
fieldTableName_
|
||||
);
|
||||
}
|
||||
|
||||
if (setAverage_)
|
||||
{
|
||||
os.writeEntry("setAverage", setAverage_);
|
||||
}
|
||||
|
||||
os.writeEntryIfDifferent<scalar>("perturb", 1e-5, perturb_);
|
||||
|
||||
os.writeEntryIfDifferent<word>("points", "points", pointsName_);
|
||||
|
||||
os.writeEntryIfDifferent<word>
|
||||
(
|
||||
"mapMethod",
|
||||
"planarInterpolation",
|
||||
mapMethod_
|
||||
);
|
||||
|
||||
if (offset_.valid())
|
||||
{
|
||||
offset_->writeData(os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
223
src/meshTools/PatchFunction1/MappedFile/MappedFile.H
Normal file
223
src/meshTools/PatchFunction1/MappedFile/MappedFile.H
Normal file
@ -0,0 +1,223 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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::PatchFunction1Types::MappedFile
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
MappedFile.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PatchFunction1Types_MappedFile_H
|
||||
#define PatchFunction1Types_MappedFile_H
|
||||
|
||||
#include "PatchFunction1.H"
|
||||
#include "pointToPointPlanarInterpolation.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace PatchFunction1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class MappedFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class MappedFile
|
||||
:
|
||||
public PatchFunction1<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Whether constructed from dictionary
|
||||
const bool dictConstructed_;
|
||||
|
||||
//- 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
|
||||
Switch setAverage_;
|
||||
|
||||
//- Fraction of perturbation (fraction of bounding box) to add
|
||||
scalar perturb_;
|
||||
|
||||
//- Name of points file; default = "points"
|
||||
word pointsName_;
|
||||
|
||||
//- Interpolation scheme to use
|
||||
word mapMethod_;
|
||||
|
||||
//- 2D interpolation (for 'planarInterpolation' mapMethod)
|
||||
mutable autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
|
||||
|
||||
//- List of boundaryData time directories
|
||||
mutable instantList sampleTimes_;
|
||||
|
||||
//- Current starting index in sampleTimes
|
||||
mutable label startSampleTime_;
|
||||
|
||||
//- Interpolated values from startSampleTime
|
||||
mutable Field<Type> startSampledValues_;
|
||||
|
||||
//- If setAverage: starting average value
|
||||
mutable Type startAverage_;
|
||||
|
||||
//- Current end index in sampleTimes
|
||||
mutable label endSampleTime_;
|
||||
|
||||
//- Interpolated values from endSampleTime
|
||||
mutable Field<Type> endSampledValues_;
|
||||
|
||||
//- If setAverage: end average value
|
||||
mutable Type endAverage_;
|
||||
|
||||
//- Time varying offset values to interpolated data
|
||||
autoPtr<Function1<Type>> offset_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void checkTable(const scalar t) const;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const MappedFile<Type>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Runtime type information
|
||||
TypeName("mappedFile");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
MappedFile
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues = true
|
||||
);
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
MappedFile
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const word& fieldTableName,
|
||||
const bool faceValues
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
explicit MappedFile(const MappedFile<Type>& ut);
|
||||
|
||||
//- Copy constructor setting patch
|
||||
explicit MappedFile
|
||||
(
|
||||
const MappedFile<Type>& ut,
|
||||
const polyPatch& pp
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<PatchFunction1<Type>> clone() const
|
||||
{
|
||||
return tmp<PatchFunction1<Type>>
|
||||
(
|
||||
new MappedFile<Type>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct and return a clone setting patch
|
||||
virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
|
||||
{
|
||||
return tmp<PatchFunction1<Type>>
|
||||
(
|
||||
new MappedFile<Type>(*this, pp)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~MappedFile() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Return MappedFile value
|
||||
virtual tmp<Field<Type>> value(const scalar) const;
|
||||
|
||||
//- Integrate between two values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
|
||||
// Mapping
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap(const FieldMapper& mapper);
|
||||
|
||||
//- Reverse map the given PatchFunction1 onto this PatchFunction1
|
||||
virtual void rmap
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const labelList& addr
|
||||
);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace PatchFunction1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "MappedFile.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
232
src/meshTools/PatchFunction1/PatchFunction1.C
Normal file
232
src/meshTools/PatchFunction1/PatchFunction1.C
Normal file
@ -0,0 +1,232 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "PatchFunction1.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1<Type>::PatchFunction1
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const bool faceValues
|
||||
)
|
||||
:
|
||||
refCount(),
|
||||
name_(entryName),
|
||||
patch_(pp),
|
||||
faceValues_(faceValues),
|
||||
coordSys_()
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1<Type>::PatchFunction1
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues
|
||||
)
|
||||
:
|
||||
refCount(),
|
||||
name_(entryName),
|
||||
patch_(pp),
|
||||
faceValues_(faceValues),
|
||||
coordSys_(pp.boundaryMesh().mesh().thisDb(), dict)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1<Type>::PatchFunction1(const PatchFunction1<Type>& pf1)
|
||||
:
|
||||
refCount(),
|
||||
name_(pf1.name_),
|
||||
patch_(pf1.patch_),
|
||||
faceValues_(pf1.faceValues_),
|
||||
coordSys_(pf1.coordSys_)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1<Type>::PatchFunction1
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const polyPatch& pp
|
||||
)
|
||||
:
|
||||
refCount(),
|
||||
name_(pf1.name_),
|
||||
patch_(pp),
|
||||
faceValues_(pf1.faceValues_),
|
||||
coordSys_(pf1.coordSys_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::word& Foam::PatchFunction1<Type>::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1<Type>::convertTimeBase(const Time&)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::value
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return Field<Type>();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return Field<Type>();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::pointField>
|
||||
Foam::PatchFunction1<Type>::localPosition(const pointField& globalPos) const
|
||||
{
|
||||
if (!coordSys_.active())
|
||||
{
|
||||
return globalPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
return coordSys_.coordSys()().localPosition(globalPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::transform
|
||||
(
|
||||
const tmp<Field<Type>>& tfld
|
||||
) const
|
||||
{
|
||||
if (!coordSys_.active())
|
||||
{
|
||||
return tfld;
|
||||
}
|
||||
|
||||
const pointField& fc =
|
||||
(
|
||||
faceValues_
|
||||
? this->patch_.faceCentres()
|
||||
: this->patch_.localPoints()
|
||||
);
|
||||
auto tresult = this->coordSys_.transform(fc, tfld());
|
||||
tfld.clear();
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::transform
|
||||
(
|
||||
const Field<Type>& fld
|
||||
) const
|
||||
{
|
||||
if (!coordSys_.active())
|
||||
{
|
||||
return fld;
|
||||
}
|
||||
|
||||
const pointField& fc =
|
||||
(
|
||||
faceValues_
|
||||
? this->patch_.faceCentres()
|
||||
: this->patch_.localPoints()
|
||||
);
|
||||
return this->coordSys_.transform(fc, fld);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1<Type>::autoMap(const FieldMapper& mapper)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1<Type>::rmap
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const labelList& addr
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
coordSys_.writeEntry(os);
|
||||
|
||||
// Leave type() output up to derived type. This is so 'Constant'&Uniform
|
||||
// can do backwards compatibility.
|
||||
//os.writeKeyword(name_) << type();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const PatchFunction1<Type>& pf1
|
||||
)
|
||||
{
|
||||
os.check(FUNCTION_NAME);
|
||||
|
||||
os << pf1.name_;
|
||||
pf1.writeData(os);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
280
src/meshTools/PatchFunction1/PatchFunction1.H
Normal file
280
src/meshTools/PatchFunction1/PatchFunction1.H
Normal file
@ -0,0 +1,280 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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::PatchFunction1
|
||||
|
||||
Description
|
||||
Top level data entry class for use in dictionaries. Provides a mechanism
|
||||
to specify a variable as a certain type, e.g. constant or time varying, and
|
||||
provide functions to return the (interpolated) value, and integral between
|
||||
limits.
|
||||
|
||||
Extends the Function1 class by adding autoMap and rMap functions
|
||||
|
||||
SourceFiles
|
||||
PatchFunction1.C
|
||||
PatchFunction1New.C
|
||||
|
||||
SeeAlso
|
||||
Foam::Function1
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PatchFunction1_H
|
||||
#define PatchFunction1_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "Field.H"
|
||||
#include "polyPatch.H"
|
||||
#include "coordinateScaling.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class Time;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class Type>
|
||||
class PatchFunction1;
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const PatchFunction1<Type>&
|
||||
);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PatchFunction1 Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class PatchFunction1
|
||||
:
|
||||
public refCount
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const PatchFunction1<Type>&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of entry
|
||||
const word name_;
|
||||
|
||||
//- Reference to the patch
|
||||
const polyPatch& patch_;
|
||||
|
||||
//- Whether to generate face or point values on patch
|
||||
const bool faceValues_;
|
||||
|
||||
//- Optional local co-ordinate system and scaling
|
||||
coordinateScaling<Type> coordSys_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
typedef Field<Type> returnType;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("PatchFunction1")
|
||||
|
||||
//- Declare runtime constructor selection table
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
PatchFunction1,
|
||||
dictionary,
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues
|
||||
),
|
||||
(pp, entryName, dict, faceValues)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from polyPatch and entry name
|
||||
PatchFunction1
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const bool faceValues = true
|
||||
);
|
||||
|
||||
//- Construct from polyPatch, dictionary and entry name
|
||||
PatchFunction1
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues = true
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
explicit PatchFunction1(const PatchFunction1<Type>& pf1);
|
||||
|
||||
//- Copy constructor setting patch
|
||||
explicit PatchFunction1
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const polyPatch& pp
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<PatchFunction1<Type>> clone() const = 0;
|
||||
|
||||
//- Construct and return a clone setting patch
|
||||
virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const = 0;
|
||||
|
||||
|
||||
//- Selector
|
||||
static autoPtr<PatchFunction1<Type>> New
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues = true
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~PatchFunction1() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the name of the entry
|
||||
const word& name() const;
|
||||
|
||||
|
||||
// Manipulation
|
||||
|
||||
//- Convert time
|
||||
virtual void convertTimeBase(const Time& t);
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalar x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
//- Helper: optionally convert coordinates to local coordinates
|
||||
virtual tmp<pointField> localPosition
|
||||
(
|
||||
const pointField& globalPos
|
||||
) const;
|
||||
|
||||
//- Apply optional transformation
|
||||
virtual tmp<Field<Type>> transform(const Field<Type>& fld) const;
|
||||
|
||||
//- Apply optional transformation
|
||||
virtual tmp<Field<Type>> transform
|
||||
(
|
||||
const tmp<Field<Type>>& tfld
|
||||
) const;
|
||||
|
||||
|
||||
// Mapping
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap(const FieldMapper& mapper);
|
||||
|
||||
//- Reverse map the given PatchFunction1 onto this PatchFunction1
|
||||
virtual void rmap
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const labelList& addr
|
||||
);
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream& os,
|
||||
const PatchFunction1<Type>& func
|
||||
);
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define makePatchFunction1(Type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(PatchFunction1<Type>, 0); \
|
||||
\
|
||||
defineTemplateRunTimeSelectionTable \
|
||||
( \
|
||||
PatchFunction1<Type>, \
|
||||
dictionary \
|
||||
);
|
||||
|
||||
#define makePatchFunction1Type(SS, Type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(PatchFunction1Types::SS<Type>, 0); \
|
||||
\
|
||||
PatchFunction1<Type>::adddictionaryConstructorToTable \
|
||||
<PatchFunction1Types::SS<Type>> \
|
||||
add##SS##Type##ConstructorToTable_;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "PatchFunction1.C"
|
||||
#include "PatchFunction1New.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
127
src/meshTools/PatchFunction1/PatchFunction1New.C
Normal file
127
src/meshTools/PatchFunction1/PatchFunction1New.C
Normal file
@ -0,0 +1,127 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "ConstantField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::autoPtr<Foam::PatchFunction1<Type>> Foam::PatchFunction1<Type>::New
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues
|
||||
)
|
||||
{
|
||||
if (dict.isDict(entryName))
|
||||
{
|
||||
const dictionary& coeffsDict(dict.subDict(entryName));
|
||||
|
||||
const word modelType(coeffsDict.lookup("type"));
|
||||
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalIOErrorInFunction(coeffsDict)
|
||||
<< "Unknown PatchFunction1 type "
|
||||
<< modelType << " for PatchFunction1 "
|
||||
<< entryName << nl << nl
|
||||
<< "Valid PatchFunction1 types :" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return cstrIter()(pp, entryName, coeffsDict, faceValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
ITstream& is = dict.lookup(entryName, false);
|
||||
|
||||
token firstToken(is);
|
||||
|
||||
if (!firstToken.isWord())
|
||||
{
|
||||
// Backwards-compatibility for reading straight fields
|
||||
is.putBack(firstToken);
|
||||
const Field<Type> value(pp.size(), pTraits<Type>(is));
|
||||
|
||||
return autoPtr<PatchFunction1<Type>>
|
||||
(
|
||||
new PatchFunction1Types::ConstantField<Type>
|
||||
(
|
||||
pp,
|
||||
entryName,
|
||||
value,
|
||||
dict,
|
||||
faceValues
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const word modelType = firstToken.wordToken();
|
||||
|
||||
// Check to see if this looks like a normal field entry
|
||||
if (modelType == "uniform" || modelType == "nonuniform")
|
||||
{
|
||||
return autoPtr<PatchFunction1<Type>>
|
||||
(
|
||||
new PatchFunction1Types::ConstantField<Type>
|
||||
(
|
||||
pp,
|
||||
entryName,
|
||||
dict
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Unknown PatchFunction1 type "
|
||||
<< modelType << " for PatchFunction1 "
|
||||
<< entryName << nl << nl
|
||||
<< "Valid PatchFunction1 types :" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
return cstrIter()
|
||||
(
|
||||
pp,
|
||||
entryName,
|
||||
dict.found(entryName + "Coeffs")
|
||||
? dict.subDict(entryName + "Coeffs")
|
||||
: dict,
|
||||
faceValues
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "UniformValueField.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(pp, entryName, dict, faceValues),
|
||||
uniformValuePtr_(Function1<Type>::New(entryName, dict))
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField
|
||||
(
|
||||
const UniformValueField<Type>& ut
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(ut),
|
||||
uniformValuePtr_(ut.uniformValuePtr_.clone())
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField
|
||||
(
|
||||
const UniformValueField<Type>& ut,
|
||||
const polyPatch& pp
|
||||
)
|
||||
:
|
||||
PatchFunction1<Type>(ut, pp),
|
||||
uniformValuePtr_(ut.uniformValuePtr_.clone())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::UniformValueField<Type>::autoMap
|
||||
(
|
||||
const FieldMapper& mapper
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::UniformValueField<Type>::rmap
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const labelList& addr
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::PatchFunction1Types::UniformValueField<Type>::writeData
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
PatchFunction1<Type>::writeData(os);
|
||||
//os << token::END_STATEMENT << nl;
|
||||
uniformValuePtr_->writeData(os);
|
||||
//os << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,186 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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::PatchFunction1Types::UniformValueField
|
||||
|
||||
Description
|
||||
Templated function that returns a uniform field based on a run-time
|
||||
selectable Function1 entry.
|
||||
|
||||
Usage - for entry \<entryName\> returning the value <value>:
|
||||
\verbatim
|
||||
<entryName> uniformValue
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
UniformValueField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PatchFunction1Types_UniformValueField_H
|
||||
#define PatchFunction1Types_UniformValueField_H
|
||||
|
||||
#include "PatchFunction1.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace PatchFunction1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class UniformValueField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class UniformValueField
|
||||
:
|
||||
public PatchFunction1<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Source of uniform values (in local co-ordinate system)
|
||||
autoPtr<Foam::Function1<Type>> uniformValuePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const UniformValueField<Type>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Runtime type information
|
||||
TypeName("uniformValue");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
// //- Construct from components
|
||||
// UniformValueField
|
||||
// (
|
||||
// const polyPatch& pp,
|
||||
// const word& entryName,
|
||||
// const Field<Type>& value,
|
||||
// const bool faceValues = true
|
||||
// );
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
UniformValueField
|
||||
(
|
||||
const polyPatch& pp,
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const bool faceValues = true
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
explicit UniformValueField(const UniformValueField<Type>& ut);
|
||||
|
||||
//- Copy constructor setting patch
|
||||
explicit UniformValueField
|
||||
(
|
||||
const UniformValueField<Type>& ut,
|
||||
const polyPatch& pp
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<PatchFunction1<Type>> clone() const
|
||||
{
|
||||
return tmp<PatchFunction1<Type>>
|
||||
(
|
||||
new UniformValueField<Type>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct and return a clone setting patch
|
||||
virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
|
||||
{
|
||||
return tmp<PatchFunction1<Type>>
|
||||
(
|
||||
new UniformValueField<Type>(*this, pp)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~UniformValueField() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Return UniformValueField value
|
||||
virtual inline tmp<Field<Type>> value(const scalar) const;
|
||||
|
||||
//- Integrate between two values
|
||||
virtual inline tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
|
||||
// Mapping
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap(const FieldMapper& mapper);
|
||||
|
||||
//- Reverse map the given PatchFunction1 onto this PatchFunction1
|
||||
virtual void rmap
|
||||
(
|
||||
const PatchFunction1<Type>& pf1,
|
||||
const labelList& addr
|
||||
);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace PatchFunction1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "UniformValueFieldI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "UniformValueField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "UniformValueField.H"
|
||||
#include "SubField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Foam::tmp<Foam::Field<Type>>
|
||||
Foam::PatchFunction1Types::UniformValueField<Type>::value
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
{
|
||||
label sz =
|
||||
(
|
||||
this->faceValues_
|
||||
? this->patch_.size()
|
||||
: this->patch_.nPoints()
|
||||
);
|
||||
|
||||
tmp<Field<Type>> tfld
|
||||
(
|
||||
tmp<Field<Type>>::New
|
||||
(
|
||||
sz,
|
||||
uniformValuePtr_->value(x)
|
||||
)
|
||||
);
|
||||
return this->transform(tfld);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::tmp<Foam::Field<Type>>
|
||||
Foam::PatchFunction1Types::UniformValueField<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
label sz =
|
||||
(
|
||||
this->faceValues_
|
||||
? this->patch_.size()
|
||||
: this->patch_.nPoints()
|
||||
);
|
||||
|
||||
tmp<Field<Type>> tfld
|
||||
(
|
||||
tmp<Field<Type>>::New
|
||||
(
|
||||
sz,
|
||||
uniformValuePtr_->integrate(x1, x2)
|
||||
)
|
||||
);
|
||||
return this->transform(tfld);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
42
src/meshTools/PatchFunction1/coordinateLabelScaling.C
Normal file
42
src/meshTools/PatchFunction1/coordinateLabelScaling.C
Normal file
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "coordinateScaling.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
Foam::tmp<Foam::Field<Foam::label>>
|
||||
Foam::coordinateScaling<Foam::label>::transform
|
||||
(
|
||||
const pointField& pos,
|
||||
const Field<label>& local
|
||||
) const
|
||||
{
|
||||
return local;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
144
src/meshTools/PatchFunction1/coordinateScaling.C
Normal file
144
src/meshTools/PatchFunction1/coordinateScaling.C
Normal file
@ -0,0 +1,144 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::coordinateScaling<Type>::coordinateScaling()
|
||||
:
|
||||
active_(false)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::coordinateScaling<Type>::coordinateScaling
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordSys_
|
||||
(
|
||||
dict.found(coordinateSystem::typeName_())
|
||||
? coordinateSystem::New(obr, dict)
|
||||
: nullptr
|
||||
),
|
||||
scale_(3),
|
||||
active_(coordSys_.valid())
|
||||
{
|
||||
for (direction dir = 0; dir < vector::nComponents; dir++)
|
||||
{
|
||||
const word key("scale" + Foam::name(dir+1));
|
||||
|
||||
if (dict.found(key))
|
||||
{
|
||||
scale_.set(dir, Function1<Type>::New(key, dict));
|
||||
active_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::coordinateScaling<Type>::coordinateScaling(const coordinateScaling& cs)
|
||||
:
|
||||
coordSys_(cs.coordSys_.clone()),
|
||||
scale_(cs.scale_),
|
||||
active_(cs.active_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::coordinateScaling<Type>::~coordinateScaling()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::coordinateScaling<Type>::transform
|
||||
(
|
||||
const pointField& pos,
|
||||
const Field<Type>& p0
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tfld(new Field<Type>(p0));
|
||||
Field<Type>& fld = tfld.ref();
|
||||
|
||||
if (coordSys_.valid())
|
||||
{
|
||||
const vectorField local(coordSys_->localPosition(pos));
|
||||
for (direction dir = 0; dir < vector::nComponents; dir++)
|
||||
{
|
||||
if (scale_.set(dir))
|
||||
{
|
||||
fld = cmptMultiply
|
||||
(
|
||||
fld,
|
||||
scale_[dir].value(local.component(dir))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return coordSys_->transform(pos, fld);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (direction dir = 0; dir < vector::nComponents; dir++)
|
||||
{
|
||||
if (scale_.set(dir))
|
||||
{
|
||||
fld = cmptMultiply
|
||||
(
|
||||
fld,
|
||||
scale_[dir].value(pos.component(dir))
|
||||
);
|
||||
}
|
||||
}
|
||||
return fld;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::coordinateScaling<Type>::writeEntry(Ostream& os) const
|
||||
{
|
||||
if (coordSys_.valid())
|
||||
{
|
||||
coordSys_->writeEntry(coordinateSystem::typeName_(), os);
|
||||
}
|
||||
forAll(scale_, dir)
|
||||
{
|
||||
if (scale_.set(dir))
|
||||
{
|
||||
scale_[dir].writeData(os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
142
src/meshTools/PatchFunction1/coordinateScaling.H
Normal file
142
src/meshTools/PatchFunction1/coordinateScaling.H
Normal file
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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::coordinateScaling
|
||||
|
||||
Description
|
||||
Helper class to wrap coordinate system and component-wise scaling
|
||||
|
||||
See also
|
||||
Foam::Function1Types
|
||||
|
||||
SourceFiles
|
||||
coordinateScaling.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateScaling_H
|
||||
#define coordinateScaling_H
|
||||
|
||||
#include "coordinateSystem.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class coordinateScaling Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class coordinateScaling
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Local co-ordinate system
|
||||
const autoPtr<coordinateSystem> coordSys_;
|
||||
|
||||
//- In local co-ordinate system component-wise scaling
|
||||
PtrList<Function1<Type>> scale_;
|
||||
|
||||
//- Cached whether any scaling or coordinate system
|
||||
bool active_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const coordinateScaling<Type>&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
coordinateScaling();
|
||||
|
||||
//- Construct from registry and dictionary
|
||||
coordinateScaling
|
||||
(
|
||||
const objectRegistry&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct copy
|
||||
coordinateScaling(const coordinateScaling&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~coordinateScaling();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Has any scaling or coordinate transformation
|
||||
bool active() const
|
||||
{
|
||||
return active_;
|
||||
}
|
||||
|
||||
//- Access to optional coordinate system
|
||||
const autoPtr<coordinateSystem>& coordSys() const
|
||||
{
|
||||
return coordSys_;
|
||||
}
|
||||
|
||||
//- Evaluate
|
||||
virtual tmp<Field<Type>> transform
|
||||
(
|
||||
const pointField& pos,
|
||||
const Field<Type>& local
|
||||
) const;
|
||||
|
||||
//- Write dictionary entry
|
||||
virtual void writeEntry(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
tmp<Field<label>> coordinateScaling<label>::transform
|
||||
(
|
||||
const pointField& pos,
|
||||
const Field<label>& local
|
||||
) const;
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "coordinateScaling.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
166
src/meshTools/PatchFunction1/makePatchFunction1s.C
Normal file
166
src/meshTools/PatchFunction1/makePatchFunction1s.C
Normal file
@ -0,0 +1,166 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ 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 "PatchFunction1.H"
|
||||
#include "fieldTypes.H"
|
||||
#include "ConstantField.H"
|
||||
#include "UniformValueField.H"
|
||||
#include "MappedFile.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Table.H"
|
||||
|
||||
#define makePatchFunction1s(Type) \
|
||||
makePatchFunction1(Type); \
|
||||
makePatchFunction1Type(ConstantField, Type); \
|
||||
makePatchFunction1Type(MappedFile, Type); \
|
||||
makePatchFunction1Type(UniformValueField, Type);
|
||||
|
||||
#define addUniformValueFieldFunction1s(F1Type, Type) \
|
||||
PatchFunction1<Type>::adddictionaryConstructorToTable \
|
||||
<PatchFunction1Types::UniformValueField<Type>> \
|
||||
add##F1Type##UniformValueField##Type##ConstructorToTable_(#F1Type);
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchFunction1(label);
|
||||
makePatchFunction1Type(ConstantField, label);
|
||||
|
||||
makePatchFunction1s(scalar);
|
||||
makePatchFunction1s(vector);
|
||||
makePatchFunction1s(sphericalTensor);
|
||||
makePatchFunction1s(symmTensor);
|
||||
makePatchFunction1s(tensor);
|
||||
|
||||
|
||||
//- Option1 : add UniformFieldValue under the same name as Function1
|
||||
// See makeFunction1s.C. Note that we do not need
|
||||
// Constant & Uniform
|
||||
addUniformValueFieldFunction1s(zero, scalar);
|
||||
addUniformValueFieldFunction1s(zero, vector);
|
||||
addUniformValueFieldFunction1s(zero, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(zero, symmTensor);
|
||||
addUniformValueFieldFunction1s(zero, tensor);
|
||||
|
||||
addUniformValueFieldFunction1s(one, scalar);
|
||||
addUniformValueFieldFunction1s(one, vector);
|
||||
addUniformValueFieldFunction1s(one, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(one, symmTensor);
|
||||
addUniformValueFieldFunction1s(one, tensor);
|
||||
|
||||
addUniformValueFieldFunction1s(polynomial, scalar);
|
||||
addUniformValueFieldFunction1s(polynomial, vector);
|
||||
addUniformValueFieldFunction1s(polynomial, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(polynomial, symmTensor);
|
||||
addUniformValueFieldFunction1s(polynomial, tensor);
|
||||
|
||||
addUniformValueFieldFunction1s(sine, scalar);
|
||||
addUniformValueFieldFunction1s(sine, vector);
|
||||
addUniformValueFieldFunction1s(sine, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(sine, symmTensor);
|
||||
addUniformValueFieldFunction1s(sine, tensor);
|
||||
|
||||
addUniformValueFieldFunction1s(square, scalar);
|
||||
addUniformValueFieldFunction1s(square, vector);
|
||||
addUniformValueFieldFunction1s(square, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(square, symmTensor);
|
||||
addUniformValueFieldFunction1s(square, tensor);
|
||||
|
||||
addUniformValueFieldFunction1s(csvFile, scalar);
|
||||
addUniformValueFieldFunction1s(csvFile, vector);
|
||||
addUniformValueFieldFunction1s(csvFile, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(csvFile, symmTensor);
|
||||
addUniformValueFieldFunction1s(csvFile, tensor);
|
||||
|
||||
addUniformValueFieldFunction1s(table, scalar);
|
||||
addUniformValueFieldFunction1s(table, vector);
|
||||
addUniformValueFieldFunction1s(table, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(table, symmTensor);
|
||||
addUniformValueFieldFunction1s(table, tensor);
|
||||
|
||||
addUniformValueFieldFunction1s(tableFile, scalar);
|
||||
addUniformValueFieldFunction1s(tableFile, vector);
|
||||
addUniformValueFieldFunction1s(tableFile, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(tableFile, symmTensor);
|
||||
addUniformValueFieldFunction1s(tableFile, tensor);
|
||||
|
||||
addUniformValueFieldFunction1s(scale, scalar);
|
||||
addUniformValueFieldFunction1s(scale, vector);
|
||||
addUniformValueFieldFunction1s(scale, sphericalTensor);
|
||||
addUniformValueFieldFunction1s(scale, symmTensor);
|
||||
addUniformValueFieldFunction1s(scale, tensor);
|
||||
|
||||
|
||||
////- Option2 : at static initialisation add all Function1 types.
|
||||
//// This does not work because we cannot guarantee that the Function1
|
||||
//// static initialisation has happened already.
|
||||
//template<class Type>
|
||||
//class addToUniform
|
||||
//{
|
||||
//public:
|
||||
// addToUniform()
|
||||
// {
|
||||
// // Get the Function1 table
|
||||
// typedef typename Function1<Type>::dictionaryConstructorTable
|
||||
// F1Type;
|
||||
// Function1<Type>::constructdictionaryConstructorTables();
|
||||
// const F1Type& F1Table =
|
||||
// *Function1<Type>::dictionaryConstructorTablePtr_;
|
||||
//
|
||||
// // Get the PatchFunction1 table
|
||||
// typedef typename PatchFunction1<Type>::dictionaryConstructorTable
|
||||
// PF1Type;
|
||||
//
|
||||
// PatchFunction1<Type>::constructdictionaryConstructorTables();
|
||||
// PF1Type& PF1Table =
|
||||
// *PatchFunction1<Type>::dictionaryConstructorTablePtr_;
|
||||
//
|
||||
// // Get the UniformValueField constructor
|
||||
// auto cstrIter =
|
||||
// PatchFunction1<Type>::dictionaryConstructorTablePtr_->cfind
|
||||
// (
|
||||
// PatchFunction1Types::UniformValueField<Type>::typeName
|
||||
// );
|
||||
//
|
||||
// // Add the UniformValueField under the Function1 name
|
||||
// forAllConstIter(typename F1Type, F1Table, iter)
|
||||
// {
|
||||
// //bool ok =
|
||||
// PF1Table.insert(iter.key(), cstrIter());
|
||||
// //if (!ok)
|
||||
// //{
|
||||
// // std::cout<< "** problem" << std::endl;
|
||||
// //}
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
//static const addToUniform<scalar> addScalar;
|
||||
//static const addToUniform<vector> addVector;
|
||||
//static const addToUniform<sphericalTensor> addSphericalTensor;
|
||||
//static const addToUniform<symmTensor> addSymmTensor;
|
||||
//static const addToUniform<tensor> addTensor;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user