├── tests └── simple3dMesh │ ├── open.foam │ ├── README │ ├── constant │ ├── turbulenceProperties │ ├── g │ ├── RASProperties │ ├── transportProperties │ └── polyMesh │ │ ├── boundaryFixed │ │ └── blockMeshDict │ ├── system │ ├── mirrorMeshDict_X │ ├── mirrorMeshDict_Y │ ├── decomposeParDict │ ├── topoSetDict │ ├── setFieldsDict │ ├── createBafflesDict │ ├── controlDict │ ├── fvSchemes │ └── fvSolution │ ├── setup.sh │ └── initialFields │ ├── p │ ├── m_A │ └── U ├── .spyderproject ├── src ├── solvers │ ├── potentialSalt │ │ ├── Make │ │ │ ├── files │ │ │ └── options │ │ ├── readControls.H │ │ ├── createFields.H │ │ └── potentialSalt.C │ ├── pisoSaltTransport │ │ ├── Make │ │ │ ├── files │ │ │ └── options │ │ ├── m_AInitialContinuity.H │ │ ├── m_AEqn.H │ │ ├── m_AContinuity.H │ │ ├── UEqn.H │ │ ├── readControls.H │ │ ├── pEqn.H │ │ ├── createFields.H │ │ └── pisoSaltTransport.C │ ├── simpleSaltDiffusion │ │ ├── Make │ │ │ ├── files │ │ │ └── options │ │ ├── m_AEqn.H │ │ ├── createFields.H │ │ └── simpleSaltDiffusion.C │ ├── simpleSaltTransport │ │ ├── Make │ │ │ ├── files │ │ │ └── options │ │ ├── UEqn.H │ │ ├── m_AEqn.H │ │ ├── pEqn.H │ │ ├── createFields.H │ │ └── simpleSaltTransport.C │ └── simplePorousSaltTransport │ │ ├── Make │ │ ├── files │ │ └── options │ │ ├── rpEqn.H │ │ ├── m_AEqn.H │ │ ├── createZones.H │ │ ├── UEqn.H │ │ ├── pEqn.H │ │ ├── simplePorousSaltTransport.C │ │ └── createFields.H ├── utilities │ └── sampleMembrane │ │ ├── Make │ │ ├── files │ │ └── options │ │ └── sampleMembrane.C ├── porosityModels │ ├── Make │ │ ├── files │ │ └── options │ └── DarcyForchheimerSaltTransport │ │ ├── DarcyForchheimerSaltTransportTemplates.C │ │ ├── DarcyForchheimerSaltTransport.H │ │ ├── porosityModel.C │ │ ├── DarcyForchheimerSaltTransport.C │ │ └── porosityModel.H └── boundaryConditions │ ├── Make │ ├── options │ └── files │ ├── RO_BC │ ├── explicitROmembraneVelocity │ │ ├── explicitROmembraneVelocityFvPatchVectorField.H │ │ └── explicitROmembraneVelocityFvPatchVectorField.C │ └── explicitROmembraneSolute │ │ ├── explicitROmembraneSoluteFvPatchScalarField.C │ │ └── explicitROmembraneSoluteFvPatchScalarField.H │ └── FO_BC │ ├── explicitFOmembraneVelocity │ └── explicitFOmembraneVelocityFvPatchVectorField.H │ └── explicitFOmembraneSolute │ ├── explicitFOmembraneSoluteFvPatchScalarField.H │ └── explicitFOmembraneSoluteFvPatchScalarField.C ├── .gitignore ├── Allwclean ├── Allwmake └── README.md /tests/simple3dMesh/open.foam: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.spyderproject: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MathiasGruber/MembraneFoam/HEAD/.spyderproject -------------------------------------------------------------------------------- /src/solvers/potentialSalt/Make/files: -------------------------------------------------------------------------------- 1 | potentialSalt.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/potentialSalt 4 | -------------------------------------------------------------------------------- /src/utilities/sampleMembrane/Make/files: -------------------------------------------------------------------------------- 1 | sampleMembrane.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/sampleMembrane 4 | -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/Make/files: -------------------------------------------------------------------------------- 1 | pisoSaltTransport.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/pisoSaltTransport 4 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltDiffusion/Make/files: -------------------------------------------------------------------------------- 1 | simpleSaltDiffusion.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/simpleSaltDiffusion 4 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltTransport/Make/files: -------------------------------------------------------------------------------- 1 | simpleSaltTransport.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/simpleSaltTransport 4 | -------------------------------------------------------------------------------- /src/solvers/simplePorousSaltTransport/Make/files: -------------------------------------------------------------------------------- 1 | simplePorousSaltTransport.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/simplePorousSaltTransport 4 | -------------------------------------------------------------------------------- /src/porosityModels/Make/files: -------------------------------------------------------------------------------- 1 | DarcyForchheimerSaltTransport/DarcyForchheimerSaltTransport.C 2 | 3 | LIB = $(FOAM_USER_LIBBIN)/libMFG_PorousModels 4 | -------------------------------------------------------------------------------- /src/utilities/sampleMembrane/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude 3 | 4 | EXE_LIBS = \ 5 | -lfiniteVolume \ 6 | -lgenericPatchFields 7 | -------------------------------------------------------------------------------- /src/solvers/potentialSalt/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/meshTools/lnInclude \ 3 | -I$(LIB_SRC)/finiteVolume/lnInclude 4 | 5 | EXE_LIBS = \ 6 | -lfiniteVolume \ 7 | -lxml2 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dep 2 | *.o 3 | lnInclude/ 4 | darwinIntel64ClangDPOpt/ 5 | utilities/* 6 | MembraneFoam.sublime-project 7 | MembraneFoam.sublime-workspace 8 | darwinIntel64Gcc46DPOpt/ 9 | GXM_pisoPorousSolver_v2/ -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/meshTools/lnInclude \ 3 | -I$(LIB_SRC)/finiteVolume/lnInclude 4 | 5 | EXE_LIBS = \ 6 | -lmeshTools \ 7 | -lfiniteVolume \ 8 | -lxml2 9 | -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/m_AInitialContinuity.H: -------------------------------------------------------------------------------- 1 | scalar m_A_influx = 0.0; 2 | scalar m_A_mass = fvc::domainIntegrate(rho0 * rho_mACoeff * m_A).value(); 3 | 4 | Info << "m_A: Initial mass = " << m_A_mass << endl << endl; 5 | -------------------------------------------------------------------------------- /src/solvers/potentialSalt/readControls.H: -------------------------------------------------------------------------------- 1 | const dictionary& potentialFlow = 2 | mesh.solutionDict().subDict("potentialFlow"); 3 | 4 | const int nNonOrthCorr = 5 | potentialFlow.lookupOrDefault("nNonOrthogonalCorrectors", 0); 6 | -------------------------------------------------------------------------------- /src/porosityModels/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/triSurface/lnInclude \ 3 | -I$(LIB_SRC)/meshTools/lnInclude \ 4 | -I$(LIB_SRC)/finiteVolume/lnInclude 5 | 6 | LIB_LIBS = \ 7 | -ltriSurface \ 8 | -lfiniteVolume \ 9 | -lmeshTools 10 | -------------------------------------------------------------------------------- /src/boundaryConditions/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/triSurface/lnInclude \ 3 | -I$(LIB_SRC)/meshTools/lnInclude \ 4 | -I$(LIB_SRC)/finiteVolume/lnInclude 5 | 6 | LIB_LIBS = \ 7 | -ltriSurface \ 8 | -lfiniteVolume \ 9 | -lmeshTools 10 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltTransport/UEqn.H: -------------------------------------------------------------------------------- 1 | volScalarField mu 2 | ( 3 | "mu", 4 | mu0 * (1 + mu_mACoeff * m_A) 5 | ); 6 | 7 | tmp UEqn 8 | ( 9 | fvm::div(phi, U) 10 | - fvm::laplacian(mu, U) 11 | - fvc::div(mu*dev2(fvc::grad(U)().T())) 12 | ); 13 | 14 | UEqn().relax(); -------------------------------------------------------------------------------- /Allwclean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ${0%/*} || exit 1 # run from this directory 3 | set -x 4 | 5 | wclean libso src/boundaryConditions 6 | 7 | wclean src/solvers/pisoSaltTransport 8 | wclean src/solvers/potentialSalt 9 | wclean src/solvers/simpleSaltTransport 10 | 11 | wclean src/utilities/sampleMembrane 12 | 13 | # ----------------------------------------------------------------- end-of-file 14 | -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/m_AEqn.H: -------------------------------------------------------------------------------- 1 | 2 | volScalarField rhoD_AB 3 | ( 4 | "rho*D_AB", 5 | rho * max(D_AB_Coeff * (1.0 - D_AB_mACoeff * m_A), D_AB_Min) 6 | ); 7 | 8 | solve 9 | ( 10 | fvm::ddt(rho,m_A) 11 | + fvm::div(phi, m_A) 12 | - fvm::laplacian(rhoD_AB, m_A) 13 | ); 14 | 15 | Info << m_A.name() << ": min = " << min(m_A).value() << " max = " << max(m_A).value() << endl; 16 | -------------------------------------------------------------------------------- /src/boundaryConditions/Make/files: -------------------------------------------------------------------------------- 1 | RO_BC/explicitROmembraneVelocity/explicitROmembraneVelocityFvPatchVectorField.C 2 | RO_BC/explicitROmembraneSolute/explicitROmembraneSoluteFvPatchScalarField.C 3 | FO_BC/explicitFOmembraneSolute/explicitFOmembraneSoluteFvPatchScalarField.C 4 | FO_BC/explicitFOmembraneVelocity/explicitFOmembraneVelocityFvPatchVectorField.C 5 | 6 | LIB = $(FOAM_USER_LIBBIN)/libDHIBoundaryConditions 7 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltTransport/m_AEqn.H: -------------------------------------------------------------------------------- 1 | rho = rho0 * (1.0 + rho_mACoeff * m_A); 2 | 3 | volScalarField rhoD_AB 4 | ( 5 | "rho*D_AB", 6 | rho * max(D_AB_Coeff * (1.0 - D_AB_mACoeff * m_A), D_AB_Min) 7 | ); 8 | 9 | fvScalarMatrix m_AEqn 10 | ( 11 | fvm::div(phi, m_A) 12 | - fvm::laplacian(rhoD_AB, m_A) 13 | ); 14 | 15 | // Relax to ensure diagonal-dominance 16 | m_AEqn.relax(); 17 | 18 | // Solve for solute 19 | solve(m_AEqn); -------------------------------------------------------------------------------- /src/solvers/simplePorousSaltTransport/rpEqn.H: -------------------------------------------------------------------------------- 1 | 2 | // Use vector identity Ei * grad(p) = div( p Ei ) 3 | // Solve as being equal to mu * laplacian( U ) for getting the real pressure 4 | 5 | surfaceScalarField sf = fvc::interpolate( UnityVectorField ) & mesh.Sf(); 6 | 7 | volScalarField RightHand = UnityVectorField & mu_laplacianU; 8 | 9 | tmp rpEqn 10 | ( 11 | fvm::div(sf, rP) - (UnityVectorField & (mu * fvc::laplacian( U ))) 12 | ); 13 | rpEqn().relax(); 14 | // solve(rpEqn); 15 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltTransport/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ 3 | -I$(LIB_SRC)/finiteVolume/cfdTools \ 4 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 5 | -I$(LIB_SRC)/sampling/lnInclude \ 6 | -I$(LIB_SRC)/meshTools/lnInclude \ 7 | -I$(LIB_SRC)/fvOptions/lnInclude 8 | 9 | EXE_LIBS = \ 10 | -lfluidThermophysicalModels \ 11 | -lspecie \ 12 | -lfiniteVolume \ 13 | -lsampling \ 14 | -lmeshTools \ 15 | -lfvOptions \ 16 | -lxml2 17 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltDiffusion/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I.. \ 3 | -I$(LIB_SRC)/transportModels \ 4 | -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ 5 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 6 | -I$(LIB_SRC)/meshTools/lnInclude \ 7 | -I$(LIB_SRC)/fvOptions/lnInclude \ 8 | -I$(LIB_SRC)/sampling/lnInclude 9 | 10 | 11 | EXE_LIBS = \ 12 | -lincompressibleTransportModels \ 13 | -lfiniteVolume \ 14 | -lmeshTools \ 15 | -lfvOptions \ 16 | -lsampling \ 17 | -lxml2 18 | -------------------------------------------------------------------------------- /tests/simple3dMesh/README: -------------------------------------------------------------------------------- 1 | Quick Quide 2 | =========== 3 | 4 | This test case might not work out-of-the-box on all systems, but should 5 | give a general idea of how to set up a simulation. 6 | 7 | First run ./setup to setup the case appropriately. 8 | 9 | Subsequently, load Openfoam, e.g. depending on system: 10 | module load OpenFoam/3.0.1/gcc-5.1.0-openmpi 11 | 12 | Then run the following solver to get a good initial p field 13 | potentialSalt 14 | 15 | And then a solver to compute the membrane transport (here steady state): 16 | simpleSaltTransport 17 | 18 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltDiffusion/m_AEqn.H: -------------------------------------------------------------------------------- 1 | rho = rho0 * (1.0 + rho_mACoeff * m_A); 2 | 3 | // Calculate rho * D_AB 4 | volScalarField rhoD_AB 5 | ( 6 | "rho*D_AB*Diff_ratio", 7 | rho * max(D_AB_Coeff * (1.0 - D_AB_mACoeff * m_A), D_AB_Min) * Diff_ratio 8 | ); 9 | 10 | // Solute equation 11 | fvScalarMatrix m_AEqn 12 | ( 13 | - fvm::laplacian(rhoD_AB, m_A) 14 | ); 15 | 16 | // Relax to ensure diagonal-dominance 17 | m_AEqn.relax(); 18 | 19 | // Solve for solute 20 | solve(m_AEqn); 21 | 22 | // Output info 23 | Info<< "m_A max/min : " 24 | << max(m_A).value() << " / " 25 | << min(m_A).value() << endl; -------------------------------------------------------------------------------- /Allwmake: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ${0%/*} || exit 1 # run from this directory 3 | set -x 4 | 5 | wmake libso src/boundaryConditions 6 | 7 | wmake src/solvers/pisoSaltTransport 8 | wmake src/solvers/potentialSalt 9 | wmake src/solvers/simpleSaltTransport 10 | wmake src/solvers/simpleSaltDiffusion 11 | 12 | # Experimental work 13 | # wmake src/solvers/simplePorousSaltTransport 14 | 15 | # Experimental work 16 | # wmake src/porosityModels 17 | 18 | # Temporary utility used for experimental project 19 | # wmake src/utilities/sampleMembrane 20 | 21 | # ----------------------------------------------------------------- end-of-file 22 | -------------------------------------------------------------------------------- /src/solvers/simplePorousSaltTransport/m_AEqn.H: -------------------------------------------------------------------------------- 1 | rho = rho0 * (1.0 + rho_mACoeff * m_A); 2 | 3 | // Calculate rho * D_AB 4 | volScalarField rhoD_AB 5 | ( 6 | "rho*D_AB*Diff_ratio", 7 | rho * max(D_AB_Coeff * (1.0 - D_AB_mACoeff * m_A), D_AB_Min) * Diff_ratio 8 | ); 9 | 10 | // Calculate phiU inside vesicle 11 | surfaceScalarField phiUvesicle 12 | ( 13 | "phiUvesicle", 14 | phi * fvc::interpolate(inVesicle) 15 | ); 16 | 17 | // Solute equation 18 | fvScalarMatrix m_AEqn 19 | ( 20 | fvm::div(phiUvesicle, m_A) 21 | - fvm::laplacian(rhoD_AB, m_A) 22 | ); 23 | 24 | // Relax to ensure diagonal-dominance 25 | m_AEqn.relax(); 26 | 27 | // Solve for solute 28 | solve(m_AEqn); -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/m_AContinuity.H: -------------------------------------------------------------------------------- 1 | { 2 | scalar m_A_influx_old = m_A_influx; 3 | scalar m_A_mass_old = m_A_mass; 4 | 5 | m_A_mass = fvc::domainIntegrate(m_A * rho0 * rho_mACoeff).value(); 6 | Info << m_A.name() << " mass: old = " << m_A_mass_old << " new = " << m_A_mass << endl; 7 | m_A_influx = 0.0; 8 | 9 | forAll(m_A.boundaryField(), patchi) 10 | { 11 | m_A_influx -= sum(phi.boundaryField()[patchi] / rho.boundaryField()[patchi] * m_A.boundaryField()[patchi]); 12 | } 13 | m_A_influx *= rho0.value() * rho_mACoeff.value(); 14 | Info << m_A.name() << " influx: old = " << m_A_influx_old << " new = " << m_A_influx << endl; 15 | } 16 | -------------------------------------------------------------------------------- /src/solvers/simplePorousSaltTransport/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I.. \ 3 | -I$(LIB_SRC)/turbulenceModels \ 4 | -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ 5 | -I$(LIB_SRC)/transportModels \ 6 | -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ 7 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 8 | -I$(LIB_SRC)/meshTools/lnInclude \ 9 | -I$(LIB_SRC)/fvOptions/lnInclude \ 10 | -I$(LIB_SRC)/sampling/lnInclude 11 | 12 | 13 | EXE_LIBS = \ 14 | -lincompressibleTurbulenceModel \ 15 | -lincompressibleRASModels \ 16 | -lincompressibleTransportModels \ 17 | -lfiniteVolume \ 18 | -lmeshTools \ 19 | -lfvOptions \ 20 | -lsampling 21 | -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/UEqn.H: -------------------------------------------------------------------------------- 1 | volScalarField mu 2 | ( 3 | "mu", 4 | mu0 + mu_mACoeff*m_A 5 | ); 6 | 7 | fvVectorMatrix UEqn 8 | ( 9 | fvm::ddt(rho, U) 10 | + fvm::div(phi, U) 11 | - fvm::laplacian(mu, U) 12 | - fvc::div(mu*dev2(fvc::grad(U)().T())) 13 | ); 14 | 15 | UEqn.relax(); 16 | 17 | if (momentumPredictor) 18 | { 19 | solve 20 | ( 21 | UEqn 22 | == 23 | fvc::reconstruct 24 | ( 25 | ( 26 | - ghf*fvc::snGrad(rho) 27 | - fvc::snGrad(p) 28 | ) * mesh.magSf() 29 | ) 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /src/solvers/simplePorousSaltTransport/createZones.H: -------------------------------------------------------------------------------- 1 | IOMRFZoneList mrfZones(mesh); 2 | mrfZones.correctBoundaryVelocity(U); 3 | 4 | IOporosityModelList pZones(mesh); 5 | Switch pressureImplicitPorosity(false); 6 | 7 | // nUCorrectors used for pressureImplicitPorosity 8 | int nUCorr = 0; 9 | if (pZones.active()) 10 | { 11 | // nUCorrectors for pressureImplicitPorosity 12 | nUCorr = simple.dict().lookupOrDefault("nUCorrectors", 0); 13 | 14 | if (nUCorr > 0) 15 | { 16 | pressureImplicitPorosity = true; 17 | Info<< "Using pressure implicit porosity" << endl; 18 | } 19 | else 20 | { 21 | Info<< "Using pressure explicit porosity" << endl; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MembraneFoam 2 | ============ 3 | 4 | MembraneFoam: OpenFOAM Boundary Conditions & Solvers for RO and FO 5 | 6 | Installation 7 | ============================ 8 | 9 | You can get the latest version of this git repository by following command: 10 | 11 | ``` 12 | git clone git://github.com/MathiasGruber/MembraneFoam.git 13 | ``` 14 | 15 | These modules are still under constant development. To update to the latest version (and delete all local changes) simply do a pull from within the plmd directory as follows: 16 | 17 | ``` 18 | git fetch --all 19 | git reset --hard origin/master 20 | ``` 21 | 22 | Usage 23 | ============================ 24 | If you use these boundary conditions, please cite the following paper: 25 | *Computational fluid dynamics simulations of flow and concentration polarization in forward osmosis membrane systems*, 26 | Journal of Membrane Science, Vol. 379, No. 1-2, 2011, p. 488-495. 27 | -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/readControls.H: -------------------------------------------------------------------------------- 1 | // Pre-OF3: #include "readPISOControls.H" 2 | // Now directly in this file: 3 | const dictionary& pisoDict = mesh.solutionDict().subDict("PISO"); 4 | const int nOuterCorr = 5 | pisoDict.lookupOrDefault("nOuterCorrectors", 1); 6 | const int nCorr = 7 | pisoDict.lookupOrDefault("nCorrectors", 1); 8 | const int nNonOrthCorr = 9 | pisoDict.lookupOrDefault("nNonOrthogonalCorrectors", 0); 10 | const bool momentumPredictor = 11 | pisoDict.lookupOrDefault("momentumPredictor", true); 12 | 13 | // Pre-OF3: #include "readTimeControls.H" 14 | // Now directly in this file: 15 | 16 | const bool adjustTimeStep = 17 | runTime.controlDict().lookupOrDefault("adjustTimeStep", false); 18 | 19 | scalar maxCo = 20 | runTime.controlDict().lookupOrDefault("maxCo", 1.0); 21 | 22 | scalar maxDeltaT = 23 | runTime.controlDict().lookupOrDefault("maxDeltaT", GREAT); -------------------------------------------------------------------------------- /tests/simple3dMesh/constant/turbulenceProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.3.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object turbulenceProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | simulationType laminar; 19 | 20 | // ************************************************************************* // 21 | -------------------------------------------------------------------------------- /tests/simple3dMesh/constant/g: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 1.6 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class uniformDimensionedVectorField; 13 | location "constant"; 14 | object g; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | dimensions [0 1 -2 0 0 0 0]; 19 | value ( 0 0 0 ); 20 | 21 | 22 | // ************************************************************************* // 23 | -------------------------------------------------------------------------------- /tests/simple3dMesh/system/mirrorMeshDict_X: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 1.7.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object mirrorMeshDict; 14 | } 15 | 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | planeType pointAndNormal; 19 | 20 | pointAndNormalDict 21 | { 22 | basePoint (0 0 0); 23 | normalVector (1 0 0); 24 | } 25 | 26 | 27 | planeTolerance 0.00001; 28 | -------------------------------------------------------------------------------- /tests/simple3dMesh/system/mirrorMeshDict_Y: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 1.7.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object mirrorMeshDict; 14 | } 15 | 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | planeType pointAndNormal; 19 | 20 | pointAndNormalDict 21 | { 22 | basePoint (0 0 0); 23 | normalVector (0 0 -1); 24 | } 25 | 26 | 27 | planeTolerance 0.00001; 28 | -------------------------------------------------------------------------------- /tests/simple3dMesh/constant/RASProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.3.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object RASProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | RASModel laminar; 19 | 20 | turbulence off; 21 | 22 | printCoeffs off; 23 | 24 | 25 | // ************************************************************************* // 26 | -------------------------------------------------------------------------------- /tests/simple3dMesh/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.1.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object decomposeParDict; 14 | } 15 | 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | numberOfSubdomains 4; 19 | 20 | method hierarchical; 21 | 22 | hierarchicalCoeffs 23 | { 24 | n (2 2 1); 25 | delta 0.001; 26 | order xyz; 27 | } 28 | 29 | // ************************************************************************* // 30 | -------------------------------------------------------------------------------- /tests/simple3dMesh/system/topoSetDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: dev | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object topoSetDict; 14 | } 15 | 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | actions 19 | ( 20 | { 21 | name f0; 22 | type faceSet; 23 | action new; 24 | source boxToFace; 25 | sourceInfo 26 | { 27 | box (-1 -1 -0.000001) (1 1 0.000001); 28 | } 29 | } 30 | ); 31 | 32 | // ************************************************************************* // 33 | -------------------------------------------------------------------------------- /tests/simple3dMesh/system/setFieldsDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 1.6 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object setFieldsDict; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | defaultFieldValues 19 | ( 20 | volScalarFieldValue m_A 0.00065 21 | ); 22 | 23 | regions 24 | ( 25 | boxToCell 26 | { 27 | box (-1 -1 0) (1 1 0.5); 28 | fieldValues 29 | ( 30 | volScalarFieldValue m_A 0.065 31 | ); 32 | } 33 | ); 34 | 35 | 36 | // ************************************************************************* // 37 | -------------------------------------------------------------------------------- /tests/simple3dMesh/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Load OpenFOAM 4 | # Older OpenFOAM version is used for setting up mesh here, but newer should work also 5 | module load OpenFoam/2.3.1/gcc-4.8.4-openmpi 6 | 7 | # Remove previous 0 dir 8 | rm -rf 0 9 | 10 | # First run blockMesh to get the basic mesh 11 | blockMesh 12 | 13 | # Move the mesh to the right position 14 | transformPoints -translate "(-0.04 0 0)" 15 | 16 | # Load/run the first mirrorMeshDict 17 | cp system/mirrorMeshDict_X system/mirrorMeshDict 18 | mirrorMesh 19 | 20 | # Load/run the second mirrorMeshDict 21 | cp system/mirrorMeshDict_Y system/mirrorMeshDict 22 | mirrorMesh 23 | 24 | # Load a fixed boundary file. On each mirror mesh, the inlet/outlet patches are doubled 25 | # in size, first in the X-direction and then Y-direction. These are then split manually (or via script) 26 | # to have the right names (outletTop,outletBottom, inletTop, inletBottom) 27 | cp constant/polyMesh/boundaryFixed constant/polyMesh/boundary 28 | 29 | # Create a baffle on the membrane 30 | topoSet && setsToZones -noFlipMap && createBaffles 31 | 32 | # Move time directory from 1 to 0 33 | mv 1/ 0/ 34 | 35 | # Copy in the initial fields 36 | cp initialFields/* 0/ 37 | 38 | # Run the setFields dictionary for better initial fields 39 | setFields -------------------------------------------------------------------------------- /tests/simple3dMesh/system/createBafflesDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.2.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object createBafflesDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | internalFacesOnly true; 18 | 19 | baffles 20 | { 21 | baffleFaces 22 | { 23 | type faceZone; 24 | zoneName f0; 25 | 26 | patches 27 | { 28 | master 29 | { 30 | //- Master side patch 31 | name Membrane; 32 | type patch; 33 | } 34 | slave 35 | { 36 | // Reuse master data 37 | ${..master} 38 | } 39 | } 40 | } 41 | } 42 | 43 | 44 | // ************************************************************************* // 45 | -------------------------------------------------------------------------------- /tests/simple3dMesh/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.3.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object controlDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | application pisoSaltTransport; 18 | 19 | startFrom latestTime; 20 | startTime 0; 21 | stopAt endTime; 22 | endTime 1000000; 23 | deltaT 1; 24 | maxDeltaT 0.5; 25 | maxCo 0.70; 26 | 27 | writeControl clockTime; 28 | writeInterval 43200; 29 | purgeWrite 0; 30 | writeFormat ascii; 31 | writePrecision 6; 32 | writeCompression uncompressed; 33 | timeFormat general; 34 | timePrecision 8; 35 | runTimeModifiable no; 36 | adjustTimeStep yes; 37 | 38 | libs ( "libOpenFOAM.so" ); 39 | libs ( "libOpenFOAM.so" "libDHIBoundaryConditions.so"); 40 | 41 | // ************************************************************************* // 42 | -------------------------------------------------------------------------------- /src/solvers/potentialSalt/createFields.H: -------------------------------------------------------------------------------- 1 | Info<< "Reading field p\n" << endl; 2 | volScalarField p 3 | ( 4 | IOobject 5 | ( 6 | "p", 7 | runTime.timeName(), 8 | mesh, 9 | IOobject::MUST_READ, 10 | IOobject::AUTO_WRITE 11 | ), 12 | mesh 13 | ); 14 | 15 | p = dimensionedScalar("zero", p.dimensions(), 0.0); 16 | 17 | 18 | Info<< "Reading field U\n" << endl; 19 | volVectorField U 20 | ( 21 | IOobject 22 | ( 23 | "U", 24 | runTime.timeName(), 25 | mesh, 26 | IOobject::MUST_READ, 27 | IOobject::AUTO_WRITE 28 | ), 29 | mesh 30 | ); 31 | 32 | U = dimensionedVector("0", U.dimensions(), vector::zero); 33 | 34 | Info<< "Reading field m_A\n" << endl; 35 | volScalarField m_A 36 | ( 37 | IOobject 38 | ( 39 | "m_A", 40 | runTime.timeName(), 41 | mesh, 42 | IOobject::MUST_READ, 43 | IOobject::NO_WRITE 44 | ), 45 | mesh 46 | ); 47 | 48 | surfaceScalarField phi 49 | ( 50 | IOobject 51 | ( 52 | "phi", 53 | runTime.timeName(), 54 | mesh, 55 | IOobject::NO_READ, 56 | IOobject::NO_WRITE 57 | ), 58 | fvc::interpolate(U) & mesh.Sf() 59 | ); 60 | 61 | label pRefCell = 0; 62 | scalar pRefValue = 0.0; 63 | setRefCell 64 | ( 65 | p, 66 | potentialFlow, 67 | pRefCell, 68 | pRefValue 69 | ); 70 | -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/pEqn.H: -------------------------------------------------------------------------------- 1 | rho = rho0 * (1.0 + rho_mACoeff * m_A); 2 | 3 | { 4 | // OpenFoam 2.2 and below: 5 | // volScalarField rUA = 1.0/UEqn.A(); 6 | // surfaceScalarField rUAf = fvc::interpolate(rUA); 7 | tmp temp0 = 1.0/UEqn.A(); 8 | volScalarField rUA = temp0(); 9 | 10 | tmp temp1 = fvc::interpolate(rUA); 11 | surfaceScalarField rUAf = temp1(); 12 | 13 | U = rUA*UEqn.H(); 14 | 15 | surfaceScalarField phiU 16 | ( 17 | "phiU", 18 | fvc::interpolate(rho) * 19 | ( 20 | (fvc::interpolate(U) & mesh.Sf()) 21 | + rUAf*fvc::ddtCorr(rho, U, phi) 22 | ) 23 | ); 24 | 25 | phi = phiU - fvc::interpolate(rho)*ghf*fvc::snGrad(rho)*rUAf*mesh.magSf(); 26 | 27 | for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) 28 | { 29 | fvScalarMatrix pEqn 30 | ( 31 | fvm::laplacian(rho*rUA, p) 32 | == fvc::div(phi) 33 | + fvc::ddt(rho) 34 | ); 35 | 36 | pEqn.setReference(pRefCell, pRefValue); 37 | 38 | pEqn.solve 39 | ( 40 | mesh.solver 41 | ( 42 | p.name() 43 | + ((corr == nCorr-1 && nonOrth == nNonOrthCorr) ? "Final" : "") 44 | ) 45 | ); 46 | 47 | if (nonOrth == nNonOrthCorr) 48 | { 49 | phi -= pEqn.flux(); 50 | } 51 | } 52 | 53 | // the standard continuity errors calculated for compressible flow cannot 54 | // be used here as they rely on a basicThermo object 55 | // #include "compressibleContinuityErrs.H" 56 | 57 | U += rUA/rho*fvc::reconstruct((phi - phiU)/rUAf); 58 | U.correctBoundaryConditions(); 59 | } 60 | -------------------------------------------------------------------------------- /tests/simple3dMesh/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 1.7.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object transportProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | transportModel Newtonian; 19 | 20 | // Newtonian transport model: 21 | 22 | // Solute-dependent viscosity 23 | nu nu [ 0 2 -1 0 0 0 0 ] 0.894e-6; 24 | pi_mACoeff pi_mACoeff [ 0 0 0 0 0 0 0 ] 80510000.0; 25 | mu0 mu0 [ 1 -1 -1 0 0 0 0 ] 0.00089; 26 | mu_mACoeff mu_mACoeff [ 0 0 0 0 0 0 0 ] 1.63; 27 | D_AB_Min D_AB_Min [ 0 2 -1 0 0 0 0 ] 1.45e-09; 28 | D_AB_Coeff D_AB_Coeff [ 0 2 -1 0 0 0 0 ] 1.61e-09; 29 | D_AB_mACoeff D_AB_mACoeff [ 0 0 0 0 0 0 0 ] 14.0; 30 | rho0 rho0 [ 1 -3 0 0 0 0 0 ] 997.1; 31 | rho_mACoeff rho_mACoeff [ 0 0 0 0 0 0 0 ] 0.696; 32 | 33 | // Membrane Parameters 34 | A 1.61111e-12; 35 | B 8.33333e-08; 36 | K 150666.0; 37 | 38 | // ************************************************************************* // 39 | -------------------------------------------------------------------------------- /src/solvers/simplePorousSaltTransport/UEqn.H: -------------------------------------------------------------------------------- 1 | // Update the viscosity field 2 | mu = mu0 + mu_mACoeff*m_A; 3 | 4 | // Construct the Momentum equation 5 | tmp UEqn 6 | ( 7 | fvm::div(phi, U) 8 | - fvm::laplacian(mu, U) 9 | - fvc::div(mu*dev2(fvc::grad(U)().T())) 10 | ); 11 | UEqn().relax(); 12 | 13 | // Update the mu_laplacian field 14 | // http://www.cfd-online.com/Forums/openfoam-solving/58214-calculating-divdevreff.html 15 | // mu_laplacianU = fvc::laplacian( mu, U ); 16 | mu_laplacianU = fvc::laplacian( mu, U ) + fvc::div(mu*dev2(fvc::grad(U)().T())); 17 | 18 | // Include the porous media resistance and solve the momentum equation 19 | // either implicit in the tensorial resistance or transport using by 20 | // including the spherical part of the resistance in the momentum diagonal 21 | tmp trAU; 22 | tmp trTU; 23 | 24 | if (pressureImplicitPorosity) 25 | { 26 | tmp tTU = tensor(I)*UEqn().A(); 27 | pZones.addResistance(UEqn(), tTU()); 28 | trTU = inv(tTU()); 29 | trTU().rename("rAU"); 30 | 31 | fvOptions.constrain(UEqn()); 32 | 33 | volVectorField gradp(fvc::grad(p)); 34 | 35 | for (int UCorr=0; UCorr temp1 = fvc::interpolate(rAU); 26 | surfaceScalarField rAUf = temp1(); 27 | 28 | // Calculate phiU 29 | U = rAU*UEqn().H(); 30 | surfaceScalarField phiU 31 | ( 32 | "phiU", 33 | fvc::interpolate(rho) * 34 | ( 35 | fvc::interpolate(U) & mesh.Sf() 36 | ) 37 | ); 38 | 39 | // Calculate Phi 40 | phi = phiU - fvc::interpolate(rho)*ghf*fvc::snGrad(rho)*rAUf*mesh.magSf(); 41 | 42 | // Solve the equation 43 | while (simple.correctNonOrthogonal()) 44 | { 45 | fvScalarMatrix pEqn 46 | ( 47 | fvm::laplacian(rho*rAU, p) == fvc::div(phi) 48 | ); 49 | 50 | pEqn.setReference(pRefCell, pRefValue); 51 | 52 | pEqn.solve(); 53 | 54 | if (simple.finalNonOrthogonalIter()) 55 | { 56 | phi -= pEqn.flux(); 57 | } 58 | } 59 | 60 | 61 | // Explicitly relax pressure for momentum corrector 62 | p.relax(); 63 | 64 | // Update velocity BCs 65 | U += rAU/rho*fvc::reconstruct((phi - phiU)/rAUf); 66 | U.correctBoundaryConditions(); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /tests/simple3dMesh/initialFields/p: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.3.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | location "0"; 14 | object p; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | dimensions [1 -1 -2 0 0 0 0]; 19 | 20 | internalField uniform 0; 21 | 22 | boundaryField 23 | { 24 | symm 25 | { 26 | type symmetryPlane; 27 | } 28 | inletTop 29 | { 30 | type zeroGradient; 31 | } 32 | outletTop 33 | { 34 | type fixedValue; 35 | value uniform 0; 36 | } 37 | outletBottom 38 | { 39 | type fixedValue; 40 | value uniform 0; 41 | } 42 | inletBottom 43 | { 44 | type zeroGradient; 45 | } 46 | tempWall 47 | { 48 | type zeroGradient; 49 | } 50 | inletWall 51 | { 52 | type zeroGradient; 53 | } 54 | chamberWall 55 | { 56 | type zeroGradient; 57 | } 58 | Membrane 59 | { 60 | type zeroGradient; 61 | } 62 | } 63 | 64 | 65 | // ************************************************************************* // 66 | -------------------------------------------------------------------------------- /tests/simple3dMesh/initialFields/m_A: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.3.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | location "0"; 14 | object m_A; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | dimensions [0 0 0 0 0 0 0]; 19 | 20 | internalField uniform 0; 21 | 22 | boundaryField 23 | { 24 | symm 25 | { 26 | type symmetryPlane; 27 | } 28 | inletTop 29 | { 30 | type fixedValue; 31 | value uniform 0.065; 32 | } 33 | outletTop 34 | { 35 | type zeroGradient; 36 | } 37 | outletBottom 38 | { 39 | type zeroGradient; 40 | } 41 | inletBottom 42 | { 43 | type fixedValue; 44 | value uniform 0.00065; 45 | } 46 | tempWall 47 | { 48 | type zeroGradient; 49 | } 50 | inletWall 51 | { 52 | type zeroGradient; 53 | } 54 | chamberWall 55 | { 56 | type zeroGradient; 57 | } 58 | Membrane 59 | { 60 | type explicitFOmembraneSolute; 61 | m_A U; 62 | value uniform 0; 63 | } 64 | } 65 | 66 | 67 | // ************************************************************************* // 68 | -------------------------------------------------------------------------------- /tests/simple3dMesh/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 1.7.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object fvSchemes; 15 | } 16 | /* 17 | * Discretization schemes used 18 | */ 19 | 20 | ddtSchemes 21 | { 22 | default Euler; 23 | } 24 | 25 | gradSchemes 26 | { 27 | default Gauss linear; 28 | grad(p_rgh) Gauss linear; 29 | grad(U) Gauss linear; 30 | } 31 | 32 | divSchemes 33 | { 34 | default none; 35 | div(phi,m_A) Gauss limitedLinear 1; 36 | div(phi,U) Gauss linear; 37 | div((mu*dev2(grad(U).T()))) Gauss linear; 38 | div((nuEff*dev(T(grad(U))))) Gauss linear; 39 | } 40 | 41 | laplacianSchemes 42 | { 43 | default Gauss linear corrected; 44 | laplacian(rho*D_AB,m_A) Gauss linear corrected; 45 | laplacian(mu,U) Gauss linear corrected; 46 | laplacian((rho*(1|A(U))),p) Gauss linear corrected; 47 | laplacian(1,p) Gauss linear corrected; 48 | } 49 | 50 | interpolationSchemes 51 | { 52 | default linear; 53 | interpolate(U) linear; 54 | } 55 | 56 | snGradSchemes 57 | { 58 | default corrected; 59 | } 60 | 61 | fluxRequired 62 | { 63 | default no; 64 | p yes; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltDiffusion/createFields.H: -------------------------------------------------------------------------------- 1 | // Load transport properties dictionary 2 | Info<< "Reading transportProperties\n" << endl; 3 | IOdictionary transportProperties 4 | ( 5 | IOobject 6 | ( 7 | "transportProperties", 8 | runTime.constant(), 9 | mesh, 10 | IOobject::MUST_READ 11 | ) 12 | ); 13 | 14 | // Load relevant transport properties 15 | dimensionedScalar pi_mACoeff(transportProperties.lookup("pi_mACoeff")); 16 | dimensionedScalar mu0(transportProperties.lookup("mu0")); 17 | dimensionedScalar mu_mACoeff(transportProperties.lookup("mu_mACoeff")); 18 | dimensionedScalar D_AB_Min(transportProperties.lookup("D_AB_Min")); 19 | dimensionedScalar D_AB_Coeff(transportProperties.lookup("D_AB_Coeff")); 20 | dimensionedScalar D_AB_mACoeff(transportProperties.lookup("D_AB_mACoeff")); 21 | dimensionedScalar rho0(transportProperties.lookup("rho0")); 22 | dimensionedScalar rho_mACoeff(transportProperties.lookup("rho_mACoeff")); 23 | 24 | Info<< "Reading field m_A\n" << endl; 25 | volScalarField m_A 26 | ( 27 | IOobject 28 | ( 29 | "m_A", 30 | runTime.timeName(), 31 | mesh, 32 | IOobject::MUST_READ, 33 | IOobject::AUTO_WRITE 34 | ), 35 | mesh 36 | ); 37 | 38 | Info<< "Reading field Diff_ratio\n" << endl; 39 | volScalarField Diff_ratio 40 | ( 41 | IOobject 42 | ( 43 | "Diff_ratio", 44 | runTime.timeName(), 45 | mesh, 46 | IOobject::MUST_READ, 47 | IOobject::AUTO_WRITE 48 | ), 49 | mesh 50 | ); 51 | 52 | 53 | 54 | Info << "Creating rho\n" << endl; 55 | volScalarField rho 56 | ( 57 | IOobject 58 | ( 59 | "rho", 60 | runTime.timeName(), 61 | mesh, 62 | IOobject::NO_READ, 63 | IOobject::AUTO_WRITE 64 | ), 65 | rho0 * (1.0 + rho_mACoeff*m_A) 66 | ); -------------------------------------------------------------------------------- /src/solvers/simplePorousSaltTransport/pEqn.H: -------------------------------------------------------------------------------- 1 | // Output some information for the user 2 | Info<< "rho max/min : " 3 | << max(rho).value() << " / " 4 | << min(rho).value() << endl; 5 | 6 | Info<< "pressure max/min : " 7 | << max(p).value() << " / " 8 | << min(p).value() << endl; 9 | 10 | Info<< "m_A max/min : " 11 | << max(m_A).value() << " / " 12 | << min(m_A).value() << endl; 13 | 14 | Info<< "U max/min : " 15 | << max(U).value() << " / " 16 | << min(U).value() << endl; 17 | 18 | Info<< "mu*laplacian(U) max/min : " 19 | << max(mu_laplacianU).value() << " / " 20 | << min(mu_laplacianU).value() << endl; 21 | 22 | // Calculate new density 23 | rho = rho0 * (1.0 + rho_mACoeff * m_A); 24 | 25 | volVectorField HbyA("HbyA", U); 26 | 27 | if (pressureImplicitPorosity) 28 | { 29 | HbyA = trTU() & UEqn().H(); 30 | } 31 | else 32 | { 33 | HbyA = trAU()*UEqn().H(); 34 | } 35 | 36 | UEqn.clear(); 37 | 38 | surfaceScalarField phiHbyA 39 | ( 40 | "phiHbyA", 41 | fvc::interpolate(rho*HbyA) & mesh.Sf() 42 | ); 43 | 44 | fvOptions.makeRelative(fvc::interpolate(rho), phiHbyA); 45 | 46 | while (simple.correctNonOrthogonal()) 47 | { 48 | tmp tpEqn; 49 | 50 | if (pressureImplicitPorosity) 51 | { 52 | tpEqn = 53 | ( 54 | fvm::laplacian(rho*trTU(), p) 55 | == 56 | fvc::div(phiHbyA) 57 | ); 58 | } 59 | else 60 | { 61 | tpEqn = 62 | ( 63 | fvm::laplacian(rho*trAU(), p) 64 | == 65 | fvc::div(phiHbyA) 66 | ); 67 | } 68 | 69 | tpEqn().setReference(pRefCell, pRefValue); 70 | 71 | fvOptions.constrain(tpEqn(), rho.name()); 72 | 73 | tpEqn().solve(); 74 | 75 | if (simple.finalNonOrthogonalIter()) 76 | { 77 | phi = phiHbyA - tpEqn().flux(); 78 | } 79 | } 80 | 81 | // Explicitly relax pressure for momentum corrector 82 | p.relax(); 83 | 84 | if (pressureImplicitPorosity) 85 | { 86 | U = HbyA - (trTU() & fvc::grad(p)); 87 | } 88 | else 89 | { 90 | U = HbyA - trAU()*fvc::grad(p); 91 | } 92 | 93 | U.correctBoundaryConditions(); 94 | fvOptions.correct(U); -------------------------------------------------------------------------------- /tests/simple3dMesh/initialFields/U: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.3.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volVectorField; 13 | location "0"; 14 | object U; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | dimensions [0 1 -1 0 0 0 0]; 19 | 20 | internalField uniform (0 0 0); 21 | 22 | boundaryField 23 | { 24 | symm 25 | { 26 | type symmetryPlane; 27 | } 28 | inletTop 29 | { 30 | type surfaceNormalFixedValue; 31 | refValue uniform -0.0119048; 32 | } 33 | outletTop 34 | { 35 | type zeroGradient; 36 | } 37 | outletBottom 38 | { 39 | type zeroGradient; 40 | } 41 | inletBottom 42 | { 43 | type surfaceNormalFixedValue; 44 | refValue uniform -0.0119048; 45 | } 46 | tempWall 47 | { 48 | type fixedValue; 49 | value uniform (0 0 0); 50 | } 51 | inletWall 52 | { 53 | type fixedValue; 54 | value uniform (0 0 0); 55 | } 56 | chamberWall 57 | { 58 | type fixedValue; 59 | value uniform (0 0 0); 60 | } 61 | Membrane 62 | { 63 | type explicitFOmembraneVelocity; 64 | A 1.61111e-12; 65 | B 8.33333e-08; 66 | K 150666; 67 | alpha 1; 68 | eq advanced; 69 | aRelax 1; 70 | forwardDirection (0 0 1); 71 | slip noSlip; 72 | pi_mACoeff 8.051e+07; 73 | value uniform (0 0 0); 74 | } 75 | } 76 | 77 | 78 | // ************************************************************************* // 79 | -------------------------------------------------------------------------------- /tests/simple3dMesh/constant/polyMesh/boundaryFixed: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2.3.1 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class polyBoundaryMesh; 13 | location "constant/polyMesh"; 14 | object boundary; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 8 19 | ( 20 | symm 21 | { 22 | type symmetryPlane; 23 | inGroups 1(symmetryPlane); 24 | nFaces 5660; 25 | startFace 2977008; 26 | } 27 | inletTop 28 | { 29 | type patch; 30 | inGroups 1(patch); 31 | nFaces 207; 32 | startFace 2982668; 33 | } 34 | outletTop 35 | { 36 | type patch; 37 | inGroups 1(patch); 38 | nFaces 207; 39 | startFace 2982875; 40 | } 41 | outletBottom 42 | { 43 | type patch; 44 | inGroups 1(patch); 45 | nFaces 207; 46 | startFace 2983082; 47 | } 48 | inletBottom 49 | { 50 | type patch; 51 | inGroups 1(patch); 52 | nFaces 207; 53 | startFace 2983289; 54 | } 55 | tempWall 56 | { 57 | type wall; 58 | inGroups 1(wall); 59 | nFaces 4; 60 | startFace 2983496; 61 | } 62 | inletWall 63 | { 64 | type wall; 65 | inGroups 1(wall); 66 | nFaces 18032; 67 | startFace 2983500; 68 | } 69 | chamberWall 70 | { 71 | type wall; 72 | inGroups 1(wall); 73 | nFaces 52220; 74 | startFace 3001532; 75 | } 76 | ) 77 | 78 | // ************************************************************************* // 79 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltTransport/createFields.H: -------------------------------------------------------------------------------- 1 | Info<< "Reading field p\n" << endl; 2 | volScalarField p 3 | ( 4 | IOobject 5 | ( 6 | "p", 7 | runTime.timeName(), 8 | mesh, 9 | IOobject::MUST_READ, 10 | IOobject::AUTO_WRITE 11 | ), 12 | mesh 13 | ); 14 | 15 | Info<< "Reading field m_A\n" << endl; 16 | volScalarField m_A 17 | ( 18 | IOobject 19 | ( 20 | "m_A", 21 | runTime.timeName(), 22 | mesh, 23 | IOobject::MUST_READ, 24 | IOobject::AUTO_WRITE 25 | ), 26 | mesh 27 | ); 28 | 29 | Info<< "Reading field U\n" << endl; 30 | volVectorField U 31 | ( 32 | IOobject 33 | ( 34 | "U", 35 | runTime.timeName(), 36 | mesh, 37 | IOobject::MUST_READ, 38 | IOobject::AUTO_WRITE 39 | ), 40 | mesh 41 | ); 42 | 43 | Info<< "Reading transportProperties\n" << endl; 44 | IOdictionary transportProperties 45 | ( 46 | IOobject 47 | ( 48 | "transportProperties", 49 | runTime.constant(), 50 | mesh, 51 | IOobject::MUST_READ 52 | ) 53 | ); 54 | 55 | dimensionedScalar pi_mACoeff(transportProperties.lookup("pi_mACoeff")); 56 | dimensionedScalar mu0(transportProperties.lookup("mu0")); 57 | dimensionedScalar mu_mACoeff(transportProperties.lookup("mu_mACoeff")); 58 | dimensionedScalar D_AB_Min(transportProperties.lookup("D_AB_Min")); 59 | dimensionedScalar D_AB_Coeff(transportProperties.lookup("D_AB_Coeff")); 60 | dimensionedScalar D_AB_mACoeff(transportProperties.lookup("D_AB_mACoeff")); 61 | dimensionedScalar rho0(transportProperties.lookup("rho0")); 62 | dimensionedScalar rho_mACoeff(transportProperties.lookup("rho_mACoeff")); 63 | 64 | Info << "Creating rho\n" << endl; 65 | volScalarField rho 66 | ( 67 | IOobject 68 | ( 69 | "rho", 70 | runTime.timeName(), 71 | mesh, 72 | IOobject::NO_READ, 73 | IOobject::AUTO_WRITE 74 | ), 75 | rho0 * (1.0 + rho_mACoeff*m_A) 76 | ); 77 | rho.oldTime(); 78 | 79 | #include "compressibleCreatePhi.H" 80 | 81 | Info << "Flow is assumed to be laminar\nTurbulence is currently unsupported in this solver\n" << endl; 82 | 83 | Info<< "Calculating field (g.h)f\n" << endl; 84 | surfaceScalarField ghf = surfaceScalarField("ghf", g & mesh.Cf()); 85 | 86 | label pRefCell = 0; 87 | scalar pRefValue = 0.0; 88 | setRefCell(p, simple.dict(), pRefCell, pRefValue); -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/createFields.H: -------------------------------------------------------------------------------- 1 | Info<< "Reading field p\n" << endl; 2 | volScalarField p 3 | ( 4 | IOobject 5 | ( 6 | "p", 7 | runTime.timeName(), 8 | mesh, 9 | IOobject::MUST_READ, 10 | IOobject::AUTO_WRITE 11 | ), 12 | mesh 13 | ); 14 | 15 | Info<< "Reading field m_A\n" << endl; 16 | volScalarField m_A 17 | ( 18 | IOobject 19 | ( 20 | "m_A", 21 | runTime.timeName(), 22 | mesh, 23 | IOobject::MUST_READ, 24 | IOobject::AUTO_WRITE 25 | ), 26 | mesh 27 | ); 28 | 29 | Info<< "Reading field U\n" << endl; 30 | volVectorField U 31 | ( 32 | IOobject 33 | ( 34 | "U", 35 | runTime.timeName(), 36 | mesh, 37 | IOobject::MUST_READ, 38 | IOobject::AUTO_WRITE 39 | ), 40 | mesh 41 | ); 42 | 43 | Info<< "Reading transportProperties\n" << endl; 44 | IOdictionary transportProperties 45 | ( 46 | IOobject 47 | ( 48 | "transportProperties", 49 | runTime.constant(), 50 | mesh, 51 | IOobject::MUST_READ 52 | ) 53 | ); 54 | 55 | dimensionedScalar pi_mACoeff(transportProperties.lookup("pi_mACoeff")); 56 | dimensionedScalar mu0(transportProperties.lookup("mu0")); 57 | dimensionedScalar mu_mACoeff(transportProperties.lookup("mu_mACoeff")); 58 | dimensionedScalar D_AB_Min(transportProperties.lookup("D_AB_Min")); 59 | dimensionedScalar D_AB_Coeff(transportProperties.lookup("D_AB_Coeff")); 60 | dimensionedScalar D_AB_mACoeff(transportProperties.lookup("D_AB_mACoeff")); 61 | dimensionedScalar rho0(transportProperties.lookup("rho0")); 62 | dimensionedScalar rho_mACoeff(transportProperties.lookup("rho_mACoeff")); 63 | 64 | Info << "Creating rho\n" << endl; 65 | volScalarField rho 66 | ( 67 | IOobject 68 | ( 69 | "rho", 70 | runTime.timeName(), 71 | mesh, 72 | IOobject::NO_READ, 73 | IOobject::AUTO_WRITE 74 | ), 75 | rho0 * (1.0 + rho_mACoeff*m_A) 76 | ); 77 | rho.oldTime(); 78 | 79 | #include "compressibleCreatePhi.H" 80 | 81 | Info << "Flow is assumed to be laminar\nTurbulence is currently unsupported in this solver\n" << endl; 82 | 83 | Info<< "Calculating field (g.h)f\n" << endl; 84 | surfaceScalarField ghf = surfaceScalarField("ghf", g & mesh.Cf()); 85 | 86 | label pRefCell = 0; 87 | scalar pRefValue = 0.0; 88 | setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); -------------------------------------------------------------------------------- /src/solvers/simpleSaltDiffusion/simpleSaltDiffusion.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Application 25 | simpleSaltDiffusion 26 | 27 | Description 28 | Steady-state solver for incompressible, turbulent flow with 29 | implicit or explicit porosity treatment and support for multiple reference 30 | frames (MRF) 31 | 32 | \*---------------------------------------------------------------------------*/ 33 | 34 | #include "fvCFD.H" 35 | #include "singlePhaseTransportModel.H" 36 | #include "simpleControl.H" 37 | #include "fvIOoptionList.H" 38 | 39 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 40 | 41 | int main(int argc, char *argv[]) 42 | { 43 | #include "setRootCase.H" 44 | #include "createTime.H" 45 | #include "createMesh.H" 46 | 47 | simpleControl simple(mesh); 48 | 49 | #include "createFields.H" 50 | #include "createFvOptions.H" 51 | 52 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 53 | 54 | Info<< "\nStarting time loop\n" << endl; 55 | 56 | while (simple.loop()) 57 | { 58 | Info<< "Time = " << runTime.timeName() << nl << endl; 59 | 60 | // Pressure-velocity SIMPLE corrector 61 | { 62 | #include "m_AEqn.H" 63 | } 64 | 65 | runTime.write(); 66 | 67 | Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" 68 | << " ClockTime = " << runTime.elapsedClockTime() << " s" 69 | << nl << endl; 70 | } 71 | 72 | Info<< "End\n" << endl; 73 | 74 | return 0; 75 | } 76 | 77 | 78 | // ************************************************************************* // 79 | -------------------------------------------------------------------------------- /src/solvers/simplePorousSaltTransport/simplePorousSaltTransport.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Application 25 | simplePorousSaltTransport 26 | 27 | Description 28 | Steady-state solver for incompressible, turbulent flow with 29 | implicit or explicit porosity treatment and support for multiple reference 30 | frames (MRF) 31 | 32 | \*---------------------------------------------------------------------------*/ 33 | 34 | #include "fvCFD.H" 35 | #include "singlePhaseTransportModel.H" 36 | #include "simpleControl.H" 37 | #include "IOMRFZoneList.H" 38 | #include "IOporosityModelList.H" 39 | #include "fvIOoptionList.H" 40 | 41 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 42 | 43 | int main(int argc, char *argv[]) 44 | { 45 | #include "setRootCase.H" 46 | #include "createTime.H" 47 | #include "createMesh.H" 48 | 49 | simpleControl simple(mesh); 50 | 51 | #include "createFields.H" 52 | #include "createFvOptions.H" 53 | #include "createZones.H" 54 | #include "initContinuityErrs.H" 55 | 56 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 57 | 58 | Info<< "\nStarting time loop\n" << endl; 59 | 60 | while (simple.loop()) 61 | { 62 | Info<< "Time = " << runTime.timeName() << nl << endl; 63 | 64 | // Pressure-velocity SIMPLE corrector 65 | { 66 | #include "UEqn.H" 67 | #include "m_AEqn.H" 68 | #include "pEqn.H" 69 | #include "rpEqn.H" 70 | } 71 | 72 | runTime.write(); 73 | 74 | Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" 75 | << " ClockTime = " << runTime.elapsedClockTime() << " s" 76 | << nl << endl; 77 | } 78 | 79 | Info<< "End\n" << endl; 80 | 81 | return 0; 82 | } 83 | 84 | 85 | // ************************************************************************* // 86 | -------------------------------------------------------------------------------- /src/solvers/simpleSaltTransport/simpleSaltTransport.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Application 25 | rhoSimpleFoam 26 | 27 | Description 28 | Steady-state SIMPLE solver for soluble salt transport in a fluid. 29 | 30 | The solver assumes the process is isothermal and uses a weakly 31 | compressible solution technique. The density is solely a function of the 32 | solute mass fraction and is calculated explicitly. 33 | 34 | The current model does not include a turbulence model as the standard 35 | compressible models require more sophisticated energy treatments. The 36 | incompressible turbulence models are not used as the density variation is 37 | significant enough that a weakly-compressible formulation is required. 38 | 39 | \*---------------------------------------------------------------------------*/ 40 | 41 | #include "fvCFD.H" 42 | #include "simpleControl.H" 43 | 44 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 45 | 46 | int main(int argc, char *argv[]) 47 | { 48 | #include "setRootCase.H" 49 | #include "createTime.H" 50 | #include "createMesh.H" 51 | #include "readGravitationalAcceleration.H" 52 | 53 | simpleControl simple(mesh); 54 | 55 | #include "createFields.H" 56 | 57 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 58 | 59 | Info<< "\nStarting time loop\n" << endl; 60 | 61 | while (simple.loop()) 62 | { 63 | Info<< "Time = " << runTime.timeName() << nl << endl; 64 | 65 | // Pressure-velocity SIMPLE corrector 66 | { 67 | #include "UEqn.H" 68 | #include "m_AEqn.H" 69 | #include "pEqn.H" 70 | } 71 | 72 | runTime.write(); 73 | 74 | Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" 75 | << " ClockTime = " << runTime.elapsedClockTime() << " s" 76 | << nl << endl; 77 | } 78 | 79 | Info<< "End\n" << endl; 80 | 81 | return 0; 82 | } 83 | 84 | 85 | // ************************************************************************* // 86 | -------------------------------------------------------------------------------- /src/porosityModels/DarcyForchheimerSaltTransport/DarcyForchheimerSaltTransportTemplates.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // 27 | 28 | template 29 | void Foam::porosityModels::DarcyForchheimerSaltTransport::apply 30 | ( 31 | scalarField& Udiag, 32 | vectorField& Usource, 33 | const scalarField& V, 34 | const RhoFieldType& rho, 35 | const scalarField& mu, 36 | const vectorField& U 37 | ) const 38 | { 39 | forAll(cellZoneIDs_, zoneI) 40 | { 41 | const tensorField& dZones = D_[zoneI]; 42 | const tensorField& fZones = F_[zoneI]; 43 | 44 | const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; 45 | 46 | forAll(cells, i) 47 | { 48 | const label cellI = cells[i]; 49 | const label j = this->fieldIndex(i); 50 | const tensor Cd = 51 | mu[cellI]*dZones[j] + (rho[cellI]*mag(U[cellI]))*fZones[j]; 52 | 53 | const scalar isoCd = tr(Cd); 54 | 55 | Udiag[cellI] += V[cellI]*isoCd; 56 | Usource[cellI] -= V[cellI]*((Cd - I*isoCd) & U[cellI]); 57 | } 58 | } 59 | } 60 | 61 | 62 | template 63 | void Foam::porosityModels::DarcyForchheimerSaltTransport::apply 64 | ( 65 | tensorField& AU, 66 | const RhoFieldType& rho, 67 | const scalarField& mu, 68 | const vectorField& U 69 | ) const 70 | { 71 | forAll(cellZoneIDs_, zoneI) 72 | { 73 | const tensorField& dZones = D_[zoneI]; 74 | const tensorField& fZones = F_[zoneI]; 75 | 76 | const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; 77 | 78 | forAll(cells, i) 79 | { 80 | const label cellI = cells[i]; 81 | const label j = this->fieldIndex(i); 82 | const tensor D = dZones[j]; 83 | const tensor F = fZones[j]; 84 | 85 | AU[cellI] += mu[cellI]*D + (rho[cellI]*mag(U[cellI]))*F; 86 | } 87 | } 88 | } 89 | 90 | 91 | // ************************************************************************* // 92 | -------------------------------------------------------------------------------- /src/solvers/potentialSalt/potentialSalt.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Application 25 | potentialSalt 26 | 27 | Description 28 | Simple potential flow solver which can be used to generate starting fields 29 | for full Navier-Stokes codes. 30 | 31 | \*---------------------------------------------------------------------------*/ 32 | 33 | #include "fvCFD.H" 34 | 35 | 36 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 37 | 38 | int main(int argc, char *argv[]) 39 | { 40 | 41 | argList::validOptions.insert("writep", ""); 42 | 43 | #include "setRootCase.H" 44 | 45 | #include "createTime.H" 46 | #include "createMesh.H" 47 | #include "readControls.H" 48 | #include "createFields.H" 49 | 50 | 51 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 52 | 53 | Info<< nl << "Calculating potential flow" << endl; 54 | 55 | adjustPhi(phi, U, p); 56 | 57 | for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) 58 | { 59 | fvScalarMatrix pEqn 60 | ( 61 | fvm::laplacian 62 | ( 63 | dimensionedScalar 64 | ( 65 | "1", 66 | dimTime/p.dimensions()*dimensionSet(0, 2, -2, 0, 0), 67 | 1 68 | ), 69 | p 70 | ) 71 | == 72 | fvc::div(phi) 73 | ); 74 | 75 | pEqn.setReference(pRefCell, pRefValue); 76 | pEqn.solve(); 77 | 78 | if (nonOrth == nNonOrthCorr) 79 | { 80 | phi -= pEqn.flux(); 81 | } 82 | } 83 | 84 | Info<< "continuity error = " 85 | << mag(fvc::div(phi))().weightedAverage(mesh.V()).value() 86 | << endl; 87 | 88 | U = fvc::reconstruct(phi); 89 | U.correctBoundaryConditions(); 90 | 91 | Info<< "Interpolated U error = " 92 | << (sqrt(sum(sqr((fvc::interpolate(U) & mesh.Sf()) - phi))) 93 | /sum(mesh.magSf())).value() 94 | << endl; 95 | 96 | // Force the write 97 | U.write(); 98 | p.write(); 99 | 100 | Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" 101 | << " ClockTime = " << runTime.elapsedClockTime() << " s" 102 | << nl << endl; 103 | 104 | Info<< "End\n" << endl; 105 | 106 | return 0; 107 | } 108 | 109 | 110 | // ************************************************************************* // 111 | -------------------------------------------------------------------------------- /tests/simple3dMesh/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 1.7.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object fvSolution; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | solvers 19 | { 20 | p 21 | { 22 | solver GAMG; 23 | tolerance 1e-7; 24 | relTol 0.1; 25 | smoother GaussSeidel; 26 | cacheAgglomeration true; 27 | nCellsInCoarsestLevel 30; 28 | agglomerator faceAreaPair; 29 | mergeLevels 1; 30 | } 31 | 32 | rho 33 | { 34 | solver GAMG; 35 | tolerance 1e-8; 36 | relTol 0.01; 37 | smoother GaussSeidel; 38 | cacheAgglomeration true; 39 | nCellsInCoarsestLevel 30; 40 | agglomerator faceAreaPair; 41 | mergeLevels 1; 42 | } 43 | 44 | rP 45 | { 46 | solver GAMG; 47 | tolerance 1e-8; 48 | relTol 0.01; 49 | smoother GaussSeidel; 50 | cacheAgglomeration true; 51 | nCellsInCoarsestLevel 30; 52 | agglomerator faceAreaPair; 53 | mergeLevels 1; 54 | } 55 | 56 | U 57 | { 58 | solver PBiCG; 59 | preconditioner DILU; 60 | tolerance 1e-6; 61 | relTol 0; 62 | } 63 | 64 | UFinal 65 | { 66 | solver PBiCG; 67 | preconditioner DILU; 68 | tolerance 1e-7; 69 | relTol 0; 70 | } 71 | 72 | pFinal 73 | { 74 | solver GAMG; 75 | tolerance 1e-7; 76 | relTol 0.1; 77 | smoother GaussSeidel; 78 | cacheAgglomeration true; 79 | nCellsInCoarsestLevel 30; 80 | agglomerator faceAreaPair; 81 | mergeLevels 1; 82 | } 83 | 84 | m_A 85 | { 86 | solver GAMG; 87 | tolerance 1e-12; 88 | relTol 0; 89 | smoother GaussSeidel; 90 | cacheAgglomeration true; 91 | nCellsInCoarsestLevel 30; 92 | agglomerator faceAreaPair; 93 | mergeLevels 1; 94 | } 95 | 96 | } 97 | 98 | PISO 99 | { 100 | nOuterCorrectors 2; 101 | nCorrectors 1; 102 | nNonOrthogonalCorrectors 8; 103 | momentumPredictor no; 104 | } 105 | 106 | potentialFlow 107 | { 108 | nNonOrthogonalCorrectors 40; 109 | momentumPredictor yes; 110 | } 111 | 112 | SIMPLE 113 | { 114 | nNonOrthogonalCorrectors 8; 115 | residualControl 116 | { 117 | p 1e-4; 118 | m_A 1e-9; 119 | } 120 | } 121 | 122 | relaxationFactors 123 | { 124 | fields 125 | { 126 | p 1; 127 | } 128 | equations 129 | { 130 | p 1; 131 | U 0.5; 132 | m_A 0.9; 133 | } 134 | } -------------------------------------------------------------------------------- /src/solvers/pisoSaltTransport/pisoSaltTransport.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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 the 13 | Free Software Foundation; either version 2 of the License, or (at your 14 | option) any later version. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM; if not, write to the Free Software Foundation, 23 | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | 25 | Application 26 | pisoSaltTransport 27 | based on twoLiquidMixingFoam and rhoPisoFoam 28 | 29 | Description 30 | Solver for soluble salt transport in a fluid. 31 | 32 | The solver assumes the process is isothermal and uses a weakly 33 | compressible solution technique. The density is solely a function of the 34 | solute mass fraction and is calculated explicitly. 35 | 36 | The current model does not include a turbulence model as the standard 37 | compressible models require more sophisticated energy treatments. The 38 | incompressible turbulence models are not used as the density variation is 39 | significant enough that a weakly-compressible formulation is required. 40 | 41 | \*---------------------------------------------------------------------------*/ 42 | 43 | #include "fvCFD.H" 44 | #include "MULES.H" 45 | 46 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 47 | 48 | int main(int argc, char *argv[]) 49 | { 50 | #include "setRootCase.H" 51 | #include "createTime.H" 52 | #include "createMesh.H" 53 | #include "readGravitationalAcceleration.H" 54 | #include "readControls.H" 55 | #include "createFields.H" 56 | #include "CourantNo.H" 57 | #include "setInitialDeltaT.H" 58 | #include "m_AInitialContinuity.H" 59 | 60 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 61 | 62 | Info<< "\nStarting time loop\n" << endl; 63 | 64 | while (runTime.run()) 65 | { 66 | #include "readControls.H" 67 | #include "compressibleCourantNo.H" 68 | #include "setDeltaT.H" 69 | 70 | runTime++; 71 | 72 | Info<< "Time = " << runTime.timeName() << nl << endl; 73 | 74 | // --- Outer-corrector loop 75 | for (int oCorr=0; oCorr. 23 | 24 | Class 25 | Foam::DarcyForchheimerSaltTransport 26 | 27 | Description 28 | Darcy-Forchheimer law porosity model, given by: 29 | 30 | \f[ 31 | S = - (\mu d + \frac{\rho |U|}{2} f) U 32 | \f] 33 | 34 | where 35 | \vartable 36 | d | Darcy coefficient [1/m2] 37 | f | Forchheimer coefficient [1/m] 38 | \endvartable 39 | 40 | Since negative Darcy/Forchheimer parameters are invalid, they can be used 41 | to specify a multiplier (of the max component). 42 | 43 | The orientation of the porous region is defined with the same notation as 44 | a co-ordinate system, but only a Cartesian co-ordinate system is valid. 45 | 46 | SourceFiles 47 | DarcyForchheimerSaltTransport.C 48 | DarcyForchheimerSaltTransportTemplates.C 49 | 50 | \*---------------------------------------------------------------------------*/ 51 | 52 | #ifndef DarcyForchheimerSaltTransport_H 53 | #define DarcyForchheimerSaltTransport_H 54 | 55 | #include "porosityModel.H" 56 | #include "dimensionedTensor.H" 57 | 58 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 59 | 60 | namespace Foam 61 | { 62 | namespace porosityModels 63 | { 64 | 65 | /*---------------------------------------------------------------------------*\ 66 | Class DarcyForchheimerSaltTransport Declaration 67 | \*---------------------------------------------------------------------------*/ 68 | 69 | class DarcyForchheimerSaltTransport 70 | : 71 | public porosityModel 72 | { 73 | private: 74 | 75 | // Private data 76 | 77 | 78 | //- Darcy coefficient [1/m2] 79 | List D_; 80 | 81 | //- Forchheimer coefficient [1/m] 82 | List F_; 83 | 84 | //- Name of density field 85 | word rhoName_; 86 | 87 | //- Name of dynamic viscosity field 88 | word muName_; 89 | 90 | //- Name of kinematic viscosity field 91 | word nuName_; 92 | 93 | 94 | // Private Member Functions 95 | 96 | //- Apply 97 | template 98 | void apply 99 | ( 100 | scalarField& Udiag, 101 | vectorField& Usource, 102 | const scalarField& V, 103 | const RhoFieldType& rho, 104 | const scalarField& mu, 105 | const vectorField& U 106 | ) const; 107 | 108 | //- Apply 109 | template 110 | void apply 111 | ( 112 | tensorField& AU, 113 | const RhoFieldType& rho, 114 | const scalarField& mu, 115 | const vectorField& U 116 | ) const; 117 | 118 | //- Disallow default bitwise copy construct 119 | DarcyForchheimerSaltTransport(const DarcyForchheimerSaltTransport&); 120 | 121 | //- Disallow default bitwise assignment 122 | void operator=(const DarcyForchheimerSaltTransport&); 123 | 124 | 125 | public: 126 | 127 | //- Runtime type information 128 | TypeName("DarcyForchheimerSaltTransport"); 129 | 130 | //- Constructor 131 | DarcyForchheimerSaltTransport 132 | ( 133 | const word& name, 134 | const word& modelType, 135 | const fvMesh& mesh, 136 | const dictionary& dict, 137 | const word& cellZoneName 138 | ); 139 | 140 | //- Destructor 141 | virtual ~DarcyForchheimerSaltTransport(); 142 | 143 | 144 | // Member Functions 145 | 146 | //- Calculate the porosity force 147 | virtual void calcForce 148 | ( 149 | const volVectorField& U, 150 | const volScalarField& rho, 151 | const volScalarField& mu, 152 | vectorField& force 153 | ) const; 154 | 155 | //- Add resistance 156 | virtual void correct(fvVectorMatrix& UEqn) const; 157 | 158 | //- Add resistance 159 | virtual void correct 160 | ( 161 | fvVectorMatrix& UEqn, 162 | const volScalarField& rho, 163 | const volScalarField& mu 164 | ) const; 165 | 166 | //- Add resistance 167 | virtual void correct 168 | ( 169 | const fvVectorMatrix& UEqn, 170 | volTensorField& AU 171 | ) const; 172 | 173 | 174 | // I-O 175 | 176 | //- Write 177 | bool writeData(Ostream& os) const; 178 | }; 179 | 180 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 181 | 182 | } // End namespace porosityModels 183 | } // End namespace Foam 184 | 185 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 186 | 187 | #ifdef NoRepository 188 | #include "DarcyForchheimerSaltTransportTemplates.C" 189 | #endif 190 | 191 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 192 | 193 | #endif 194 | 195 | // ************************************************************************* // 196 | -------------------------------------------------------------------------------- /src/porosityModels/DarcyForchheimerSaltTransport/porosityModel.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "porosityModel.H" 27 | #include "volFields.H" 28 | 29 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 30 | 31 | namespace Foam 32 | { 33 | defineTypeNameAndDebug(porosityModel, 0); 34 | defineRunTimeSelectionTable(porosityModel, mesh); 35 | } 36 | 37 | 38 | // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // 39 | 40 | void Foam::porosityModel::adjustNegativeResistance(dimensionedVector& resist) 41 | { 42 | scalar maxCmpt = max(0, cmptMax(resist.value())); 43 | 44 | if (maxCmpt < 0) 45 | { 46 | FatalErrorIn 47 | ( 48 | "void Foam::porosityModel::adjustNegativeResistance" 49 | "(" 50 | "dimensionedVector&" 51 | ")" 52 | ) << "Negative resistances are invalid, resistance = " << resist 53 | << exit(FatalError); 54 | } 55 | else 56 | { 57 | vector& val = resist.value(); 58 | for (label cmpt = 0; cmpt < vector::nComponents; cmpt++) 59 | { 60 | if (val[cmpt] < 0) 61 | { 62 | val[cmpt] *= -maxCmpt; 63 | } 64 | } 65 | } 66 | } 67 | 68 | 69 | Foam::label Foam::porosityModel::fieldIndex(const label i) const 70 | { 71 | label index = 0; 72 | if (!coordSys_.R().uniform()) 73 | { 74 | index = i; 75 | } 76 | return index; 77 | } 78 | 79 | 80 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 81 | 82 | Foam::porosityModel::porosityModel 83 | ( 84 | const word& name, 85 | const word& modelType, 86 | const fvMesh& mesh, 87 | const dictionary& dict, 88 | const word& cellZoneName 89 | ) 90 | : 91 | regIOobject 92 | ( 93 | IOobject 94 | ( 95 | name, 96 | mesh.time().timeName(), 97 | mesh, 98 | IOobject::NO_READ, 99 | IOobject::NO_WRITE 100 | ) 101 | ), 102 | name_(name), 103 | mesh_(mesh), 104 | dict_(dict), 105 | coeffs_(dict.subDict(modelType + "Coeffs")), 106 | active_(true), 107 | zoneName_(cellZoneName), 108 | cellZoneIDs_(), 109 | coordSys_(coordinateSystem::New(mesh, coeffs_)) 110 | { 111 | if (zoneName_ == word::null) 112 | { 113 | dict.lookup("active") >> active_; 114 | dict_.lookup("cellZone") >> zoneName_; 115 | } 116 | 117 | cellZoneIDs_ = mesh_.cellZones().findIndices(zoneName_); 118 | 119 | Info<< " creating porous zone: " << zoneName_ << endl; 120 | 121 | bool foundZone = !cellZoneIDs_.empty(); 122 | reduce(foundZone, orOp()); 123 | 124 | if (!foundZone && Pstream::master()) 125 | { 126 | FatalErrorIn 127 | ( 128 | "Foam::porosityModel::porosityModel" 129 | "(" 130 | "const word&, " 131 | "const word&, " 132 | "const fvMesh&, " 133 | "const dictionary&" 134 | "const word&, " 135 | ")" 136 | ) << "cannot find porous cellZone " << zoneName_ 137 | << exit(FatalError); 138 | } 139 | } 140 | 141 | 142 | // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 143 | 144 | Foam::porosityModel::~porosityModel() 145 | {} 146 | 147 | 148 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 149 | 150 | Foam::tmp Foam::porosityModel::porosityModel::force 151 | ( 152 | const volVectorField& U, 153 | const volScalarField& rho, 154 | const volScalarField& mu 155 | ) const 156 | { 157 | tmp tforce(new vectorField(U.size(), vector::zero)); 158 | 159 | if (!cellZoneIDs_.empty()) 160 | { 161 | this->calcForce(U, rho, mu, tforce()); 162 | } 163 | 164 | return tforce; 165 | } 166 | 167 | 168 | void Foam::porosityModel::addResistance 169 | ( 170 | fvVectorMatrix& UEqn 171 | ) const 172 | { 173 | if (cellZoneIDs_.empty()) 174 | { 175 | return; 176 | } 177 | 178 | this->correct(UEqn); 179 | } 180 | 181 | 182 | void Foam::porosityModel::addResistance 183 | ( 184 | fvVectorMatrix& UEqn, 185 | const volScalarField& rho, 186 | const volScalarField& mu 187 | ) const 188 | { 189 | if (cellZoneIDs_.empty()) 190 | { 191 | return; 192 | } 193 | 194 | this->correct(UEqn, rho, mu); 195 | } 196 | 197 | 198 | void Foam::porosityModel::addResistance 199 | ( 200 | const fvVectorMatrix& UEqn, 201 | volTensorField& AU, 202 | bool correctAUprocBC 203 | ) const 204 | { 205 | if (cellZoneIDs_.empty()) 206 | { 207 | return; 208 | } 209 | 210 | this->correct(UEqn, AU); 211 | 212 | if (correctAUprocBC) 213 | { 214 | // Correct the boundary conditions of the tensorial diagonal to ensure 215 | // processor boundaries are correctly handled when AU^-1 is interpolated 216 | // for the pressure equation. 217 | AU.correctBoundaryConditions(); 218 | } 219 | } 220 | 221 | 222 | bool Foam::porosityModel::movePoints() 223 | { 224 | // no updates necessary; all member data independent of mesh 225 | return true; 226 | } 227 | 228 | 229 | void Foam::porosityModel::updateMesh(const mapPolyMesh& mpm) 230 | { 231 | // no updates necessary; all member data independent of mesh 232 | } 233 | 234 | 235 | bool Foam::porosityModel::writeData(Ostream& os) const 236 | { 237 | return true; 238 | } 239 | 240 | bool Foam::porosityModel::read(const dictionary& dict) 241 | { 242 | active_ = readBool(dict.lookup("active")); 243 | coeffs_ = dict.subDict(type() + "Coeffs"); 244 | dict.lookup("cellZone") >> zoneName_; 245 | cellZoneIDs_ = mesh_.cellZones().findIndices(zoneName_); 246 | 247 | return true; 248 | } 249 | 250 | 251 | // ************************************************************************* // 252 | -------------------------------------------------------------------------------- /src/porosityModels/DarcyForchheimerSaltTransport/DarcyForchheimerSaltTransport.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "addToRunTimeSelectionTable.H" 27 | #include "DarcyForchheimerSaltTransport.H" 28 | #include "geometricOneField.H" 29 | #include "fvMatrices.H" 30 | 31 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 32 | 33 | namespace Foam 34 | { 35 | namespace porosityModels 36 | { 37 | defineTypeNameAndDebug(DarcyForchheimerSaltTransport, 0); 38 | addToRunTimeSelectionTable(porosityModel, DarcyForchheimerSaltTransport, mesh); 39 | } 40 | } 41 | 42 | 43 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 44 | 45 | Foam::porosityModels::DarcyForchheimerSaltTransport::DarcyForchheimerSaltTransport 46 | ( 47 | const word& name, 48 | const word& modelType, 49 | const fvMesh& mesh, 50 | const dictionary& dict, 51 | const word& cellZoneName 52 | ) 53 | : 54 | porosityModel(name, modelType, mesh, dict, cellZoneName), 55 | D_(cellZoneIDs_.size()), 56 | F_(cellZoneIDs_.size()), 57 | rhoName_(coeffs_.lookupOrDefault("rho", "rho")), 58 | muName_(coeffs_.lookupOrDefault("mu", "thermo:mu")), 59 | nuName_(coeffs_.lookupOrDefault("nu", "nu")) 60 | { 61 | 62 | dimensionedVector d(coeffs_.lookup("d")); 63 | dimensionedVector f(coeffs_.lookup("f")); 64 | 65 | adjustNegativeResistance(d); 66 | adjustNegativeResistance(f); 67 | 68 | if (coordSys_.R().uniform()) 69 | { 70 | forAll (cellZoneIDs_, zoneI) 71 | { 72 | D_[zoneI].setSize(1, tensor::zero); 73 | F_[zoneI].setSize(1, tensor::zero); 74 | 75 | D_[zoneI][0].xx() = d.value().x(); 76 | D_[zoneI][0].yy() = d.value().y(); 77 | D_[zoneI][0].zz() = d.value().z(); 78 | 79 | D_[zoneI][0] = coordSys_.R().transformTensor(D_[zoneI][0]); 80 | 81 | // leading 0.5 is from 1/2*rho 82 | F_[zoneI][0].xx() = 0.5*f.value().x(); 83 | F_[zoneI][0].yy() = 0.5*f.value().y(); 84 | F_[zoneI][0].zz() = 0.5*f.value().z(); 85 | 86 | F_[zoneI][0] = coordSys_.R().transformTensor(F_[zoneI][0]); 87 | } 88 | 89 | } 90 | else 91 | { 92 | forAll(cellZoneIDs_, zoneI) 93 | { 94 | const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]]; 95 | 96 | D_[zoneI].setSize(cells.size(), tensor::zero); 97 | F_[zoneI].setSize(cells.size(), tensor::zero); 98 | 99 | forAll(cells, i) 100 | { 101 | D_[zoneI][i].xx() = d.value().x(); 102 | D_[zoneI][i].yy() = d.value().y(); 103 | D_[zoneI][i].zz() = d.value().z(); 104 | 105 | // leading 0.5 is from 1/2*rho 106 | F_[zoneI][i].xx() = 0.5*f.value().x(); 107 | F_[zoneI][i].yy() = 0.5*f.value().y(); 108 | F_[zoneI][i].zz() = 0.5*f.value().z(); 109 | } 110 | 111 | D_[zoneI] = coordSys_.R().transformTensor(D_[zoneI], cells); 112 | F_[zoneI] = coordSys_.R().transformTensor(F_[zoneI], cells); 113 | } 114 | } 115 | } 116 | 117 | 118 | // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 119 | 120 | Foam::porosityModels::DarcyForchheimerSaltTransport::~DarcyForchheimerSaltTransport() 121 | {} 122 | 123 | 124 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 125 | 126 | void Foam::porosityModels::DarcyForchheimerSaltTransport::calcForce 127 | ( 128 | const volVectorField& U, 129 | const volScalarField& rho, 130 | const volScalarField& mu, 131 | vectorField& force 132 | ) const 133 | { 134 | scalarField Udiag(U.size(), 0.0); 135 | vectorField Usource(U.size(), vector::zero); 136 | const scalarField& V = mesh_.V(); 137 | 138 | apply(Udiag, Usource, V, rho, mu, U); 139 | 140 | force = Udiag*U - Usource; 141 | } 142 | 143 | 144 | void Foam::porosityModels::DarcyForchheimerSaltTransport::correct 145 | ( 146 | fvVectorMatrix& UEqn 147 | ) const 148 | { 149 | const vectorField& U = UEqn.psi(); 150 | const scalarField& V = mesh_.V(); 151 | scalarField& Udiag = UEqn.diag(); 152 | vectorField& Usource = UEqn.source(); 153 | if (UEqn.dimensions() == dimForce) 154 | { 155 | const volScalarField& rho = 156 | mesh_.lookupObject(rhoName_); 157 | // In this model we use the viscosity as determined by the salt conc. 158 | // const volScalarField& mu = 159 | // mesh_.lookupObject(muName_); 160 | const volScalarField& mu = 161 | mesh_.lookupObject(nuName_); 162 | apply(Udiag, Usource, V, rho, mu, U); 163 | } 164 | else 165 | { 166 | const volScalarField& nu = 167 | mesh_.lookupObject(nuName_); 168 | 169 | apply(Udiag, Usource, V, geometricOneField(), nu, U); 170 | } 171 | } 172 | 173 | 174 | void Foam::porosityModels::DarcyForchheimerSaltTransport::correct 175 | ( 176 | fvVectorMatrix& UEqn, 177 | const volScalarField& rho, 178 | const volScalarField& mu 179 | ) const 180 | { 181 | const vectorField& U = UEqn.psi(); 182 | const scalarField& V = mesh_.V(); 183 | scalarField& Udiag = UEqn.diag(); 184 | vectorField& Usource = UEqn.source(); 185 | 186 | apply(Udiag, Usource, V, rho, mu, U); 187 | } 188 | 189 | 190 | void Foam::porosityModels::DarcyForchheimerSaltTransport::correct 191 | ( 192 | const fvVectorMatrix& UEqn, 193 | volTensorField& AU 194 | ) const 195 | { 196 | const vectorField& U = UEqn.psi(); 197 | 198 | if (UEqn.dimensions() == dimForce) 199 | { 200 | const volScalarField& rho = 201 | mesh_.lookupObject(rhoName_); 202 | const volScalarField& mu = 203 | mesh_.lookupObject(muName_); 204 | 205 | apply(AU, rho, mu, U); 206 | } 207 | else 208 | { 209 | const volScalarField& nu = 210 | mesh_.lookupObject(nuName_); 211 | 212 | apply(AU, geometricOneField(), nu, U); 213 | } 214 | } 215 | 216 | 217 | bool Foam::porosityModels::DarcyForchheimerSaltTransport::writeData(Ostream& os) const 218 | { 219 | os << indent << name_ << endl; 220 | dict_.write(os); 221 | 222 | return true; 223 | } 224 | 225 | 226 | // ************************************************************************* // 227 | -------------------------------------------------------------------------------- /src/utilities/sampleMembrane/sampleMembrane.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Application 25 | sampleMembrane 26 | 27 | Description 28 | Samples the p, U and m_A field of a membrane patch and prints to post processing file 29 | 30 | \*---------------------------------------------------------------------------*/ 31 | 32 | #include "fvCFD.H" 33 | 34 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | timeSelector::addOptions(); 39 | #include "addRegionOption.H" 40 | argList::validArgs.append("patchName"); 41 | #include "setRootCase.H" 42 | #include "createTime.H" 43 | instantList timeDirs = timeSelector::select0(runTime, args); 44 | #include "createNamedMesh.H" 45 | 46 | const word patchName = args[1]; 47 | 48 | forAll(timeDirs, timeI) 49 | { 50 | runTime.setTime(timeDirs[timeI], timeI); 51 | Info<< "Time = " << runTime.timeName() << endl; 52 | 53 | // Get the fields 54 | IOobject VelocityHeader 55 | ( 56 | "U", 57 | runTime.timeName(), 58 | mesh, 59 | IOobject::MUST_READ 60 | ); 61 | 62 | IOobject saltHeader 63 | ( 64 | "m_A", 65 | runTime.timeName(), 66 | mesh, 67 | IOobject::MUST_READ 68 | ); 69 | 70 | IOobject PressureHeader 71 | ( 72 | "p", 73 | runTime.timeName(), 74 | mesh, 75 | IOobject::MUST_READ 76 | ); 77 | 78 | IOobject ShearHeader 79 | ( 80 | "wallShearStress", 81 | runTime.timeName(), 82 | mesh, 83 | IOobject::MUST_READ 84 | ); 85 | 86 | // Check fields exists 87 | if (VelocityHeader.headerOk() && saltHeader.headerOk() && PressureHeader.headerOk()) 88 | { 89 | mesh.readUpdate(); 90 | 91 | // Check that the patch is there 92 | const label patchI = mesh.boundaryMesh().findPatchID(patchName); 93 | if (patchI < 0) 94 | { 95 | FatalError 96 | << "Unable to find patch " << patchName << nl 97 | << exit(FatalError); 98 | } 99 | 100 | // Give patch area 101 | Info<< " Area vector of patch " 102 | << patchName << '[' << patchI << ']' << " = " 103 | << gSum(mesh.Sf().boundaryField()[patchI]) << endl; 104 | Info<< " Area magnitude of patch " 105 | << patchName << '[' << patchI << ']' << " = " 106 | << gSum(mesh.magSf().boundaryField()[patchI]) << endl; 107 | 108 | // Write out face centers of patch 109 | IOField cfOut 110 | ( 111 | IOobject 112 | ( 113 | patchName+"_coordinates", 114 | mesh.time().timeName(), 115 | mesh, 116 | IOobject::NO_READ, 117 | IOobject::NO_WRITE 118 | ), 119 | mesh.Cf().boundaryField()[ patchI ] 120 | ); 121 | cfOut.write(); 122 | 123 | // Write out face area of patch 124 | IOField sfOut 125 | ( 126 | IOobject 127 | ( 128 | patchName+"_face_areas", 129 | mesh.time().timeName(), 130 | mesh, 131 | IOobject::NO_READ, 132 | IOobject::NO_WRITE 133 | ), 134 | mesh.magSf().boundaryField()[ patchI ] 135 | ); 136 | sfOut.write(); 137 | 138 | // Write out the other fields 139 | Info<< " Reading m_A" << endl; 140 | volScalarField saltField(saltHeader, mesh); 141 | 142 | Info<< " Reading U" << endl; 143 | volVectorField velocityField(VelocityHeader, mesh); 144 | 145 | Info<< " Reading p" << endl; 146 | volScalarField pressureField(PressureHeader, mesh); 147 | 148 | // Write out the values 149 | IOField saltOut 150 | ( 151 | IOobject 152 | ( 153 | saltField.name()+"_"+patchName+"_values", 154 | mesh.time().timeName(), 155 | mesh, 156 | IOobject::NO_READ, 157 | IOobject::NO_WRITE 158 | ), 159 | saltField.boundaryField()[ patchI ] 160 | ); 161 | saltOut.write(); 162 | 163 | IOField pressureOut 164 | ( 165 | IOobject 166 | ( 167 | pressureField.name()+"_"+patchName+"_values", 168 | mesh.time().timeName(), 169 | mesh, 170 | IOobject::NO_READ, 171 | IOobject::NO_WRITE 172 | ), 173 | pressureField.boundaryField()[ patchI ] 174 | ); 175 | pressureOut.write(); 176 | 177 | IOField velocityOut 178 | ( 179 | IOobject 180 | ( 181 | velocityField.name()+"_"+patchName+"_values", 182 | mesh.time().timeName(), 183 | mesh, 184 | IOobject::NO_READ, 185 | IOobject::NO_WRITE 186 | ), 187 | velocityField.boundaryField()[ patchI ] 188 | ); 189 | velocityOut.write(); 190 | 191 | // Also output shear stresses 192 | if( ShearHeader.headerOk() ){ 193 | Info<< " Reading wallShearStress" << endl; 194 | volVectorField shearField(ShearHeader, mesh); 195 | IOField shearOut 196 | ( 197 | IOobject 198 | ( 199 | shearField.name()+"_"+patchName+"_values", 200 | mesh.time().timeName(), 201 | mesh, 202 | IOobject::NO_READ, 203 | IOobject::NO_WRITE 204 | ), 205 | shearField.boundaryField()[ patchI ] 206 | ); 207 | shearOut.write(); 208 | } 209 | 210 | 211 | } 212 | else 213 | { 214 | Info<< " Could not find all fields. p, U and m_A required. " << endl; 215 | } 216 | 217 | Info<< endl; 218 | } 219 | 220 | Info<< "End\n" << endl; 221 | 222 | return 0; 223 | } 224 | 225 | 226 | // ************************************************************************* // 227 | -------------------------------------------------------------------------------- /src/porosityModels/DarcyForchheimerSaltTransport/porosityModel.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::porosityModel 26 | 27 | Description 28 | Top level model for porosity models 29 | 30 | SourceFiles 31 | porosityModel.C 32 | porosityModelNew.C 33 | 34 | \*---------------------------------------------------------------------------*/ 35 | 36 | #ifndef porosityModel_H 37 | #define porosityModel_H 38 | 39 | #include "fvMesh.H" 40 | #include "dictionary.H" 41 | #include "fvMatricesFwd.H" 42 | #include "runTimeSelectionTables.H" 43 | #include "coordinateSystem.H" 44 | #include "dimensionedVector.H" 45 | #include "keyType.H" 46 | 47 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 48 | 49 | namespace Foam 50 | { 51 | 52 | /*---------------------------------------------------------------------------*\ 53 | Class porosityModel Declaration 54 | \*---------------------------------------------------------------------------*/ 55 | 56 | class porosityModel 57 | : 58 | public regIOobject 59 | { 60 | private: 61 | 62 | // Private Member Functions 63 | 64 | //- Disallow default bitwise copy construct 65 | porosityModel(const porosityModel&); 66 | 67 | //- Disallow default bitwise assignment 68 | void operator=(const porosityModel&); 69 | 70 | 71 | protected: 72 | 73 | // Protected data 74 | 75 | //- Porosity name 76 | word name_; 77 | 78 | //- Reference to the mesh database 79 | const fvMesh& mesh_; 80 | 81 | //- Dictionary used for model construction 82 | const dictionary dict_; 83 | 84 | //- Model coefficients dictionary 85 | dictionary coeffs_; 86 | 87 | //- Porosity active flag 88 | bool active_; 89 | 90 | //- Name(s) of cell-zone 91 | keyType zoneName_; 92 | 93 | //- Cell zone IDs 94 | labelList cellZoneIDs_; 95 | 96 | //- Local co-ordinate system 97 | coordinateSystem coordSys_; 98 | 99 | 100 | // Protected Member Functions 101 | 102 | //- Adjust negative resistance values to be multiplier of max value 103 | void adjustNegativeResistance(dimensionedVector& resist); 104 | 105 | //- Calculate the porosity force 106 | virtual void calcForce 107 | ( 108 | const volVectorField& U, 109 | const volScalarField& rho, 110 | const volScalarField& mu, 111 | vectorField& force 112 | ) const = 0; 113 | 114 | virtual void correct(fvVectorMatrix& UEqn) const = 0; 115 | 116 | virtual void correct 117 | ( 118 | fvVectorMatrix& UEqn, 119 | const volScalarField& rho, 120 | const volScalarField& mu 121 | ) const = 0; 122 | 123 | virtual void correct 124 | ( 125 | const fvVectorMatrix& UEqn, 126 | volTensorField& AU 127 | ) const = 0; 128 | 129 | //- Return label index 130 | label fieldIndex(const label index) const; 131 | 132 | 133 | public: 134 | 135 | //- Runtime type information 136 | TypeName("porosityModel"); 137 | 138 | //- Selection table 139 | declareRunTimeSelectionTable 140 | ( 141 | autoPtr, 142 | porosityModel, 143 | mesh, 144 | ( 145 | const word& modelName, 146 | const word& name, 147 | const fvMesh& mesh, 148 | const dictionary& dict, 149 | const word& cellZoneName 150 | ), 151 | (modelName, name, mesh, dict, cellZoneName) 152 | ); 153 | 154 | //- Constructor 155 | porosityModel 156 | ( 157 | const word& name, 158 | const word& modelType, 159 | const fvMesh& mesh, 160 | const dictionary& dict, 161 | const word& cellZoneName = word::null 162 | ); 163 | 164 | //- Return pointer to new porosityModel object created on the freestore 165 | // from an Istream 166 | class iNew 167 | { 168 | //- Reference to the mesh database 169 | const fvMesh& mesh_; 170 | const word& name_; 171 | 172 | public: 173 | 174 | iNew 175 | ( 176 | const fvMesh& mesh, 177 | const word& name 178 | ) 179 | : 180 | mesh_(mesh), 181 | name_(name) 182 | {} 183 | 184 | autoPtr operator()(Istream& is) const 185 | { 186 | const dictionary dict(is); 187 | 188 | return autoPtr 189 | ( 190 | porosityModel::New 191 | ( 192 | name_, 193 | mesh_, 194 | dict 195 | ) 196 | ); 197 | } 198 | }; 199 | 200 | //- Selector 201 | static autoPtr New 202 | ( 203 | const word& name, 204 | const fvMesh& mesh, 205 | const dictionary& dict, 206 | const word& cellZoneName = word::null 207 | ); 208 | 209 | //- Destructor 210 | virtual ~porosityModel(); 211 | 212 | 213 | // Member Functions 214 | 215 | //- Return const access to the porosity model name 216 | inline const word& name() const; 217 | 218 | //- Return const access to the porosity active flag 219 | inline bool active() const; 220 | 221 | //- Return const access to the cell zone IDs 222 | inline const labelList& cellZoneIDs() const; 223 | 224 | //- Return the force over the cell zone(s) 225 | virtual tmp force 226 | ( 227 | const volVectorField& U, 228 | const volScalarField& rho, 229 | const volScalarField& mu 230 | ) const; 231 | 232 | //- Add resistance 233 | virtual void addResistance(fvVectorMatrix& UEqn) const; 234 | 235 | //- Add resistance 236 | virtual void addResistance 237 | ( 238 | fvVectorMatrix& UEqn, 239 | const volScalarField& rho, 240 | const volScalarField& mu 241 | ) const; 242 | 243 | //- Add resistance 244 | virtual void addResistance 245 | ( 246 | const fvVectorMatrix& UEqn, 247 | volTensorField& AU, 248 | bool correctAUprocBC 249 | ) const; 250 | 251 | 252 | // Topology change 253 | 254 | //- Move points 255 | virtual bool movePoints(); 256 | 257 | //- Update on meshUpdate 258 | virtual void updateMesh(const mapPolyMesh& mpm); 259 | 260 | 261 | // I-O 262 | 263 | //- Write 264 | virtual bool writeData(Ostream& os) const; 265 | 266 | //- Read porosity dictionary 267 | virtual bool read(const dictionary& dict); 268 | }; 269 | 270 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 271 | 272 | } // End namespace Foam 273 | 274 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 275 | 276 | #include "porosityModelI.H" 277 | 278 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 279 | 280 | #endif 281 | 282 | // ************************************************************************* // 283 | -------------------------------------------------------------------------------- /src/boundaryConditions/RO_BC/explicitROmembraneVelocity/explicitROmembraneVelocityFvPatchVectorField.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 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 the 13 | Free Software Foundation; either version 2 of the License, or (at your 14 | option) any later version. 15 | 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 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM; if not, write to the Free Software Foundation, 23 | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | 25 | Class 26 | Foam::explicitROmembraneVelocityFvPatchVectorField 27 | 28 | Description 29 | Foam::explicitROmembraneVelocityFvPatchVectorField 30 | 31 | this boundary condition is designed to simulate a membrane 32 | across which the velocity is set by the pressure difference calculated 33 | from the previous timestep. The concentration can also be set. The full 34 | boundary condition set up with typical values is given below: 35 | { 36 | type explicitROmembraneVelocity; 37 | value uniform (0 0 0);// initialisation value 38 | K 2e-10; // K coefficient 39 | m_A none; // field of concentration in moles (can be set 40 | // to "none" or left out if the osmotic 41 | // pressure is not to taken into account 42 | } 43 | Density changes across the membrane are taken into account. 44 | 45 | The values of hydrodynamic pressure do not take gravity explicitly into 46 | account, so it is assumed that the membrane has a thickness of zero. 47 | 48 | SourceFiles 49 | explicitROmembraneVelocityFvPatchVectorField.C 50 | 51 | \*---------------------------------------------------------------------------*/ 52 | 53 | #ifndef explicitROmembraneVelocityFvPatchVectorField_H 54 | #define explicitROmembraneVelocityFvPatchVectorField_H 55 | 56 | #include "fixedValueFvPatchFields.H" 57 | 58 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 59 | 60 | namespace Foam 61 | { 62 | 63 | /*---------------------------------------------------------------------------*\ 64 | Class explicitROmembraneVelocityFvPatch Declaration 65 | \*---------------------------------------------------------------------------*/ 66 | 67 | class explicitROmembraneVelocityFvPatchVectorField 68 | : 69 | public fixedValueFvPatchVectorField 70 | { 71 | // Private data 72 | 73 | //- Transport Properties dictionary 74 | IOdictionary transProps_; 75 | 76 | //- Name of the pressure field 77 | word pName_; 78 | 79 | //- Name of the concentration field 80 | word m_AName_; 81 | 82 | //- K coefficient 83 | scalar K_; 84 | 85 | //- Osmotic pressure coefficient 86 | dimensionedScalar pi_mACoeff_; 87 | 88 | //- Solution density 89 | dimensionedScalar rho0_; 90 | 91 | //- Density m_A coefficient 92 | dimensionedScalar rho_mACoeff_; 93 | 94 | //- face indexing list 95 | List