CFD Online URL
[Sponsors]
Home > Forums > SU2

Custom Source Terms

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 30, 2013, 11:39
Default Custom Source Terms
  #1
New Member
 
Join Date: Jan 2013
Posts: 12
Rep Power: 3
sss3700 is on a distinguished road
I'm also interested in adding some custom source terms. Could you please explain the best approach to do that?
sss3700 is offline   Reply With Quote

Old   January 30, 2013, 11:51
Default
  #2
New Member
 
Amrita Lonkar
Join Date: Nov 2012
Posts: 14
Rep Power: 4
Amrita Lonkar is on a distinguished road
The best place to add new source terms to the flow equations is in the method called "Source_Template" in the file solution_direct_mean.cpp.

This method is directly connected to the rest of the code, which makes it easy to implement new source terms. You will have to specify the following option in the configuration file to activate it. SOUR_NUM_METHOD_FLOW= PIECEWISE_CONSTANT

I would also recommend that you download the new version of SU2 that will be available towards the mid of February for this particular problem, it will include some important changes to ease the implementation of new source terms.

Thanks again for your questions! Let me know if you need more assistance, we are very happy to help potential developers!

Last edited by Amrita Lonkar; January 30, 2013 at 12:15.
Amrita Lonkar is offline   Reply With Quote

Old   January 31, 2013, 01:34
Default
  #3
Member
 
Sean R. Copeland
Join Date: Jan 2013
Posts: 40
Rep Power: 3
copeland is on a distinguished road
Just a follow up on Amrita's comments:

The inviscid fluxes, viscous fluxes, and source terms are all handled independently of one another and you can see the structure by taking a look at CIntegration::Space_Integration in the integration_structure.cpp source code file. A selection of PIECEWISE_CONSTANT integration of the source terms allows for rapid implementation of new source terms in the CSource_Template class located in the numerics_source.cpp file.

There are plenty of examples of specialized source terms in numerics_source.cpp that you can reference as you input your own custom source terms.



Regards,
Sean
copeland is offline   Reply With Quote

Old   February 18, 2013, 00:05
Default
  #4
New Member
 
Join Date: Jan 2013
Posts: 12
Rep Power: 3
sss3700 is on a distinguished road
I need to use the x-y-z data for the current node in the calculation of my custom source terms. I'm trying to use the 'Coord_0' variable that I set with 'SetCoord' in 'solution_direct_mean.cpp'.

However, I get a segmentation fault when I try to use the 'Coord' variables in 'numerics_source.cpp'.

Excerpt from 'numerics_source.cpp':

