# How to code Strang splitting ?

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

 January 11, 2020, 14:41 How to code Strang splitting ? #1 Member   Join Date: Mar 2019 Posts: 82 Rep Power: 6 Best wishes to all in this new year I couldn't find how to do this in openFoam and all of its variants. Strang splitting means df/dt = T + S becomes df/dt = S df/dt = T df/dt = S T stands for convective and diffusive terms whereas S stands for a source term. Also the original dt for the derivative numerical scheme is halved for both df/dt = S in the above I think what should be done for two fields f1 and f2 is as follows. (S1 and S2 may depend non linearly on both f1 and f2) .... delT = runTime.deltaT().value(); runTime.deltaT().value() = delT/2.; solve ( fvm::ddt(f1) == T1 ) ; solve ( fvm::ddt(f2) == T2 ) ; runTime.deltaT().value() = delT; solve ( fvm::ddt(f1) == S1 ) ; solve ( fvm::ddt(f2) == S2 ) ; runTime.deltaT().value() = delT/2; solve ( fvm::ddt(f1) == T1 ) ; solve ( fvm::ddt(f2) == T2 ) ; runTime.deltaT().value() = delT; .... Is anything wrong with my approach ? Any reply welcome

 January 13, 2020, 15:28 #2 Member   Join Date: Mar 2019 Posts: 82 Rep Power: 6 Well, Im going to give you a first clue you cannot set it this way doubleScalar delT = runTime.deltaT().value(); runTime.deltaT().value() = delt/2; I checked using Info that the original value isnt changed. Instead, you have to write runTime.setDeltaT ( delT/2. ); I will keep you posted after I study more about these time objects superkelle likes this.

 March 26, 2020, 13:48 #3 Member   alexander thierfelder Join Date: Dec 2019 Posts: 71 Rep Power: 6 Hey I found out that it should be possible with subCycle. But I don't know how to implement that the right way "Strang splitting is an alternative to this method, in which the sweeps are performed in a symmetric order. An odd number of sweeps are required for this splitting, i.e. M = 3, 5, 7.., and the reaction terms are always integrated explicitly at the middle iteration (M + 1)/2. The homogeneous terms are integrated implicitly. The example is given for M = 3: The sub-cycling is implemented using the built-in subCycle utility. This functionality alters the current time index of the corresponding volume field, assuring that sub-iterations are stored as t+i/N and the final iteration corresponds to the current time step t+1, instead of t+N which would be the case of the time indices are not corrected." Source: https://repository.tudelft.nl/island...m/OBJ/download

 May 24, 2020, 09:46 #4 Member   alexander thierfelder Join Date: Dec 2019 Posts: 71 Rep Power: 6 For the simplest case n =3 ,I think it should work somehow like this: Code: ```label nSubCycles = 3; dimensionedScalar totalDeltaT = runTime.deltaT(); for ( subCycle YSubCycle(Y, nSubCycles); !(YSubCycle).end(); ++YSubCycle) { if ( YsubCycle.index() != 2 ) { runTime.setDeltaT(totalDeltaT/2); #include "YEqnHom.H" YEqnHom.solve(); } else { runTime.setDeltaT(totalDeltaT); #include "YEqnHet.H" YEqnHet.solve(); } }```

 June 6, 2020, 08:25 #5 Member   alexander thierfelder Join Date: Dec 2019 Posts: 71 Rep Power: 6 And for any number of sub cycles (odd). Code: ```label nSubCycles = 5; // odd dimensionedScalar totalDeltaT = runTime.deltaT(); for ( subCycle YSubCycle(Y, nSubCycles); !(YSubCycle).end(); ++YSubCycle) { if ( YsubCycle.index() != (floor(nSubcycle/2)+1) ) { runTime.setDeltaT(totalDeltaT/(nSubcycle-1)); #include "YEqnHom.H" YEqnHom.solve(); } else { runTime.setDeltaT(totalDeltaT); #include "YEqnHet.H" YEqnHet.solve(); } }``` Last edited by superkelle; June 6, 2020 at 16:23.