# How to code Strang splitting ?

 Register Blogs Members List Search Today's Posts Mark Forums Read January 11, 2020, 13:41 How to code Strang splitting ? #1 Member   Join Date: Mar 2019 Posts: 40 Rep Power: 3 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, 14:28 #2 Member   Join Date: Mar 2019 Posts: 40 Rep Power: 3 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, 12:48 #3 Member   alexander thierfelder Join Date: Dec 2019 Posts: 64 Rep Power: 2 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, 08:46 #4 Member   alexander thierfelder Join Date: Dec 2019 Posts: 64 Rep Power: 2 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, 07:25 #5 Member   alexander thierfelder Join Date: Dec 2019 Posts: 64 Rep Power: 2 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 15:23.  Thread Tools Search this Thread Show Printable Version Email this Page Search this Thread: Advanced Search Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 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 OffTrackbacks are Off Pingbacks are On Refbacks are On Forum Rules Similar Threads Thread Thread Starter Forum Replies Last Post plasmaCode Main CFD Forum 3 December 12, 2015 22:10 holger_marschall OpenFOAM 242 March 7, 2013 12:30 cwang5 OpenFOAM Programming & Development 1 May 30, 2011 04:47 MechE OpenFOAM 28 May 16, 2011 11:02 Zdravko Stojanovic Main CFD Forum 2 July 19, 2010 10:11

All times are GMT -4. The time now is 18:46.