Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
cahn_hilliard_boundary_conditions.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_cahn_hilliard_boundary_conditions_h
5#define lethe_cahn_hilliard_boundary_conditions_h
6
8#include <core/utilities.h>
9
10#include <deal.II/base/function.h>
11#include <deal.II/base/parameter_handler.h>
12#include <deal.II/base/parsed_function.h>
13
14#include <map>
15#include <memory>
16#include <vector>
17
18using namespace dealii;
19
20namespace BoundaryConditions
21{
22 /// Boundary condition types of the Cahn-Hilliard equations. periodic_neighbor
23 /// is not a user choice: it is assigned to the boundary matching a periodic
24 /// boundary.
35
36 /// Boundary condition types of the Cahn-Hilliard equations which can be
37 /// selected in the parameter file
38 inline const std::vector<CahnHilliardBoundaryType>
45
46 /**
47 * @brief This class manages the functions associated with function-type boundary conditions
48 * of the Cahn-Hilliard equations
49 */
50 template <int dim>
52 {
53 public:
54 // Cahn-Hilliard variables
55 Functions::ParsedFunction<dim> phi;
56 Functions::ParsedFunction<dim> eta;
57 };
58
59 /**
60 * @brief This class manages the boundary conditions for the Cahn-Hilliard solver
61 * It introduces the boundary functions and declares the boundary conditions
62 * coherently.
63 */
64 template <int dim>
66 : public BoundaryConditions<CahnHilliardBoundaryType>
67 {
68 public:
69 std::map<types::boundary_id, double> angle_of_contact;
70 std::map<types::boundary_id, double> phase_dirichlet_value;
71 std::map<types::boundary_id,
72 std::shared_ptr<CahnHilliardBoundaryFunctions<dim>>>
74
75 /**
76 * @brief Declare the default parameters for one Cahn-Hilliard boundary condition.
77 *
78 * @param[in, out] prm The parameter handler object.
79 * @param[in] default_boundary_id The default mesh boundary id.
80 */
81 void
82 declare_default_entry(ParameterHandler &prm,
83 types::boundary_id default_boundary_id);
84
85 /**
86 * @brief Declare the Cahn-Hilliard boundary condition parameters.
87 *
88 * @param[in, out] prm The parameter handler object.
89 * @param[in] number_of_boundary_conditions The number of boundary
90 * conditions to declare.
91 */
92 void
93 declare_parameters(ParameterHandler &prm,
95
96 /**
97 * @brief Parse the information for one Cahn-Hilliard boundary condition.
98 *
99 * @param[in] prm The parameter handler object.
100 */
101 void
102 parse_boundary(ParameterHandler &prm);
103
104 /**
105 * @brief Parse the Cahn-Hilliard boundary condition parameters.
106 *
107 * @param[in] prm The parameter handler object.
108 */
109 void
110 parse_parameters(ParameterHandler &prm);
111 };
112} // namespace BoundaryConditions
113
114
115/**
116 * @brief Class that implements a boundary conditions for the Cahn-Hilliard equation
117 * where the phase and chemical potential are defined using individual functions
118 */
119template <int dim>
120class CahnHilliardFunctionDefined : public Function<dim>
121{
122private:
123 Functions::ParsedFunction<dim> *phi;
124
125public:
126 /**
127 * @brief Initialize the Cahn-Hilliard boundary function with its phase field.
128 *
129 * @param[in] p_phi The parsed function defining the phase field.
130 */
131 CahnHilliardFunctionDefined(Functions::ParsedFunction<dim> *p_phi)
132 : Function<dim>(2)
133 , phi(p_phi)
134 {}
135
136 /**
137 * @brief Calculates the value of a Function-type for the Cahn-Hilliard equations
138 *
139 * @param[in] p A point (generally a gauss point)
140 * @param[in] component The vector component of the boundary condition (0-x,
141 * 1-y and 2-z)
142 */
143 double
144 value(const Point<dim> &p, unsigned int component) const override;
145};
146
147#endif
This class manages the boundary conditions for the Cahn-Hilliard solver It introduces the boundary fu...
void parse_parameters(ParameterHandler &prm)
Parse the Cahn-Hilliard boundary condition parameters.
void declare_default_entry(ParameterHandler &prm, types::boundary_id default_boundary_id)
Declare the default parameters for one Cahn-Hilliard boundary condition.
void declare_parameters(ParameterHandler &prm, unsigned int number_of_boundary_conditions)
Declare the Cahn-Hilliard boundary condition parameters.
std::map< types::boundary_id, std::shared_ptr< CahnHilliardBoundaryFunctions< dim > > > bcFunctions
void parse_boundary(ParameterHandler &prm)
Parse the information for one Cahn-Hilliard boundary condition.
This class manages the functions associated with function-type boundary conditions of the Cahn-Hillia...
CahnHilliardFunctionDefined(Functions::ParsedFunction< dim > *p_phi)
Initialize the Cahn-Hilliard boundary function with its phase field.
double value(const Point< dim > &p, unsigned int component) const override
Calculates the value of a Function-type for the Cahn-Hilliard equations.
Functions::ParsedFunction< dim > * phi
const std::vector< CahnHilliardBoundaryType > cahn_hilliard_boundary_types