-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from hamidrezanorouzi/main
diffusion model for porosity is added, base class porosity is modified
- Loading branch information
Showing
14 changed files
with
345 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/*------------------------------- phasicFlow --------------------------------- | ||
O C enter of | ||
O O E ngineering and | ||
O O M ultiscale modeling of | ||
OOOOOOO F luid flow | ||
------------------------------------------------------------------------------ | ||
Copyright (C): www.cemf.ir | ||
email: hamid.r.norouzi AT gmail.com | ||
------------------------------------------------------------------------------ | ||
Licence: | ||
This file is part of phasicFlow code. It is a free software for simulating | ||
granular and multiphase flows. You can redistribute it and/or modify it under | ||
the terms of GNU General Public License v3 or any other later versions. | ||
phasicFlow is distributed to help others in their research in the field of | ||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the | ||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
-----------------------------------------------------------------------------*/ | ||
|
||
// from OpenFOAM | ||
#include "fvCFD.H" | ||
|
||
|
||
#include "diffusion.hpp" | ||
|
||
|
||
Foam::tmp<Foam::fvMatrix<Foam::scalar>> pFlow::coupling::diffusion::fvmDdt | ||
( | ||
const Foam::volScalarField& sField | ||
) | ||
{ | ||
Foam::tmp<fvMatrix<Foam::scalar>> tfvm | ||
( | ||
new Foam::fvMatrix<Foam::scalar> | ||
( | ||
sField, | ||
sField.dimensions()*Foam::dimVol/Foam::dimTime | ||
) | ||
); | ||
|
||
Foam::fvMatrix<Foam::scalar>& fvm = tfvm.ref(); | ||
|
||
const Foam::scalar rDeltaT = 1.0/dt_.value(); | ||
|
||
fvm.diag() = rDeltaT*sField.mesh().Vsc(); | ||
|
||
if (sField.mesh().moving()) | ||
{ | ||
fvm.source() = rDeltaT*sField.oldTime().primitiveField()*sField.mesh().Vsc0(); | ||
} | ||
else | ||
{ | ||
fvm.source() = rDeltaT*sField.oldTime().primitiveField()*sField.mesh().Vsc(); | ||
} | ||
|
||
return tfvm; | ||
} | ||
|
||
pFlow::coupling::diffusion::diffusion( | ||
Foam::dictionary dict, | ||
couplingMesh& cMesh, | ||
MPI::centerMassField& centerMass, | ||
MPI::realProcCMField& parDiam) | ||
: | ||
PIC(dict, cMesh, centerMass, parDiam), | ||
nSteps_(Foam::max(1,dict.lookup<Foam::label>("nSteps"))), | ||
intTime_(dict.lookup<Foam::scalar>("intTime")), | ||
dt_("dt", Foam::dimTime, intTime_/nSteps_), | ||
picSolDict_("picSolDict") | ||
{ | ||
|
||
picSolDict_.add("relTol", 0); | ||
picSolDict_.add("tolerance", 1.0e-8); | ||
picSolDict_.add("solver", "smoothSolver"); | ||
picSolDict_.add("smoother", "symGaussSeidel"); | ||
} | ||
|
||
|
||
bool pFlow::coupling::diffusion::internalFieldUpdate() | ||
{ | ||
|
||
auto solidVoldTmp = Foam::volScalarField::Internal::New( | ||
"solidVol", | ||
this->mesh(), | ||
Foam::dimensioned("solidVol", Foam::dimVol, Foam::scalar(0)) | ||
); | ||
|
||
auto& solidVol = solidVoldTmp.ref(); | ||
|
||
size_t numPar = centerMass_.size(); | ||
|
||
#pragma omp parallel for | ||
for(size_t i=0; i<numPar; i++) | ||
{ | ||
const auto cellId = parCellIndex_[i]; | ||
if( cellId >= 0 ) | ||
{ | ||
#pragma omp atomic | ||
solidVol[cellId] += | ||
static_cast<real>(3.14159265358979/6)* | ||
pFlow::pow(particleDiameter_[i], static_cast<real>(3.0)); | ||
|
||
} | ||
} | ||
|
||
auto picAlphaTmp = Foam::volScalarField::New( | ||
"picAlpha", | ||
this->mesh(), | ||
Foam::dimensioned("picAlpha", Foam::dimless, Foam::scalar(0)), | ||
"zeroGradient" | ||
); | ||
|
||
volScalarField& picAlpha = picAlphaTmp.ref(); | ||
|
||
|
||
picAlpha.ref() = Foam::max( 1 - solidVol/this->mesh().V(), 0.0); | ||
picAlpha.correctBoundaryConditions(); | ||
|
||
|
||
// start of Time loop | ||
for(Foam::label i=0; i<nSteps_; i++) | ||
{ | ||
picAlpha.storeOldTime(); | ||
fvScalarMatrix alphaEq | ||
( | ||
fvmDdt(picAlpha) - fvm::laplacian(picAlpha) | ||
); | ||
alphaEq.solve(picSolDict_); | ||
} | ||
|
||
this->ref() = picAlpha.internalField(); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/*------------------------------- phasicFlow --------------------------------- | ||
O C enter of | ||
O O E ngineering and | ||
O O M ultiscale modeling of | ||
OOOOOOO F luid flow | ||
------------------------------------------------------------------------------ | ||
Copyright (C): www.cemf.ir | ||
email: hamid.r.norouzi AT gmail.com | ||
------------------------------------------------------------------------------ | ||
Licence: | ||
This file is part of phasicFlow code. It is a free software for simulating | ||
granular and multiphase flows. You can redistribute it and/or modify it under | ||
the terms of GNU General Public License v3 or any other later versions. | ||
phasicFlow is distributed to help others in their research in the field of | ||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the | ||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
-----------------------------------------------------------------------------*/ | ||
|
||
#ifndef __diffusion_hpp__ | ||
#define __diffusion_hpp__ | ||
|
||
#include "virtualConstructor.hpp" | ||
|
||
// from phasicFlow-coupling | ||
#include "PIC.hpp" | ||
|
||
|
||
namespace pFlow::coupling | ||
{ | ||
|
||
/** | ||
* Particle In Cell (diffusion) model for porosity calculation | ||
* | ||
* This model only considers the particle center and if the particle center | ||
* resides inside a cell, it is assumed that the whole volume of the particle | ||
* is located in that cell. | ||
* | ||
*/ | ||
class diffusion | ||
: | ||
public PIC | ||
{ | ||
private: | ||
|
||
Foam::label nSteps_; | ||
|
||
Foam::scalar intTime_; | ||
|
||
Foam::dimensionedScalar dt_; | ||
|
||
Foam::dictionary picSolDict_; | ||
|
||
Foam::tmp<Foam::fvMatrix<Foam::scalar>> fvmDdt | ||
( | ||
const Foam::volScalarField& sField | ||
); | ||
|
||
public: | ||
|
||
/// Type info | ||
TypeInfo("diffusion"); | ||
|
||
/// Construc from dictionary | ||
diffusion( | ||
Foam::dictionary dict, | ||
couplingMesh& cMesh, | ||
MPI::centerMassField& centerMass, | ||
MPI::realProcCMField& parDiam); | ||
|
||
/// Destructor | ||
virtual ~diffusion() = default; | ||
|
||
/// Add this constructor to the list of virtual constructors | ||
add_vCtor | ||
( | ||
porosity, | ||
diffusion, | ||
dictionary | ||
); | ||
|
||
bool internalFieldUpdate() override; | ||
|
||
|
||
}; | ||
|
||
} // pFlow::coupling | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.