Merge remote-tracking branch 'upstream/develop' into wp3-directional-refinement

This commit is contained in:
mattijs
2017-12-21 13:24:21 +00:00
948 changed files with 107557 additions and 3249 deletions

View File

@ -40,6 +40,7 @@ wmakeLnInclude -u fvOptions
wmake $targetType finiteVolume
wmake $targetType lagrangian/basic
wmake $targetType lagrangian/distributionModels
wmake $targetType finiteArea
wmake $targetType genericPatchFields
conversion/Allwmake $targetType $*

View File

@ -106,7 +106,14 @@ inline Foam::Istream& Foam::UIPstream::readStringFromBuffer(std::string& str)
size_t len;
readFromBuffer(len);
str.assign(&externalBuf_[externalBufPosition_], len);
if (len == 0)
{
str.clear();
}
else
{
str.assign(&externalBuf_[externalBufPosition_], len);
}
externalBufPosition_ += len;
checkEof();

View File

@ -54,7 +54,7 @@ bool Foam::functionEntries::includeFuncEntry::execute
)
{
const word fNameArgs(is);
HashSet<word> selectedFields;
HashSet<wordRe> selectedFields;
return functionObjectList::readFunctionObject
(

View File

@ -141,6 +141,12 @@ bool Foam::functionObject::read(const dictionary& dict)
}
bool Foam::functionObject::execute(const label)
{
return true;
}
bool Foam::functionObject::end()
{
return true;

View File

@ -222,13 +222,19 @@ public:
const word& name() const;
//- Read and set the function object if its data have changed
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict);
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual executeControl behaviour and
// forces execution (used in post-processing mode)
virtual bool execute() = 0;
//- Execute using the specified subIndex.
// The base implementation is a no-op.
// \param subIndex an execution sub-index corresponding to a
// sub-cycle or something similar.
virtual bool execute(const label subIndex);
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and
// forces writing always (used in post-processing mode)
@ -245,9 +251,11 @@ public:
virtual bool filesModified() const;
//- Update for changes of mesh
// The base implementation is a no-op.
virtual void updateMesh(const mapPolyMesh& mpm);
//- Update for changes of mesh
// The base implementation is a no-op.
virtual void movePoints(const polyMesh& mesh);
};

View File

@ -32,6 +32,7 @@ License
//#include "IFstream.H"
#include "dictionaryEntry.H"
#include "stringOps.H"
#include "wordRes.H"
#include "Tuple2.H"
#include "etcFiles.H"
#include "IOdictionary.H"
@ -175,7 +176,7 @@ bool Foam::functionObjectList::readFunctionObject
(
const string& funcNameArgs,
dictionary& functionsDict,
HashSet<word>& requiredFields,
HashSet<wordRe>& requiredFields,
const word& region
)
{
@ -189,7 +190,7 @@ bool Foam::functionObjectList::readFunctionObject
word funcName(funcNameArgs);
int argLevel = 0;
wordList args;
wordReList args;
List<Tuple2<word, string>> namedArgs;
bool namedArg = false;
@ -236,9 +237,12 @@ bool Foam::functionObjectList::readFunctionObject
{
args.append
(
word::validate
wordRe
(
funcNameArgs.substr(start, i - start)
word::validate
(
funcNameArgs.substr(start, i - start)
)
)
);
}
@ -309,11 +313,11 @@ bool Foam::functionObjectList::readFunctionObject
}
else if (funcDict.found("field"))
{
requiredFields.insert(word(funcDict.lookup("field")));
requiredFields.insert(wordRe(funcDict.lookup("field")));
}
else if (funcDict.found("fields"))
{
requiredFields.insert(wordList(funcDict.lookup("fields")));
requiredFields.insert(wordReList(funcDict.lookup("fields")));
}
// Insert named arguments
@ -383,7 +387,7 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
const argList& args,
const Time& runTime,
dictionary& controlDict,
HashSet<word>& requiredFields
HashSet<wordRe>& requiredFields
)
{
autoPtr<functionObjectList> functionsPtr;
@ -579,6 +583,7 @@ bool Foam::functionObjectList::execute()
}
}
}
// Force writing of state dictionary after function object execution
if (time_.writeTime())
{
@ -600,6 +605,49 @@ bool Foam::functionObjectList::execute()
}
bool Foam::functionObjectList::execute(const label subIndex)
{
bool ok = execution_;
if (ok)
{
forAll(*this, obji)
{
functionObject& funcObj = operator[](obji);
ok = funcObj.execute(subIndex) && ok;
}
}
return ok;
}
bool Foam::functionObjectList::execute
(
const wordRes& functionNames,
const label subIndex
)
{
bool ok = execution_;
if (ok && functionNames.size())
{
forAll(*this, obji)
{
functionObject& funcObj = operator[](obji);
if (functionNames.match(funcObj.name()))
{
ok = funcObj.execute(subIndex) && ok;
}
}
}
return ok;
}
bool Foam::functionObjectList::end()
{
bool ok = true;

View File

@ -52,8 +52,10 @@ SourceFiles
namespace Foam
{
class mapPolyMesh;
// Forward declarations
class argList;
class mapPolyMesh;
class wordRes;
/*---------------------------------------------------------------------------*\
Class functionObjectList Declaration
@ -94,19 +96,19 @@ class functionObjectList
void createStateDict() const;
//- Remove and return the function object pointer by name,
// and returns the old index via the parameter.
//- and returns the old index via the parameter.
// Returns a nullptr (and index -1) if it didn't exist
functionObject* remove(const word&, label& oldIndex);
functionObject* remove(const word& key, label& oldIndex);
//- Search the specified directory for functionObject
// configuration files, add to the given map and recurse
//- configuration files, add to the given map and recurse
static void listDir(const fileName& dir, HashSet<word>& foMap);
//- Disallow default bitwise copy construct
functionObjectList(const functionObjectList&);
functionObjectList(const functionObjectList&) = delete;
//- Disallow default bitwise assignment
void operator=(const functionObjectList&);
void operator=(const functionObjectList&) = delete;
public:
@ -114,7 +116,7 @@ public:
// Static data members
//- Default relative path to the directory structure
// containing the functionObject dictionary files
//- containing the functionObject dictionary files
static fileName functionObjectDictPath;
@ -153,7 +155,7 @@ public:
const argList& args,
const Time& runTime,
dictionary& controlDict,
HashSet<word>& requiredFields
HashSet<wordRe>& requiredFields
);
@ -188,7 +190,7 @@ public:
label findObjectID(const word& name) const;
//- Print a list of functionObject configuration files in
// user/group/shipped directories.
//- user/group/shipped directories.
// The search scheme allows for version-specific and
// version-independent files using the following hierarchy:
// - \b user settings:
@ -205,7 +207,7 @@ public:
static void list();
//- Search for functionObject dictionary file in
// user/group/shipped directories.
//- user/group/shipped directories.
// The search scheme allows for version-specific and
// version-independent files using the following hierarchy:
// - \b user settings:
@ -234,7 +236,7 @@ public:
(
const string& funcNameArgs0,
dictionary& functionsDict,
HashSet<word>& requiredFields,
HashSet<wordRe>& requiredFields,
const word& region = word::null
);
@ -258,6 +260,18 @@ public:
// forces execution (used in post-processing mode)
bool execute();
//- Execute function objects using the specified subIndex.
// \param subIndex an execution sub-index corresponding to a
// sub-cycle or something similar
bool execute(const label subIndex);
//- Execute a subset of function objects using the specified subIndex.
// \param functionNames names or regex of existing functions to
// execute
// \param subIndex an execution sub-index corresponding to a
// sub-cycle or something similar
bool execute(const wordRes& functionNames, const label subIndex);
//- Called when Time::run() determines that the time-loop exits
bool end();

View File

@ -96,7 +96,7 @@ if (argList::postProcess(argc, argv))
// if not constructed from runTime
dictionary functionsDict;
HashSet<word> selectedFields;
HashSet<wordRe> selectedFields;
// Construct functionObjectList
autoPtr<functionObjectList> functionsPtr

View File

@ -450,6 +450,18 @@ bool Foam::functionObjects::timeControl::execute()
}
bool Foam::functionObjects::timeControl::execute(const label subIndex)
{
if (active())
{
// Call underlying function object directly
foPtr_->execute(subIndex);
}
return true;
}
bool Foam::functionObjects::timeControl::write()
{
if (active() && (postProcess || writeControl_.execute()))
@ -726,10 +738,8 @@ bool Foam::functionObjects::timeControl::read(const dictionary& dict)
return true;
}
else
{
return false;
}
return false;
}

View File

@ -206,6 +206,9 @@ public:
// forces execution (used in post-processing mode)
virtual bool execute();
//- Execute using the specified subIndex.
virtual bool execute(const label subIndex);
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and
// forces writing (used in post-processing mode)

View File

@ -1283,6 +1283,37 @@ Foam::argList::~argList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::argList::optionCount(const UList<word>& optionNames) const
{
label n = 0;
for (const word& optName : optionNames)
{
if (options_.found(optName))
{
++n;
}
}
return n;
}
Foam::label Foam::argList::optionCount
(
std::initializer_list<word> optionNames
) const
{
label n = 0;
for (const word& optName : optionNames)
{
if (options_.found(optName))
{
++n;
}
}
return n;
}
bool Foam::argList::setOption(const word& optionName, const string& param)
{
// Some options are always protected

View File

@ -102,7 +102,7 @@ SourceFiles
#include "fileName.H"
#include "parRun.H"
#include "OSspecific.H"
#include "ITstream.H"
#include "StringStream.H"
#include <utility>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -302,8 +302,14 @@ public:
//- Return true if the named option is found
inline bool optionFound(const word& optionName) const;
//- Return an input token stream for the named option
inline ITstream optionLookup(const word& optionName) const;
//- Return how many of the specified options were used
label optionCount(const UList<word>& optionNames) const;
//- Return how many of the specified options were used
label optionCount(std::initializer_list<word> optionNames) const;
//- Return an input stream for the named option
inline IStringStream optionLookup(const word& optionName) const;
//- Read a value from the named option
template<class T>

View File

@ -105,12 +105,12 @@ inline bool Foam::argList::optionFound(const word& optionName) const
}
inline Foam::ITstream Foam::argList::optionLookup
inline Foam::IStringStream Foam::argList::optionLookup
(
const word& optionName
) const
{
return ITstream(optionName, options_[optionName]);
return IStringStream(options_[optionName]);
}

View File

@ -227,12 +227,6 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fileOperations::collatedFileOperation::~collatedFileOperation()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::fileOperations::collatedFileOperation::objectPath

View File

@ -99,7 +99,7 @@ public:
//- Destructor
virtual ~collatedFileOperation();
virtual ~collatedFileOperation() = default;
// Member Functions

View File

@ -54,10 +54,10 @@ namespace Foam
false
)
);
word fileOperation::processorsDir = "processors";
}
Foam::word Foam::fileOperation::processorsDir = "processors";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -143,30 +143,25 @@ bool Foam::fileOperation::isFileOrDir(const bool isFile, const fileName& f)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileOperation::fileOperation()
{}
Foam::autoPtr<Foam::fileOperation> Foam::fileOperation::New
(
const word& type,
const word& handlerType,
const bool verbose
)
{
if (debug)
{
InfoInFunction << "Constructing fileOperation" << endl;
InfoInFunction << "Constructing fileHandler" << endl;
}
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(type);
auto cstrIter = wordConstructorTablePtr_->cfind(handlerType);
if (cstrIter == wordConstructorTablePtr_->end())
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown fileOperation type "
<< type << nl << nl
<< "Valid fileOperation types are" << endl
<< "Unknown fileHandler type "
<< handlerType << nl << nl
<< "Valid fileHandler types :" << endl
<< wordConstructorTablePtr_->sortedToc()
<< abort(FatalError);
}
@ -175,12 +170,6 @@ Foam::autoPtr<Foam::fileOperation> Foam::fileOperation::New
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fileOperation::~fileOperation()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::fileOperation::objectPath
@ -278,10 +267,8 @@ Foam::fileName Foam::fileOperation::filePath(const fileName& fName) const
{
return fName;
}
else
{
return fileName::null;
}
return fileName::null;
}

View File

@ -24,6 +24,15 @@ License
Class
Foam::fileOperation
Description
An encapsulation of filesystem-related operations.
Namespace
Foam::fileOperations
Description
Namespace for implementations of a fileOperation
\*---------------------------------------------------------------------------*/
#ifndef fileOperation_H
@ -75,7 +84,7 @@ public:
// Static data
//- Return the processors directory name (usually "processors")
//- The processors directory name (usually "processors")
static word processorsDir;
//- Default fileHandler
@ -108,7 +117,7 @@ public:
// Constructors
//- Construct null
fileOperation();
fileOperation() = default;
// Declare run-time constructor selection table
@ -127,12 +136,16 @@ public:
// Selectors
//- Select type
static autoPtr<fileOperation> New(const word& type, const bool verbose);
//- Select fileHandler-type
static autoPtr<fileOperation> New
(
const word& handlerType,
const bool verbose
);
//- Destructor
virtual ~fileOperation();
virtual ~fileOperation() = default;
// Member Functions

View File

@ -489,13 +489,6 @@ masterUncollatedFileOperation
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fileOperations::masterUncollatedFileOperation::
~masterUncollatedFileOperation()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileOperations::masterUncollatedFileOperation::mkDir

View File

@ -427,7 +427,7 @@ public:
//- Destructor
virtual ~masterUncollatedFileOperation();
virtual ~masterUncollatedFileOperation() = default;
// Member Functions

View File

@ -161,12 +161,6 @@ Foam::fileOperations::uncollatedFileOperation::uncollatedFileOperation
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fileOperations::uncollatedFileOperation::~uncollatedFileOperation()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileOperations::uncollatedFileOperation::mkDir

View File

@ -77,7 +77,7 @@ public:
//- Destructor
virtual ~uncollatedFileOperation();
virtual ~uncollatedFileOperation() = default;
// Member Functions

View File

@ -27,7 +27,6 @@ Namespace
Description
Namespace for OpenFOAM
Global
Foam::FOAMversion
@ -67,6 +66,9 @@ namespace Foam
extern const char* const FOAMversion;
extern const char* const FOAMbuild;
extern const std::string FOAMbuildArch;
//- Additional OpenFOAM modules
namespace Module {}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -233,10 +233,10 @@ public:
void reorder(const labelUList&, const bool validBoundary);
//- writeData member function required by regIOobject
bool writeData(Ostream&) const;
virtual bool writeData(Ostream&) const;
//- Write using given format, version and form uncompression
bool writeObject
virtual bool writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -384,15 +384,65 @@ kOmegaSSTBase<BasicEddyViscosityModel>::kOmegaSSTBase
IOobject::AUTO_WRITE
),
this->mesh_
),
decayControl_
(
Switch::lookupOrAddToDict
(
"decayControl",
this->coeffDict_,
false
)
),
kInf_
(
dimensioned<scalar>::lookupOrAddToDict
(
"kInf",
this->coeffDict_,
k_.dimensions(),
0
)
),
omegaInf_
(
dimensioned<scalar>::lookupOrAddToDict
(
"omegaInf",
this->coeffDict_,
omega_.dimensions(),
0
)
)
{
bound(k_, this->kMin_);
bound(omega_, this->omegaMin_);
setDecayControl(this->coeffDict_);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasicEddyViscosityModel>
void kOmegaSSTBase<BasicEddyViscosityModel>::setDecayControl
(
const dictionary& dict
)
{
decayControl_.readIfPresent("decayControl", this->coeffDict());
if (decayControl_)
{
kInf_.read(this->coeffDict());
omegaInf_.read(this->coeffDict());
Info<< " Employing decay control with kInf:" << kInf_
<< " and omegaInf:" << omegaInf_ << endl;
}
}
template<class BasicEddyViscosityModel>
bool kOmegaSSTBase<BasicEddyViscosityModel>::read()
{
@ -412,6 +462,8 @@ bool kOmegaSSTBase<BasicEddyViscosityModel>::read()
c1_.readIfPresent(this->coeffDict());
F3_.readIfPresent("F3", this->coeffDict());
setDecayControl(this->coeffDict());
return true;
}
else
@ -476,6 +528,7 @@ void kOmegaSSTBase<BasicEddyViscosityModel>::correct()
alpha()*rho()*(F1() - scalar(1))*CDkOmega()/omega_(),
omega_
)
+ alpha()*rho()*beta*sqr(omegaInf_)
+ Qsas(S2(), gamma, beta)
+ omegaSource()
+ fvOptions(alpha, rho, omega_)
@ -499,6 +552,7 @@ void kOmegaSSTBase<BasicEddyViscosityModel>::correct()
alpha()*rho()*Pk(G)
- fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
- fvm::Sp(alpha()*rho()*epsilonByk(F1, tgradU()), k_)
+ alpha()*rho()*betaStar_*omegaInf_*kInf_
+ kSource()
+ fvOptions(alpha, rho, k_)
);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,13 +52,21 @@ Description
and the addition of the optional F3 term for rough walls from
\verbatim
Hellsten, A. (1998).
"Some Improvements in Menter's k-omega-SST turbulence model"
Some Improvements in Menter's k-omega-SST turbulence model
29th AIAA Fluid Dynamics Conference, AIAA-98-2554.
\endverbatim
and the optional decay control from:
\verbatim
Spalart, P. R. and Rumsey, C. L. (2007).
Effective Inflow Conditions for Turbulence Models in Aerodynamic
Calculations
AIAA Journal, 45(10), 2544 - 2553.
\endverbatim
Note that this implementation is written in terms of alpha diffusion
coefficients rather than the more traditional sigma (alpha = 1/sigma) so
that the blending can be applied to all coefficuients in a consistent
that the blending can be applied to all coefficients in a consistent
manner. The paper suggests that sigma is blended but this would not be
consistent with the blending of the k-epsilon and k-omega models.
@ -76,19 +84,24 @@ Description
\verbatim
kOmegaSSTBaseCoeffs
{
alphaK1 0.85;
alphaK2 1.0;
alphaOmega1 0.5;
alphaOmega2 0.856;
beta1 0.075;
beta2 0.0828;
betaStar 0.09;
gamma1 5/9;
gamma2 0.44;
a1 0.31;
b1 1.0;
c1 10.0;
F3 no;
alphaK1 0.85;
alphaK2 1.0;
alphaOmega1 0.5;
alphaOmega2 0.856;
beta1 0.075;
beta2 0.0828;
betaStar 0.09;
gamma1 5/9;
gamma2 0.44;
a1 0.31;
b1 1.0;
c1 10.0;
F3 no;
// Optional decay control
decayControl yes;
kInf \<far-field k value\>;
omegaInf \<far-field omega value\>;
}
\endverbatim
@ -145,6 +158,7 @@ protected:
dimensionedScalar b1_;
dimensionedScalar c1_;
//- Flag to include the F3 term
Switch F3_;
@ -159,8 +173,18 @@ protected:
volScalarField omega_;
// Decay control
//- Flag to include the decay control
Switch decayControl_;
dimensionedScalar kInf_;
dimensionedScalar omegaInf_;
// Protected Member Functions
void setDecayControl(const dictionary& dict);
virtual tmp<volScalarField> F1(const volScalarField& CDkOmega) const;
virtual tmp<volScalarField> F2() const;
virtual tmp<volScalarField> F3() const;

View File

@ -89,7 +89,7 @@ tmp<volScalarField> kOmegaSSTDDES<BasicTurbulenceModel>::dTilda
return max
(
lRAS
lRAS
- fd(magGradU)
*max
(

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,6 +26,7 @@ License
#include "IDDESDelta.H"
#include "addToRunTimeSelectionTable.H"
#include "wallDist.H"
#include "maxDeltaxyz.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -43,7 +44,7 @@ namespace LESModels
void Foam::LESModels::IDDESDelta::calcDelta()
{
const volScalarField& hmax = hmax_;
const volScalarField& hmax = hmaxPtr_();
const fvMesh& mesh = turbulenceModel_.mesh();
// Wall-normal vectors
@ -143,12 +144,7 @@ Foam::LESModels::IDDESDelta::IDDESDelta
)
:
LESdelta(name, turbulence),
hmax_
(
IOobject::groupName("hmax", turbulence.U().group()),
turbulence,
dict
),
hmaxPtr_(nullptr),
Cw_
(
dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar>
@ -158,6 +154,33 @@ Foam::LESModels::IDDESDelta::IDDESDelta
)
)
{
if (dict.optionalSubDict(type() + "Coeffs").found("hmax"))
{
// User-defined hmax
hmaxPtr_ =
LESdelta::New
(
IOobject::groupName("hmax", turbulence.U().group()),
turbulence,
dict.optionalSubDict(type() + "Coeffs"),
"hmax"
);
}
else
{
Info<< "Employing " << maxDeltaxyz::typeName << " for hmax" << endl;
hmaxPtr_.reset
(
new maxDeltaxyz
(
IOobject::groupName("hmax", turbulence.U().group()),
turbulence,
dict.optionalSubDict(type() + "Coeffs")
)
);
}
calcDelta();
}
@ -178,7 +201,7 @@ void Foam::LESModels::IDDESDelta::correct()
{
if (turbulenceModel_.mesh().changing())
{
hmax_.correct();
hmaxPtr_->correct();
calcDelta();
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,7 +37,7 @@ SourceFiles
#ifndef LESModels_IDDESDelta_H
#define LESModels_IDDESDelta_H
#include "maxDeltaxyz.H"
#include "LESdelta.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,9 @@ class IDDESDelta
{
// Private data
maxDeltaxyz hmax_;
//- Run-time selectable delta for hmax
// Defaults to the maxDeltaXYZ model if not supplied
autoPtr<LESdelta> hmaxPtr_;
scalar Cw_;
@ -102,7 +104,7 @@ public:
//- Return the hmax delta field
const volScalarField& hmax() const
{
return hmax_;
return hmaxPtr_();
}
// Correct values

View File

@ -66,12 +66,13 @@ Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
(
const word& name,
const turbulenceModel& turbulence,
const dictionary& dict
const dictionary& dict,
const word& lookupName
)
{
const word deltaType(dict.lookup("delta"));
const word deltaType(dict.lookup(lookupName));
Info<< "Selecting LES delta type " << deltaType << endl;
Info<< "Selecting LES " << lookupName << " type " << deltaType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(deltaType);
@ -94,12 +95,13 @@ Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
const word& name,
const turbulenceModel& turbulence,
const dictionary& dict,
const dictionaryConstructorTable& additionalConstructors
const dictionaryConstructorTable& additionalConstructors,
const word& lookupName
)
{
const word deltaType(dict.lookup("delta"));
const word deltaType(dict.lookup(lookupName));
Info<< "Selecting LES delta type " << deltaType << endl;
Info<< "Selecting LES " << lookupName << " type " << deltaType << endl;
// First any additional ones
{

View File

@ -108,7 +108,8 @@ public:
(
const word& name,
const turbulenceModel& turbulence,
const dictionary& dict
const dictionary& dict,
const word& lookupName = "delta"
);
//- Return a reference to the selected LES delta
@ -117,7 +118,8 @@ public:
const word& name,
const turbulenceModel& turbulence,
const dictionary& dict,
const dictionaryConstructorTable&
const dictionaryConstructorTable& additionalConstructors,
const word& lookupName = "delta"
);

View File

@ -64,14 +64,14 @@ void Foam::LESModels::maxDeltaxyz::calcDelta()
const point& fc = faceC[facei];
const vector& n = faceN[facei];
scalar tmp = magSqr(n*(n & (fc - cc)));
scalar tmp = mag(n & (fc - cc));
if (tmp > deltaMaxTmp)
{
deltaMaxTmp = tmp;
}
}
hmax[celli] = deltaCoeff_*Foam::sqrt(deltaMaxTmp);
hmax[celli] = deltaCoeff_*deltaMaxTmp;
}
if (nD == 3)
@ -113,7 +113,7 @@ Foam::LESModels::maxDeltaxyz::maxDeltaxyz
dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar>
(
"deltaCoeff",
1
2
)
)
{

View File

@ -108,7 +108,10 @@ Foam::LESModels::vanDriestDelta::vanDriestDelta
(
IOobject::groupName("geometricDelta", turbulence.U().group()),
turbulence,
dict.optionalSubDict(type() + "Coeffs")
// Note: cannot use optionalSubDict - if no *Coeffs dict the
// code will get stuck in a loop attempting to read the delta entry
// - consider looking up "geometricDelta" instead of "delta"?
dict.subDict(type() + "Coeffs")
)
),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),

View File

@ -1,8 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lfiniteArea \
-lmeshTools

View File

@ -40,6 +40,7 @@ SourceFiles
#include "OFstream.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "areaFields.H"
#include "indirectPrimitivePatch.H"
#include "foamVtkOutputOptions.H"
@ -152,6 +153,13 @@ public:
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
);
//- Write surface field
template<class Type>
void write
(
const GeometricField<Type, faPatchField, areaMesh>& field
);
// Write fields (collectively)
@ -164,6 +172,16 @@ public:
const GeometricField<Type, fvsPatchField, surfaceMesh>
>& sflds
);
//- Write surface fields
template<class Type>
void write
(
const UPtrList
<
const GeometricField<Type, faPatchField, areaMesh>
>& sflds
);
};

