1+ /*------------------------------- phasicFlow ---------------------------------
2+ O C enter of
3+ O O E ngineering and
4+ O O M ultiscale modeling of
5+ OOOOOOO F luid flow
6+ ------------------------------------------------------------------------------
7+ Copyright (C): www.cemf.ir
8+ email: hamid.r.norouzi AT gmail.com
9+ ------------------------------------------------------------------------------
10+ Licence:
11+ This file is part of phasicFlow code. It is a free software for simulating
12+ granular and multiphase flows. You can redistribute it and/or modify it under
13+ the terms of GNU General Public License v3 or any other later versions.
14+
15+ phasicFlow is distributed to help others in their research in the field of
16+ granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18+
19+ -----------------------------------------------------------------------------*/
20+
21+ // from OpenFOAM
22+ #include "fvCFD.H"
23+
24+
25+ #include "diffusion.hpp"
26+
27+
28+ Foam ::tmp < Foam ::fvMatrix < Foam ::scalar >> pFlow ::coupling ::diffusion ::fvmDdt
29+ (
30+ const Foam ::volScalarField & sField
31+ )
32+ {
33+ Foam ::tmp < fvMatrix < Foam ::scalar >> tfvm
34+ (
35+ new Foam ::fvMatrix < Foam ::scalar >
36+ (
37+ sField ,
38+ sField .dimensions ()* Foam ::dimVol /Foam ::dimTime
39+ )
40+ );
41+
42+ Foam ::fvMatrix < Foam ::scalar > & fvm = tfvm .ref ();
43+
44+ const Foam ::scalar rDeltaT = 1.0 /dt_ .value ();
45+
46+ fvm .diag () = rDeltaT * sField .mesh ().Vsc ();
47+
48+ if (sField .mesh ().moving ())
49+ {
50+ fvm .source () = rDeltaT * sField .oldTime ().primitiveField ()* sField .mesh ().Vsc0 ();
51+ }
52+ else
53+ {
54+ fvm .source () = rDeltaT * sField .oldTime ().primitiveField ()* sField .mesh ().Vsc ();
55+ }
56+
57+ return tfvm ;
58+ }
59+
60+ pFlow ::coupling ::diffusion ::diffusion (
61+ Foam ::dictionary dict ,
62+ couplingMesh & cMesh ,
63+ MPI ::centerMassField & centerMass ,
64+ MPI ::realProcCMField & parDiam )
65+ :
66+ PIC (dict , cMesh , centerMass , parDiam ),
67+ nSteps_ (Foam ::max (1 ,dict .lookup < Foam ::label > ("nSteps" ))),
68+ intTime_ (dict .lookup < Foam ::scalar > ("intTime" )),
69+ dt_ ("dt" , Foam ::dimTime , intTime_ /nSteps_ ),
70+ picSolDict_ ("picSolDict" )
71+ {
72+
73+ picSolDict_ .add ("relTol" , 0 );
74+ picSolDict_ .add ("tolerance" , 1.0e-8 );
75+ picSolDict_ .add ("solver" , "smoothSolver" );
76+ picSolDict_ .add ("smoother" , "symGaussSeidel" );
77+ }
78+
79+
80+ bool pFlow ::coupling ::diffusion ::internalFieldUpdate ()
81+ {
82+
83+ auto solidVoldTmp = Foam ::volScalarField ::Internal ::New (
84+ "solidVol" ,
85+ this -> mesh (),
86+ Foam ::dimensioned ("solidVol" , Foam ::dimVol , Foam ::scalar (0 ))
87+ );
88+
89+ auto& solidVol = solidVoldTmp .ref ();
90+
91+ size_t numPar = centerMass_ .size ();
92+
93+ #pragma omp parallel for
94+ for (size_t i = 0 ; i < numPar ; i ++ )
95+ {
96+ const auto cellId = parCellIndex_ [i ];
97+ if ( cellId >= 0 )
98+ {
99+ #pragma omp atomic
100+ solidVol [cellId ] +=
101+ static_cast < real > (3.14159265358979 /6 )*
102+ pFlow ::pow (particleDiameter_ [i ], static_cast < real > (3.0 ));
103+
104+ }
105+ }
106+
107+ auto picAlphaTmp = Foam ::volScalarField ::New (
108+ "picAlpha" ,
109+ this -> mesh (),
110+ Foam ::dimensioned ("picAlpha" , Foam ::dimless , Foam ::scalar (0 )),
111+ "zeroGradient"
112+ );
113+
114+ volScalarField & picAlpha = picAlphaTmp .ref ();
115+
116+
117+ picAlpha .ref () = Foam ::max ( 1 - solidVol /this -> mesh ().V (), 0.0 );
118+ picAlpha .correctBoundaryConditions ();
119+
120+
121+ // start of Time loop
122+ for (Foam ::label i = 0 ; i < nSteps_ ; i ++ )
123+ {
124+ picAlpha .storeOldTime ();
125+ fvScalarMatrix alphaEq
126+ (
127+ fvmDdt (picAlpha ) - fvm ::laplacian (picAlpha )
128+ );
129+ alphaEq .solve (picSolDict_ );
130+ }
131+
132+ this -> ref () = picAlpha .internalField ();
133+
134+ return true;
135+ }
0 commit comments