-
Notifications
You must be signed in to change notification settings - Fork 239
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
Jacobian tester for local assemblers. #2238
Conversation
I just changed the checks for the M, K and b matrices as requested. I hope the changed code works. |
<jacobian_assembler> | ||
<type>CompareJacobians</type> | ||
<jacobian_assembler> | ||
<type>CentralDifferences</type> |
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.
I'd put an analytical jacobian as an example. Norbert has one.
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.
<jacobian_assembler>
<type>Analytical</type>
</jacobian_assembler>
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.
OK
@@ -41,6 +42,8 @@ class AbstractJacobianAssembler | |||
std::vector<double>& /*local_Jac_data*/, | |||
LocalCoupledSolutions const& /*coupled_solutions*/) | |||
{ | |||
// TODO make pure virtual. |
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.
Please add a short why, and maybe how (if not obvious).
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.
Why ... because implementing this can be easily forgotten in derived classes. E.g., it's not implemented in the central differences assembler if I remember correctly.
How ... obviously: make it pure virtual and add the missing implementations.
Do you really want to have these comments in the code?
//! about exceeded tolerances and assembled local matrices. | ||
std::ofstream _log_file; | ||
|
||
//! Counter used for identifying blocks in the \c _log_file. Is be |
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.
Second sentence starts with "It is", probably...
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.
Thanks.
namespace | ||
{ | ||
//! Dumps a \c double value as a Python script snippet. | ||
void dump_py(std::ofstream& fh, std::string const& var, double const val) |
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.
minor; an ostream
would be more general...
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.
✅
fh << var << " = " << val << '\n'; | ||
} | ||
|
||
//! Dumps an Eigen vector as a Python script snippet. |
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.
Dumps an arbitrary vector (of type Vec) as a Python script snippet.
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.
✅
dump_py_vec(fh, var, val); | ||
} | ||
|
||
template <typename Derived> |
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.
ah, ... and the Eigen vector comment goes here...
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.
✅
|
||
if (fatal_error) | ||
{ | ||
OGS_FATAL("%s", msg_fatal.c_str()); |
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.
Not sure if the _log_file
is flushed on std::abort
(on throw it probably is correctly closed). I'd add a flush to the _log_file before every OGS_FATAL, just in case...
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.
✅
createCompareJacobiansJacobianAssembler(BaseLib::ConfigTree const& config) | ||
{ | ||
// TODO doc script corner case: Parameter could occur at different | ||
// locations. |
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.
note to myself. ?.
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.
The parameter could be at
OpenGeoSys/processes/process/jacobian_assembler/type
or at
OpenGeoSys/processes/process/jacobian_assembler/CompareJacobians/jacobian_assembler/type
in the prj file. AFAIK this is not covered by the input parameter documentation scripts.
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.
Minor comments. Nice read!
@Scinopode If this works for you, give thumbs up, please. |
Works great, but output is still not complete (not flushed?) |
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 feature!
OpenGeoSys development has been moved to GitLab. |
As requested, here comes a simple implementation of the Jacobian tester.
Configuration in the
prj
file:Sample (Python) log file (Click to expand)
A convenient visualization of the results is possible, e.g., with Spyder (or any other Python IDE):