diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H index fc66a21b16..62036fcc76 100644 --- a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H @@ -13,23 +13,6 @@ mesh ); - // Add overset specific interpolations - { - dictionary oversetDict; - oversetDict.add("T", true); - - const_cast - ( - mesh.schemesDict() - ).add - ( - "oversetInterpolationRequired", - oversetDict, - true - ); - } - - Info<< "Reading transportProperties\n" << endl; IOdictionary transportProperties diff --git a/applications/solvers/basic/potentialFoam/overPotentialFoam/createFields.H b/applications/solvers/basic/potentialFoam/overPotentialFoam/createFields.H index 80f04a8a68..d39f3044b7 100644 --- a/applications/solvers/basic/potentialFoam/overPotentialFoam/createFields.H +++ b/applications/solvers/basic/potentialFoam/overPotentialFoam/createFields.H @@ -121,21 +121,14 @@ mesh.setFluxRequired(Phi.name()); #include "createMRF.H" -// Add overset specific interpolations +// Add solver-specific interpolations { - dictionary oversetDict; - oversetDict.add("Phi", true); - oversetDict.add("U", true); + wordHashSet& nonInt = + const_cast(Stencil::New(mesh).nonInterpolatedFields()); + + nonInt.insert("cellMask"); + nonInt.insert("interpolatedCells"); - const_cast - ( - mesh.schemesDict() - ).add - ( - "oversetInterpolationRequired", - oversetDict, - true - ); } // Mask field for zeroing out contributions on hole cells diff --git a/applications/test/complex/Test-complex.C b/applications/test/complex/Test-complex.C index 0cf31f9c85..bc4d3d05dc 100644 --- a/applications/test/complex/Test-complex.C +++ b/applications/test/complex/Test-complex.C @@ -25,12 +25,11 @@ Application Description Some tests for complex numbers + \*---------------------------------------------------------------------------*/ #include "argList.H" -#include "complex.H" -#include "complexVector.H" -#include "Field.H" +#include "complexFields.H" using namespace Foam; @@ -52,15 +51,26 @@ int main(int argc, char *argv[]) << "complex(scalar) : " << complex(3.14519) << nl << nl; + std::complex c1(10, -3); + Info<< "std::complex : " << c1 << nl; + Info<< "sin: " << std::sin(c1) << nl; + + Info<< "complexVector::zero : " << complexVector::zero << nl << "complexVector::one : " << complexVector::one << nl << nl; - // Comparison - - for (complex c : { complex{1, 0}, complex{1, 2}} ) + for (complex c : { complex{1, 0}, complex{1, 2}} ) { + Info<< nl; print1(c); + + Info<< "sin: " << sin(c) << nl; + Info<< "pow(3): " << pow(c, 3) << nl; + Info<< "pow3: " << pow3(c) << nl; + Info<< "log: " << log(c) << nl; + Info<< "pow025: " << pow025(c) << nl; + // TDB: allow implicit construct from scalar? // // if (c == 1.0) @@ -69,22 +79,46 @@ int main(int argc, char *argv[]) // } } - Field fld1(3, complex(2.0, 1.0)); + complexField fld1(3, complex(2.0, 1.0)); + complexField fld2(fld1); + + for (complex& c : fld2) + { + c = ~c; + } Info<< "Field " << flatOutput(fld1) << nl; + Info<< "Conjugate: " << flatOutput(fld2) << nl; + + // Some arbitrary change + for (complex& c : fld2) + { + c.Im() *= 5; + } + Info<< "sum = " << sum(fld1) << nl; // Not yet Info<< "min = " << min(fld1) << nl; fld1 *= 10; - Info<< "Multiply: " << flatOutput(fld1) << nl; + Info<< "scalar multiply: " << flatOutput(fld1) << nl; - for (complex& c : fld1) - { - c = ~c; - } + fld1 /= 10; + Info<< "scalar divide: " << flatOutput(fld1) << nl; + + Info<< "sin: " << sin(fld1) << nl; + + Info<< "operator + : " << (fld1 + fld2) << nl; + + // Some operators are still incomplete + + // Info<< "operator * : " << (fld1 * fld2) << nl; + // Info<< "operator / : " << (fld1 / fld2) << nl; + Info<< "operator / : " << (fld1 / 2) << nl; + // Info<< "operator / : " << (fld1 / fld2) << nl; + Info<< "sqrt : " << sqrt(fld1) << nl; + // Info<< "pow(2) : " << pow(fld1, 2) << nl; - Info<< "Conjugate: " << flatOutput(fld1) << nl; Info<< "\nEnd\n" << endl; return 0; diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 4313846826..a247fdb059 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -217,6 +217,7 @@ int main(int argc, char *argv[]) ); #include "addRegionOption.H" + argList::addOption("dict", "file", "Use alternative extrudeMeshDict"); #include "setRootCase.H" #include "createTimeExtruded.H" @@ -236,15 +237,19 @@ int main(int argc, char *argv[]) << runTimeExtruded.timeName() << nl << endl; } - - IOdictionary dict + const IOdictionary dict ( - IOobject + IOobject::selectIO ( - "extrudeMeshDict", - runTimeExtruded.system(), - runTimeExtruded, - IOobject::MUST_READ_IF_MODIFIED + IOobject + ( + "extrudeMeshDict", + runTimeExtruded.system(), + runTimeExtruded, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ), + args.opt("dict", "") ) ); diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 5ac2aeb11d..d5381bc241 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011, 2015-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011, 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -1691,19 +1691,41 @@ int main(int argc, char *argv[]) } - const bool mergePatchFaces - ( - meshDict.lookupOrDefault("mergePatchFaces", true) - ); - - if (!mergePatchFaces) + // How to treat co-planar faces + meshRefinement::FaceMergeType mergeType = + meshRefinement::FaceMergeType::GEOMETRIC; { - Info<< "Not merging patch-faces of cell to preserve" - << " (split)hex cell shape." - << nl << endl; + const bool mergePatchFaces + ( + meshDict.lookupOrDefault("mergePatchFaces", true) + ); + + if (!mergePatchFaces) + { + Info<< "Not merging patch-faces of cell to preserve" + << " (split)hex cell shape." + << nl << endl; + mergeType = meshRefinement::FaceMergeType::NONE; + } + else + { + const bool mergeAcrossPatches + ( + meshDict.lookupOrDefault("mergeAcrossPatches", false) + ); + + if (mergeAcrossPatches) + { + Info<< "Merging co-planar patch-faces of cells" + << ", regardless of patch assignment" + << nl << endl; + mergeType = meshRefinement::FaceMergeType::IGNOREPATCH; + } + } } + if (wantRefine) { cpuTime timer; @@ -1732,7 +1754,7 @@ int main(int argc, char *argv[]) refineParams, snapParams, refineParams.handleSnapProblems(), - mergePatchFaces, // merge co-planar faces + mergeType, motionDict ); @@ -1784,7 +1806,7 @@ int main(int argc, char *argv[]) ( snapDict, motionDict, - mergePatchFaces, + mergeType, curvature, planarAngle, snapParams @@ -1851,7 +1873,7 @@ int main(int argc, char *argv[]) layerDict, motionDict, layerParams, - mergePatchFaces, + mergeType, preBalance, decomposer, distributor diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index f8d08abc5a..0780059017 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -55,7 +55,7 @@ Description #include "faceSet.H" #include "pointSet.H" #include "processorMeshes.H" -#include "hexRef8.H" +#include "hexRef8Data.H" #ifdef HAVE_ZOLTAN #include "zoltanRenumber.H" @@ -1327,8 +1327,24 @@ int main(int argc, char *argv[]) // Remove old procAddressing files processorMeshes::removeFiles(mesh); - // Remove refinement data - hexRef8::removeFiles(mesh); + + // Update refinement data + hexRef8Data refData + ( + IOobject + ( + "dummy", + mesh.facesInstance(), + polyMesh::meshSubDir, + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE, + false + ) + ); + refData.updateMesh(map()); + refData.write(); + // Update sets topoSet::updateMesh(mesh.facesInstance(), map(), cellSets); topoSet::updateMesh(mesh.facesInstance(), map(), faceSets); diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 54c3b2a19a..b3c9ecfdcc 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -672,7 +672,8 @@ $(Fields)/quaternionField/quaternionField.C $(Fields)/quaternionField/quaternionIOField.C $(Fields)/triadField/triadField.C $(Fields)/triadField/triadIOField.C -$(Fields)/complexFields/complexFields.C +$(Fields)/complex/complexField.C +$(Fields)/complex/complexVectorField.C $(Fields)/transformField/transformField.C $(Fields)/fieldTypes.C diff --git a/src/OpenFOAM/containers/Bits/bitSet/bitSet.H b/src/OpenFOAM/containers/Bits/bitSet/bitSet.H index 2c5c283136..00d9430596 100644 --- a/src/OpenFOAM/containers/Bits/bitSet/bitSet.H +++ b/src/OpenFOAM/containers/Bits/bitSet/bitSet.H @@ -513,10 +513,6 @@ public: //- Move assignment inline bitSet& operator=(bitSet&& bitset); - //- Complement operator. - // Return a copy of the existing set with all its bits flipped. - inline bitSet operator~() const; - //- Bitwise-AND all the bits in other with the bits in this bitset. // The operands may have dissimilar sizes without affecting the size // of the set. @@ -555,14 +551,6 @@ public: { return *this; } - - - // Housekeeping - - //- Deprecated(2018-04) compatibility name for PackedBoolList - // \deprecated(2018-04) - use toc() method - inline labelList used() const { return toc(); } - }; @@ -576,6 +564,9 @@ Ostream& operator<<(Ostream& os, const bitSet& bitset); Ostream& operator<<(Ostream& os, const InfoProxy& info); +//- Bitset complement, returns a copy of the bitset with all its bits flipped +inline bitSet operator~(const bitSet& bitset); + //- Bitwise-AND of two bitsets. // See bitSet::operator&= for more details. inline bitSet operator&(const bitSet& a, const bitSet& b); diff --git a/src/OpenFOAM/containers/Bits/bitSet/bitSetI.H b/src/OpenFOAM/containers/Bits/bitSet/bitSetI.H index afc7d93f97..5312caa3d1 100644 --- a/src/OpenFOAM/containers/Bits/bitSet/bitSetI.H +++ b/src/OpenFOAM/containers/Bits/bitSet/bitSetI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -663,14 +663,6 @@ inline Foam::bitSet& Foam::bitSet::operator=(bitSet&& bitset) } -inline Foam::bitSet Foam::bitSet::operator~() const -{ - bitSet result(*this); - result.flip(); - return result; -} - - inline Foam::bitSet& Foam::bitSet::operator&=(const bitSet& other) { return andEq(other); @@ -697,6 +689,14 @@ inline Foam::bitSet& Foam::bitSet::operator-=(const bitSet& other) // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // +inline Foam::bitSet Foam::operator~(const bitSet& bitset) +{ + bitSet result(bitset); + result.flip(); + return result; +} + + inline Foam::bitSet Foam::operator&(const bitSet& a, const bitSet& b) { bitSet result(a); diff --git a/src/OpenFOAM/fields/Fields/complex/complexField.C b/src/OpenFOAM/fields/Fields/complex/complexField.C new file mode 100644 index 0000000000..5662ab4076 --- /dev/null +++ b/src/OpenFOAM/fields/Fields/complex/complexField.C @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- + | Copyright (C) 2011 OpenFOAM Foundation +------------------------------------------------------------------------------- +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 "complexField.H" +#include "addToRunTimeSelectionTable.H" + +#define TEMPLATE +#include "FieldFunctionsM.C" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineCompoundTypeName(List, complexList); + addCompoundToRunTimeSelectionTable(List, complexList); +} + + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +Foam::complexField Foam::ComplexField +( + const UList& re, + const UList& im +) +{ + complexField cf(re.size()); + + forAll(cf, i) + { + cf[i].Re() = re[i]; + cf[i].Im() = im[i]; + } + + return cf; +} + + +Foam::complexField Foam::ReComplexField(const UList& re) +{ + complexField cf(re.size()); + + forAll(cf, i) + { + cf[i].Re() = re[i]; + cf[i].Im() = 0.0; + } + + return cf; +} + + +Foam::complexField Foam::ImComplexField(const UList& im) +{ + complexField cf(im.size()); + + forAll(cf, i) + { + cf[i].Re() = 0.0; + cf[i].Im() = im[i]; + } + + return cf; +} + + +Foam::scalarField Foam::ReImSum(const UList& cf) +{ + scalarField sf(cf.size()); + + forAll(sf, i) + { + sf[i] = cf[i].Re() + cf[i].Im(); + } + + return sf; +} + + +Foam::scalarField Foam::Re(const UList& cf) +{ + scalarField sf(cf.size()); + + forAll(sf, i) + { + sf[i] = cf[i].Re(); + } + + return sf; +} + + +Foam::scalarField Foam::Im(const UList& cf) +{ + scalarField sf(cf.size()); + + forAll(sf, i) + { + sf[i] = cf[i].Im(); + } + + return sf; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +UNARY_FUNCTION(complex, complex, pow3) +UNARY_FUNCTION(complex, complex, pow4) +UNARY_FUNCTION(complex, complex, pow5) +UNARY_FUNCTION(complex, complex, pow6) +UNARY_FUNCTION(complex, complex, pow025) +UNARY_FUNCTION(complex, complex, sqrt) +UNARY_FUNCTION(complex, complex, exp) +UNARY_FUNCTION(complex, complex, log) +UNARY_FUNCTION(complex, complex, log10) +UNARY_FUNCTION(complex, complex, sin) +UNARY_FUNCTION(complex, complex, cos) +UNARY_FUNCTION(complex, complex, tan) +UNARY_FUNCTION(complex, complex, asin) +UNARY_FUNCTION(complex, complex, acos) +UNARY_FUNCTION(complex, complex, atan) +UNARY_FUNCTION(complex, complex, sinh) +UNARY_FUNCTION(complex, complex, cosh) +UNARY_FUNCTION(complex, complex, tanh) +UNARY_FUNCTION(complex, complex, asinh) +UNARY_FUNCTION(complex, complex, acosh) +UNARY_FUNCTION(complex, complex, atanh) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "undefFieldFunctionsM.H" + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/Fields/complex/complexField.H b/src/OpenFOAM/fields/Fields/complex/complexField.H new file mode 100644 index 0000000000..c9b9351364 --- /dev/null +++ b/src/OpenFOAM/fields/Fields/complex/complexField.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- + | Copyright (C) 2011 OpenFOAM Foundation +------------------------------------------------------------------------------- +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 . + +Typedef + Foam::complexField + +Description + Specialisation of Field\ for complex. + +SourceFiles + complexField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef complexField_H +#define complexField_H + +#include "complex.H" +#include "scalarField.H" + +#define TEMPLATE +#include "FieldFunctionsM.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +typedef Field complexField; + +//- Zip up two lists of values into a list of complex +complexField ComplexField +( + const UList& re, + const UList& im +); + +//- Create complex field from a list of real (using imag == 0) +complexField ReComplexField(const UList& re); + +//- Create complex field from a list of imag (using real == 0) +complexField ImComplexField(const UList& im); + +//- Extract real component +scalarField Re(const UList& cf); + +//- Extract imag component +scalarField Im(const UList& cf); + +//- Sum real and imag components +scalarField ReImSum(const UList& cf); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +UNARY_FUNCTION(complex, complex, pow3) +UNARY_FUNCTION(complex, complex, pow4) +UNARY_FUNCTION(complex, complex, pow5) +UNARY_FUNCTION(complex, complex, pow6) +UNARY_FUNCTION(complex, complex, pow025) +UNARY_FUNCTION(complex, complex, sqrt) +UNARY_FUNCTION(complex, complex, exp) +UNARY_FUNCTION(complex, complex, log) +UNARY_FUNCTION(complex, complex, log10) +UNARY_FUNCTION(complex, complex, sin) +UNARY_FUNCTION(complex, complex, cos) +UNARY_FUNCTION(complex, complex, tan) +UNARY_FUNCTION(complex, complex, asin) +UNARY_FUNCTION(complex, complex, acos) +UNARY_FUNCTION(complex, complex, atan) +UNARY_FUNCTION(complex, complex, sinh) +UNARY_FUNCTION(complex, complex, cosh) +UNARY_FUNCTION(complex, complex, tanh) +UNARY_FUNCTION(complex, complex, asinh) +UNARY_FUNCTION(complex, complex, acosh) +UNARY_FUNCTION(complex, complex, atanh) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "undefFieldFunctionsM.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/Fields/complex/complexFields.H b/src/OpenFOAM/fields/Fields/complex/complexFields.H new file mode 100644 index 0000000000..ef031db0e4 --- /dev/null +++ b/src/OpenFOAM/fields/Fields/complex/complexFields.H @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +InClass + Foam::complexFields + +Description + Specialisations of Field\ for complex and complexVector + +\*---------------------------------------------------------------------------*/ + +#ifndef complexFields_H +#define complexFields_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "complexField.H" +#include "complexVectorField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/Fields/complex/complexVectorField.C b/src/OpenFOAM/fields/Fields/complex/complexVectorField.C new file mode 100644 index 0000000000..3ac98022f5 --- /dev/null +++ b/src/OpenFOAM/fields/Fields/complex/complexVectorField.C @@ -0,0 +1,156 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- + | Copyright (C) 2011 OpenFOAM Foundation +------------------------------------------------------------------------------- +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 "complexVectorField.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineCompoundTypeName(List, complexVectorList); + addCompoundToRunTimeSelectionTable(List, complexVectorList); +} + + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +Foam::complexVectorField Foam::ComplexField +( + const UList& re, + const UList& im +) +{ + complexVectorField cvf(re.size()); + + for (direction cmpt=0; cmpt& re) +{ + complexVectorField cvf(re.size()); + + for (direction cmpt=0; cmpt& im) +{ + complexVectorField cvf(im.size()); + + for (direction cmpt=0; cmpt& cvf) +{ + vectorField vf(cvf.size()); + + for (direction cmpt=0; cmpt& cvf) +{ + vectorField vf(cvf.size()); + + for (direction cmpt=0; cmpt& cvf) +{ + vectorField vf(cvf.size()); + + for (direction cmpt=0; cmpt& vf, + const UList& cvf +) +{ + return ComplexField(vf^Re(cvf), vf^Im(cvf)); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/Fields/complexFields/complexFields.H b/src/OpenFOAM/fields/Fields/complex/complexVectorField.H similarity index 64% rename from src/OpenFOAM/fields/Fields/complexFields/complexFields.H rename to src/OpenFOAM/fields/Fields/complex/complexVectorField.H index 13e02472c9..507a6dc51d 100644 --- a/src/OpenFOAM/fields/Fields/complexFields/complexFields.H +++ b/src/OpenFOAM/fields/Fields/complex/complexVectorField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011 OpenFOAM Foundation @@ -23,12 +23,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Typedef - Foam::complexField - -Description - Specialisation of Field\ for complex. - Typedef Foam::complexVectorField @@ -36,49 +30,53 @@ Description Specialisation of Field\ for complexVector. SourceFiles - complexFields.C + complexVectorField.C \*---------------------------------------------------------------------------*/ -#ifndef complexFields_H -#define complexFields_H +#ifndef complexVectorField_H +#define complexVectorField_H #include "complex.H" #include "complexVector.H" -#include "primitiveFields.H" +#include "vectorField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -typedef Field complexField; - -complexField ComplexField(const UList&, const UList&); -complexField ReComplexField(const UList&); -complexField ImComplexField(const UList&); -scalarField Re(const UList&); -scalarField Im(const UList&); -scalarField ReImSum(const UList&); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // typedef Field complexVectorField; -complexVectorField ComplexField(const UList&, const UList&); -complexVectorField ReComplexField(const UList&); -complexVectorField ImComplexField(const UList&); -vectorField Re(const UList&); -vectorField Im(const UList&); -vectorField ReImSum(const UList&); +//- Zip up two lists of values into a list of complex +complexVectorField ComplexField +( + const UList& re, + const UList& im +); + + +//- Create complex field from a list of real (using imag == 0) +complexVectorField ReComplexField(const UList& re); + +//- Create complex field from a list of imag (using real == 0) +complexVectorField ImComplexField(const UList& im); + +//- Extract real component +vectorField Re(const UList& cvf); + +//- Extract imag component +vectorField Im(const UList& cvf); + +//- Sum real and imag components +vectorField ReImSum(const UList& cvf); complexVectorField operator^ ( - const UList&, - const UList& + const UList& vf, + const UList& cvf ); diff --git a/src/OpenFOAM/fields/Fields/complexFields/complexFields.C b/src/OpenFOAM/fields/Fields/complexFields/complexFields.C deleted file mode 100644 index df9203067c..0000000000 --- a/src/OpenFOAM/fields/Fields/complexFields/complexFields.C +++ /dev/null @@ -1,248 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- - | Copyright (C) 2011 OpenFOAM Foundation -------------------------------------------------------------------------------- -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 . - -Description - Specialisation of Field\ for complex and complexVector. - -\*---------------------------------------------------------------------------*/ - -#include "complexFields.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -defineCompoundTypeName(List, complexList); -addCompoundToRunTimeSelectionTable(List, complexList); - -complexField ComplexField(const UList& re, const UList& im) -{ - complexField cf(re.size()); - - forAll(cf, i) - { - cf[i].Re() = re[i]; - cf[i].Im() = im[i]; - } - - return cf; -} - - -complexField ReComplexField(const UList& sf) -{ - complexField cf(sf.size()); - - forAll(cf, i) - { - cf[i].Re() = sf[i]; - cf[i].Im() = 0.0; - } - - return cf; -} - - -complexField ImComplexField(const UList& sf) -{ - complexField cf(sf.size()); - - forAll(cf, i) - { - cf[i].Re() = 0.0; - cf[i].Im() = sf[i]; - } - - return cf; -} - - -scalarField ReImSum(const UList& cf) -{ - scalarField sf(cf.size()); - - forAll(sf, i) - { - sf[i] = cf[i].Re() + cf[i].Im(); - } - - return sf; -} - - -scalarField Re(const UList& cf) -{ - scalarField sf(cf.size()); - - forAll(sf, i) - { - sf[i] = cf[i].Re(); - } - - return sf; -} - - -scalarField Im(const UList& cf) -{ - scalarField sf(cf.size()); - - forAll(sf, i) - { - sf[i] = cf[i].Im(); - } - - return sf; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -defineCompoundTypeName(List, complexVectorList); -addCompoundToRunTimeSelectionTable(List, complexVectorList); - -complexVectorField ComplexField -( - const UList& re, - const UList& im -) -{ - complexVectorField cvf(re.size()); - - for (direction cmpt=0; cmpt& vf) -{ - complexVectorField cvf(vf.size()); - - for (direction cmpt=0; cmpt& vf) -{ - complexVectorField cvf(vf.size()); - - for (direction cmpt=0; cmpt& cvf) -{ - vectorField vf(cvf.size()); - - for (direction cmpt=0; cmpt& cvf) -{ - vectorField vf(cvf.size()); - - for (direction cmpt=0; cmpt& cvf) -{ - vectorField vf(cvf.size()); - - for (direction cmpt=0; cmpt& vf, - const UList& cvf -) -{ - return ComplexField(vf^Re(cvf), vf^Im(cvf)); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCGStab/PBiCGStab.C b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCGStab/PBiCGStab.C index adf8b3054a..1e343565fb 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCGStab/PBiCGStab.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCGStab/PBiCGStab.C @@ -208,7 +208,11 @@ Foam::solverPerformance Foam::PBiCGStab::solve solverPerf.finalResidual() = gSumMag(sA, matrix().mesh().comm())/normFactor; - if (solverPerf.checkConvergence(tolerance_, relTol_)) + if + ( + solverPerf.nIterations() >= minIter_ + && solverPerf.checkConvergence(tolerance_, relTol_) + ) { for (label cell=0; cell complexVector; } +// Functions #include "complexVectorI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Vector/complexVector/complexVectorI.H b/src/OpenFOAM/primitives/Vector/complexVector/complexVectorI.H index 7e181669d1..175900b723 100644 --- a/src/OpenFOAM/primitives/Vector/complexVector/complexVectorI.H +++ b/src/OpenFOAM/primitives/Vector/complexVector/complexVectorI.H @@ -23,10 +23,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - complexVector specific part of 3D complexVector obtained from - generic Vector. - \*---------------------------------------------------------------------------*/ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -34,7 +30,7 @@ Description namespace Foam { -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // inline complexVector operator*(const complex& v1, const complexVector& v2) { @@ -80,8 +76,7 @@ inline complexVector operator/(const complex& v1, const complexVector& v2) } -// complexVector dot product - +//- Dot product for complexVector inline complex operator&(const complexVector& v1, const complexVector& v2) { return complex @@ -93,8 +88,7 @@ inline complex operator&(const complexVector& v1, const complexVector& v2) } -// complexVector cross product - +//- Cross product for complexVector inline complexVector operator^(const complexVector& v1, const complexVector& v2) { return complexVector @@ -106,8 +100,7 @@ inline complexVector operator^(const complexVector& v1, const complexVector& v2) } -// complexVector cross product - +//- Cross product for complexVector inline complexVector operator^(const vector& v1, const complexVector& v2) { return complexVector diff --git a/src/OpenFOAM/primitives/complex/complex.C b/src/OpenFOAM/primitives/complex/complex.C index e53a04fe52..2afbfe8612 100644 --- a/src/OpenFOAM/primitives/complex/complex.C +++ b/src/OpenFOAM/primitives/complex/complex.C @@ -32,7 +32,7 @@ License const char* const Foam::complex::typeName = "complex"; const Foam::complex Foam::complex::zero(0, 0); -const Foam::complex Foam::complex::one(1, 1); +const Foam::complex Foam::complex::one(1, 0); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -55,12 +55,15 @@ Foam::word Foam::name(const complex& c) Foam::Istream& Foam::operator>>(Istream& is, complex& c) { + scalar r, i; + is.readBegin("complex"); - - is >> c.re >> c.im; - + is >> r >> i; is.readEnd("complex"); + c.real(r); + c.imag(i); + is.check(FUNCTION_NAME); return is; } @@ -69,7 +72,7 @@ Foam::Istream& Foam::operator>>(Istream& is, complex& c) Foam::Ostream& Foam::operator<<(Ostream& os, const complex& c) { os << token::BEGIN_LIST - << c.re << token::SPACE << c.im + << c.real() << token::SPACE << c.imag() << token::END_LIST; return os; diff --git a/src/OpenFOAM/primitives/complex/complex.H b/src/OpenFOAM/primitives/complex/complex.H index 8c67134d80..aa7dee6c70 100644 --- a/src/OpenFOAM/primitives/complex/complex.H +++ b/src/OpenFOAM/primitives/complex/complex.H @@ -38,6 +38,7 @@ SourceFiles #ifndef complex_H #define complex_H +#include #include "scalar.H" #include "word.H" #include "zero.H" @@ -68,9 +69,6 @@ inline complex operator*(const complex&, const scalar); inline complex operator/(const complex&, const scalar); inline complex operator/(const scalar, const complex&); -Istream& operator>>(Istream& is, complex& c); -Ostream& operator<<(Ostream& os, const complex& c); - /*---------------------------------------------------------------------------*\ Class complex Declaration @@ -98,7 +96,7 @@ public: //- A complex zero (0,0) static const complex zero; - //- A complex one (1,1) + //- A complex one (1,0) static const complex one; @@ -119,6 +117,12 @@ public: //- Construct from real and imaginary parts inline constexpr complex(const scalar r, const scalar i) noexcept; + //- Construct from std::complex + inline complex(const std::complex& c); + + //- Construct from std::complex + inline complex(const std::complex& c); + //- Construct from Istream explicit complex(Istream& is); @@ -172,6 +176,13 @@ public: // Member Operators + //- Conversion to std::complex + inline operator std::complex() const + { + return std::complex(re, im); + } + + //- Copy assignment inline void operator=(const complex& c); @@ -189,12 +200,6 @@ public: inline void operator*=(const scalar s); inline void operator/=(const scalar s); - //- Conjugate - inline complex operator~() const; - - //- Conjugate - inline complex operator!() const; - inline bool operator==(const complex& c) const; inline bool operator!=(const complex& c) const; @@ -224,17 +229,19 @@ public: friend complex operator*(const complex& c, const scalar s); friend complex operator/(const complex& c, const scalar s); friend complex operator/(const scalar s, const complex& c); - - - // IOstream Operators - - friend Istream& operator>>(Istream& is, complex& c); - friend Ostream& operator<<(Ostream& os, const complex& c); }; -// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // +Istream& operator>>(Istream& is, complex& c); +Ostream& operator<<(Ostream& os, const complex& c); + +//- Complex conjugate +inline complex operator~(const complex& c); + + +// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // //- Return string representation of complex word name(const complex& c); diff --git a/src/OpenFOAM/primitives/complex/complexI.H b/src/OpenFOAM/primitives/complex/complexI.H index 41bfa6befd..58e564e5fb 100644 --- a/src/OpenFOAM/primitives/complex/complexI.H +++ b/src/OpenFOAM/primitives/complex/complexI.H @@ -55,6 +55,20 @@ inline constexpr Foam::complex::complex(const scalar r, const scalar i) noexcept {} +inline Foam::complex::complex(const std::complex& c) +: + re(c.real()), + im(c.imag()) +{} + + +inline Foam::complex::complex(const std::complex& c) +: + re(c.real()), + im(c.imag()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // inline void Foam::complex::real(scalar val) @@ -174,18 +188,6 @@ inline void Foam::complex::operator/=(const scalar s) } -inline Foam::complex Foam::complex::operator~() const -{ - return conjugate(); -} - - -inline Foam::complex Foam::complex::operator!() const -{ - return conjugate(); -} - - inline bool Foam::complex::operator==(const complex& c) const { return (equal(re, c.re) && equal(im, c.im)); @@ -198,8 +200,15 @@ inline bool Foam::complex::operator!=(const complex& c) const } -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // +inline Foam::complex Foam::operator~(const complex& c) +{ + return c.conjugate(); +} + + +// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // namespace Foam { @@ -341,9 +350,97 @@ inline complex operator/(const scalar s, const complex& c) return complex(s/c.re, s/c.im); } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Complex transcendental functions +namespace Foam +{ + #define transFunc(func) \ + inline complex func(const Foam::complex& z) \ + { \ + return std:: func (std::complex(z)); \ + } + +transFunc(sqrt) +transFunc(exp) +transFunc(log) +transFunc(log10) +transFunc(sin) +transFunc(cos) +transFunc(tan) +transFunc(asin) +transFunc(acos) +transFunc(atan) +transFunc(sinh) +transFunc(cosh) +transFunc(tanh) +transFunc(asinh) +transFunc(acosh) +transFunc(atanh) + +// Special treatment for pow() +inline complex pow(const complex& x, const complex& y) +{ + return std::pow(std::complex(x), std::complex(y)); +} + + +// Combinations of complex and real +#define powFuncs(type2) \ + inline complex pow(const complex& x, const type2& y) \ + { \ + return std::pow(std::complex(x), scalar(y)); \ + } \ + \ + inline Foam::complex pow(const type2& x, const complex& y) \ + { \ + return std::pow(scalar(x), std::complex(y)); \ + } + + +powFuncs(float) +powFuncs(double) +powFuncs(int) +powFuncs(long) + + +inline complex pow3(const complex& c) +{ + return c*sqr(c); +} + + +inline complex pow4(const complex& c) +{ + return sqr(sqr(c)); +} + + +inline complex pow5(const complex& c) +{ + return c*pow4(c); +} + + +inline complex pow6(const complex& c) +{ + return pow3(sqr(c)); +} + + +inline complex pow025(const complex& c) +{ + return sqrt(sqrt(c)); +} + +} // End namespace Foam + +#undef transFunc +#undef powFuncs + // ************************************************************************* // diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C index 9c47866bd4..8078b9ccfc 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C @@ -129,6 +129,7 @@ bool Foam::combineFaces::validFace void Foam::combineFaces::regioniseFaces ( const scalar minCos, + const bool mergeAcrossPatches, const label celli, const labelList& cEdges, Map