View File

@ -74,8 +74,7 @@ void Foam::vtk::surfaceMeshWriter::write
}
else
{
format().openDataArray<float, nCmpt>(field.name())
.closeTag();
format().openDataArray<float, nCmpt>(field.name()).closeTag();
}
format().writeSize(payLoad);
@ -90,6 +89,36 @@ void Foam::vtk::surfaceMeshWriter::write
}
template<class Type>
void Foam::vtk::surfaceMeshWriter::write
(
const GeometricField<Type, faPatchField, areaMesh>& field
)
{
const int nCmpt(pTraits<Type>::nComponents);
const uint64_t payLoad(pp_.size() * nCmpt * sizeof(float));
if (legacy_)
{
legacy::floatField(os(), field.name(), nCmpt, pp_.size());
}
else
{
format().openDataArray<float, nCmpt>(field.name()).closeTag();
}
format().writeSize(payLoad);
vtk::writeList(format(), field.primitiveField());
format().flush();
if (!legacy_)
{
format().endDataArray();
}
}
template<class Type>
void Foam::vtk::surfaceMeshWriter::write
(
@ -106,4 +135,20 @@ void Foam::vtk::surfaceMeshWriter::write
}
template<class Type>
void Foam::vtk::surfaceMeshWriter::write
(
const UPtrList
<
const GeometricField<Type, faPatchField, areaMesh>
>& sflds
)
{
for (const auto& field : sflds)
{
write(field);
}
}
// ************************************************************************* //

View File

@ -176,9 +176,6 @@ class enrichedPatch
//- Estimated ratio of original-to-enriched face size
static const label enrichedFaceRatio_;
//- Estimated number of master face hits by slave points
static const label nFaceHits_;
//- Size of face on which the check is forced
static const label maxFaceSizeDebug_;

View File

@ -28,11 +28,6 @@ License
#include "demandDrivenData.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::label Foam::enrichedPatch::nFaceHits_ = 4;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::enrichedPatch::calcMasterPointFaces() const
@ -63,11 +58,8 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
for (const label pointi : curFace)
{
DynamicList<label>& dynLst = mpf(pointi); // Get or create
dynLst.reserve(primitiveMesh::facesPerPoint_); // Min size for list
dynLst.append(facei);
// Existing or auto-vivify DynamicList
mpf(pointi).append(facei);
}
}
@ -86,11 +78,8 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
// Index of projected point corresponding to this slave point
const label mergedPointi = pointMergeMap()[slaveMeshPoints[pointi]];
DynamicList<label>& dynLst = mpf(mergedPointi); // Get or create
dynLst.reserve(primitiveMesh::facesPerPoint_); // Min size for list
dynLst.append(slavePointFaceHits_[pointi].hitObject());
// Existing or auto-vivify DynamicList
mpf(mergedPointi).append(slavePointFaceHits_[pointi].hitObject());
}
}

124
src/finiteArea/Make/files Normal file
View File

