1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "CollidingCloud.H"
27 #include "CollisionModel.H"
29 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
31 template<class CloudType>
32 void Foam::CollidingCloud<CloudType>::setModels()
36 CollisionModel<CollidingCloud<CloudType> >::New
38 this->subModelProperties(),
45 template<class CloudType>
46 template<class TrackData>
47 void Foam::CollidingCloud<CloudType>::moveCollide
53 td.part() = TrackData::tpVelocityHalfStep;
54 CloudType::move(td, deltaT);
56 td.part() = TrackData::tpLinearTrack;
57 CloudType::move(td, deltaT);
59 // td.part() = TrackData::tpRotationalTrack;
60 // CloudType::move(td);
62 this->updateCellOccupancy();
64 this->collision().collide();
66 td.part() = TrackData::tpVelocityHalfStep;
67 CloudType::move(td, deltaT);
72 template<class CloudType>
73 void Foam::CollidingCloud<CloudType>::cloudReset(CollidingCloud<CloudType>& c)
75 CloudType::cloudReset(c);
77 collisionModel_.reset(c.collisionModel_.ptr());
81 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
83 template<class CloudType>
84 Foam::CollidingCloud<CloudType>::CollidingCloud
86 const word& cloudName,
87 const volScalarField& rho,
88 const volVectorField& U,
89 const volScalarField& mu,
90 const dimensionedVector& g,
94 CloudType(cloudName, rho, U, mu, g, false),
97 if (this->solution().steadyState())
101 "Foam::CollidingCloud<CloudType>::CollidingCloud"
104 "const volScalarField&, "
105 "const volVectorField&, "
106 "const volScalarField&, "
107 "const dimensionedVector&, "
110 ) << "Collision modelling not currently available for steady state "
111 << "calculations" << exit(FatalError);
114 if (this->solution().active())
120 parcelType::readFields(*this);
126 template<class CloudType>
127 Foam::CollidingCloud<CloudType>::CollidingCloud
129 CollidingCloud<CloudType>& c,
134 collisionModel_(c.collisionModel_->clone())
138 template<class CloudType>
139 Foam::CollidingCloud<CloudType>::CollidingCloud
143 const CollidingCloud<CloudType>& c
146 CloudType(mesh, name, c),
147 collisionModel_(NULL)
151 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
153 template<class CloudType>
154 Foam::CollidingCloud<CloudType>::~CollidingCloud()
158 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
160 template<class CloudType>
161 bool Foam::CollidingCloud<CloudType>::hasWallImpactDistance() const
163 return !collision().controlsWallInteraction();
167 template<class CloudType>
168 void Foam::CollidingCloud<CloudType>::storeState()
172 static_cast<CollidingCloud<CloudType>*>
174 clone(this->name() + "Copy").ptr()
180 template<class CloudType>
181 void Foam::CollidingCloud<CloudType>::restoreState()
183 cloudReset(cloudCopyPtr_());
184 cloudCopyPtr_.clear();
188 template<class CloudType>
189 void Foam::CollidingCloud<CloudType>::evolve()
191 if (this->solution().canEvolve())
193 typename parcelType::template
194 TrackingData<CollidingCloud<CloudType> > td(*this);
201 template<class CloudType>
202 template<class TrackData>
203 void Foam::CollidingCloud<CloudType>::motion(TrackData& td)
205 // Sympletic leapfrog integration of particle forces:
206 // + apply half deltaV with stored force
207 // + move positions with new velocity
208 // + calculate forces in new position
209 // + apply half deltaV with new force
211 label nSubCycles = collision().nSubCycles();
215 Info<< " " << nSubCycles << " move-collide subCycles" << endl;
217 subCycleTime moveCollideSubCycle
219 const_cast<Time&>(this->db().time()),
223 while(!(++moveCollideSubCycle).end())
225 moveCollide(td, this->db().time().deltaTValue());
228 moveCollideSubCycle.endSubCycle();
232 moveCollide(td, this->db().time().deltaTValue());
237 // ************************************************************************* //