-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
241 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <cmath> | ||
#include <config.h> | ||
#include <core/boundary_conditions/nonuniform_dirichlet.h> | ||
|
||
template <int dim> | ||
void | ||
customNonuniformDirichlet<dim>::set_nonuniform_dirichlet( | ||
[[maybe_unused]] const uint &index, | ||
[[maybe_unused]] const uint &boundary_id, | ||
[[maybe_unused]] const uint &component, | ||
[[maybe_unused]] const dealii::Point<dim> &point, | ||
[[maybe_unused]] double &scalar_value, | ||
[[maybe_unused]] double &vector_component_value) const | ||
{ | ||
if (index == 0) | ||
{ | ||
if (boundary_id == 0 || boundary_id == 1) | ||
{ | ||
scalar_value = std::sin(point[1] * M_PI); | ||
} | ||
} | ||
} | ||
|
||
INSTANTIATE_UNI_TEMPLATE(customNonuniformDirichlet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
include/core/boundary_conditions/nonuniform_dirichlet.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#ifndef nonuniform_dirichlet_h | ||
#define nonuniform_dirichlet_h | ||
|
||
#include <deal.II/base/function.h> | ||
#include <deal.II/lac/vector.h> | ||
|
||
#include <core/type_enums.h> | ||
|
||
/** | ||
* \brief Forward declaration of user-facing implementation | ||
*/ | ||
template <int dim> | ||
class customNonuniformDirichlet; | ||
|
||
/** | ||
* \brief Function for user-implemented nonuniform dirichlet boundary condition. | ||
*/ | ||
template <int dim, fieldType field_type = fieldType::SCALAR> | ||
class nonuniformDirichlet : public dealii::Function<dim, double> | ||
{ | ||
public: | ||
/** | ||
* \brief Constructor. | ||
*/ | ||
nonuniformDirichlet(const uint &_index, const uint &_boundary_id) | ||
: dealii::Function<dim>((field_type == fieldType::VECTOR) ? dim : 1) | ||
, index(_index) | ||
, boundary_id(_boundary_id) {}; | ||
|
||
/** | ||
* \brief Scalar value. | ||
*/ | ||
double | ||
value(const dealii::Point<dim> &p, const unsigned int component = 0) const override; | ||
|
||
/** | ||
* \brief Vector value. | ||
*/ | ||
void | ||
vector_value(const dealii::Point<dim> &p, dealii::Vector<double> &value) const override; | ||
|
||
private: | ||
const uint index; | ||
|
||
const uint boundary_id; | ||
|
||
customNonuniformDirichlet<dim> custom_nonuniform_dirichlet; | ||
}; | ||
|
||
template <int dim, fieldType field_type> | ||
inline double | ||
nonuniformDirichlet<dim, field_type>::value( | ||
const dealii::Point<dim> &p, | ||
[[maybe_unused]] const unsigned int component) const | ||
{ | ||
// Initialize passed variables to zero | ||
double scalar_value = 0.0; | ||
dealii::Vector<double> vector_value(dim); | ||
|
||
// Pass variables to user-facing function to evaluate | ||
custom_nonuniform_dirichlet | ||
.set_nonuniform_dirichlet(index, boundary_id, 0, p, scalar_value, vector_value(0)); | ||
|
||
return scalar_value; | ||
} | ||
|
||
template <int dim, fieldType field_type> | ||
inline void | ||
nonuniformDirichlet<dim, field_type>::vector_value(const dealii::Point<dim> &p, | ||
dealii::Vector<double> &value) const | ||
{ | ||
// Initialize passed variables to zero | ||
double scalar_value = 0.0; | ||
dealii::Vector<double> vector_value(dim); | ||
|
||
// Pass variables to user-facing function to evaluate | ||
for (uint i = 0; i < dim; i++) | ||
{ | ||
custom_nonuniform_dirichlet.set_nonuniform_dirichlet(index, | ||
boundary_id, | ||
i, | ||
p, | ||
scalar_value, | ||
vector_value(i)); | ||
} | ||
|
||
value = vector_value; | ||
} | ||
|
||
/** | ||
* \brief User-facing implementation of nonuniform boundary conditions | ||
*/ | ||
template <int dim> | ||
class customNonuniformDirichlet | ||
{ | ||
public: | ||
/** | ||
* \brief Constructor. | ||
*/ | ||
customNonuniformDirichlet() = default; | ||
|
||
/** | ||
* \brief Function that passes the value/vector and point that are set in the nonuniform | ||
* dirichlet. | ||
*/ | ||
void | ||
set_nonuniform_dirichlet(const uint &index, | ||
const uint &boundary_id, | ||
const uint &component, | ||
const dealii::Point<dim> &point, | ||
double &scalar_value, | ||
double &vector_component_value) const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.