-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add gradient data write functionality #233
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We kind of forgot about this PR in the middle of other changes. @davidscn we can also include this into the next release, we just need use/test cases.
Additional fields that could be useful would be pressure and velocity gradients in the FF module.
The changes make sense to me, and it looks like the API calls already correspond to preCICE v3.
Still needs to be documented and I would say we also need some kind of test case, to be able to maintain the feature.
I have not tested anything yet.
void preciceAdapter::CouplingDataUser::writeGradients(std::vector<double>& gradientBuffer, const unsigned int dim) | ||
{ | ||
adapterInfo("Data \"" + getDataName() + "\" does not support writing gradients. Please select a different " | ||
"data or a different mapping configuration, which does not require " | ||
"additional gradient information.", | ||
"error"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice way to default to a "not implemented" error message!
Only typo: change "a data" to just "data" or make it also "a different data configuration". ("data" is not countable)
void preciceAdapter::CHT::Temperature::writeGradients(std::vector<double>& gradientBuffer, const unsigned int dim) | ||
{ | ||
for (const label patchID : patchIDs_) | ||
{ | ||
const auto& TGrad = fvc::grad(*T_); | ||
forAll(TGrad().boundaryField()[patchID], i) | ||
{ | ||
for (unsigned int d = 0; d < dim; ++d) | ||
{ | ||
gradientBuffer[i * dim + d] = TGrad().boundaryField()[patchID][i][d]; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This essentially addresses the same problem as @thesamriel implemented in FF/TemperatureGradient.C
in https://github.com/precice/openfoam-adapter/pull/281/files#diff-90c837067b5e748c5bc1af9d24a5ab6f0a5f7801bd91685900c27491c259a830
The main difference is that:
- This PR gives the gradient of (temperature) to preCICE, as gradient data
- Updates to the FF module #281 gives the (gradient of temperature) to preCICE, as normal data values
Would these two PRs need to be aligned somehow? @thesamriel I assume that this still cannot be shaped as a replacement for the respective addition of #281.
if (precice_.isGradientDataRequired(couplingDataWriter->dataID())) | ||
{ | ||
couplingDataWriter->writeGradients(gradientBuffer_, dim_); | ||
precice_.writeBlockVectorGradientData(couplingDataWriter->dataID(), | ||
numDataLocations_, | ||
vertexIDs_, | ||
gradientBuffer_.data()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One example for vector data would be velocity. We should also implement that (in this or in a follow-up PR), otherwise this case will be completely unused for now.
... in case gradient data is required for the mapping.
The current changes only implement the functionality for a simple CHT case. We need to go through all relevant fields and have a look, where it makes sense to support this feature. We also need to find a proper solution in order to avoid code duplication in all the fields, as the 'write' step looks similar for all fields (mainly depending on the number of data components).
TODO list:
docs/
changelog-entries/
(create directory if missing)