Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Python wrapper marker BC values appropriately nondimensionalized #2078

Merged
merged 2 commits into from
Jul 30, 2023

Conversation

j-signorelli
Copy link
Contributor

Proposed Changes

In current release of SU2, having, for example, a MARKER_ISOTHERMAL=(marker, 300) and MARKER_PYTHON_CUSTOM=(marker) causes the BC temperature to be set to a nondimensional value of 300, which is inconsistent with what that marker's value is supposed to mean. This can be seen being set here:

/*--- Initialize quantities for customized boundary conditions.
* Custom values are initialized with the default values specified in the config (avoiding non physical values) ---*/
CustomBoundaryTemperature = new su2double*[nMarker];
CustomBoundaryHeatFlux = new su2double*[nMarker];
for(iMarker=0; iMarker < nMarker; iMarker++){
Marker_Tag = config->GetMarker_All_TagBound(iMarker);
CustomBoundaryHeatFlux[iMarker] = nullptr;
CustomBoundaryTemperature[iMarker] = nullptr;
if(config->GetMarker_All_PyCustom(iMarker)){
switch(config->GetMarker_All_KindBC(iMarker)){
case HEAT_FLUX:
CustomBoundaryHeatFlux[iMarker] = new su2double[nVertex[iMarker]];
for(iVertex=0; iVertex < nVertex[iMarker]; iVertex++){
CustomBoundaryHeatFlux[iMarker][iVertex] = config->GetWall_HeatFlux(Marker_Tag);
}
break;
case ISOTHERMAL:
CustomBoundaryTemperature[iMarker] = new su2double[nVertex[iMarker]];
for(iVertex=0; iVertex < nVertex[iMarker]; iVertex++){
CustomBoundaryTemperature[iMarker][iVertex] = config->GetIsothermal_Temperature(Marker_Tag);

and called for example here:

else if (config->GetMarker_All_PyCustom(val_marker)) {
Twall = geometry->GetCustomBoundaryTemperature(val_marker, iVertex);
}

This PR nondimensionalizes any custom boundary temperatures or heat fluxes appropriately so that any setting of them does not need to be nondimensionalized manually before, both in MARKER_ISOTHERMAL and MARKER_HEATFLUX and in any Python code setting values of them.

Related Work

None that I am aware of.

PR Checklist

Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

@pcarruscag
Copy link
Member

Thanks, can you look for other places where the values are used, I think the incompressible solver might need the same fix.

@j-signorelli
Copy link
Contributor Author

j-signorelli commented Jul 12, 2023

A grep -R CustomBoundaryTemperature . and grep -R CustomBoundaryHeatFlux . doesn't seem to show anything done for the incompressible solver, and also doesn't appear to be an option here at least:

/*--- Get the specified wall heat flux, temperature or heat transfer coefficient from config ---*/
su2double Wall_HeatFlux = 0.0, Twall = 0.0, Tinfinity = 0.0, Transfer_Coefficient = 0.0;
switch (kind_boundary) {
case HEAT_FLUX:
Wall_HeatFlux = config->GetWall_HeatFlux(Marker_Tag) / config->GetHeat_Flux_Ref();
if (config->GetIntegrated_HeatFlux()) {
Wall_HeatFlux /= geometry->GetSurfaceArea(config, val_marker);
}
break;
case ISOTHERMAL:
Twall = config->GetIsothermal_Temperature(Marker_Tag) / config->GetTemperature_Ref();
break;
case HEAT_TRANSFER:
Transfer_Coefficient = config->GetWall_HeatTransfer_Coefficient(Marker_Tag) * config->GetTemperature_Ref() /
config->GetHeat_Flux_Ref();
Tinfinity = config->GetWall_HeatTransfer_Temperature(Marker_Tag) / config->GetTemperature_Ref();
break;
default:
SU2_MPI::Error("Unknown type of boundary condition.", CURRENT_FUNCTION);
break;
}

However, I might have missed a spot here:

void CMultiGridGeometry::SetMultiGridWallHeatFlux(const CGeometry* fine_grid, unsigned short val_marker) {
struct {
const CGeometry* fine_grid;
unsigned short marker;
su2double* target;
su2double Get(unsigned long iVertex) const { return fine_grid->GetCustomBoundaryHeatFlux(marker, iVertex); }
void Set(unsigned long iVertex, const su2double& val) const { target[iVertex] = val; }
} wall_heat_flux;
wall_heat_flux.fine_grid = fine_grid;
wall_heat_flux.marker = val_marker;
wall_heat_flux.target = CustomBoundaryHeatFlux[val_marker];
SetMultiGridWallQuantity(fine_grid, val_marker, wall_heat_flux);
}
void CMultiGridGeometry::SetMultiGridWallTemperature(const CGeometry* fine_grid, unsigned short val_marker) {
struct {
const CGeometry* fine_grid;
unsigned short marker;
su2double* target;
su2double Get(unsigned long iVertex) const { return fine_grid->GetCustomBoundaryTemperature(marker, iVertex); }
void Set(unsigned long iVertex, const su2double& val) const { target[iVertex] = val; }
} wall_temperature;
wall_temperature.fine_grid = fine_grid;
wall_temperature.marker = val_marker;
wall_temperature.target = CustomBoundaryTemperature[val_marker];
SetMultiGridWallQuantity(fine_grid, val_marker, wall_temperature);
}

but my guess is that it's fine since values from here are re-nondimensionalized from the above commits. Please let me know if not however - I am not familiar with the specifics of multigrid and its implementation.

Note that the commits above presume that values specified in CustomBoundaryTemperature and CustomBoundaryHeatFlux in CGeometry are dimensional, regardless if SU2 is in nondimensional mode. It might make more sense to have these be nondimensional and just ensure that incoming default values from a MARKER_ISOTHERMAL and MARKER_HEATFLUX are nondimensionalized appropriately, but in my opinion it is more straightforward to have users set dimensional temperatures and heat fluxes. However, then it would also make sense to return dimensional heat fluxes and temperatures as well for Python custom walls which I am not sure is currently how it is done.

Apologies for the long explanation, but curious to hear your input on this.

I will look into why one of the regression tests failed and get back to you.

@pcarruscag
Copy link
Member

You are right, custom temperature is not implemented in the incompressible solver.
@bigfooted the inlet profiles are always dimensional now right?

@pcarruscag
Copy link
Member

You can relax the tolerance in the python script of the failing test @j-signorelli

@bigfooted
Copy link
Contributor

You are right, custom temperature is not implemented in the incompressible solver. @bigfooted the inlet profiles are always dimensional now right?

Yes, the inlet profiles are dimensional.

@pcarruscag pcarruscag merged commit c3444c8 into su2code:develop Jul 30, 2023
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants