From 7df47610681c6208c5b67f769116ec5e16b5e702 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 23 Jun 2009 18:20:57 +0100 Subject: [PATCH 01/12] updated comment --- .../meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H index 690fb1083b..de1d9cc9f9 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.H @@ -32,7 +32,6 @@ Description SourceFiles coupledPolyPatch.C - coupledPolyPatchMorph.C \*---------------------------------------------------------------------------*/ From 9ea05f837178ac55fdf5ce9bb4b43e00ae473c9f Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Jun 2009 12:03:10 +0100 Subject: [PATCH 02/12] moved sort from List to UList --- src/OpenFOAM/containers/Lists/List/List.C | 30 --------------------- src/OpenFOAM/containers/Lists/List/List.H | 12 --------- src/OpenFOAM/containers/Lists/UList/UList.C | 30 +++++++++++++++++++++ src/OpenFOAM/containers/Lists/UList/UList.H | 12 +++++++++ 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 3fa3dcc874..08422fd9ba 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -35,8 +35,6 @@ License #include "BiIndirectList.H" #include "contiguous.H" -#include - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // @@ -442,34 +440,6 @@ void Foam::List::transfer(SortableList& a) } -template -void Foam::sort(List& a) -{ - std::sort(a.begin(), a.end()); -} - - -template -void Foam::sort(List& a, const Cmp& cmp) -{ - std::sort(a.begin(), a.end(), cmp); -} - - -template -void Foam::stableSort(List& a) -{ - std::stable_sort(a.begin(), a.end()); -} - - -template -void Foam::stableSort(List& a, const Cmp& cmp) -{ - std::stable_sort(a.begin(), a.end(), cmp); -} - - // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // Assignment to UList operator. Takes linear time. diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index a6bf29686a..b89f6c95a9 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -248,18 +248,6 @@ public: template List readList(Istream&); -template -void sort(List&); - -template -void sort(List&, const Cmp&); - -template -void stableSort(List&); - -template -void stableSort(List&, const Cmp&); - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index 255a91ecfe..42d00bc41e 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -30,6 +30,8 @@ License #include "ListLoopM.H" #include "contiguous.H" +#include + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -116,6 +118,34 @@ Foam::label Foam::UList::byteSize() const } +template +void Foam::sort(UList& a) +{ + std::sort(a.begin(), a.end()); +} + + +template +void Foam::sort(UList& a, const Cmp& cmp) +{ + std::sort(a.begin(), a.end(), cmp); +} + + +template +void Foam::stableSort(UList& a) +{ + std::stable_sort(a.begin(), a.end()); +} + + +template +void Foam::stableSort(UList& a, const Cmp& cmp) +{ + std::stable_sort(a.begin(), a.end(), cmp); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index f7db8226ff..087f685ff6 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -320,6 +320,18 @@ public: ); }; +template +void sort(UList&); + +template +void sort(UList&, const Cmp&); + +template +void stableSort(UList&); + +template +void stableSort(UList&, const Cmp&); + // Reverse the first n elements of the list template inline void reverse(UList&, const label n); From c8d033f1ef24c99b314c3183778dfa3d0969c7b3 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Jun 2009 12:37:15 +0100 Subject: [PATCH 03/12] updated to current thermo spec --- .../mixtures/basicMixture/basicMixtures.C | 18 ++ .../basic/psiThermo/ePsiThermo/ePsiThermos.C | 6 +- .../specie/thermo/eConst/eConstThermo.C | 15 +- .../specie/thermo/eConst/eConstThermo.H | 32 ++-- .../specie/thermo/eConst/eConstThermoI.H | 166 +++++++++++------- 5 files changed, 147 insertions(+), 90 deletions(-) diff --git a/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C b/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C index 022263ecc3..0aced02618 100644 --- a/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C +++ b/src/thermophysicalModels/basic/mixtures/basicMixture/basicMixtures.C @@ -34,6 +34,8 @@ Description #include "perfectGas.H" +#include "eConstThermo.H" + #include "hConstThermo.H" #include "janafThermo.H" #include "specieThermo.H" @@ -68,6 +70,22 @@ makeBasicMixture perfectGas ); +makeBasicMixture +( + pureMixture, + constTransport, + eConstThermo, + perfectGas +); + +makeBasicMixture +( + pureMixture, + sutherlandTransport, + eConstThermo, + perfectGas +); + makeBasicMixture ( pureMixture, diff --git a/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermos.C b/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermos.C index 2849a29ea7..0517a06ec2 100644 --- a/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermos.C +++ b/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermos.C @@ -28,7 +28,7 @@ License #include "perfectGas.H" -#include "hConstThermo.H" +#include "eConstThermo.H" #include "janafThermo.H" #include "specieThermo.H" @@ -50,7 +50,7 @@ makeBasicPsiThermo ePsiThermo, pureMixture, constTransport, - hConstThermo, + eConstThermo, perfectGas ); @@ -59,7 +59,7 @@ makeBasicPsiThermo ePsiThermo, pureMixture, sutherlandTransport, - hConstThermo, + eConstThermo, perfectGas ); diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C index 8d62be816f..e13eb5b0ab 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C @@ -29,9 +29,10 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::eConstThermo::eConstThermo(Istream& is) +template +Foam::eConstThermo::eConstThermo(Istream& is) : - specieThermo(is), + equationOfState(is), Cv_(readScalar(is)), Hf_(readScalar(is)) { @@ -41,9 +42,15 @@ Foam::eConstThermo::eConstThermo(Istream& is) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // -Foam::Ostream& Foam::operator<<(Ostream& os, const eConstThermo& ct) +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const eConstThermo& ct +) { - os << (const specieThermo&)ct << tab << ct.Cv_ << tab << ct.Hf_; + os << static_cast(ct) << tab + << ct.Cv_ << tab << ct.Hf_; os.check("Ostream& operator<<(Ostream& os, const eConstThermo& ct)"); return os; diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H index c01600eabd..6d9bef7423 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H @@ -26,8 +26,8 @@ Class Foam::eConstThermo Description - Constant properties thermodynamics package derived from the basic - thermo package data type specieThermo. + Constant properties thermodynamics package templated on an equation of + state SourceFiles eConstThermoI.H @@ -86,12 +86,13 @@ Ostream& operator<< /*---------------------------------------------------------------------------*\ - Class eConstThermo Declaration + Class eConstThermo Declaration \*---------------------------------------------------------------------------*/ +template class eConstThermo : - public specieThermo + public equationOfState { // Private data @@ -104,7 +105,7 @@ class eConstThermo //- Construct from components inline eConstThermo ( - const specieThermo& st, + const equationOfState& st, const scalar cv, const scalar hf ); @@ -147,20 +148,10 @@ public: inline scalar s(const scalar T) const; - // Some derived properties - // Other derived properties obtained from specieThermo base type - - //- Temperature from Enthalpy given an initial temperature T0 - inline scalar TH(const scalar h, const scalar T0) const; - - //- Temperature from internal energy given an initial temperature T0 - inline scalar TE(const scalar e, const scalar T0) const; - - // Member operators - inline void operator+=(const hConstThermo&); - inline void operator-=(const hConstThermo&); + inline void operator+=(const eConstThermo&); + inline void operator-=(const eConstThermo&); // Friend operators @@ -194,7 +185,8 @@ public: friend Ostream& operator<< ( - Ostream&, const eConstThermo& + Ostream&, + const eConstThermo& ); }; @@ -207,6 +199,10 @@ public: #include "eConstThermoI.H" +#ifdef NoRepository +# include "eConstThermo.C" +#endif + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H index aba6da1eef..8e021c53ab 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H @@ -26,14 +26,15 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -inline Foam::eConstThermo::eConstThermo +template +inline Foam::eConstThermo::eConstThermo ( - const specieThermo& st, + const equationOfState& st, const scalar cv, const scalar hf ) : - specieThermo(st), + equationOfState(st), Cv_(cv), Hf_(hf) {} @@ -41,20 +42,21 @@ inline Foam::eConstThermo::eConstThermo // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -inline Foam::eConstThermo::eConstThermo +template +inline Foam::eConstThermo::eConstThermo ( const word& name, - const eConstThermo& ct + const eConstThermo& ct ) : - specieThermo(name, ct), + equationOfState(name, ct), Cv_(ct.Cv_), Hf_(ct.Hf_) {} template -inline Foam::autoPtr > +inline Foam::autoPtr > Foam::eConstThermo::clone() const { return autoPtr > @@ -65,7 +67,7 @@ Foam::eConstThermo::clone() const template -inline autoPtr > +inline Foam::autoPtr > Foam::eConstThermo::New(Istream& is) { return autoPtr > @@ -77,19 +79,31 @@ Foam::eConstThermo::New(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline Foam::scalar Foam::eConstThermo::cp(const scalar) const +template +inline Foam::scalar Foam::eConstThermo::cp +( + const scalar +) const { - return Cv_*W() + RR; + return Cv_*this->W() + specie::RR; } -inline Foam::scalar Foam::eConstThermo::h(const scalar T) const +template +inline Foam::scalar Foam::eConstThermo::h +( + const scalar T +) const { - return cp(T)*T + Hf_*W(); + return cp(T)*T + Hf_*this->W(); } -inline Foam::scalar Foam::eConstThermo::hs(const scalar T) const +template +inline Foam::scalar Foam::eConstThermo::hs +( + const scalar T +) const { return cp(T)*T; } @@ -102,104 +116,126 @@ inline Foam::scalar Foam::eConstThermo::hc() const } -inline Foam::scalar Foam::eConstThermo::s(const scalar T) const +template +inline Foam::scalar Foam::eConstThermo::s +( + const scalar T +) const { notImplemented("scalar eConstThermo::s(const scalar T) const"); return T; } -inline Foam::scalar Foam::eConstThermo::TH -( - const scalar h, - const scalar T0 -) const -{ - return (h - Hf_)/Cp(T0); -} - - -inline Foam::scalar Foam::eConstThermo::TE -( - const scalar e, - const scalar -) const -{ - return (e - Hf_)/Cv_; -} - - // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline Foam::eConstThermo& Foam::eConstThermo::operator= +template +inline void Foam::eConstThermo::operator+= ( - const eConstThermo& ct + const eConstThermo& ct ) { - specieThermo::operator=(ct); + scalar molr1 = this->nMoles(); - Cv_ = ct.Cv_; - Hf_ = ct.Hf_; + equationOfState::operator+=(ct); - return *this; + molr1 /= this->nMoles(); + scalar molr2 = ct.nMoles()/this->nMoles(); + + Cv_ = molr1*Cv_ + molr2*ct.Cv_; + Hf_ = molr1*Hf_ + molr2*ct.Hf_; +} + + +template +inline void Foam::eConstThermo::operator-= +( + const eConstThermo& ct +) +{ + scalar molr1 = this->nMoles(); + + equationOfState::operator-=(ct); + + molr1 /= this->nMoles(); + scalar molr2 = ct.nMoles()/this->nMoles(); + + Cv_ = molr1*Cv_ - molr2*ct.Cv_; + Hf_ = molr1*Hf_ - molr2*ct.Hf_; } // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -inline Foam::eConstThermo Foam::operator+ +template +inline Foam::eConstThermo Foam::operator+ ( - const eConstThermo& ct1, - const eConstThermo& ct2 + const eConstThermo& ct1, + const eConstThermo& ct2 ) { - specieThermo st(((const specieThermo&)ct1) + ((const specieThermo&)ct2)); - - return eConstThermo + equationOfState eofs ( - st, - ct1.nMoles()/st.nMoles()*ct1.Cv_ + ct2.nMoles()/st.nMoles()*ct2.Cv_, - ct1.nMoles()/st.nMoles()*ct1.Hf_ + ct2.nMoles()/st.nMoles()*ct2.Hf_ + static_cast(ct1) + + static_cast(ct2) + ); + + return eConstThermo + ( + eofs, + ct1.nMoles()/eofs.nMoles()*ct1.Cv_ + + ct2.nMoles()/eofs.nMoles()*ct2.Cv_, + ct1.nMoles()/eofs.nMoles()*ct1.Hf_ + + ct2.nMoles()/eofs.nMoles()*ct2.Hf_ ); } -inline Foam::eConstThermo Foam::operator- +template +inline Foam::eConstThermo Foam::operator- ( - const eConstThermo& ct1, - const eConstThermo& ct2 + const eConstThermo& ct1, + const eConstThermo& ct2 ) { - specieThermo st(((const specieThermo&)ct1) - ((const specieThermo&)ct2)); - - return eConstThermo + equationOfState eofs ( - st, - ct1.nMoles()/st.nMoles()*ct1.Cv_ - ct2.nMoles()/st.nMoles()*ct2.Cv_, - ct1.nMoles()/st.nMoles()*ct1.Hf_ - ct2.nMoles()/st.nMoles()*ct2.Hf_ + static_cast(ct1) + - static_cast(ct2) + ); + + return eConstThermo + ( + eofs, + ct1.nMoles()/eofs.nMoles()*ct1.Cv_ + - ct2.nMoles()/eofs.nMoles()*ct2.Cv_, + ct1.nMoles()/eofs.nMoles()*ct1.Hf_ + - ct2.nMoles()/eofs.nMoles()*ct2.Hf_ ); } -inline Foam::eConstThermo Foam::operator* +template +inline Foam::eConstThermo Foam::operator* ( const scalar s, - const eConstThermo& ct + const eConstThermo& ct ) { - return eConstThermo + return eConstThermo ( - s*((const specieThermo&)ct), + s*static_cast(ct), ct.Cv_, ct.Hf_ ); } -inline Foam::eConstThermo Foam::operator== +template +inline Foam::eConstThermo Foam::operator== ( - const eConstThermo& ct1, - const eConstThermo& ct2 + const eConstThermo& ct1, + const eConstThermo& ct2 ) { return ct2 - ct1; From fac1b596b8e3785a5e751a2666b231230413230e Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Jun 2009 13:19:41 +0100 Subject: [PATCH 04/12] sonicFoam solver and tutorial updates --- .../solvers/compressible/sonicFoam/UEqn.H | 8 +++ .../sonicFoam/compressibleContinuityErrs.H | 12 ----- .../compressible/sonicFoam/createFields.H | 8 +-- .../solvers/compressible/sonicFoam/eEqn.H | 12 +++++ .../solvers/compressible/sonicFoam/hEqn.H | 12 ----- .../solvers/compressible/sonicFoam/pEqn.H | 37 ++++++++++++++ .../sonicFoam/readThermodynamicProperties.H | 23 --------- .../sonicFoam/readTransportProperties.H | 18 ------- .../compressible/sonicFoam/sonicFoam.C | 51 ++----------------- tutorials/compressible/sonicFoam/Allrun | 5 ++ .../compressible/sonicFoam/laminar/Allrun | 22 ++++++++ .../constant/thermophysicalProperties | 23 +++++++++ ...ansportProperties => turbulenceProperties} | 6 +-- .../laminar/forwardStep/system/fvSchemes | 8 +-- .../constant/thermophysicalProperties | 23 +++++++++ ...ansportProperties => turbulenceProperties} | 6 +-- .../laminar/shockTube/system/fvSchemes | 6 ++- .../constant/thermophysicalProperties | 4 +- .../constant/turbulenceProperties} | 8 ++- .../ras/nacaAirfoil/system/controlDict | 7 ++- .../ras/nacaAirfoil/system/fvSchemes | 6 +-- .../ras/nacaAirfoil/system/fvSolution | 2 +- .../prism/constant/thermophysicalProperties | 6 +-- .../prism/constant/turbulenceProperties} | 8 ++- .../sonicFoam/ras/prism/system/fvSchemes | 6 +-- .../sonicFoam/ras/prism/system/fvSolution | 2 +- 26 files changed, 176 insertions(+), 153 deletions(-) create mode 100644 applications/solvers/compressible/sonicFoam/UEqn.H delete mode 100644 applications/solvers/compressible/sonicFoam/compressibleContinuityErrs.H create mode 100644 applications/solvers/compressible/sonicFoam/eEqn.H delete mode 100644 applications/solvers/compressible/sonicFoam/hEqn.H create mode 100644 applications/solvers/compressible/sonicFoam/pEqn.H delete mode 100644 applications/solvers/compressible/sonicFoam/readThermodynamicProperties.H delete mode 100644 applications/solvers/compressible/sonicFoam/readTransportProperties.H create mode 100755 tutorials/compressible/sonicFoam/Allrun create mode 100755 tutorials/compressible/sonicFoam/laminar/Allrun create mode 100644 tutorials/compressible/sonicFoam/laminar/forwardStep/constant/thermophysicalProperties rename tutorials/compressible/sonicFoam/laminar/forwardStep/constant/{transportProperties => turbulenceProperties} (84%) create mode 100644 tutorials/compressible/sonicFoam/laminar/shockTube/constant/thermophysicalProperties rename tutorials/compressible/sonicFoam/laminar/shockTube/constant/{transportProperties => turbulenceProperties} (84%) rename tutorials/compressible/sonicFoam/{laminar/shockTube/constant/thermodynamicProperties => ras/nacaAirfoil/constant/turbulenceProperties} (79%) rename tutorials/compressible/sonicFoam/{laminar/forwardStep/constant/thermodynamicProperties => ras/prism/constant/turbulenceProperties} (79%) diff --git a/applications/solvers/compressible/sonicFoam/UEqn.H b/applications/solvers/compressible/sonicFoam/UEqn.H new file mode 100644 index 0000000000..25506783ae --- /dev/null +++ b/applications/solvers/compressible/sonicFoam/UEqn.H @@ -0,0 +1,8 @@ +fvVectorMatrix UEqn +( + fvm::ddt(rho, U) + + fvm::div(phi, U) + + turbulence->divDevRhoReff(U) +); + +solve(UEqn == -fvc::grad(p)); diff --git a/applications/solvers/compressible/sonicFoam/compressibleContinuityErrs.H b/applications/solvers/compressible/sonicFoam/compressibleContinuityErrs.H deleted file mode 100644 index 128d99c946..0000000000 --- a/applications/solvers/compressible/sonicFoam/compressibleContinuityErrs.H +++ /dev/null @@ -1,12 +0,0 @@ -{ -# include "rhoEqn.H" -} -{ - scalar sumLocalContErr = (sum(mag(rho - psi*p))/sum(rho)).value(); - scalar globalContErr = (sum(rho - psi*p)/sum(rho)).value(); - cumulativeContErr += globalContErr; - - Info<< "time step continuity errors : sum local = " << sumLocalContErr - << ", global = " << globalContErr - << ", cumulative = " << cumulativeContErr << endl; -} diff --git a/applications/solvers/compressible/sonicFoam/createFields.H b/applications/solvers/compressible/sonicFoam/createFields.H index bbb5d10526..5d03dd2bb7 100644 --- a/applications/solvers/compressible/sonicFoam/createFields.H +++ b/applications/solvers/compressible/sonicFoam/createFields.H @@ -7,7 +7,7 @@ basicPsiThermo& thermo = pThermo(); volScalarField& p = thermo.p(); - volScalarField& h = thermo.h(); + volScalarField& e = thermo.e(); const volScalarField& psi = thermo.psi(); volScalarField rho @@ -35,7 +35,7 @@ mesh ); -# include "compressibleCreatePhi.H" + #include "compressibleCreatePhi.H" Info<< "Creating turbulence model\n" << endl; @@ -49,7 +49,3 @@ thermo ) ); - - Info<< "Creating field DpDt\n" << endl; - volScalarField DpDt = - fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); diff --git a/applications/solvers/compressible/sonicFoam/eEqn.H b/applications/solvers/compressible/sonicFoam/eEqn.H new file mode 100644 index 0000000000..1d1d6aef0b --- /dev/null +++ b/applications/solvers/compressible/sonicFoam/eEqn.H @@ -0,0 +1,12 @@ +{ + solve + ( + fvm::ddt(rho, e) + + fvm::div(phi, e) + - fvm::laplacian(turbulence->alphaEff(), e) + == + - p*fvc::div(phi/fvc::interpolate(rho)) + ); + + thermo.correct(); +} diff --git a/applications/solvers/compressible/sonicFoam/hEqn.H b/applications/solvers/compressible/sonicFoam/hEqn.H deleted file mode 100644 index baa2dab343..0000000000 --- a/applications/solvers/compressible/sonicFoam/hEqn.H +++ /dev/null @@ -1,12 +0,0 @@ -{ - solve - ( - fvm::ddt(rho, h) - + fvm::div(phi, h) - - fvm::laplacian(turbulence->alphaEff(), h) - == - DpDt - ); - - thermo.correct(); -} diff --git a/applications/solvers/compressible/sonicFoam/pEqn.H b/applications/solvers/compressible/sonicFoam/pEqn.H new file mode 100644 index 0000000000..96a500d4c2 --- /dev/null +++ b/applications/solvers/compressible/sonicFoam/pEqn.H @@ -0,0 +1,37 @@ +rho = thermo.rho(); + +volScalarField rUA = 1.0/UEqn.A(); +U = rUA*UEqn.H(); + +surfaceScalarField phid +( + "phid", + fvc::interpolate(psi) + *( + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phi) + ) +); + +for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) +{ + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvm::div(phid, p) + - fvm::laplacian(rho*rUA, p) + ); + + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi = pEqn.flux(); + } +} + +#include "rhoEqn.H" +#include "compressibleContinuityErrs.H" + +U -= rUA*fvc::grad(p); +U.correctBoundaryConditions(); diff --git a/applications/solvers/compressible/sonicFoam/readThermodynamicProperties.H b/applications/solvers/compressible/sonicFoam/readThermodynamicProperties.H deleted file mode 100644 index 1fc57fc5fd..0000000000 --- a/applications/solvers/compressible/sonicFoam/readThermodynamicProperties.H +++ /dev/null @@ -1,23 +0,0 @@ - Info<< "Reading thermodynamicProperties\n" << endl; - - IOdictionary thermodynamicProperties - ( - IOobject - ( - "thermodynamicProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); - - dimensionedScalar R - ( - thermodynamicProperties.lookup("R") - ); - - dimensionedScalar Cv - ( - thermodynamicProperties.lookup("Cv") - ); diff --git a/applications/solvers/compressible/sonicFoam/readTransportProperties.H b/applications/solvers/compressible/sonicFoam/readTransportProperties.H deleted file mode 100644 index 1502e2033a..0000000000 --- a/applications/solvers/compressible/sonicFoam/readTransportProperties.H +++ /dev/null @@ -1,18 +0,0 @@ - Info<< "Reading transportProperties\n" << endl; - - IOdictionary transportProperties - ( - IOobject - ( - "transportProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); - - dimensionedScalar mu - ( - transportProperties.lookup("mu") - ); diff --git a/applications/solvers/compressible/sonicFoam/sonicFoam.C b/applications/solvers/compressible/sonicFoam/sonicFoam.C index c9eda00fa3..df100262ef 100644 --- a/applications/solvers/compressible/sonicFoam/sonicFoam.C +++ b/applications/solvers/compressible/sonicFoam/sonicFoam.C @@ -58,64 +58,21 @@ int main(int argc, char *argv[]) #include "rhoEqn.H" - fvVectorMatrix UEqn - ( - fvm::ddt(rho, U) - + fvm::div(phi, U) - + turbulence->divDevRhoReff(U) - ); + #include "UEqn.H" - solve(UEqn == -fvc::grad(p)); - - #include "hEqn.H" + #include "eEqn.H" // --- PISO loop for (int corr=0; corrcorrect(); - rho = psi*p; + rho = thermo.rho(); runTime.write(); diff --git a/tutorials/compressible/sonicFoam/Allrun b/tutorials/compressible/sonicFoam/Allrun new file mode 100755 index 0000000000..4f1a1e464a --- /dev/null +++ b/tutorials/compressible/sonicFoam/Allrun @@ -0,0 +1,5 @@ +#!/bin/sh +set -x + +(cd laminar && ./Allrun) +(cd ras && ./Allrun) diff --git a/tutorials/compressible/sonicFoam/laminar/Allrun b/tutorials/compressible/sonicFoam/laminar/Allrun new file mode 100755 index 0000000000..573ff3a12d --- /dev/null +++ b/tutorials/compressible/sonicFoam/laminar/Allrun @@ -0,0 +1,22 @@ +#!/bin/sh +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +# Get application name from directory +application=sonicFoam + +cases=" \ +forwardStep \ +shockTube \ +" +for case in $cases +do + (cd $case && runApplication blockMesh) +# + if [ "$case" = "shockTube" ] ; then + (cd $case && ./Allrun) + else + (cd $case && runApplication $application) + fi +# +done diff --git a/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/thermophysicalProperties b/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/thermophysicalProperties new file mode 100644 index 0000000000..82d43de570 --- /dev/null +++ b/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/thermophysicalProperties @@ -0,0 +1,23 @@ +/*--------------------------------*- 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 ePsiThermo>>>>; + +mixture air 1 11640.31 1.78571 0 0 0.7; + + +// ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/transportProperties b/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/turbulenceProperties similarity index 84% rename from tutorials/compressible/sonicFoam/laminar/forwardStep/constant/transportProperties rename to tutorials/compressible/sonicFoam/laminar/forwardStep/constant/turbulenceProperties index 1e9d5be60c..c2c3b28a1b 100644 --- a/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/transportProperties +++ b/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/turbulenceProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -11,11 +11,11 @@ FoamFile format ascii; class dictionary; location "constant"; - object transportProperties; + object turbulenceProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -mu mu [ 1 -1 -1 0 0 0 0 ] 0; +simulationType laminar; // ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/laminar/forwardStep/system/fvSchemes b/tutorials/compressible/sonicFoam/laminar/forwardStep/system/fvSchemes index 1c36c50aa6..6bebe35dfb 100644 --- a/tutorials/compressible/sonicFoam/laminar/forwardStep/system/fvSchemes +++ b/tutorials/compressible/sonicFoam/laminar/forwardStep/system/fvSchemes @@ -30,17 +30,19 @@ gradSchemes divSchemes { default none; - div(phi,U) Gauss limitedLinearV 1; + div(phi,U) Gauss upwind; div(phid,p) Gauss limitedLinear 1; div(phi,e) Gauss limitedLinear 1; + div(phiU,p) Gauss limitedLinear 1; + div((muEff*dev2(grad(U).T()))) Gauss linear 1; } laplacianSchemes { default none; - laplacian(mu,U) Gauss linear corrected; - laplacian(mu,e) Gauss linear corrected; laplacian((rho*(1|A(U))),p) Gauss linear corrected; + laplacian(muEff,U) Gauss linear corrected; + laplacian(alphaEff,e) Gauss linear corrected; } interpolationSchemes diff --git a/tutorials/compressible/sonicFoam/laminar/shockTube/constant/thermophysicalProperties b/tutorials/compressible/sonicFoam/laminar/shockTube/constant/thermophysicalProperties new file mode 100644 index 0000000000..2560f39757 --- /dev/null +++ b/tutorials/compressible/sonicFoam/laminar/shockTube/constant/thermophysicalProperties @@ -0,0 +1,23 @@ +/*--------------------------------*- 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 ePsiThermo>>>>; + +mixture air 1 28.9 717.5 0 0 0.7; + + +// ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/laminar/shockTube/constant/transportProperties b/tutorials/compressible/sonicFoam/laminar/shockTube/constant/turbulenceProperties similarity index 84% rename from tutorials/compressible/sonicFoam/laminar/shockTube/constant/transportProperties rename to tutorials/compressible/sonicFoam/laminar/shockTube/constant/turbulenceProperties index 1e9d5be60c..c2c3b28a1b 100644 --- a/tutorials/compressible/sonicFoam/laminar/shockTube/constant/transportProperties +++ b/tutorials/compressible/sonicFoam/laminar/shockTube/constant/turbulenceProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -11,11 +11,11 @@ FoamFile format ascii; class dictionary; location "constant"; - object transportProperties; + object turbulenceProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -mu mu [ 1 -1 -1 0 0 0 0 ] 0; +simulationType laminar; // ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/laminar/shockTube/system/fvSchemes b/tutorials/compressible/sonicFoam/laminar/shockTube/system/fvSchemes index deef4abd26..6bebe35dfb 100644 --- a/tutorials/compressible/sonicFoam/laminar/shockTube/system/fvSchemes +++ b/tutorials/compressible/sonicFoam/laminar/shockTube/system/fvSchemes @@ -33,14 +33,16 @@ divSchemes div(phi,U) Gauss upwind; div(phid,p) Gauss limitedLinear 1; div(phi,e) Gauss limitedLinear 1; + div(phiU,p) Gauss limitedLinear 1; + div((muEff*dev2(grad(U).T()))) Gauss linear 1; } laplacianSchemes { default none; - laplacian(mu,U) Gauss linear corrected; - laplacian(mu,e) Gauss linear corrected; laplacian((rho*(1|A(U))),p) Gauss linear corrected; + laplacian(muEff,U) Gauss linear corrected; + laplacian(alphaEff,e) Gauss linear corrected; } interpolationSchemes diff --git a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/constant/thermophysicalProperties b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/constant/thermophysicalProperties index 97425177af..5580ffd632 100644 --- a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/constant/thermophysicalProperties +++ b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/constant/thermophysicalProperties @@ -15,9 +15,9 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -thermoType hPsiThermo>>>>; +thermoType ePsiThermo>>>>; -mixture air 1 28.9 1000 2.544e+06 1.8e-05 0.7; +mixture air 1 28.9 717.5 0 1.8e-05 0.7; // ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/laminar/shockTube/constant/thermodynamicProperties b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/constant/turbulenceProperties similarity index 79% rename from tutorials/compressible/sonicFoam/laminar/shockTube/constant/thermodynamicProperties rename to tutorials/compressible/sonicFoam/ras/nacaAirfoil/constant/turbulenceProperties index 99575bf65f..3721a46a2e 100644 --- a/tutorials/compressible/sonicFoam/laminar/shockTube/constant/thermodynamicProperties +++ b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/constant/turbulenceProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -11,13 +11,11 @@ FoamFile format ascii; class dictionary; location "constant"; - object thermodynamicProperties; + object turbulenceProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Cv Cv [ 0 2 -2 -1 0 0 0 ] 717.5; - -R R [ 0 2 -2 -1 0 0 0 ] 287; +simulationType RASModel; // ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/controlDict b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/controlDict index ce2e9218c9..aad6ecd97e 100644 --- a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/controlDict +++ b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/controlDict @@ -49,7 +49,12 @@ functions { type forceCoeffs; functionObjectLibs ( "libforces.so" ); - patches ( WALL10 ); + outputControl timeStep; + outputInterval 1; + patches + ( + WALL10 + ); pName p; UName U; log true; diff --git a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/fvSchemes b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/fvSchemes index 0cab17b88e..444443d62d 100644 --- a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/fvSchemes +++ b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/fvSchemes @@ -35,7 +35,7 @@ divSchemes div(R) Gauss linear; div(phid,p) Gauss limitedLinear 1; div(phiU,p) Gauss limitedLinear 1; - div(phi,h) Gauss limitedLinear 1; + div(phi,e) Gauss limitedLinear 1; div((muEff*dev2(grad(U).T()))) Gauss linear; } @@ -47,7 +47,7 @@ laplacianSchemes laplacian(DREff,R) Gauss linear limited 0.5; laplacian(DepsilonEff,epsilon) Gauss linear limited 0.5; laplacian((rho*(1|A(U))),p) Gauss linear limited 0.5; - laplacian(alphaEff,h) Gauss linear limited 0.5; + laplacian(alphaEff,e) Gauss linear limited 0.5; } interpolationSchemes @@ -63,7 +63,7 @@ snGradSchemes fluxRequired { default no; - p ; + p; } diff --git a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/fvSolution b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/fvSolution index a1782db685..d46dcd13cf 100644 --- a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/fvSolution +++ b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/fvSolution @@ -41,7 +41,7 @@ solvers relTol 0; } - h + e { solver PBiCG; preconditioner DILU; diff --git a/tutorials/compressible/sonicFoam/ras/prism/constant/thermophysicalProperties b/tutorials/compressible/sonicFoam/ras/prism/constant/thermophysicalProperties index 39b28b3681..5580ffd632 100644 --- a/tutorials/compressible/sonicFoam/ras/prism/constant/thermophysicalProperties +++ b/tutorials/compressible/sonicFoam/ras/prism/constant/thermophysicalProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -15,9 +15,9 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -thermoType hPsiThermo>>>>; +thermoType ePsiThermo>>>>; -mixture air 1 28.9 1300 2.544e+06 1.84e-05 0.7; +mixture air 1 28.9 717.5 0 1.8e-05 0.7; // ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/thermodynamicProperties b/tutorials/compressible/sonicFoam/ras/prism/constant/turbulenceProperties similarity index 79% rename from tutorials/compressible/sonicFoam/laminar/forwardStep/constant/thermodynamicProperties rename to tutorials/compressible/sonicFoam/ras/prism/constant/turbulenceProperties index c6bf31c073..3721a46a2e 100644 --- a/tutorials/compressible/sonicFoam/laminar/forwardStep/constant/thermodynamicProperties +++ b/tutorials/compressible/sonicFoam/ras/prism/constant/turbulenceProperties @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -11,13 +11,11 @@ FoamFile format ascii; class dictionary; location "constant"; - object thermodynamicProperties; + object turbulenceProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Cv Cv [ 0 2 -2 -1 0 0 0 ] 1.78571; - -R R [ 0 2 -2 -1 0 0 0 ] 0.714286; +simulationType RASModel; // ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/ras/prism/system/fvSchemes b/tutorials/compressible/sonicFoam/ras/prism/system/fvSchemes index 7b3c03466f..9737d97c28 100644 --- a/tutorials/compressible/sonicFoam/ras/prism/system/fvSchemes +++ b/tutorials/compressible/sonicFoam/ras/prism/system/fvSchemes @@ -35,7 +35,7 @@ divSchemes div(R) Gauss linear; div(phid,p) Gauss limitedLinear 1; div(phiU,p) Gauss limitedLinear 1; - div(phi,h) Gauss limitedLinear 1; + div(phi,e) Gauss limitedLinear 1; div((muEff*dev2(grad(U).T()))) Gauss linear; } @@ -47,7 +47,7 @@ laplacianSchemes laplacian(DREff,R) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; laplacian((rho*(1|A(U))),p) Gauss linear corrected; - laplacian(alphaEff,h) Gauss linear corrected; + laplacian(alphaEff,e) Gauss linear corrected; } interpolationSchemes @@ -63,7 +63,7 @@ snGradSchemes fluxRequired { default no; - p ; + p; } diff --git a/tutorials/compressible/sonicFoam/ras/prism/system/fvSolution b/tutorials/compressible/sonicFoam/ras/prism/system/fvSolution index 5341a980f4..5ff77210a9 100644 --- a/tutorials/compressible/sonicFoam/ras/prism/system/fvSolution +++ b/tutorials/compressible/sonicFoam/ras/prism/system/fvSolution @@ -41,7 +41,7 @@ solvers relTol 0; } - h + e { solver PBiCG; preconditioner DILU; From 1aab4aaec8e4e669487ca5a62960f1b502b0ecdd Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Jun 2009 16:24:26 +0100 Subject: [PATCH 05/12] changed comment; added faceZoneToCell source --- src/meshTools/Make/files | 1 + .../faceZoneToCell/faceZoneToCell.C | 185 ++++++++++++++++++ .../faceZoneToCell/faceZoneToCell.H | 138 +++++++++++++ .../sets/cellSources/zoneToCell/zoneToCell.C | 3 +- .../faceSources/patchToFace/patchToFace.C | 2 +- .../sets/faceSources/zoneToFace/zoneToFace.C | 3 +- .../pointSources/zoneToPoint/zoneToPoint.C | 3 +- 7 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C create mode 100644 src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index d5133cb33d..a61d00246e 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -90,6 +90,7 @@ $(cellSources)/nbrToCell/nbrToCell.C $(cellSources)/zoneToCell/zoneToCell.C $(cellSources)/sphereToCell/sphereToCell.C $(cellSources)/cylinderToCell/cylinderToCell.C +$(cellSources)/faceZoneToCell/faceZoneToCell.C faceSources = sets/faceSources $(faceSources)/faceToFace/faceToFace.C diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C new file mode 100644 index 0000000000..526620fe14 --- /dev/null +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C @@ -0,0 +1,185 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "faceZoneToCell.H" +#include "polyMesh.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(faceZoneToCell, 0); + +addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word); + +addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::faceZoneToCell::usage_ +( + faceZoneToCell::typeName, + "\n Usage: faceZoneToCell zone master|slave\n\n" + " Select master or slave side of the faceZone." + " Note:accepts wildcards for zone.\n\n" +); + + +template<> +const char* Foam::NamedEnum::names[] = +{ + "master", + "slave" +}; + + +const Foam::NamedEnum + Foam::faceZoneToCell::faceActionNames_; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const +{ + bool hasMatched = false; + + forAll(mesh_.faceZones(), i) + { + const faceZone& zone = mesh_.faceZones()[i]; + + if (zoneName_.match(zone.name())) + { + const labelList& cellLabels = + ( + option_ == MASTER + ? zone.masterCells() + : zone.slaveCells() + ); + + Info<< " Found matching zone " << zone.name() + << " with " << cellLabels.size() << " cells on selected side." + << endl; + + hasMatched = true; + + forAll(cellLabels, i) + { + // Only do active cells + if (cellLabels[i] < mesh_.nCells()) + { + addOrDelete(set, cellLabels[i], add); + } + } + } + } + + if (!hasMatched) + { + WarningIn("faceZoneToCell::combine(topoSet&, const bool)") + << "Cannot find any faceZone named " << zoneName_ << endl + << "Valid names are " << mesh_.faceZones().names() << endl; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::faceZoneToCell::faceZoneToCell +( + const polyMesh& mesh, + const word& zoneName, + const faceAction option +) +: + topoSetSource(mesh), + zoneName_(zoneName), + option_(option) +{} + + +// Construct from dictionary +Foam::faceZoneToCell::faceZoneToCell +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + zoneName_(dict.lookup("name")), + option_(faceActionNames_.read(dict.lookup("option"))) +{} + + +// Construct from Istream +Foam::faceZoneToCell::faceZoneToCell +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + zoneName_(checkIs(is)), + option_(faceActionNames_.read(checkIs(is))) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::faceZoneToCell::~faceZoneToCell() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::faceZoneToCell::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding all " << faceActionNames_[option_] + << " cells of faceZone " << zoneName_ << " ..." << endl; + + combine(set, true); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing all " << faceActionNames_[option_] + << " cells of faceZone " << zoneName_ << " ..." << endl; + + combine(set, false); + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H new file mode 100644 index 0000000000..b09c58399f --- /dev/null +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H @@ -0,0 +1,138 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::faceZoneToCell + +Description + A topoSetSource to select cells based on side of faceZone. + +SourceFiles + faceZoneToCell.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceZoneToCell_H +#define faceZoneToCell_H + +#include "topoSetSource.H" +#include "wordRe.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class faceZoneToCell Declaration +\*---------------------------------------------------------------------------*/ + +class faceZoneToCell +: + public topoSetSource +{ +public: + //- Enumeration defining the valid options + enum faceAction + { + MASTER, + SLAVE + }; + +private: + + // Private data + + static const NamedEnum faceActionNames_; + + //- Add usage string + static addToUsageTable usage_; + + //- Name/regular expression of faceZone + wordRe zoneName_; + + //- Option + faceAction option_; + + + // Private Member Functions + + void combine(topoSet& set, const bool add) const; + + +public: + + //- Runtime type information + TypeName("faceZoneToCell"); + + // Constructors + + //- Construct from components + faceZoneToCell + ( + const polyMesh& mesh, + const word& zoneName, + const faceAction option + ); + + //- Construct from dictionary + faceZoneToCell + ( + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from Istream + faceZoneToCell + ( + const polyMesh& mesh, + Istream& + ); + + + // Destructor + + virtual ~faceZoneToCell(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C index 0dcd1e0ffb..14b6deb7f3 100644 --- a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C +++ b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C @@ -47,7 +47,8 @@ Foam::topoSetSource::addToUsageTable Foam::zoneToCell::usage_ ( zoneToCell::typeName, "\n Usage: zoneToCell zone\n\n" - " Select all cells in the cellZone\n\n" + " Select all cells in the cellZone." + " Note:accepts wildcards for zone.\n\n" ); diff --git a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C index 9bcf49690f..000db639a9 100644 --- a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C +++ b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C @@ -49,7 +49,7 @@ Foam::topoSetSource::addToUsageTable Foam::patchToFace::usage_ ( patchToFace::typeName, "\n Usage: patchToFace patch\n\n" - " Select all faces in the patch\n\n" + " Select all faces in the patch. Note:accepts wildcards for patch.\n\n" ); diff --git a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C index 12cbab560d..465632f2b1 100644 --- a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C +++ b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C @@ -47,7 +47,8 @@ Foam::topoSetSource::addToUsageTable Foam::zoneToFace::usage_ ( zoneToFace::typeName, "\n Usage: zoneToFace zone\n\n" - " Select all faces in the faceZone\n\n" + " Select all faces in the faceZone." + " Note:accepts wildcards for zone.\n\n" ); diff --git a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C index 4b5148c558..0558093afa 100644 --- a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C +++ b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C @@ -47,7 +47,8 @@ Foam::topoSetSource::addToUsageTable Foam::zoneToPoint::usage_ ( zoneToPoint::typeName, "\n Usage: zoneToPoint zone\n\n" - " Select all points in the pointZone\n\n" + " Select all points in the pointZone." + " Note:accepts wildcards for zone.\n\n" ); From 6c994a32d6ecb0628ffa08b58792937596ac0767 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Jun 2009 17:24:08 +0100 Subject: [PATCH 06/12] updated example dictionaries for new sources --- .../mesh/manipulation/cellSet/cellSetDict | 56 ++++++++++++------- .../mesh/manipulation/pointSet/pointSetDict | 18 ++++-- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/applications/utilities/mesh/manipulation/cellSet/cellSetDict b/applications/utilities/mesh/manipulation/cellSet/cellSetDict index 95465d8f54..fd11ab871d 100644 --- a/applications/utilities/mesh/manipulation/cellSet/cellSetDict +++ b/applications/utilities/mesh/manipulation/cellSet/cellSetDict @@ -26,12 +26,31 @@ action new; topoSetSources ( + // Select by explicitly providing cell labels + labelToCell + { + value (12 13 56); // labels of cells + } + // Copy elements from cellSet cellToCell { set c1; } + // Cells in cell zone + zoneToCell + { + name ".*Zone"; // Name of cellZone, regular expressions allowed + } + + // Cells on master or slave side of faceZone + faceZoneToCell + { + name ".*Zone"; // Name of faceZone, regular expressions allowed + option master; // master/slave + } + // Select based on faceSet faceToCell { @@ -51,12 +70,6 @@ topoSetSources //option all; // cell with all points in pointSet } - // Select by explicitly providing cell labels - labelToCell - { - value (12 13 56); // labels of cells - } - // Select based on cellShape shapeToCell { @@ -87,7 +100,6 @@ topoSetSources radius 5.0; } - // Cells with centre within sphere sphereToCell { @@ -95,20 +107,6 @@ topoSetSources radius 5.0; } - // Cells in cell zone - zoneToCell - { - name ".*Zone"; // Name of cellZone, regular expressions allowed - } - - // values of field within certain range - fieldToCell - { - fieldName U; // Note: uses mag(U) since volVectorField - min 0.1; - max 0.5; - } - // Cells with cellCentre nearest to coordinates nearestToCell { @@ -129,6 +127,22 @@ topoSetSources // and near surf curvature // (set to -100 if not used) } + + // values of field within certain range + fieldToCell + { + fieldName U; // Note: uses mag(U) since volVectorField + min 0.1; + max 0.5; + } + + // Mesh region (non-face connected part of (subset of)mesh) + regionToCell + { + set c0; // name of cellSet giving mesh subset + insidePoint (1 2 3); // point inside region to select + } + ); diff --git a/applications/utilities/mesh/manipulation/pointSet/pointSetDict b/applications/utilities/mesh/manipulation/pointSet/pointSetDict index 1c704a1868..895dcd7f0a 100644 --- a/applications/utilities/mesh/manipulation/pointSet/pointSetDict +++ b/applications/utilities/mesh/manipulation/pointSet/pointSetDict @@ -51,18 +51,24 @@ topoSetSources value (12 13 56); // labels of points } - // Points with coordinate within box - boxToPoint - { - box (0 0 0) (1 1 1); - } - // All points in pointzone zoneToPoint { name ".*Zone"; // name of pointZone, regular expressions allowed } + // Points nearest to coordinates + nearestToPoint + { + points ((0 0 0) (1 1 1)); + } + + // Points with coordinate within box + boxToPoint + { + box (0 0 0) (1 1 1); + } + // Select based on surface surfaceToPoint { From 794c658140c117e3dcb532aecc148463926a18f0 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Jun 2009 19:34:21 +0100 Subject: [PATCH 07/12] added some more global access methods --- .../polyMesh/globalMeshData/globalIndex.H | 12 +++++-- .../polyMesh/globalMeshData/globalIndexI.H | 34 +++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H index 0ed207057a..e394f679d0 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H @@ -106,6 +106,15 @@ public: //- Global sum of localSizes inline label size() const; + //- Size of procI data + inline label localSize(const label procI) const; + + //- From local to global on procI + inline label toGlobal(const label procI, const label i) const; + + //- Is on processor procI + inline bool isLocal(const label procI, const label i) const; + //- From global to local on procI inline label toLocal(const label procI, const label i) const; @@ -115,9 +124,6 @@ public: //- Start of procI data inline label offset(const label procI) const; - //- Size of procI data - inline label localSize(const label procI) const; - // IOstream Operators diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H index f9444fe54b..d7c44107c6 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H @@ -63,27 +63,39 @@ inline Foam::label Foam::globalIndex::size() const } -inline Foam::label Foam::globalIndex::toGlobal(const label i) const +inline Foam::label Foam::globalIndex::toGlobal +( + const label procI, + const label i +) const { - return - ( - Pstream::myProcNo() == 0 - ? i - : i + offsets_[Pstream::myProcNo()-1] - ); + return(procI == 0 ? i : i + offsets_[procI-1]); } + +inline Foam::label Foam::globalIndex::toGlobal(const label i) const +{ + return toGlobal(Pstream::myProcNo(), i); +} + + //- Is on local processor -inline bool Foam::globalIndex::isLocal(const label i) const +inline bool Foam::globalIndex::isLocal(const label procI, const label i) const { return - (i < offsets_[Pstream::myProcNo()]) - && (i >= (Pstream::myProcNo() == 0 ? 0 : offsets_[Pstream::myProcNo()-1])); + (i < offsets_[procI]) + && (i >= (procI == 0 ? 0 : offsets_[procI-1])); +} + + +inline bool Foam::globalIndex::isLocal(const label i) const +{ + return isLocal(Pstream::myProcNo(), i); } inline Foam::label Foam::globalIndex::toLocal(const label procI, const label i) - const +const { label localI = (procI == 0 ? i : i - offsets_[procI-1]); From 70dfaf64566de4e22a03eca0318e3222f144cd25 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Jun 2009 19:34:37 +0100 Subject: [PATCH 08/12] moved message printing --- .../utilities/mesh/generation/blockMesh/mergePatchPairs.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H b/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H index 3347db180b..aeb3137adf 100644 --- a/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H +++ b/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H @@ -1,7 +1,7 @@ - Info<< "Creating merge patch pairs" << nl << endl; - if (mergePatchPairs.size()) { + Info<< "Creating merge patch pairs" << nl << endl; + // Create and add point and face zones and mesh modifiers List pz(mergePatchPairs.size()); List fz(3*mergePatchPairs.size()); From 0f7eb36836adebaf8188a31517315a4b9fabc70b Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Jun 2009 19:35:17 +0100 Subject: [PATCH 09/12] double registering of dictionary --- .../incompressible/channelFoam/readTransportProperties.H | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/solvers/incompressible/channelFoam/readTransportProperties.H b/applications/solvers/incompressible/channelFoam/readTransportProperties.H index c99d0ae4b5..87c93c9195 100644 --- a/applications/solvers/incompressible/channelFoam/readTransportProperties.H +++ b/applications/solvers/incompressible/channelFoam/readTransportProperties.H @@ -7,7 +7,8 @@ runTime.constant(), mesh, IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + false ) ); From 0ae328ecedea439a9d62f444248da1d8d44888c0 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Jun 2009 23:41:16 +0100 Subject: [PATCH 10/12] surface following bc for use with 3D displacement solver --- src/fvMotionSolver/Make/files | 1 + ...surfaceDisplacementPointPatchVectorField.C | 514 ++++++++++++++++++ ...surfaceDisplacementPointPatchVectorField.H | 223 ++++++++ ...aceSlipDisplacementPointPatchVectorField.C | 50 +- ...aceSlipDisplacementPointPatchVectorField.H | 58 +- 5 files changed, 777 insertions(+), 69 deletions(-) create mode 100644 src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C create mode 100644 src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.H diff --git a/src/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index 41f31c0ecc..f229ae322e 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -30,5 +30,6 @@ pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPo pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C LIB = $(FOAM_LIBBIN)/libfvMotionSolvers diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C new file mode 100644 index 0000000000..bbafb189fa --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C @@ -0,0 +1,514 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "surfaceDisplacementPointPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "Time.H" +#include "transformField.H" +#include "fvMesh.H" +#include "displacementLaplacianFvMotionSolver.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template<> +const char* +NamedEnum:: +names[] = +{ + "nearest", + "pointNormal", + "fixedNormal" +}; + +const NamedEnum + surfaceDisplacementPointPatchVectorField::projectModeNames_; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void surfaceDisplacementPointPatchVectorField::calcProjection +( + vectorField& displacement +) const +{ + const polyMesh& mesh = patch().boundaryMesh().mesh()(); + const pointField& localPoints = patch().localPoints(); + const labelList& meshPoints = patch().meshPoints(); + + //const scalar deltaT = mesh.time().deltaT().value(); + + // Construct large enough vector in direction of projectDir so + // we're guaranteed to hit something. + + //- Per point projection vector: + const scalar projectLen = mag(mesh.bounds().max()-mesh.bounds().min()); + + // For case of fixed projection vector: + vector projectVec; + if (projectMode_ == FIXEDNORMAL) + { + vector n = projectDir_/mag(projectDir_); + projectVec = projectLen*n; + } + + + // Get fixed points (bit of a hack) + const pointZone* zonePtr = NULL; + + if (frozenPointsZone_.size() > 0) + { + const pointZoneMesh& pZones = mesh.pointZones(); + + zonePtr = &pZones[pZones.findZoneID(frozenPointsZone_)]; + + Pout<< "surfaceDisplacementPointPatchVectorField : Fixing all " + << zonePtr->size() << " points in pointZone " << zonePtr->name() + << endl; + } + + // Get the starting locations from the motionSolver + const pointField& points0 = mesh.lookupObject + ( + "dynamicMeshDict" + ).points0(); + + + pointField start(meshPoints.size()); + forAll(start, i) + { + start[i] = points0[meshPoints[i]] + displacement[i]; + } + + label nNotProjected = 0; + + if (projectMode_ == NEAREST) + { + List nearest; + labelList hitSurfaces; + surfaces().findNearest + ( + start, + scalarField(start.size(), sqr(projectLen)), + hitSurfaces, + nearest + ); + + forAll(nearest, i) + { + if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0)) + { + // Fixed point. Reset to point0 location. + displacement[i] = points0[meshPoints[i]] - localPoints[i]; + } + else if (nearest[i].hit()) + { + displacement[i] = + nearest[i].hitPoint() + - points0[meshPoints[i]]; + } + else + { + nNotProjected++; + + if (debug) + { + Pout<< " point:" << meshPoints[i] + << " coord:" << localPoints[i] + << " did not find any surface within " << projectLen + << endl; + } + } + } + } + else + { + // Do tests on all points. Combine later on. + + // 1. Check if already on surface + List nearest; + { + labelList nearestSurface; + surfaces().findNearest + ( + start, + scalarField(start.size(), sqr(SMALL)), + nearestSurface, + nearest + ); + } + + // 2. intersection. (combined later on with information from nearest + // above) + vectorField projectVecs(start.size(), projectVec); + + if (projectMode_ == POINTNORMAL) + { + projectVecs = projectLen*patch().pointNormals(); + } + + // Knock out any wedge component + scalarField offset(start.size(), 0.0); + if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents) + { + forAll(offset, i) + { + offset[i] = start[i][wedgePlane_]; + start[i][wedgePlane_] = 0; + projectVecs[i][wedgePlane_] = 0; + } + } + + List rightHit; + { + labelList rightSurf; + surfaces().findAnyIntersection + ( + start, + start+projectVecs, + rightSurf, + rightHit + ); + } + + List leftHit; + { + labelList leftSurf; + surfaces().findAnyIntersection + ( + start, + start-projectVecs, + leftSurf, + leftHit + ); + } + + // 3. Choose either -fixed, nearest, right, left. + forAll(displacement, i) + { + if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0)) + { + // Fixed point. Reset to point0 location. + displacement[i] = points0[meshPoints[i]] - localPoints[i]; + } + else if (nearest[i].hit()) + { + // Found nearest. + displacement[i] = + nearest[i].hitPoint() + - points0[meshPoints[i]]; + } + else + { + pointIndexHit interPt; + + if (rightHit[i].hit()) + { + if (leftHit[i].hit()) + { + if + ( + magSqr(rightHit[i].hitPoint()-start[i]) + < magSqr(leftHit[i].hitPoint()-start[i]) + ) + { + interPt = rightHit[i]; + } + else + { + interPt = leftHit[i]; + } + } + else + { + interPt = rightHit[i]; + } + } + else + { + if (leftHit[i].hit()) + { + interPt = leftHit[i]; + } + } + + + if (interPt.hit()) + { + if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents) + { + interPt.rawPoint()[wedgePlane_] += offset[i]; + } + displacement[i] = interPt.rawPoint()-points0[meshPoints[i]]; + } + else + { + nNotProjected++; + + if (debug) + { + Pout<< " point:" << meshPoints[i] + << " coord:" << localPoints[i] + << " did not find any intersection between" + << " ray from " << start[i]-projectVecs[i] + << " to " << start[i]+projectVecs[i] << endl; + } + } + } + } + } + + reduce(nNotProjected, sumOp