Code:
void CSource_Template::SetResidual(double *val_residual, double **val_Jacobian_i, CConfig *config) {
double P,rho_u,rho_v,rho_w, xx, yy,zz,Beta_Sq,Core,L,K,A0,A1,A2,A3,
mx,my,mz, Ax,Ay,Az,dmx_dx,dmy_dy,dmz_dz,dAx_dx,dAy_dy,dAz_dz,dBx_dx,dBy_dy,dBz_dz,
dCx_dx,dCy_dy,dCz_dz,d2Ax_dxx,d2Ay_dyy,d2Az_dzz,dCore_dx,dCore_dy,dCore_dz,
dCore_dxx,dCore_dyy,dCore_dzz,dP_dx,dP_dy,dP_dz,drho_u_dx,drho_u_dy,drho_u_dz,
drho_v_dx,drho_v_dy,drho_v_dz,drho_w_dx,drho_w_dy,drho_w_dz,drho_u_dxx,drho_u_dyy,
drho_u_dzz,drho_v_dxx,drho_v_dyy,drho_v_dzz,drho_w_dxx,drho_w_dyy,drho_w_dzz, rho,
Beta_Squared, S1,S2,S3,S4,mu_tot;
 
cout << "Get Coordinates " <<endl; 
 
xx = Coord_0[0];
yy = Coord_0[1];
zz = Coord_0[2];
 
cout << "Coordinates set" << endl;
sss3700 is offline   Reply With Quote

Old   February 20, 2013, 02:42
Default
  #5
Super Moderator
 
Thomas D. Economon
Join Date: Jan 2013
Location: Stanford, CA
Posts: 225
Rep Power: 4
economon is on a distinguished road
Hi,

Sounds like you are on the right track... An example might be setting the following in solution_direct_mean.cpp:

Code:
/*--- Set coordinates ---*/
solver->SetCoord(geometry->node[iPoint]->GetCoord(),geometry->node[iPoint]->GetCoord());
and then these coordinates may be accessed in the source routine of the numerics class under the variable Coord_i, i.e. Coord_i[0], Coord_i[1], & Coord_i[2].

Hope this helps!
economon is offline   Reply With Quote

Old   February 28, 2013, 23:04
Default
  #6
New Member
 
Join Date: Jan 2013
Posts: 12
Rep Power: 3
sss3700 is on a distinguished road
I've added the following code in the CEulerSolution::Source_Residual method:

Code:
	if (MMS) {

	   /*--- loop over points ---*/
	   for (iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) { 
			
	      if ( !geometry->node[iPoint]->GetBoundary() ) { 
	         /*--- Set solution  ---*/
	         solver->SetConservative(node[iPoint]->GetSolution(), node[iPoint]->GetSolution());

	         /*--- Set incompressible density  ---*/
	         solver->SetDensityInc(node[iPoint]->GetDensityInc(), node[iPoint]->GetDensityInc());
				
	         /*--- Set beta squared  ---*/
	         solver->SetBetaInc2(node[iPoint]->GetBetaInc2(), node[iPoint]->GetBetaInc2());

	         /*--- Set control volume ---*/
	         solver->SetVolume(geometry->node[iPoint]->GetVolume());

	         /*--- Set coordinates for MMS ---*/
	         solver->SetCoord(geometry->node[iPoint]->GetCoord(),geometry->node[iPoint]->GetCoord());

	         /*--- Compute Source term Residual ---*/
	         solver->SetResidual(Residual, Jacobian_i, config); //MMS Modification

	         /*--- Set Source Residual ---*/
	         //node[iPoint]->SetRes_Sour(Residual);
	         node[iPoint]->AddRes_Conv(Residual);

	       } //added IF for MMS Modification
	    }
	}
Is this the correct approach for adding a constant source term?
sss3700 is offline   Reply With Quote

Old   March 18, 2013, 17:46
Default
  #7
New Member
 
Join Date: Jan 2013
Posts: 12
Rep Power: 3
sss3700 is on a distinguished road
I'm also wondering if the source terms should be non-dimensionalized. If so how are the solution variables non-dimensionalized in the solver code?
sss3700 is offline   Reply With Quote

Old   March 24, 2013, 01:04
Default
  #8
Super Moderator
 
Francisco Palacios
Join Date: Jan 2013
Location: Stanford, CA
Posts: 258
Rep Power: 4
fpalacios is on a distinguished road
Quote:
Originally Posted by sss3700 View Post
I'm also wondering if the source terms should be non-dimensionalized. If so how are the solution variables non-dimensionalized in the solver code?
Hi,

The non-dimensionalization of the code is described in
http://su2.stanford.edu/documents/SU2_AIAA_ASM2013.pdf

Best,
Francisco
fpalacios is offline   Reply With Quote

Old   March 24, 2013, 22:02
Default
  #9
New Member
 
Join Date: Jan 2013
Posts: 12
Rep Power: 3
sss3700 is on a distinguished road
I've been using that document, but it mentions an "internal document" by Prof. Feng Liu: "Non-dimensionalization of the Navier-Stokes Equations" that might be the missing piece that I need.

I'm trying to write custom source terms so that I can conduct a verification of the order of accuracy of the code using the Method of Manufactured Solutions (MMS). So far it's not working, and I think it's due to the non-dimensionalization of the source terms (or there's a problem with this part of the code).
sss3700 is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
wmake compiling new solver mksca OpenFOAM Programming & Development 13 August 18, 2014 23:26
groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM 22 August 26, 2013 12:06
swak4foam building problem GGerber OpenFOAM 45 July 30, 2013 16:08
funkySetFields compilation error tayo OpenFOAM 39 December 3, 2012 06:18
Compiling gmshFoam with OpenFOAM-1.5 BlGene Open Source Meshers: Gmsh, Netgen, CGNS, ... 10 August 6, 2009 05:26


All times are GMT -4. The time now is 11:58.