@ -0,0 +1,124 @@
faMesh/faGlobalMeshData/faGlobalMeshData.C
faMesh/faMesh.C
faMesh/faMeshDemandDrivenData.C
faMesh/faMeshUpdate.C
faMesh/faBoundaryMesh/faBoundaryMesh.C
faPatches = faMesh/faPatches
$(faPatches)/faPatch/faPatch.C
$(faPatches)/faPatch/faPatchNew.C
$(faPatches)/basic/coupled/coupledFaPatch.C
$(faPatches)/constraint/empty/emptyFaPatch.C
$(faPatches)/constraint/processor/processorFaPatch.C
$(faPatches)/constraint/wedge/wedgeFaPatch.C
$(faPatches)/constraint/cyclic/cyclicFaPatch.C
$(faPatches)/constraint/symmetry/symmetryFaPatch.C
faMeshMapper = faMesh/faMeshMapper
$(faMeshMapper)/faMeshMapper.C
$(faMeshMapper)/faAreaMapper.C
$(faMeshMapper)/faEdgeMapper.C
$(faMeshMapper)/faPatchMapper.C
faPatchFields = fields/faPatchFields
$(faPatchFields)/faPatchField/faPatchFields.C
basicFaPatchFields = $(faPatchFields)/basic
$(basicFaPatchFields)/basicSymmetry/basicSymmetryFaPatchScalarField.C
$(basicFaPatchFields)/calculated/calculatedFaPatchFields.C
$(basicFaPatchFields)/coupled/coupledFaPatchFields.C
$(basicFaPatchFields)/zeroGradient/zeroGradientFaPatchFields.C
$(basicFaPatchFields)/fixedValue/fixedValueFaPatchFields.C
$(basicFaPatchFields)/fixedGradient/fixedGradientFaPatchFields.C
$(basicFaPatchFields)/mixed/mixedFaPatchFields.C
$(basicFaPatchFields)/transform/transformFaPatchFields.C
$(basicFaPatchFields)/transform/transformFaPatchScalarField.C
constraintFaPatchFields = $(faPatchFields)/constraint
$(constraintFaPatchFields)/empty/emptyFaPatchFields.C
$(constraintFaPatchFields)/processor/processorFaPatchFields.C
$(constraintFaPatchFields)/processor/processorFaPatchScalarField.C
$(constraintFaPatchFields)/wedge/wedgeFaPatchFields.C
$(constraintFaPatchFields)/wedge/wedgeFaPatchScalarField.C
$(constraintFaPatchFields)/cyclic/cyclicFaPatchFields.C
$(constraintFaPatchFields)/symmetry/symmetryFaPatchFields.C
derivedFaPatchFields = $(faPatchFields)/derived
$(derivedFaPatchFields)/fixedValueOutflow/fixedValueOutflowFaPatchFields.C
$(derivedFaPatchFields)/inletOutlet/inletOutletFaPatchFields.C
$(derivedFaPatchFields)/slip/slipFaPatchFields.C
$(derivedFaPatchFields)/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.C
$(derivedFaPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C
faePatchFields = fields/faePatchFields
$(faePatchFields)/faePatchField/faePatchFields.C
basicFaePatchFields = $(faePatchFields)/basic
$(basicFaePatchFields)/calculated/calculatedFaePatchFields.C
$(basicFaePatchFields)/coupled/coupledFaePatchFields.C
$(basicFaePatchFields)/fixedValue/fixedValueFaePatchFields.C
constraintFaePatchFields = $(faePatchFields)/constraint
$(constraintFaePatchFields)/empty/emptyFaePatchFields.C
$(constraintFaePatchFields)/processor/processorFaePatchFields.C
$(constraintFaePatchFields)/wedge/wedgeFaePatchFields.C
$(constraintFaePatchFields)/cyclic/cyclicFaePatchFields.C
$(constraintFaePatchFields)/symmetry/symmetryFaePatchFields.C
fields/areaFields/areaFields.C
fields/edgeFields/edgeFields.C
faMatrices/faMatrices.C
faMatrices/faScalarMatrix/faScalarMatrix.C
edgeInterpolation = interpolation/edgeInterpolation
$(edgeInterpolation)/edgeInterpolation.C
$(edgeInterpolation)/edgeInterpolationScheme/edgeInterpolationSchemes.C
schemes = $(edgeInterpolation)/schemes
$(schemes)/linear/linearEdgeInterpolationMake.C
$(schemes)/upwind/upwindEdgeInterpolationMake.C
$(schemes)/linearUpwind/linearUpwindEdgeInterpolationMake.C
$(schemes)/Gamma/GammaEdgeInterpolationMake.C
$(schemes)/blended/blendedEdgeInterpolationMake.C
finiteArea/fa/fa.C
finiteArea/faSchemes/faSchemes.C
ddtSchemes = finiteArea/ddtSchemes
$(ddtSchemes)/faDdtScheme/faDdtSchemes.C
$(ddtSchemes)/steadyStateFaDdtScheme/steadyStateFaDdtSchemes.C
$(ddtSchemes)/EulerFaDdtScheme/EulerFaDdtSchemes.C
$(ddtSchemes)/backwardFaDdtScheme/backwardFaDdtSchemes.C
$(ddtSchemes)/boundedBackwardFaDdtScheme/boundedBackwardFaDdtScheme.C
divSchemes = finiteArea/divSchemes
finiteArea/fam/vectorFamDiv.C
$(divSchemes)/faDivScheme/faDivSchemes.C
$(divSchemes)/gaussFaDivScheme/gaussFaDivSchemes.C
gradSchemes = finiteArea/gradSchemes
$(gradSchemes)/faGradScheme/faGradSchemes.C
$(gradSchemes)/gaussFaGrad/gaussFaGrads.C
$(gradSchemes)/leastSquaresFaGrad/leastSquaresFaVectors.C
$(gradSchemes)/leastSquaresFaGrad/leastSquaresFaGrads.C
limitedGradSchemes = $(gradSchemes)/limitedGradSchemes
$(limitedGradSchemes)/faceLimitedFaGrad/faceLimitedFaGrads.C
$(limitedGradSchemes)/edgeLimitedFaGrad/edgeLimitedFaGrads.C
lnGradSchemes = finiteArea/lnGradSchemes
$(lnGradSchemes)/lnGradScheme/lnGradSchemes.C
$(lnGradSchemes)/correctedLnGrad/correctedLnGrads.C
$(lnGradSchemes)/limitedLnGrad/limitedLnGrads.C
$(lnGradSchemes)/fourthLnGrad/fourthLnGrads.C
laplacianSchemes = finiteArea/laplacianSchemes
$(laplacianSchemes)/faLaplacianScheme/faLaplacianSchemes.C
$(laplacianSchemes)/gaussFaLaplacianScheme/gaussFaLaplacianSchemes.C
convectionSchemes = finiteArea/convectionSchemes
$(convectionSchemes)/faConvectionScheme/faConvectionSchemes.C
$(convectionSchemes)/gaussFaConvectionScheme/gaussFaConvectionSchemes.C
LIB = $(FOAM_LIBBIN)/libfiniteArea

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lmeshTools

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::areaMesh
Description
Mesh data needed to do the Finite Area discretisation.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef areaFaMesh_H
#define areaFaMesh_H
#include "GeoMesh.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class areaMesh Declaration
\*---------------------------------------------------------------------------*/
class areaMesh
:
public GeoMesh<faMesh>
{
public:
explicit areaMesh(const faMesh& mesh)
:
GeoMesh<faMesh>(mesh)
{}
label size() const
{
return size(mesh_);
}
static label size(const Mesh& mesh)
{
return mesh.nFaces();
}
const areaVectorField& C()
{
return mesh_.areaCentres();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::edgeMesh
Description
Mesh data needed to do the Finite Area discretisation.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef edgeFaMesh_H
#define edgeFaMesh_H
#include "GeoMesh.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class edgeMesh Declaration
\*---------------------------------------------------------------------------*/
class edgeMesh
:
public GeoMesh<faMesh>
{
public:
explicit edgeMesh(const faMesh& mesh)
:
GeoMesh<faMesh>(mesh)
{}
label size() const
{
return size(mesh_);
}
static label size(const Mesh& mesh)
{
return mesh.nInternalEdges();
}
const edgeVectorField& C()
{
return mesh_.edgeCentres();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Description
Finite-Volume matrix member static data members
\*---------------------------------------------------------------------------*/
#include "faMatrices.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTemplateTypeNameAndDebug(faScalarMatrix, 0);
defineTemplateTypeNameAndDebug(faVectorMatrix, 0);
defineTemplateTypeNameAndDebug(faTensorMatrix, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faMatrix
Description
A special matrix type and solver, designed for finite area
solutions of scalar equations.
Face addressing is used to make all matrix assembly
and solution loops vectorise.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faMatrices_H
#define faMatrices_H
#include "faScalarMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef faMatrix<scalar> faScalarMatrix;
typedef faMatrix<vector> faVectorMatrix;
typedef faMatrix<tensor> faTensorMatrix;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,786 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faMatrix
Description
Finite-Area matrix.
SourceFiles
faMatrix.C
faMatrixSolve.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faMatrix_H
#define faMatrix_H
#include "areaFields.H"
#include "edgeFields.H"
#include "lduMatrix.H"
#include "tmp.H"
#include "autoPtr.H"
#include "dimensionedTypes.H"
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * Forward declaration of template friend fuctions * * * * * * * //
template<class Type>
class faMatrix;
template<class Type>
Ostream& operator<<(Ostream&, const faMatrix<Type>&);
/*---------------------------------------------------------------------------*\
Class faMatrix Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class faMatrix
:
public tmp<faMatrix<Type>>::refCount,
public lduMatrix
{
// Private data
// Reference to GeometricField<Type, faPatchField, areaMesh>
const GeometricField<Type, faPatchField, areaMesh>& psi_;
//- Dimension set
dimensionSet dimensions_;
//- Source term
Field<Type> source_;
//- Boundary scalar field containing pseudo-matrix coeffs
// for internal faces
FieldField<Field, Type> internalCoeffs_;
//- Boundary scalar field containing pseudo-matrix coeffs
// for boundary faces
FieldField<Field, Type> boundaryCoeffs_;
//- Face flux field for non-orthogonal correction
mutable GeometricField<Type, faePatchField, edgeMesh>
*faceFluxCorrectionPtr_;
// Private member functions
//- Add patch contribution to internal field
template<class Type2>
void addToInternalField
(
const labelUList& addr,
const Field<Type2>& pf,
Field<Type2>& intf
) const;
template<class Type2>
void addToInternalField
(
const labelUList& addr,
const tmp<Field<Type2>>& tpf,
Field<Type2>& intf
) const;
//- Subtract patch contribution from internal field
template<class Type2>
void subtractFromInternalField
(
const labelUList& addr,
const Field<Type2>& pf,
Field<Type2>& intf
) const;
template<class Type2>
void subtractFromInternalField
(
const labelUList& addr,
const tmp<Field<Type2>>& tpf,
Field<Type2>& intf
) const;
// Matrix completion functionality
void addBoundaryDiag
(
scalarField& diag,
const direction cmpt
) const;
void addCmptAvBoundaryDiag(scalarField& diag) const;
void addBoundarySource
(
Field<Type>& source,
const bool couples = true
) const;
public:
//- Solver class returned by the solver function
class faSolver
{
faMatrix<Type>& faMat_;
autoPtr<lduMatrix::solver> solver_;
public:
// Constructors
faSolver(faMatrix<Type>& faMat, autoPtr<lduMatrix::solver> sol)
:
faMat_(faMat),
solver_(sol)
{}
// Member functions
//- Solve returning the solution statistics.
// Solver controls read from dictionary
SolverPerformance<Type> solve(const dictionary&);
//- Solve returning the solution statistics.
// Solver controls read from faSolution
SolverPerformance<Type> solve();
};
ClassName("faMatrix");
// Constructors
//- Construct given a field to solve for
faMatrix
(
const GeometricField<Type, faPatchField, areaMesh>&,
const dimensionSet&
);
//- Construct as copy
faMatrix(const faMatrix<Type>&);
//- Construct from Istream given field to solve for
faMatrix
(
const GeometricField<Type, faPatchField, areaMesh>&,
Istream&
);
//- Clone
tmp<faMatrix<Type>> clone() const;
//- Destructor
virtual ~faMatrix();
// Member functions
// Access
const GeometricField<Type, faPatchField, areaMesh>& psi() const
{
return psi_;
}
const dimensionSet& dimensions() const
{
return dimensions_;
}
Field<Type>& source()
{
return source_;
}
const Field<Type>& source() const
{
return source_;
}
//- faBoundary scalar field containing pseudo-matrix coeffs
// for internal cells
FieldField<Field, Type>& internalCoeffs()
{
return internalCoeffs_;
}
//- faBoundary scalar field containing pseudo-matrix coeffs
// for boundary cells
FieldField<Field, Type>& boundaryCoeffs()
{
return boundaryCoeffs_;
}
//- Declare return type of the faceFluxCorrectionPtr() function
typedef GeometricField<Type, faePatchField, edgeMesh>
*edgeTypeFieldPtr;
//- Return pointer to face-flux non-orthogonal correction field
edgeTypeFieldPtr& faceFluxCorrectionPtr()
{
return faceFluxCorrectionPtr_;
}
// Operations
//- Set solution in given cells and eliminate corresponding
// equations from the matrix
void setValues
(
const labelUList& faces,
const UList<Type>& values
);
//- Set reference level for solution
void setReference
(
const label facei,
const Type& value
);
//- Set reference level for a component of the solution
// on a given patch face
void setComponentReference
(
const label patchi,
const label facei,
const direction cmpt,
const scalar value
);
//- Relax matrix (for steady-state solution).
// alpha = 1 : diagonally equal
// alpha < 1 : ,, dominant
// alpha = 0 : do nothing
void relax(const scalar alpha);
//- Relax matrix (for steadty-state solution).
// alpha is read from controlDict
void relax();
//- Solve returning the solution statistics.
// Solver controls read Istream
SolverPerformance<Type> solve(const dictionary&);
//- Solve returning the solution statistics.
// Solver controls read from faSolution
SolverPerformance<Type> solve();
//- Return the matrix residual
tmp<Field<Type>> residual() const;
//- Return the matrix diagonal
tmp<scalarField> D() const;
//- Return the central coefficient
tmp<areaScalarField> A() const;
//- Return the H operation source
tmp<GeometricField<Type, faPatchField, areaMesh>> H() const;
//- Return the face-flux field from the matrix
tmp<GeometricField<Type, faePatchField, edgeMesh>> flux() const;
// Member operators
void operator=(const faMatrix<Type>&);
void operator=(const tmp<faMatrix<Type>>&);
void negate();
void operator+=(const faMatrix<Type>&);
void operator+=(const tmp<faMatrix<Type>>&);
void operator-=(const faMatrix<Type>&);
void operator-=(const tmp<faMatrix<Type>>&);
void operator+=(const GeometricField<Type,faPatchField,areaMesh>&);
void operator+=(const tmp<GeometricField<Type,faPatchField,areaMesh>>&);
void operator-=(const GeometricField<Type,faPatchField,areaMesh>&);
void operator-=(const tmp<GeometricField<Type,faPatchField,areaMesh>>&);
void operator+=(const dimensioned<Type>&);
void operator-=(const dimensioned<Type>&);
void operator*=(const areaScalarField&);
void operator*=(const tmp<areaScalarField>&);
void operator*=(const dimensioned<scalar>&);
// Ostream operator
friend Ostream& operator<< <Type>
(
Ostream&,
const faMatrix<Type>&
);
};
// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
template<class Type>
void checkMethod
(
const faMatrix<Type>&,
const faMatrix<Type>&,
const char*
);
template<class Type>
void checkMethod
(
const faMatrix<Type>&,
const GeometricField<Type, faPatchField, areaMesh>&,
const char*
);
template<class Type>
void checkMethod
(
const faMatrix<Type>&,
const dimensioned<Type>&,
const char*
);
//- Solve returning the solution statistics given convergence tolerance
// Solver controls read Istream
template<class Type>
SolverPerformance<Type> solve(faMatrix<Type>&, Istream&);
//- Solve returning the solution statistics given convergence tolerance,
// deleting temporary matrix after solution.
// Solver controls read Istream
template<class Type>
SolverPerformance<Type> solve(const tmp<faMatrix<Type>>&, Istream&);
//- Solve returning the solution statistics given convergence tolerance
// Solver controls read faSolution
template<class Type>
SolverPerformance<Type> solve(faMatrix<Type>&);
//- Solve returning the solution statistics given convergence tolerance,
// deleting temporary matrix after solution.
// Solver controls read faSolution
template<class Type>
SolverPerformance<Type> solve(const tmp<faMatrix<Type>>&);
// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
template<class Type>
tmp<faMatrix<Type>> operator-
(
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const faMatrix<Type>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const tmp<faMatrix<Type>>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const faMatrix<Type>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const tmp<faMatrix<Type>>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const faMatrix<Type>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const tmp<faMatrix<Type>>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const faMatrix<Type>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const tmp<faMatrix<Type>>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const faMatrix<Type>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const tmp<faMatrix<Type>>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const faMatrix<Type>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const tmp<faMatrix<Type>>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const faMatrix<Type>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const tmp<faMatrix<Type>>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const faMatrix<Type>&,
const tmp<GeometricField<Type, faPatchField, areaMesh>>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const tmp<faMatrix<Type>>&,
const tmp<GeometricField<Type, faPatchField, areaMesh>>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const GeometricField<Type, faPatchField, areaMesh>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const GeometricField<Type, faPatchField, areaMesh>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const tmp<GeometricField<Type, faPatchField, areaMesh>>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const tmp<GeometricField<Type, faPatchField, areaMesh>>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const faMatrix<Type>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const tmp<faMatrix<Type>>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const faMatrix<Type>&,
const tmp<GeometricField<Type, faPatchField, areaMesh>>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const tmp<faMatrix<Type>>&,
const tmp<GeometricField<Type, faPatchField, areaMesh>>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const GeometricField<Type, faPatchField, areaMesh>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const GeometricField<Type, faPatchField, areaMesh>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const tmp<GeometricField<Type, faPatchField, areaMesh>>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const tmp<GeometricField<Type, faPatchField, areaMesh>>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const faMatrix<Type>&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const tmp<faMatrix<Type>>&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const dimensioned<Type>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator+
(
const dimensioned<Type>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const faMatrix<Type>&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const tmp<faMatrix<Type>>&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const dimensioned<Type>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator-
(
const dimensioned<Type>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const faMatrix<Type>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const tmp<faMatrix<Type>>&,
const GeometricField<Type, faPatchField, areaMesh>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const faMatrix<Type>&,
const tmp<GeometricField<Type, faPatchField, areaMesh>>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const tmp<faMatrix<Type>>&,
const tmp<GeometricField<Type, faPatchField, areaMesh>>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const faMatrix<Type>&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator==
(
const tmp<faMatrix<Type>>&,
const dimensioned<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator*
(
const areaScalarField&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator*
(
const areaScalarField&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator*
(
const tmp<areaScalarField>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator*
(
const tmp<areaScalarField>&,
const tmp<faMatrix<Type>>&
);
template<class Type>
tmp<faMatrix<Type>> operator*
(
const dimensioned<scalar>&,
const faMatrix<Type>&
);
template<class Type>
tmp<faMatrix<Type>> operator*
(
const dimensioned<scalar>&,
const tmp<faMatrix<Type>>&
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "faMatrix.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,208 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Description
Finite-Area matrix basic solvers.
\*---------------------------------------------------------------------------*/
template<class Type>
void Foam::faMatrix<Type>::setComponentReference
(
const label patchi,
const label facei,
const direction cmpt,
const scalar value
)
{
internalCoeffs_[patchi][facei].component(cmpt) +=
diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
boundaryCoeffs_[patchi][facei].component(cmpt) +=
diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]*value;
}
template<class Type>
Foam::SolverPerformance<Type> Foam::faMatrix<Type>::solve
(
const dictionary& solverControls
)
{
DebugInFunction
<< "solving faMatrix<Type>"
<< endl;
SolverPerformance<Type> solverPerfVec
(
"faMatrix<Type>::solve",
psi_.name()
);
scalarField saveDiag(diag());
Field<Type> source(source_);
addBoundarySource(source);
// Note: make a copy of interfaces: no longer a reference
lduInterfaceFieldPtrsList interfaces =
psi_.boundaryField().scalarInterfaces();
// Cast into a non-const to solve
GeometricField<Type, faPatchField, areaMesh>& psi =
const_cast<GeometricField<Type, faPatchField, areaMesh>&>(psi_);
for (direction cmpt = 0; cmpt < Type::nComponents; ++cmpt)
{
// copy field and source
scalarField psiCmpt(psi_.primitiveField().component(cmpt));
addBoundaryDiag(diag(), cmpt);
scalarField sourceCmpt(source.component(cmpt));
FieldField<Field, scalar> bouCoeffsCmpt
(
boundaryCoeffs_.component(cmpt)
);
FieldField<Field, scalar> intCoeffsCmpt
(
internalCoeffs_.component(cmpt)
);
// Use the initMatrixInterfaces and updateMatrixInterfaces to correct
// bouCoeffsCmpt for the explicit part of the coupled boundary
// conditions
initMatrixInterfaces
(
true,
bouCoeffsCmpt,
interfaces,
psiCmpt,
sourceCmpt,
cmpt
);
updateMatrixInterfaces
(
true,
bouCoeffsCmpt,
interfaces,
psiCmpt,
sourceCmpt,
cmpt
);
solverPerformance solverPerf;
// Solver call
solverPerf = lduMatrix::solver::New
(
psi_.name() + pTraits<Type>::componentNames[cmpt],
*this,
bouCoeffsCmpt,
intCoeffsCmpt,
interfaces,
solverControls
)->solve(psiCmpt, sourceCmpt, cmpt);
if (SolverPerformance<Type>::debug)
{
solverPerf.print(Info);
}
solverPerfVec.replace(cmpt, solverPerf);
solverPerfVec.solverName() = solverPerf.solverName();
psi.primitiveFieldRef().replace(cmpt, psiCmpt);
diag() = saveDiag;
}
psi.correctBoundaryConditions();
psi.mesh().setSolverPerformance(psi.name(), solverPerfVec);
return solverPerfVec;
}
template<class Type>
Foam::SolverPerformance<Type> Foam::faMatrix<Type>::faSolver::solve()
{
return solve(faMat_.psi().mesh().solverDict(faMat_.psi().name()));
}
template<class Type>
Foam::SolverPerformance<Type> Foam::faMatrix<Type>::solve()
{
return solve(this->psi().mesh().solverDict(this->psi().name()));
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::faMatrix<Type>::residual() const
{
tmp<Field<Type>> tres(source_);
Field<Type>& res = tres().ref();
addBoundarySource(res);
lduInterfaceFieldPtrsList interfaces =
psi_.boundaryField().scalarInterfaces();
// Loop over field components
for (direction cmpt = 0; cmpt < Type::nComponents; ++cmpt)
{
scalarField psiCmpt(psi_.internalField().component(cmpt));
scalarField boundaryDiagCmpt(psi_.size(), 0.0);
addBoundaryDiag(boundaryDiagCmpt, cmpt);
FieldField<Field, scalar> bouCoeffsCmpt
(
boundaryCoeffs_.component(cmpt)
);
res.replace
(
cmpt,
lduMatrix::residual
(
psiCmpt,
res.component(cmpt) - boundaryDiagCmpt*psiCmpt,
bouCoeffsCmpt,
interfaces,
cmpt
)
);
}
return tres;
}
// ************************************************************************* //

View File

@ -0,0 +1,154 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Description
Finite-Area scalar matrix member functions and operators
\*---------------------------------------------------------------------------*/
#include "faScalarMatrix.H"
#include "zeroGradientFaPatchFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<>
void Foam::faMatrix<Foam::scalar>::setComponentReference
(
const label patchI,
const label edgeI,
const direction,
const scalar value
)
{
const labelUList& faceLabels = psi_.mesh().boundary()[patchI].edgeFaces();
internalCoeffs_[patchI][edgeI] += diag()[faceLabels[edgeI]];
boundaryCoeffs_[patchI][edgeI] = value;
}
template<>
Foam::solverPerformance Foam::faMatrix<Foam::scalar>::solve
(
const dictionary& solverControls
)
{
DebugInFunction
<< "solving faMatrix<scalar>"
<< endl;
GeometricField<scalar, faPatchField, areaMesh>& psi =
const_cast<GeometricField<scalar, faPatchField, areaMesh>&>(psi_);
scalarField saveDiag(diag());
addBoundaryDiag(diag(), 0);
scalarField totalSource(source_);
addBoundarySource(totalSource, 0);
// Solver call
solverPerformance solverPerf = lduMatrix::solver::New
(
psi_.name(),
*this,
boundaryCoeffs_,
internalCoeffs_,
psi_.boundaryField().scalarInterfaces(),
solverControls
)->solve(psi.ref(), totalSource);
if (solverPerformance::debug)
{
solverPerf.print(Info);
}
diag() = saveDiag;
psi.correctBoundaryConditions();
psi.mesh().setSolverPerformance(psi.name(), solverPerf);
return solverPerf;
}
template<>
Foam::tmp<Foam::scalarField> Foam::faMatrix<Foam::scalar>::residual() const
{
scalarField boundaryDiag(psi_.size(), 0.0);
addBoundaryDiag(boundaryDiag, 0);
tmp<scalarField> tres
(
lduMatrix::residual
(
psi_.internalField(),
source_ - boundaryDiag*psi_.internalField(),
boundaryCoeffs_,
psi_.boundaryField().scalarInterfaces(),
0
)
);
addBoundarySource(tres.ref());
return tres;
}
template<>
Foam::tmp<Foam::areaScalarField> Foam::faMatrix<Foam::scalar>::H() const
{
tmp<areaScalarField> tHphi
(
new areaScalarField
(
IOobject
(
"H("+psi_.name()+')',
psi_.instance(),
psi_.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
psi_.mesh(),
dimensions_/dimArea,
zeroGradientFaPatchScalarField::typeName
)
);
areaScalarField& Hphi = tHphi.ref();
Hphi.primitiveFieldRef() = (lduMatrix::H(psi_.primitiveField()) + source_);
addBoundarySource(Hphi.primitiveFieldRef());
Hphi.ref() /= psi_.mesh().S();
Hphi.correctBoundaryConditions();
return tHphi;
}
// ************************************************************************* //

View File

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faScalarMatrix
Description
Template specialisation for scalar faMatrix
SourceFiles
faScalarMatrix.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faScalarMatrix_H
#define faScalarMatrix_H
#include "faMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Set reference level for a component of the solution
// on a given patch face
template<>
void faMatrix<scalar>::setComponentReference
(
const label patchi,
const label facei,
const direction,
const scalar value
);
template<>
SolverPerformance<scalar> faMatrix<scalar>::solve(const dictionary&);
// Return the matrix residual
template<>
tmp<scalarField> faMatrix<scalar>::residual() const;
// H operator
template<>
tmp<areaScalarField> faMatrix<scalar>::H() const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,369 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Description
\*---------------------------------------------------------------------------*/
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "primitiveMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faBoundaryMesh, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faBoundaryMesh::faBoundaryMesh
(
const IOobject& io,
const faMesh& mesh
)
:
faPatchList(),
regIOobject(io),
mesh_(mesh)
{
if (readOpt() == IOobject::MUST_READ)
{
faPatchList& patches = *this;
// Read polyPatchList
Istream& is = readStream(typeName);
PtrList<entry> patchEntries(is);
patches.setSize(patchEntries.size());
forAll(patches, patchI)
{
patches.set
(
patchI,
faPatch::New
(
patchEntries[patchI].keyword(),
patchEntries[patchI].dict(),
patchI,
*this
)
);
}
// Check state of IOstream
is.check(FUNCTION_NAME);
close();
}
}
Foam::faBoundaryMesh::faBoundaryMesh
(
const IOobject& io,
const faMesh& pm,
const label size
)
:
faPatchList(size),
regIOobject(io),
mesh_(pm)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faBoundaryMesh::calcGeometry()
{
forAll(*this, patchi)
{
operator[](patchi).initGeometry();
}
forAll(*this, patchi)
{
operator[](patchi).calcGeometry();
}
}
const Foam::faMesh& Foam::faBoundaryMesh::mesh() const
{
return mesh_;
}
Foam::lduInterfacePtrsList Foam::faBoundaryMesh::interfaces() const
{
lduInterfacePtrsList interfaces(size());
forAll(interfaces, patchi)
{
if (isA<lduInterface>(this->operator[](patchi)))
{
interfaces.set
(
patchi,
&refCast<const lduInterface>(this->operator[](patchi))
);
}
}
return interfaces;
}
Foam::wordList Foam::faBoundaryMesh::types() const
{
const faPatchList& patches = *this;
wordList t(patches.size());
forAll(patches, patchI)
{
t[patchI] = patches[patchI].type();
}
return t;
}
Foam::wordList Foam::faBoundaryMesh::names() const
{
const faPatchList& patches = *this;
wordList t(patches.size());
forAll(patches, patchI)
{
t[patchI] = patches[patchI].name();
}
return t;
}
Foam::label Foam::faBoundaryMesh::findPatchID(const word& patchName) const
{
const faPatchList& patches = *this;
forAll(patches, patchI)
{
if (patches[patchI].name() == patchName)
{
return patchI;
}
}
// Patch not found
return -1;
}
Foam::labelList Foam::faBoundaryMesh::findIndices
(
const keyType& key,
const bool usePatchGroups
) const
{
DynamicList<label> indices;
if (!key.empty())
{
if (key.isPattern())
{
indices = findStrings(key, this->names());
}
else
{
// Literal string. Special version of above to avoid
// unnecessary memory allocations
indices.setCapacity(1);
forAll(*this, i)
{
if (key == operator[](i).name())
{
indices.append(i);
break;
}
}
}
}
return indices;
}
Foam::label Foam::faBoundaryMesh::whichPatch(const label edgeIndex) const
{
// Find out which patch the current face belongs to by comparing label
// with patch start labels.
// If the face is internal, return -1;
// if it is off the end of the list, abort
if (edgeIndex >= mesh().nEdges())
{
FatalErrorInFunction
<< "given label greater than the number of edges"
<< abort(FatalError);
}
if (edgeIndex < mesh().nInternalEdges())
{
return -1;
}
forAll(*this, patchI)
{
label start = mesh_.patchStarts()[patchI];
label size = operator[](patchI).faPatch::size();
if
(
edgeIndex >= start
&& edgeIndex < start + size
)
{
return patchI;
}
}
// If not in any of above, it's trouble!
FatalErrorInFunction
<< "error in patch search algorithm"
<< abort(FatalError);
return -1;
}
bool Foam::faBoundaryMesh::checkDefinition(const bool report) const
{
label nextPatchStart = mesh().nInternalEdges();
const faBoundaryMesh& bm = *this;
bool boundaryError = false;
forAll(bm, patchI)
{
if (bm[patchI].start() != nextPatchStart)
{
boundaryError = true;
InfoInFunction
<< "Problem with boundary patch " << patchI
<< ".\nThe patch should start on face no " << nextPatchStart
<< " and the boundary file specifies " << bm[patchI].start()
<< "." << nl << endl;
}
nextPatchStart += bm[patchI].faPatch::size();
}
if (boundaryError)
{
SeriousErrorInFunction
<< "This mesh is not valid: boundary definition is in error."
<< endl;
}
else
{
if (debug || report)
{
Info << "Boundary definition OK." << endl;
}
}
return boundaryError;
}
void Foam::faBoundaryMesh::movePoints(const pointField& p)
{
faPatchList& patches = *this;
forAll(patches, patchI)
{
patches[patchI].initMovePoints(p);
}
forAll(patches, patchI)
{
patches[patchI].movePoints(p);
}
}
void Foam::faBoundaryMesh::updateMesh()
{
faPatchList& patches = *this;
forAll(patches, patchi)
{
patches[patchi].initUpdateMesh();
}
forAll(patches, patchi)
{
patches[patchi].updateMesh();
}
}
bool Foam::faBoundaryMesh::writeData(Ostream& os) const
{
const faPatchList& patches = *this;
os << patches.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(patches, patchi)
{
os << indent << patches[patchi].name() << nl
<< indent << token::BEGIN_BLOCK << nl
<< incrIndent << patches[patchi] << decrIndent
<< indent << token::END_BLOCK << endl;
}
os << decrIndent << token::END_LIST;
// Check state of IOstream
os.check(FUNCTION_NAME);
return os.good();
}
Foam::Ostream& Foam::operator<<(Ostream& os, const faBoundaryMesh& bm)
{
bm.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,172 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faBoundaryMesh
Description
Finite area boundary mesh
SourceFiles
faBoundaryMesh.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faBoundaryMesh_H
#define faBoundaryMesh_H
#include "faPatchList.H"
#include "lduInterfacePtrsList.H"
#include "wordList.H"
#include "pointField.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class faMesh;
/*---------------------------------------------------------------------------*\
Class faBoundaryMesh Declaration
\*---------------------------------------------------------------------------*/
class faBoundaryMesh
:
public faPatchList,
public regIOobject
{
// private data
//- Reference to mesh
const faMesh& mesh_;
//- Disallow construct as copy
faBoundaryMesh(const faBoundaryMesh&);
//- Disallow assignment
void operator=(const faBoundaryMesh&);
public:
//- Runtime type information
TypeName("faBoundaryMesh");
// Constructors
//- Construct from dictionary
faBoundaryMesh
(
const IOobject& io,
const faMesh& fam
);
//- Construct given size
faBoundaryMesh
(
const IOobject& io,
const faMesh& fam,
const label size
);
// Destructor - default
// Member functions
// Access
//- Calculate the geometry for the patches
// (transformation tensors etc.)
void calcGeometry();
//- Return the mesh reference
const faMesh& mesh() const;
//- Return a list of pointers for each patch
// with only those pointing to interfaces being set
lduInterfacePtrsList interfaces() const;
//- Return a list of patch types
wordList types() const;
//- Return a list of patch names
wordList names() const;
//- Find patch index given a name
label findPatchID(const word& patchName) const;
//- Find patch indices given a name
// Compatibility change HJ, 12/Aug/2017
labelList findIndices
(
const keyType&,
const bool useGroups = false
) const;
//- Return patch index for a given edge label
label whichPatch(const label edgeIndex) const;
//- Check boundary definition
bool checkDefinition(const bool report = false) const;
// Edit
//- Correct faBoundaryMesh after moving points
void movePoints(const pointField&);
//- Correct faBoundaryMesh after topology update
void updateMesh();
//- writeData member function required by regIOobject
bool writeData(Ostream&) const;
// Ostream operator
friend Ostream& operator<<(Ostream&, const faBoundaryMesh&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Description
Author
Hrvoje Jasak
\*----------------------------------------------------------------------------*/
#include "faGlobalMeshData.H"
#include "faMesh.H"
#include "globalMeshData.H"
#include "PstreamCombineReduceOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faGlobalMeshData::faGlobalMeshData(const faMesh& mesh)
:
faProcessorTopology(mesh.boundary(), UPstream::worldComm),
mesh_(mesh),
nGlobalPoints_(-1),
sharedPointLabels_(0),
sharedPointAddr_(0)
{
updateMesh();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faGlobalMeshData::~faGlobalMeshData()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::faMesh& Foam::faGlobalMeshData::mesh() const
{
return mesh_;
}
void Foam::faGlobalMeshData::updateMesh()
{
label polyMeshNGlobalPoints = mesh_().globalData().nGlobalPoints();
const labelList& polyMeshSharedPointLabels =
mesh_().globalData().sharedPointLabels();
const labelList& polyMeshSharedPointAddr =
mesh_().globalData().sharedPointAddr();
labelHashSet sharedPointLabels;
labelField globalList(polyMeshNGlobalPoints, 0);
forAll(mesh_.boundary(), patchI)
{
const faPatch& fap = mesh_.boundary()[patchI];
if (isA<processorFaPatch>(fap))
{
const labelList& localPointLabels = fap.pointLabels();
forAll(localPointLabels, pointI)
{
label polyMeshPoint =
mesh_.patch().meshPoints()[localPointLabels[pointI]];
label sharedPolyMeshPoint =
findIndex(polyMeshSharedPointLabels, polyMeshPoint);
if
(
sharedPolyMeshPoint != -1
&& !sharedPointLabels.found(localPointLabels[pointI])
)
{
globalList[polyMeshSharedPointAddr[sharedPolyMeshPoint]]
+= 1;
sharedPointLabels.insert(localPointLabels[pointI]);
}
}
}
}
sharedPointLabels_ = sharedPointLabels.toc();
combineReduce(globalList, plusEqOp<labelField>());
nGlobalPoints_ = 0;
for (label i=0; i<globalList.size(); ++i)
{
if (globalList[i] > 0)
{
globalList[i] = ++nGlobalPoints_;
}
}
sharedPointAddr_.setSize(sharedPointLabels_.size());
forAll(sharedPointAddr_, pointI)
{
label polyMeshSharedPointIndex = findIndex
(
polyMeshSharedPointLabels,
mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
);
sharedPointAddr_[pointI] =
globalList[polyMeshSharedPointAddr[polyMeshSharedPointIndex]]
- 1;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,138 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faGlobalMeshData
Description
Various mesh related information for a parallel run
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faGlobalMeshData_H
#define faGlobalMeshData_H
#include "faProcessorTopology.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class faMesh;
/*---------------------------------------------------------------------------*\
Class faGlobalMeshData Declaration
\*---------------------------------------------------------------------------*/
class faGlobalMeshData
:
public faProcessorTopology
{
// Private data
//- Reference to mesh
const faMesh& mesh_;
// Globally shared point addressing
//- Total number of global points
label nGlobalPoints_;
//- Indices of local points that are globally shared
labelList sharedPointLabels_;
//- Indices of globally shared points in the master list
// This list contains all the shared points in the mesh
labelList sharedPointAddr_;
// Private Member Functions
//- Disallow default bitwise copy construct
faGlobalMeshData(const faGlobalMeshData&);
//- Disallow default bitwise assignment
void operator=(const faGlobalMeshData&);
public:
//- Runtime type information
ClassName("faGlobalMeshData");
//- Construct from mesh
faGlobalMeshData(const faMesh& mesh);
//- Destructor
~faGlobalMeshData();
// Member Functions
// Access
//- Return mesh reference
const faMesh& mesh() const;
// Globally shared point addressing
//- Return number of globally shared points
label nGlobalPoints() const
{
return nGlobalPoints_;
}
//- Return indices of local points that are globally shared
const labelList& sharedPointLabels() const
{
return sharedPointLabels_;
}
//- Return addressing into the complete globally shared points
// list
const labelList& sharedPointAddr() const
{
return sharedPointAddr_;
}
//- Change global mesh data given a topological change.
void updateMesh();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Typedef
Foam::faProcessorTopology
Description
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faProcessorTopology_H
#define faProcessorTopology_H
#include "ProcessorTopology.H"
#include "faPatchList.H"
#include "processorFaPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef ProcessorTopology<faPatchList, processorFaPatch> faProcessorTopology;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,572 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faMesh
Description
Finite area mesh. Used for 2-D non-Euclidian finite area method.
SourceFiles
faMesh.C
faMeshDemandDrivenData.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faMesh_H
#define faMesh_H
#include "GeoMesh.H"
#include "MeshObject.H"
#include "polyMesh.H"
#include "lduMesh.H"
#include "faBoundaryMesh.H"
#include "edgeList.H"
#include "faceList.H"
#include "primitiveFieldsFwd.H"
#include "DimensionedField.H"
#include "areaFieldsFwd.H"
#include "edgeFieldsFwd.H"
#include "indirectPrimitivePatch.H"
#include "edgeInterpolation.H"
#include "labelIOList.H"
#include "FieldFields.H"
#include "faGlobalMeshData.H"
#include "faSchemes.H"
#include "faSolution.H"
#include "data.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class faMeshLduAddressing;
class faMeshMapper;
/*---------------------------------------------------------------------------*\
Class faMesh Declaration
\*---------------------------------------------------------------------------*/
class faMesh
:
public GeoMesh<polyMesh>,
public MeshObject<polyMesh, Foam::UpdateableMeshObject, faMesh>,
public lduMesh,
public edgeInterpolation,
public faSchemes,
public faSolution,
public data
{
// Private data
//- Face labels
labelIOList faceLabels_;
//- Boundary mesh
faBoundaryMesh boundary_;
// Primitive mesh data
//- Edges, addressing into local point list
edgeList edges_;
//- Edge owner
labelList edgeOwner_;
//- Edge neighbour
labelList edgeNeighbour_;
// Primitive size data
//- Number of points
mutable label nPoints_;
//- Number of edges
mutable label nEdges_;
//- Number of internal edges
mutable label nInternalEdges_;
//- Number of faces
mutable label nFaces_;
// Communication support
//- Communicator used for parallel communication
label comm_;
// Demand-driven data
//- Primitive patch
mutable indirectPrimitivePatch* patchPtr_;
//- Ldu addressing data
mutable faMeshLduAddressing* lduPtr_;
//- Current time index for motion
// Note. The whole mechanism will be replaced once the
// dimensionedField is created and the dimensionedField
// will take care of the old-time levels.
mutable label curTimeIndex_;
//- Face areas
mutable DimensionedField<scalar, areaMesh>* SPtr_;
//- Face areas old time level
mutable DimensionedField<scalar, areaMesh>* S0Ptr_;
//- Face areas old-old time level
mutable DimensionedField<scalar, areaMesh>* S00Ptr_;
//- Patch starts in the edge list
mutable labelList* patchStartsPtr_;
//- Edge length vectors
mutable edgeVectorField* LePtr_;
//- Mag edge length vectors
mutable edgeScalarField* magLePtr_;
//- Face centres
mutable areaVectorField* centresPtr_;
//- Edge centres
mutable edgeVectorField* edgeCentresPtr_;
//- Face area normals
mutable areaVectorField* faceAreaNormalsPtr_;
//- Edge area normals
mutable edgeVectorField* edgeAreaNormalsPtr_;
//- Edge area normals
mutable vectorField* pointAreaNormalsPtr_;
//- Face curvatures
mutable areaScalarField* faceCurvaturesPtr_;
//- Edge transformation tensors
mutable FieldField<Field, tensor>* edgeTransformTensorsPtr_;
//- Whether point normals must be corrected for a patch
mutable boolList* correctPatchPointNormalsPtr_;
// Other mesh-related data
//- Parallel info
mutable faGlobalMeshData* globalMeshDataPtr_;
// Static Private Data
//- Use quadrics fit
static const int quadricsFit_;
// Private Member Functions
//- Disallow default bitwise copy construct
faMesh(const faMesh&);
//- Disallow default bitwise assignment
void operator=(const faMesh&);
//- Set primitive mesh data
void setPrimitiveMeshData();
// Private member functions to calculate demand driven data
//- Calculate ldu addressing
void calcLduAddressing() const;
//- Calculate patch starts in the edge list
void calcPatchStarts() const;
//- Calculate edge lengths
void calcLe() const;
//- Calculate mag edge lengths
void calcMagLe() const;
//- Calculate face centres
void calcAreaCentres() const;
//- Calculate edge centres
void calcEdgeCentres() const;
//- Calculate face areas
void calcS() const;
//- Calculate face area normals
void calcFaceAreaNormals() const;
//- Calculate edge area normals
void calcEdgeAreaNormals() const;
//- Calculate point area normals
void calcPointAreaNormals() const;
//- Calculate point area normals by quadrics fit
void calcPointAreaNormalsByQuadricsFit() const;
//- Calculate face curvatures
void calcFaceCurvatures() const;
//- Calculate edge transformation tensors
void calcEdgeTransformTensors() const;
//- Clear geometry but not the face areas
void clearGeomNotAreas() const;
//- Clear geometry
void clearGeom() const;
//- Clear addressing
void clearAddressing() const;
//- Clear demand-driven data
void clearOut() const;
public:
// Public typedefs
typedef faMesh Mesh;
typedef faBoundaryMesh BoundaryMesh;
//- Runtime type information
TypeName("faMesh");
//- Return the mesh sub-directory name (usually "faMesh")
static word meshSubDir;
// Constructors
//- Construct from polyMesh
explicit faMesh(const polyMesh& m);
//- Construct from components without boundary.
// Boundary is added using addFaPatches() member function
faMesh
(
const polyMesh& m,
const labelList& faceLabels
);
//- Construct from finite area mesh definition file
faMesh
(
const polyMesh& m,
const fileName& defFile
);
//- Construct from polyPatch
faMesh
(
const polyMesh& m,
const label polyPatchID
);
//- Destructor
virtual ~faMesh();
// Member Functions
// Helpers
//- Add boundary patches. Constructor helper
void addFaPatches(const List<faPatch*> &);
// Database
//- Return access to polyMesh
const polyMesh& mesh() const
{
return
MeshObject
<
polyMesh,
Foam::UpdateableMeshObject,
faMesh
>::mesh();
}
//- Return the local mesh directory (dbDir()/meshSubDir)
fileName meshDir() const;
//- Return reference to time
const Time& time() const;
//- Return the current instance directory for points
// Used in the consruction of gemometric mesh data dependent
// on points
const fileName& pointsInstance() const;
//- Return the current instance directory for faces
const fileName& facesInstance() const;
// Mesh size parameters
inline label nPoints() const
{
return nPoints_;
}
inline label nEdges() const
{
return nEdges_;
}
inline label nInternalEdges() const
{
return nInternalEdges_;
}
inline label nFaces() const
{
return nFaces_;
}
// Primitive mesh data
//- Return mesh points
const pointField& points() const;
//- Return edges
const edgeList& edges() const;
//- Return faces
const faceList& faces() const;
//- Edge owner addresing
inline const labelList& edgeOwner() const
{
return edgeOwner_;
}
//- Edge neighbour addressing
inline const labelList& edgeNeighbour() const
{
return edgeNeighbour_;
}
// Communication support
//- Return communicator used for parallel communication
label comm() const;
//- Return communicator used for parallel communication
label& comm();
// Access
//- Return reference to the mesh database
virtual const objectRegistry& thisDb() const;
//- Name function is needed to disambiguate those inherited
// from base classes
const word& name() const
{
return thisDb().name();
}
//- Return constant reference to boundary mesh
const faBoundaryMesh& boundary() const;
//- Return faMesh face labels
const labelList& faceLabels() const
{
return faceLabels_;
}
//- Return parallel info
const faGlobalMeshData& globalData() const;
//- Return ldu addressing
virtual const lduAddressing& lduAddr() const;
//- Return a list of pointers for each patch
// with only those pointing to interfaces being set
virtual lduInterfacePtrsList interfaces() const
{
return boundary().interfaces();
}
//- Internal face owner
const labelUList& owner() const
{
return lduAddr().lowerAddr();
}
//- Internal face neighbour
const labelUList& neighbour() const
{
return lduAddr().upperAddr();
}
//- Return true if given edge label is internal to the mesh
inline bool isInternalEdge(const label edgeIndex) const
{
return edgeIndex < nInternalEdges();
}
// Mesh motion and mophing
//- Is mesh moving
bool moving() const
{
return mesh().moving();
}
//- Update after mesh motion
virtual bool movePoints();
//- Update after topo change
virtual void updateMesh(const mapPolyMesh&);
// Mapping
//- Map all fields in time using given map.
virtual void mapFields(const faMeshMapper& mapper) const;
//- Map face areas in time using given map.
virtual void mapOldAreas(const faMeshMapper& mapper) const;
// Demand-driven data
//- Return constant reference to primitive patch
const indirectPrimitivePatch& patch() const;
//- Return reference to primitive patch
indirectPrimitivePatch& patch();
//- Return patch starts
const labelList& patchStarts() const;
//- Return edge length vectors
const edgeVectorField& Le() const;
//- Return edge length magnitudes
const edgeScalarField& magLe() const;
//- Return face centres as areaVectorField
const areaVectorField& areaCentres() const;
//- Return edge centres as edgeVectorField
const edgeVectorField& edgeCentres() const;
//- Return face areas
const DimensionedField<scalar, areaMesh>& S() const;
//- Return old-time face areas
const DimensionedField<scalar, areaMesh>& S0() const;
//- Return old-old-time face areas
const DimensionedField<scalar, areaMesh>& S00() const;
//- Return face area normals
const areaVectorField& faceAreaNormals() const;
//- Return edge area normals
const edgeVectorField& edgeAreaNormals() const;
//- Return point area normals
const vectorField& pointAreaNormals() const;
//- Return face curvatures
const areaScalarField& faceCurvatures() const;
//- Return edge transformation tensors
const FieldField<Field, tensor>& edgeTransformTensors() const;
//- Return internal point labels
labelList internalPoints() const;
//- Return boundary point labels
labelList boundaryPoints() const;
//- Return edge length correction
tmp<edgeScalarField> edgeLengthCorrection() const;
//- Whether point normals should be corrected for a patch
bool correctPatchPointNormals(const label patchID) const;
//- Set whether point normals should be corrected for a patch
boolList& correctPatchPointNormals() const;
//- Write mesh
virtual bool write(const bool valid = true) const;
// Member Operators
bool operator!=(const faMesh& m) const;
bool operator==(const faMesh& m) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "faPatchFaMeshTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faMeshLduAddressing
Description
lduAddressing wrapper for faMesh
SourceFiles
faMeshLduAddressing.C
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faMeshLduAddressing_H
#define faMeshLduAddressing_H
#include "lduAddressing.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faMeshLduAddressing Declaration
\*---------------------------------------------------------------------------*/
class faMeshLduAddressing
:
public lduAddressing
{
// Private data
//- Lower as a subList of allOwner
labelList::subList lowerAddr_;
//- Upper as a reference to neighbour
const labelList& upperAddr_;
//- Patch addressing as a list of sublists
List<const labelUList*> patchAddr_;
//- Patch field evaluation schedule
const lduSchedule& patchSchedule_;
// Private Member Functions
//- Disallow default bitwise copy construct
faMeshLduAddressing(const faMeshLduAddressing&);
//- Disallow default bitwise assignment
void operator=(const faMeshLduAddressing&);
public:
// Constructors
//- Construct from components
faMeshLduAddressing(const faMesh& mesh)
:
lduAddressing(mesh.nFaces()),
lowerAddr_
(
labelList::subList
(
mesh.edgeOwner(),
mesh.nInternalEdges()
)
),
upperAddr_(mesh.edgeNeighbour()),
patchAddr_(mesh.boundary().size()),
patchSchedule_(mesh.globalData().patchSchedule())
{
forAll(mesh.boundary(), patchI)
{
patchAddr_[patchI] = &mesh.boundary()[patchI].edgeFaces();
}
}
//-Destructor
virtual ~faMeshLduAddressing()
{}
// Member Functions
//- Return number of interfaces
virtual label nPatches() const
{
return patchAddr_.size();
}
//- Return lower addressing (i.e. lower label = upper triangle)
virtual const labelUList& lowerAddr() const
{
return lowerAddr_;
}
//- Return upper addressing (i.e. upper label)
virtual const labelUList& upperAddr() const
{
return upperAddr_;
}
//- Return patch addressing
virtual const labelUList& patchAddr(const label i) const
{
return *patchAddr_[i];
}
// Return patch field evaluation schedule
virtual const lduSchedule& patchSchedule() const
{
return patchSchedule_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,424 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Description
FV surface mapper.
\*---------------------------------------------------------------------------*/
#include "faAreaMapper.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faAreaMapper::calcAddressing() const
{
if
(
newFaceLabelsPtr_
|| newFaceLabelsMapPtr_
|| directAddrPtr_
|| interpolationAddrPtr_
|| weightsPtr_
|| insertedObjectLabelsPtr_
)
{
FatalErrorInFunction
<< "Addressing already calculated"
<< abort(FatalError);
}
// Mapping
const label oldNInternal = mpm_.nOldInternalFaces();
hasUnmapped_ = false;
// Calculate new face labels
// Copy old face labels
const labelList& oldFaces = mesh_.faceLabels();
// Prepare a list of new face labels and (preliminary) addressing
// Note: dimensioned to number of boundary faces of polyMesh
newFaceLabelsPtr_ = new labelList
(
mesh_().nFaces() - mesh_().nInternalFaces(),
-1
);
labelList& newFaceLabels = *newFaceLabelsPtr_;
newFaceLabelsMapPtr_ = new labelList
(
mesh_().nFaces() - mesh_().nInternalFaces(),
-1
);
labelList& newFaceLabelsMap = *newFaceLabelsMapPtr_;
label nNewFaces = 0;
Info<< "Old face list size: " << oldFaces.size()
<< " estimated new size " << newFaceLabels.size() << endl;
// Get reverse face map
const labelList& reverseFaceMap = mpm_.reverseFaceMap();
// Pick up live old faces
forAll(oldFaces, faceI)
{
if (reverseFaceMap[oldFaces[faceI]] > -1)
{
// Face is live, add it and record addressing
newFaceLabels[nNewFaces] = reverseFaceMap[oldFaces[faceI]];
newFaceLabelsMap[nNewFaces] = faceI;
nNewFaces++;
}
}
// Assemble the maps
if (direct())
{
Info<< "Direct"<< endl;
// Direct mapping: no further faces to add. Resize list
newFaceLabels.setSize(nNewFaces);
directAddrPtr_ = new labelList(newFaceLabels.size());
labelList& addr = *directAddrPtr_;
// Adjust for creation of a boundary face from an internal face
forAll(addr, faceI)
{
if (newFaceLabelsMap[faceI] < oldNInternal)
{
addr[faceI] = 0;
}
else
{
addr[faceI] = newFaceLabelsMap[faceI];
}
}
}
else
{
// There are further faces to add. Prepare interpolation addressing
// and weights to full size
interpolationAddrPtr_ = new labelListList(newFaceLabels.size());
labelListList& addr = *interpolationAddrPtr_;
weightsPtr_ = new scalarListList(newFaceLabels.size());
scalarListList& w = *weightsPtr_;
// Insert single addressing and weights
for (label addrI = 0; addrI < nNewFaces; ++addrI)
{
addr[addrI] = labelList(1, newFaceLabelsMap[addrI]);
w[addrI] = scalarList(1, scalar(1));
}
// Pick up faces from points, edges and faces where the origin
// Only map from faces which were previously in the faMesh, using
// fast lookup
// Set of faces previously in the mesh
labelHashSet oldFaceLookup(oldFaces);
// Go through faces-from lists and add the ones where all
// old face labels belonged to the faMesh
const List<objectMap>& ffp = mpm_.facesFromPointsMap();
forAll(ffp, ffpI)
{
// Get addressing
const labelList& mo = ffp[ffpI].masterObjects();
// Check if master objects are in faMesh
labelList validMo(mo.size());
label nValidMo = 0;
forAll(mo, moI)
{
if (oldFaceLookup.found(mo[moI]))
{
validMo[nValidMo] = oldFaceLookup[mo[moI]];
nValidMo++;
}
}
if (nValidMo > 0)
{
// Some objects found: add face and interpolation to list
newFaceLabels[nNewFaces] = ffp[ffpI].index();
// No old face available
newFaceLabelsMap[nNewFaces] = -1;
// Map from masters, uniform weights
addr[nNewFaces] = validMo;
w[nNewFaces] = scalarList(validMo.size(), 1.0/validMo.size());
nNewFaces++;
}
}
const List<objectMap>& ffe = mpm_.facesFromEdgesMap();
forAll(ffe, ffeI)
{
// Get addressing
const labelList& mo = ffe[ffeI].masterObjects();
// Check if master objects are in faMesh
labelList validMo(mo.size());
label nValidMo = 0;
forAll(mo, moI)
{
if (oldFaceLookup.found(mo[moI]))
{
validMo[nValidMo] = oldFaceLookup[mo[moI]];
nValidMo++;
}
}
if (nValidMo > 0)
{
// Some objects found: add face and interpolation to list
newFaceLabels[nNewFaces] = ffe[ffeI].index();
// No old face available
newFaceLabelsMap[nNewFaces] = -1;
// Map from masters, uniform weights
addr[nNewFaces] = validMo;
w[nNewFaces] = scalarList(validMo.size(), 1.0/validMo.size());
nNewFaces++;
}
}
const List<objectMap>& fff = mpm_.facesFromFacesMap();
forAll(fff, fffI)
{
// Get addressing
const labelList& mo = fff[fffI].masterObjects();
// Check if master objects are in faMesh
labelList validMo(mo.size());
label nValidMo = 0;
forAll(mo, moI)
{
if (oldFaceLookup.found(mo[moI]))
{
validMo[nValidMo] = oldFaceLookup[mo[moI]];
nValidMo++;
}
}
if (nValidMo > 0)
{
// Some objects found: add face and interpolation to list
newFaceLabels[nNewFaces] = fff[fffI].index();
// No old face available
newFaceLabelsMap[nNewFaces] = -1;
// Map from masters, uniform weights
addr[nNewFaces] = validMo;
w[nNewFaces] = scalarList(validMo.size(), 1.0/validMo.size());
nNewFaces++;
}
}
// All faces collected. Reset sizes of lists
newFaceLabels.setSize(nNewFaces);
newFaceLabelsMap.setSize(nNewFaces);
addr.setSize(nNewFaces);
w.setSize(nNewFaces);
Info<< "addr: " << addr << nl
<< "w: " << w << endl;
}
// Inserted objects cannot appear in the new faMesh as they have no master
// HJ, 10/Aug/2011
insertedObjectLabelsPtr_ = new labelList(0);
}
void Foam::faAreaMapper::clearOut()
{
deleteDemandDrivenData(newFaceLabelsPtr_);
deleteDemandDrivenData(newFaceLabelsMapPtr_);
deleteDemandDrivenData(directAddrPtr_);
deleteDemandDrivenData(interpolationAddrPtr_);
deleteDemandDrivenData(weightsPtr_);
deleteDemandDrivenData(insertedObjectLabelsPtr_);
hasUnmapped_ = false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faAreaMapper::faAreaMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
)
:
mesh_(mesh),
mpm_(mpm),
insertedFaces_(false),
direct_(false),
hasUnmapped_(false),
sizeBeforeMapping_(mesh.nFaces()),
newFaceLabelsPtr_(nullptr),
newFaceLabelsMapPtr_(nullptr),
directAddrPtr_(nullptr),
interpolationAddrPtr_(nullptr),
weightsPtr_(nullptr),
insertedObjectLabelsPtr_(nullptr)
{
// Check for possibility of direct mapping
if
(
mpm_.facesFromPointsMap().empty()
&& mpm_.facesFromEdgesMap().empty()
&& mpm_.facesFromFacesMap().empty()
)
{
direct_ = true;
}
else
{
direct_ = false;
}
// Inserted objects not suported: no master
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faAreaMapper::~faAreaMapper()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelList& Foam::faAreaMapper::newFaceLabels() const
{
if (!newFaceLabelsPtr_)
{
calcAddressing();
}
return *newFaceLabelsPtr_;
}
const Foam::labelList& Foam::faAreaMapper::newFaceLabelsMap() const
{
if (!newFaceLabelsMapPtr_)
{
calcAddressing();
}
return *newFaceLabelsMapPtr_;
}
const Foam::labelUList& Foam::faAreaMapper::directAddressing() const
{
if (!direct())
{
FatalErrorInFunction
<< "Requested direct addressing for an interpolative mapper."
<< abort(FatalError);
}
if (!directAddrPtr_)
{
calcAddressing();
}
return *directAddrPtr_;
}
const Foam::labelListList& Foam::faAreaMapper::addressing() const
{
if (direct())
{
FatalErrorInFunction
<< "Requested interpolative addressing for a direct mapper."
<< abort(FatalError);
}
if (!interpolationAddrPtr_)
{
calcAddressing();
}
return *interpolationAddrPtr_;
}
const Foam::scalarListList& Foam::faAreaMapper::weights() const
{
if (direct())
{
FatalErrorInFunction
<< "Requested interpolative weights for a direct mapper."
<< abort(FatalError);
}
if (!weightsPtr_)
{
calcAddressing();
}
return *weightsPtr_;
}
const Foam::labelList& Foam::faAreaMapper::insertedObjectLabels() const
{
if (!insertedObjectLabelsPtr_)
{
calcAddressing();
}
return *insertedObjectLabelsPtr_;
}
// ************************************************************************* //

View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faAreaMapper
Description
FA area mapper.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faAreaMapper.C
\*---------------------------------------------------------------------------*/
#ifndef faAreaMapper_H
#define faAreaMapper_H
#include "morphFieldMapper.H"
#include "faMesh.H"
#include "faceMapper.H"
#include "HashSet.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faAreaMapper Declaration
\*---------------------------------------------------------------------------*/
class faAreaMapper
:
public morphFieldMapper
{
// Private data
//- Reference to mesh mapper
const faMesh& mesh_;
//- Reference to mapPolyMesh
const mapPolyMesh& mpm_;
//- Are there any inserted (unmapped) faces
bool insertedFaces_;
//- Is the mapping direct
bool direct_;
// Demand-driven private data
mutable bool hasUnmapped_;
//- Old mesh size
label sizeBeforeMapping_;
//- New face labels after mapping
mutable labelList* newFaceLabelsPtr_;
//- New face labels after mapping
mutable labelList* newFaceLabelsMapPtr_;
//- Direct addressing (only one form of addressing is used)
mutable labelList* directAddrPtr_;
//- Interpolated addressing (only one form of addressing is used)
mutable labelListList* interpolationAddrPtr_;
//- Interpolation weights
mutable scalarListList* weightsPtr_;
//- Inserted faces
mutable labelList* insertedObjectLabelsPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
faAreaMapper(const faAreaMapper&);
//- Disallow default bitwise assignment
void operator=(const faAreaMapper&);
//- Calculate addressing
void calcAddressing() const;
//- Clear out local storage
void clearOut();
public:
//- Construct from components
faAreaMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
);
//- Destructor
virtual ~faAreaMapper();
// Member Functions
//- Return new face labels
const labelList& newFaceLabels() const;
//- Return new face labels map
// For new faces return old face index if it exists
// If the face has been added, index will be -1
const labelList& newFaceLabelsMap() const;
//- Return size
virtual label size() const
{
return newFaceLabels().size();
}
//- Return size of field before mapping
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
//- Is the mapping direct
virtual bool direct() const
{
return direct_;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;
}
//- Return direct addressing
virtual const labelUList& directAddressing() const;
//- Return interpolated addressing
virtual const labelListList& addressing() const;
//- Return interpolaion weights
virtual const scalarListList& weights() const;
//- Are there any inserted faces
virtual bool insertedObjects() const
{
return !insertedObjectLabels().empty();
}
//- Return list of inserted faces
virtual const labelList& insertedObjectLabels() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,101 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faBoundaryMeshMapper
Description
Foam::faBoundaryMeshMapper
\*---------------------------------------------------------------------------*/
#ifndef faBoundaryMeshMapper_H
#define faBoundaryMeshMapper_H
#include "PtrList.H"
#include "faPatchMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faBoundaryMeshMapper Declaration
\*---------------------------------------------------------------------------*/
class faBoundaryMeshMapper
:
public PtrList<faPatchMapper>
{
// Private Member Functions
//- Disallow default bitwise copy construct
faBoundaryMeshMapper(const faBoundaryMeshMapper&);
//- Disallow default bitwise assignment
void operator=(const faBoundaryMeshMapper&);
public:
// Constructors
//- Construct from components
faBoundaryMeshMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
)
:
PtrList<faPatchMapper>(mesh.boundary().size())
{
const faBoundaryMesh& patches = mesh.boundary();
forAll(patches, patchI)
{
set
(
patchI,
new faPatchMapper
(
patches[patchI],
mpm
)
);
}
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,116 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Description
FA edge mapper.
\*---------------------------------------------------------------------------*/
#include "faEdgeMapper.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faEdgeMapper::calcAddressing() const
{
if (directAddrPtr_)
{
FatalErrorInFunction
<< "Addressing already calculated"
<< abort(FatalError);
}
hasUnmapped_ = false;
// Dummy mapping: take value from edge 0
directAddrPtr_ = new labelList(size(), 0);
}
void Foam::faEdgeMapper::clearOut()
{
deleteDemandDrivenData(directAddrPtr_);
hasUnmapped_ = false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faEdgeMapper::faEdgeMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
)
:
mesh_(mesh),
mpm_(mpm),
sizeBeforeMapping_(mesh.nInternalEdges()),
hasUnmapped_(false),
directAddrPtr_(nullptr)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faEdgeMapper::~faEdgeMapper()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelUList& Foam::faEdgeMapper::directAddressing() const
{
if (!directAddrPtr_)
{
calcAddressing();
}
return *directAddrPtr_;
}
const Foam::labelListList& Foam::faEdgeMapper::addressing() const
{
FatalErrorInFunction
<< "Requested interpolative addressing for a direct mapper."
<< abort(FatalError);
return labelListList::null();
}
const Foam::scalarListList& Foam::faEdgeMapper::weights() const
{
FatalErrorInFunction
<< "Requested interpolative weights for a direct mapper."
<< abort(FatalError);
return scalarListList::null();
}
// ************************************************************************* //

View File

@ -0,0 +1,169 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faEdgeMapper
Description
FA edge mapper. Currently, edge-based finite area data is not mapped,
but only resized, since edge-based mapping data is not available
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faEdgeMapper.C
\*---------------------------------------------------------------------------*/
#ifndef faEdgeMapper_H
#define faEdgeMapper_H
#include "morphFieldMapper.H"
#include "faMesh.H"
#include "faceMapper.H"
#include "HashSet.H"
#include "mapPolyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faEdgeMapper Declaration
\*---------------------------------------------------------------------------*/
class faEdgeMapper
:
public morphFieldMapper
{
// Private data
//- Reference to mesh
const faMesh& mesh_;
//- Reference to mapPolyMesh
const mapPolyMesh& mpm_;
//- Old mesh size
label sizeBeforeMapping_;
// Demand-driven private data
mutable bool hasUnmapped_;
//- Direct addressing
mutable labelList* directAddrPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
faEdgeMapper(const faEdgeMapper&);
//- Disallow default bitwise assignment
void operator=(const faEdgeMapper&);
//- Calculate addressing
void calcAddressing() const;
//- Clear out local storage
void clearOut();
public:
//- Construct from components
faEdgeMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
);
//- Destructor
virtual ~faEdgeMapper();
// Member Functions
//- Return size
virtual label size() const
{
return mesh_.nInternalEdges();
}
//- Return size of field before mapping
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
//- Is the mapping direct
virtual bool direct() const
{
return true;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;
}
//- Return direct addressing
virtual const labelUList& directAddressing() const;
//- Return interpolated addressing
virtual const labelListList& addressing() const;
//- Return interpolaion weights
virtual const scalarListList& weights() const;
//- Are there any inserted faces
virtual bool insertedObjects() const
{
return false;
}
//- Return list of inserted faces
virtual const labelList& insertedObjectLabels() const
{
return labelList::null();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "faMeshMapper.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faMeshMapper::faMeshMapper
(
const faMesh& mesh,
const mapPolyMesh& mpm
)
:
mesh_(mesh),
nOldPoints_(mesh.nPoints()),
nOldEdges_(mesh.nEdges()),
nOldInternalEdges_(mesh.nInternalEdges()),
nOldFaces_(mesh.nFaces()),
oldPatchSizes_(mesh.boundary().size(), 0),
oldPatchStarts_(mesh.boundary().size(), -1),
oldPatchEdgeFaces_(mesh.boundary().size()),
areaMap_(mesh, mpm),
edgeMap_(mesh, mpm),
boundaryMap_(mesh, mpm)
{
// Capture old patch information
const faBoundaryMesh& patches = mesh.boundary();
forAll(patches, patchI)
{
oldPatchSizes_[patchI] = patches[patchI].size();
oldPatchStarts_[patchI] = patches[patchI].start();
oldPatchEdgeFaces_[patchI] = patches[patchI].edgeFaces();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,221 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faMeshMapper
Description
Class holds all the necessary information for mapping fields associated
with faMesh
Note
In order to capture all necessary mesh sizes and mapping data, mapper
is created with the OLD mesh, and provides new mesh data.
In the process, field mapping information is assembled from the old faMesh
and the mapping data
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faMeshMapper.C
\*---------------------------------------------------------------------------*/
#ifndef faMeshMapper_H
#define faMeshMapper_H
#include "faceMapper.H"
#include "faAreaMapper.H"
#include "faEdgeMapper.H"
#include "faBoundaryMeshMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class faMesh;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class faMeshMapper Declaration
\*---------------------------------------------------------------------------*/
class faMeshMapper
{
// Private data
//- Reference to mesh
const faMesh& mesh_;
// Old mesh data
//- Number of old points
label nOldPoints_;
//- Number of old edges
label nOldEdges_;
//- Number of old internal edges
label nOldInternalEdges_;
//- Number of old faces
label nOldFaces_;
//- Old patch sizes
labelList oldPatchSizes_;
//- Old patch starts
labelList oldPatchStarts_;
//- Old patch edgeFaces
labelListList oldPatchEdgeFaces_;
// Mappers
//- Area mapper
faAreaMapper areaMap_;
//- Edge mapper
faEdgeMapper edgeMap_;
//- Boundary mapper
faBoundaryMeshMapper boundaryMap_;
// Private Member Functions
//- Disallow default bitwise copy construct
faMeshMapper(const faMeshMapper&);
//- Disallow default bitwise assignment
void operator=(const faMeshMapper&);
public:
// Constructors
//- Construct from components
faMeshMapper(const faMesh& mesh, const mapPolyMesh& mpm);
// Member Functions
//- Return reference to mesh
const faMesh& mesh() const
{
return mesh_;
}
//- Return reference to objectRegistry storing fields. Can be
// removed once fields stored on pointMesh.
const objectRegistry& thisDb() const
{
return mesh_.thisDb();
}
// Basic sizing information
//- Return number of old points
label nOldPoints() const
{
return nOldPoints_;
}
//- Return number of old edges
label nOldEdges() const
{
return nOldEdges_;
};
//- Return number of old internal edges
label nOldInternalEdges() const
{
return nOldInternalEdges_;
};
//- Return number of old faces
label nOldFaces() const
{
return nOldFaces_;
};
//- Return old patch sizes
const labelList& oldPatchSizes() const
{
return oldPatchSizes_;
};
//- Return old patch starts
const labelList& oldPatchStarts() const
{
return oldPatchStarts_;
};
//- Return old patch edgeFaces
const labelListList& oldPatchEdgeFaces() const
{
return oldPatchEdgeFaces_;
};
// Mappers
//- Return surface mapper
const faAreaMapper& areaMap() const
{
return areaMap_;
}
//- Return edge mapper
const faEdgeMapper& edgeMap() const
{
return edgeMap_;
}
//- Return boundary mapper
const faBoundaryMeshMapper& boundaryMap() const
{
return boundaryMap_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,155 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "faPatchMapper.H"
#include "faPatch.H"
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "mapPolyMesh.H"
#include "faceMapper.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faPatchMapper::calcAddressing() const
{
if (directAddrPtr_)
{
FatalErrorInFunction
<< "Addressing already calculated"
<< abort(FatalError);
}
// Compatibility change HJ, 12/Aug/2017
hasUnmapped_ = false;
directAddrPtr_ = new labelList(patch_.size(), 0);
labelList& addr = *directAddrPtr_;
// Make a map of old edgeFaces, giving edge index in patch given the new
// face label next to the patch
// Create edge index lookup
Map<label> edgeIndexLookup;
const labelList& reverseFaceMap = mpm_.reverseFaceMap();
forAll(oldEdgeFaces_, oefI)
{
if (reverseFaceMap[oldEdgeFaces_[oefI]] > -1)
{
// Face has survived. Insert its label under new face index
edgeIndexLookup.insert(reverseFaceMap[oldEdgeFaces_[oefI]], oefI);
}
}
// Go through new edgeFaces and for each edge try to locate old index
const labelList& ef = patch_.edgeFaces();
forAll(ef, efI)
{
if (edgeIndexLookup.found(ef[efI]))
{
addr[efI] = edgeIndexLookup[ef[efI]];
}
else
{
// Not found: map from zero
addr[efI] = 0;
// Compatibility change HJ, 12/Aug/2017
hasUnmapped_ = true;
}
}
}
void Foam::faPatchMapper::clearOut()
{
deleteDemandDrivenData(directAddrPtr_);
hasUnmapped_ = false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faPatchMapper::faPatchMapper
(
const faPatch& patch,
const mapPolyMesh& mpm
)
:
patch_(patch),
mpm_(mpm),
sizeBeforeMapping_(patch.size()),
oldEdgeFaces_(patch.edgeFaces()),
hasUnmapped_(false),
directAddrPtr_(nullptr)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faPatchMapper::~faPatchMapper()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelUList& Foam::faPatchMapper::directAddressing() const
{
if (!directAddrPtr_)
{
calcAddressing();
}
return *directAddrPtr_;
}
const Foam::labelListList& Foam::faPatchMapper::addressing() const
{
FatalErrorInFunction
<< "Requested interpolative addressing for a direct mapper."
<< abort(FatalError);
return labelListList::null();
}
const Foam::scalarListList& Foam::faPatchMapper::weights() const
{
FatalErrorInFunction
<< "Requested interpolative weights for a direct mapper."
<< abort(FatalError);
return scalarListList::null();
}
// ************************************************************************* //

View File

@ -0,0 +1,164 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faPatchMapper
Description
Mapping class for a faPatchField. Edge mapping is calculated based on
faceCells comparison of old and new patch
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faPatchMapper.C
\*---------------------------------------------------------------------------*/
#ifndef faPatchMapper_H
#define faPatchMapper_H
#include "faPatchFieldMapper.H"
#include "faceMapper.H"
#include "faPatch.H"
#include "primitiveFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class faPatch;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class faPatchMapper Declaration
\*---------------------------------------------------------------------------*/
class faPatchMapper
:
public faPatchFieldMapper
{
// Private data
//- Reference to patch
const faPatch& patch_;
//- Reference to mapPolyMesh
const mapPolyMesh& mpm_;
//- Size before mapping
const label sizeBeforeMapping_;
//- faceCells before mapping
const labelList oldEdgeFaces_;
// Demand-driven private data
mutable bool hasUnmapped_;
//- Direct addressing
mutable labelList* directAddrPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
faPatchMapper(const faPatchMapper&);
//- Disallow default bitwise assignment
void operator=(const faPatchMapper&);
//- Calculate addressing for mapping with inserted cells
void calcAddressing() const;
//- Clear out local storage
void clearOut();
public:
//- Construct from mappers
faPatchMapper
(
const faPatch& patch,
const mapPolyMesh& mpm
);
// Destructor
virtual ~faPatchMapper();
// Member Functions
//- Return size
virtual label size() const
{
return patch_.size();
}
//- Return size of field before mapping
virtual label sizeBeforeMapping() const
{
return sizeBeforeMapping_;
}
//- Is the mapping direct
virtual bool direct() const
{
return true;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;
}
//- Return direct addressing
virtual const labelUList& directAddressing() const;
//- Return interpolated addressing
virtual const labelListList& addressing() const;
//- Return interpolaion weights
virtual const scalarListList& weights() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,244 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "faMesh.H"
#include "mapPolyMesh.H"
#include "MapFaFields.H"
#include "faMeshMapper.H"
#include "areaFields.H"
#include "edgeFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::faMesh::updateMesh(const mapPolyMesh& mpm)
{
if (debug)
{
Info<< "bool faMesh::updateMesh(const mapPolyMesh& mpm) : "
<< "Updating mesh" << endl;
}
// if (!mpm.morphing())
// {
// // No topo change
// return false;
// }
// Create fa mesh mapper, using the old mesh
const faMeshMapper mapper(*this, mpm);
// Rebuild mesh
// Cast away const for interface reasons. HJ, 12/Aug/2011
faMesh& m = const_cast<faMesh&>(*this);
// Clear existing mesh data
clearOut();
// Set new labels
m.faceLabels_ = mapper.areaMap().newFaceLabels();
const indirectPrimitivePatch& bp = patch();
// Collect patch data
const label nTotalEdges = bp.nEdges();
const label nInternalEdges = bp.nInternalEdges();
const labelListList& edgeFaces = bp.edgeFaces();
labelListList patchEdges(boundary_.size());
// Special handling required for faces that have more than one edge
// Each patch will be visited separately
labelList edgeToPatch(nTotalEdges - nInternalEdges, -1);
const labelList& newFaceLabelsMap = mapper.areaMap().newFaceLabelsMap();
const labelListList& oldPatchEdgeFaces = mapper.oldPatchEdgeFaces();
forAll(oldPatchEdgeFaces, patchI)
{
labelList& curPatchEdges = patchEdges[patchI];
curPatchEdges.setSize(nTotalEdges - nInternalEdges);
label nCurPatchEdges = 0;
// Note: it is possible to pick up the old-to-new boundary patch
// mapping, but currently this is not done. HJ, 13/Aug/2011
// Make a fast lookup
labelHashSet oldFaceLookup(oldPatchEdgeFaces[patchI]);
for (label edgeI = nInternalEdges; edgeI < nTotalEdges; ++edgeI)
{
if (edgeToPatch[edgeI - nInternalEdges] > -1)
{
// Edge already found; continue with the next one
continue;
}
// Boundary edges will only have one face next to them
const label oldFaceIndex = newFaceLabelsMap[edgeFaces[edgeI][0]];
if (oldFaceIndex > -1)
{
// Old face exists. See if it has got an edge in this patch
if (oldFaceLookup.found(oldFaceIndex))
{
// Face found, add it to the patch
curPatchEdges[nCurPatchEdges] = edgeI;
nCurPatchEdges++;
edgeToPatch[edgeI - nInternalEdges] = patchI;
}
}
}
// Collected all faces for the current patch
curPatchEdges.setSize(nCurPatchEdges);
}
// Set new edges for all patches
forAll(m.boundary_, patchI)
{
m.boundary_[patchI].resetEdges(patchEdges[patchI]);
}
m.setPrimitiveMeshData();
// Create global mesh data
if (Pstream::parRun())
{
globalData();
}
// Calculate topology for the patches (processor-processor comms etc.)
m.boundary_.updateMesh();
// Calculate the geometry for the patches (transformation tensors etc.)
m.boundary_.calcGeometry();
// Map fields
mapFields(mapper);
// Map old areas
mapOldAreas(mapper);
// Update edge interpolation
edgeInterpolation::movePoints();
return;
}
void Foam::faMesh::mapFields(const faMeshMapper& mapper) const
{
// Map all the areaFields in the objectRegistry
MapGeometricFields<scalar, faPatchField, faMeshMapper, areaMesh>(mapper);
MapGeometricFields<vector, faPatchField, faMeshMapper, areaMesh>(mapper);
MapGeometricFields<sphericalTensor, faPatchField, faMeshMapper, areaMesh>
(mapper);
MapGeometricFields<symmTensor, faPatchField, faMeshMapper, areaMesh>
(mapper);
MapGeometricFields<tensor, faPatchField, faMeshMapper, areaMesh>(mapper);
// Map all the edgeFields in the objectRegistry
MapGeometricFields<scalar, faePatchField, faMeshMapper, edgeMesh>(mapper);
MapGeometricFields<vector, faePatchField, faMeshMapper, edgeMesh>(mapper);
MapGeometricFields<sphericalTensor, faePatchField, faMeshMapper, edgeMesh>
(mapper);
MapGeometricFields<symmTensor, faePatchField, faMeshMapper, edgeMesh>
(mapper);
MapGeometricFields<tensor, faePatchField, faMeshMapper, edgeMesh>(mapper);
}
void Foam::faMesh::mapOldAreas(const faMeshMapper& mapper) const
{
if (S0Ptr_)
{
if (debug)
{
InfoIn("void faMesh::mapOldAreas(const faMeshMapper& mapper)")
<< "Mapping old face areas." << endl;
}
scalarField& S0 = *S0Ptr_;
scalarField savedS0(S0);
S0.setSize(nFaces());
const labelList& faceMap = mapper.areaMap().newFaceLabelsMap();
// Map existing old areas; for new faces set area to zero
forAll(faceMap, faceI)
{
if (faceMap[faceI] > -1)
{
S0[faceI] = savedS0[faceMap[faceI]];
}
else
{
S0[faceI] = 0;
}
}
}
if (S00Ptr_)
{
if (debug)
{
InfoIn("void faMesh::mapOldAreas(const faMeshMapper& mapper)")
<< "Mapping old-old face areas." << endl;
}
scalarField& S00 = *S00Ptr_;
scalarField savedS00(S00);
S00.setSize(nFaces());
const labelList& faceMap = mapper.areaMap().newFaceLabelsMap();
// Map old areas for existing faces; for new faces, set area to zero
forAll(faceMap, faceI)
{
if (faceMap[faceI] > -1)
{
S00[faceI] = savedS00[faceMap[faceI]];
}
else
{
S00[faceI] = 0;
}
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "coupledFaPatch.H"
#include "transform.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(coupledFaPatch, 0);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::coupledFaPatch::calcTransformTensors
(
const vector& Cf,
const vector& Cr,
const vector& nf,
const vector& nr
) const
{
if (mag(nf & nr) < 1 - SMALL)
{
separation_.setSize(0);
forwardT_ = tensorField(1, rotationTensor(-nr, nf));
reverseT_ = tensorField(1, rotationTensor(nf, -nr));
}
else
{
forwardT_.setSize(0);
reverseT_.setSize(0);
vector separation = (nf & (Cr - Cf))*nf;
if (mag(separation) > SMALL)
{
separation_ = vectorField(1, separation);
}
else
{
separation_.setSize(0);
}
}
}
void Foam::coupledFaPatch::calcTransformTensors
(
const vectorField& Cf,
const vectorField& Cr,
const vectorField& nf,
const vectorField& nr
) const
{
if (sum(mag(nf & nr)) < Cf.size() - SMALL)
{
separation_.setSize(0);
forwardT_.setSize(size());
reverseT_.setSize(size());
forAll(forwardT_, facei)
{
forwardT_[facei] = rotationTensor(-nr[facei], nf[facei]);
reverseT_[facei] = rotationTensor(nf[facei], -nr[facei]);
}
if (sum(mag(forwardT_ - forwardT_[0])) < SMALL)
{
forwardT_.setSize(1);
reverseT_.setSize(1);
}
}
else
{
forwardT_.setSize(0);
reverseT_.setSize(0);
separation_ = (nf&(Cr - Cf))*nf;
if (sum(mag(separation_)) < SMALL)
{
separation_.setSize(0);
}
else if (sum(mag(separation_ - separation_[0])) < SMALL)
{
separation_.setSize(1);
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::coupledFaPatch::~coupledFaPatch()
{}
// ************************************************************************* //

View File

@ -0,0 +1,279 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::coupledFaPatch
Author
Zeljko Tukovic and Hrvoje Jasak
Description
coupledFaPatch is an abstract base class for patches that couple regions
of the computational domain e.g. cyclic, arbitrary interfaces, sliding
interfaces and processor-processor links.
SourceFiles
coupledFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef coupledFaPatch_H
#define coupledFaPatch_H
#include "lduInterface.H"
#include "faPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class coupledFaPatch Declaration
\*---------------------------------------------------------------------------*/
class coupledFaPatch
:
public lduInterface,
public faPatch
{
// Private data
//- offset (distance) vector from one side of the couple to the other
mutable vectorField separation_;
//- Face transformation tensor
mutable tensorField forwardT_;
//- Neighbour-cell transformation tensor
mutable tensorField reverseT_;
protected:
// Protected Member Functions
//- Make patch weighting factors
virtual void makeWeights(scalarField&) const = 0;
//- Make patch face - neighbour cell distances
virtual void makeDeltaCoeffs(scalarField&) const = 0;
//- Calculate the uniform transformation tensors
void calcTransformTensors
(
const vector& Cf,
const vector& Cr,
const vector& nf,
const vector& nr
) const;
//- Calculate the transformation tensors
void calcTransformTensors
(
const vectorField& Cf,
const vectorField& Cr,
const vectorField& nf,
const vectorField& nr
) const;
public:
//- Runtime type information
TypeName("coupled");
// Constructors
//- Construct from components
coupledFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
)
:
faPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex)
{}
//- Construct from dictionary
coupledFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
faPatch(name, dict, index, bm)
{}
//- Destructor
virtual ~coupledFaPatch();
// Member Functions
// Access
//- Return true because this patch is coupled
virtual bool coupled() const
{
return true;
}
//- Are the coupled planes separated
bool separated() const
{
return separation_.size();
}
//- Return the offset (distance) vector from one side of the couple
// to the other
const vectorField& separation() const
{
if (!separation_.size())
{
FatalErrorInFunction
<< "Coupled patches are not separated"
<< abort(FatalError);
}
return separation_;
}
//- Return face transformation tensor
const tensorField& forwardT() const
{
if (!forwardT_.size())
{
FatalErrorInFunction
<< "Coupled planes do not need transformation"
<< abort(FatalError);
}
return forwardT_;
}
//- Return neighbour-cell transformation tensor
const tensorField& reverseT() const
{
if (!reverseT_.size())
{
FatalErrorInFunction
<< "Coupled planes do not need transformation"
<< abort(FatalError);
}
return reverseT_;
}
//- Are the cyclic planes parallel
bool parallel() const
{
return forwardT_.size() == 0;
}
//- Initialise the calculation of the patch geometry
virtual void initGeometry() = 0;
//- Calculate the patch geometry
virtual void calcGeometry() = 0;
//- Initialise the patches for moving points
virtual void initMovePoints(const pointField&) = 0;
//- Correct patches after moving points
virtual void movePoints(const pointField&) = 0;
// Access functions for demand driven data
//- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const = 0;
// Interface transfer functions
//- Return faceCell addressing: lduInterface virtual function
virtual const labelUList& faceCells() const
{
return edgeFaces();
}
//- Return the values of the given internal data adjacent to
// the interface as a field
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData
) const = 0;
//- Initialise interface data transfer
virtual void initTransfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const
{}
//- Transfer and return neighbour field
virtual tmp<labelField> transfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const = 0;
//- Initialise neighbour field transfer
virtual void initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF
) const
{}
//- Return neighbour field
virtual tmp<labelField> internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,344 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "cyclicFaPatch.H"
#include "coupledPolyPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "transform.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cyclicFaPatch, 0);
addToRunTimeSelectionTable(faPatch, cyclicFaPatch, dictionary);
}
const Foam::scalar Foam::cyclicFaPatch::matchTol_ = 1e-3;
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cyclicFaPatch::calcTransforms()
{
if (size() > 0)
{
pointField half0Ctrs(size()/2);
pointField half1Ctrs(size()/2);
for (label i=0; i<size()/2; ++i)
{
half0Ctrs[i] = this->edgeCentres()[i];
half1Ctrs[i] = this->edgeCentres()[i+size()/2];
}
vectorField half0Normals(size()/2);
vectorField half1Normals(size()/2);
const vectorField eN(edgeNormals()*magEdgeLengths());
scalar maxMatchError = 0;
label errorEdge = -1;
for (label edgei = 0; edgei < size()/2; ++edgei)
{
half0Normals[edgei] = eN[edgei];
label nbrEdgei = edgei + size()/2;
half1Normals[edgei] = eN[nbrEdgei];
scalar magLe = mag(half0Normals[edgei]);
scalar nbrMagLe = mag(half1Normals[edgei]);
scalar avLe = (magLe + nbrMagLe)/2.0;
if (magLe < ROOTVSMALL && nbrMagLe < ROOTVSMALL)
{
// Undetermined normal. Use dummy normal to force separation
// check. (note use of sqrt(VSMALL) since that is how mag
// scales)
half0Normals[edgei] = point(1, 0, 0);
half1Normals[edgei] = half0Normals[edgei];
}
else if (mag(magLe - nbrMagLe)/avLe > matchTol_)
{
// Error in area matching. Find largest error
maxMatchError =
Foam::max(maxMatchError, mag(magLe - nbrMagLe)/avLe);
errorEdge = edgei;
}
else
{
half0Normals[edgei] /= magLe;
half1Normals[edgei] /= nbrMagLe;
}
}
// Check for error in edge matching
if (maxMatchError > matchTol_)
{
label nbrEdgei = errorEdge + size()/2;
scalar magLe = mag(half0Normals[errorEdge]);
scalar nbrMagLe = mag(half1Normals[errorEdge]);
scalar avLe = (magLe + nbrMagLe)/2.0;
FatalErrorInFunction
<< "edge " << errorEdge
<< " area does not match neighbour "
<< nbrEdgei << " by "
<< 100*mag(magLe - nbrMagLe)/avLe
<< "% -- possible edge ordering problem." << endl
<< "patch:" << name()
<< " my area:" << magLe
<< " neighbour area:" << nbrMagLe
<< " matching tolerance:" << matchTol_
<< endl
<< "Mesh edge:" << start() + errorEdge
<< endl
<< "Neighbour edge:" << start() + nbrEdgei
<< endl
<< "Other errors also exist, only the largest is reported. "
<< "Please rerun with cyclic debug flag set"
<< " for more information." << exit(FatalError);
}
// Calculate transformation tensors
calcTransformTensors
(
half0Ctrs,
half1Ctrs,
half0Normals,
half1Normals
);
// Check transformation tensors
if (!parallel())
{
if (forwardT().size() > 1 || reverseT().size() > 1)
{
SeriousErrorInFunction
<< "Transformation tensor is not constant for the cyclic "
<< "patch. Please reconsider your setup and definition of "
<< "cyclic boundaries." << endl;
}
}
}
}
void Foam::cyclicFaPatch::makeWeights(scalarField& w) const
{
const scalarField& magL = magEdgeLengths();
const scalarField deltas(edgeNormals() & faPatch::delta());
label sizeby2 = deltas.size()/2;
scalar maxMatchError = 0;
label errorEdge = -1;
for (label edgei = 0; edgei < sizeby2; ++edgei)
{
scalar avL = (magL[edgei] + magL[edgei + sizeby2])/2.0;
if
(
mag(magL[edgei] - magL[edgei + sizeby2])/avL
> matchTol_
)
{
// Found error. Look for largest matching error
maxMatchError =
Foam::max
(
maxMatchError,
mag(magL[edgei] - magL[edgei + sizeby2])/avL
);
errorEdge = edgei;
}
scalar di = deltas[edgei];
scalar dni = deltas[edgei + sizeby2];
w[edgei] = dni/(di + dni);
w[edgei + sizeby2] = 1 - w[edgei];
}
// Check for error in matching
if (maxMatchError > matchTol_)
{
scalar avL = (magL[errorEdge] + magL[errorEdge + sizeby2])/2.0;
FatalErrorInFunction
<< "edge " << errorEdge << " and " << errorEdge + sizeby2
<< " areas do not match by "
<< 100*mag(magL[errorEdge] - magL[errorEdge + sizeby2])/avL
<< "% -- possible edge ordering problem." << nl
<< "Cyclic area match tolerance = "
<< matchTol_ << " patch: " << name()
<< abort(FatalError);
}
}
void Foam::cyclicFaPatch::makeDeltaCoeffs(scalarField& dc) const
{
const scalarField deltas(edgeNormals() & faPatch::delta());
label sizeby2 = deltas.size()/2;
for (label edgei = 0; edgei < sizeby2; ++edgei)
{
scalar di = deltas[edgei];
scalar dni = deltas[edgei + sizeby2];
dc[edgei] = 1.0/(di + dni);
dc[edgei + sizeby2] = dc[edgei];
}
}
void Foam::cyclicFaPatch::initGeometry()
{
faPatch::initGeometry();
}
void Foam::cyclicFaPatch::calcGeometry()
{
faPatch::calcGeometry();
calcTransforms();
}
void Foam::cyclicFaPatch::initMovePoints(const pointField& p)
{
faPatch::initMovePoints(p);
}
void Foam::cyclicFaPatch::movePoints(const pointField& p)
{
faPatch::movePoints(p);
calcTransforms();
}
Foam::tmp<Foam::vectorField> Foam::cyclicFaPatch::delta() const
{
const vectorField patchD(faPatch::delta());
label sizeby2 = patchD.size()/2;
tmp<vectorField> tpdv(new vectorField(patchD.size()));
vectorField& pdv = tpdv.ref();
// Do the transformation if necessary
if (parallel())
{
for (label edgei = 0; edgei < sizeby2; ++edgei)
{
const vector& ddi = patchD[edgei];
vector dni = patchD[edgei + sizeby2];
pdv[edgei] = ddi - dni;
pdv[edgei + sizeby2] = -pdv[edgei];
}
}
else
{
for (label edgei = 0; edgei < sizeby2; ++edgei)
{
const vector& ddi = patchD[edgei];
vector dni = patchD[edgei + sizeby2];
pdv[edgei] = ddi - transform(forwardT()[0], dni);
pdv[edgei + sizeby2] = -transform(reverseT()[0], pdv[edgei]);
}
}
return tpdv;
}
Foam::label Foam::cyclicPolyPatch::neighbPatchID() const
{
NotImplemented;
return -1;
}
Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::interfaceInternalField
(
const labelUList& internalData
) const
{
return patchInternalField(internalData);
}
Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::transfer
(
const Pstream::commsTypes,
const labelUList& interfaceData
) const
{
tmp<labelField> tpnf(new labelField(this->size()));
labelField& pnf = tpnf.ref();
label sizeby2 = this->size()/2;
for (label edgei=0; edgei<sizeby2; ++edgei)
{
pnf[edgei] = interfaceData[edgei + sizeby2];
pnf[edgei + sizeby2] = interfaceData[edgei];
}
return tpnf;
}
Foam::tmp<Foam::labelField> Foam::cyclicFaPatch::internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF
) const
{
const labelUList& edgeCells = this->faceCells();
tmp<labelField> tpnf(new labelField(this->size()));
labelField& pnf = tpnf.ref();
label sizeby2 = this->size()/2;
for (label edgei=0; edgei<sizeby2; ++edgei)
{
pnf[edgei] = iF[edgeCells[edgei + sizeby2]];
pnf[edgei + sizeby2] = iF[edgeCells[edgei]];
}
return tpnf;
}
// ************************************************************************* //

View File

@ -0,0 +1,200 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::cyclicFaPatch
Description
Cyclic-plane patch.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
cyclicFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicFaPatch_H
#define cyclicFaPatch_H
#include "coupledFaPatch.H"
#include "cyclicLduInterface.H"
#include "cyclicPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicFaPatch Declaration
\*---------------------------------------------------------------------------*/
class cyclicFaPatch
:
public coupledFaPatch,
public cyclicLduInterface
{
// Private member functions
void calcTransforms();
protected:
// Protected static data
//- Relative tolerance (for geometric matching). Is factor of
// maximum edge length per face.
static const scalar matchTol_;
// Protected Member functions
//- Make patch weighting factors
void makeWeights(scalarField&) const;
//- Make patch face - neighbour cell distances
void makeDeltaCoeffs(scalarField&) const;
public:
//- Runtime type information
TypeName("cyclic");
// Constructors
//- Construct from dictionary
cyclicFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
coupledFaPatch(name, dict, index, bm)
{}
//- Destructor
virtual ~cyclicFaPatch()
{}
// Member functions
// Access
//- Is this the master side? Yes: it contains both sets of faces
virtual bool master() const
{
return true;
}
//- Return neighbour
virtual label neighbPatchID() const
{
NotImplemented;
return index();
}
virtual bool owner() const
{
return master();
}
//- Return processor number
virtual const cyclicLduInterface& neighbPatch() const
{
NotImplemented;
return *this;
}
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return coupledFaPatch::forwardT();
}
//- Return neighbour-cell transformation tensor
virtual const tensorField& reverseT() const
{
return coupledFaPatch::reverseT();
}
//- Initialise the calculation of the patch geometry
virtual void initGeometry();
//- Calculate the patch geometry
virtual void calcGeometry();
//- Initialise the patches for moving points
virtual void initMovePoints(const pointField&);
//- Correct patches after moving points
virtual void movePoints(const pointField&);
//- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const;
// Interface transfer functions
//- Return the values of the given internal data adjacent to
// the interface as a field
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData
) const;
//- Transfer and return neighbour field
virtual tmp<labelField> transfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const;
//- Return neighbour field
virtual tmp<labelField> internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& internalData
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "emptyFaPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Patch name
defineTypeNameAndDebug(emptyFaPatch, 0);
// Add the patch constructor functions to the hash tables
addToRunTimeSelectionTable(faPatch, emptyFaPatch, dictionary);
// Over-riding the face normals return from the underlying patch
// This is the only piece of info used out of the underlying primitivePatch
// I choose to store it there because it is used in primitive patch operations
// and it should not be duplicated as before. However, to ensure everything
// in the empty patch is sized to zero, we shall here return a reference to
// a zero-sized field (it does not matter what the field is
//
// const vectorField& emptyFaPatch::edgeNormals() const
// {
// return faceAreas();
// }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::emptyFaPatch
Description
A patch which will not exist in the faMesh. Typical example is a front and
back plane of a 2-D geometry
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
emptyFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef emptyFaPatch_H
#define emptyFaPatch_H
#include "faPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class emptyFaPatch Declaration
\*---------------------------------------------------------------------------*/
class emptyFaPatch
:
public faPatch
{
public:
//- Runtime type information
TypeName("empty");
// Constructors
//- Construct from components
emptyFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
)
:
faPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex)
{}
//- Construct from dictionary
emptyFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
faPatch(name, dict, index, bm)
{}
//- Construct and return a clone, resetting the edge list
// and boundary mesh
virtual autoPtr<faPatch> clone
(
const faBoundaryMesh& bm,
const labelList& edgeLabels,
const label index,
const label ngbPolyPatchIndex
) const
{
return autoPtr<faPatch>
(
new emptyFaPatch
(
name(),
edgeLabels,
index,
bm,
ngbPolyPatchIndex
)
);
}
// Member Functions
virtual label size() const
{
return 0;
}
//- Return face normals. Over-riding base class return to get zero size
//
// virtual const vectorField& edgeNormals() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,517 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "processorFaPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "IPstream.H"
#include "OPstream.H"
#include "transformField.H"
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(processorFaPatch, 0);
addToRunTimeSelectionTable(faPatch, processorFaPatch, dictionary);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::processorFaPatch::~processorFaPatch()
{
deleteDemandDrivenData(neighbPointsPtr_);
deleteDemandDrivenData(nonGlobalPatchPointsPtr_);
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::label Foam::processorFaPatch::comm() const
{
return boundaryMesh().mesh().comm();
}
int Foam::processorFaPatch::tag() const
{
return Pstream::msgType();
}
void Foam::processorFaPatch::makeNonGlobalPatchPoints() const
{
// If it is not runing parallel or there are no global points
// create a 1->1 map
// Can not use faGlobalMeshData at this point yet
if
(
!Pstream::parRun()
|| !boundaryMesh().mesh()().globalData().nGlobalPoints()
// || !boundaryMesh().mesh().globalData().nGlobalPoints()
)
{
nonGlobalPatchPointsPtr_ = new labelList(nPoints());
labelList& ngpp = *nonGlobalPatchPointsPtr_;
forAll(ngpp, i)
{
ngpp[i] = i;
}
}
else
{
// Get reference to shared points
const labelList& sharedPoints =
boundaryMesh().mesh()().globalData().sharedPointLabels();
nonGlobalPatchPointsPtr_ = new labelList(nPoints());
labelList& ngpp = *nonGlobalPatchPointsPtr_;
const labelList& faMeshPatchPoints = pointLabels();
const labelList& meshPoints =
boundaryMesh().mesh().patch().meshPoints();
label noFiltPoints = 0;
forAll(faMeshPatchPoints, pointI)
{
label curP = meshPoints[faMeshPatchPoints[pointI]];
bool found = false;
forAll(sharedPoints, sharedI)
{
if (sharedPoints[sharedI] == curP)
{
found = true;
break;
}
}
if (!found)
{
ngpp[noFiltPoints] = pointI;
++noFiltPoints;
}
}
ngpp.setSize(noFiltPoints);
// // Get reference to shared points
// const labelList& sharedPoints =
// boundaryMesh().mesh().globalData().sharedPointLabels();
// nonGlobalPatchPointsPtr_ = new labelList(nPoints());
// labelList& ngpp = *nonGlobalPatchPointsPtr_;
// const labelList& patchPoints = pointLabels();
// label noFiltPoints = 0;
// forAll(patchPoints, pointI)
// {
// label curP = patchPoints[pointI];
// bool found = false;
// forAll(sharedPoints, pI)
// {
// if (sharedPoints[pI] == curP)
// {
// found = true;
// break;
// }
// }
// if (!found)
// {
// ngpp[noFiltPoints] = pointI;
// noFiltPoints++;
// }
// }
// ngpp.setSize(noFiltPoints);
}
}
void Foam::processorFaPatch::initGeometry()
{
if (Pstream::parRun())
{
OPstream toNeighbProc
(
Pstream::commsTypes::blocking,
neighbProcNo(),
3*(sizeof(label) + size()*sizeof(vector))
);
toNeighbProc
<< edgeCentres()
<< edgeLengths()
<< edgeFaceCentres();
}
}
void Foam::processorFaPatch::calcGeometry()
{
if (Pstream::parRun())
{
{
IPstream fromNeighbProc
(
Pstream::commsTypes::blocking,
neighbProcNo(),
3*(sizeof(label) + size()*sizeof(vector))
);
fromNeighbProc
>> neighbEdgeCentres_
>> neighbEdgeLengths_
>> neighbEdgeFaceCentres_;
}
const scalarField& magEl = magEdgeLengths();
forAll(magEl, edgei)
{
scalar nmagEl = mag(neighbEdgeLengths_[edgei]);
scalar avEl = (magEl[edgei] + nmagEl)/2.0;
if (mag(magEl[edgei] - nmagEl)/avEl > 1e-6)
{
FatalErrorInFunction
<< "edge " << edgei
<< " length does not match neighbour by "
<< 100*mag(magEl[edgei] - nmagEl)/avEl
<< "% -- possible edge ordering problem"
<< exit(FatalError);
}
}
calcTransformTensors
(
edgeCentres(),
neighbEdgeCentres_,
edgeNormals(),
neighbEdgeLengths_/mag(neighbEdgeLengths_)
);
}
}
void Foam::processorFaPatch::initMovePoints(const pointField& p)
{
faPatch::movePoints(p);
initGeometry();
}
void Foam::processorFaPatch::movePoints(const pointField&)
{
calcGeometry();
}
void Foam::processorFaPatch::initUpdateMesh()
{
// For completeness
faPatch::initUpdateMesh();
deleteDemandDrivenData(neighbPointsPtr_);
if (Pstream::parRun())
{
// Express all points as patch edge and index in edge.
labelList patchEdge(nPoints());
labelList indexInEdge(nPoints());
const edgeList::subList patchEdges =
patchSlice(boundaryMesh().mesh().edges());
const labelListList& ptEdges = pointEdges();
for (label patchPointI = 0; patchPointI < nPoints(); ++patchPointI)
{
label edgeI = ptEdges[patchPointI][0];
patchEdge[patchPointI] = edgeI;
const edge& e = patchEdges[edgeI];
indexInEdge[patchPointI] =
findIndex(e, pointLabels()[patchPointI]);
}
OPstream toNeighbProc
(
Pstream::commsTypes::blocking,
neighbProcNo(),
2*sizeof(label) + 2*nPoints()*sizeof(label)
);
toNeighbProc
<< patchEdge
<< indexInEdge;
}
}
void Foam::processorFaPatch::updateMesh()
{
// For completeness
faPatch::updateMesh();
if (Pstream::parRun())
{
labelList nbrPatchEdge(nPoints());
labelList nbrIndexInEdge(nPoints());
{
// Note cannot predict exact size since edgeList not (yet) sent as
// binary entity but as List of edges.
IPstream fromNeighbProc
(
Pstream::commsTypes::blocking,
neighbProcNo()
);
fromNeighbProc
>> nbrPatchEdge
>> nbrIndexInEdge;
}
if (nbrPatchEdge.size() == nPoints())
{
// Convert neighbour edges and indices into face back into
// my edges and points.
neighbPointsPtr_ = new labelList(nPoints());
labelList& neighbPoints = *neighbPointsPtr_;
const edgeList::subList patchEdges =
patchSlice(boundaryMesh().mesh().edges());
forAll(nbrPatchEdge, nbrPointI)
{
// Find edge and index in edge on this side.
const edge& e = patchEdges[nbrPatchEdge[nbrPointI]];
label index = 1 - nbrIndexInEdge[nbrPointI];
label patchPointI = findIndex(pointLabels(), e[index]);
neighbPoints[patchPointI] = nbrPointI;
}
}
else
{
// Differing number of points. Probably patch includes
// part of a cyclic.
neighbPointsPtr_ = nullptr;
}
}
}
const Foam::labelList& Foam::processorFaPatch::neighbPoints() const
{
if (!neighbPointsPtr_)
{
// Was probably created from cyclic patch and hence the
// number of edges or points might differ on both
// sides of the processor patch since one side might have
// it merged with another bit of geometry
FatalErrorInFunction
<< "No extended addressing calculated for patch " << name()
<< nl
<< "This can happen if the number of points on both"
<< " sides of the two coupled patches differ." << nl
<< "This happens if the processorPatch was constructed from"
<< " part of a cyclic patch."
<< abort(FatalError);
}
return *neighbPointsPtr_;
}
void Foam::processorFaPatch::makeWeights(scalarField& w) const
{
if (Pstream::parRun())
{
// The face normals point in the opposite direction on the other side
scalarField neighbEdgeCentresCn
(
(
neighbEdgeLengths()
/mag(neighbEdgeLengths())
)
& (
neighbEdgeCentres()
- neighbEdgeFaceCentres()
)
);
w = neighbEdgeCentresCn/
(
(edgeNormals() & faPatch::delta())
+ neighbEdgeCentresCn
);
}
else
{
w = 1.0;
}
}
void Foam::processorFaPatch::makeDeltaCoeffs(scalarField& dc) const
{
if (Pstream::parRun())
{
dc = (1.0 - weights())/(edgeNormals() & faPatch::delta());
}
else
{
dc = 1.0/(edgeNormals() & faPatch::delta());
}
}
Foam::tmp<Foam::vectorField> Foam::processorFaPatch::delta() const
{
if (Pstream::parRun())
{
// To the transformation if necessary
if (parallel())
{
return
faPatch::delta()
- (
neighbEdgeCentres()
- neighbEdgeFaceCentres()
);
}
else
{
return
faPatch::delta()
- transform
(
forwardT(),
(
neighbEdgeCentres()
- neighbEdgeFaceCentres()
)
);
}
}
else
{
return faPatch::delta();
}
}
const Foam::labelList& Foam::processorFaPatch::nonGlobalPatchPoints() const
{
if (!nonGlobalPatchPointsPtr_)
{
makeNonGlobalPatchPoints();
}
return *nonGlobalPatchPointsPtr_;
}
Foam::tmp<Foam::labelField> Foam::processorFaPatch::interfaceInternalField
(
const labelUList& internalData
) const
{
return patchInternalField(internalData);
}
void Foam::processorFaPatch::initTransfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const
{
send(commsType, interfaceData);
}
Foam::tmp<Foam::labelField> Foam::processorFaPatch::transfer
(
const Pstream::commsTypes commsType,
const labelUList&
) const
{
return receive<label>(commsType, this->size());
}
void Foam::processorFaPatch::initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF
) const
{
send(commsType, patchInternalField(iF)());
}
Foam::tmp<Foam::labelField> Foam::processorFaPatch::internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList&
) const
{
return receive<label>(commsType, this->size());
}
void Foam::processorFaPatch::write(Ostream& os) const
{
faPatch::write(os);
os.writeKeyword("myProcNo") << myProcNo_
<< token::END_STATEMENT << nl;
os.writeKeyword("neighbProcNo") << neighbProcNo_
<< token::END_STATEMENT << nl;
}
// ************************************************************************* //

View File

@ -0,0 +1,315 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::processorFaPatch
Description
Processor patch.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
processorFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef processorFaPatch_H
#define processorFaPatch_H
#include "coupledFaPatch.H"
#include "processorLduInterface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class processorFaPatch Declaration
\*---------------------------------------------------------------------------*/
class processorFaPatch
:
public coupledFaPatch,
public processorLduInterface
{
// Private data
//- My processro number
int myProcNo_;
//- Neighbour processor number
int neighbProcNo_;
//- Processor-neighbbour patch edge centres
vectorField neighbEdgeCentres_;
//- Processor-neighbbour patch edge lengths
vectorField neighbEdgeLengths_;
//- Processor-neighbbour patch neighbour face centres
vectorField neighbEdgeFaceCentres_;
//- Corresponding neighbouring local point label for every local point
// (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
mutable labelList* neighbPointsPtr_;
//- The set of labels of the processor patch points which are
// non-global, i.e. present in this processor patch
mutable labelList* nonGlobalPatchPointsPtr_;
protected:
// Protected Member functions
//- Make patch weighting factors
void makeWeights(scalarField&) const;
//- Make patch face - neighbour cell distances
void makeDeltaCoeffs(scalarField&) const;
//- Find non-globa patch points
void makeNonGlobalPatchPoints() const;
// Geometry functions
//- Initialise the calculation of the patch geometry
void initGeometry();
//- Calculate the patch geometry
void calcGeometry();
//- Initialise the patches for moving points
void initMovePoints(const pointField&);
//- Correct patches after moving points
void movePoints(const pointField&);
//- Initialise the update of the patch topology
virtual void initUpdateMesh();
//- Update of the patch topology
virtual void updateMesh();
public:
//- Runtime type information
// TypeName(processorPolyPatch::typeName_());
TypeName("processor");
// Constructors
//- Construct from components
processorFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex,
const label myProcNo,
const label neighbProcNo
)
:
coupledFaPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex),
myProcNo_(myProcNo),
neighbProcNo_(neighbProcNo),
neighbEdgeCentres_(),
neighbEdgeLengths_(),
neighbEdgeFaceCentres_(),
neighbPointsPtr_(nullptr),
nonGlobalPatchPointsPtr_(nullptr)
{}
//- Construct from dictionary
processorFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
coupledFaPatch(name, dict, index, bm),
myProcNo_(readLabel(dict.lookup("myProcNo"))),
neighbProcNo_(readLabel(dict.lookup("neighbProcNo"))),
neighbEdgeCentres_(),
neighbEdgeLengths_(),
neighbEdgeFaceCentres_(),
neighbPointsPtr_(nullptr),
nonGlobalPatchPointsPtr_(nullptr)
{}
//- Destructor
virtual ~processorFaPatch();
// Member functions
//- Return interface size
virtual label interfaceSize() const
{
return size();
}
//- Return processor number
int myProcNo() const
{
return myProcNo_;
}
//- Return neigbour processor number
int neighbProcNo() const
{
return neighbProcNo_;
}
//- Return true if running parallel
virtual bool coupled() const
{
if (Pstream::parRun())
{
return true;
}
else
{
return false;
}
}
//- Is this the master side?
virtual bool master() const
{
return (myProcNo_ < neighbProcNo_);
}
// Communications support
//- Return communicator used for communication
virtual label comm() const;
//- Return message tag to use for communication
virtual int tag() const;
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return coupledFaPatch::forwardT();
}
//- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const;
//- Return processor-neighbbour patch edge centres
const vectorField& neighbEdgeCentres() const
{
return neighbEdgeCentres_;
}
//- Return processor-neighbbour patch edge lengths
const vectorField& neighbEdgeLengths() const
{
return neighbEdgeLengths_;
}
//- Return processor-neighbbour patch neighbour face centres
const vectorField& neighbEdgeFaceCentres() const
{
return neighbEdgeFaceCentres_;
}
//- Return neighbour point labels. This is for my local point the
// corresponding local point on the other side. Call
// faBoundaryMesh::updateMesh() on all processors
// before using this.
const labelList& neighbPoints() const;
//- Return the set of labels of the processor patch points which are
// non-global, i.e. present in this processorFaPatch
const labelList& nonGlobalPatchPoints() const;
// Interface transfer functions
//- Return the values of the given internal data adjacent to
// the interface as a field
virtual tmp<labelField> interfaceInternalField
(
const labelUList& internalData
) const;
//- Initialise interface data transfer
virtual void initTransfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const;
//- Transfer and return neighbour field
virtual tmp<labelField> transfer
(
const Pstream::commsTypes commsType,
const labelUList& interfaceData
) const;
//- Initialise neighbour field transfer
virtual void initInternalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& internalData
) const;
//- Return neighbour field
virtual tmp<labelField> internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& internalData
) const;
//- Write the patch data as a dictionary
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "symmetryFaPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(symmetryFaPatch, 0);
addToRunTimeSelectionTable(faPatch, symmetryFaPatch, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::symmetryFaPatch::makeCorrVecs(vectorField& cv) const
{
// Non-orthogonal correction not allowed
cv = vector::zero;
}
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
Foam::symmetryFaPatch::symmetryFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
)
:
faPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex)
{}
Foam::symmetryFaPatch::symmetryFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
faPatch(name, dict, index, bm)
{
if (ngbPolyPatchIndex() == -1)
{
FatalErrorInFunction
<< "Neighbour polyPatch index is not specified for faPatch "
<< this->name() << exit(FatalError);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,129 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::symmetryFaPatch
Description
Symmetry-plane patch.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
symmetryFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef symmetryFaPatch_H
#define symmetryFaPatch_H
#include "faPatch.H"
#include "symmetryPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class symmetryFaPatch Declaration
\*---------------------------------------------------------------------------*/
class symmetryFaPatch
:
public faPatch
{
protected:
// Protected Member Functions
//- Make patch face non-orthogonality correction vectors
virtual void makeCorrVecs(vectorField&) const;
public:
//- Runtime type information
TypeName(symmetryPolyPatch::typeName_());
// Constructors
//- Construct from components
symmetryFaPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
);
//- Construct from dictionary
symmetryFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
);
//- Construct and return a clone, resetting the edge list
// and boundary mesh
virtual autoPtr<faPatch> clone
(
const faBoundaryMesh& bm,
const labelList& edgeLabels,
const label index,
const label ngbPolyPatchIndex
) const
{
return autoPtr<faPatch>
(
new symmetryFaPatch
(
name(), edgeLabels, index, bm, ngbPolyPatchIndex
)
);
}
//- Destructor
virtual ~symmetryFaPatch()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "wedgeFaPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "faBoundaryMesh.H"
#include "wedgePolyPatch.H"
#include "polyMesh.H"
#include "faMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(wedgeFaPatch, 0);
addToRunTimeSelectionTable(faPatch, wedgeFaPatch, dictionary);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::wedgeFaPatch::findAxisPoint() const
{
// Find axis point
const labelList& ptLabels = pointLabels();
const labelListList& ptEdges = pointEdges();
const vectorField& points = boundaryMesh().mesh().points();
const scalarField& magL = magEdgeLengths();
forAll(ptEdges, pointI)
{
if (ptEdges[pointI].size() == 1)
{
scalar r = mag((I-axis()*axis())&points[ptLabels[pointI]]);
if (r < magL[ptEdges[pointI][0]])
{
axisPoint_ = ptLabels[pointI];
break;
}
}
}
axisPointChecked_ = true;
}
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
Foam::wedgeFaPatch::wedgeFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
faPatch(name, dict, index, bm),
wedgePolyPatchPtr_(nullptr),
axisPoint_(-1),
axisPointChecked_(false)
{
if (ngbPolyPatchIndex() == -1)
{
FatalErrorInFunction
<< "Neighbour polyPatch index is not specified for faPatch "
<< this->name() << exit(FatalError);
}
if (isA<wedgePolyPatch>(bm.mesh()().boundaryMesh()[ngbPolyPatchIndex()]))
{
const wedgePolyPatch& wedge =
refCast<const wedgePolyPatch>
(
bm.mesh()().boundaryMesh()[ngbPolyPatchIndex()]
);
wedgePolyPatchPtr_ = &wedge;
}
else
{
FatalErrorInFunction
<< "Neighbour polyPatch is not of type "
<< wedgePolyPatch::typeName
<< exit(FatalError);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::wedgeFaPatch
Description
Wedge front and back plane patch.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
wedgeFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef wedgeFaPatch_H
#define wedgeFaPatch_H
#include "faPatch.H"
#include "wedgePolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class wedgeFaPatch Declaration
\*---------------------------------------------------------------------------*/
class wedgeFaPatch
:
public faPatch
{
// Private data
const wedgePolyPatch* wedgePolyPatchPtr_;
//- Axis point label
mutable label axisPoint_;
//- Is it axis point looked for?
mutable bool axisPointChecked_;
//- Finde axis point
void findAxisPoint() const;
public:
//- Runtime type information
TypeName("wedge");
//- Construct from dictionary
wedgeFaPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
);
//- Destructor
virtual ~wedgeFaPatch()
{}
// Member functions
// Access
//- Return axis of the wedge
const vector& axis() const
{
return wedgePolyPatchPtr_->axis();
}
//- Return plane normal between the wedge boundaries
const vector& centreNormal() const
{
return wedgePolyPatchPtr_->centreNormal();
}
//- Return face transformation tensor
const tensor& edgeT() const
{
return wedgePolyPatchPtr_->faceT();
}
//- Return neighbour-cell transformation tensor
const tensor& faceT() const
{
return wedgePolyPatchPtr_->cellT();
}
//- Return axis point label
label axisPoint() const
{
if (axisPoint_ == -1 && !axisPointChecked_)
{
findAxisPoint();
}
return axisPoint_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,491 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "faPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "faBoundaryMesh.H"
#include "faMesh.H"
#include "areaFields.H"
#include "edgeFields.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faPatch, 0);
defineRunTimeSelectionTable(faPatch, dictionary);
addToRunTimeSelectionTable(faPatch, faPatch, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faPatch::clearOut()
{
deleteDemandDrivenData(edgeFacesPtr_);
deleteDemandDrivenData(pointLabelsPtr_);
deleteDemandDrivenData(pointEdgesPtr_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faPatch::faPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
)
:
labelList(edgeLabels),
patchIdentifier(name, index),
ngbPolyPatchIndex_(ngbPolyPatchIndex),
boundaryMesh_(bm),
edgeFacesPtr_(nullptr),
pointLabelsPtr_(nullptr),
pointEdgesPtr_(nullptr)
{}
Foam::faPatch::faPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
:
labelList(dict.lookup("edgeLabels")),
patchIdentifier(name, dict, index),
ngbPolyPatchIndex_(readInt(dict.lookup("ngbPolyPatchIndex"))),
boundaryMesh_(bm),
edgeFacesPtr_(nullptr),
pointLabelsPtr_(nullptr),
pointEdgesPtr_(nullptr)
{}
Foam::faPatch::faPatch(const faPatch& p, const faBoundaryMesh& bm)
:
labelList(p),
patchIdentifier(p, p.index()),
ngbPolyPatchIndex_(p.ngbPolyPatchIndex_),
boundaryMesh_(bm),
edgeFacesPtr_(nullptr),
pointLabelsPtr_(nullptr),
pointEdgesPtr_(nullptr)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faPatch::~faPatch()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::faPatch::ngbPolyPatchIndex() const
{
return ngbPolyPatchIndex_;
}
const Foam::faBoundaryMesh& Foam::faPatch::boundaryMesh() const
{
return boundaryMesh_;
}
Foam::label Foam::faPatch::start() const
{
return boundaryMesh().mesh().patchStarts()[index()];
}
const Foam::labelList& Foam::faPatch::pointLabels() const
{
if (!pointLabelsPtr_)
{
calcPointLabels();
}
return *pointLabelsPtr_;
}
void Foam::faPatch::calcPointLabels() const
{
SLList<label> labels;
UList<edge> edges = patchSlice(boundaryMesh().mesh().edges());
forAll(edges, edgeI)
{
bool existStart = false;
bool existEnd = false;
forAllIters(labels, iter)
{
if (*iter == edges[edgeI].start())
{
existStart = true;
}
if (*iter == edges[edgeI].end())
{
existEnd = true;
}
}
if (!existStart)
{
labels.append(edges[edgeI].start());
}
if (!existEnd)
{
labels.append(edges[edgeI].end());
}
}
pointLabelsPtr_ = new labelList(labels);
}
void Foam::faPatch::calcPointEdges() const
{
const labelList& points = pointLabels();
const edgeList::subList e = patchSlice(boundaryMesh().mesh().edges());
// set up storage for pointEdges
List<SLList<label>> pointEdgs(points.size());
forAll(e, edgeI)
{
const edge& curPoints = e[edgeI];
forAll(curPoints, pointI)
{
label localPointIndex = findIndex(points, curPoints[pointI]);
pointEdgs[localPointIndex].append(edgeI);
}
}
// sort out the list
pointEdgesPtr_ = new labelListList(pointEdgs.size());
labelListList& pEdges = *pointEdgesPtr_;
forAll(pointEdgs, pointI)
{
pEdges[pointI].setSize(pointEdgs[pointI].size());
label i = 0;
for
(
SLList<label>::iterator curEdgesIter = pointEdgs[pointI].begin();
curEdgesIter != pointEdgs[pointI].end();
++curEdgesIter, ++i
)
{
pEdges[pointI][i] = curEdgesIter();
}
}
}
const Foam::labelListList& Foam::faPatch::pointEdges() const
{
if (!pointEdgesPtr_)
{
calcPointEdges();
}
return *pointEdgesPtr_;
}
Foam::labelList Foam::faPatch::ngbPolyPatchFaces() const
{
labelList ngbFaces;
if (ngbPolyPatchIndex() == -1)
{
return ngbFaces;
}
ngbFaces.setSize(faPatch::size());
const faMesh& aMesh = boundaryMesh().mesh();
const polyMesh& pMesh = aMesh();
const indirectPrimitivePatch& patch = aMesh.patch();
const labelListList& edgeFaces = pMesh.edgeFaces();
labelList faceCells(patch.size(), -1);
forAll(faceCells, faceI)
{
label faceID = aMesh.faceLabels()[faceI];
faceCells[faceI] = pMesh.faceOwner()[faceID];
}
labelList meshEdges
(
patch.meshEdges
(
pMesh.edges(),
pMesh.cellEdges(),
faceCells
)
);
forAll(ngbFaces, edgeI)
{
ngbFaces[edgeI] = -1;
label curEdge = (*this)[edgeI];
label curPMeshEdge = meshEdges[curEdge];
forAll(edgeFaces[curPMeshEdge], faceI)
{
label curFace = edgeFaces[curPMeshEdge][faceI];
label curPatchID = pMesh.boundaryMesh().whichPatch(curFace);
if (curPatchID == ngbPolyPatchIndex())
{
ngbFaces[edgeI] = curFace;
}
}
if (ngbFaces[edgeI] == -1)
{
WarningInFunction
<< "Problem with determination of edge ngb faces!"
<< endl;
}
}
return ngbFaces;
}
Foam::tmp<Foam::vectorField> Foam::faPatch::ngbPolyPatchFaceNormals() const
{
tmp<vectorField> tfN(new vectorField());
vectorField& fN = tfN.ref();
if (ngbPolyPatchIndex() == -1)
{
return tfN;
}
fN.setSize(faPatch::size());
labelList ngbFaces = ngbPolyPatchFaces();
const polyMesh& pMesh = boundaryMesh().mesh()();
const faceList& faces = pMesh.faces();
const pointField& points = pMesh.points();
forAll(fN, faceI)
{
fN[faceI] = faces[ngbFaces[faceI]].normal(points)
/faces[ngbFaces[faceI]].mag(points);
}
return tfN;
}
Foam::tmp<Foam::vectorField> Foam::faPatch::ngbPolyPatchPointNormals() const
{
if (ngbPolyPatchIndex() == -1)
{
return tmp<vectorField>(new vectorField());
}
const labelListList& pntEdges = pointEdges();
tmp<vectorField> tpN(new vectorField(pntEdges.size(), vector::zero));
vectorField& pN = tpN.ref();
const vectorField faceNormals(ngbPolyPatchFaceNormals());
forAll(pN, pointI)
{
forAll(pntEdges[pointI], edgeI)
{
pN[pointI] += faceNormals[pntEdges[pointI][edgeI]];
}
}
pN /= mag(pN);
return tpN;
}
const Foam::labelUList& Foam::faPatch::edgeFaces() const
{
if (!edgeFacesPtr_)
{
edgeFacesPtr_ = new labelList::subList
(
patchSlice(boundaryMesh().mesh().edgeOwner())
);
}
return *edgeFacesPtr_;
}
const Foam::vectorField& Foam::faPatch::edgeCentres() const
{
return boundaryMesh().mesh().edgeCentres().boundaryField()[index()];
}
const Foam::vectorField& Foam::faPatch::edgeLengths() const
{
return boundaryMesh().mesh().Le().boundaryField()[index()];
}
const Foam::scalarField& Foam::faPatch::magEdgeLengths() const
{
return boundaryMesh().mesh().magLe().boundaryField()[index()];
}
Foam::tmp<Foam::vectorField> Foam::faPatch::edgeNormals() const
{
tmp<vectorField> eN(new vectorField(size()));
eN.ref() = edgeLengths()/magEdgeLengths();
return eN;
}
Foam::tmp<Foam::vectorField> Foam::faPatch::edgeFaceCentres() const
{
tmp<vectorField> tfc(new vectorField(size()));
vectorField& fc = tfc.ref();
// get reference to global face centres
const vectorField& gfc =
boundaryMesh().mesh().areaCentres().internalField();
const labelUList& faceLabels = edgeFaces();
forAll(faceLabels, edgeI)
{
fc[edgeI] = gfc[faceLabels[edgeI]];
}
return tfc;
}
Foam::tmp<Foam::vectorField> Foam::faPatch::delta() const
{
return edgeCentres() - edgeFaceCentres();
}
void Foam::faPatch::makeDeltaCoeffs(scalarField& dc) const
{
dc = 1.0/(edgeNormals() & delta());
}
const Foam::scalarField& Foam::faPatch::deltaCoeffs() const
{
return boundaryMesh().mesh().deltaCoeffs().boundaryField()[index()];
}
void Foam::faPatch::makeWeights(scalarField& w) const
{
w = 1.0;
}
const Foam::scalarField& Foam::faPatch::weights() const
{
return boundaryMesh().mesh().weights().boundaryField()[index()];
}
void Foam::faPatch::movePoints(const pointField& points)
{}
void Foam::faPatch::resetEdges(const labelList& newEdges)
{
Info<< "Resetting patch edges" << endl;
labelList::operator=(newEdges);
clearOut();
}
void Foam::faPatch::write(Ostream& os) const
{
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
patchIdentifier::write(os);
const labelList& edgeLabels = *this;
edgeLabels.writeEntry("edgeLabels", os);
os.writeKeyword("ngbPolyPatchIndex") << ngbPolyPatchIndex_
<< token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const faPatch& p)
{
p.write(os);
os.check(FUNCTION_NAME);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,379 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faPatch
Description
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
faPatch.C
newFaPatch.C
\*---------------------------------------------------------------------------*/
#ifndef faPatch_H
#define faPatch_H
#include "patchIdentifier.H"
#include "labelList.H"
#include "pointField.H"
#include "typeInfo.H"
#include "faPatchFieldsFwd.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class faBoundaryMesh;
/*---------------------------------------------------------------------------*\
Class faPatch Declaration
\*---------------------------------------------------------------------------*/
class faPatch
:
public labelList,
public patchIdentifier
{
private:
// Private data
//- Neighbour polyPatch index
const label ngbPolyPatchIndex_;
//- Reference to boundary mesh
const faBoundaryMesh& boundaryMesh_;
// Demand-driven private data
//- Edge-face addressing
mutable labelList::subList* edgeFacesPtr_;
//- Local points labels
mutable labelList* pointLabelsPtr_;
//- Point-edge addressing
mutable labelListList* pointEdgesPtr_;
// Private Member Functions
//- Disallow construct as copy
faPatch(const faPatch&) = delete;
//- Disallow assignment
void operator=(const faPatch&) = delete;
//- Clear out topological patch data
void clearOut();
protected:
//- The faPatch geometry initialisation is called by faBoundaryMesh
friend class faBoundaryMesh;
//- Calculate patch point labels
void calcPointLabels() const;
//- Calculate patch point-edge addressing
void calcPointEdges() const;
//- Initialise the calculation of the patch geometry
virtual void initGeometry()
{}
//- Calculate the patch geometry
virtual void calcGeometry()
{}
//- Initialise the patches for moving points
virtual void initMovePoints(const pointField&)
{}
//- Correct patch after moving points
virtual void movePoints(const pointField&);
//- Initialise the update of the patch topology
virtual void initUpdateMesh()
{}
//- Update of the patch topology
virtual void updateMesh()
{}
public:
typedef faBoundaryMesh BoundaryMesh;
//- Runtime type information
TypeName("patch");
// Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
faPatch,
dictionary,
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
),
(name, dict, index, bm)
);
// Constructors
//- Construct from components
faPatch
(
const word& name,
const labelList& edgeLabels,
const label index,
const faBoundaryMesh& bm,
const label ngbPolyPatchIndex
);
//- Construct from dictionary
faPatch
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
);
//- Construct as copy, resetting the boundary mesh
faPatch(const faPatch&, const faBoundaryMesh&);
//- Construct and return a clone, resetting the edge list
// and boundary mesh
virtual autoPtr<faPatch> clone
(
const faBoundaryMesh& bm,
const labelList& edgeLabels,
const label index,
const label ngbPolyPatchIndex
) const
{
return autoPtr<faPatch>
(
new faPatch(name(), edgeLabels, index, bm, ngbPolyPatchIndex)
);
}
// Selectors
//- Return a pointer to a new patch created
// on freestore from dictionary
static autoPtr<faPatch> New
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
);
//- Destructor
virtual ~faPatch();
// Member Functions
//- Return number of patch points
label nPoints() const
{
return pointLabels().size();
}
//- Return neighbour polyPatch index
label ngbPolyPatchIndex() const;
//- Return boundaryMesh reference
const faBoundaryMesh& boundaryMesh() const;
//- Return true if this patch is coupled
virtual bool coupled() const
{
return false;
}
//- Patch start in edge list
label start() const;
//- Patch size
virtual label size() const
{
return labelList::size();
}
//- Return label of edge in patch from global edge label
inline label whichEdge(const label l) const
{
return l - start();
}
//- Slice list to patch
template<class T>
typename List<T>::subList patchSlice(const List<T>& l) const
{
return typename List<T>::subList(l, size(), start());
}
//- Write
virtual void write(Ostream&) const;
// Acces functions for geometrical data
//- Return patch point labels
const labelList& pointLabels() const;
//- Return patch point-edge addressing
const labelListList& pointEdges() const;
//- Return edge neighbour polyPatch faces
labelList ngbPolyPatchFaces() const;
//- Return normals of neighbour polyPatch faces
tmp<vectorField> ngbPolyPatchFaceNormals() const;
//- Return normals of neighbour polyPatch joined points
tmp<vectorField> ngbPolyPatchPointNormals() const;
//- Return edge-face addressing
const labelUList& edgeFaces() const;
//- Return edge centres
const vectorField& edgeCentres() const;
//- Return edge length vectors
const vectorField& edgeLengths() const;
//- Return edge length magnitudes
const scalarField& magEdgeLengths() const;
//- Return edge normals
tmp<vectorField> edgeNormals() const;
//- Return neighbour face centres
tmp<vectorField> edgeFaceCentres() const;
//- Return cell-centre to face-centre vector
// except for coupled patches for which the cell-centre
// to coupled-cell-centre vector is returned
virtual tmp<vectorField> delta() const;
// Access functions for demand driven data
//- Make patch weighting factors
virtual void makeWeights(scalarField&) const;
//- Return patch weighting factors
const scalarField& weights() const;
//- Make patch edge - neighbour face distances
virtual void makeDeltaCoeffs(scalarField&) const;
//- Return patch edge - neighbour face distances
const scalarField& deltaCoeffs() const;
// Topological changes
//- Reset edge list
void resetEdges(const labelList&);
// Evaluation functions
//- Return given internal field next to patch as patch field
template<class Type>
tmp<Field<Type>> patchInternalField(const UList<Type>&) const;
//- Return the corresponding patchField of the named field
template<class GeometricField, class Type>
const typename GeometricField::Patch& patchField
(
const GeometricField&
) const;
//- Lookup and return the patchField of the named field from the
// local objectRegistry.
// N.B. The dummy pointer arguments are used if this function is
// instantiated within a templated function to avoid a bug in gcc.
// See inletOutletFvPatchField.C and outletInletFvPatchField.C
template<class GeometricField, class Type>
const typename GeometricField::Patch& lookupPatchField
(
const word& name,
const GeometricField* = nullptr,
const Type* = nullptr
) const;
// Ostream Operator
friend Ostream& operator<<(Ostream&, const faPatch&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "faPatchTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faPatchData
Description
Class which holds data needed for faPatch construction
\*---------------------------------------------------------------------------*/
#ifndef faPatchData_H
#define faPatchData_H
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faPatchData Declaration
\*---------------------------------------------------------------------------*/
struct faPatchData
{
word name_;
word type_;
dictionary dict_;
label ownPolyPatchID_;
label ngbPolyPatchID_;
labelList edgeLabels_;
faPatchData()
:
name_(word::null),
type_(word::null),
ownPolyPatchID_(-1),
ngbPolyPatchID_(-1)
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "faPatch.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class GeometricField, class Type>
const typename GeometricField::Patch& Foam::faPatch::lookupPatchField
(
const word& name,
const GeometricField*,
const Type*
) const
{
return patchField<GeometricField, Type>
(
boundaryMesh().mesh()().objectRegistry::lookupObject<GeometricField>
(
name
)
);
}
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
Typedef
foam::faPatchList
Description
Container classes for faPatch
\*---------------------------------------------------------------------------*/
#ifndef faPatchList_H
#define faPatchList_H
#include "faPatch.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef PtrList<faPatch> faPatchList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "faPatch.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::faPatch> Foam::faPatch::New
(
const word& name,
const dictionary& dict,
const label index,
const faBoundaryMesh& bm
)
{
DebugInFunction
<< "constructing faPatch" << endl;
word patchType(dict.lookup("type"));
auto cstrIter = dictionaryConstructorTablePtr_->cfind(patchType);
if (!cstrIter.found())
{
FatalIOErrorInFunction(dict)
<< "Unknown faPatch type " << patchType << nl << nl
<< "Valid faPatch types are :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
return autoPtr<faPatch>(cstrIter()(name, dict, index, bm));
}
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*----------------------------------------------------------------------------*/
#include "faPatch.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::faPatch::patchInternalField
(
const UList<Type>& f
) const
{
tmp<Field<Type>> tpif (new Field<Type>(size()));
Field<Type>& pif = tpif.ref();
const labelUList& edgeFaces = this->edgeFaces();
forAll(pif, facei)
{
pif[facei] = f[edgeFaces[facei]];
}
return tpif;
}
template<class GeometricField, class Type>
const typename GeometricField::Patch& Foam::faPatch::patchField
(
const GeometricField& gf
) const
{
return gf.boundaryField()[index()];
}
// ************************************************************************* //

View File

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::faSolution
Description
Selector class for finite area solution.
faMesh is derived from faSolution so that all fields have access to the
faSolution from the mesh reference they hold.
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
\*---------------------------------------------------------------------------*/
#ifndef faSolution_H
#define faSolution_H
#include "solution.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faSolution Declaration
\*---------------------------------------------------------------------------*/
class faSolution
:
public solution
{
// Private Member Functions
//- Disallow default bitwise copy construct and assignment
faSolution(const faSolution&);
void operator=(const faSolution&);
public:
//- Construct from objectRegistry
faSolution(const objectRegistry& obr)
:
solution(obr, "faSolution")
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "faMesh.H"
#include "areaFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTemplate2TypeNameAndDebug(areaScalarField::Internal, 0);
defineTemplate2TypeNameAndDebug(areaVectorField::Internal, 0);
defineTemplate2TypeNameAndDebug(areaSphericalTensorField::Internal, 0);
defineTemplate2TypeNameAndDebug(areaSymmTensorField::Internal, 0);
defineTemplate2TypeNameAndDebug(areaTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(areaScalarField, 0);
defineTemplateTypeNameAndDebug(areaVectorField, 0);
defineTemplateTypeNameAndDebug(areaSphericalTensorField, 0);
defineTemplateTypeNameAndDebug(areaSymmTensorField, 0);
defineTemplateTypeNameAndDebug(areaTensorField, 0);
template<>
tmp<GeometricField<scalar, faPatchField, areaMesh>>
GeometricField<scalar, faPatchField, areaMesh>::component
(
const direction
) const
{
return *this;
}
template<>
void GeometricField<scalar, faPatchField, areaMesh>::replace
(
const direction,
const GeometricField<scalar, faPatchField, areaMesh>& gsf
)
{
*this == gsf;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::areaFields
Description
Finite area area (element) fields
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
areaFields.C
\*---------------------------------------------------------------------------*/
#ifndef areaFields_H
#define areaFields_H
#include "objectRegistry.H"
#include "GeometricFields.H"
#include "areaFaMesh.H"
#include "faMesh.H"
#include "faPatchFields.H"
#include "areaFieldsFwd.H"
#include "calculatedFaPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
tmp<GeometricField<scalar, faPatchField, areaMesh>>
GeometricField<scalar, faPatchField, areaMesh>::component
(
const direction
) const;
template<>
void GeometricField<scalar, faPatchField, areaMesh>::replace
(
const direction,
const GeometricField<scalar, faPatchField, areaMesh>& sf
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,71 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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
areaFields
Description
SourceFiles
areaFields.C
\*---------------------------------------------------------------------------*/
#ifndef areaFieldsFwd_H
#define areaFieldsFwd_H
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class areaMesh;
template<class Type>
class faPatchField;
template<class Type, template<class> class PatchField, class GeoMesh>
class GeometricField;
typedef GeometricField<scalar, faPatchField, areaMesh> areaScalarField;
typedef GeometricField<vector, faPatchField, areaMesh> areaVectorField;
typedef GeometricField<sphericalTensor, faPatchField, areaMesh>
areaSphericalTensorField;
typedef GeometricField<symmTensor, faPatchField, areaMesh> areaSymmTensorField;
typedef GeometricField<tensor, faPatchField, areaMesh> areaTensorField;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "faMesh.H"
#include "edgeFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTemplate2TypeNameAndDebug(edgeScalarField::Internal, 0);
defineTemplate2TypeNameAndDebug(edgeVectorField::Internal, 0);
defineTemplate2TypeNameAndDebug(edgeSphericalTensorField::Internal, 0);
defineTemplate2TypeNameAndDebug(edgeSymmTensorField::Internal, 0);
defineTemplate2TypeNameAndDebug(edgeTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(edgeScalarField, 0);
defineTemplateTypeNameAndDebug(edgeVectorField, 0);
defineTemplateTypeNameAndDebug(edgeSphericalTensorField, 0);
defineTemplateTypeNameAndDebug(edgeSymmTensorField, 0);
defineTemplateTypeNameAndDebug(edgeTensorField, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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
edgeFields
Description
Finite area edge fields
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
edgeFields.C
\*---------------------------------------------------------------------------*/
#ifndef edgeFields_H
#define edgeFields_H
#include "objectRegistry.H"
#include "GeometricFields.H"
#include "edgeFaMesh.H"
#include "fieldTypes.H"
#include "faMesh.H"
#include "faePatchFields.H"
#include "edgeFieldsFwd.H"
#include "calculatedFaePatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,71 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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
edgeFields
Description
SourceFiles
edgeFields.C
\*---------------------------------------------------------------------------*/
#ifndef edgeFieldsFwd_H
#define edgeFieldsFwd_H
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class edgeMesh;
template<class Type>
class faePatchField;
template<class Type, template<class> class PatchField, class GeoMesh>
class GeometricField;
typedef GeometricField<scalar, faePatchField, edgeMesh> edgeScalarField;
typedef GeometricField<vector, faePatchField, edgeMesh> edgeVectorField;
typedef GeometricField<sphericalTensor, faePatchField, edgeMesh>
edgeSphericalTensorField;
typedef GeometricField<symmTensor, faePatchField, edgeMesh> edgeSymmTensorField;
typedef GeometricField<tensor, faePatchField, edgeMesh> edgeTensorField;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "basicSymmetryFaPatchField.H"
#include "symmTransformField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::basicSymmetryFaPatchField<Type>::basicSymmetryFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF
)
:
transformFaPatchField<Type>(p, iF)
{}
template<class Type>
Foam::basicSymmetryFaPatchField<Type>::basicSymmetryFaPatchField
(
const basicSymmetryFaPatchField<Type>& ptf,
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const faPatchFieldMapper& mapper
)
:
transformFaPatchField<Type>(ptf, p, iF, mapper)
{}
template<class Type>
Foam::basicSymmetryFaPatchField<Type>::basicSymmetryFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const dictionary& dict
)
:
transformFaPatchField<Type>(p, iF, dict)
{
this->evaluate();
}
template<class Type>
Foam::basicSymmetryFaPatchField<Type>::basicSymmetryFaPatchField
(
const basicSymmetryFaPatchField<Type>& ptf
)
:
transformFaPatchField<Type>(ptf)
{}
template<class Type>
Foam::basicSymmetryFaPatchField<Type>::basicSymmetryFaPatchField
(
const basicSymmetryFaPatchField<Type>& ptf,
const DimensionedField<Type, areaMesh>& iF
)
:
transformFaPatchField<Type>(ptf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::basicSymmetryFaPatchField<Type>::snGrad() const
{
const vectorField nHat(this->patch().edgeNormals());
return
(
transform(I - 2.0*sqr(nHat), this->patchInternalField())
- this->patchInternalField()
)*(this->patch().deltaCoeffs()/2.0);
}
template<class Type>
void Foam::basicSymmetryFaPatchField<Type>::evaluate(const Pstream::commsTypes)
{
if (!this->updated())
{
this->updateCoeffs();
}
const vectorField nHat(this->patch().edgeNormals());
Field<Type>::operator=
(
(
this->patchInternalField()
+ transform(I - 2.0*sqr(nHat), this->patchInternalField())
)/2.0
);
transformFaPatchField<Type>::evaluate();
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::basicSymmetryFaPatchField<Type>::snGradTransformDiag() const
{
const vectorField nHat(this->patch().edgeNormals());
vectorField diag(nHat.size());
diag.replace(vector::X, mag(nHat.component(vector::X)));
diag.replace(vector::Y, mag(nHat.component(vector::Y)));
diag.replace(vector::Z, mag(nHat.component(vector::Z)));
return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
}
// ************************************************************************* //

View File

@ -0,0 +1,171 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::basicSymmetryFaPatchField
Description
A symmetry patch
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
basicSymmetryFaPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef basicSymmetryFaPatchField_H
#define basicSymmetryFaPatchField_H
#include "transformFaPatchField.H"
#include "symmetryFaPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class basicSymmetryFaPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class basicSymmetryFaPatchField
:
public transformFaPatchField<Type>
{
public:
// Constructors
//- Construct from patch and internal field
basicSymmetryFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&
);
//- Construct from patch, internal field and dictionary
basicSymmetryFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const dictionary&
);
//- Construct by mapping given basicSymmetryFaPatchField onto a new patch
basicSymmetryFaPatchField
(
const basicSymmetryFaPatchField<Type>&,
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const faPatchFieldMapper&
);
//- Construct as copy
basicSymmetryFaPatchField
(
const basicSymmetryFaPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<faPatchField<Type>> clone() const
{
return tmp<faPatchField<Type>>
(
new basicSymmetryFaPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
basicSymmetryFaPatchField
(
const basicSymmetryFaPatchField<Type>&,
const DimensionedField<Type, areaMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<faPatchField<Type>> clone
(
const DimensionedField<Type, areaMesh>& iF
) const
{
return tmp<faPatchField<Type>>
(
new basicSymmetryFaPatchField<Type>(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Return gradient at boundary
virtual tmp<Field<Type>> snGrad() const;
//- Evaluate the patch field
// Default argument needed to allow call in constructors
// HJ, 30/Jun/2009
virtual void evaluate
(
const Pstream::commsTypes commsType = Pstream::commsTypes::blocking
);
//- Return face-gradient transform diagonal
virtual tmp<Field<Type>> snGradTransformDiag() const;
};
// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * //
template<>
tmp<scalarField> basicSymmetryFaPatchField<scalar>::snGrad() const;
template<>
void basicSymmetryFaPatchField<scalar>::evaluate
(
const Pstream::commsTypes commsType
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "basicSymmetryFaPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "basicSymmetryFaPatchFields.H"
#include "faPatchFields.H"
#include "areaFaMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeFaPatchFields(basicSymmetry);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#ifndef basicSymmetryFaPatchFields_H
#define basicSymmetryFaPatchFields_H
#include "basicSymmetryFaPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeFaPatchTypeFieldTypedefs(basicSymmetry)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "basicSymmetryFaPatchField.H"
#include "areaFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<>
Foam::tmp<Foam::scalarField>
Foam::basicSymmetryFaPatchField<Foam::scalar>::snGrad() const
{
return tmp<scalarField>(new scalarField(size(), 0.0));
}
template<>
void Foam::basicSymmetryFaPatchField<Foam::scalar>::evaluate
(
const Pstream::commsTypes
)
{
if (!updated())
{
updateCoeffs();
}
scalarField::operator=(patchInternalField());
transformFaPatchField<scalar>::evaluate();
}
// ************************************************************************* //

View File

@ -0,0 +1,218 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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/>.
\*---------------------------------------------------------------------------*/
#include "calculatedFaPatchField.H"
#include "faPatchFieldMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
const Foam::word& Foam::faPatchField<Type>::calculatedType()
{
return calculatedFaPatchField<Type>::typeName;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::calculatedFaPatchField<Type>::calculatedFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF
)
:
faPatchField<Type>(p, iF)
{}
template<class Type>
Foam::calculatedFaPatchField<Type>::calculatedFaPatchField
(
const calculatedFaPatchField<Type>& ptf,
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const faPatchFieldMapper& mapper
)
:
faPatchField<Type>(ptf, p, iF, mapper)
{}
template<class Type>
Foam::calculatedFaPatchField<Type>::calculatedFaPatchField
(
const faPatch& p,
const DimensionedField<Type, areaMesh>& iF,
const dictionary& dict
)
:
faPatchField<Type>(p, iF, Field<Type>("value", dict, p.size()))
{}
template<class Type>
Foam::calculatedFaPatchField<Type>::calculatedFaPatchField
(
const calculatedFaPatchField<Type>& ptf
)
:
faPatchField<Type>(ptf)
{}
template<class Type>
Foam::calculatedFaPatchField<Type>::calculatedFaPatchField
(
const calculatedFaPatchField<Type>& ptf,
const DimensionedField<Type, areaMesh>& iF
)
:
faPatchField<Type>(ptf, iF)
{}
template<class Type>
template<class Type2>
Foam::tmp<Foam::faPatchField<Type>> Foam::faPatchField<Type>::NewCalculatedType
(
const faPatchField<Type2>& pf
)
{
typename patchConstructorTable::iterator patchTypeCstrIter =
patchConstructorTablePtr_->find(pf.patch().type());
if (patchTypeCstrIter.found())
{
return patchTypeCstrIter()
(
pf.patch(),
DimensionedField<Type, areaMesh>::null()
);
}
else
{
return tmp<faPatchField<Type>>
(
new calculatedFaPatchField<Type>
(
pf.patch(),
DimensionedField<Type, areaMesh>::null()
)
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::calculatedFaPatchField<Type>::valueInternalCoeffs
(
const tmp<scalarField>&
) const
{
FatalErrorInFunction
<< "valueInternalCoeffs cannot be called for a calculatedFaPatchField"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"default boundary condition."
<< exit(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::calculatedFaPatchField<Type>::valueBoundaryCoeffs
(
const tmp<scalarField>&
) const
{
FatalErrorInFunction
<< "valueBoundaryCoeffs cannot be called for a calculatedFaPatchField"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"default boundary condition."
<< exit(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::calculatedFaPatchField<Type>::gradientInternalCoeffs() const
{
FatalErrorInFunction
<< "gradientInternalCoeffs cannot be called for a "
"calculatedFaPatchField"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"default boundary condition."
<< exit(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::calculatedFaPatchField<Type>::gradientBoundaryCoeffs() const
{
FatalErrorInFunction
<< "\n "
"gradientBoundaryCoeffs cannot be called for a "
"calculatedFaPatchField"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"default boundary condition."
<< exit(FatalError);
return *this;
}
template<class Type>
void Foam::calculatedFaPatchField<Type>::write(Ostream& os) const
{
faPatchField<Type>::write(os);
this->writeEntry("value", os);
}
// ************************************************************************* //

View File

@ -0,0 +1,184 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016-2017 Wikki 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::calculatedFaPatchField
Description
Author
Zeljko Tukovic, FMENA
Hrvoje Jasak, Wikki Ltd.
SourceFiles
calculatedFaPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef calculatedFaPatchField_H
#define calculatedFaPatchField_H
#include "faPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class calculatedFaPatch Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class calculatedFaPatchField
:
public faPatchField<Type>
{
public:
//- Runtime type information
TypeName("calculated");
// Constructors
//- Construct from patch and internal field
calculatedFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&
);
//- Construct from patch, internal field and dictionary
calculatedFaPatchField
(
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const dictionary&
);
//- Construct by mapping given patchField<Type> onto a new patch
calculatedFaPatchField
(
const calculatedFaPatchField<Type>&,
const faPatch&,
const DimensionedField<Type, areaMesh>&,
const faPatchFieldMapper&
);
//- Construct as copy
calculatedFaPatchField
(
const calculatedFaPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<faPatchField<Type>> clone() const
{
return tmp<faPatchField<Type>>
(
new calculatedFaPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
calculatedFaPatchField
(
const calculatedFaPatchField<Type>&,
const DimensionedField<Type, areaMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<faPatchField<Type>> clone
(
const DimensionedField<Type, areaMesh>& iF
) const
{
return tmp<faPatchField<Type>>
(
new calculatedFaPatchField<Type>(*this, iF)
);
}
// Member functions
// Access
//- Return true if this patch field fixes a value.
// Needed to check if a level has to be specified while solving
// Poissons equations.
virtual bool fixesValue() const
{
return true;
}
// Evaluation functions
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the value of this patchField with given weights
virtual tmp<Field<Type>> valueInternalCoeffs
(
const tmp<scalarField>&
) const;
//- Return the matrix source coefficients corresponding to the
// evaluation of the value of this patchField with given weights
virtual tmp<Field<Type>> valueBoundaryCoeffs
(
const tmp<scalarField>&
) const;
//- Return the matrix diagonal coefficients corresponding to the
// evaluation of the gradient of this patchField
tmp<Field<Type>> gradientInternalCoeffs() const;
//- Return the matrix source coefficients corresponding to the
// evaluation of the gradient of this patchField
tmp<Field<Type>> gradientBoundaryCoeffs() const;
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "calculatedFaPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More