Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
cahn_hilliard_assemblers.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2023-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_assemblers_h
5#define lethe_cahn_hilliard_assemblers_h
6
9
11#include <solvers/copy_data.h>
14
15/**
16 * @brief A pure virtual class that serves as an interface for all
17 * of the assemblers for the Cahn-Hilliard equations.
18 *
19 * @tparam dim Integer that denotes the number of spatial dimensions.
20 *
21 * @ingroup assemblers
22 */
23template <int dim>
26
27
28/**
29 * @brief Class that assembles the core of the Cahn-Hilliard equation :
30 * \f$ \frac{d \phi}{dt} + (u \cdot \nabla) \phi - \nabla \cdot (M(\phi)\nabla
31 * \eta) = 0 \\ \eta - \frac{\lambda}{\epsilon^2}(\phi^3 - \phi) + \lambda
32 * \nabla^2 \phi + \xi \nabla^2 \eta = 0 \f$
33 *
34 * @tparam dim An integer that denotes the number of spatial dimensions
35 *
36 * @ingroup assemblers
37 */
38template <int dim>
40{
41public:
50
51 /**
52 * @brief assemble_matrix Assembles the matrix
53 * @param scratch_data (see base class)
54 * @param copy_data (see base class)
55 */
56 virtual void
58 StabilizedMethodsCopyData &copy_data) override;
59
60 /**
61 * @brief assemble_rhs Assembles the rhs
62 * @param scratch_data (see base class)
63 * @param copy_data (see base class)
64 */
65 virtual void
67 StabilizedMethodsCopyData &copy_data) override;
68
69 const std::shared_ptr<SimulationControl> simulation_control;
71 // Epsilon is a coefficient that depends on the mesh size. The thickness of
72 // the interface between the two phases is proportional to epsilon
73 const double epsilon;
74};
75
76
77/**
78 * @brief Class that assembles the boundary condition on the angle of contact in the
79 * Cahn-Hilliard equations.
80 *
81 * @tparam dim An integer that denotes the number of spatial dimensions
82 *
83 * @ingroup assemblers
84 */
85template <int dim>
87 : public CahnHilliardAssemblerBase<dim>
88{
89public:
91 const std::shared_ptr<SimulationControl> &simulation_control,
93 const double epsilon,
95 &p_cahn_hilliard_boundary_conditions)
99 , cahn_hilliard_boundary_conditions(p_cahn_hilliard_boundary_conditions)
100 {}
101
102 /**
103 * @brief assemble_matrix Assembles the matrix
104 * @param scratch_data (see base class)
105 * @param copy_data (see base class)
106 */
107 virtual void
109 StabilizedMethodsCopyData &copy_data) override;
110
111 /**
112 * @brief assemble_rhs Assembles the rhs
113 * @param scratch_data (see base class)
114 * @param copy_data (see base class)
115 */
116 virtual void
117 assemble_rhs(const CahnHilliardScratchData<dim> &scratch_data,
118 StabilizedMethodsCopyData &copy_data) override;
119
120 const std::shared_ptr<SimulationControl> simulation_control;
122
123 // Epsilon is a coefficient that depends on the mesh size. The thickness of
124 // the interface between the two phases is proportional to epsilon
125 const double epsilon;
128};
129
130
131/**
132 * @brief Class that assembles the boundary condition that allows a free angle of
133 * contact, thus adding a degree of freedom to the problem
134 *
135 * @tparam dim An integer that denotes the number of spatial dimensions
136 *
137 * @ingroup assemblers
138 */
139template <int dim>
141{
142public:
144 const std::shared_ptr<SimulationControl> &simulation_control,
146 const double epsilon,
148 &p_cahn_hilliard_boundary_conditions)
152 , cahn_hilliard_boundary_conditions(p_cahn_hilliard_boundary_conditions)
153 {}
154
155 /**
156 * @brief assemble_matrix Assembles the matrix
157 * @param scratch_data (see base class)
158 * @param copy_data (see base class)
159 */
160 virtual void
162 StabilizedMethodsCopyData &copy_data) override;
163
164 /**
165 * @brief assemble_rhs Assembles the rhs
166 * @param scratch_data (see base class)
167 * @param copy_data (see base class)
168 */
169 virtual void
170 assemble_rhs(const CahnHilliardScratchData<dim> &scratch_data,
171 StabilizedMethodsCopyData &copy_data) override;
172
173 const std::shared_ptr<SimulationControl> simulation_control;
175
176 // Epsilon is a coefficient that depends on the mesh size. The thickness of
177 // the interface between the two phases is proportional to espilon
178 const double epsilon;
181};
182
183
184/**
185 * @brief Class that assembles the transient time arising from BDF time
186 * integration for the Cahn-Hilliard equations. For example, if a BDF1 scheme is
187 * chosen, the following is assembled
188 * \f$\frac{\mathbf{T}^{t+\Delta t}-\mathbf{T}^{t}}{\Delta t}\f$
189 *
190 * @tparam dim An integer that denotes the number of spatial dimensions
191 *
192 * @ingroup assemblers
193 */
194template <int dim>
196{
197public:
199 const std::shared_ptr<SimulationControl> &simulation_control)
201 {}
202
203 /**
204 * @brief assemble_matrix Assembles the matrix
205 * @param scratch_data (see base class)
206 * @param copy_data (see base class)
207 */
208
209 virtual void
211 StabilizedMethodsCopyData &copy_data) override;
212
213 /**
214 * @brief assemble_rhs Assembles the rhs
215 * @param scratch_data (see base class)
216 * @param copy_data (see base class)
217 */
218 virtual void
219 assemble_rhs(const CahnHilliardScratchData<dim> &scratch_data,
220 StabilizedMethodsCopyData &copy_data) override;
221
222 const std::shared_ptr<SimulationControl> simulation_control;
223};
224
225
226#endif
PhysicsAssemblerBase< CahnHilliardScratchData< dim >, StabilizedMethodsCopyData > CahnHilliardAssemblerBase
A pure virtual class that serves as an interface for all of the assemblers for the Cahn-Hilliard equa...
This class manages the boundary conditions for the Cahn-Hilliard solver It introduces the boundary fu...
CahnHilliardAssemblerAngleOfContact(const std::shared_ptr< SimulationControl > &simulation_control, const Parameters::CahnHilliard cahn_hilliard_parameters, const double epsilon, const BoundaryConditions::CahnHilliardBoundaryConditions< dim > &p_cahn_hilliard_boundary_conditions)
const Parameters::CahnHilliard cahn_hilliard_parameters
const std::shared_ptr< SimulationControl > simulation_control
virtual void assemble_matrix(const CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data) override
assemble_matrix Assembles the matrix
const BoundaryConditions::CahnHilliardBoundaryConditions< dim > & cahn_hilliard_boundary_conditions
virtual void assemble_rhs(const CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data) override
assemble_rhs Assembles the rhs
const std::shared_ptr< SimulationControl > simulation_control
virtual void assemble_matrix(const CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data) override
assemble_matrix Assembles the matrix
CahnHilliardAssemblerBDF(const std::shared_ptr< SimulationControl > &simulation_control)
virtual void assemble_rhs(const CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data) override
assemble_rhs Assembles the rhs
const std::shared_ptr< SimulationControl > simulation_control
virtual void assemble_rhs(const CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data) override
assemble_rhs Assembles the rhs
CahnHilliardAssemblerCore(const std::shared_ptr< SimulationControl > &simulation_control, const Parameters::CahnHilliard cahn_hilliard_parameters, const double epsilon)
const Parameters::CahnHilliard cahn_hilliard_parameters
virtual void assemble_matrix(const CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data) override
assemble_matrix Assembles the matrix
const std::shared_ptr< SimulationControl > simulation_control
virtual void assemble_matrix(const CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data) override
assemble_matrix Assembles the matrix
virtual void assemble_rhs(const CahnHilliardScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data) override
assemble_rhs Assembles the rhs
const Parameters::CahnHilliard cahn_hilliard_parameters
const BoundaryConditions::CahnHilliardBoundaryConditions< dim > & cahn_hilliard_boundary_conditions
CahnHilliardAssemblerFreeAngle(const std::shared_ptr< SimulationControl > &simulation_control, const Parameters::CahnHilliard cahn_hilliard_parameters, const double epsilon, const BoundaryConditions::CahnHilliardBoundaryConditions< dim > &p_cahn_hilliard_boundary_conditions)
Class that stores the information required by the assembly procedure for the Cahn-Hilliard equations....
Base class for assembler objects of physics and subequations.
Class responsible for storing the information calculated using the assembly of stabilized scalar equa...
Definition copy_data.h:67
Simulation control classes for managing time-stepping and iteration control in Lethe.