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
Adapt Robin / Neumann boundary conditions to user needs. #2710
Changes from all commits
e0b8a68
fbba655
5aaacae
b13f1bf
5574182
654a831
fc21689
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Typically boundary conditions are set on domains with dimension exactly one | ||
lower than the bulk mesh dimension. In some cases the boundary condition should | ||
be set on entities that have lower dimension than one lower. For instance | ||
boundary conditions on points in 2d or 3d domains or boundary conditions on | ||
lines in 3d domains. | ||
|
||
In order not to integrate over a null set the area tag can be used to specify | ||
the area the boundary condition should be effective. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Typically boundary conditions are set on domains with dimension exactly one | ||
lower than the bulk mesh dimension. In some cases the boundary condition should | ||
be set on entities that have lower dimension than one lower. For instance | ||
boundary conditions on points in 2d or 3d domains or boundary conditions on | ||
lines in 3d domains. | ||
|
||
In order not to integrate over a null set the area tag can be used to specify | ||
the area the boundary condition should be effective. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,6 +18,12 @@ | |||||
|
||||||
namespace ProcessLib | ||||||
{ | ||||||
struct NeumannBoundaryConditionData final | ||||||
{ | ||||||
ParameterLib::Parameter<double> const& neumann_bc_parameter; | ||||||
ParameterLib::Parameter<double> const* const integral_measure; | ||||||
}; | ||||||
|
||||||
template <typename ShapeFunction, typename IntegrationMethod, | ||||||
unsigned GlobalDim> | ||||||
class NeumannBoundaryConditionLocalAssembler final | ||||||
|
@@ -37,9 +43,9 @@ class NeumannBoundaryConditionLocalAssembler final | |||||
std::size_t const local_matrix_size, | ||||||
bool const is_axially_symmetric, | ||||||
unsigned const integration_order, | ||||||
ParameterLib::Parameter<double> const& neumann_bc_parameter) | ||||||
NeumannBoundaryConditionData const& data) | ||||||
: Base(e, is_axially_symmetric, integration_order), | ||||||
_neumann_bc_parameter(neumann_bc_parameter), | ||||||
_data(data), | ||||||
_local_rhs(local_matrix_size) | ||||||
{ | ||||||
} | ||||||
|
@@ -58,24 +64,36 @@ class NeumannBoundaryConditionLocalAssembler final | |||||
// Get element nodes for the interpolation from nodes to integration | ||||||
// point. | ||||||
NodalVectorType parameter_node_values = | ||||||
_neumann_bc_parameter.getNodalValuesOnElement(Base::_element, t) | ||||||
_data.neumann_bc_parameter | ||||||
.getNodalValuesOnElement(Base::_element, t) | ||||||
.template topRows<ShapeFunction::MeshElement::n_all_nodes>(); | ||||||
|
||||||
ParameterLib::SpatialPosition position; | ||||||
position.setElementID(Base::_element.getID()); | ||||||
|
||||||
double integral_measure = 1.0; | ||||||
for (unsigned ip = 0; ip < n_integration_points; ip++) | ||||||
{ | ||||||
position.setIntegrationPoint(ip); | ||||||
auto const& ip_data = Base::_ns_and_weights[ip]; | ||||||
auto const& N = ip_data.N; | ||||||
auto const& w = ip_data.weight; | ||||||
|
||||||
_local_rhs.noalias() += ip_data.N * | ||||||
parameter_node_values.dot(ip_data.N) * | ||||||
ip_data.weight; | ||||||
if (_data.integral_measure) | ||||||
{ | ||||||
integral_measure = (*_data.integral_measure)(t, position)[0]; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this doesn't work. See the argument in the RobinBoundaryConditionLocalAssembler case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. |
||||||
} | ||||||
_local_rhs.noalias() += | ||||||
N * parameter_node_values.dot(N) * w * integral_measure; | ||||||
} | ||||||
|
||||||
auto const indices = NumLib::getIndices(id, dof_table_boundary); | ||||||
b.add(indices, _local_rhs); | ||||||
} | ||||||
|
||||||
private: | ||||||
ParameterLib::Parameter<double> const& _neumann_bc_parameter; | ||||||
NeumannBoundaryConditionData const& _data; | ||||||
|
||||||
NodalVectorType _local_rhs; | ||||||
|
||||||
public: | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -20,6 +20,7 @@ struct RobinBoundaryConditionData final | |||||
{ | ||||||
ParameterLib::Parameter<double> const& alpha; | ||||||
ParameterLib::Parameter<double> const& u_0; | ||||||
ParameterLib::Parameter<double> const* const integral_measure; | ||||||
}; | ||||||
|
||||||
template <typename ShapeFunction, typename IntegrationMethod, | ||||||
|
@@ -64,17 +65,29 @@ class RobinBoundaryConditionLocalAssembler final | |||||
_data.u_0.getNodalValuesOnElement(Base::_element, t) | ||||||
.template topRows<ShapeFunction::MeshElement::n_all_nodes>(); | ||||||
|
||||||
ParameterLib::SpatialPosition position; | ||||||
position.setElementID(Base::_element.getID()); | ||||||
|
||||||
for (unsigned ip = 0; ip < n_integration_points; ++ip) | ||||||
{ | ||||||
position.setIntegrationPoint(ip); | ||||||
auto const& ip_data = Base::_ns_and_weights[ip]; | ||||||
auto const& N = ip_data.N; | ||||||
auto const& w = ip_data.weight; | ||||||
|
||||||
double integral_measure = 1.0; | ||||||
if (_data.integral_measure) | ||||||
{ | ||||||
integral_measure = (*_data.integral_measure)(t, position)[0]; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't declare/define the variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⏩ |
||||||
} | ||||||
|
||||||
// flux = alpha * ( u_0 - u ) | ||||||
// adding a alpha term to the diagonal of the stiffness matrix | ||||||
// and a alpha * u_0 term to the rhs vector | ||||||
_local_K.diagonal().noalias() += N * alpha.dot(N) * w; | ||||||
_local_rhs.noalias() += N * alpha.dot(N) * u_0.dot(N) * w; | ||||||
_local_K.diagonal().noalias() += | ||||||
N * alpha.dot(N) * w * integral_measure; | ||||||
_local_rhs.noalias() += | ||||||
N * alpha.dot(N) * u_0.dot(N) * w * integral_measure; | ||||||
} | ||||||
|
||||||
auto const indices = NumLib::getIndices(id, dof_table_boundary); | ||||||
|
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.
remove it if the following suggestion (fro lines 82-84) is taken .