From 9782a6e9fa113f82578c29d7c7f058b008486a27 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 15 Jun 2011 15:13:49 +0100 Subject: [PATCH 1/9] ENH: Added defaultCoeffs option to spray break-up models --- .../intermediate/submodels/SubModelBase.C | 17 +++++++++- .../intermediate/submodels/SubModelBase.H | 6 ++-- .../spray/submodels/BreakupModel/ETAB/ETAB.C | 32 +++++++++---------- .../BreakupModel/PilchErdman/PilchErdman.C | 12 +++++-- .../BreakupModel/ReitzDiwakar/ReitzDiwakar.C | 18 ++++++++--- .../BreakupModel/ReitzKHRT/ReitzKHRT.C | 31 ++++++++++-------- .../spray/submodels/BreakupModel/SHF/SHF.C | 2 +- 7 files changed, 76 insertions(+), 42 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/SubModelBase.C b/src/lagrangian/intermediate/submodels/SubModelBase.C index 527342d174..5f8b988276 100644 --- a/src/lagrangian/intermediate/submodels/SubModelBase.C +++ b/src/lagrangian/intermediate/submodels/SubModelBase.C @@ -90,6 +90,21 @@ const Foam::dictionary& Foam::SubModelBase::coeffDict() const } +template +bool Foam::SubModelBase::defaultCoeffs(const bool printMsg) const +{ + bool def = coeffDict_.lookupOrDefault("defaultCoeffs", false); + if (printMsg && def) + { + Info<< incrIndent; + Info<< indent << "Employing default coefficients" << endl; + Info<< decrIndent; + } + + return def; +} + + template CloudType& Foam::SubModelBase::owner() { @@ -105,7 +120,7 @@ bool Foam::SubModelBase::active() const template -void Foam::SubModelBase::cacheFields(const bool) +void Foam::SubModelBase::cacheFields(const bool) { // do nothing } diff --git a/src/lagrangian/intermediate/submodels/SubModelBase.H b/src/lagrangian/intermediate/submodels/SubModelBase.H index d5cc8a53bd..c94947e80f 100644 --- a/src/lagrangian/intermediate/submodels/SubModelBase.H +++ b/src/lagrangian/intermediate/submodels/SubModelBase.H @@ -63,11 +63,10 @@ protected: //- Reference to the cloud dictionary const dictionary& dict_; - //- Reference to the coefficients dictionary + //- Coefficients dictionary const dictionary& coeffDict_; - public: // Constructors @@ -108,6 +107,9 @@ public: //- Return const access to the coefficients dictionary const dictionary& coeffDict() const; + //- Returns true if defaultCoeffs is true and outputs on printMsg + bool defaultCoeffs(const bool printMsg) const; + //- Return the model 'active' status - default active = true virtual bool active() const; diff --git a/src/lagrangian/spray/submodels/BreakupModel/ETAB/ETAB.C b/src/lagrangian/spray/submodels/BreakupModel/ETAB/ETAB.C index 1ba28effe1..ce9eb40916 100644 --- a/src/lagrangian/spray/submodels/BreakupModel/ETAB/ETAB.C +++ b/src/lagrangian/spray/submodels/BreakupModel/ETAB/ETAB.C @@ -35,24 +35,24 @@ Foam::ETAB::ETAB ) : BreakupModel(dict, owner, typeName), - Cmu_(this->coeffDict().template lookupOrDefault("Cmu", 10.0)), - Comega_(this->coeffDict().template lookupOrDefault("Comega", 8.0)), - k1_(this->coeffDict().template lookupOrDefault("k1", 0.2)), - k2_(this->coeffDict().template lookupOrDefault("k2", 0.2)), - WeCrit_ -( - this->coeffDict().template lookupOrDefault("WeCrit", 12.0) -), - WeTransition_ - ( - this->coeffDict().template lookupOrDefault - ( - "WeTransition", - 100.0 - ) - ), + Cmu_(10.0), + Comega_(8.0), + k1_(0.2), + k2_(0.2), + WeCrit_(12.0), + WeTransition_(100.0), AWe_(0.0) { + if (!this->defaultCoeffs(true)) + { + this->coeffDict().lookup("Cmu") >> Cmu_; + this->coeffDict().lookup("Comega") >> Comega_; + this->coeffDict().lookup("k1") >> k1_; + this->coeffDict().lookup("k2") >> k2_; + this->coeffDict().lookup("WeCrit") >> WeCrit_; + this->coeffDict().lookup("WeTransition") >> WeTransition_; + } + scalar k21 = k2_/k1_; AWe_ = (k21*sqrt(WeTransition_) - 1.0)/pow4(WeTransition_); diff --git a/src/lagrangian/spray/submodels/BreakupModel/PilchErdman/PilchErdman.C b/src/lagrangian/spray/submodels/BreakupModel/PilchErdman/PilchErdman.C index a3a6cdd2f9..65ba5498ce 100644 --- a/src/lagrangian/spray/submodels/BreakupModel/PilchErdman/PilchErdman.C +++ b/src/lagrangian/spray/submodels/BreakupModel/PilchErdman/PilchErdman.C @@ -35,9 +35,15 @@ Foam::PilchErdman::PilchErdman ) : BreakupModel(dict, owner, typeName), - B1_(this->coeffDict().template lookupOrDefault("B1", 0.375)), - B2_(this->coeffDict().template lookupOrDefault("B2", 0.236)) -{} + B1_(0.375), + B2_(0.236) +{ + if (!this->defaultCoeffs(true)) + { + this->coeffDict().lookup("B1") >> B1_; + this->coeffDict().lookup("B2") >> B2_; + } +} template diff --git a/src/lagrangian/spray/submodels/BreakupModel/ReitzDiwakar/ReitzDiwakar.C b/src/lagrangian/spray/submodels/BreakupModel/ReitzDiwakar/ReitzDiwakar.C index 1ff7327986..c9cb30ff2b 100644 --- a/src/lagrangian/spray/submodels/BreakupModel/ReitzDiwakar/ReitzDiwakar.C +++ b/src/lagrangian/spray/submodels/BreakupModel/ReitzDiwakar/ReitzDiwakar.C @@ -35,11 +35,19 @@ Foam::ReitzDiwakar::ReitzDiwakar ) : BreakupModel(dict, owner, typeName), - Cbag_(this->coeffDict().template lookupOrDefault("Cbag", 6.0)), - Cb_(this->coeffDict().template lookupOrDefault("Cb", 0.785)), - Cstrip_(this->coeffDict().template lookupOrDefault("Cstrip", 0.5)), - Cs_(this->coeffDict().template lookupOrDefault("Cs", 10.0)) -{} + Cbag_(6.0), + Cb_(0.785), + Cstrip_(0.5), + Cs_(10.0) +{ + if (!this->defaultCoeffs(true)) + { + this->coeffDict().lookup("Cbag") >> Cbag_; + this->coeffDict().lookup("Cb") >> Cb_; + this->coeffDict().lookup("Cstrip") >> Cstrip_; + this->coeffDict().lookup("Cs") >> Cs_; + } +} template diff --git a/src/lagrangian/spray/submodels/BreakupModel/ReitzKHRT/ReitzKHRT.C b/src/lagrangian/spray/submodels/BreakupModel/ReitzKHRT/ReitzKHRT.C index 0e8835c75c..e0bc8b3721 100644 --- a/src/lagrangian/spray/submodels/BreakupModel/ReitzKHRT/ReitzKHRT.C +++ b/src/lagrangian/spray/submodels/BreakupModel/ReitzKHRT/ReitzKHRT.C @@ -35,20 +35,23 @@ Foam::ReitzKHRT::ReitzKHRT ) : BreakupModel(dict, owner, typeName), - b0_(this->coeffDict().template lookupOrDefault("B0", 0.61)), - b1_(this->coeffDict().template lookupOrDefault("B1", 40.0)), - cTau_(this->coeffDict().template lookupOrDefault("Ctau", 1.0)), - cRT_(this->coeffDict().template lookupOrDefault("CRT", 0.1)), - msLimit_ - ( - this->coeffDict().template lookupOrDefault - ( - "msLimit", - 0.03 - ) - ), - weberLimit_(readScalar(this->coeffDict().lookup("WeberLimit"))) -{} + b0_(0.61), + b1_(40.0), + cTau_(1.0), + cRT_(0.1), + msLimit_(0.03), + weberLimit_(6.0) +{ + if (!this->defaultCoeffs(true)) + { + this->coeffDict().lookup("B0") >> b0_; + this->coeffDict().lookup("B1") >> b1_; + this->coeffDict().lookup("Ctau") >> cTau_; + this->coeffDict().lookup("CRT") >> cRT_; + this->coeffDict().lookup("msLimit") >> msLimit_; + this->coeffDict().lookup("WeberLimit") >> weberLimit_; + } +} template diff --git a/src/lagrangian/spray/submodels/BreakupModel/SHF/SHF.C b/src/lagrangian/spray/submodels/BreakupModel/SHF/SHF.C index 73dd7cc401..a705c37096 100644 --- a/src/lagrangian/spray/submodels/BreakupModel/SHF/SHF.C +++ b/src/lagrangian/spray/submodels/BreakupModel/SHF/SHF.C @@ -142,7 +142,7 @@ bool Foam::SHF::update { bool addChild = false; - scalar d03 = pow(d, 3); + scalar d03 = pow3(d); scalar rhopi6 = rho*constant::mathematical::pi/6.0; scalar mass0 = nParticle*rhopi6*d03; scalar mass = mass0; From 7412ca8952d7e3db30fc217c8cb0ff40111594a1 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 15 Jun 2011 16:37:58 +0100 Subject: [PATCH 2/9] ENH: Use range insertion. Move storeSizesAndAlignments out of insertInitialPoints. --- .../conformalVoronoiMesh.C | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 9993162a93..5157f3c580 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -272,18 +272,19 @@ void Foam::conformalVoronoiMesh::insertPoints label nVert = number_of_vertices(); - Info<< "TEMPORARILY USING INDIVIDUAL INSERTION TO DETECT FAILURE" << endl; // using the range insert (faster than inserting points one by one) - // insert(points.begin(), points.end()); - for - ( - std::list::iterator pit=points.begin(); - pit != points.end(); - ++pit - ) - { - insertVb(*pit); - } + insert(points.begin(), points.end()); + + // Info<< "USING INDIVIDUAL INSERTION TO DETECT FAILURE" << endl; + // for + // ( + // std::list::iterator pit=points.begin(); + // pit != points.end(); + // ++pit + // ) + // { + // insertVb(*pit); + // } label nInserted(number_of_vertices() - preInsertionSize); @@ -1167,12 +1168,6 @@ void Foam::conformalVoronoiMesh::insertInitialPoints() writePoints("initialPoints.obj", true); } - Info<< "NEED TO CHANGE storeSizesAndAlignments AFTER DISTRIBUTE" << endl; - Info<< "NEED TO MAP FEATURE POINTS AFTER DISTRIBUTE" << endl; - Info<< "NEED TO ENSURE THAT FEATURE POINTS ARE INSERTED ON THE " - << "CORRECT PRCOESSOR" << endl; - - storeSizesAndAlignments(initPts); } @@ -1808,6 +1803,13 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh insertFeaturePoints(); + Info<< "NEED TO MAP FEATURE POINTS AFTER DISTRIBUTE" << endl; + Info<< "NEED TO ENSURE THAT FEATURE POINTS ARE INSERTED ON THE " + << "CORRECT PROCESSOR" << endl; + + Info<< "NEED TO CHANGE storeSizesAndAlignments AFTER DISTRIBUTE" << endl; + // storeSizesAndAlignments(initPts); + buildSurfaceConformation(rmCoarse); // The introduction of the surface conformation may have distorted the From 1f61715738cf805bbbf9b5c126060aba5c802c22 Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 16 Jun 2011 14:57:54 +0100 Subject: [PATCH 3/9] ENH: Distributing and storing feature points, surface conformation and sizes. --- .../conformalVoronoiMesh.C | 178 +++++++++++++----- .../conformalVoronoiMesh.H | 40 +++- .../conformalVoronoiMeshConformToSurface.C | 51 ++++- .../conformalVoronoiMeshI.H | 60 +++--- .../conformalVoronoiMesh/indexedVertex.H | 67 +++---- 5 files changed, 266 insertions(+), 130 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 5157f3c580..208dba1083 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -283,7 +283,7 @@ void Foam::conformalVoronoiMesh::insertPoints // ++pit // ) // { - // insertVb(*pit); + // insertPoint(topoint(*pit), Vb::ptInternalPoint); // } label nInserted(number_of_vertices() - preInsertionSize); @@ -318,6 +318,10 @@ void Foam::conformalVoronoiMesh::insertPoints bool distribute ) { + // The pts, indices and types lists must be intact and up-to-date at the + // end of this function as they may also be used by other functions + // subsequently. + if (Pstream::parRun() && distribute) { // The link between vertices that form the boundary via pairs cannot be @@ -363,7 +367,6 @@ void Foam::conformalVoronoiMesh::insertPoints if (type > Vb::ptFarPoint) { // This is a member of a point pair, don't use the type directly - type += number_of_vertices(); } @@ -750,6 +753,7 @@ void Foam::conformalVoronoiMesh::insertFeaturePoints() createMixedFeaturePoints(pts, indices, types); + // Insert the created points, distributing to the appropriate processor insertPoints(pts, indices, types, true); if(cvMeshControls().objOutput()) @@ -770,27 +774,15 @@ void Foam::conformalVoronoiMesh::insertFeaturePoints() << " feature vertices" << endl; } - Info<< "SORT OUT FEATURE POINT DISTRIBUTION AND STORAGE" << endl; + featureVertices_.clear(); - // featureVertices_.setSize(number_of_vertices()); - - // label featPtI = 0; - - // for - // ( - // Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); - // vit != finite_vertices_end(); - // vit++ - // ) - // { - // featureVertices_[featPtI] = Vb(vit->point()); - - // featureVertices_[featPtI].index() = vit->index(); - - // featureVertices_[featPtI].type() = vit->type(); - - // featPtI++; - // } + forAll(pts, pI) + { + featureVertices_.push_back + ( + Vb(toPoint(pts[pI]), indices[pI], types[pI]) + ); + } constructFeaturePointLocations(); } @@ -1066,14 +1058,72 @@ void Foam::conformalVoronoiMesh::constructFeaturePointLocations() } -void Foam::conformalVoronoiMesh::reinsertFeaturePoints() +void Foam::conformalVoronoiMesh::reinsertFeaturePoints(bool distribute) { Info<< nl << "Reinserting stored feature points" << endl; - forAll(featureVertices_, f) + label preReinsertionSize(number_of_vertices()); + + if (distribute) { - insertVb(featureVertices_[f]); + DynamicList pointsToInsert; + DynamicList