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

Port mixing length model to the gpu path (and gradient fix, part 2) #226

Merged
merged 10 commits into from
Aug 31, 2023

Conversation

trevilo
Copy link
Contributor

@trevilo trevilo commented Aug 31, 2023

This PR adds the mixing length turbulence model to the gpu path. Two notable developments are included:

As evidence that the implemenation is correct, pipe.mix.test has been added to the tests that run on gpu systems.

The goal is to enable MixingLengthTransport on the gpu.  Prior to this
commit, this class was surrounded by a #if that prevented it from
being compiled in gpu builds.  Simply removing this #if leads to test
failures, b/c the design of the MixingLengthTransport---specifically,
where some methods call the same method from a different class.  This
seems to confuse nvcc, even though the MixingLengthTransport class is
not even instantiated in the gpu path yet.  Specifically, test
failures are observed (e.g., the parallel tests in cyl3d.gpu.test
fail).

I think the problem is related to the issue first noticed in #184 and
then dealt with (via a workaround) in #203.  To work around it here, a
new class MolecularTransport is introduced, where the flux and source
transport functions can have a different signature (b/c they never
need the distance function, for example).  This is enough to avoid the
problem---i.e., all the tests pass.
Wanted to use dynamic_cast to cast the TransportProperties pointer
that M2ulPhyS holds to MolecularTransport (as in the cpu path), but
host-side dynamic_cast on a device-side pointer seg faults, and
device-side call to dynamic_cast isn't allowed.  So... go ahead and
pass the TransportProperties pointer and use a regular cast on the
device.
Two bugs in setting the distance function arrays for the interior
faces on the gpu path.  This data are only used in the
MixingLengthTransport class, and since we only just started trying to
make that work on the gpu path, it was just noticed now.

The useBCinGrad flag is not implemented on the gpu yet, so
pipe.mix.test fails.  However, if that flag is set to false on the cpu
path, then the result of that case is the same on the gpu and the cpu
(to within the soln_differ tolerance).
This test will fail currently, b/c the useBCinGrad option is not
implemented for the gpu path.  Goal now is to fix this.
This commit implements the useBCinGrad flag on the gpu path.  When
this flag is on, for a no-slip adiabatic wall, the velocity (0) and
user-set temperature are used in boundary terms that appear in the
system defining the gradient.  Otherwise, these terms are ignored,
which is incorrect.

Since the terms were ignored before, there was no infrastructure for
looping over boundary faces in forming the gradient system on the gpu
path.  This commit adds this infrastructure, which is slightly more
complicated than analogous face loops (i.e., interior and 'shared'
faces) due to the fact that periodic faces are counted as boundary
faces by mfem (see mfem::Mesh::GetNBE vs mfem::Mesh::GetNFbyType).

The infrastructure is added in the minimal way possible---i.e., just
for no-slip, isothermal walls.  The BC infrastructure will need to be
refactored to make it easy to support all BC types.
In addition to modifying the gradient calculation, when the
useBCinGrad flag is on, we use a mass-conserving variant of the weak
wall BC.  This commit implements this on the gpu path.
Two mods... first, add logic to determine how to run parallel job to
pipe.mix.test, so that it can run with flux on systems where mpirun
isn't available.  Second, relax pipe.mix.test tolerance slightly.
Observed small increase in deltas on some (not all) cuda systems where
tests run.
@trevilo trevilo added the enhancement New feature or request label Aug 31, 2023
@trevilo trevilo self-assigned this Aug 31, 2023
During development, BC info was hard-coded (to 3-velocity no slip,
300K).  This commit removes this.  Velocity is still assumed to be
zero, but temperature is taken from the input file.  This is hacked in
via the boundaryFaceIntegrationData struct, which is suboptimal and
should be refactored to easily support other BC types.
@trevilo trevilo changed the title Port mixing length model on the gpu path (and gradient fix, part 2) Port mixing length model to the gpu path (and gradient fix, part 2) Aug 31, 2023
@trevilo trevilo marked this pull request as ready for review August 31, 2023 20:07
@trevilo trevilo merged commit d536b9b into main Aug 31, 2023
10 checks passed
@trevilo trevilo deleted the dev-mixing-length-gpu branch July 19, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant