From d4787dce18bc839a1fa23fd923426518102c1914 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 14 Jan 2013 12:49:31 +0000 Subject: [PATCH 01/41] ENH: Updated info message --- src/randomProcesses/noise/noiseFFT.C | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/randomProcesses/noise/noiseFFT.C b/src/randomProcesses/noise/noiseFFT.C index 9a7ca7cd95..a262125121 100644 --- a/src/randomProcesses/noise/noiseFFT.C +++ b/src/randomProcesses/noise/noiseFFT.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,16 +53,14 @@ Foam::noiseFFT::noiseFFT(const fileName& pFileName, const label skip) scalarField(), deltat_(0.0) { - // Construct control dictionary + // Construct pressure data file IFstream pFile(pFileName); // Check pFile stream is OK if (!pFile.good()) { - FatalErrorIn - ( - "noiseFFT::noiseFFT(const fileName&, const label)" - ) << "Cannot read file " << pFileName + FatalErrorIn("noiseFFT::noiseFFT(const scalar, const scalarField&)") + << "Cannot read file " << pFileName << exit(FatalError); } @@ -76,7 +74,10 @@ Foam::noiseFFT::noiseFFT(const fileName& pFileName, const label skip) if (!pFile.good() || pFile.eof()) { - FatalErrorIn("noiseFFT::noiseFFT(const fileName&, const label)") + FatalErrorIn + ( + "noiseFFT::noiseFFT(const scalar, const scalarField&)" + ) << "Number of points in file " << pFileName << " is less than the number to be skipped = " << skip << exit(FatalError); From 89473d43dd00786d7acd03e16aa5e2a84ae6fcd0 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 16 Jan 2013 16:38:37 +0000 Subject: [PATCH 02/41] ENH: Added sumDirection operation into faceSource function object --- .../field/fieldValues/faceSource/faceSource.C | 72 +++++++++++++++++-- .../field/fieldValues/faceSource/faceSource.H | 19 +++-- .../faceSource/faceSourceTemplates.C | 22 +++++- .../field/fieldValues/fieldValue/fieldValue.C | 5 +- .../field/fieldValues/fieldValue/fieldValue.H | 8 ++- .../fieldValues/fieldValue/fieldValueI.H | 8 ++- 6 files changed, 121 insertions(+), 13 deletions(-) diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index 14a6fa310e..d69ac989ad 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,10 +48,11 @@ namespace Foam template<> - const char* NamedEnum::names[] = + const char* NamedEnum::names[] = { "none", "sum", + "sumDirection", "average", "weightedAverage", "areaAverage", @@ -74,7 +75,7 @@ namespace Foam const Foam::NamedEnum Foam::fieldValues::faceSource::sourceTypeNames_; -const Foam::NamedEnum +const Foam::NamedEnum Foam::fieldValues::faceSource::operationTypeNames_; @@ -486,6 +487,46 @@ void Foam::fieldValues::faceSource::writeFileHeader(const label i) } +template<> +Foam::scalar Foam::fieldValues::faceSource::processValues +( + const Field& values, + const vectorField& Sf, + const scalarField& weightField +) const +{ + switch (operation_) + { + case opSumDirection: + { + const vector direction(dict_.lookup("direction")); + + scalar v = 0.0; + + forAll(Sf, i) + { + scalar d = Sf[i] & direction; + if (d > 0) + { + v += pos(values[i])*values[i]; + } + else + { + v += neg(values[i])*values[i]; + } + } + + return v; + } + default: + { + // Fall through to other operations + return processSameTypeValues(values, Sf, weightField); + } + } +} + + template<> Foam::vector Foam::fieldValues::faceSource::processValues ( @@ -496,14 +537,35 @@ Foam::vector Foam::fieldValues::faceSource::processValues { switch (operation_) { + case opSumDirection: + { + const vector direction(dict_.lookup("direction")); + + vector v(vector::zero); + + forAll(Sf, i) + { + scalar d = Sf[i] & direction; + if (d > 0) + { + v += pos(values[i] & direction)*values[i]; + } + else + { + v += neg(values[i] & direction)*values[i]; + } + } + + return v; + } case opAreaNormalAverage: { - scalar result = sum(values&Sf)/sum(mag(Sf)); + scalar result = sum(values & Sf)/sum(mag(Sf)); return vector(result, 0.0, 0.0); } case opAreaNormalIntegrate: { - scalar result = sum(values&Sf); + scalar result = sum(values & Sf); return vector(result, 0.0, 0.0); } default: diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index 42bc27a311..9af8c7c342 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,6 +87,7 @@ Description \plaintable none | no operation sum | sum + sumDirection | sum values which are positive in given direction average | ensemble average weightedAverage | weighted average areaAverage | area weighted average @@ -176,6 +177,7 @@ public: { opNone, opSum, + opSumDirection, opAverage, opWeightedAverage, opAreaAverage, @@ -188,7 +190,7 @@ public: }; //- Operation type names - static const NamedEnum operationTypeNames_; + static const NamedEnum operationTypeNames_; private: @@ -366,8 +368,17 @@ public: }; -//- Specialisation of processing vectors for opAreaNormalAverage, -// opAreaNormalIntegrate (use inproduct - dimension reducing operation) +//- Specialisation of processing scalars +template<> +scalar faceSource::processValues +( + const Field& values, + const vectorField& Sf, + const scalarField& weightField +) const; + + +//- Specialisation of processing vectors template<> vector faceSource::processValues ( diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index a82f489036..8177946ffc 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -141,6 +141,26 @@ Type Foam::fieldValues::faceSource::processSameTypeValues result = sum(values); break; } + case opSumDirection: + { + FatalErrorIn + ( + "template" + "Type Foam::fieldValues::faceSource::processSameTypeValues" + "(" + "const Field&, " + "const vectorField&, " + "const scalarField&" + ") const" + ) + << "Operation " << operationTypeNames_[operation_] + << " not available for values of type " + << pTraits::typeName + << exit(FatalError); + + result = pTraits::zero; + break; + } case opAverage: { result = sum(values)/values.size(); diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C index 5cb2faa3b6..50d47d8198 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,6 +43,8 @@ void Foam::fieldValue::read(const dictionary& dict) { if (active_) { + dict_ = dict; + log_ = dict.lookupOrDefault("log", false); dict.lookup("fields") >> fields_; dict.lookup("valueOutput") >> valueOutput_; @@ -78,6 +80,7 @@ Foam::fieldValue::fieldValue functionObjectFile(obr, name, valueType), name_(name), obr_(obr), + dict_(dict), active_(true), log_(false), sourceName_(dict.lookupOrDefault("sourceName", "sampledSurface")), diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H index 1b2f2621e7..b7994383d5 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,6 +75,9 @@ protected: //- Database this class is registered to const objectRegistry& obr_; + //- Construction dictionary + dictionary dict_; + //- Active flag bool active_; @@ -149,6 +152,9 @@ public: //- Return the reference to the object registry inline const objectRegistry& obr() const; + //- Return the reference to the construction dictionary + inline const dictionary& dict() const; + //- Return the active flag inline bool active() const; diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H index aaee816af2..55651a3539 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,6 +40,12 @@ inline const Foam::objectRegistry& Foam::fieldValue::obr() const } +inline const Foam::dictionary& Foam::fieldValue::dict() const +{ + return dict_; +} + + inline bool Foam::fieldValue::active() const { return active_; From 55b083336ce2a68c3658219aa4e213c3a540521f Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 16 Jan 2013 16:39:14 +0000 Subject: [PATCH 03/41] ENH: Added average option to fieldValueDelta function object --- .../fieldValueDelta/fieldValueDelta.C | 17 ++++++++--------- .../fieldValueDelta/fieldValueDelta.H | 18 +++++++++++++++--- .../fieldValueDelta/fieldValueDeltaTemplates.C | 16 ++++++++++++++-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C index 20614f474f..cf9fb29236 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,15 +38,16 @@ namespace Foam template<> const char* - NamedEnum::names[] = + NamedEnum::names[] = { "add", "subtract", "min", - "max" + "max", + "average" }; - const NamedEnum + const NamedEnum fieldValues::fieldValueDelta::operationTypeNames_; } @@ -158,7 +159,7 @@ void Foam::fieldValues::fieldValueDelta::write() if (log_) { - Info<< type() << " output:" << endl; + Info<< type() << " " << name_ << " output:" << endl; } bool found = false; @@ -179,10 +180,8 @@ void Foam::fieldValues::fieldValueDelta::write() { Info<< " none" << endl; } - else - { - Info<< endl; - } + + Info<< endl; } } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H index e28771109a..24d72f1f6b 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,6 +37,8 @@ Description { type fieldValueDelta; functionObjectLibs ("libfieldFunctionObjects.so"); + operation subtract; + fieldValue1 { ... @@ -54,6 +56,15 @@ Description type | type name: fieldValueDelta | yes | \endtable + \linebreak + The \c operation is one of: + \plaintable + add | add + subtract | subtract + min | minimum + max | maximum + average | average + \endplaintable SeeAlso Foam::fieldValue @@ -92,11 +103,12 @@ public: opAdd, opSubtract, opMin, - opMax + opMax, + opAverage }; //- Operation type names - static const NamedEnum operationTypeNames_; + static const NamedEnum operationTypeNames_; private: diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaTemplates.C index 6b757fc2df..b107c79527 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ License #include "GeometricField.H" #include "volMesh.H" +#include "surfaceMesh.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -59,6 +60,11 @@ Type Foam::fieldValues::fieldValueDelta::applyOperation result = max(value1, value2); break; } + case opAverage: + { + result = 0.5*(value1 + value2); + break; + } default: { FatalErrorIn @@ -83,6 +89,7 @@ template void Foam::fieldValues::fieldValueDelta::processFields(bool& found) { typedef GeometricField vf; + typedef GeometricField sf; const wordList& fields1 = source1Ptr_->fields(); @@ -95,7 +102,12 @@ void Foam::fieldValues::fieldValueDelta::processFields(bool& found) forAll(fields1, i) { const word& fieldName = fields1[i]; - if (obr_.foundObject(fieldName) && results2.found(fieldName)) + + if + ( + (obr_.foundObject(fieldName) || obr_.foundObject(fieldName)) + && results2.found(fieldName) + ) { results1.lookup(fieldName) >> r1; results2.lookup(fieldName) >> r2; From 9e5e2c8beae87e83a7a3ad14d79a575664af78bb Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 16 Jan 2013 16:41:08 +0000 Subject: [PATCH 04/41] ENH: Added scale option to nastranSurfaceWriter --- .../writers/nastran/nastranSurfaceWriter.C | 10 ++++++---- .../writers/nastran/nastranSurfaceWriter.H | 5 ++++- .../writers/nastran/nastranSurfaceWriterTemplates.C | 10 ++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C index 436457c469..eaa16feb6b 100644 --- a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -336,15 +336,17 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter() : surfaceWriter(), writeFormat_(wfShort), - fieldMap_() + fieldMap_(), + scale_(1.0) {} Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options) : surfaceWriter(), - writeFormat_(wfShort), - fieldMap_() + writeFormat_(wfLong), + fieldMap_(), + scale_(options.lookupOrDefault("scale", 1.0)) { if (options.found("format")) { diff --git a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H index 4e968ee55f..35374a7d94 100644 --- a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,6 +75,9 @@ private: //- Map of OpenFOAM field name vs nastran field name HashTable fieldMap_; + //- Scale to apply to values (default = 1.0) + scalar scale_; + // Private Member Functions diff --git a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriterTemplates.C b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriterTemplates.C index e43dc5757f..fc0a283d75 100644 --- a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriterTemplates.C +++ b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriterTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,6 +46,8 @@ void Foam::nastranSurfaceWriter::writeFaceValue label SID = 1; + Type scaledValue = scale_*value; + switch (writeFormat_) { case wfShort: @@ -59,7 +61,7 @@ void Foam::nastranSurfaceWriter::writeFaceValue for (direction dirI = 0; dirI < pTraits::nComponents; dirI++) { - os << setw(8) << component(value, dirI); + os << setw(8) << component(scaledValue, dirI); } os.unsetf(ios_base::right); @@ -77,7 +79,7 @@ void Foam::nastranSurfaceWriter::writeFaceValue for (direction dirI = 0; dirI < pTraits::nComponents; dirI++) { - os << setw(16) << component(value, dirI); + os << setw(16) << component(scaledValue, dirI); } os.unsetf(ios_base::right); @@ -98,7 +100,7 @@ void Foam::nastranSurfaceWriter::writeFaceValue for (direction dirI = 0; dirI < pTraits::nComponents; dirI++) { - os << ',' << component(value, dirI); + os << ',' << component(scaledValue, dirI); } break; From 5e13cdf1ff6de32a4cce967d6097bc3598341854 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 16 Jan 2013 17:00:08 +0000 Subject: [PATCH 05/41] BUG: Corrected bug in spray break-up model --- .../spray/submodels/BreakupModel/PilchErdman/PilchErdman.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lagrangian/spray/submodels/BreakupModel/PilchErdman/PilchErdman.C b/src/lagrangian/spray/submodels/BreakupModel/PilchErdman/PilchErdman.C index d900260410..2aca8ae5ad 100644 --- a/src/lagrangian/spray/submodels/BreakupModel/PilchErdman/PilchErdman.C +++ b/src/lagrangian/spray/submodels/BreakupModel/PilchErdman/PilchErdman.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -127,10 +127,10 @@ bool Foam::PilchErdman::update scalar rho12 = sqrt(rhoc/rho); - scalar Vd = Urmag*rho12*(B1_*taubBar * B2_*taubBar*taubBar); + scalar Vd = Urmag*rho12*(B1_*taubBar + B2_*taubBar*taubBar); scalar Vd1 = sqr(1.0 - Vd/Urmag); Vd1 = max(Vd1, SMALL); - scalar Ds = 2.0*Wec*sigma*Vd1/(Vd1*rhoc*sqr(Urmag)); + scalar Ds = 2.0*Wec*sigma/(Vd1*rhoc*sqr(Urmag)); scalar A = Urmag*rho12/d; scalar taub = taubBar/A; From d4a937aafc5c1fe8fa333eee5520f4569985e252 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 17 Jan 2013 11:22:58 +0000 Subject: [PATCH 06/41] ENH: face source: updated sumDirection op for vector --- .../field/fieldValues/faceSource/faceSource.C | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index d69ac989ad..dd54de718a 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -540,23 +540,7 @@ Foam::vector Foam::fieldValues::faceSource::processValues case opSumDirection: { const vector direction(dict_.lookup("direction")); - - vector v(vector::zero); - - forAll(Sf, i) - { - scalar d = Sf[i] & direction; - if (d > 0) - { - v += pos(values[i] & direction)*values[i]; - } - else - { - v += neg(values[i] & direction)*values[i]; - } - } - - return v; + return sum(pos(values & direction)*values); } case opAreaNormalAverage: { From 59c4dfe0db3099ef5888231184b6a2c41a4e1253 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 17 Jan 2013 12:38:07 +0000 Subject: [PATCH 07/41] ENH: Tutorial update --- .../chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions index 00978429d9..475ac8e040 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions @@ -69,7 +69,7 @@ MRF1 { origin (0.25 0.25 0.25); axis (0 0 1); - omega 5.305; // 500 rpm + omega 477.5; // 500 rpm } } From fd7bcb62e946e716f59552bbaced8b87c037852c Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 18 Jan 2013 08:32:19 +0000 Subject: [PATCH 08/41] ENH: Updated tutorial --- .../incompressible/simpleFoam/motorBike/system/forceCoeffs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/forceCoeffs b/tutorials/incompressible/simpleFoam/motorBike/system/forceCoeffs index c3a066a07f..7ecdf60478 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/system/forceCoeffs +++ b/tutorials/incompressible/simpleFoam/motorBike/system/forceCoeffs @@ -10,8 +10,7 @@ forceCoeffs1 { type forceCoeffs; functionObjectLibs ( "libforces.so" ); - outputControl timeStep; - outputInterval 1; + outputControl outputTime; log yes; patches ( "motorBike.*" ); From 0aee45baaa5bc81372f2d3e4901a69404b987c72 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 18 Jan 2013 22:01:51 +0000 Subject: [PATCH 09/41] compressibleTwoPhaseEulerFoam: Completed update to energy equations and tutorials --- .../compressibleTwoPhaseEulerFoam/EEqns.H | 13 +++-- .../compressibleTwoPhaseEulerFoam/alphaEqn.H | 4 +- .../multiphaseEulerFoam/Make/options | 2 +- .../multiphase/multiphaseEulerFoam/UEqns.H | 7 +-- .../multiphase/multiphaseEulerFoam/pEqn.H | 34 +++++++++--- .../bubbleColumn/system/fvSchemes | 33 ++++++------ .../bubbleColumn/system/fvSolution | 18 +------ .../fluidisedBed/system/controlDict | 2 +- .../fluidisedBed/system/fvSchemes | 49 ++++++++--------- .../fluidisedBed/system/fvSolution | 4 +- .../mixerVessel2D/constant/polyMesh/boundary | 2 + .../constant/thermophysicalProperties1 | 49 +++++++++++++++++ .../constant/thermophysicalProperties2 | 53 +++++++++++++++++++ .../constant/transportProperties | 21 ++------ .../mixerVessel2D/system/fvSchemes | 20 ++++--- .../mixerVessel2D/system/fvSolution | 17 ++---- 16 files changed, 208 insertions(+), 120 deletions(-) create mode 100644 tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/thermophysicalProperties1 create mode 100644 tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/thermophysicalProperties2 diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/EEqns.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/EEqns.H index 4562d1ed19..3911fa339d 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/EEqns.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/EEqns.H @@ -14,14 +14,18 @@ volScalarField& he1 = thermo1.he(); volScalarField& he2 = thermo2.he(); + volScalarField Cpv1(thermo1.Cpv()); + volScalarField Cpv2(thermo2.Cpv()); + fvScalarMatrix he1Eqn ( fvm::ddt(alpha1, he1) + fvm::div(alphaPhi1, he1) - fvm::laplacian(k1, he1) == - heatTransferCoeff*(thermo1.he(p, thermo2.T())/thermo1.Cp())/rho1 - - fvm::Sp(heatTransferCoeff/thermo1.Cp()/rho1, he1) + heatTransferCoeff*(thermo2.T() - thermo1.T())/rho1 + + heatTransferCoeff*he1/Cpv1/rho1 + - fvm::Sp(heatTransferCoeff/Cpv1/rho1, he1) + alpha1*(dpdt/rho1 - (fvc::ddt(K1) + fvc::div(phi1, K1))) ); @@ -31,8 +35,9 @@ + fvm::div(alphaPhi2, he2) - fvm::laplacian(k2, he2) == - heatTransferCoeff*(thermo2.he(p, thermo1.T())/thermo2.Cp())/rho2 - - fvm::Sp(heatTransferCoeff/thermo2.Cp()/rho2, he2) + heatTransferCoeff*(thermo1.T() - thermo2.T())/rho2 + + heatTransferCoeff*he2/Cpv2/rho2 + - fvm::Sp(heatTransferCoeff/Cpv2/rho2, he2) + alpha2*(dpdt/rho2 - (fvc::ddt(K2) + fvc::div(phi2, K2))) ); diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/alphaEqn.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/alphaEqn.H index 7dfad758b4..a20f53e014 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/alphaEqn.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/alphaEqn.H @@ -2,8 +2,8 @@ surfaceScalarField alphaPhi1("alphaPhi" + phase1Name, phi1); surfaceScalarField alphaPhi2("alphaPhi" + phase2Name, phi2); { - word alphaScheme("div(phi,alpha)"); - word alpharScheme("div(phir,alpha)"); + word alphaScheme("div(phi," + alpha1.name() + ')'); + word alpharScheme("div(phir," + alpha1.name() + ')'); surfaceScalarField phic("phic", phi); surfaceScalarField phir("phir", phi1 - phi2); diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/Make/options b/applications/solvers/multiphase/multiphaseEulerFoam/Make/options index 7cd8f48ee4..688b9364b6 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/Make/options +++ b/applications/solvers/multiphase/multiphaseEulerFoam/Make/options @@ -1,4 +1,4 @@ -EXE_INC = \ +EXE_INC = -g \ -IphaseModel/lnInclude \ -ImultiphaseSystem/lnInclude \ -ImultiphaseFixedFluxPressure \ diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/UEqns.H b/applications/solvers/multiphase/multiphaseEulerFoam/UEqns.H index e6478e4d89..a63ff3c85a 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/UEqns.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/UEqns.H @@ -32,9 +32,10 @@ forAllIter(PtrDictionary, fluid.phases(), iter) "div(Rc)" ) == - - fvm::Sp(fluid.dragCoeff(phase, dragCoeffs())/phase.rho(), U) + //- fvm::Sp(fluid.dragCoeff(phase, dragCoeffs())/phase.rho(), U) //- (alpha*phase.rho())*fluid.lift(phase) - + (alpha/phase.rho())*fluid.Svm(phase) + //+ + (alpha/phase.rho())*fluid.Svm(phase) - fvm::Sp ( slamDampCoeff @@ -53,7 +54,7 @@ forAllIter(PtrDictionary, fluid.phases(), iter) alpha*(1 + (1/phase.rho())*fluid.Cvm(phase)), UEqns[phasei] ); - UEqns[phasei].relax(); + //UEqns[phasei].relax(); phasei++; } diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H b/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H index 07d867b1e7..5e71a2eeeb 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H @@ -67,8 +67,29 @@ const volScalarField& alpha = phase; alphafs.set(phasei, fvc::interpolate(alpha).ptr()); - rAUs.set(phasei, (1.0/UEqns[phasei].A()).ptr()); - rAlphaAUfs.set(phasei, fvc::interpolate(alpha*rAUs[phasei]).ptr()); + + volScalarField dragCoeffi + ( + IOobject + ( + "dragCoeffi", + runTime.timeName(), + mesh + ), + fluid.dragCoeff(phase, dragCoeffs())/phase.rho(), + zeroGradientFvPatchScalarField::typeName + ); + dragCoeffi.correctBoundaryConditions(); + + rAUs.set(phasei, (1.0/(UEqns[phasei].A() + dragCoeffi)).ptr()); + rAlphaAUfs.set + ( + phasei, + ( + alphafs[phasei] + /fvc::interpolate(UEqns[phasei].A() + dragCoeffi) + ).ptr() + ); HbyAs[phasei] = rAUs[phasei]*UEqns[phasei].H(); @@ -115,10 +136,9 @@ } phiHbyAs[phasei] += - fvc::interpolate - ( - (1.0/phase.rho())*rAUs[phasei]*(*dcIter()) - )*phase2Ptr->phi(); + fvc::interpolate((*dcIter())/phase.rho()) + /fvc::interpolate(UEqns[phasei].A() + dragCoeffi) + *phase2Ptr->phi(); HbyAs[phasei] += (1.0/phase.rho())*rAUs[phasei]*(*dcIter()) @@ -240,7 +260,7 @@ + rAlphaAUfs[phasei]*mSfGradp/phase.rho() ); - // phase.U() = fvc::reconstruct(phase.phi()); + //phase.U() = fvc::reconstruct(phase.phi()); phase.U().correctBoundaryConditions(); U += alpha*phase.U(); diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSchemes b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSchemes index 2f9b6ccca2..37a7524ee6 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSchemes +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSchemes @@ -18,6 +18,8 @@ FoamFile ddtSchemes { default Euler; + + "ddt\(alpha.*,.*\)" bounded Euler; } gradSchemes @@ -27,25 +29,20 @@ gradSchemes divSchemes { - default none; + default none; - div(phi,alpha) Gauss limitedLinear01 1; - div(phir,alpha) Gauss limitedLinear01 1; - div(alphaPhiair,Uair) Gauss limitedLinearV 1; - div(alphaPhiwater,Uwater) Gauss limitedLinearV 1; - div(phiair,Uair) Gauss limitedLinearV 1; - div(phiwater,Uwater) Gauss limitedLinearV 1; - div((alphaair*Rc)) Gauss linear; - div((alphawater*Rc)) Gauss linear; - div(alphaPhiair,hair) Gauss limitedLinear 1; - div(alphaPhiwater,hwater) Gauss limitedLinear 1; - div(alphaPhiwater,k) Gauss limitedLinear 1; - div(alphaPhiwater,epsilon) Gauss limitedLinear 1; - div(phi,Theta) Gauss limitedLinear 1; - div(phidair,p) Gauss upwind; - div(phidwater,p) Gauss upwind; - div(phiair,Kair) Gauss limitedLinear 1; - div(phiwater,Kwater) Gauss limitedLinear 1; + div(phi,alphaair) Gauss vanLeer; + div(phir,alphaair) Gauss vanLeer; + + "div\(alphaPhi.*,U.*\)" bounded Gauss limitedLinearV 1; + "div\(phi.*,U.*\)" Gauss limitedLinearV 1; + "div\(\(alpha.*Rc\)\)" Gauss linear; + "div\(phid.*,p\)" Gauss upwind; + + "div\(alphaPhi.*,h.*\)" bounded Gauss limitedLinear 1; + "div\(phi.*,K.*\)" Gauss limitedLinear 1; + + "div\(alphaPhi.*,(k|epsilon)\)" bounded Gauss limitedLinear 1; } laplacianSchemes diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSolution b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSolution index b4dc8bc622..067ac927d0 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSolution +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSolution @@ -63,23 +63,7 @@ solvers relTol 0; } - "Theta.*" - { - solver PBiCG; - preconditioner DILU; - tolerance 1e-05; - relTol 0; - } - - "k.*" - { - solver PBiCG; - preconditioner DILU; - tolerance 1e-05; - relTol 0; - } - - "epsilon.*" + "(k|epsilon|Theta).*" { solver PBiCG; preconditioner DILU; diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/controlDict b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/controlDict index e688082587..e07be01b0e 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/controlDict +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/controlDict @@ -17,7 +17,7 @@ FoamFile application compressibleTwoPhaseEulerFoam; -startFrom latestTime; +startFrom startTime; startTime 0; diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSchemes b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSchemes index e1bb6834f6..72cf3cb54b 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSchemes +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSchemes @@ -17,57 +17,54 @@ FoamFile ddtSchemes { - default Euler; + default Euler; + + "ddt\(alpha.,.*\)" bounded Euler; } gradSchemes { - default Gauss linear; + default Gauss linear; } divSchemes { - default none; + default none; - div(alphaPhi1,U1) Gauss limitedLinearV 1; - div(alphaPhi2,U2) Gauss limitedLinearV 1; - div(phi1,U1) Gauss limitedLinearV 1; - div(phi2,U2) Gauss limitedLinearV 1; - div(alphaPhi1,h1) Gauss limitedLinear 1; - div(alphaPhi2,h2) Gauss limitedLinear 1; - div(alphaPhi2,k) Gauss limitedLinear 1; - div(alphaPhi2,epsilon) Gauss limitedLinear 1; - div(phi,alpha) Gauss limitedLinear01 1; - div(phir,alpha) Gauss limitedLinear01 1; - div(phi,Theta) Gauss limitedLinear 1; - div((alpha1*Rc)) Gauss linear; - div((alpha2*Rc)) Gauss linear; - div(phid1,p) Gauss upwind; - div(phid2,p) Gauss upwind; - div(phi1,K1) Gauss limitedLinear 1; - div(phi2,K2) Gauss limitedLinear 1; + div(phi,alpha1) Gauss vanLeer; + div(phir,alpha1) Gauss vanLeer; + + "div\(alphaPhi.,U.\)" bounded Gauss limitedLinearV 1; + "div\(phi.,U.\)" Gauss limitedLinearV 1; + "div\(\(alpha.*Rc\)\)" Gauss linear; + "div\(phid.,p\)" Gauss upwind; + + "div\(alphaPhi.,h.\)" bounded Gauss limitedLinear 1; + "div\(phi.,K.\)" Gauss limitedLinear 1; + + div(alphaPhi2,k) bounded Gauss limitedLinear 1; + div(alphaPhi2,epsilon) bounded Gauss limitedLinear 1; } laplacianSchemes { - default Gauss linear uncorrected; + default Gauss linear uncorrected; } interpolationSchemes { - default linear; + default linear; } snGradSchemes { - default uncorrected; + default uncorrected; } fluxRequired { - default no; - p ; - alpha1 ; + default no; + p ; } diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSolution b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSolution index b4dc8bc622..1c5fdb8117 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSolution +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSolution @@ -90,8 +90,8 @@ solvers PIMPLE { - nOuterCorrectors 1; - nCorrectors 2; + nOuterCorrectors 3; + nCorrectors 1; nNonOrthogonalCorrectors 0; nAlphaCorr 1; nAlphaSubCycles 2; diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/polyMesh/boundary b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/polyMesh/boundary index 292f25b806..188a0f0c58 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/polyMesh/boundary +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/polyMesh/boundary @@ -32,12 +32,14 @@ FoamFile front { type empty; + inGroups 1(empty); nFaces 3072; startFace 6336; } back { type empty; + inGroups 1(empty); nFaces 3072; startFace 9408; } diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/thermophysicalProperties1 b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/thermophysicalProperties1 new file mode 100644 index 0000000000..11c033af59 --- /dev/null +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/thermophysicalProperties1 @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture pureMixture; + transport const; + thermo hConst; + equationOfState perfectGas; + specie specie; + energy sensibleEnthalpy; +} + +mixture +{ + specie + { + nMoles 1; + molWeight 28.9; + } + thermodynamics + { + Cp 1007; + Hf 0; + } + transport + { + mu 1.84e-05; + Pr 0.7; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/thermophysicalProperties2 b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/thermophysicalProperties2 new file mode 100644 index 0000000000..672b24a98b --- /dev/null +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/thermophysicalProperties2 @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture pureMixture; + transport const; + thermo hConst; + equationOfState perfectFluid; + specie specie; + energy sensibleEnthalpy; +} + +mixture +{ + specie + { + nMoles 1; + molWeight 28.9; + } + equationOfState + { + rho0 1027; + } + thermodynamics + { + Cp 4195; + Hf 0; + } + transport + { + mu 3.645e-4; + Pr 2.289; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/transportProperties b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/transportProperties index 9ea9ed2189..071be24444 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/transportProperties +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/transportProperties @@ -17,14 +17,6 @@ FoamFile phase1 { - rho0 0; - rho 0.88; - R 287; - Cp 1007; - nu 2.46e-05; - d 4e-3; - - kappa 2.63e-2; diameterModel isothermal; isothermalCoeffs { @@ -35,14 +27,6 @@ phase1 phase2 { - rho 733; - rho0 733; - R 1e10; - Cp 4195; - nu 2.73e-6; - d 1e-4; - - kappa 0.668; diameterModel constant; constantCoeffs { @@ -54,12 +38,13 @@ phase2 Cvm 0.5; // Lift coefficient -Cl 0; +Cl 0; // Dispersed-phase turbulence coefficient -Ct 0.2; +Ct 1; // Minimum allowable pressure pMin 10000; + // ************************************************************************* // diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSchemes b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSchemes index 56e5e3fd0d..e1b193c952 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSchemes +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSchemes @@ -18,6 +18,8 @@ FoamFile ddtSchemes { default Euler; + + "ddt\(alpha.*,.*\)" bounded Euler; } gradSchemes @@ -29,16 +31,18 @@ divSchemes { default none; - div(phi,alpha1) Gauss limitedLinear01 1; - div(phir,alpha1) Gauss limitedLinear01 1; + div(phi,alpha1) Gauss vanLeer; + div(phir,alpha1) Gauss vanLeer; + + "div\(alphaPhi.,U.\)" bounded Gauss limitedLinearV 1; "div\(phi.,U.\)" Gauss limitedLinearV 1; - "div\(alphaPhi.,U.\)" Gauss limitedLinearV 1; - "div\(\(alpha.*Rc.\)\)" Gauss linear; - "div\(alphaPhi.,(k|epsilon)\)" Gauss limitedLinear 1; - div(phi,Theta) Gauss limitedLinear 1; - "div\(phi.,K.\)" Gauss linear; - "div\(alphaPhi.,T.\)" Gauss limitedLinear 1; + "div\(\(alpha.*Rc\)\)" Gauss linear; "div\(phid.,p\)" Gauss linear; + + "div\(alphaPhi.,h.\)" bounded Gauss limitedLinear 1; + "div\(phi.,K.\)" Gauss linear; + + "div\(alphaPhi.,(k|epsilon)\)" bounded Gauss limitedLinear 1; } laplacianSchemes diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSolution b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSolution index 891746fcf3..97c8cb32d1 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSolution +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSolution @@ -36,7 +36,7 @@ solvers relTol 0; } - U + "U.*" { solver smoothSolver; smoother GaussSeidel; @@ -45,14 +45,6 @@ solvers relTol 0.1; } - UFinal - { - solver PBiCG; - preconditioner DILU; - tolerance 1e-07; - relTol 0; - } - "alpha.*" { solver PBiCG; @@ -61,7 +53,7 @@ solvers relTol 0; } - "(k|epsilon|Theta|T).*" + "(k|epsilon|Theta|h).*" { solver PBiCG; preconditioner DILU; @@ -76,7 +68,7 @@ PIMPLE nCorrectors 3; nNonOrthogonalCorrectors 0; nAlphaCorr 1; - correctAlpha yes; + nAlphaSubCycles 2; pRefCell 0; pRefValue 0; } @@ -85,16 +77,15 @@ relaxationFactors { fields { - p 1; } equations { "U.*" 1; + "h.*" 1; "alpha.*" 1; "Theta.*" 1; "k.*" 1; "epsilon.*" 1; - "T.*" 1; } } From 6e5e96414da84a162300d3a5ec949f7654eeff9f Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 19 Jan 2013 14:15:57 +0000 Subject: [PATCH 10/41] compressibleTwoPhaseEulerFoam: Improved handling of compressibility effect on continuity and boundedness --- .../multiphase/compressibleTwoPhaseEulerFoam/EEqns.H | 8 ++++++++ .../multiphase/compressibleTwoPhaseEulerFoam/UEqns.H | 6 ++++++ .../turbulenceModel/kEpsilon.H | 8 ++++++++ .../bubbleColumn/system/fvSchemes | 8 +++----- .../fluidisedBed/system/fvSchemes | 10 ++++------ .../mixerVessel2D/system/fvSchemes | 8 +++----- .../bubbleColumn/constant/polyMesh/boundary | 1 + 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/EEqns.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/EEqns.H index 3911fa339d..b64277749e 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/EEqns.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/EEqns.H @@ -21,6 +21,10 @@ ( fvm::ddt(alpha1, he1) + fvm::div(alphaPhi1, he1) + + // Compressibity correction + - fvm::Sp(fvc::ddt(alpha1) + fvc::div(alphaPhi1), he1) + - fvm::laplacian(k1, he1) == heatTransferCoeff*(thermo2.T() - thermo1.T())/rho1 @@ -33,6 +37,10 @@ ( fvm::ddt(alpha2, he2) + fvm::div(alphaPhi2, he2) + + // Compressibity correction + - fvm::Sp(fvc::ddt(alpha2) + fvc::div(alphaPhi2), he2) + - fvm::laplacian(k2, he2) == heatTransferCoeff*(thermo1.T() - thermo2.T())/rho2 diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/UEqns.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/UEqns.H index a243db6300..ce5c622f9a 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/UEqns.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/UEqns.H @@ -31,6 +31,9 @@ fvVectorMatrix U2Eqn(U2, U2.dimensions()*dimVol/dimTime); fvm::ddt(alpha1, U1) + fvm::div(alphaPhi1, U1) + // Compressibity correction + - fvm::Sp(fvc::ddt(alpha1) + fvc::div(alphaPhi1), U1) + + Cvm*rho2*alpha1*alpha2/rho1* ( fvm::ddt(U1) @@ -61,6 +64,9 @@ fvVectorMatrix U2Eqn(U2, U2.dimensions()*dimVol/dimTime); fvm::ddt(alpha2, U2) + fvm::div(alphaPhi2, U2) + // Compressibity correction + - fvm::Sp(fvc::ddt(alpha2) + fvc::div(alphaPhi2), U2) + + Cvm*rho2*alpha1*alpha2/rho2* ( fvm::ddt(U2) diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/turbulenceModel/kEpsilon.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/turbulenceModel/kEpsilon.H index bc9a07b0a8..b74e1b18d7 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/turbulenceModel/kEpsilon.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/turbulenceModel/kEpsilon.H @@ -16,6 +16,10 @@ if (turbulence) ( fvm::ddt(alpha2, epsilon) + fvm::div(alphaPhi2, epsilon) + + // Compressibity correction + - fvm::Sp(fvc::ddt(alpha2) + fvc::div(alphaPhi2), epsilon) + - fvm::laplacian ( alpha1Eps*nuEff2, epsilon, @@ -41,6 +45,10 @@ if (turbulence) ( fvm::ddt(alpha2, k) + fvm::div(alphaPhi2, k) + + // Compressibity correction + - fvm::Sp(fvc::ddt(alpha2) + fvc::div(alphaPhi2), k) + - fvm::laplacian ( alpha1k*nuEff2, k, diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSchemes b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSchemes index 37a7524ee6..1851801037 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSchemes +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/system/fvSchemes @@ -18,8 +18,6 @@ FoamFile ddtSchemes { default Euler; - - "ddt\(alpha.*,.*\)" bounded Euler; } gradSchemes @@ -34,15 +32,15 @@ divSchemes div(phi,alphaair) Gauss vanLeer; div(phir,alphaair) Gauss vanLeer; - "div\(alphaPhi.*,U.*\)" bounded Gauss limitedLinearV 1; + "div\(alphaPhi.*,U.*\)" Gauss limitedLinearV 1; "div\(phi.*,U.*\)" Gauss limitedLinearV 1; "div\(\(alpha.*Rc\)\)" Gauss linear; "div\(phid.*,p\)" Gauss upwind; - "div\(alphaPhi.*,h.*\)" bounded Gauss limitedLinear 1; + "div\(alphaPhi.*,h.*\)" Gauss limitedLinear 1; "div\(phi.*,K.*\)" Gauss limitedLinear 1; - "div\(alphaPhi.*,(k|epsilon)\)" bounded Gauss limitedLinear 1; + "div\(alphaPhi.*,(k|epsilon)\)" Gauss limitedLinear 1; } laplacianSchemes diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSchemes b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSchemes index 72cf3cb54b..8799476cc7 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSchemes +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/system/fvSchemes @@ -18,8 +18,6 @@ FoamFile ddtSchemes { default Euler; - - "ddt\(alpha.,.*\)" bounded Euler; } gradSchemes @@ -34,16 +32,16 @@ divSchemes div(phi,alpha1) Gauss vanLeer; div(phir,alpha1) Gauss vanLeer; - "div\(alphaPhi.,U.\)" bounded Gauss limitedLinearV 1; + "div\(alphaPhi.,U.\)" Gauss limitedLinearV 1; "div\(phi.,U.\)" Gauss limitedLinearV 1; "div\(\(alpha.*Rc\)\)" Gauss linear; "div\(phid.,p\)" Gauss upwind; - "div\(alphaPhi.,h.\)" bounded Gauss limitedLinear 1; + "div\(alphaPhi.,h.\)" Gauss limitedLinear 1; "div\(phi.,K.\)" Gauss limitedLinear 1; - div(alphaPhi2,k) bounded Gauss limitedLinear 1; - div(alphaPhi2,epsilon) bounded Gauss limitedLinear 1; + div(alphaPhi2,k) Gauss limitedLinear 1; + div(alphaPhi2,epsilon) Gauss limitedLinear 1; } laplacianSchemes diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSchemes b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSchemes index e1b193c952..c88d130244 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSchemes +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/fvSchemes @@ -18,8 +18,6 @@ FoamFile ddtSchemes { default Euler; - - "ddt\(alpha.*,.*\)" bounded Euler; } gradSchemes @@ -34,15 +32,15 @@ divSchemes div(phi,alpha1) Gauss vanLeer; div(phir,alpha1) Gauss vanLeer; - "div\(alphaPhi.,U.\)" bounded Gauss limitedLinearV 1; + "div\(alphaPhi.,U.\)" Gauss limitedLinearV 1; "div\(phi.,U.\)" Gauss limitedLinearV 1; "div\(\(alpha.*Rc\)\)" Gauss linear; "div\(phid.,p\)" Gauss linear; - "div\(alphaPhi.,h.\)" bounded Gauss limitedLinear 1; + "div\(alphaPhi.,h.\)" Gauss limitedLinear 1; "div\(phi.,K.\)" Gauss linear; - "div\(alphaPhi.,(k|epsilon)\)" bounded Gauss limitedLinear 1; + "div\(alphaPhi.,(k|epsilon)\)" Gauss limitedLinear 1; } laplacianSchemes diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/constant/polyMesh/boundary b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/constant/polyMesh/boundary index 56e0a545c1..bf47f69643 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/constant/polyMesh/boundary +++ b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/constant/polyMesh/boundary @@ -38,6 +38,7 @@ FoamFile defaultFaces { type empty; + inGroups 1(empty); nFaces 3750; startFace 3850; } From 8098d688a74657fe28972c8950521fdd1d6bb9e7 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 20 Jan 2013 13:28:26 +0000 Subject: [PATCH 11/41] chemkinLexer: Downgrade to original format for therm.dat to support existing tutorials --- .../chemkinReader/chemkinLexer.L | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L index 23c689107c..c0cce76a2a 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L @@ -439,9 +439,20 @@ bool finishReaction = false; {thermoSpecieName} { string specieString(foamSpecieString(YYText())); - specieString.replaceAll(" ", "_"); - size_t strEnd = specieString.find_last_not_of('_'); - currentSpecieName = specieString.substr(0, strEnd + 1); + // Old format + size_t spacePos = specieString.find(' '); + if (spacePos != string::npos) + { + currentSpecieName = specieString(0, spacePos); + } + else + { + currentSpecieName = specieString; + } + // New format + // specieString.replaceAll(" ", "_"); + // size_t strEnd = specieString.find_last_not_of('_'); + // currentSpecieName = specieString.substr(0, strEnd + 1); BEGIN(readThermoDate); } From b8b8f50d2cc33fd0a5477416156ee93b17ea307e Mon Sep 17 00:00:00 2001 From: laurence Date: Sun, 20 Jan 2013 15:23:38 +0000 Subject: [PATCH 12/41] BUG: Update biconic25-55Run35 tutorial to run with latest version of collapseEdges --- .../rhoCentralFoam/biconic25-55Run35/Allrun | 2 +- .../biconic25-55Run35/system/collapseDict | 84 +++++++++++++++++++ .../biconic25-55Run35/system/meshQualityDict | 67 +++++++++++++++ 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/collapseDict create mode 100644 tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/meshQualityDict diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun index ca832252d8..abde516d9c 100755 --- a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun +++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun @@ -20,7 +20,7 @@ runApplication datToFoam grid256.dat CONST="constant" cat $CONST/pointsHeader $CONST/points.tmp > $CONST/polyMesh/points -runApplication collapseEdges "2e-07" 5 +runApplication collapseEdges moveTimeMeshToConstant echo "Changing patch type to wedge type in boundary file" diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/collapseDict b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/collapseDict new file mode 100644 index 0000000000..95602e9516 --- /dev/null +++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/collapseDict @@ -0,0 +1,84 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object collapseDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +collapseEdgesCoeffs +{ + // Edges shorter than this absolute value will be merged + minimumEdgeLength 2e-7; + + // The maximum angle between two edges that share a point attached to + // no other edges + maximumMergeAngle 5; + + // The amount that minimumEdgeLength will be reduced by for each + // edge if that edge's collapse generates a poor quality face + reductionFactor 0.5; +} + + +collapseFacesCoeffs +{ + // The initial face length factor + initialFaceLengthFactor 0.5; + + // The amount that initialFaceLengthFactor will be reduced by for each + // face if its collapse generates a poor quality face + reductionFactor $initialFaceLengthFactor; + + // If the face can't be collapsed to an edge, and it has a span less than + // the target face length multiplied by this coefficient, collapse it + // to a point. + maxCollapseFaceToPointSideLengthCoeff 0.3; + + // Allow early collapse of edges to a point + allowEarlyCollapseToPoint on; + + // Fraction to premultiply maxCollapseFaceToPointSideLengthCoeff by if + // allowEarlyCollapseToPoint is enabled + allowEarlyCollapseCoeff 0.2; + + // Defining how close to the midpoint (M) of the projected + // vertices line a projected vertex (X) can be before making this + // an invalid edge collapse + // + // X---X-g----------------M----X-----------g----X--X + // + // Only allow a collapse if all projected vertices are outwith + // guardFraction (g) of the distance form the face centre to the + // furthest vertex in the considered direction + guardFraction 0.1; +} + + +meshQualityCoeffs +{ + // Name of the dictionary that has the mesh quality coefficients used + // by motionSmoother::checkMesh + #include "meshQualityDict"; + + // Maximum number of smoothing iterations for the reductionFactors + maximumSmoothingIterations 2; + + // Maximum number of outer iterations is mesh quality checking is enabled + maximumIterations 10; + + // Maximum number of iterations deletion of a point can cause a bad face + // to be constructed before it is forced to not be deleted + maxPointErrorCount 5; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/meshQualityDict b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/meshQualityDict new file mode 100644 index 0000000000..d6228d0abd --- /dev/null +++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/meshQualityDict @@ -0,0 +1,67 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: http://www.openfoam.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object meshQualityDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Maximum non-orthogonality allowed. Set to 180 to disable. +maxNonOrtho 180; + +//- Max skewness allowed. Set to <0 to disable. +maxBoundarySkewness 50; + +//- Max skewness allowed. Set to <0 to disable. +maxInternalSkewness 10; + +//- Max concaveness allowed. Is angle (in degrees) below which concavity +// is allowed. 0 is straight face, <0 would be convex face. +// Set to 180 to disable. +maxConcave 80; + +//- Minimum pyramid volume. Is absolute volume of cell pyramid. +// Set to a sensible fraction of the smallest cell volume expected. +// Set to very negative number (e.g. -1E30) to disable. +minVol 1e-20; + +//- Minimum quality of the tet formed by the face-centre +// and variable base point minimum decomposition triangles and +// the cell centre. This has to be a positive number for tracking +// to work. Set to very negative number (e.g. -1E30) to +// disable. +// <0 = inside out tet, +// 0 = flat tet +// 1 = regular tet +minTetQuality 1e-30; + +//- Minimum face area. Set to <0 to disable. +minArea -1; + +//- Minimum face twist. Set to <-1 to disable. dot product of face normal +//- and face centre triangles normal +minTwist 0.0; + +//- minimum normalised cell determinant +//- 1 = hex, <= 0 = folded or flattened illegal cell +minDeterminant 0.001; + +//- minFaceWeight (0 -> 0.5) +minFaceWeight 0.02; + +//- minVolRatio (0 -> 1) +minVolRatio 0.01; + +//must be >0 for Fluent compatibility +minTriangleTwist -1; + + +// ************************************************************************* // From b824bbb6604684c08f0a4fbabcb4bed97c986aaa Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 20 Jan 2013 21:23:17 +0000 Subject: [PATCH 13/41] rhoCentralFoam: Updated the handling of thermal transport Note that smoluchowskiJumpTFvPatchScalarField still uses the specified Pr from the thermophysicalProperties whereas it should derive appropriate information from the thermo package --- .../T/smoluchowskiJumpTFvPatchScalarField.C | 10 ++++---- .../readThermophysicalProperties.H | 23 ------------------- .../rhoCentralDyMFoam/rhoCentralDyMFoam.C | 4 ---- .../rhoCentralFoam/rhoCentralFoam.C | 1 - 4 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C index 2b04637b04..d636481b31 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C @@ -185,12 +185,10 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs() dimensionedScalar Pr ( - dimensionedScalar::lookupOrDefault - ( - "Pr", - thermophysicalProperties, - 1.0 - ) + "Pr", + dimless, + thermophysicalProperties.subDict("mixture").subDict("transport") + .lookup("Pr") ); Field C2 diff --git a/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H b/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H deleted file mode 100644 index e0b16f0f39..0000000000 --- a/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H +++ /dev/null @@ -1,23 +0,0 @@ -Info<< "Reading thermophysicalProperties\n" << endl; - -// Pr defined as a separate constant to enable calculation of k, currently -// inaccessible through thermo -IOdictionary thermophysicalProperties -( - IOobject - ( - "thermophysicalProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) -); - -dimensionedScalar Pr -( - "Pr", - dimless, - thermophysicalProperties.subDict("mixture").subDict("transport") - .lookup("Pr") -); diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C index 0d69256d21..5f25016a84 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C @@ -46,7 +46,6 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" #include "createFields.H" - #include "readThermophysicalProperties.H" #include "readTimeControls.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -236,13 +235,10 @@ int main(int argc, char *argv[]) if (!inviscid) { - volScalarField k("k", thermo.Cp()*muEff/Pr); solve ( fvm::ddt(rho, e) - fvc::ddt(rho, e) - fvm::laplacian(turbulence->alphaEff(), e) - + fvc::laplacian(turbulence->alpha(), e) - - fvc::laplacian(k, T) ); thermo.correct(); rhoE = rho*(e + 0.5*magSqr(U)); diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C index 84a122d0dd..24752a166a 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C @@ -45,7 +45,6 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" #include "createFields.H" - #include "readThermophysicalProperties.H" #include "readTimeControls.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // From 52c637f8062b97d50d976ceee967e46cf5bb53ac Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 20 Jan 2013 21:50:45 +0000 Subject: [PATCH 14/41] tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet: Removed unused setting --- .../cavitatingBullet/constant/transportProperties | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/constant/transportProperties b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/constant/transportProperties index 995339fd09..c78a74d48d 100644 --- a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/constant/transportProperties +++ b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/constant/transportProperties @@ -14,8 +14,6 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -phaseChange on; - phaseChangeTwoPhaseMixture SchnerrSauer; pSat pSat [1 -1 -2 0 0] 2300; // saturation pressure From ba391381abdd59695b264b0cd305bf32e5961537 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 21 Jan 2013 11:40:20 +0000 Subject: [PATCH 15/41] STYLE: minor input file change --- .../rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions index d75a43c565..57de407801 100644 --- a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions +++ b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions @@ -59,4 +59,4 @@ porosity1 } -************************************************************************* // +//***************************************************************************// From 685635e6a393e10d8b2332c0d7558e9e79a5512a Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 21 Jan 2013 12:17:17 +0000 Subject: [PATCH 16/41] ENH: Deleting parabolicCylindricalCS, sphericalCS and toroidalCS coordinate systems Modifying constructors from dictionary of coordinateSystem class (no default type) Adding localAxesRotation type. It constructs a axes-rotation tensor on each cell centre. Adding functionality to coordinateRotation blase class (transformTensor, transformVector, etc) --- src/engine/enginePiston/enginePiston.C | 2 +- src/engine/engineValve/engineValve.C | 2 +- .../derived/rotorDiskSource/rotorDiskSource.C | 8 +- .../trimModel/targetCoeff/targetCoeffTrim.C | 6 +- src/meshTools/Make/files | 7 +- src/meshTools/coordinateSystems/cartesianCS.C | 162 +++++++++ .../{sphericalCS.H => cartesianCS.H} | 59 ++-- .../EulerCoordinateRotation.C | 170 ++++++++- .../EulerCoordinateRotation.H | 97 ++++++ .../STARCDCoordinateRotation.C | 167 ++++++++- .../STARCDCoordinateRotation.H | 96 ++++++ .../coordinateRotation/axesRotation.C | 324 ++++++++++++++++++ .../coordinateRotation/axesRotation.H | 229 +++++++++++++ .../coordinateRotation/coordinateRotation.C | 212 ++---------- .../coordinateRotation/coordinateRotation.H | 202 +++++------ .../coordinateRotationNew.C | 107 ++++++ .../coordinateRotation/localAxesRotation.C | 282 +++++++++++++++ .../coordinateRotation/localAxesRotation.H | 209 +++++++++++ .../coordinateSystems/coordinateSystem.C | 132 ++++--- .../coordinateSystems/coordinateSystem.H | 242 ++++--------- .../coordinateSystems/coordinateSystemNew.C | 78 ++++- .../coordinateSystems/coordinateSystems.H | 19 + .../coordinateSystems/cylindricalCS.C | 18 +- .../coordinateSystems/cylindricalCS.H | 12 +- .../parabolicCylindricalCS.C | 177 ---------- .../parabolicCylindricalCS.H | 120 ------- src/meshTools/coordinateSystems/sphericalCS.C | 244 ------------- src/meshTools/coordinateSystems/toroidalCS.C | 184 ---------- src/meshTools/coordinateSystems/toroidalCS.H | 133 ------- .../searchableSurfaceCollection.C | 1 - .../fieldCoordinateSystemTransform.C | 2 +- .../fieldCoordinateSystemTransformTemplates.C | 2 +- .../functionObjects/forces/forces/forces.C | 2 +- src/sampling/sampledSet/array/arraySet.C | 2 +- .../sampledPlane/sampledPlane.C | 2 +- 35 files changed, 2244 insertions(+), 1467 deletions(-) create mode 100644 src/meshTools/coordinateSystems/cartesianCS.C rename src/meshTools/coordinateSystems/{sphericalCS.H => cartesianCS.H} (77%) create mode 100644 src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C create mode 100644 src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H create mode 100644 src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C create mode 100644 src/meshTools/coordinateSystems/coordinateRotation/localAxesRotation.C create mode 100644 src/meshTools/coordinateSystems/coordinateRotation/localAxesRotation.H delete mode 100644 src/meshTools/coordinateSystems/parabolicCylindricalCS.C delete mode 100644 src/meshTools/coordinateSystems/parabolicCylindricalCS.H delete mode 100644 src/meshTools/coordinateSystems/sphericalCS.C delete mode 100644 src/meshTools/coordinateSystems/toroidalCS.C delete mode 100644 src/meshTools/coordinateSystems/toroidalCS.H diff --git a/src/engine/enginePiston/enginePiston.C b/src/engine/enginePiston/enginePiston.C index deac506a02..b186324fd7 100644 --- a/src/engine/enginePiston/enginePiston.C +++ b/src/engine/enginePiston/enginePiston.C @@ -63,7 +63,7 @@ Foam::enginePiston::enginePiston ( coordinateSystem::New ( - "coordinateSystem", + mesh_, dict.subDict("coordinateSystem") ) ), diff --git a/src/engine/engineValve/engineValve.C b/src/engine/engineValve/engineValve.C index 6b130711a3..90daa4a2da 100644 --- a/src/engine/engineValve/engineValve.C +++ b/src/engine/engineValve/engineValve.C @@ -125,7 +125,7 @@ Foam::engineValve::engineValve ( coordinateSystem::New ( - "coordinateSystem", + mesh_, dict.subDict("coordinateSystem") ) ), diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C index 070ce02518..7896ae5dda 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C @@ -92,7 +92,7 @@ void Foam::fv::rotorDiskSource::checkData() ( readScalar(coeffs_.lookup("inletNormalVelocity")) ); - inletVelocity_ = -coordSys_.e3()*UIn; + inletVelocity_ = -coordSys_.R().e3()*UIn; break; } case ifLocal: @@ -345,9 +345,9 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem() << " - disk diameter = " << diameter << nl << " - disk area = " << sumArea << nl << " - origin = " << coordSys_.origin() << nl - << " - r-axis = " << coordSys_.e1() << nl - << " - psi-axis = " << coordSys_.e2() << nl - << " - z-axis = " << coordSys_.e3() << endl; + << " - r-axis = " << coordSys_.R().e1() << nl + << " - psi-axis = " << coordSys_.R().e2() << nl + << " - z-axis = " << coordSys_.R().e3() << endl; } diff --git a/src/fvOptions/sources/derived/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C b/src/fvOptions/sources/derived/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C index 8ee53bad24..4de719b1f6 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C @@ -59,9 +59,9 @@ Foam::vector Foam::targetCoeffTrim::calcCoeffs const List& x = rotor_.x(); const vector& origin = rotor_.coordSys().origin(); - const vector& rollAxis = rotor_.coordSys().e1(); - const vector& pitchAxis = rotor_.coordSys().e2(); - const vector& yawAxis = rotor_.coordSys().e3(); + const vector& rollAxis = rotor_.coordSys().R().e1(); + const vector& pitchAxis = rotor_.coordSys().R().e2(); + const vector& yawAxis = rotor_.coordSys().R().e3(); scalar coeff1 = alpha_*sqr(rotor_.omega())*mathematical::pi; diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 401d14a383..c8bc7b23a9 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -14,12 +14,13 @@ $(csys)/coordinateSystem.C $(csys)/coordinateSystemNew.C $(csys)/coordinateSystems.C $(csys)/cylindricalCS.C -$(csys)/sphericalCS.C -$(csys)/parabolicCylindricalCS.C -$(csys)/toroidalCS.C +$(csys)/cartesianCS.C +$(csys)/coordinateRotation/axesRotation.C $(csys)/coordinateRotation/coordinateRotation.C +$(csys)/coordinateRotation/coordinateRotationNew.C $(csys)/coordinateRotation/EulerCoordinateRotation.C $(csys)/coordinateRotation/STARCDCoordinateRotation.C +$(csys)/coordinateRotation/localAxesRotation.C edgeFaceCirculator/edgeFaceCirculator.C diff --git a/src/meshTools/coordinateSystems/cartesianCS.C b/src/meshTools/coordinateSystems/cartesianCS.C new file mode 100644 index 0000000000..4de586c2e9 --- /dev/null +++ b/src/meshTools/coordinateSystems/cartesianCS.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "cartesianCS.H" + +#include "one.H" +#include "mathematicalConstants.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cartesianCS, 0); + addToRunTimeSelectionTable(coordinateSystem, cartesianCS, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cartesianCS::cartesianCS() +: + coordinateSystem() +{} + + +Foam::cartesianCS::cartesianCS +( + const coordinateSystem& cs +) +: + coordinateSystem(cs) +{} + + +Foam::cartesianCS::cartesianCS +( + const word& name, + const coordinateSystem& cs +) +: + coordinateSystem(name, cs) +{} + + +Foam::cartesianCS::cartesianCS +( + const word& name, + const point& origin, + const coordinateRotation& cr +) +: + coordinateSystem(name, origin, cr) +{} + + +Foam::cartesianCS::cartesianCS +( + const word& name, + const point& origin, + const vector& axis, + const vector& dirn +) +: + coordinateSystem(name, origin, axis, dirn) +{} + + +Foam::cartesianCS::cartesianCS +( + const word& name, + const dictionary& dict +) +: + coordinateSystem(name, dict) +{} + + +Foam::cartesianCS::cartesianCS +( + const objectRegistry& obr, + const dictionary& dict +) +: + coordinateSystem(obr, dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cartesianCS::~cartesianCS() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +Foam::vector Foam::cartesianCS::localToGlobal +( + const vector& local, + bool translate +) const +{ + return coordinateSystem::localToGlobal(local, translate); +} + + +Foam::tmp Foam::cartesianCS::localToGlobal +( + const vectorField& local, + bool translate +) const +{ + return coordinateSystem::localToGlobal(local, translate); +} + + +Foam::vector Foam::cartesianCS::globalToLocal +( + const vector& global, + bool translate +) const +{ + return coordinateSystem::globalToLocal(global, translate); +} + + +Foam::tmp Foam::cartesianCS::globalToLocal +( + const vectorField& global, + bool translate +) const +{ + return coordinateSystem::globalToLocal(global, translate); +} + + + + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/sphericalCS.H b/src/meshTools/coordinateSystems/cartesianCS.H similarity index 77% rename from src/meshTools/coordinateSystems/sphericalCS.H rename to src/meshTools/coordinateSystems/cartesianCS.H index f8565bb76f..3986d8a59c 100644 --- a/src/meshTools/coordinateSystems/sphericalCS.H +++ b/src/meshTools/coordinateSystems/cartesianCS.H @@ -22,20 +22,21 @@ License along with OpenFOAM. If not, see . Class - Foam::sphericalCS + Foam::cartesianCS Description - Spherical coordinate system + Cylindrical coordinate system SourceFiles - sphericalCS.C + cartesianCS.C \*---------------------------------------------------------------------------*/ -#ifndef sphericalCS_H -#define sphericalCS_H +#ifndef cartesianCS_H +#define cartesianCS_H #include "coordinateSystem.H" +#include "typeInfo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,23 +44,18 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class sphericalCS Declaration + Class cartesianCS Declaration \*---------------------------------------------------------------------------*/ -class sphericalCS +class cartesianCS : public coordinateSystem { - // Private data members - - //- Are angles in degrees? (default = true) - bool inDegrees_; - - protected: // Protected Member Functions + //- Convert from local coordinate system to the global Cartesian system // with optional translation for the origin virtual vector localToGlobal(const vector&, bool translate) const; @@ -88,61 +84,58 @@ protected: public: //- Runtime type information - TypeName("spherical"); + TypeName("cartesian"); // Constructors //- Construct null - sphericalCS(const bool inDegrees=true); + cartesianCS(); //- Construct copy - sphericalCS + cartesianCS ( - const coordinateSystem&, - const bool inDegrees=true + const coordinateSystem& ); //- Construct copy with a different name - sphericalCS + cartesianCS ( const word& name, - const coordinateSystem&, - const bool inDegrees=true + const coordinateSystem& ); //- Construct from origin and rotation - sphericalCS + cartesianCS ( const word& name, const point& origin, - const coordinateRotation&, - const bool inDegrees=true + const coordinateRotation& ); //- Construct from origin and 2 axes - sphericalCS + cartesianCS ( const word& name, const point& origin, const vector& axis, - const vector& dirn, - const bool inDegrees=true + const vector& dirn ); //- Construct from dictionary - sphericalCS(const word& name, const dictionary&); + cartesianCS(const word&, const dictionary&); - // Member Functions + //- Construct from dictionary and objectRegistry + cartesianCS(const objectRegistry&, const dictionary&); - //- Are angles in degrees? - bool inDegrees() const; - //- Non-const access to inDegrees - bool& inDegrees(); + //- Destructor + virtual ~cartesianCS(); + }; + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C index c79697eec9..cf730ec042 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C @@ -39,8 +39,134 @@ namespace Foam EulerCoordinateRotation, dictionary ); + addToRunTimeSelectionTable + ( + coordinateRotation, + EulerCoordinateRotation, + objectRegistry + ); } +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::vector Foam::EulerCoordinateRotation::transform(const vector& st) const +{ + return (R_ & st); +} + + +Foam::vector Foam::EulerCoordinateRotation::invTransform +( + const vector& st +) const +{ + return (Rtr_ & st); +} + + +Foam::tmp Foam::EulerCoordinateRotation::transform +( + const vectorField& st +) const +{ + notImplemented + ( + "tmp Foam::EulerCoordinateRotation:: " + "transform(const vectorField& st) const" + ); + return tmp(NULL); +} + + +Foam::tmp Foam::EulerCoordinateRotation::invTransform +( + const vectorField& st +) const +{ + notImplemented + ( + "tmp Foam::EulerCoordinateRotation::" + "invTransform(const vectorField& st) const" + ); + return tmp(NULL); +} + + +const Foam::tensorField& Foam::EulerCoordinateRotation::Tr() const +{ + notImplemented + ( + "const tensorField& EulerCoordinateRotation::Tr() const" + ); + return *reinterpret_cast(0); +} + + +Foam::tmp Foam::EulerCoordinateRotation::transformTensor +( + const tensorField& st +) const +{ + notImplemented + ( + "const tensorField& EulerCoordinateRotation::transformTensor() const" + ); + return tmp(NULL); +} + + +Foam::tensor Foam::EulerCoordinateRotation::transformTensor +( + const tensor& st +) const +{ + return (R_ & st & Rtr_); +} + + +Foam::tmp Foam::EulerCoordinateRotation::transformTensor +( + const tensorField& st, + const labelList& cellMap +) const +{ + notImplemented + ( + "tmp EulerCoordinateRotation::transformTensor " + " const tensorField& st," + " const labelList& cellMap " + ") const" + ); + return tmp(NULL); +} + + +Foam::tmp Foam::EulerCoordinateRotation:: +transformVector +( + const vectorField& st +) const +{ + tmp tfld(new symmTensorField(st.size())); + symmTensorField& fld = tfld(); + + forAll(fld, i) + { + fld[i] = transformPrincipal(R_, st[i]); + } + return tfld; +} + + +Foam::symmTensor Foam::EulerCoordinateRotation::transformVector +( + const vector& st +) const +{ + return transformPrincipal(R_, st); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::EulerCoordinateRotation::calcTransform @@ -62,7 +188,7 @@ void Foam::EulerCoordinateRotation::calcTransform psi *= constant::mathematical::pi/180.0; } - tensor::operator= + R_ = ( tensor ( @@ -79,6 +205,8 @@ void Foam::EulerCoordinateRotation::calcTransform cos(theta) ) ); + + Rtr_ = R_.T(); } @@ -86,7 +214,8 @@ void Foam::EulerCoordinateRotation::calcTransform Foam::EulerCoordinateRotation::EulerCoordinateRotation() : - coordinateRotation() + R_(sphericalTensor::I), + Rtr_(R_) {} @@ -96,7 +225,8 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation const bool inDegrees ) : - coordinateRotation() + R_(sphericalTensor::I), + Rtr_(R_) { calcTransform ( @@ -116,7 +246,8 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation const bool inDegrees ) : - coordinateRotation() + R_(sphericalTensor::I), + Rtr_(R_) { calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees); } @@ -127,7 +258,8 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation const dictionary& dict ) : - coordinateRotation() + R_(sphericalTensor::I), + Rtr_(R_) { vector rotation(dict.lookup("rotation")); @@ -141,4 +273,32 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation } +Foam::EulerCoordinateRotation::EulerCoordinateRotation +( + const dictionary& dict, + const objectRegistry& +) +: + R_(sphericalTensor::I), + Rtr_(R_) +{ + vector rotation(dict.lookup("rotation")); + + calcTransform + ( + rotation.component(vector::X), + rotation.component(vector::Y), + rotation.component(vector::Z), + dict.lookupOrDefault("degrees", true) + ); +} + + +void Foam::EulerCoordinateRotation::write(Ostream& os) const +{ + os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; + os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl; + os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; +} + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H index b8936975ea..ea7aa8f023 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H @@ -65,6 +65,16 @@ class EulerCoordinateRotation : public coordinateRotation { + + // Private Member Data + + //- Local-to-global transformation tensor + tensor R_; + + //- Global-to-Local transformation tensor + tensor Rtr_; + + // Private Member Functions //- Calculate transformation tensor @@ -107,6 +117,93 @@ public: //- Construct from dictionary EulerCoordinateRotation(const dictionary&); + //- Construct from dictionary and mesh + EulerCoordinateRotation(const dictionary&, const objectRegistry&); + + + // Member Functions + + //- Reset rotation to an identity rotation + virtual void clear() + { + R_ = sphericalTensor::I; + Rtr_ = sphericalTensor::I; + } + + //- Return local-to-global transformation tensor + virtual const tensor& R() const + { + return R_; + } + + //- Return global-to-local transformation tensor + virtual const tensor& Rtr() const + { + return Rtr_; + }; + + //- Return local Cartesian x-axis + virtual const vector e1() const + { + return R_.x(); + } + + //- Return local Cartesian y-axis + virtual const vector e2() const + { + return R_.y(); + } + + //- Return local Cartesian z-axis + virtual const vector e3() const + { + return R_.z(); + } + + //- Return transformation tensor field + virtual const tensorField& Tr() const; + + //- Transform vectorField using transformation tensor field + virtual tmp transform(const vectorField& st) const; + + //- Transform vector using transformation tensor + virtual vector transform(const vector& st) const; + + //- Inverse transform vectorField using transformation tensor field + virtual tmp invTransform(const vectorField& st) const; + + //- Inverse transform vector using transformation tensor + virtual vector invTransform(const vector& st) const; + + //- Transform tensor field using transformation tensorField + virtual tmp transformTensor(const tensorField& st) const; + + //- Transform tensor using transformation tensorField + virtual tensor transformTensor(const tensor& st) const; + + //- Transform tensor sub-field using transformation tensorField + virtual tmp transformTensor + ( + const tensorField& st, + const labelList& cellMap + ) const; + + //- Transform vectorField using transformation tensorField and return + // symmetrical tensorField + virtual tmp transformVector + ( + const vectorField& st + ) const; + + //- Transform vector using transformation tensor and return + // symmetrical tensor + virtual symmTensor transformVector(const vector& st) const; + + + // Write + + //- Write + virtual void write(Ostream&) const; }; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C index ab2c77ae94..3fe8eab178 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C @@ -39,9 +39,134 @@ namespace Foam STARCDCoordinateRotation, dictionary ); + addToRunTimeSelectionTable + ( + coordinateRotation, + STARCDCoordinateRotation, + objectRegistry + ); } +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::vector Foam::STARCDCoordinateRotation::transform(const vector& st) const +{ + return (R_ & st); +} + + +Foam::vector Foam::STARCDCoordinateRotation::invTransform +( + const vector& st +) const +{ + return (Rtr_ & st); +} + + +Foam::tmp Foam::STARCDCoordinateRotation::transform +( + const vectorField& st +) const +{ + notImplemented + ( + "tmp Foam::STARCDCoordinateRotation:: " + "transform(const vectorField& st) const" + ); + return tmp(NULL); +} + + +Foam::tmp Foam::STARCDCoordinateRotation::invTransform +( + const vectorField& st +) const +{ + notImplemented + ( + "tmp Foam::STARCDCoordinateRotation::" + "invTransform(const vectorField& st) const" + ); + return tmp(NULL); +} + + +const Foam::tensorField& Foam::STARCDCoordinateRotation::Tr() const +{ + notImplemented + ( + "const tensorField& STARCDCoordinateRotatio::Tr() const" + ); + return *reinterpret_cast(0); +} + + +Foam::tmp Foam::STARCDCoordinateRotation::transformTensor +( + const tensorField& st +) const +{ + notImplemented + ( + "tmp STARCDCoordinateRotation::transformTensor()" + ); + return tmp(NULL); +} + + +Foam::tensor Foam::STARCDCoordinateRotation::transformTensor +( + const tensor& st +) const +{ + return (R_ & st & Rtr_); +} + + +Foam::tmp Foam::STARCDCoordinateRotation::transformTensor +( + const tensorField& st, + const labelList& cellMap +) const +{ + notImplemented + ( + "tmp STARCDCoordinateRotation::transformTensor " + " const tensorField& st," + " const labelList& cellMap " + ") const" + ); + return tmp(NULL); +} + + +Foam::tmp Foam::STARCDCoordinateRotation:: +transformVector +( + const vectorField& st +) const +{ + tmp tfld(new symmTensorField(st.size())); + symmTensorField& fld = tfld(); + + forAll(fld, i) + { + fld[i] = transformPrincipal(R_, st[i]); + } + return tfld; +} + + +Foam::symmTensor Foam::STARCDCoordinateRotation::transformVector +( + const vector& st +) const +{ + return transformPrincipal(R_, st); +} + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::STARCDCoordinateRotation::calcTransform @@ -63,7 +188,7 @@ void Foam::STARCDCoordinateRotation::calcTransform z *= constant::mathematical::pi/180.0; } - tensor::operator= + R_ = ( tensor ( @@ -80,6 +205,8 @@ void Foam::STARCDCoordinateRotation::calcTransform cos(x)*cos(y) ) ); + + Rtr_ = R_.T(); } @@ -87,7 +214,8 @@ void Foam::STARCDCoordinateRotation::calcTransform Foam::STARCDCoordinateRotation::STARCDCoordinateRotation() : - coordinateRotation() + R_(sphericalTensor::I), + Rtr_(R_) {} @@ -97,7 +225,8 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation const bool inDegrees ) : - coordinateRotation() + R_(sphericalTensor::I), + Rtr_(R_) { calcTransform ( @@ -117,7 +246,8 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation const bool inDegrees ) : - coordinateRotation() + R_(sphericalTensor::I), + Rtr_(R_) { calcTransform(rotZ, rotX, rotY, inDegrees); } @@ -128,7 +258,8 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation const dictionary& dict ) : - coordinateRotation() + R_(sphericalTensor::I), + Rtr_(R_) { vector rotation(dict.lookup("rotation")); @@ -141,4 +272,30 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation ); } + +Foam::STARCDCoordinateRotation::STARCDCoordinateRotation +( + const dictionary& dict, + const objectRegistry& +) +{ + vector rotation(dict.lookup("rotation")); + + calcTransform + ( + rotation.component(vector::X), + rotation.component(vector::Y), + rotation.component(vector::Z), + dict.lookupOrDefault("degrees", true) + ); +} + + +void Foam::STARCDCoordinateRotation::write(Ostream& os) const +{ + os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; + os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl; + os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; +} + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H index f3286d80ff..ba5fabad44 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H @@ -62,6 +62,16 @@ class STARCDCoordinateRotation : public coordinateRotation { + + // Private Member Data + + //- Local-to-Global transformation tensor + tensor R_; + + //- Global-to-Local transformation tensor + tensor Rtr_; + + // Private Member Functions //- Calculate transformation tensor @@ -104,6 +114,92 @@ public: //- Construct from dictionary STARCDCoordinateRotation(const dictionary&); + //- Construct from dictionary and mesh + STARCDCoordinateRotation(const dictionary&, const objectRegistry&); + + // Member Functions + + //- Reset rotation to an identity rotation + virtual void clear() + { + R_ = sphericalTensor::I; + Rtr_ = sphericalTensor::I; + } + + //- Return local-to-global transformation tensor + virtual const tensor& R() const + { + return R_; + } + + //- Return global-to-local transformation tensor + virtual const tensor& Rtr() const + { + return Rtr_; + }; + + //- Return local Cartesian x-axis + virtual const vector e1() const + { + return R_.x(); + } + + //- Return local Cartesian y-axis + virtual const vector e2() const + { + return R_.y(); + } + + //- Return local Cartesian z-axis + virtual const vector e3() const + { + return R_.z(); + } + + //- Return transformation tensor field + virtual const tensorField& Tr() const; + + //- Transform vectorField using transformation tensor field + virtual tmp transform(const vectorField& st) const; + + //- Transform vector using transformation tensor + virtual vector transform(const vector& st) const; + + //- Inverse transform vectorField using transformation tensor field + virtual tmp invTransform(const vectorField& st) const; + + //- Inverse transform vector using transformation tensor + virtual vector invTransform(const vector& st) const; + + //- Transform tensor field using transformation tensorField + virtual tmp transformTensor(const tensorField& st) const; + + //- Transform tensor using transformation tensorField + virtual tensor transformTensor(const tensor& st) const; + + //- Transform tensor sub-field using transformation tensorField + virtual tmp transformTensor + ( + const tensorField& st, + const labelList& cellMap + ) const; + + //- Transform vectorField using transformation tensorField and return + // symmetrical tensorField + virtual tmp transformVector + ( + const vectorField& st + ) const; + + //- Transform vector using transformation tensor and return + // symmetrical tensor + virtual symmTensor transformVector(const vector& st) const; + + + // Write + + //- Write + virtual void write(Ostream&) const; }; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C new file mode 100644 index 0000000000..7d76bc4f31 --- /dev/null +++ b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C @@ -0,0 +1,324 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "axesRotation.H" +#include "dictionary.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(axesRotation, 0); + addToRunTimeSelectionTable(coordinateRotation, axesRotation, dictionary); + addToRunTimeSelectionTable + ( + coordinateRotation, + axesRotation, + objectRegistry + ); +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::axesRotation::calcTransform +( + const vector& axis1, + const vector& axis2, + const axisOrder& order +) +{ + vector a = axis1 / mag(axis1); + vector b = axis2; + + // Absorb minor nonorthogonality into axis2 + b = b - (b & a)*a; + + if (mag(b) < SMALL) + { + FatalErrorIn("axesRotation::calcTransform()") + << "axis1, axis2 appear co-linear: " + << axis1 << ", " << axis2 << endl + << abort(FatalError); + } + + b = b / mag(b); + vector c = a ^ b; + + tensor Rtr; + switch (order) + { + case e1e2: + Rtr = tensor(a, b, c); + break; + + case e2e3: + Rtr = tensor(c, a, b); + break; + + case e3e1: + Rtr = tensor(b, c, a); + break; + + default: + FatalErrorIn("axesRotation::calcTransform()") + << "programmer error" << endl + << abort(FatalError); + + Rtr = tensor::zero; + break; + } + + // the global -> local transformation + Rtr_ = Rtr; + // the local -> global transformation + R_ = Rtr.T(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::axesRotation::axesRotation() +: + R_(sphericalTensor::I), + Rtr_(R_) +{} + + +Foam::axesRotation::axesRotation +( + const vector& axis, + const vector& dir +) +: + R_(sphericalTensor::I), + Rtr_(R_) +{ + calcTransform(axis, dir, e3e1); +} + + +Foam::axesRotation::axesRotation +( + const dictionary& dict +) +: + R_(sphericalTensor::I), + Rtr_(R_) +{ + operator=(dict); +} + + +Foam::axesRotation::axesRotation +( + const dictionary& dict, + const objectRegistry& obr +) +: + R_(sphericalTensor::I), + Rtr_(R_) +{ + operator=(dict); +} + + +Foam::axesRotation::axesRotation(const tensor& R) +: + R_(R), + Rtr_(R_.T()) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::vector Foam::axesRotation::transform(const vector& st) const +{ + return (R_ & st); +} + + +Foam::vector Foam::axesRotation::invTransform(const vector& st) const +{ + return (Rtr_ & st); +} + + +Foam::tmp Foam::axesRotation::transform +( + const vectorField& st +) const +{ + notImplemented + ( + "tmp Foam::axesRotation:: " + "transform(const vectorField& st) const" + ); + return tmp(NULL); +} + + +Foam::tmp Foam::axesRotation::invTransform +( + const vectorField& st +) const +{ + notImplemented + ( + "tmp Foam::axesRotation::" + "invTransform(const vectorField& st) const" + ); + return tmp(NULL); +} + + +const Foam::tensorField& Foam::axesRotation::Tr() const +{ + notImplemented + ( + "const Foam::tensorField& axesRotation::Tr() const" + ); + return *reinterpret_cast(0); +} + + +Foam::tmp Foam::axesRotation::transformTensor +( + const tensorField& st +) const +{ + notImplemented + ( + "const tensorField& axesRotation::transformTensor() const" + ); + return tmp(NULL); +} + + +Foam::tensor Foam::axesRotation::transformTensor +( + const tensor& st +) const +{ + return (R_ & st & Rtr_); +} + + +Foam::tmp Foam::axesRotation::transformTensor +( + const tensorField& st, + const labelList& cellMap +) const +{ + notImplemented + ( + "tmp axesRotation::transformTensor " + " const tensorField& st," + " const labelList& cellMap " + ") const" + ); + return tmp(NULL); +} + +Foam::tmp Foam::axesRotation::transformVector +( + const vectorField& st +) const +{ + tmp tfld(new symmTensorField(st.size())); + symmTensorField& fld = tfld(); + + forAll(fld, i) + { + fld[i] = transformPrincipal(R_, st[i]); + } + return tfld; +} + + +Foam::symmTensor Foam::axesRotation::transformVector +( + const vector& st +) const +{ + return transformPrincipal(R_, st); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void Foam::axesRotation::operator=(const dictionary& dict) +{ + if (debug) + { + Pout<< "axesRotation::operator=(const dictionary&) : " + << "assign from " << dict << endl; + } + + vector axis1, axis2; + axisOrder order(e3e1); + + if (dict.readIfPresent("e1", axis1) && dict.readIfPresent("e2", axis2)) + { + order = e1e2; + } + else if (dict.readIfPresent("e2", axis1)&& dict.readIfPresent("e3", axis2)) + { + order = e2e3; + } + else if (dict.readIfPresent("e3", axis1)&& dict.readIfPresent("e1", axis2)) + { + order = e3e1; + } + else if (dict.found("axis") || dict.found("direction")) + { + // let it bomb if only one of axis/direction is defined + order = e3e1; + dict.lookup("axis") >> axis1; + dict.lookup("direction") >> axis2; + } + else + { + FatalErrorIn + ( + "axesRotation::operator=(const dictionary&) " + ) << "not entry of the type (e1, e2) or (e2, e3) or (e3, e1) " + << "found " + << exit(FatalError); + } + + calcTransform(axis1, axis2, order); +} + + +void Foam::axesRotation::write(Ostream& os) const +{ + os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; + os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl; + os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H new file mode 100644 index 0000000000..fd61ebc506 --- /dev/null +++ b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H @@ -0,0 +1,229 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::axesRotation + +Description + A coordinate rotation specified using global axis + + The rotation is defined by a combination of vectors (e1/e2), (e2/e3) + or (e3/e1). Any nonorthogonality will be absorbed into the second vector. + + \verbatim + axesRotation + { + type axesRotation; + e1 (1 0 0); + e2 (0 1 0); + } + \endverbatim + +\*---------------------------------------------------------------------------*/ + +#ifndef axesRotation_H +#define axesRotation_H + +#include "vector.H" +#include "coordinateRotation.H" +#include "dictionary.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class axesRotation Declaration +\*---------------------------------------------------------------------------*/ + +class axesRotation +: + public coordinateRotation +{ + // Private data + + //- Local-to-Global transformation tensor + tensor R_; + + //- Global-to-Local transformation tensor + tensor Rtr_; + + //- the combination of local axes to be used + enum axisOrder + { + e1e2, + e2e3, + e3e1 + }; + + // Private Member Functions + + //- Calculate transformation tensor + void calcTransform + ( + const vector& axis1, + const vector& axis2, + const axisOrder& order = e3e1 + ); + +public: + + //- Runtime type information + TypeName("axesRotation"); + + // Constructors + + //- Construct null + axesRotation(); + + //- Construct from 2 axes + axesRotation + ( + const vector& axis, + const vector& dir + ); + + //- Construct from dictionary + axesRotation(const dictionary&); + + //- Construct from components + axesRotation(const tensor& R); + + //- Construct from dictionary and mesh + axesRotation(const dictionary&, const objectRegistry&); + + //- Return clone + autoPtr clone() const + { + return autoPtr(new axesRotation(*this)); + } + + + //- Destructor + virtual ~axesRotation() + {} + + + // Member Functions + + //- Reset rotation to an identity rotation + virtual void clear() + { + R_ = sphericalTensor::I; + Rtr_ = sphericalTensor::I; + } + + //- Return local-to-global transformation tensor + virtual const tensor& R() const + { + return R_; + } + + //- Return global-to-local transformation tensor + virtual const tensor& Rtr() const + { + return Rtr_; + } + + //- Return local Cartesian x-axis + virtual const vector e1() const + { + return R_.x(); + } + + //- Return local Cartesian y-axis + virtual const vector e2() const + { + return R_.y(); + } + + //- Return local Cartesian z-axis + virtual const vector e3() const + { + return R_.z(); + } + + //- Return transformation tensor field + virtual const tensorField& Tr() const; + + //- Transform vectorField using transformation tensor field + virtual tmp transform(const vectorField& st) const; + + //- Transform vector using transformation tensor + virtual vector transform(const vector& st) const; + + //- Inverse transform vectorField using transformation tensor field + virtual tmp invTransform(const vectorField& st) const; + + //- Inverse transform vector using transformation tensor + virtual vector invTransform(const vector& st) const; + + //- Transform tensor field using transformation tensorField + virtual tmp transformTensor(const tensorField& st) const; + + //- Transform tensor using transformation tensorField + virtual tensor transformTensor(const tensor& st) const; + + //- Transform tensor sub-field using transformation tensorField + virtual tmp transformTensor + ( + const tensorField& st, + const labelList& cellMap + ) const; + + //- Transform vectorField using transformation tensorField and return + // symmetrical tensorField + virtual tmp transformVector + ( + const vectorField& st + ) const; + + //- Transform vector using transformation tensor and return + // symmetrical tensor + virtual symmTensor transformVector(const vector& st) const; + + + // Member Operators + + //- assign from dictionary + void operator=(const dictionary&); + + + // Write + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C index 4b34a42a8d..f96e4587bd 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C @@ -33,197 +33,45 @@ namespace Foam { defineTypeNameAndDebug(coordinateRotation, 0); defineRunTimeSelectionTable(coordinateRotation, dictionary); -} - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::coordinateRotation::calcTransform -( - const vector& axis1, - const vector& axis2, - const axisOrder& order -) -{ - vector a = axis1 / mag(axis1); - vector b = axis2; - - // Absorb minor nonorthogonality into axis2 - b = b - (b & a)*a; - - if (mag(b) < SMALL) - { - FatalErrorIn("coordinateRotation::calcTransform()") - << "axis1, axis2 appear co-linear: " - << axis1 << ", " << axis2 << endl - << abort(FatalError); - } - - b = b / mag(b); - vector c = a ^ b; - - // the global -> local transformation - tensor Rtr; - switch (order) - { - case e1e2: - Rtr = tensor(a, b, c); - break; - - case e2e3: - Rtr = tensor(c, a, b); - break; - - case e3e1: - Rtr = tensor(b, c, a); - break; - - default: - FatalErrorIn("coordinateRotation::calcTransform()") - << "programmer error" << endl - << abort(FatalError); - // To satisfy compiler warnings - Rtr = tensor::zero; - break; - } - - // the local -> global transformation - tensor::operator=( Rtr.T() ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::coordinateRotation::coordinateRotation() -: - tensor(sphericalTensor::I) -{} - - -Foam::coordinateRotation::coordinateRotation -( - const vector& axis, - const vector& dir -) -: - tensor(sphericalTensor::I) -{ - calcTransform(axis, dir, e3e1); -} - - -Foam::coordinateRotation::coordinateRotation -( - const dictionary& dict -) -: - tensor(sphericalTensor::I) -{ - operator=(dict); -} - -// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // - -Foam::autoPtr Foam::coordinateRotation::New -( - const dictionary& dict -) -{ - if (debug) - { - Pout<< "coordinateRotation::New(const dictionary&) : " - << "constructing coordinateRotation" - << endl; - } - - // default type is self (alias: "axes") - word rotType(typeName_()); - dict.readIfPresent("type", rotType); - - // can (must) construct base class directly - if (rotType == typeName_() || rotType == "axes") - { - return autoPtr(new coordinateRotation(dict)); - } - - - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(rotType); - - if (cstrIter == dictionaryConstructorTablePtr_->end()) - { - FatalIOErrorIn - ( - "coordinateRotation::New(const dictionary&)", - dict - ) << "Unknown coordinateRotation type " - << rotType << nl << nl - << "Valid coordinateRotation types are :" << nl - << "[default: axes " << typeName_() << "]" - << dictionaryConstructorTablePtr_->sortedToc() - << exit(FatalIOError); - } - - return autoPtr(cstrIter()(dict)); + defineRunTimeSelectionTable(coordinateRotation, objectRegistry); } // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -void Foam::coordinateRotation::clear() +Foam::symmTensor Foam::coordinateRotation::transformPrincipal +( + const tensor& tt, + const vector& st +) const { - this->tensor::operator=(sphericalTensor::I); -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -void Foam::coordinateRotation::operator=(const dictionary& rhs) -{ - if (debug) - { - Pout<< "coordinateRotation::operator=(const dictionary&) : " - << "assign from " << rhs << endl; - } - - // allow as embedded sub-dictionary "coordinateRotation" - const dictionary& dict = + return symmTensor ( - rhs.found(typeName_()) - ? rhs.subDict(typeName_()) - : rhs + tt.xx()*st.x()*tt.xx() + + tt.xy()*st.y()*tt.xy() + + tt.xz()*st.z()*tt.xz(), + + tt.xx()*st.x()*tt.yx() + + tt.xy()*st.y()*tt.yy() + + tt.xz()*st.z()*tt.yz(), + + tt.xx()*st.x()*tt.zx() + + tt.xy()*st.y()*tt.zy() + + tt.xz()*st.z()*tt.zz(), + + tt.yx()*st.x()*tt.yx() + + tt.yy()*st.y()*tt.yy() + + tt.yz()*st.z()*tt.yz(), + + tt.yx()*st.x()*tt.zx() + + tt.yy()*st.y()*tt.zy() + + tt.yz()*st.z()*tt.zz(), + + tt.zx()*st.x()*tt.zx() + + tt.zy()*st.y()*tt.zy() + + tt.zz()*st.z()*tt.zz() ); - vector axis1, axis2; - axisOrder order(e3e1); - - if (dict.readIfPresent("e1", axis1) && dict.readIfPresent("e2", axis2)) - { - order = e1e2; - } - else if (dict.readIfPresent("e2", axis1) && dict.readIfPresent("e3", axis2)) - { - order = e2e3; - } - else if (dict.readIfPresent("e3", axis1) && dict.readIfPresent("e1", axis2)) - { - order = e3e1; - } - else if (dict.found("axis") || dict.found("direction")) - { - // let it bomb if only one of axis/direction is defined - order = e3e1; - dict.lookup("axis") >> axis1; - dict.lookup("direction") >> axis2; - } - else - { - // unspecified axes revert to the global system - tensor::operator=(sphericalTensor::I); - return; - } - - calcTransform(axis1, axis2, order); } - // ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H index 4c58e99c39..3cd8ea5276 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H @@ -25,46 +25,24 @@ Class Foam::coordinateRotation Description - A coordinate rotation specified per local axes and the base class for - other rotation specifications - - The rotation is defined by a combination of local vectors (e1/e2), (e2/e3) - or (e3/e1). Any nonorthogonality will be absorbed into the second vector. - - For convenience, the dictionary constructor forms allow a few shortcuts: - - if the \c type is not otherwise specified, the type \c axes - is implicit - - if an axes specification (eg, e3/e1) is used, the coordinateRotation - sub-dictionary can be dropped. - - Specifying the rotation by an EulerCoordinateRotation - (type "EulerRotation") or by a STARCDCoordinateRotation - (type "STARCDRotation") requires the coordinateRotation sub-dictionary. + Abstract base class for coordinate rotation \verbatim coordinateRotation { - type STARCDRotation - rotation (0 0 90); + type axesRotation + e1 (1 0 0); + e2 (0 1 0); } \endverbatim - - the rotation angles are in degrees, unless otherwise explictly specified: + Types of coordinateRotation: + 1) axesRotation + 2) STARCDRotation + 3) localAxesRotation + 4) EulerCoordinateRotation - \verbatim - coordinateRotation - { - type STARCDRotation - degrees false; - rotation (0 0 3.141592654); - } - \endverbatim -Deprecated - Specifying the local vectors as an \c axis (corresponding to e3) and a - \c direction (corresponding to e1), is allowed for backwards - compatibility, but this terminology is generally a bit confusing. - (deprecated Apr 2008) \*---------------------------------------------------------------------------*/ @@ -73,8 +51,10 @@ Deprecated #include "vector.H" #include "tensor.H" +#include "tensorField.H" #include "dictionary.H" #include "runTimeSelectionTables.H" +#include "objectRegistry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -86,72 +66,59 @@ namespace Foam \*---------------------------------------------------------------------------*/ class coordinateRotation -: - public tensor { - // Private data +protected: - //- the combination of local axes to be used - enum axisOrder - { - e1e2, - e2e3, - e3e1 - }; + // Protected member functions - // Private Member Functions + //- Transform principal + symmTensor transformPrincipal(const tensor&, const vector&) const; - //- Calculate transformation tensor - void calcTransform - ( - const vector& axis1, - const vector& axis2, - const axisOrder& order = e3e1 - ); public: + //- Runtime type information TypeName("coordinateRotation"); - // Constructors - - //- Construct null - coordinateRotation(); - - //- Construct from 2 axes - coordinateRotation - ( - const vector& axis, - const vector& dir - ); - - //- Construct from dictionary - coordinateRotation(const dictionary&); - - //- Return clone - autoPtr clone() const - { - return autoPtr(new coordinateRotation(*this)); - } // Declare run-time constructor selection table - - declareRunTimeSelectionTable + // for constructors with dictionary and objectRegistry + declareRunTimeSelectionTable + ( + autoPtr, + coordinateRotation, + objectRegistry, ( - autoPtr, - coordinateRotation, - dictionary, - ( - const dictionary& dict - ), - (dict) - ); + const dictionary& dict, const objectRegistry& obr + ), + (dict, obr) + ); + + + // Declare run-time constructor selection table + // for constructors with dictionary + declareRunTimeSelectionTable + ( + autoPtr, + coordinateRotation, + dictionary, + ( + const dictionary& dict + ), + (dict) + ); // Selectors - //- Select constructed from Istream + //- Select constructed from dictionary and objectRegistry + static autoPtr New + ( + const dictionary& dict, const objectRegistry& obr + ); + + //- Select constructed from dictionary static autoPtr New ( const dictionary& dict @@ -166,37 +133,76 @@ public: // Member Functions //- Reset rotation to an identity rotation - virtual void clear(); + virtual void clear() = 0; //- Return local-to-global transformation tensor - const tensor& R() const - { - return (*this); - } + virtual const tensor& R() const = 0; + + //- Return global-to-local transformation tensor + virtual const tensor& Rtr() const = 0; //- Return local Cartesian x-axis - const vector e1() const - { - return tensor::T().x(); - } + virtual const vector e1() const = 0; //- Return local Cartesian y-axis - const vector e2() const - { - return tensor::T().y(); - } + virtual const vector e2() const = 0; //- Return local Cartesian z-axis - const vector e3() const + virtual const vector e3() const = 0; + + //- Return local-to-global transformation tensor + virtual const tensorField& Tr() const = 0; + + //- Return true if the rotation tensor is uniform + virtual bool uniform() const { - return tensor::T().z(); + return true; } + //- Transform vectorField using transformation tensor field + virtual tmp transform(const vectorField& st) const = 0; - // Member Operators + //- Transform vector using transformation tensor + virtual vector transform(const vector& st) const = 0; - //- assign from dictionary - void operator=(const dictionary&); + //- Inverse transform vectorField using transformation tensor field + virtual tmp invTransform(const vectorField& st) const = 0; + + //- Inverse transform vector using transformation tensor + virtual vector invTransform(const vector& st) const = 0; + + //- Transform tensor field using transformation tensorField + virtual tmp transformTensor + ( + const tensorField& st + ) const = 0; + + //- Transform tensor sub-field using transformation tensorField + virtual tmp transformTensor + ( + const tensorField& st, + const labelList& cellMap + ) const = 0; + + //- Transform tensor using transformation tensorField + virtual tensor transformTensor(const tensor& st) const = 0; + + //- Transform vectorField using transformation tensorField and return + // symmetrical tensorField + virtual tmp transformVector + ( + const vectorField& st + ) const = 0; + + //- Transform vector using transformation tensor and return + // symmetrical tensor + virtual symmTensor transformVector(const vector& st) const = 0; + + + // Write + + //- Write + virtual void write(Ostream&) const = 0; }; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C new file mode 100644 index 0000000000..c30c5cb36e --- /dev/null +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "coordinateRotation.H" +#include "objectRegistry.H" + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::coordinateRotation::New +( + const dictionary& dict, const objectRegistry& obr +) +{ + if (debug) + { + Pout<< "coordinateRotation::New(const dictionary&) : " + << "constructing coordinateRotation" + << endl; + } + + word rotType = dict.lookup("type"); + + objectRegistryConstructorTable::iterator cstrIter = + objectRegistryConstructorTablePtr_->find(rotType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "coordinateRotation::New" + "(" + " const dictionary&, " + " const objectRegistry& " + ")", + dict + ) << "Unknown coordinateRotation type " + << rotType << nl << nl + << "Valid coordinateRotation types are :" << nl + << "[default: axes ]" + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalIOError); + } + + return autoPtr(cstrIter()(dict, obr)); +} + + +Foam::autoPtr Foam::coordinateRotation::New +( + const dictionary& dict +) +{ + if (debug) + { + Pout<< "coordinateRotation::New(const dictionary&) : " + << "constructing coordinateRotation" + << endl; + } + + word rotType = dict.lookup("type"); + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(rotType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "coordinateRotation::New" + "(" + " const dictionary&, " + ")", + dict + ) << "Unknown coordinateRotation type " + << rotType << nl << nl + << "Valid coordinateRotation types are :" << nl + << "[default: axes ]" + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalIOError); + } + + return autoPtr(cstrIter()(dict)); +} + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/localAxesRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/localAxesRotation.C new file mode 100644 index 0000000000..0c78cc9043 --- /dev/null +++ b/src/meshTools/coordinateSystems/coordinateRotation/localAxesRotation.C @@ -0,0 +1,282 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "localAxesRotation.H" +#include "axesRotation.H" +#include "addToRunTimeSelectionTable.H" +#include "polyMesh.H" +#include "tensorIOField.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(localAxesRotation, 0); + addToRunTimeSelectionTable + ( + coordinateRotation, + localAxesRotation, + dictionary + ); + addToRunTimeSelectionTable + ( + coordinateRotation, + localAxesRotation, + objectRegistry + ); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::localAxesRotation::localAxesRotation +( + const dictionary& dict, const objectRegistry& orb +) +: + Rptr_(), + origin_(point::zero), + e3_(vector::zero) +{ + // If origin is specified in the coordinateSystem + if (dict.parent().found("origin")) + { + dict.parent().lookup("origin") >> origin_; + } + + // rotation axis + dict.lookup("e3") >> e3_; + + const polyMesh& mesh = refCast(orb); + + Rptr_.reset + ( + new tensorField(mesh.nCells()) + ); + init(dict, orb); +} + + +Foam::localAxesRotation::localAxesRotation +( + const dictionary& dict +) +: + Rptr_(), + origin_(), + e3_() +{ + FatalErrorIn + ( + "localAxesRotation(const dictionary&)" + ) << " localAxesRotation can not be contructed from dictionary " + << " use the construtctor : " + "(" + " const dictionary& dict, const objectRegistry& orb" + ")" + << exit(FatalIOError); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::localAxesRotation::clear() +{ + if (!Rptr_.empty()) + { + Rptr_.clear(); + } +} + + +Foam::vector Foam::localAxesRotation::transform(const vector& st) const +{ + notImplemented + ( + "vector Foam::localAxesRotation:: " + "transform(const vector& st) const" + ); + return vector(vector::zero); +} + + +Foam::vector Foam::localAxesRotation::invTransform(const vector& st) const +{ + notImplemented + ( + "vector Foam::localAxesRotation:: " + "transform(const vector& st) const" + ); + return vector(vector::zero); +} + + +Foam::tmp Foam::localAxesRotation::transform +( + const vectorField& st +) const +{ + if (Rptr_->size() != st.size()) + { + FatalErrorIn + ( + "localAxesRotation::transform(const vectorField& st) " + ) << "vectorField st has different size to tensorField " + << abort(FatalError); + } + + return (Rptr_() & st); +} + + +Foam::tmp Foam::localAxesRotation::invTransform +( + const vectorField& st +) const +{ + return (Rptr_().T() & st); +} + + +Foam::tmp Foam::localAxesRotation::transformTensor +( + const tensorField& st +) const +{ + if (Rptr_->size() != st.size()) + { + FatalErrorIn + ( + "localAxesRotation::transformTensor(const tensorField& st) " + ) << "tensorField st has different size to tensorField Tr" + << abort(FatalError); + } + return (Rptr_() & st & Rptr_().T()); +} + + +Foam::tensor Foam::localAxesRotation::transformTensor +( + const tensor& st +) const +{ + notImplemented + ( + "tensor localAxesRotation::transformTensor() const" + ); + return tensor(tensor::zero); +} + + +Foam::tmp Foam::localAxesRotation::transformTensor +( + const tensorField& st, + const labelList& cellMap +) const +{ + if (cellMap.size() != st.size()) + { + FatalErrorIn + ( + "localAxesRotation::transformTensor(const tensorField& st) " + ) << "tensorField st has different size to tensorField Tr" + << abort(FatalError); + } + + const tensorField Rtr = Rptr_().T(); + tmp tt(new tensorField(cellMap.size())); + tensorField& t = tt(); + forAll (cellMap, i) + { + const label cellI = cellMap[i]; + t[i] = Rptr_()[cellI] & st[i] & Rtr[cellI]; + } + return tt; +} + + +Foam::tmp Foam::localAxesRotation::transformVector +( + const vectorField& st +) const +{ + if (Rptr_->size() != st.size()) + { + FatalErrorIn + ( + "localAxesRotation::transformVector(const vectorField& st) " + ) << "tensorField st has different size to tensorField Tr" + << abort(FatalError); + } + + tmp tfld(new symmTensorField(Rptr_->size())); + symmTensorField& fld = tfld(); + + forAll(fld, i) + { + fld[i] = transformPrincipal(Rptr_()[i], st[i]); + } + return tfld; +} + + +Foam::symmTensor Foam::localAxesRotation::transformVector +( + const vector& st +) const +{ + notImplemented + ( + "tensor localAxesRotation::transformVector(const vector&) const" + ); + return symmTensor(symmTensor::zero); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void Foam::localAxesRotation::init +( + const dictionary& dict, + const objectRegistry& obr +) +{ + const polyMesh& mesh = refCast(obr); + forAll(mesh.cellCentres(), cellI) + { + vector dir = mesh.cellCentres()[cellI] - origin_; + dir /= mag(dir); + + Rptr_()[cellI] = axesRotation(e3_, dir).R(); + } +} + + +void Foam::localAxesRotation::write(Ostream& os) const +{ + os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; +} + + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/localAxesRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/localAxesRotation.H new file mode 100644 index 0000000000..7e669bb514 --- /dev/null +++ b/src/meshTools/coordinateSystems/coordinateRotation/localAxesRotation.H @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::localAxesRotation + +Description + A local coordinate rotation. + Each rotational tensor is defined with two vectors (dir and e3) + where dir = cellC - origin and e3 is the rotation axis. + Per each cell an axesRotation type of rotation is created + + \verbatim + localAxesRotation + { + type localAxes; + e3 (0 0 1); + } + \endverbatim + +\*---------------------------------------------------------------------------*/ + +#ifndef localAxesRotation_H +#define localAxesRotation_H + +#include "point.H" +#include "vector.H" +#include "coordinateRotation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class localAxesRotation Declaration +\*---------------------------------------------------------------------------*/ + +class localAxesRotation +: + public coordinateRotation +{ + // Private data + + //- AutoPtr to transformation tensor + autoPtr Rptr_; + + //- Origin of the coordinate system + point origin_; + + //- Rotation axis + vector e3_; + + + // Private members + + //- Init transformation tensor + void init(const dictionary& dict, const objectRegistry& obr); + + +public: + + //- Runtime type information + TypeName("localAxesRotation"); + + // Constructors + + //- Construct from dictionary and objectRegistry + localAxesRotation(const dictionary&, const objectRegistry&); + + //- Construct from dictionary + localAxesRotation(const dictionary&); + + //- Return clone + autoPtr clone() const + { + return autoPtr(new localAxesRotation(*this)); + } + + + //- Destructor + virtual ~localAxesRotation() + {} + + + // Member Functions + + //- Reset rotation to an identity rotation + virtual void clear(); + + //- Return local-to-global transformation tensor + virtual const tensor& R() const + { + notImplemented("const tensor& localAxesRotation::R() const"); + return tensor::zero; + } + + //- Return global-to-local transformation tensor + virtual const tensor& Rtr() const + { + notImplemented("const tensor& localAxesRotation::Rtr() const"); + return tensor::zero; + } + + //- Return local Cartesian x-axis + virtual const vector e1() const + { + notImplemented("const tensor& localAxesRotation::e1() const"); + return vector::zero; + } + + //- Return local Cartesian y-axis + virtual const vector e2() const + { + notImplemented("const tensor& localAxesRotation::e2() const"); + return vector::zero; + } + + //- Return local Cartesian z-axis + virtual const vector e3() const + { + return e3_; + } + + virtual const tensorField& Tr() const + { + return Rptr_(); + } + + //- Transform vectorField using transformation tensor field + virtual tmp transform(const vectorField& st) const; + + //- Transform vector using transformation tensor + virtual vector transform(const vector& st) const; + + //- Inverse transform vectorField using transformation tensor field + virtual tmp invTransform(const vectorField& st) const; + + //- Inverse transform vector using transformation tensor + virtual vector invTransform(const vector& st) const; + + //- Return if the rotation is uniform + virtual bool uniform() const + { + return false; + } + + //- Transform tensor field using transformation tensorField + virtual tmp transformTensor(const tensorField& st) const; + + //- Transform tensor using transformation tensorField + virtual tensor transformTensor(const tensor& st) const; + + //- Transform tensor sub-field using transformation tensorField + virtual tmp transformTensor + ( + const tensorField& st, + const labelList& cellMap + ) const; + + //- Transform vectorField using transformation tensorField and return + // symmetrical tensorField + virtual tmp transformVector + ( + const vectorField& st + ) const; + + //- Transform vector using transformation tensor and return + // symmetrical tensor (R & st & R.T()) + virtual symmTensor transformVector(const vector& st) const; + + + // Write + + //- Write + virtual void write(Ostream&) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateSystem.C b/src/meshTools/coordinateSystems/coordinateSystem.C index a9153daa85..8537ec45e0 100644 --- a/src/meshTools/coordinateSystems/coordinateSystem.C +++ b/src/meshTools/coordinateSystems/coordinateSystem.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "IOstream.H" +#include "axesRotation.H" #include "coordinateSystem.H" #include "coordinateSystems.H" #include "addToRunTimeSelectionTable.H" @@ -34,18 +35,16 @@ namespace Foam { defineTypeNameAndDebug(coordinateSystem, 0); defineRunTimeSelectionTable(coordinateSystem, dictionary); - defineRunTimeSelectionTable(coordinateSystem, origRotation); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::coordinateSystem::coordinateSystem() : - name_(type()), + name_(), note_(), origin_(point::zero), - R_(), - Rtr_(sphericalTensor::I) + R_(new axesRotation(sphericalTensor::I)) {} @@ -58,8 +57,7 @@ Foam::coordinateSystem::coordinateSystem name_(name), note_(), origin_(cs.origin_), - R_(cs.R_), - Rtr_(R_.T()) + R_(const_cast(&cs.R())) {} @@ -73,8 +71,7 @@ Foam::coordinateSystem::coordinateSystem name_(name), note_(), origin_(origin), - R_(cr), - Rtr_(R_.T()) + R_(const_cast(&cr)) {} @@ -89,8 +86,7 @@ Foam::coordinateSystem::coordinateSystem name_(name), note_(), origin_(origin), - R_(axis, dirn), - Rtr_(R_.T()) + R_(new axesRotation(axis, dirn)) {} @@ -103,37 +99,35 @@ Foam::coordinateSystem::coordinateSystem name_(name), note_(), origin_(point::zero), - R_(), - Rtr_(sphericalTensor::I) + R_() { - operator=(dict); + init(dict); } Foam::coordinateSystem::coordinateSystem(const dictionary& dict) : - name_(type()), + name_(), note_(), origin_(point::zero), - R_(), - Rtr_(sphericalTensor::I) + R_() { - operator=(dict); + init(dict); } Foam::coordinateSystem::coordinateSystem ( - const dictionary& dict, - const objectRegistry& obr + const objectRegistry& obr, + const dictionary& dict ) : - name_(type()), + name_(), note_(), origin_(point::zero), - R_(), - Rtr_(sphericalTensor::I) + R_() { + const entry* entryPtr = dict.lookupEntryPtr(typeName_(), false, false); // non-dictionary entry is a lookup into global coordinateSystems @@ -170,7 +164,7 @@ Foam::coordinateSystem::coordinateSystem } else { - operator=(dict); + init(dict, obr); } } @@ -180,11 +174,10 @@ Foam::coordinateSystem::coordinateSystem(Istream& is) name_(is), note_(), origin_(point::zero), - R_(), - Rtr_(sphericalTensor::I) + R_() { dictionary dict(is); - operator=(dict); + init(dict); } @@ -215,8 +208,8 @@ Foam::dictionary Foam::coordinateSystem::dict(bool ignoreType) const } dict.add("origin", origin_); - dict.add("e1", e1()); - dict.add("e3", e3()); + dict.add("e1", R_->e1()); + dict.add("e3", R_->e3()); return dict; } @@ -230,11 +223,11 @@ Foam::vector Foam::coordinateSystem::localToGlobal { if (translate) { - return (R_ & local) + origin_; + return (R_->transform(local)) + origin_; } else { - return (R_ & local); + return R_->transform(local); } } @@ -247,11 +240,11 @@ Foam::tmp Foam::coordinateSystem::localToGlobal { if (translate) { - return (R_ & local) + origin_; + return (R_->transform(local)) + origin_; } else { - return (R_ & local); + return R_->transform(local); } } @@ -264,11 +257,11 @@ Foam::vector Foam::coordinateSystem::globalToLocal { if (translate) { - return (Rtr_ & (global - origin_)); + return R_->invTransform(global - origin_); } else { - return (Rtr_ & global); + return R_->invTransform(global); } } @@ -281,11 +274,11 @@ Foam::tmp Foam::coordinateSystem::globalToLocal { if (translate) { - return (Rtr_ & (global - origin_)); + return R_->invTransform(global - origin_); } else { - return (Rtr_ & global); + return R_->invTransform(global); } } @@ -294,15 +287,14 @@ void Foam::coordinateSystem::clear() { note_.clear(); origin_ = point::zero; - R_.clear(); - Rtr_ = sphericalTensor::I; + R_->clear(); } void Foam::coordinateSystem::write(Ostream& os) const { - os << type() - << " origin: " << origin() << " e1: " << e1() << " e3: " << e3(); + os << type() << " origin: " << origin() << nl; + R_->write(os); } @@ -314,11 +306,8 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const << indent << token::BEGIN_BLOCK << incrIndent << nl; } - // only write type for derived types - if (type() != typeName_()) - { - os.writeKeyword("type") << type() << token::END_STATEMENT << nl; - } + os.writeKeyword("type") << type() << token::END_STATEMENT << nl; + // The note entry is optional if (note_.size()) @@ -327,8 +316,7 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const } os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; - os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; - os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; + R_->write(os); if (subDict) { @@ -339,7 +327,20 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -void Foam::coordinateSystem::operator=(const dictionary& rhs) +void Foam::coordinateSystem::init(const dictionary& rhs) +{ + rhs.lookup("origin") >> origin_; + note_.clear(); + rhs.readIfPresent("note", note_); + R_.reset(coordinateRotation::New(rhs.subDict("coordinateRotation")).ptr()); +} + + +void Foam::coordinateSystem::init +( + const dictionary& rhs, + const objectRegistry& obr +) { if (debug) { @@ -347,34 +348,16 @@ void Foam::coordinateSystem::operator=(const dictionary& rhs) << "assign from " << rhs << endl; } - // allow as embedded sub-dictionary "coordinateSystem" - const dictionary& dict = - ( - rhs.found(typeName_()) - ? rhs.subDict(typeName_()) - : rhs - ); - - // unspecified origin is (0 0 0) - origin_ = point::zero; - dict.readIfPresent("origin", origin_); + rhs.lookup("origin") >> origin_; // The note entry is optional note_.clear(); rhs.readIfPresent("note", note_); - // specify via coordinateRotation sub-dictionary - if (dict.found("coordinateRotation")) - { - R_ = coordinateRotation::New(dict.subDict("coordinateRotation"))(); - } - else - { - // let coordinateRotation constructor extract the axes specification - R_ = coordinateRotation(dict); - } - - Rtr_ = R_.T(); + R_.reset + ( + coordinateRotation::New(rhs.subDict("coordinateRotation"), obr).ptr() + ); } @@ -382,7 +365,12 @@ void Foam::coordinateSystem::operator=(const dictionary& rhs) bool Foam::operator!=(const coordinateSystem& a, const coordinateSystem& b) { - return (a.origin() != b.origin() || a.R() != b.R() || a.type() != b.type()); + return + ( + a.origin() != b.origin() + || a.R().R() != b.R().R() + || a.type() != b.type() + ); } diff --git a/src/meshTools/coordinateSystems/coordinateSystem.H b/src/meshTools/coordinateSystems/coordinateSystem.H index 5170b494b4..f0e695b507 100644 --- a/src/meshTools/coordinateSystems/coordinateSystem.H +++ b/src/meshTools/coordinateSystems/coordinateSystem.H @@ -25,18 +25,15 @@ Class Foam::coordinateSystem Description - A cartesian coordinate system and the base class for other coordinate + Base class for other coordinate system specifications. All systems are defined by an origin point and a coordinateRotation. - For convenience, the dictionary constructor forms allow a few shortcuts: - - the default origin corresponds to (0 0 0) - - if the \c type is not otherwise specified, a Cartesian coordinateSystem - is implicit \verbatim - flipped + coordinateSystem { + type cartesian; origin (0 0 0); coordinateRotation { @@ -46,79 +43,18 @@ Description } \endverbatim - - if an axes specification (eg, e3/e1) is used, the coordinateRotation - sub-dictionary can be dropped. + Types of coordinateRotation: + 1) axesRotation + 2) STARCDRotation + 3) localAxesRotation + 4) EulerCoordinateRotation - \verbatim - flipped // the same, specified as axes - { - origin (0 0 0); - coordinateRotation - { - type axes; - e3 (1 0 0); - e1 (0 0 -1); - } - } - flipped // the same, using all the shortcuts - { - e3 (1 0 0); - e1 (0 0 -1); - } - \endverbatim - - - if a sub-dictionary coordinateSystem is found within the dictionary, it - will be used. This provides a convenient means of embedding - coordinateSystem information in another dictionary. - This is used, for example, in the porousZones: - - \verbatim - 1 - ( - cat1 - { - coordinateSystem - { - origin (0 0 0); - coordinateRotation - { - type STARCDRotation; - rotation (0 0 90); - } - } - porosity 0.781; - Darcy - { - d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08); - f f [0 -1 0 0 0] (-1000 -1000 12.83); - } - } - ) - \endverbatim - - - additionally, if the coordinateSystem points to a plain entry, - it can be used to reference one of the global coordinateSystems - - \verbatim - 1 - ( - cat1 - { - coordinateSystem system_10; - porosity 0.781; - Darcy - { - d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08); - f f [0 -1 0 0 0] (-1000 -1000 12.83); - } - } - ) - \endverbatim - For this to work correctly, the coordinateSystem constructor must be - supplied with both a dictionary and an objectRegistry. + Type of coordinates: + 1) cartesian + 2) cylindricalCS See Also - coordinateSystems and coordinateSystems::New + coordinateSystem and coordinateSystem::New SourceFiles coordinateSystem.C @@ -136,6 +72,7 @@ SourceFiles #include "tmp.H" #include "coordinateRotation.H" #include "objectRegistry.H" +#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -151,19 +88,16 @@ class coordinateSystem // Private data //- Name of coordinate system - mutable word name_; + word name_; //- Optional note - mutable string note_; + string note_; //- Origin - mutable point origin_; + point origin_; //- Local-to-Global transformation tensor - coordinateRotation R_; - - //- Global-to-Local transformation tensor - tensor Rtr_; + autoPtr R_; protected: @@ -194,6 +128,12 @@ protected: bool translate ) const; + //- Init from dict and obr + void init(const dictionary&); + + //- Init from dictionary + void init(const dictionary&, const objectRegistry&); + public: @@ -238,63 +178,47 @@ public: //- Construct from dictionary (default name) // With the ability to reference global coordinateSystems - coordinateSystem(const dictionary&, const objectRegistry&); + coordinateSystem(const objectRegistry&, const dictionary&); //- Construct from Istream // The Istream contains a word followed by a dictionary coordinateSystem(Istream&); - //- Return clone - autoPtr clone() const - { - return autoPtr(new coordinateSystem(*this)); - } + + //- Return clone + autoPtr clone() const + { + return autoPtr(new coordinateSystem(*this)); + } // Declare run-time constructor selection table - - declareRunTimeSelectionTable + declareRunTimeSelectionTable + ( + autoPtr, + coordinateSystem, + dictionary, ( - autoPtr, - coordinateSystem, - dictionary, - ( - const word& name, - const dictionary& dict - ), - (name, dict) - ); - - declareRunTimeSelectionTable - ( - autoPtr, - coordinateSystem, - origRotation, - ( - const word& name, - const point& origin, - const coordinateRotation& cr - ), - (name, origin, cr) - ); + const objectRegistry& obr, + const dictionary& dict + ), + (obr, dict) + ); // Selectors + //- Select constructed from dictionary and objectRegistry + static autoPtr New + ( + const objectRegistry& obr, + const dictionary& dict + ); + //- Select constructed from dictionary static autoPtr New ( - const word& name, - const dictionary& - ); - - //- Select constructed from origin and rotation - static autoPtr New - ( - const word& coordType, - const word& name, - const point& origin, - const coordinateRotation& + const dictionary& dict ); //- Select constructed from Istream @@ -307,6 +231,7 @@ public: // Member Functions + // Access //- Return name @@ -333,49 +258,18 @@ public: return origin_; } - //- Return coordinate rotation - const coordinateRotation& rotation() const + //- Return const reference to coordinate rotation + const coordinateRotation& R() const { - return R_; + return R_(); } - //- Return local-to-global transformation tensor - const tensor& R() const + //- Return non const reference to coordinate rotation + coordinateRotation& R() { - return R_; + return R_(); } - //- Return local Cartesian x-axis - const vector e1() const - { - return Rtr_.x(); - } - - //- Return local Cartesian y-axis - const vector e2() const - { - return Rtr_.y(); - } - - //- Return local Cartesian z-axis - const vector e3() const - { - return Rtr_.z(); - } - - //- Return axis (e3: local Cartesian z-axis) - // \deprecated method e3 is preferred (deprecated Apr 2008) - const vector axis() const - { - return Rtr_.z(); - } - - //- Return direction (e1: local Cartesian x-axis) - // \deprecated method e1 is preferred (deprecated Apr 2008) - const vector direction() const - { - return Rtr_.x(); - } //- Return as dictionary of entries // \param [in] ignoreType drop type (cartesian, cylindrical, etc) @@ -386,7 +280,7 @@ public: // Edit //- Rename - virtual void rename(const word& newName) + void rename(const word& newName) { name_ = newName; } @@ -408,7 +302,7 @@ public: virtual void write(Ostream&) const; //- Write dictionary - virtual void writeDict(Ostream&, bool subDict=true) const; + void writeDict(Ostream&, bool subDict=true) const; // Transformations @@ -472,22 +366,18 @@ public: // Member Operators - //- assign from dictionary - void operator=(const dictionary&); + // friend Operators + + friend bool operator!= + ( + const coordinateSystem&, + const coordinateSystem& + ); - // friend Operators + // IOstream Operators - friend bool operator!= - ( - const coordinateSystem&, - const coordinateSystem& - ); - - - // IOstream Operators - - friend Ostream& operator<<(Ostream&, const coordinateSystem&); + friend Ostream& operator<<(Ostream&, const coordinateSystem&); }; diff --git a/src/meshTools/coordinateSystems/coordinateSystemNew.C b/src/meshTools/coordinateSystems/coordinateSystemNew.C index 60c4e8482d..da5bc06958 100644 --- a/src/meshTools/coordinateSystems/coordinateSystemNew.C +++ b/src/meshTools/coordinateSystems/coordinateSystemNew.C @@ -30,7 +30,7 @@ License Foam::autoPtr Foam::coordinateSystem::New ( - const word& name, + const objectRegistry& obr, const dictionary& dict ) { @@ -41,17 +41,8 @@ Foam::autoPtr Foam::coordinateSystem::New << endl; } - // construct base class directly, also allow 'cartesian' as an alias - word coordType(typeName_()); - if - ( - !dict.readIfPresent("type", coordType) - || coordType == typeName_() - || coordType == "cartesian" - ) - { - return autoPtr(new coordinateSystem(name, dict)); - } + const dictionary& coordDict = dict.subDict(typeName_()); + word coordType = coordDict.lookup("type"); dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTablePtr_->find(coordType); @@ -60,20 +51,54 @@ Foam::autoPtr Foam::coordinateSystem::New { FatalIOErrorIn ( - "coordinateSystem::New(const word&, const dictionary&)", + "coordinateSystem::New(const objectRegistry&, const dictionary&)", dict ) << "Unknown coordinateSystem type " << coordType << nl << nl << "Valid coordinateSystem types are :" << nl - << "[default: " << typeName_() << "]" << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalIOError); } - return autoPtr(cstrIter()(name, dict)); + return autoPtr(cstrIter()(obr, coordDict)); } +Foam::autoPtr Foam::coordinateSystem::New +( + const dictionary& dict +) +{ + if (debug) + { + Pout<< "coordinateSystem::New(cconst dictionary&) : " + << "constructing coordinateSystem" + << endl; + } + + const dictionary& coordDict = dict.subDict(typeName_()); + word coordType = coordDict.lookup("type"); +/* + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(coordType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "coordinateSystem::New(const dictionary&)", + dict + ) << "Unknown coordinateSystem type " + << coordType << nl << nl + << "Valid coordinateSystem types are :" << nl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalIOError); + } +*/ + return autoPtr(new coordinateSystem(coordDict)); +} + +/* Foam::autoPtr Foam::coordinateSystem::New ( const word& coordType, @@ -109,7 +134,7 @@ Foam::autoPtr Foam::coordinateSystem::New return autoPtr(cstrIter()(name, origin, cr)); } - +*/ Foam::autoPtr Foam::coordinateSystem::New ( @@ -119,7 +144,26 @@ Foam::autoPtr Foam::coordinateSystem::New const word name(is); const dictionary dict(is); - return New(name, dict); + word coordType = dict.lookup("type"); +/* + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(coordType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "coordinateSystem::New(Istream& is)", + dict + ) << "Unknown coordinateSystem type " + << coordType << nl << nl + << "Valid coordinateSystem types are :" << nl + << "[default: " << typeName_() << "]" + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalIOError); + } +*/ + return autoPtr(new coordinateSystem(name, dict)); } diff --git a/src/meshTools/coordinateSystems/coordinateSystems.H b/src/meshTools/coordinateSystems/coordinateSystems.H index c509eab4ed..8a0a489eb5 100644 --- a/src/meshTools/coordinateSystems/coordinateSystems.H +++ b/src/meshTools/coordinateSystems/coordinateSystems.H @@ -31,6 +31,25 @@ Note Mixing normal constructors and the coordinateSystems::New constructor may yield unexpected results. + \verbatim + 1 + ( + cat1 + { + coordinateSystem system_10; + porosity 0.781; + Darcy + { + d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08); + f f [0 -1 0 0 0] (-1000 -1000 12.83); + } + } + ) + \endverbatim + + For this to work correctly, the coordinateSystem constructor must be + supplied with both a dictionary and an objectRegistry. + SourceFiles coordinateSystems.C diff --git a/src/meshTools/coordinateSystems/cylindricalCS.C b/src/meshTools/coordinateSystems/cylindricalCS.C index a505504607..4be9deda7d 100644 --- a/src/meshTools/coordinateSystems/cylindricalCS.C +++ b/src/meshTools/coordinateSystems/cylindricalCS.C @@ -35,7 +35,6 @@ namespace Foam { defineTypeNameAndDebug(cylindricalCS, 0); addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, dictionary); - addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, origRotation); } @@ -109,6 +108,23 @@ Foam::cylindricalCS::cylindricalCS {} +Foam::cylindricalCS::cylindricalCS +( + const objectRegistry& obr, + const dictionary& dict +) +: + coordinateSystem(obr, dict), + inDegrees_(dict.lookupOrDefault("degrees", true)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cylindricalCS::~cylindricalCS() +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::cylindricalCS::inDegrees() const diff --git a/src/meshTools/coordinateSystems/cylindricalCS.H b/src/meshTools/coordinateSystems/cylindricalCS.H index 0cc70efcb5..e03d1feac8 100644 --- a/src/meshTools/coordinateSystems/cylindricalCS.H +++ b/src/meshTools/coordinateSystems/cylindricalCS.H @@ -61,6 +61,7 @@ protected: // Protected Member Functions + //- Convert from local coordinate system to the global Cartesian system // with optional translation for the origin virtual vector localToGlobal(const vector&, bool translate) const; @@ -131,8 +132,15 @@ public: const bool inDegrees=true ); - //- Construct from dictionary - cylindricalCS(const word& name, const dictionary&); + //- Construct from dictionary and name + cylindricalCS(const word&, const dictionary&); + + //- Construct from dictionary and objectRegistry + cylindricalCS(const objectRegistry&, const dictionary&); + + + //- Destructor + virtual ~cylindricalCS(); // Member Functions diff --git a/src/meshTools/coordinateSystems/parabolicCylindricalCS.C b/src/meshTools/coordinateSystems/parabolicCylindricalCS.C deleted file mode 100644 index bf202bd39d..0000000000 --- a/src/meshTools/coordinateSystems/parabolicCylindricalCS.C +++ /dev/null @@ -1,177 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "parabolicCylindricalCS.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(parabolicCylindricalCS, 0); - addToRunTimeSelectionTable - ( - coordinateSystem, - parabolicCylindricalCS, - dictionary - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::parabolicCylindricalCS::parabolicCylindricalCS() -: - coordinateSystem() -{} - - -Foam::parabolicCylindricalCS::parabolicCylindricalCS -( - const word& name, - const point& origin, - const coordinateRotation& cr -) -: - coordinateSystem(name, origin, cr) -{} - - -Foam::parabolicCylindricalCS::parabolicCylindricalCS -( - const word& name, - const dictionary& dict -) -: - coordinateSystem(name, dict) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::vector Foam::parabolicCylindricalCS::localToGlobal -( - const vector& local, - bool translate -) const -{ - // Notation: u = local.x() v = local.y() z = local.z(); - if (local.y() < 0.0) - { - FatalErrorIn - ( - "parabolicCylindricalCS::localToGlobal(const vector&, bool) const" - ) - << "parabolic cylindrical coordinates v < 0" - << abort(FatalError); - } - - return coordinateSystem::localToGlobal - ( - vector - ( - 0.5*(sqr(local.x()) - sqr(local.y())), - local.x()*local.y(), - local.z() - ), - translate - ); -} - - -Foam::tmp Foam::parabolicCylindricalCS::localToGlobal -( - const vectorField& local, - bool translate -) const -{ - if (min(local.component(vector::Y)) < 0.0) - { - FatalErrorIn - ( - "parabolicCylindricalCS::localToGlobal" - "(const vectorField&, bool) const" - ) << "parabolic cylindrical coordinates v < 0" - << abort(FatalError); - } - - vectorField lc(local.size()); - lc.replace - ( - vector::X, - 0.5* - ( - sqr(local.component(vector::X)) - - sqr(local.component(vector::Y)) - ) - ); - - lc.replace - ( - vector::Y, - local.component(vector::X) * local.component(vector::Y) - ); - - lc.replace - ( - vector::Z, - local.component(vector::Z) - ); - - return coordinateSystem::localToGlobal(lc, translate); -} - - -Foam::vector Foam::parabolicCylindricalCS::globalToLocal -( - const vector& global, - bool translate -) const -{ - notImplemented - ( - "parabolicCylindricalCS::globalToLocal(const vector&, bool) const" - ); - - return vector::zero; -} - - -Foam::tmp Foam::parabolicCylindricalCS::globalToLocal -( - const vectorField& global, - bool translate -) const -{ - notImplemented - ( - "parabolicCylindricalCS::globalToLocal(const vectorField&, bool) const" - ); - - return tmp(vectorField::null()); -} - - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/parabolicCylindricalCS.H b/src/meshTools/coordinateSystems/parabolicCylindricalCS.H deleted file mode 100644 index 9f09e9c2f4..0000000000 --- a/src/meshTools/coordinateSystems/parabolicCylindricalCS.H +++ /dev/null @@ -1,120 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::parabolicCylindricalCS - -Description - Parabolic cylindrical coordinate system. - - Notation: u = a.x() v = a.y() z = a.z(); - -Note - The maintenance of this class may lag that of the main types. - -SourceFiles - parabolicCylindricalCS.C - -\*---------------------------------------------------------------------------*/ - -#ifndef parabolicCylindricalCS_H -#define parabolicCylindricalCS_H - -#include "coordinateSystem.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class parabolicCylindricalCS Declaration -\*---------------------------------------------------------------------------*/ - -class parabolicCylindricalCS -: - public coordinateSystem -{ - -protected: - - // Protected Member Functions - - //- Convert from local coordinate system to the global Cartesian system - // with optional translation for the origin - virtual vector localToGlobal(const vector&, bool translate) const; - - //- Convert from local coordinate system to the global Cartesian system - // with optional translation for the origin - virtual tmp localToGlobal - ( - const vectorField&, - bool translate - ) const; - - //- Convert from global Cartesian system to the local coordinate system - // with optional translation for the origin - virtual vector globalToLocal(const vector&, bool translate) const; - - //- Convert from global Cartesian system to the local coordinate system - // with optional translation for the origin - virtual tmp globalToLocal - ( - const vectorField&, - bool translate - ) const; - - -public: - - //- Runtime type information - TypeName("parabolicCylindrical"); - - - // Constructors - - //- Construct null - parabolicCylindricalCS(); - - //- Construct from origin and rotation - parabolicCylindricalCS - ( - const word& name, - const point& origin, - const coordinateRotation& - ); - - //- Construct from dictionary - parabolicCylindricalCS(const word&, const dictionary&); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/sphericalCS.C b/src/meshTools/coordinateSystems/sphericalCS.C deleted file mode 100644 index f28c87c8c1..0000000000 --- a/src/meshTools/coordinateSystems/sphericalCS.C +++ /dev/null @@ -1,244 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "sphericalCS.H" - -#include "one.H" -#include "mathematicalConstants.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(sphericalCS, 0); - addToRunTimeSelectionTable(coordinateSystem, sphericalCS, dictionary); - addToRunTimeSelectionTable(coordinateSystem, sphericalCS, origRotation); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::sphericalCS::sphericalCS(const bool inDegrees) -: - coordinateSystem(), - inDegrees_(inDegrees) -{} - - -Foam::sphericalCS::sphericalCS -( - const coordinateSystem& cs, - const bool inDegrees -) -: - coordinateSystem(cs), - inDegrees_(inDegrees) -{} - - -Foam::sphericalCS::sphericalCS -( - const word& name, - const coordinateSystem& cs, - const bool inDegrees -) -: - coordinateSystem(name, cs), - inDegrees_(inDegrees) -{} - - -Foam::sphericalCS::sphericalCS -( - const word& name, - const point& origin, - const coordinateRotation& cr, - const bool inDegrees -) -: - coordinateSystem(name, origin, cr), - inDegrees_(inDegrees) -{} - - -Foam::sphericalCS::sphericalCS -( - const word& name, - const point& origin, - const vector& axis, - const vector& dirn, - const bool inDegrees -) -: - coordinateSystem(name, origin, axis, dirn), - inDegrees_(inDegrees) -{} - - -Foam::sphericalCS::sphericalCS -( - const word& name, - const dictionary& dict -) -: - coordinateSystem(name, dict), - inDegrees_(dict.lookupOrDefault("degrees", true)) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::sphericalCS::inDegrees() const -{ - return inDegrees_; -} - - -bool& Foam::sphericalCS::inDegrees() -{ - return inDegrees_; -} - - -Foam::vector Foam::sphericalCS::localToGlobal -( - const vector& local, - bool translate -) const -{ - scalar r = local.x(); - const scalar theta - ( - local.y() - *(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0) - ); - const scalar phi - ( - local.z() - *(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0) - ); - - return coordinateSystem::localToGlobal - ( - vector(r*cos(theta)*sin(phi), r*sin(theta)*sin(phi), r*cos(phi)), - translate - ); -} - - -Foam::tmp Foam::sphericalCS::localToGlobal -( - const vectorField& local, - bool translate -) const -{ - const scalarField r(local.component(vector::X)); - const scalarField theta - ( - local.component(vector::Y) - *(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0) - ); - const scalarField phi - ( - local.component(vector::Z) - *(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0) - ); - - vectorField lc(local.size()); - lc.replace(vector::X, r*cos(theta)*sin(phi)); - lc.replace(vector::Y, r*sin(theta)*sin(phi)); - lc.replace(vector::Z, r*cos(phi)); - - return coordinateSystem::localToGlobal(lc, translate); -} - - -Foam::vector Foam::sphericalCS::globalToLocal -( - const vector& global, - bool translate -) const -{ - const vector lc = coordinateSystem::globalToLocal(global, translate); - const scalar r = mag(lc); - - return vector - ( - r, - atan2 - ( - lc.y(), lc.x() - )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0), - acos - ( - lc.z()/(r + SMALL) - )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0) - ); -} - - -Foam::tmp Foam::sphericalCS::globalToLocal -( - const vectorField& global, - bool translate -) const -{ - const vectorField lc(coordinateSystem::globalToLocal(global, translate)); - const scalarField r(mag(lc)); - - tmp tresult(new vectorField(lc.size())); - vectorField& result = tresult(); - - result.replace - ( - vector::X, r - - ); - - result.replace - ( - vector::Y, - atan2 - ( - lc.component(vector::Y), - lc.component(vector::X) - )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0) - ); - - result.replace - ( - vector::Z, - acos - ( - lc.component(vector::Z)/(r + SMALL) - )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0) - ); - - return tresult; -} - - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/toroidalCS.C b/src/meshTools/coordinateSystems/toroidalCS.C deleted file mode 100644 index d221b5e93c..0000000000 --- a/src/meshTools/coordinateSystems/toroidalCS.C +++ /dev/null @@ -1,184 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "toroidalCS.H" -#include "addToRunTimeSelectionTable.H" -#include "unitConversion.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(toroidalCS, 0); - addToRunTimeSelectionTable(coordinateSystem, toroidalCS, dictionary); -} - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - - -Foam::toroidalCS::toroidalCS -( - const word& name, - const point& origin, - const coordinateRotation& cr, - const scalar radius -) -: - coordinateSystem(name, origin, cr), - radius_(radius) -{} - - -Foam::toroidalCS::toroidalCS -( - const word& name, - const dictionary& dict -) -: - coordinateSystem(name, dict), - radius_(readScalar(dict.lookup("radius"))) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::vector Foam::toroidalCS::localToGlobal -( - const vector& local, - bool translate -) const -{ - // Notation: r = local.x() - scalar theta = degToRad(local.y()); - scalar phi = degToRad(local.z()); - - scalar rprime = radius_ + local.x()*sin(phi); - - if ((local.x()*sin(phi)) > (radius_)) - { - FatalErrorIn("toroidalCS::toGlobal(vector) const") - << "Badly defined toroidal coordinates" - << abort(FatalError); - } - - return coordinateSystem::localToGlobal - ( - vector(rprime*cos(theta), rprime*sin(theta), local.x()*cos(phi)), - translate - ); -} - - -Foam::tmp Foam::toroidalCS::localToGlobal -( - const vectorField& local, - bool translate -) const -{ - const scalarField r - ( - local.component(vector::X) - ); - - const scalarField theta - ( - local.component(vector::Y)*constant::mathematical::pi/180.0 - ); - - const scalarField phi - ( - local.component(vector::Z)*constant::mathematical::pi/180.0 - ); - - const scalarField rprime - ( - radius_ + r*sin(phi) - ); - - vectorField lc(local.size()); - lc.replace(vector::X, rprime*cos(theta)); - lc.replace(vector::Y, rprime*sin(theta)); - lc.replace(vector::Z, r*cos(phi)); - - return coordinateSystem::localToGlobal(lc, translate); -} - - -Foam::vector Foam::toroidalCS::globalToLocal -( - const vector& global, - bool translate -) const -{ - notImplemented - ( - "toroidalCS::globalToLocal(const vector&, bool) const" - ); - - return vector::zero; -} - - -Foam::tmp Foam::toroidalCS::globalToLocal -( - const vectorField& global, - bool translate -) const -{ - notImplemented - ( - "toroidalCS::globalToLocal(const vectorField&, bool) const" - ); - - return tmp(vectorField::null()); -} - - -void Foam::toroidalCS::write(Ostream& os) const -{ - coordinateSystem::write(os); - os << "radius: " << radius() << endl; -} - - -void Foam::toroidalCS::writeDict(Ostream& os, bool subDict) const -{ - if (subDict) - { - os << indent << name() << nl - << indent << token::BEGIN_BLOCK << incrIndent << nl; - } - - coordinateSystem::writeDict(os, false); - os.writeKeyword("radius") << radius() << token::END_STATEMENT << nl; - - if (subDict) - { - os << decrIndent << indent << token::END_BLOCK << endl; - } -} - - -// ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/toroidalCS.H b/src/meshTools/coordinateSystems/toroidalCS.H deleted file mode 100644 index fef6ea6303..0000000000 --- a/src/meshTools/coordinateSystems/toroidalCS.H +++ /dev/null @@ -1,133 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::toroidalCS - -Description - Toroidal coordinate system, always in degrees - -Note - The maintenance of this class may lag that of the main types. - -SourceFiles - toroidalCS.C - -\*---------------------------------------------------------------------------*/ - -#ifndef toroidalCS_H -#define toroidalCS_H - -#include "coordinateSystem.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class toroidalCS Declaration -\*---------------------------------------------------------------------------*/ - -class toroidalCS -: - public coordinateSystem -{ - // Private data - - //- Radius of the torus - scalar radius_; - - // Private Member Functions - - //- Convert from local coordinate system to the global Cartesian system - // with optional translation for the origin - virtual vector localToGlobal(const vector&, bool translate) const; - - //- Convert from local coordinate system to the global Cartesian system - // with optional translation for the origin - virtual tmp localToGlobal - ( - const vectorField&, - bool translate - ) const; - - //- Convert from global Cartesian system to the local coordinate system - // with optional translation for the origin - virtual vector globalToLocal(const vector&, bool translate) const; - - //- Convert from global Cartesian system to the local coordinate system - // with optional translation for the origin - virtual tmp globalToLocal - ( - const vectorField&, - bool translate - ) const; - - -public: - - //- Runtime type information - TypeName("toroidal"); - - - // Constructors - - //- Construct from origin, rotation and radius - toroidalCS - ( - const word& name, - const point& origin, - const coordinateRotation&, - const scalar radius - ); - - //- Construct from dictionary - toroidalCS(const word& name, const dictionary&); - - - // Member Functions - - //- Return radius - scalar radius() const - { - return radius_; - } - - //- Write - virtual void write(Ostream&) const; - - //- Write dictionary - virtual void writeDict(Ostream&, bool subDict=true) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/meshTools/searchableSurface/searchableSurfaceCollection.C b/src/meshTools/searchableSurface/searchableSurfaceCollection.C index 1aa9cbc123..ba703155a0 100644 --- a/src/meshTools/searchableSurface/searchableSurfaceCollection.C +++ b/src/meshTools/searchableSurface/searchableSurfaceCollection.C @@ -203,7 +203,6 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection surfI, coordinateSystem::New ( - "", subDict.subDict("transform") ) ); diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C index 250e3c34dc..a4587f26b1 100644 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C @@ -48,7 +48,7 @@ Foam::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform obr_(obr), active_(true), fieldSet_(), - coordSys_(dict, obr) + coordSys_(obr, dict) { // Check if the available mesh is an fvMesh otherise deactivate if (!isA(obr_)) diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C index c1ecc72707..00d21a95f6 100644 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C @@ -39,7 +39,7 @@ void Foam::fieldCoordinateSystemTransform::transformField { const word& fieldName = field.name() + "Transformed"; - dimensionedTensor R("R", field.dimensions(), coordSys_.R()); + dimensionedTensor R("R", field.dimensions(), coordSys_.R().R()); if (obr_.foundObject(fieldName)) { diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 27310c7a80..a381a41115 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -444,7 +444,7 @@ void Foam::forces::read(const dictionary& dict) // specified directly, from coordinate system, or implicitly (0 0 0) if (!dict.readIfPresent("CofR", coordSys_.origin())) { - coordSys_ = coordinateSystem(dict, obr_); + coordSys_ = coordinateSystem(obr_, dict); localSystem_ = true; } diff --git a/src/sampling/sampledSet/array/arraySet.C b/src/sampling/sampledSet/array/arraySet.C index fb97a93bfe..580b718963 100644 --- a/src/sampling/sampledSet/array/arraySet.C +++ b/src/sampling/sampledSet/array/arraySet.C @@ -83,7 +83,7 @@ void Foam::arraySet::calcSamples forAll(sampleCoords, i) { - sampleCoords[i] = transform(coordSys_.R(), sampleCoords[i]); + sampleCoords[i] = transform(coordSys_.R().R(), sampleCoords[i]); } forAll(sampleCoords, sampleI) diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C index 3622dcb585..3f035ee845 100644 --- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C +++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C @@ -77,7 +77,7 @@ Foam::sampledPlane::sampledPlane // allow lookup from global coordinate systems if (dict.found("coordinateSystem")) { - coordinateSystem cs(dict, mesh); + coordinateSystem cs(mesh, dict); point base = cs.globalPosition(planeDesc().refPoint()); vector norm = cs.globalVector(planeDesc().normal()); From 52eb4f89240fa1a3ab51d900529da89105469cf3 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 21 Jan 2013 12:26:32 +0000 Subject: [PATCH 17/41] ENH: Adding tensor fields option for porosity models DarcyForchheimer and fixedCoeff --- .../DarcyForchheimer/DarcyForchheimer.C | 103 ++++++++------- .../DarcyForchheimer/DarcyForchheimer.H | 9 +- .../DarcyForchheimerTemplates.C | 21 +-- .../porosityModel/fixedCoeff/fixedCoeff.C | 121 +++++++++--------- .../porosityModel/fixedCoeff/fixedCoeff.H | 10 +- .../porosityModel/porosityModel.C | 16 ++- .../porosityModel/porosityModel.H | 7 + 7 files changed, 152 insertions(+), 135 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C index b0857fa78e..f46c77e3e2 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C @@ -52,66 +52,65 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer ) : porosityModel(name, modelType, mesh, dict, cellZoneName), - coordSys_(coeffs_, mesh), - D_("D", dimless/sqr(dimLength), tensor::zero), - F_("F", dimless/dimLength, tensor::zero), + D_(cellZoneIds_.size()), + F_(cellZoneIds_.size()), rhoName_(coeffs_.lookupOrDefault("rho", "rho")), muName_(coeffs_.lookupOrDefault("mu", "thermo:mu")), nuName_(coeffs_.lookupOrDefault("nu", "nu")) { - // local-to-global transformation tensor - const tensor& E = coordSys_.R(); dimensionedVector d(coeffs_.lookup("d")); - if (D_.dimensions() != d.dimensions()) - { - FatalIOErrorIn - ( - "Foam::porosityModels::DarcyForchheimer::DarcyForchheimer" - "(" - "const word&, " - "const word&, " - "const fvMesh&, " - "const dictionary&" - ")", - coeffs_ - ) << "incorrect dimensions for d: " << d.dimensions() - << " should be " << D_.dimensions() - << exit(FatalIOError); - } + dimensionedVector f(coeffs_.lookup("f")); adjustNegativeResistance(d); - - D_.value().xx() = d.value().x(); - D_.value().yy() = d.value().y(); - D_.value().zz() = d.value().z(); - D_.value() = (E & D_ & E.T()).value(); - - dimensionedVector f(coeffs_.lookup("f")); - if (F_.dimensions() != f.dimensions()) - { - FatalIOErrorIn - ( - "Foam::porosityModels::DarcyForchheimer::DarcyForchheimer" - "(" - "const word&, " - "const word&, " - "const fvMesh&, " - "const dictionary&" - ")", - coeffs_ - ) << "incorrect dimensions for f: " << f.dimensions() - << " should be " << F_.dimensions() - << exit(FatalIOError); - } - adjustNegativeResistance(f); - // leading 0.5 is from 1/2*rho - F_.value().xx() = 0.5*f.value().x(); - F_.value().yy() = 0.5*f.value().y(); - F_.value().zz() = 0.5*f.value().z(); - F_.value() = (E & F_ & E.T()).value(); + if (coordSys_.R().uniform()) + { + forAll (cellZoneIds_, zoneI) + { + D_[zoneI].setSize(1, tensor::zero); + F_[zoneI].setSize(1, tensor::zero); + + D_[zoneI][0].xx() = d.value().x(); + D_[zoneI][0].yy() = d.value().y(); + D_[zoneI][0].zz() = d.value().z(); + + D_[zoneI][0] = coordSys_.R().transformTensor(D_[zoneI][0]); + + // leading 0.5 is from 1/2*rho + F_[zoneI][0].xx() = 0.5*f.value().x(); + F_[zoneI][0].yy() = 0.5*f.value().y(); + F_[zoneI][0].zz() = 0.5*f.value().z(); + + F_[zoneI][0] = coordSys_.R().transformTensor(F_[zoneI][0]); + } + + } + else + { + forAll(cellZoneIds_, zoneI) + { + const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; + + D_[zoneI].setSize(cells.size(), tensor::zero); + F_[zoneI].setSize(cells.size(), tensor::zero); + + forAll(cells, i) + { + D_[zoneI][i].xx() = d.value().x(); + D_[zoneI][i].yy() = d.value().y(); + D_[zoneI][i].zz() = d.value().z(); + + F_[zoneI][i].xx() = f.value().x(); + F_[zoneI][i].yy() = f.value().y(); + F_[zoneI][i].zz() = f.value().z(); + } + + D_[zoneI] = coordSys_.R().transformTensor(D_[zoneI], cells); + F_[zoneI] = coordSys_.R().transformTensor(F_[zoneI], cells); + } + } } @@ -132,7 +131,7 @@ void Foam::porosityModels::DarcyForchheimer::correct const scalarField& V = mesh_.V(); scalarField& Udiag = UEqn.diag(); vectorField& Usource = UEqn.source(); - + if (UEqn.dimensions() == dimForce) { const volScalarField& rho = @@ -163,7 +162,7 @@ void Foam::porosityModels::DarcyForchheimer::correct const scalarField& V = mesh_.V(); scalarField& Udiag = UEqn.diag(); vectorField& Usource = UEqn.source(); - + apply(Udiag, Usource, V, rho, mu, U); } diff --git a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.H b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.H index ab3007d204..856089cee6 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.H @@ -53,7 +53,6 @@ SourceFiles #define DarcyForchheimer_H #include "porosityModel.H" -#include "coordinateSystem.H" #include "dimensionedTensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,14 +74,12 @@ private: // Private data - //- Local co-ordinate system - coordinateSystem coordSys_; //- Darcy coefficient [1/m2] - dimensionedTensor D_; + List D_; //- Forchheimer coefficient [1/m] - dimensionedTensor F_; + List F_; //- Name of density field word rhoName_; @@ -161,7 +158,7 @@ public: virtual void correct ( const fvVectorMatrix& UEqn, - volTensorField& AU + volTensorField& AU ) const; diff --git a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimerTemplates.C b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimerTemplates.C index 184206a010..27b10a79ef 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimerTemplates.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimerTemplates.C @@ -36,18 +36,19 @@ void Foam::porosityModels::DarcyForchheimer::apply const vectorField& U ) const { - const tensor& D = D_.value(); - const tensor& F = F_.value(); - forAll(cellZoneIds_, zoneI) { + const tensorField& dZones = D_[zoneI]; + const tensorField& fZones = F_[zoneI]; + const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; forAll(cells, i) { const label cellI = cells[i]; - - const tensor Cd = mu[cellI]*D + (rho[cellI]*mag(U[cellI]))*F; + const label j = this->fieldIndex(i); + const tensor Cd = + mu[cellI]*dZones[j] + (rho[cellI]*mag(U[cellI]))*fZones[j]; const scalar isoCd = tr(Cd); @@ -67,16 +68,20 @@ void Foam::porosityModels::DarcyForchheimer::apply const vectorField& U ) const { - const tensor& D = D_.value(); - const tensor& F = F_.value(); - forAll(cellZoneIds_, zoneI) { + const tensorField& dZones = D_[zoneI]; + const tensorField& fZones = F_[zoneI]; + const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; forAll(cells, i) { const label cellI = cells[i]; + const label j = this->fieldIndex(i); + const tensor D = dZones[j]; + const tensor F = fZones[j]; + AU[cellI] += mu[cellI]*D + (rho[cellI]*mag(U[cellI]))*F; } } diff --git a/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.C b/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.C index 59cef74368..b8267f7152 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.C @@ -50,19 +50,18 @@ void Foam::porosityModels::fixedCoeff::apply const scalar rho ) const { - const tensor& alpha = alpha_.value(); - const tensor& beta = beta_.value(); - forAll(cellZoneIds_, zoneI) { + const tensorField& alphaZones = alpha_[zoneI]; + const tensorField& betaZones = beta_[zoneI]; + const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; forAll(cells, i) { const label cellI = cells[i]; - - const tensor Cd = rho*(alpha + beta*mag(U[cellI])); - + const label j = fieldIndex(i); + const tensor Cd = rho*(alphaZones[j] + betaZones[j]*mag(U[cellI])); const scalar isoCd = tr(Cd); Udiag[cellI] += V[cellI]*isoCd; @@ -79,16 +78,21 @@ void Foam::porosityModels::fixedCoeff::apply const scalar rho ) const { - const tensor& alpha = alpha_.value(); - const tensor& beta = beta_.value(); forAll(cellZoneIds_, zoneI) { + const tensorField& alphaZones = alpha_[zoneI]; + const tensorField& betaZones = beta_[zoneI]; + const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; forAll(cells, i) { const label cellI = cells[i]; + const label j = fieldIndex(i); + const tensor alpha = alphaZones[j]; + const tensor beta = betaZones[j]; + AU[cellI] += rho*(alpha + beta*mag(U[cellI])); } } @@ -107,62 +111,59 @@ Foam::porosityModels::fixedCoeff::fixedCoeff ) : porosityModel(name, modelType, mesh, dict, cellZoneName), - coordSys_(coeffs_, mesh), - alpha_("alpha", dimless/dimTime, tensor::zero), - beta_("beta", dimless/dimLength, tensor::zero) + alpha_(cellZoneIds_.size()), + beta_(cellZoneIds_.size()) { - // local-to-global transformation tensor - const tensor& E = coordSys_.R(); - dimensionedVector alpha(coeffs_.lookup("alpha")); - if (alpha_.dimensions() != alpha.dimensions()) - { - FatalIOErrorIn - ( - "Foam::porosityModels::fixedCoeff::fixedCoeff" - "(" - "const word&, " - "const word&, " - "const fvMesh&, " - "const dictionary&" - ")", - coeffs_ - ) << "incorrect dimensions for alpha: " << alpha.dimensions() - << " should be " << alpha_.dimensions() - << exit(FatalIOError); - } + dimensionedVector beta(coeffs_.lookup("beta")); adjustNegativeResistance(alpha); - - alpha_.value().xx() = alpha.value().x(); - alpha_.value().yy() = alpha.value().y(); - alpha_.value().zz() = alpha.value().z(); - alpha_.value() = (E & alpha_ & E.T()).value(); - - dimensionedVector beta(coeffs_.lookup("beta")); - if (beta_.dimensions() != beta.dimensions()) - { - FatalIOErrorIn - ( - "Foam::porosityModels::fixedCoeff::fixedCoeff" - "(" - "const word&, " - "const word&, " - "const fvMesh&, " - "const dictionary&" - ")", - coeffs_ - ) << "incorrect dimensions for beta: " << beta.dimensions() - << " should be " << beta_.dimensions() - << exit(FatalIOError); - } - adjustNegativeResistance(beta); - beta_.value().xx() = beta.value().x(); - beta_.value().yy() = beta.value().y(); - beta_.value().zz() = beta.value().z(); - beta_.value() = (E & beta_ & E.T()).value(); + if (coordSys_.R().uniform()) + { + forAll (cellZoneIds_, zoneI) + { + alpha_[zoneI].setSize(1, tensor::zero); + beta_[zoneI].setSize(1, tensor::zero); + + alpha_[zoneI][0].xx() = alpha.value().x(); + alpha_[zoneI][0].yy() = alpha.value().y(); + alpha_[zoneI][0].zz() = alpha.value().z(); + alpha_[zoneI][0] = coordSys_.R().transformTensor(alpha_[zoneI][0]); + + beta_[zoneI][0].xx() = beta.value().x(); + beta_[zoneI][0].yy() = beta.value().y(); + beta_[zoneI][0].zz() = beta.value().z(); + beta_[zoneI][0] = coordSys_.R().transformTensor(beta_[zoneI][0]); + } + } + else + { + forAll(cellZoneIds_, zoneI) + { + const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; + + alpha_[zoneI].setSize(cells.size(), tensor::zero); + beta_[zoneI].setSize(cells.size(), tensor::zero); + + forAll(cells, i) + { + alpha_[zoneI][i].xx() = alpha.value().x(); + alpha_[zoneI][i].yy() = alpha.value().y(); + alpha_[zoneI][i].zz() = alpha.value().z(); + + beta_[zoneI][i].xx() = beta.value().x(); + beta_[zoneI][i].yy() = beta.value().y(); + beta_[zoneI][i].zz() = beta.value().z(); + } + + alpha_[zoneI] = + coordSys_.R().transformTensor(alpha_[zoneI], cells); + + beta_[zoneI] = coordSys_.R().transformTensor(beta_[zoneI], cells); + } + } } @@ -183,7 +184,7 @@ void Foam::porosityModels::fixedCoeff::correct const scalarField& V = mesh_.V(); scalarField& Udiag = UEqn.diag(); vectorField& Usource = UEqn.source(); - + scalar rho = 1.0; if (UEqn.dimensions() == dimForce) { @@ -211,7 +212,7 @@ void Foam::porosityModels::fixedCoeff::correct { coeffs_.lookup("rhoRef") >> rho; } - + apply(Udiag, Usource, V, U, rho); } diff --git a/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.H b/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.H index 61f4c36224..09cf5cfa79 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/fixedCoeff/fixedCoeff.H @@ -43,7 +43,6 @@ SourceFiles #define fixedCoeff_H #include "porosityModel.H" -#include "coordinateSystem.H" #include "dimensionedTensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -65,14 +64,11 @@ private: // Private data - //- Local co-ordinate system - coordinateSystem coordSys_; - //- Model alpha coefficient [1/s] - dimensionedTensor alpha_; + List alpha_; //- Model beta coefficient [1/m] - dimensionedTensor beta_; + List beta_; // Private Member Functions @@ -138,7 +134,7 @@ public: virtual void correct ( const fvVectorMatrix& UEqn, - volTensorField& AU + volTensorField& AU ) const; diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C index 77de5b1ffe..3b9a9c6375 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C @@ -66,6 +66,17 @@ void Foam::porosityModel::adjustNegativeResistance(dimensionedVector& resist) } +Foam::label Foam::porosityModel::fieldIndex(const label i) const +{ + label index = 0; + if (!coordSys_.R().uniform()) + { + index = i; + } + return index; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::porosityModel::porosityModel @@ -83,7 +94,8 @@ Foam::porosityModel::porosityModel coeffs_(dict.subDict(modelType + "Coeffs")), active_(true), zoneName_(cellZoneName), - cellZoneIds_() + cellZoneIds_(), + coordSys_(coordinateSystem::New(mesh, coeffs_)) { if (zoneName_ == word::null) { @@ -158,7 +170,7 @@ void Foam::porosityModel::porosityModel::addResistance ( const fvVectorMatrix& UEqn, volTensorField& AU, - bool correctAUprocBC + bool correctAUprocBC ) const { if (cellZoneIds_.empty()) diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H index 1c61e29f18..019c063f87 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H @@ -40,6 +40,7 @@ SourceFiles #include "dictionary.H" #include "fvMatricesFwd.H" #include "runTimeSelectionTables.H" +#include "coordinateSystem.H" #include "dimensionedVector.H" #include "keyType.H" @@ -90,6 +91,9 @@ protected: //- Cell zone Ids labelList cellZoneIds_; + //- Local co-ordinate system + coordinateSystem coordSys_; + // Protected Member Functions @@ -111,6 +115,9 @@ protected: volTensorField& AU ) const = 0; + //- Return label index + label fieldIndex(const label index) const; + public: From 9692a52e3aa7114ff55dc7c74b5a9f9b745c4175 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 21 Jan 2013 12:37:54 +0000 Subject: [PATCH 18/41] ENH: Update tutorials using coordinate systems for porosity models --- .../angledDuct/system/fvOptions | 12 +++++-- .../porosityProperties => system/fvOptions} | 34 ++++++++++++------ .../ras/angledDuct/system/fvSolution | 4 +-- .../mixerVessel2D/constant/porosityProperties | 10 ++++-- .../porosityProperties => system/fvOptions} | 35 +++++++++++++------ .../constant/porosityProperties | 10 ++++-- .../system/fvOptions | 12 +++++-- .../constant/porosityProperties | 10 ++++-- .../filter/constant/porosityProperties | 10 ++++-- 9 files changed, 99 insertions(+), 38 deletions(-) rename tutorials/compressible/rhoPimpleFoam/ras/angledDuct/{constant/porosityProperties => system/fvOptions} (51%) rename tutorials/compressible/rhoPimplecFoam/angledDuct/{constant/porosityProperties => system/fvOptions} (51%) diff --git a/tutorials/compressible/rhoLTSPimpleFoam/angledDuct/system/fvOptions b/tutorials/compressible/rhoLTSPimpleFoam/angledDuct/system/fvOptions index 246601aa16..2fd3242b6d 100644 --- a/tutorials/compressible/rhoLTSPimpleFoam/angledDuct/system/fvOptions +++ b/tutorials/compressible/rhoLTSPimpleFoam/angledDuct/system/fvOptions @@ -33,12 +33,18 @@ porosity1 coordinateSystem { - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); + } } } } } -************************************************************************* // +//************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/constant/porosityProperties b/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/system/fvOptions similarity index 51% rename from tutorials/compressible/rhoPimpleFoam/ras/angledDuct/constant/porosityProperties rename to tutorials/compressible/rhoPimpleFoam/ras/angledDuct/system/fvOptions index 650f01268c..2fd3242b6d 100644 --- a/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/constant/porosityProperties +++ b/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/system/fvOptions @@ -10,29 +10,41 @@ FoamFile version 2.0; format ascii; class dictionary; - location "constant"; - object porosityProperties; + location "system"; + object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // porosity1 { - type DarcyForchheimer; - active yes; + type explicitPorositySource; + active true; + selectionMode cellZone; cellZone porosity; - DarcyForchheimerCoeffs + explicitPorositySourceCoeffs { - d d [0 -2 0 0 0 0 0] (5e7 -1000 -1000); - f f [0 -1 0 0 0 0 0] (0 0 0); + type DarcyForchheimer; - coordinateSystem + DarcyForchheimerCoeffs { - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); + d d [0 -2 0 0 0 0 0] (5e7 -1000 -1000); + f f [0 -1 0 0 0 0 0] (0 0 0); + + coordinateSystem + { + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); + } + } } } } -// ************************************************************************* // +//************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/system/fvSolution b/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/system/fvSolution index 084c382e84..d87df4b492 100644 --- a/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/system/fvSolution +++ b/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/system/fvSolution @@ -57,7 +57,7 @@ PIMPLE nCorrectors 1; nNonOrthogonalCorrectors 0; rhoMin rhoMin [ 1 -3 0 0 0 ] 0.5; - rhoMax rhoMax [ 1 -3 0 0 0 ] 2.0; + rhoMax rhoMax [ 1 -3 0 0 0 ] 1.5; residualControl { @@ -76,7 +76,7 @@ relaxationFactors fields { "p.*" 0.3; - "rho.*" 1; + "rho.*" 0.01; } equations { diff --git a/tutorials/compressible/rhoPimpleFoam/ras/mixerVessel2D/constant/porosityProperties b/tutorials/compressible/rhoPimpleFoam/ras/mixerVessel2D/constant/porosityProperties index 1a76ef1d80..6c2f939ea6 100644 --- a/tutorials/compressible/rhoPimpleFoam/ras/mixerVessel2D/constant/porosityProperties +++ b/tutorials/compressible/rhoPimpleFoam/ras/mixerVessel2D/constant/porosityProperties @@ -28,8 +28,14 @@ porosity1 coordinateSystem { - e1 (1 0 0); - e2 (0 1 0); + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (1 0 0); + e2 (0 1 0); + } } } } diff --git a/tutorials/compressible/rhoPimplecFoam/angledDuct/constant/porosityProperties b/tutorials/compressible/rhoPimplecFoam/angledDuct/system/fvOptions similarity index 51% rename from tutorials/compressible/rhoPimplecFoam/angledDuct/constant/porosityProperties rename to tutorials/compressible/rhoPimplecFoam/angledDuct/system/fvOptions index 22add8ff29..3cb9357ca0 100644 --- a/tutorials/compressible/rhoPimplecFoam/angledDuct/constant/porosityProperties +++ b/tutorials/compressible/rhoPimplecFoam/angledDuct/system/fvOptions @@ -10,28 +10,41 @@ FoamFile version 2.0; format ascii; class dictionary; - location "constant"; - object porosityProperties; + location "system"; + object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // porosity1 { - type DarcyForchheimer; - active yes; + type explicitPorositySource; + active false; + selectionMode cellZone; cellZone porosity; - DarcyForchheimerCoeffs + explicitPorositySourceCoeffs { - d d [0 -2 0 0 0 0 0] (5e7 -1000 -1000); - f f [0 -1 0 0 0 0 0] (0 0 0); + type DarcyForchheimer; - coordinateSystem + DarcyForchheimerCoeffs { - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); + d d [0 -2 0 0 0 0 0] (5e5 -1000 -1000); + f f [0 -1 0 0 0 0 0] (0 0 0); + + coordinateSystem + { + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); + } + } } } } -// ************************************************************************* // + +//************************************************************************* // diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuctImplicit/constant/porosityProperties b/tutorials/compressible/rhoPorousSimpleFoam/angledDuctImplicit/constant/porosityProperties index 650f01268c..9795d83b85 100644 --- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuctImplicit/constant/porosityProperties +++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuctImplicit/constant/porosityProperties @@ -28,8 +28,14 @@ porosity1 coordinateSystem { - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); + } } } } diff --git a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions index d75a43c565..5aee15c82d 100644 --- a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions +++ b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/system/fvOptions @@ -51,12 +51,18 @@ porosity1 coordinateSystem { - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); + } } } } } -************************************************************************* // +//************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/porosityProperties b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/porosityProperties index 650f01268c..80421b7786 100644 --- a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/porosityProperties +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/porosityProperties @@ -28,8 +28,14 @@ porosity1 coordinateSystem { - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); + } } } } diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/constant/porosityProperties b/tutorials/lagrangian/reactingParcelFoam/filter/constant/porosityProperties index 93c4de650d..af10f81b16 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/constant/porosityProperties +++ b/tutorials/lagrangian/reactingParcelFoam/filter/constant/porosityProperties @@ -28,8 +28,14 @@ filter1 coordinateSystem { - e1 (1 0 0); - e2 (0 1 0); + type cartesian; + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (1 0 0); + e2 (0 1 0); + } } } } From 01c4970dd6d82158a78d14f5c16ed4dd9cf0a18a Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 21 Jan 2013 12:59:51 +0000 Subject: [PATCH 19/41] BUG: Correcting createBafflesDict --- .../system/createBafflesDict | 69 +++++-------------- 1 file changed, 19 insertions(+), 50 deletions(-) diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/createBafflesDict b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/createBafflesDict index 8dda6535dd..bc1ec594fd 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/createBafflesDict +++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/createBafflesDict @@ -23,7 +23,7 @@ internalFacesOnly true; // Baffles to create. baffles { - baffleFaces + baffleFacesThermoBaffle1D { //- Use predefined faceZone to select faces and orientation. type faceZone; @@ -52,61 +52,27 @@ baffles { T { - type compressible::thermoBaffle; - - // Coupled BC. - neighbourFieldName T; - kappa fluidThermo; - kappaName none; - - // Thermo baffle model - thermoBaffleModel thermoBaffle; - regionName baffleRegion; - infoOutput no; - active yes; - thermoBaffleCoeffs + type compressible::thermoBaffle1D; + baffleActivated yes; + thickness uniform 0.005; // thickness [m] + Qs uniform 100; // heat flux [W/m2] + specie { + nMoles 1; + molWeight 20; } - - // Solid thermo - thermoType + transport { - type heSolidThermo; - mixture pureMixture; - transport constIso; - thermo hConst; - equationOfState rhoConst; - specie specie; - energy sensibleEnthalpy; + kappa 1; } - - mixture + thermodynamics { - specie - { - nMoles 1; - molWeight 20; - } - transport - { - kappa 0.01; - } - thermodynamics - { - Hf 0; - Cp 15; - } - equationOfState - { - rho 80; - } + Hf 0; + Cp 10; } - - radiation + equationOfState { - radiationModel opaqueSolid; - absorptionEmissionModel none; - scatterModel none; + rho 10; } value uniform 300; @@ -160,7 +126,10 @@ baffles offsetMode uniform; offset (0 0 0); - ${..master.patchFields} + patchFields + { + ${...master.patchFields} + } } } } From 4256e0a770842ee656d82f4ca935e370768f600b Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 21 Jan 2013 14:39:16 +0000 Subject: [PATCH 20/41] ENH: edgeCollapser: Make mesh checking optional and set default values for dictionary Update biconic25-55Run35 tutorial with simplified collapseDict --- .../mesh/advanced/collapseEdges/collapseDict | 25 ++- .../polyMeshFilter/polyMeshFilter.C | 202 ++++++++++-------- .../polyMeshFilter/polyMeshFilter.H | 8 +- .../polyTopoChange/edgeCollapser.C | 9 +- .../biconic25-55Run35/system/collapseDict | 56 ----- .../biconic25-55Run35/system/meshQualityDict | 67 ------ 6 files changed, 136 insertions(+), 231 deletions(-) delete mode 100644 tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/meshQualityDict diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseDict b/applications/utilities/mesh/advanced/collapseEdges/collapseDict index 340c33049f..170a0a890d 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseDict +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseDict @@ -14,6 +14,11 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// If on, after collapsing check the quality of the mesh. If bad faces are +// generated then redo the collapsing with stricter filtering. +controlMeshQuality on; + + collapseEdgesCoeffs { // Edges shorter than this absolute value will be merged @@ -22,21 +27,13 @@ collapseEdgesCoeffs // The maximum angle between two edges that share a point attached to // no other edges maximumMergeAngle 30; - - // The amount that minimumEdgeLength will be reduced by for each - // edge if that edge's collapse generates a poor quality face - reductionFactor 0.5; } collapseFacesCoeffs { // The initial face length factor - initialFaceLengthFactor 0.5; - - // The amount that initialFaceLengthFactor will be reduced by for each - // face if its collapse generates a poor quality face - reductionFactor $initialFaceLengthFactor; + initialFaceLengthFactor 0.5; // If the face can't be collapsed to an edge, and it has a span less than // the target face length multiplied by this coefficient, collapse it @@ -63,12 +60,20 @@ collapseFacesCoeffs } -meshQualityCoeffs +controlMeshQualityCoeffs { // Name of the dictionary that has the mesh quality coefficients used // by motionSmoother::checkMesh #include "meshQualityDict"; + // The amount that minimumEdgeLength will be reduced by for each + // edge if that edge's collapse generates a poor quality face + edgeReductionFactor 0.5; + + // The amount that initialFaceLengthFactor will be reduced by for each + // face if its collapse generates a poor quality face + faceReductionFactor $initialFaceLengthFactor; + // Maximum number of smoothing iterations for the reductionFactors maximumSmoothingIterations 2; diff --git a/src/dynamicMesh/polyMeshFilter/polyMeshFilter.C b/src/dynamicMesh/polyMeshFilter/polyMeshFilter.C index 9b184f994e..a1cfc83aeb 100644 --- a/src/dynamicMesh/polyMeshFilter/polyMeshFilter.C +++ b/src/dynamicMesh/polyMeshFilter/polyMeshFilter.C @@ -427,9 +427,13 @@ Foam::polyMeshFilter::polyMeshFilter(const fvMesh& mesh) IOobject::NO_WRITE ) ), + controlMeshQuality_ + ( + dict_.lookupOrDefault("controlMeshQuality", false) + ), collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")), - collapseFacesCoeffDict_(dict_.subDict("collapseFacesCoeffs")), - meshQualityCoeffDict_(dict_.subDict("meshQualityCoeffs")), + collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")), + meshQualityCoeffDict_(dict_.subOrEmptyDict("controlMeshQualityCoeffs")), minLen_(readScalar(collapseEdgesCoeffDict_.lookup("minimumEdgeLength"))), maxCos_ ( @@ -443,27 +447,39 @@ Foam::polyMeshFilter::polyMeshFilter(const fvMesh& mesh) ), edgeReductionFactor_ ( - readScalar(collapseEdgesCoeffDict_.lookup("reductionFactor")) + meshQualityCoeffDict_.lookupOrDefault("edgeReductionFactor", -1) ), maxIterations_ ( - readLabel(meshQualityCoeffDict_.lookup("maximumIterations")) + meshQualityCoeffDict_.lookupOrAddDefault