CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

spatially-varied time-constant diffusivity in interMixingFoam

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   July 7, 2020, 00:55
Default spatially-varied time-constant diffusivity in interMixingFoam
New Member
Ron Bardell
Join Date: Aug 2012
Posts: 5
Rep Power: 10
rbardell is on a distinguished road
I'm modeling diffusion/perfusion of two miscible chemical solutions through human tissue with interMixingFoam in OpenFOAM 7. The physical components in the domain (eg. cells, membranes, intercellular matrix) all are fixed in position during the simulation, but each component has its own diffusion coefficients in the real world. So, instead of using the constant diffusion coefficient D23, it would be more realistic to set up a volScalarField for DiffCoef (just picking a name) in the time 0 folder like is done for alpha2, use topoSetDict to define cellZones for the different physical components, and set their unique values of DiffCoef in setFieldsDict. But I suspect this would require modification of the solver and I'm better at Fortran77 and Scilab than C++ so I could use some hints.

I see that in alphaEqn.H for interMixingFoam, the constant D23 is used to construct the volScalarFields Dc23 and Dc32. So I assume these lines would need to be altered to handle D23 as a volScalarField (ie. my DiffCoef). It's not clear to me how D23 got to this namespace, but volScalarField DiffCoef would need to find its way here. Is there another solver that has a volScalarField diffusivity that I could emulate? I'm fairly good at monkey see, monkey do.

Thanks for your help, -Ron.
rbardell is offline   Reply With Quote

Old   July 8, 2020, 15:46
Default update to spatially-varied time-constant diffusivity in interMixingFoam
New Member
Ron Bardell
Join Date: Aug 2012
Posts: 5
Rep Power: 10
rbardell is on a distinguished road
This turned out to be easier than I imagined. In my test case, I set the diffusion coefficient to zero in a region and diffusion was prevented there as expected. Here is what I did, for future reference.

To create the new version of interMixingFoam, I used:

mkdir -p $WM_PROJECT_USER_DIR/applications/solvers
cp -r interMixingFoam $WM_PROJECT_USER_DIR/applications/solvers/interMixingDFieldFoam
cd $WM_PROJECT_USER_DIR/applications/solvers/interMixingDFieldFoam
mv interMixingFoam.C interMixingDFieldFoam.C
rm interMixingFoam.dep

Then I edited Make/files to update the last lines:


EXE = $(FOAM_USER_APPBIN)/interMixingDFieldFoam

I removed the old binaries:

rm -rf Make/linux64GccDPint32Opt

I tested the compilation process with:

Then confirmed the new solver binary was in:

I modified createFields.H to replace the scalar D23 with the volScalarField Diff. I doesn't need a value specified after the second "mesh", because it will be reading the field of values set in setFieldsDict. The dimensions are set in transportProperties. It is set to NO-WRITE because the initialized values are never changed.

//dimensionedScalar D23("D23", dimViscosity, mixture);
volScalarField Diff

In alphaEqn.H, I replaced D23 with Diff. No other changes needed.

// Create the diffusion coefficients for alpha2<->alpha3
// volScalarField Dc23(D23*max(alpha3, scalar(0))*pos0(alpha2));
// volScalarField Dc32(D23*max(alpha2, scalar(0))*pos0(alpha3));
volScalarField Dc23(Diff*max(alpha3, scalar(0))*pos0(alpha2));
volScalarField Dc32(Diff*max(alpha2, scalar(0))*pos0(alpha3));

I used wclean and then wmake to compile the new solver, then focused on trying it out.

In the time 0.orig folder in my case folder (run/NTB30), I added a file named Diff with all the boundary conditions set to zeroGradient. (I don't know if these are even needed):

version 2.0;
format ascii;
class volScalarField;
object Diff;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
type zeroGradient;

In the transportProperties file I replaced D23 with Diff and did not specify a value since they are initialized in setFieldsDict:

// Diffusivity between miscible phases,
//D23 80.0e-5 ;
Diff Diff [0 2 -1 0 0 0 0];

In setFieldsDict, I added Diff to the defaultFieldValues and any region (which are defined in topoSetDict) in which the value is different:

volScalarFieldValue Diff 102.0e-5

name "meshLayer";
volScalarFieldValue alpha.two 0
volScalarFieldValue alpha.three 1
volScalarFieldValue Diff 0.008
rbardell is offline   Reply With Quote


diffusion coefficient, volscalarfield

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script for pseudo-parallel usage of reconstructPar kwardle OpenFOAM Post-Processing 39 July 1, 2020 09:13
How to export time series of variables for one point? mary mor OpenFOAM Post-Processing 8 July 19, 2017 10:54
High Courant Number @ icoFoam Artex85 OpenFOAM Running, Solving & CFD 11 February 16, 2017 13:40
Extrusion with OpenFoam problem No. Iterations 0 Lord Kelvin OpenFOAM Running, Solving & CFD 8 March 28, 2016 11:08
simpleFoam error - "Floating point exception" mbcx4jc2 OpenFOAM Running, Solving & CFD 12 August 4, 2015 02:20

All times are GMT -4. The time now is 03:37.