-
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
Volumetric source terms #2220
Volumetric source terms #2220
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.
Only minor things.
{ | ||
DBUG("Assemble NodalSourceTerm."); | ||
DBUG("Integrate NodalSourceTerm."); |
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.
Hmm... A nodal source term is not really integrated...
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.
Renamed.
ProcessLib/SourceTerms/SourceTerm.h
Outdated
class SourceTerm | ||
{ | ||
public: | ||
SourceTerm(const NumLib::LocalToGlobalIndexMap& source_term_dof_table) |
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: explicit
. ✅
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.
some parts are lost, it seems... But when you add mesh and variable's id to it, it's not needed then...
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.
explicit still missing...
|
||
#include "VolumetricSourceTerm.h" | ||
|
||
#include <cassert> |
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 needed I guess.:white_check_mark:
: volumetric_source_term(volumetric_source_term_) | ||
{} | ||
|
||
VolumetricSourceTermData(VolumetricSourceTermData&& other) |
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.
Maybe now we don't have to specify that explicitly anymore due to newer compilers. ✅
|
||
struct VolumetricSourceTermData final | ||
{ | ||
VolumetricSourceTermData( |
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: explicit
✅
TESTER vtkdiff | ||
REQUIREMENTS NOT (OGS_USE_LIS OR OGS_USE_MPI) | ||
DIFF_DATA | ||
square_1x1_quad_1e2_volumetricsourceterm_analytical_solution.vtu square_1e2_volumetricsourceterm_pcs_0_ts_1_t_1.000000.vtu analytical_solution pressure 1e-14 1e-16 |
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.
Is the solution a linear slope or a constant? OGS is extremely close to the analytical result.
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 analytical solution is h(x,y) = - 1/2 (x^2 + x) + 2.
@@ -0,0 +1 @@ | |||
Declares a source term to be associated to the entire domain. |
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.
Maybe Declares a source term that is defined on the entire domain.
✅
@@ -0,0 +1,2 @@ | |||
The name of the parameter that defines value that should be used for the source | |||
term. |
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 value
.
Maybe a comment that nodal parameters are not supported would be appropriate. And maybe there should also be an addendum that the user should carefully check which physical quantity that parameter is. It's not necessarily the same as \dot{primary_variable}
.
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 do not understand what is meant by 'nodal parameter'. Can you explain, please?
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.
Suggestion to keep the comment as is, and bake another PR handling this case.
|
||
The solution of this problem is | ||
$$ | ||
h(x,y) = - 1 \over 2 (x^2 + x) + 2. |
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 fraction seems to be set wrongly. Btw. in LaTex there is \frac{...}{...}
. ✅
[menu.benchmarks] | ||
parent = "elliptic" | ||
|
||
+++ |
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 test is OK and nicely documented, but for an actual user it might be more instructive to have some physical quantities with some actual units.
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.
You are right. I'll ask @WaltherM or @Thomas-TK for a more practical test.
#pragma once | ||
|
||
#include <memory> | ||
#include "ProcessLib/Process.h" |
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.
Use forward decls like in CreateBoundaryCondition.h ... ✅
|
||
private: | ||
NumLib::LocalToGlobalIndexMap const& _dof_table; | ||
std::size_t const _bulk_mesh_id; | ||
MeshLib::Mesh const& _st_mesh; | ||
int const _variable_id; |
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 move both, the variable's id and the mesh to the base class. The mesh is the domain of definition.
The variable's id is also part of domain of definition.
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 also thought about this. The VolumetricSourceTerm is also derived from the class SourceTerm and it doesn't need the mesh and the variable id as attributes. In the VolumetricSourceTerm implementation the mesh and the variable id are only used in the constructor.
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, got it. Keep it as is.
source_term_dof_table.getNumberOfVariableComponents(variable_id)) | ||
{ | ||
OGS_FATAL( | ||
"Variable id or component id too high. Actual values: (%d, %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.
Could be split in two errors...
|
||
#include "SourceTerm.h" | ||
#include "VolumetricSourceTermFEM.h" | ||
#include "VolumetricSourceTermData.h" |
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.
Some of the includes could be replaced with fwd decls. ✅
VolumetricSourceTermData(VolumetricSourceTermData&&) = default; | ||
|
||
//! Copies are forbidden. | ||
VolumetricSourceTermData(VolumetricSourceTermData const&) = delete; |
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.
Question: If the base class has a deleted assignment op or ctor, is a default assignment op or ctor created implicitly in the derived class?
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.
cppreference:
A defaulted copy assignment operator for class T is defined as deleted if T has a virtual base class that cannot be copy-assigned (selects a deleted or inaccessible function).
I'm unsure if this is an answer to your question?
### Comparison of the analytical solution and the computed solution | ||
|
||
{{< img src="../square_1e2_volumetricsourceterm_pcs_0_ts_1_t_1.000000_h_AnalyticalSolution_VolumetricSourceTerm.png" >}} | ||
{{< img src="../square_1e2_volumetricsourceterm_pcs_0_ts_1_t_1.000000_Diff_h_AnalyticalSolution_VolumetricSourceTerm.png" >}} |
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.
Description of both figures is missing. The analytical solution line is not visible. In the second figure h
should be pressure
, I guess.
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.
In the formulae above the primary variable was 'h'. I renamed h -> p to make it consistent.
Preparation for the SourceTerm interface class.
63c3fab
to
3e91419
Compare
#include <vector> | ||
|
||
#include "SourceTerm.h" | ||
#include "VolumetricSourceTerm.h" |
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.
self include? Or am I missing the difference? ✅
virtual void integrate(const double t, GlobalVector& b) const = 0; | ||
|
||
virtual ~SourceTerm() = default; | ||
protected: |
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 protected? Could be private as far as I see. It can only be set in the ctor...
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.
Protected because the attribute should be used in the derived classes.
|
||
private: | ||
Parameter<double> const& _volumetric_source_term; | ||
std::vector<std::unique_ptr<VolumetricSourceTermLocalAssemblerInterface>> |
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 think a fwd-decl to the local asm interface would be sufficient...
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 fwd-decl leads to:
error: invalid application of 'sizeof' to an incomplete type 'ProcessLib::VolumetricSourceTermLocalAssemblerInterface'
|
||
template <typename ShapeFunction, typename IntegrationMethod, | ||
unsigned GlobalDim> | ||
class VolumetricSourceTermLocalAssembler |
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.
final ✅
auto const st_val = _volumetric_source_term(t, pos)[0]; | ||
|
||
_local_rhs.noalias() += | ||
sm.N * st_val * sm.detJ * sm.integralMeasure * wp.getWeight(); |
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.
It would be much better to store only the N vector in the ip data (not all of the shape matrices) and precompute the integration_weight = detJ * intMeasure * w_ip.
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.
Introduced class IntegrationPointData
, see commit 3ba3927.
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.
Looks good in general but still few things either are not yet uploaded, or forgotten.
3e91419
to
3ba3927
Compare
First approach use the original bulk mesh as integration domain.
3ba3927
to
79c3e71
Compare
OpenGeoSys development has been moved to GitLab. |
First version of volumetric source terms. Source term function has to be defined on the entire domain.