diff --git a/doc/docs/Documentation/User/Aliases/index.md b/doc/docs/Documentation/User/Aliases/index.md new file mode 100644 index 00000000..135a6213 --- /dev/null +++ b/doc/docs/Documentation/User/Aliases/index.md @@ -0,0 +1,55 @@ +# Aliases + +Every `SLOTH` test needs the same handful of type aliases (finite element collection, variables, post-processing, mesh, boundary conditions...) plus a couple of factory functions. Instead of declaring them one by one, a single line brings in everything for a given spatial dimension: + +```c++ +using namespace Sloth2D; // or Sloth1D / Sloth3D +``` + +That's it — no need to write out `FECollection`, `VARS`, `SPA`, etc. by hand anymore. + +## What you get with `using namespace SlothND` + +| Alias | Description | Typical use | +| ----------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `DIM` | Spatial dimension | Passed to many objects... | +| `FECollection` | Finite element collection (`mfem::H1_FECollection`) | Passed to `SPA`/`BCS` if you need it explicitly | +| `VARS` | Collection of variables | `VARS vars(var1, var2, ...)` | +| `VAR` | A single variable | `VAR phi(&spatial, bcs, "phi", ...)` | +| `PST` | Post-processing object | `PST pst(&spatial, pst_parameters)` | +| `SPA` | Spatial discretization | `SPA spatial(mesh_type, ...)` | +| `SPAS` | `std::vector` | Returned by the [SpatialDiscretization factories](../SpatialDiscretization/Meshing/index.md#factory) | +| `BCS` | Boundary conditions | `BCS bcs(&spatial, boundaries)` | +| `PB_MPI` | `MPI_Problem` | 0D / lumped-parameter problems | +| `PB_CALPHAD` | `Calphad_Problem` | Calphad-driven problems | +| `PB_PROPERTY` | `Property_problem` | Property-driven problems | + +None of these depend on whether the problem is transient or steady — that's why one `using namespace` is enough to get all of them, regardless of the scheme used. + +## PDE aliases + +`TransientOPE`/`TransientPB`/`SteadyOPE`/`SteadyPB` are already included in the single `using namespace Sloth2D;` shown above — no extra namespace is required: + +```c++ +using namespace Sloth2D; +``` + +| Alias | Description | +| -------------- | ---------------------------------------------------------- | +| `TransientOPE` | The operator (`TransientOperator<...>`) | +| `SteadyOPE` | The operator (`SteadyOperator<...>`) | +| `TransientPB` | The transient problem (`Problem`) | +| `SteadyPB` | The steady problem (`Problem`) | + + + +## Practical cheat sheet + +- **One scheme only, minimal setup** → `using namespace Sloth2D;` +- **Both schemes in the same file** → use `TransientPB`/`SteadyPB`, `TransientOPE`/`SteadyOPE`. +- **1D or 3D** → replace `2D` with `1D`/`3D` everywhere above. +- **Building many spatial discretizations / boundary conditions / a coupling** : + - `setSpatialDiscretization(N, args...)` : builds `N` spatial discretizations sharing a single **non-periodic** mesh — see [Meshing](../SpatialDiscretization/Meshing/index.md#factory). + - `setPeriodicSpatialDiscretization(N, args...)` : same as above, for a **periodic** mesh — see [Meshing](../SpatialDiscretization/Meshing/index.md#factory). + - `setBoundaryConditions(N, spatials, boundaries)` : builds `N` boundary conditions, one per spatial discretization, from a single shared list of `Boundary` objects — see [Boundary Conditions](../SpatialDiscretization/BoundaryConditions/index.md#factory). + - `setCoupling(name, problems)` : couples `N` `Problem` objects of the same type into a single `Coupling`, without repeating the type by hand — see [Couplings](../MultiPhysicsCouplingScheme/Couplings/index.md#factory). diff --git a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Convergence/index.md b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Convergence/index.md index 561e8af8..d9761c9e 100644 --- a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Convergence/index.md +++ b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Convergence/index.md @@ -29,7 +29,7 @@ The `PhysicalConvergence` objects are defined by: auto conv_criteria = Convergence(phi_cvg, mu_cvg); - Problem my_problem(my_operator, my_variables, my_post_processing, conv_criteria); + TransientPB my_problem(my_operator, my_variables, my_post_processing, conv_criteria); ``` !!! note "On the use of `Convergence` objects" diff --git a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Couplings/index.md b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Couplings/index.md index b4bf75b4..20945bf4 100644 --- a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Couplings/index.md +++ b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Couplings/index.md @@ -2,6 +2,9 @@ This page described how to define and manage couplings in `SLOTH`. + +## __Coupling different problems__ {#coupling} + Couplings for `SLOTH` are made with a C++ object of type `Coupling`. They must be defined by: @@ -23,6 +26,28 @@ They must be defined by: ``` +## __Coupling N identical problems__ {#factory} + +This approach work naturally when each problem has a distinct role, but becomes impractical when coupling `N` problems of the **same** type `PB`, as encountered for multiphase-field simulations. +In that case, it is recommended to use `setCoupling`, which enables building repeated type from a `std::vector`, with `N` given explicitly as a template parameter: + +!!! example "Coupling 30 identical problems" + In this example, 30 identical Allen-Cahn problems for simulating polycristaline microstructure are used to define a `Coupling` + + ```c++ + std::vector ac_pbs; + ac_pbs.reserve(30); + // ... fill ac_pbs with 30 Problem objects ... + + auto cc = setCoupling<30>("Multigrains", ac_pbs); + ``` + This is equivalent to `Coupling("Multigrains", ac_pbs[0], ac_pbs[1], ..., ac_pbs[29])`, without writing out the repeated type or the 30 arguments by hand. + +!!! warning "Consistency between N and the size of the vector" + `N` must match the size of the vector exactly + + + diff --git a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/0D/index.md b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/0D/index.md index 37d07917..94abe63b 100644 --- a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/0D/index.md +++ b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/0D/index.md @@ -9,10 +9,8 @@ Definition of CALPHAD problems for `SLOTH` is made with a C++ object of type `Ca `Calphad_Problem` is a template class instantiated with three template parameters: first, a CALPHAD object, second, the `Variables` object, and third, the `Postprocessing` object. !!! example "Alias declaration for `Calphad_Problem` class template" - ```c++ - using CalphadProblem = Calphad_Problem; - ``` - + The alias `PB_CALPHAD` is provided by `SLOTH` namespaces (see the [Aliases page](../../../Aliases/index.md)). + In this alias, `CALPHAD` refers to a Calphad-type model. `Calphad_Problem` objects are defined by @@ -123,7 +121,7 @@ where $`R`$ is the molar gas constant, $`T`$ the temperature and $`x`$ the mola In this example, a fictitious `Calphad_Problem` based on `AnalyticalIdealSolution` is defined with `Parameters` (see `calphad_parameters`), outputs (primary `Variables`) and inputs (auxiliary `Variables`, here T, P, composition) ```c++ - Calphad_Problem, VARS, PST> my_calphad_problem = CalphadProblem(calphad_parameters, outputs, calphad_pst, T, P, composition); + PB_CALPHAD> my_calphad_problem = CalphadProblem(calphad_parameters, outputs, calphad_pst, T, P, composition); ``` @@ -216,6 +214,6 @@ The parameters associated with `CalphadInformedNeuralNetwork` are own_mobility_model, input_composition_order, element_removed_from_nn_inputs) - Calphad_Problem, VARS, PST> my_calphad_problem = CalphadProblem(calphad_parameters, outputs, calphad_pst, T, P, composition); + PB_CALPHAD> my_calphad_problem = CalphadProblem(calphad_parameters, outputs, calphad_pst, T, P, composition); ``` diff --git a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/PDEs/index.md b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/PDEs/index.md index 40d8d180..38a78ddc 100644 --- a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/PDEs/index.md +++ b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/PDEs/index.md @@ -30,11 +30,6 @@ For `SLOTH`, all PDEs are solved using a unified nonlinear algorithm based on th Definition of PDEs for `SLOTH` is made with a C++ object of type `Problem`, which is a template class instantiated with three template parameters: first, an `OPERATOR` object, second, a [Variables](../../../Variables/index.md) object (see `VARS` in the example), and third, a [PostProcessing](../../../PostProcessing/index.md) object (see `PST` in the example). -!!! example "Alias declaration for `Problem` class template" - ```c++ - using PDE = Problem; - ``` - The `OPERATOR` object in `Problem` refers to an object that inherits from base classes responsible for solving the nonlinear system (1). These classes are illustrated in the figure 2: `OperatorBase` is a base class with two derived classes: @@ -340,13 +335,9 @@ In the figure 3, the integrators are gathered in two grouped: `TransientOperator` is a template class instantiated with two template parameters: first, the kind of finite element and second, the spatial dimension. !!! example "Alias declaration for `TransientOperator` class template" - This example show how to define a convenient alias for the `TransientOperator` class template instantiated with `mfem::H1_FECollection` in dimension 3. - - ```c++ - using OPERATOR = TransientOperator; - ``` - - The `OPERATOR` operator must be defined by: + The alias `TransientOPE` is provided by `SLOTH` namespaces (see the [Aliases page](../../../Aliases/index.md)) for operator used in unsteady problems + + The `TransientOPE` operator must be defined by: - a vector of spatial discretisation objects (see [Meshing](../../../SpatialDiscretization/Meshing/index.md)) [required], - a vector of strings specifying the integrators used to model spatial differential operators [required], @@ -371,21 +362,19 @@ In the figure 3, the integrators are gathered in two grouped: !!! example "Definition of a transient operator" This example assume a Cahn-Hilliard problem with two unknowns (`phi` and `mu`). - The `OPERATOR` object, denoted by `phasefield_ope`, is well declared with a vector of two [spatial discretization](../../../SpatialDiscretization/index.md) objects, the `CahnHilliard` and `SplitTimeDerivative` integrators and an Euler Implicit time-stepping method. + The `OPERATOR` object, denoted by `phasefield_ope`, is well declared with a vector of two [spatial discretization](../../../SpatialDiscretization/index.md) objects (see the alias `SPAS` provided by a [`SLOTH` namespace](../../../Aliases/index.md)), the `CahnHilliard` and `SplitTimeDerivative` integrators and an Euler Implicit time-stepping method. ```c++ - using OPERATOR = TransientOperator; - std::vector spatials{&spatial, &spatial}; - OPERATOR phasefield_ope(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + SPAS spatials{&spatial, &spatial}; + TransientOPE phasefield_ope(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); ``` !!! example "Definition of a transient operator with a combination of integrators" The integrators for the differential operators can be combined. ```c++ - using OPERATOR = TransientOperator; - std::vector spatials{&spatial}; - OPERATOR phasefield_ope(spatials, {"AllenCahn", "MeltingConstant"}, TimeScheme::EulerImplicit, "TimeDerivative"); + SPAS spatials{&spatial}; + TransientOPE phasefield_ope(spatials, {"AllenCahn", "MeltingConstant"}, TimeScheme::EulerImplicit, "TimeDerivative"); ``` In the following example, the operator enables to solve the following equation: @@ -404,13 +393,9 @@ In the figure 3, the integrators are gathered in two grouped: `SteadyOperator` is a template class instantiated with two template parameters: first, the kind of finite element and second, the spatial dimension. !!! example "Alias declaration for `SteadyOperator` class template" - This example show how to define a convenient alias for the `SteadyOperator` class template instantiated with `mfem::H1_FECollection` in dimension 3. - - ```c++ - using OPERATOR = SteadyOperator; - ``` + The alias `SteadyOPE` is provided by `SLOTH` namespaces (see the [Aliases page](../../../Aliases/index.md)) for operator used in steady problems - The `OPERATOR` operator must be defined by: + The `SteadyOPE` operator must be defined by: - a vector of spatial discretisation objects (see [Meshing](../../../SpatialDiscretization/Meshing/index.md)) [required], - a vector of strings specifying the integrators used to model spatial differential operators [required], @@ -426,27 +411,26 @@ In the figure 3, the integrators are gathered in two grouped: The `OPERATOR` object, denoted by `phasefield_ope`, is well declared with a vector of one [spatial discretization](../../../SpatialDiscretization/index.md) object and the `AllenCahn` integrator. ```c++ - using OPERATOR = SteadyOperator; - std::vector spatials{&spatial, &spatial}; - OPERATOR phasefield_ope(spatials, {"AllenCahn"}); + SPAS spatials{&spatial, &spatial}; + SteadyOPE phasefield_ope(spatials, {"AllenCahn"}); ``` ### __Problems__ {#problems} As already mentioned, `Problem` for `SLOTH` is a template class instantiated with three template parameters: first, an `OPERATOR` object, second, a [Variables](../../../Variables/index.md) object, and third, a [PostProcessing](../../../PostProcessing/index.md) object. + !!! example "Alias declaration for `Problem` class template" - ```c++ - using PDE = Problem; - ``` + The aliases `SteadyPB` and `TransientPB` are provided by `SLOTH` namespaces (see the [Aliases page](../../../Aliases/index.md)) for steady and unsteady problems, respectively. + -The `PDE` problem must be defined by: +The `SteadyPB` and `TransientPB` problems must be defined by: - - an [Operator](#operators) [required], + - a [`TransientOPE/SteadyOPE`](#operators) [required], - primary [Variables](../../../Variables/index.md) [required], - a vector of [Coefficients](../../../Coefficients/index.md) [required], - a set of parameters (see [Parameters](../../../Parameters/index.md)) [optional], - - an [PostProcessing](../../../PostProcessing/index.md) object [required], + - an [PostProcessing](../../../PostProcessing/index.md) object [optional], - a set of [auxiliary Variables](../../../Variables/index.md) [optional]. @@ -461,8 +445,7 @@ The `PDE` problem must be defined by: !!! example "Definition of a Cahn-Hilliard problem" ```c++ - using OPERATOR = SteadyOperator; - std::vector spatials{&spatial, &spatial}; + SPAS spatials{&spatial, &spatial}; // Variables: phi, mu auto phi = VAR(&spatial, bcs_phi, "phi", Glossary::PhaseField, 2, phi_initial_condition); @@ -470,7 +453,7 @@ The `PDE` problem must be defined by: auto vars = VARS(phi, mu); // Operator - OPE phasefield_ope(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE phasefield_ope(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); // Coefficients // Interface thickness @@ -487,7 +470,7 @@ The `PDE` problem must be defined by: Coefficients coef_phase_field(double_well, capillary, mobility, grad_energy); // Problem (pst is PostProcessing object not detailed here) - PDE phase_field_pb(phasefield_ope, vars, {coef_phase_field, coef_phase_field}, pst); + TransientPB phase_field_pb(phasefield_ope, vars, {coef_phase_field, coef_phase_field}, pst); ``` @@ -512,7 +495,7 @@ The `PDE` problem must be defined by: ``` - The `OPERATOR` object, denoted by `phasefield_ope`, is well declared with a vector of two [spatial discretization](../../../SpatialDiscretization/index.md) objects, the `CahnHilliard` integrator for the right-hand-side of PDEs and the `SplitTimeDerivative` for the left-hand-side. + The `TransientOPE` object, denoted by `phasefield_ope`, is well declared with a vector of two [spatial discretization](../../../SpatialDiscretization/index.md) objects (see the alias `SPAS` provided by a [`SLOTH` namespace](../../../Aliases/index.md)), the `CahnHilliard` integrator for the right-hand-side of PDEs and the `SplitTimeDerivative` for the left-hand-side. For this example, the Backward Euler method is considered (see `TimeScheme::EulerImplicit`). @@ -527,7 +510,7 @@ To enable simulations on axisymmetric geometries, the current definition of the ```c++ - PDE phase_field_pb(phasefield_ope, vars, {coef_phase_field, coef_phase_field}, pst); + TransientPB phase_field_pb(phasefield_ope, vars, {coef_phase_field, coef_phase_field}, pst); phase_field_pb.setGeometry(Geometry::Axisymmetric); ``` @@ -564,4 +547,32 @@ Once a `Problem` is fully defined, an AMR driver can be attached to it so that ` This page only shows how to attach an already-configured AMR driver to a `Problem`. - For the complete step-by-step workflow, see the [AMR tutorial](../../../../../Started/HowTo/Tutorials/AMR/index.md); - - For the full reference on error estimators (`ErrorEstimatorType::KELLY`, `ErrorEstimatorType::ZZ`) and AMR drivers (`SingleVariableAMR`, `MultiVariableMaxAMR`), see the [Adaptive Mesh Refinement](../../../AMR/index.md) page of the User Manual. \ No newline at end of file + - For the full reference on error estimators (`ErrorEstimatorType::KELLY`, `ErrorEstimatorType::ZZ`) and AMR drivers (`SingleVariableAMR`, `MultiVariableMaxAMR`), see the [Adaptive Mesh Refinement](../../../AMR/index.md) page of the User Manual. + + +#### __How to set auxiliary variables after construction?__ {#set-auxvariables} + +Auxiliary variables (see [Variables](../../../Variables/index.md)) can be set afterwards with `set_auxvariables`, exactly as `set_amr` is used above to attach an AMR driver: + +!!! example "Setting auxiliary variables after construction" + ```c++ + std::vector aux_vect = {&aux_vars_1, &aux_vars_2}; + phase_field_pb.set_auxvariables(aux_vect); + ``` + `aux_vect` is a `std::vector`. This is particularly convenient in partitioned multiphase-field simulations, where each `Problem` needs the other `Variables` as auxiliary variables. + + +#### __How to export a `Coefficient` in VTK output?__ {#set-vtk-coefficients} + +In addition to the primary [Variables](../../../Variables/index.md), quantities computed from a [`Coefficient`](../../../Coefficients/index.md) — not resolved by the system, but useful for visualization or diagnostics - can be exported to VTK output. The coefficient must first be given a name, then registered on the `Problem` with `set_vtk_coefficients`: + +!!! example "Registering a Coefficient for VTK output" + In this example, the `Coefficient` named Squares is exported to VTK output. + + ```c++ + Coefficient squares(Glossary::PhaseField, Scheme::Implicit, Squares()); + squares.set_name("Squares"); + + phase_field_pb.set_vtk_coefficients({squares}); + ``` + `set_vtk_coefficients` takes a `std::vector`, so several coefficients can be registered at once. Each is projected onto a grid function and saved alongside the usual `Variables`, using its name (`"Squares"` here) as the field name in the VTK output. diff --git a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/Remainder/index.md b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/Remainder/index.md index f090782b..36ccd9fb 100644 --- a/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/Remainder/index.md +++ b/doc/docs/Documentation/User/MultiPhysicsCouplingScheme/Problems/Remainder/index.md @@ -5,15 +5,14 @@ _"The remainder"_ refers to everything that is neither PDEs nor 0D problems, suc The `SLOTH` development team recommends using `Property_problem`. This is a template class instantiated with three template parameters: first, an `PROPERTY` object, second, the `Variables` object (see `VARS`in the example), and third, the `Postprocessing` object (see `PST` in the example). -!!! example "Alias declaration for `Property_problem` class template" - ```c++ - using PropertyProblem = PropertyProblem; - ``` The users are referred to dedicated pages of the user manual for details about [Variables](../../../Variables/index.md) and [PostProcessing](../../../PostProcessing/index.md). The `PROPERTY` object in `Property_problem` corresponds to a C++ object that inherits from the template class `PropertyBase`, only defined with a set of `Parameter` (within a `Parameters` object). +!!! example "Alias declaration for `Property_problem` class template" + The alias `PB_PROPERTY` is provided by `SLOTH` namespaces (see the [Aliases page](../../../Aliases/index.md)). + Similar to other types of problems, `Property_problem` take auxiliary `Variables` as inputs, and primary `Variables` as outputs. @@ -21,9 +20,8 @@ Similar to other types of problems, `Property_problem` take auxiliary `Variable ```c++ auto property_params = FictitiousProperty(property_params); - using PropertyProblem = PropertyProblem; - PropertyProblem prop_pb = fictitious_property_problem( + PB_PROPERTY prop_pb = fictitious_property_problem( "Property problem", property_params, outputs_property_var, inputs_property_var); ``` \ No newline at end of file diff --git a/doc/docs/Documentation/User/PostProcessing/index.md b/doc/docs/Documentation/User/PostProcessing/index.md index 26d47188..7c08673e 100644 --- a/doc/docs/Documentation/User/PostProcessing/index.md +++ b/doc/docs/Documentation/User/PostProcessing/index.md @@ -19,11 +19,8 @@ The development team primarily uses [`ParaView`](https://www.paraview.org) to vi In that case, please contact the development team so that an interface to the `mfem::VisitDataCollection` class can be provided. !!! example "Alias declaration for `PostProcessing` class template" - ```c++ - using PST = PostProcessing; - ``` - This example shows how to define a convenient alias for the `PostProcessing` class template instantiated with `mfem::H1_FECollection` and `mfem::ParaviewDataCollection` in dimension 2. - + The alias `PST` is provided by `SLOTH` namespaces (see the [Aliases page](../../../Aliases/index.md)) for `PostProcessing` class template. + Without loss of generality, the alias `PST` is used in this page in order to simplify each code snippet. The `PST` object must be defined by: @@ -37,6 +34,7 @@ The `PST` object must be defined by: ``` This example shows how to declare a `PST` object with the spatial discretisation `spatial` and the parameters `pst_parameters`. + ## Optional post-processing `PST` objects are optional when defining a `Problem`. @@ -168,3 +166,21 @@ Isovalues are not stored in the `time_specialized.csv` file. Instead, the parame auto post_processing = PST(&spatial, pst_parameters); ``` +## Post-processing Coefficients in VTK output {#coefficients} + +In addition to `Variables`, a `PST` object can also export named [`Coefficient`](../Coefficients/index.md) objects — quantities computed from the solved variables, not resolved by the system, but useful for visualization or diagnostics (e.g. an interpolation function, an order-parameter norm used to check the multiphase-field normalization constraint, ...). + +A coefficient must be given a name and registered on a [`Problem`](../MultiPhysicsCouplingScheme/Problems/index.md) with `set_vtk_coefficients`: + +!!! example "Registering a Coefficient for VTK output" + ```c++ + Coefficient squares(Glossary::PhaseField, Scheme::Implicit, Squares()); + squares.set_name("Squares"); + + phase_field_pb.set_vtk_coefficients({squares}); + ``` + +At each post-processing step, every registered coefficient is projected onto a grid function and saved to the VTK output under its name, alongside the usual `Variables`. + +!!! note "Storage and unified/non-unified output" + This feature is compatible with both unified and non-unified VTK post-processing (see [Shared post-processing for multiphysics simulations](#shared-post-processing-for-multiphysics-simulations)). \ No newline at end of file diff --git a/doc/docs/Documentation/User/SpatialDiscretization/BoundaryConditions/index.md b/doc/docs/Documentation/User/SpatialDiscretization/BoundaryConditions/index.md index 466b6f26..f1c035c8 100644 --- a/doc/docs/Documentation/User/SpatialDiscretization/BoundaryConditions/index.md +++ b/doc/docs/Documentation/User/SpatialDiscretization/BoundaryConditions/index.md @@ -2,6 +2,9 @@ This page described the definition and the use of boundary conditions in `SLOTH`. +## Build boundary conditions {#bcs} + + Definition of boundary conditions for `SLOTH` is made with a C++ object of type `BoundaryConditions`. As for the object `SpatialDiscretization` (see [Meshing](../Meshing/index.md)), `BoundaryConditions` is a template class instantiated with two template parameters: first, the kind of finite element, and second, the spatial dimension. Currently, the most commonly used finite element collection in `SLOTH` is `mfem::H1_FECollection`, which corresponds to arbitrary order H1-conforming continuous finite elements. @@ -33,15 +36,51 @@ A `Boundary` object is defined by In the code snippets, it is referred to as a `spatial` object. These examples show how to define `Dirichlet`, homogeneous `Neumann` and `Periodic` boundary conditions in a square. - + === "Dirichlet" ```c++ - auto list_boundaries_2 = {Boundary("left", 0, "Dirichlet", 0.), Boundary("bottom", 1, "Neumann"), Boundary("right", 2, "Dirichlet", 1.), Boundary("top", 3, "Neumann")}; - auto bcs_2 = BCS(&spatial, list_boundaries_2); + auto list_boundaries_2 = {Boundary("left", 0, "Dirichlet", 0.), Boundary("bottom", 1, "Neumann"), Boundary("right", 2, "Dirichlet", 1.), Boundary("top", 3, "Neumann")}; + auto bcs_2 = BCS(&spatial, list_boundaries_2); ``` The fourth argument in the definition of a Boundary object is only required for Dirichlet boundary conditions. + To define space- and/or time-dependent Dirichlet boundary conditions, a `Coefficient` object of type `Glossary::Dirichlet` must be defined and associated with a set of `Boundary` objects, exactly as for non-homogeneous Neumann or Robin boundary conditions. + The following example prescribes a different `DirichletCoefficient` on the right boundary (`1`) and on the left boundary (`3`). + + ```c++ + auto boundaries = {Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Dirichlet"), + Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Dirichlet")}; + auto bcs = BCS(&spatial, boundaries); + + Coefficient dirichlet_left(Glossary::Dirichlet, Scheme::Implicit, DirichletCoefficient()); + Coefficient dirichlet_right(Glossary::Dirichlet, Scheme::Implicit, DirichletCoefficient(-1)); + dirichlet_left.set_bdr_index_coef(std::vector{3}); + dirichlet_right.set_bdr_index_coef(std::vector{1}); + ``` + + Here, `Boundary("right", 1, "Dirichlet")` and `Boundary("left", 3, "Dirichlet")` use the three-argument constructor overload (no constant value), since the actual boundary value is provided by the associated `Coefficient` instead. + + In this example, `DirichletCoefficient()` is built from the following JSON file + + ```json + [ + { + "expression":"t*sin(pi*y)", + "variables":"phi", + "auxiliary_variables":"x,y", + "constants":"(t:T)", + "class_name":"DirichletCoefficient", + "outputfile":"Coefficient" + } + ] + ``` + + `phi` is declared as the coefficient's own variable, even though it is not used in the expression. + `x` and `y` are the spatial coordinates, provided as auxiliary variables. + `t` is mapped to the current simulation time. + The prefactor passed to `DirichletCoefficient(-1)` flips the sign of the whole expression for the left boundary. + === "Neumann" ```c++ @@ -54,7 +93,7 @@ A `Boundary` object is defined by The following example prescribes the `heat_flux` coefficient on the left boundary (`0`) and on the top boundary (`3`). ```c++ - Coefficient neumann(Glossary::Neumann, heat_flux); + Coefficient neumann(Glossary::Neumann, Scheme::Implicit, heat_flux()); neumann.set_bdr_index_coef(std::vector{0,3}); ``` @@ -123,3 +162,21 @@ The user can define as many boundary conditions as there are variables. !!! warning "Consistency of the indices of the boundaries" `MFEM v4.7` provides new features for referring to boundary attribute numbers. Such an improvement is not yet implemented in `SLOTH`. Consequently, users must take care to the consistency of the indices used in the test file with the indices defined when building the mesh with `GMSH`. + + +## Build N boundary conditions from a vector of spatial discretizations {#factory} + +When `N` spatial discretizations share the same boundary layout - typically the `SPAS` vector built by the [spatial discretization factory](../Meshing/index.md#factory) — building each `BCS` object one by one is repetitive. `setBoundaryConditions` builds `N` of them in a single call, from a `spatials` vector and a single, shared list of `Boundary` objects. + +!!! example "Building boundary conditions for 30 spatial discretizations" + ```c++ + using namespace Sloth2D; + + auto boundaries = {Boundary("lower", 0, "Periodic"), Boundary("right", 1, "Periodic"), + Boundary("upper", 2, "Periodic"), Boundary("left", 3, "Periodic")}; + auto bcs = setBoundaryConditions(30, spatials, boundaries); + ``` + `spatials` is a `SPAS` object (e.g. built with [`setPeriodicSpatialDiscretization`](../Meshing/index.md#factory)), and `bcs[i]` is the `BCS` object associated with `spatials[i]`, equivalent to `BCS(spatials[i], boundaries)`. + +!!! warning "Number of spatial discretizations" + `spatials` must contain exactly `N` elements — one `Boundary` list is shared across every spatial discretization, but each still gets its own `BoundaryConditions` object. \ No newline at end of file diff --git a/doc/docs/Documentation/User/SpatialDiscretization/Meshing/index.md b/doc/docs/Documentation/User/SpatialDiscretization/Meshing/index.md index e6cc6729..6653a090 100644 --- a/doc/docs/Documentation/User/SpatialDiscretization/Meshing/index.md +++ b/doc/docs/Documentation/User/SpatialDiscretization/Meshing/index.md @@ -25,6 +25,7 @@ Without loss of generality, the alias `SPA` is used in this page in order to sim - `allow_nc_simplices` *(default `false`)* — additionally allows non-conforming refinement on **triangle/tetrahedron** elements specifically. It has no effect on quadrilateral/hexahedral meshes, which natively support non-conforming refinement regardless of this flag. Its value is what `is_nc_simplices()` returns afterwards. Both are illustrated as "With AMR" variants in the examples below. See the [AMR tutorial](../../../../Started/HowTo/Tutorials/AMR/index.md) for the complete workflow. + ## __Build a mesh from `GMSH` file__ {#gmsh} @@ -263,6 +264,31 @@ This constructor is useful in two situations: +## __Build N spatial discretizations sharing a mesh__ {#factory} + +For problems with many unknowns sharing the same mesh — typically a multiphase-field simulation — building each `SPA` object becomes repetitive. +The factory functions `setSpatialDiscretization` and `setPeriodicSpatialDiscretization` build `N` such objects in a single call. + +!!! example "Building 30 spatial discretizations sharing a periodic mesh" + ```c++ + using namespace Sloth2D; + + SPAS spatials = + setPeriodicSpatialDiscretization(30, "InlineSquareWithQuadrangles", 1, refinement_level, + std::make_tuple(NN, NN, L, L), translations, true); + ``` + This builds the same mesh as done above and 30 `SPA` objects sharing it, equivalent to writing the first one, then 29 more from its `get_mesh()`. + `SPAS` (defined by `using namespace SlothND`, see the [Basic features](../../../../Started/HowTo/Simple/index.md) page) is an alias for `std::vector`, ready to use wherever a vector of spatial discretizations is expected (variables, operators, boundary conditions). + +The first argument is `N`, the number of objects to build; the remaining arguments are forwarded verbatim to whichever `SPA` constructor they match — any of the constructors described [above](#gmsh) (`GMSH`), [above](#mfem) (`MFEM` inline meshes, periodic or not). The first object builds the mesh; the following `N - 1` share it, exactly as in the [manual pattern](#shared-mesh). + +- `setSpatialDiscretization(N, args...)` builds `N` objects sharing a **non-periodic** mesh. +- `setPeriodicSpatialDiscretization(N, args...)` builds `N` objects sharing a **periodic** mesh. + +!!! note "Ownership" + The returned `SPAS` does not own the underlying `SpatialDiscretization` objects by itself — they must be released with `deleteSpatialDiscretization(spatials)` once no longer needed (typically at the end of `main`), which deletes them in the correct order (mesh-owning object last) to avoid a use-after-free on the shared mesh. + + ## __GMSH Split Meshes__ {#gmsh-split-meshes} To read directly partitioned meshes, the MFEM miniapps called `mesh-explorer` must be used. diff --git a/doc/docs/Documentation/User/index.md b/doc/docs/Documentation/User/index.md index e123cf7c..ae53c912 100644 --- a/doc/docs/Documentation/User/index.md +++ b/doc/docs/Documentation/User/index.md @@ -24,8 +24,11 @@ This page focuses on the kernel of `SLOTH`, providing all the essential informat - [Profiling](Profiling/index.md) - [Adaptive Mesh Refinement](AMR/index.md) +!!! tip "On the use of aliases" + To simplify the definition of `SLOTH` tests, a set of aliases (finite element collection, variables, post-processing, mesh, boundary conditions...) plus a couple of factory functions are provided to the users. The development team recommends visiting the [Aliases page](./Aliases/index.md). + !!! tip "On the use of tutorials" - Development team recommend visiting the [tutorials page](../../Started/HowTo/Tutorials/index.md) to discover tips and tricks for specific `SLOTH` features + The development team recommends visiting the [tutorials page](../../Started/HowTo/Tutorials/index.md) to discover tips and tricks for specific `SLOTH` features !!! note "`MFEM` documentation" For further details regarding dependencies, advanced numerical methods, and massively parallel features, users are referred to the [MFEM website](https://mfem.org). diff --git a/doc/docs/Started/HowTo/Simple/index.md b/doc/docs/Started/HowTo/Simple/index.md index 6c7ea91d..41d7f269 100644 --- a/doc/docs/Started/HowTo/Simple/index.md +++ b/doc/docs/Started/HowTo/Simple/index.md @@ -43,11 +43,11 @@ On this page, the users can find the most important parts of a `SLOTH` input dat For this test, the following parameters are considered: | Parameter | Symbol | Value | - |------------------------------------|--------------|--------------------------------| + | ---------------------------------- | ------------ | ------------------------------ | | mobility coefficient | $`M_\phi`$ | $`10^{-5}`$ | | energy gradient coefficient | $`\lambda`$ | $`\frac{3}{2}\sigma\epsilon`$ | | surface tension | $`\sigma`$ | $`0.06`$ | - | interface \epsilon | $`\epsilon`$ | $`5\times10^{-4}`$ | + | interface \epsilon | $`\epsilon`$ | $`5\times10^{-4}`$ | | depth of the double-well potential | $`\omega`$ | $`12\frac{\sigma}/{\epsilon}`$ | @@ -72,7 +72,7 @@ Each `SLOTH` test is actually defined as a `main.cpp` file, which consists of fo //--------------------------------------- int main(int argc, char* argv[]) { //--------------------------------------- - // 1/ Aliases / Parallelism + // 1/ Namespace / Parallelism //--------------------------------------- //--------------------------------------- @@ -89,9 +89,9 @@ Each `SLOTH` test is actually defined as a `main.cpp` file, which consists of fo } ``` -### __Headers, Aliases & Parallelism__ {#common} +### __Headers, Namespace & Parallelism__ {#common} -Headers, aliases and parallelism features are the most general information that can be find in all test files. +Headers, naamespace and parallelism features are the most general information that can be find in all test files. There are 3 main headers. @@ -105,69 +105,65 @@ There are 3 main headers. //--------------------------------------- // Headers //--------------------------------------- - #include "kernel/sloth.hpp" + #include "Sloth/sloth.hpp" #include "mfem.hpp" // NOLINT [no include the directory when naming mfem include file] - #include "tests/tests.hpp" + #include "Sloth/tests.hpp" int main(int argc, char* argv[]) { } ``` +There are three namespaces, `Sloth1D`, `Sloth2D` and `Sloth3D`, for 1D, 2D, 3D simulations, respectively. +They involved aliases that facilitate the use of complex C++ types by providing a more concise alternative and pertain to all tests. +They are detailed in the [Aliases page](../../../Documentation/User/Aliases/index.md). -Aliases facilitate the use of complex C++ types by providing a more concise alternative. -It should be noted that users may define additional aliases. However, those specified in this page pertain to all tests. -Each alias employ a template structure for space dimension dependence (see `DIM` in the example). - -!!! example "Test file with headers and common aliases" +!!! example "Test file with headers and namespace " ```c++ hl_lines="12-19" //--------------------------------------- // Headers //--------------------------------------- - #include "kernel/sloth.hpp" + #include "Sloth/sloth.hpp" #include "mfem.hpp" // NOLINT [no include the directory when naming mfem include file] - #include "tests/tests.hpp" + #include "Sloth/tests.hpp" int main(int argc, char* argv[]) { //--------------------------------------- - // Common aliases + // Namespace //--------------------------------------- - const int DIM=1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; + using namespace Sloth1D; } ``` -These aliases both refer to MFEM or `SLOTH` types used many times in the test file: - -| **Alias** | **Type** | **Description** | -|-----------------|----------------------------|------------------------------------------------------------| -| `FECollection` | `Test::FECollection` | Finite Element Space. $`\cal{H}^1`$ by default (MFEM type) | -| `VARS` | `Test::VARS` | Collection of Variable objects (SLOTH type) | -| `VAR` | `Test::VAR` | Variable object (SLOTH type) | -| `PST` | `Test::PST` | PostProcessing (SLOTH type) | -| `SPA` | `Test::SPA` | Spatial Discretization (SLOTH type) | -| `BCS` | `Test::BCS` | Boundary Conditions (SLOTH type) | +The main aliases involved by the namespace `Sloth1D` are: + +| Alias | Description | +| -------------- | ------------------------------ | +| `DIM` | Spatial dimension | +| `VAR` | A single variable | +| `VARS` | Collection of variables | +| `PST` | Post-processing object | +| `SPA` | Spatial discretization | +| `SPAS` | `std::vector` | +| `BCS` | Boundary conditions | +| `TransientOPE` | Operator for transient problem | +| `TransientPB` | Transient problem | SLOTH's ambition is to be able to perform massively parallel computations while logically retaining the ability to perform sequential computations. -Only three lines of code must be defined in each test file for the MPI and HYPRE libraries. +Only three lines of code must be defined in each test file for the MPI and HYPRE libraries, and two lines for the profiling. !!! example "Test file with headers, common aliases and parallelism features" - ```c++ hl_lines="12 13 30" + ```c++ hl_lines="12 13 23" //--------------------------------------- // Headers //--------------------------------------- - #include "kernel/sloth.hpp" + #include "Sloth/sloth.hpp" #include "mfem.hpp" // NOLINT [no include the directory when naming `MFEM` include file] - #include "tests/tests.hpp" + #include "Sloth/tests.hpp" int main(int argc, char* argv[]) { //--------------------------------------- @@ -176,21 +172,24 @@ Only three lines of code must be defined in each test file for the MPI and HYPRE mfem::Mpi::Init(argc, argv); mfem::Hypre::Init(); //--------------------------------------- - // Common aliases + // Profiling + //--------------------------------------- + Profiling::getInstance().enable(); //--------------------------------------- - const int DIM=1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; + // Namespace + //--------------------------------------- + using namespace Sloth1D; + - + //--------------------------------------- + // Profiling stop + //--------------------------------------- + Profiling::getInstance().print(); //--------------------------------------- // Finalize MPI //--------------------------------------- mfem::Mpi::Finalize(); + return 0; } ``` @@ -230,7 +229,7 @@ A `Boundary` object is defined by - a name (C++ type `std::string'), - an index (C++ type `int`), - a type (C++ type `std::string') among "Dirichlet", "Neumann", "Periodic", - - a value (C++ type `double`), equal to zero by default. + - a value (C++ type `double`), only for uniform Dirichlet boundar condition. !!! example "Extract of the test file with the mesh and its associated Neumann boundary conditions" @@ -244,10 +243,10 @@ A `Boundary` object is defined by auto nb_fe = 30; SPA spatial("InlineLineWithSegments", fe_order, refinement_level, std::make_tuple(nb_fe, length)); - auto boundaries = {Boundary("left", 0, "Neumann", 0.), Boundary("right", 1, "Neumann", 0.)}; + auto boundaries = {Boundary("left", 0, "Neumann"), Boundary("right", 1, "Neumann")}; auto bcs = BCS(&spatial, boundaries); ``` - This example consider Neumann boundary conditions both on the left and on the right of the domain. + This example consider homogeneous Neumann boundary conditions both on the left and on the right of the domain. Different type of boundary conditions can be mixed as detailed in the [Boundary Conditions section of the user manual](../../../Documentation/User/SpatialDiscretization/BoundaryConditions/index.md). @@ -257,13 +256,13 @@ Different type of boundary conditions can be mixed as detailed in the [Boundary !!! example "Test file with the mesh and the boundary conditions" - ```c++ hl_lines="28-34" + ```c++ hl_lines="22-28" //--------------------------------------- // Headers //--------------------------------------- - #include "kernel/sloth.hpp" + #include "Sloth/sloth.hpp" #include "mfem.hpp" // NOLINT [no include the directory when naming mfem include file] - #include "tests/tests.hpp" + #include "Sloth/tests.hpp" int main(int argc, char* argv[]) { //--------------------------------------- @@ -272,15 +271,14 @@ Different type of boundary conditions can be mixed as detailed in the [Boundary mfem::Mpi::Init(argc, argv); mfem::Hypre::Init(); //--------------------------------------- - // Common aliases + // Profiling + //--------------------------------------- + Profiling::getInstance().enable(); //--------------------------------------- - const int DIM=1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; + // Namespace + //--------------------------------------- + using namespace Sloth1D; + //--------------------------------------- // Meshing & Boundary Conditions //--------------------------------------- @@ -289,12 +287,13 @@ Different type of boundary conditions can be mixed as detailed in the [Boundary auto length = 1.e-3; auto nb_fe = 30; SPA spatial("InlineLineWithSegments", fe_order, refinement_level, std::make_tuple(nb_fe, length)); - auto boundaries = {Boundary("left", 0, "Neumann", 0.), Boundary("right", 1, "Neumann", 0.)}; + auto boundaries = {Boundary("left", 0, "Neumann"), Boundary("right", 1, "Neumann")}; auto bcs = BCS(&spatial, boundaries); //--------------------------------------- // Finalize MPI //--------------------------------------- mfem::Mpi::Finalize(); + return 0; } ``` @@ -335,7 +334,7 @@ If the mathematical expression is not yet available, the users can define it wit !!! example "Extract of the test file with Variables" - ```c++ hl_lines="15" + ```c++ hl_lines="15-17" //--------------------------------------- // Multiphysics coupling scheme @@ -348,7 +347,7 @@ If the mathematical expression is not yet available, the users can define it wit const auto& radius = 5.e-4; std::string variable_name = "phi"; - GlossaryQuantities variable_type = Glossary::Phi; + GlossaryQuantity variable_type = Glossary::PhaseField; int level_of_storage= 2; auto initial_condition = AnalyticalFunctions(AnalyticalFunctionsType::from("HyperbolicTangent"), center_x, a_x, 2.*thickness, radius); @@ -358,7 +357,7 @@ If the mathematical expression is not yet available, the users can define it wit This example defines a single primary variable, named "phi" with two levels of storage. The initial condition and the analytical solution are of the hyperbolic tangent type. -Other major C++ objects for `SLOTH` is `SteadyOperator` and `TransientOperator`, which enables to solve the steady and unsteady algebraic system resulting from the discretization of the (non-linear) equations. This is detailed in the [`Partial Differential Equations` page of the user manual](../../../Documentation/User/MultiPhysicsCouplingScheme/Problems/PDEs/index.md). +Other major C++ objects for `SLOTH` is `SteadyOperator` and `TransientOperator`, which enables to solve the steady and unsteady algebraic system resulting from the discretization of the (non-linear) equations. This is detailed in the [`Partial Differential Equations` page of the user manual](../../../Documentation/User/MultiPhysicsCouplingScheme/Problems/PDEs/index.md). Specifically for tests, `SteadyOperator` and `TransientOperator` are accessible by using the aliases `SteadyOPE` and `TransientOPE`. Although the input arguments provided to these objects are of interest, the focus is rather on the definition of the C++ object itself, which requires the input of the variational formulation of the equations. This specificity is implemented using objects of `BlockNonLinearFormIntegrators`, also detailed in the user manual in the [`Partial Differential Equations`](../../../Documentation/User/MultiPhysicsCouplingScheme/Problems/PDEs/index.md) page. @@ -374,15 +373,14 @@ In the present example, the variational formulation is defined by combining the ``` where $`\alpha`$ is a constant enthalpy of melting. -!!! example "Extract of the test file with a TransientOperator" +!!! example "Extract of the test file with a transient Operator" - ```c++ hl_lines="6" - std::vector spatials{&spatial}; + ```c++ hl_lines="5" + SPAS spatials{&spatial}; const auto& alpha(7.e3); auto params = Parameters(Parameter("melting_factor", alpha)); - std::vector spatials{&spatial}; - TransientOperator oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, "TimeDerivative"); ``` @@ -408,18 +406,19 @@ By default, all primary variables associated with a `SLOTH` `Problem` are saved. ``` In this example, the results will be saved in the `Saves/AllenCahn` directory (see `Parameter("main_folder_path", main_folder_path)` and `Parameter("calculation_path", calculation_path)`), at each time-step (see `Parameter("frequency", frequency)`). -At this stage, the `SLOTH` `Problem` can be defined and, as previously explained, collected in a `Coupling` object. -This is illustrated in the following example (see `Problem ac_problem` and `Coupling("Main coupling", ac_problem)`). +At this stage, the `SLOTH` `Problem` can be defined and, as previously explained, collected in a `Coupling` object. Specially for tests, steady and unsteady problems are accessible using the `SteadyPB` and `TransientPB`, respectively. + +This is illustrated in the following example (see `TransientPB` and `Coupling("Main coupling", ac_problem)`). !!! example "Test file with Variables, Operators and Integrators and Post-Processing" - ```c++ hl_lines="62-76 88" + ```c++ hl_lines="45 52 69-73 78" //--------------------------------------- // Headers //--------------------------------------- - #include "kernel/sloth.hpp" + #include "Sloth/sloth.hpp" #include "mfem.hpp" // NOLINT [no include the directory when naming mfem include file] - #include "tests/tests.hpp" + #include "Sloth/tests.hpp" int main(int argc, char* argv[]) { //--------------------------------------- @@ -428,15 +427,13 @@ This is illustrated in the following example (see `Problem ac_pr mfem::Mpi::Init(argc, argv); mfem::Hypre::Init(); //--------------------------------------- - // Common aliases + // Profiling + //--------------------------------------- + Profiling::getInstance().enable(); //--------------------------------------- - const int DIM=1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; + // Namespace + //--------------------------------------- + using namespace Sloth1D; //--------------------------------------- // Meshing & Boundary Conditions //--------------------------------------- @@ -445,7 +442,7 @@ This is illustrated in the following example (see `Problem ac_pr auto length = 1.e-3; auto nb_fe = 30; SPA spatial("InlineLineWithSegments", fe_order, refinement_level, std::make_tuple(nb_fe, length)); - auto boundaries = {Boundary("left", 0, "Neumann", 0.), Boundary("right", 1, "Neumann", 0.)}; + auto boundaries = {Boundary("left", 0, "Neumann"), Boundary("right", 1, "Neumann")}; auto bcs = BCS(&spatial, boundaries); //--------------------------------------- @@ -459,22 +456,19 @@ This is illustrated in the following example (see `Problem ac_pr const auto& radius = 5.e-4; std::string variable_name = "phi"; - GlossaryQuantities variable_type = Glossary::Phi; + GlossaryQuantity variable_type = Glossary::PhaseField; int level_of_storage= 2; auto initial_condition = AnalyticalFunctions(AnalyticalFunctionsType::from("HyperbolicTangent"), center_x, a_x, 2.*thickness, radius); auto analytical_solution = AnalyticalFunctions(AnalyticalFunctionsType::from("HyperbolicTangent"), center_x, a_x, thickness, radius); auto vars = VARS(VAR(&spatial, bcs, variable_name, variable_type, level_of_storage, initial_condition, analytical_solution)); - //--- Integrator : alias definition for the sake of clarity - using NLFI = AllenCahnNLFormIntegrator; - //--- Operator definition - std::vector spatials{&spatial}; + SPAS spatials{&spatial}; const auto& alpha(7.e3); auto params = Parameters(Parameter("melting_factor", alpha)); - TransientOperator oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, "TimeDerivative"); //--- Coefficients // Interfacial energy @@ -500,17 +494,22 @@ This is illustrated in the following example (see `Problem ac_pr //----------------------- // Problem //----------------------- - Problem, VARS, PST> ac_problem(oper, vars, {coef_ac}, pst); + TransientPB ac_problem(oper, vars, {coef_ac}, pst); //----------------------- // Coupling //----------------------- auto main_coupling = Coupling("Main coupling", ac_problem); + //--------------------------------------- + // Profiling stop + //--------------------------------------- + Profiling::getInstance().print(); //--------------------------------------- // Finalize MPI //--------------------------------------- mfem::Mpi::Finalize(); + return 0; } ``` In this example, a coupling, labelled `Main coupling`, is defined with only one `SLOTH` `Problem` associated with the solution of Allen-Cahn equation. @@ -552,9 +551,9 @@ This is detailed in the [`Time` page of the user manual](../../../Documentation/ //--------------------------------------- // Headers //--------------------------------------- - #include "kernel/sloth.hpp" + #include "Sloth/sloth.hpp" #include "mfem.hpp" // NOLINT [no include the directory when naming mfem include file] - #include "tests/tests.hpp" + #include "Sloth/tests.hpp" int main(int argc, char* argv[]) { //--------------------------------------- @@ -563,15 +562,13 @@ This is detailed in the [`Time` page of the user manual](../../../Documentation/ mfem::Mpi::Init(argc, argv); mfem::Hypre::Init(); //--------------------------------------- - // Common aliases + // Profiling //--------------------------------------- - const int DIM=1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; + Profiling::getInstance().enable(); + //--------------------------------------- + // Namespace + //--------------------------------------- + using namespace Sloth1D; //--------------------------------------- // Meshing & Boundary Conditions //--------------------------------------- @@ -580,7 +577,7 @@ This is detailed in the [`Time` page of the user manual](../../../Documentation/ auto length = 1.e-3; auto nb_fe = 30; SPA spatial("InlineLineWithSegments", fe_order, refinement_level, std::make_tuple(nb_fe, length)); - auto boundaries = {Boundary("left", 0, "Neumann", 0.), Boundary("right", 1, "Neumann", 0.)}; + auto boundaries = {Boundary("left", 0, "Neumann"), Boundary("right", 1, "Neumann")}; auto bcs = BCS(&spatial, boundaries); //--------------------------------------- @@ -594,22 +591,19 @@ This is detailed in the [`Time` page of the user manual](../../../Documentation/ const auto& radius = 5.e-4; std::string variable_name = "phi"; - GlossaryQuantities variable_type = Glossary::Phi; + GlossaryQuantity variable_type = Glossary::PhaseField; int level_of_storage= 2; auto initial_condition = AnalyticalFunctions(AnalyticalFunctionsType::from("HyperbolicTangent"), center_x, a_x, 2.*thickness, radius); auto analytical_solution = AnalyticalFunctions(AnalyticalFunctionsType::from("HyperbolicTangent"), center_x, a_x, thickness, radius); auto vars = VARS(VAR(&spatial, bcs, variable_name, variable_type, level_of_storage, initial_condition, analytical_solution)); - //--- Integrator : alias definition for the sake of clarity - using NLFI = AllenCahnNLFormIntegrator; - //--- Operator definition - std::vector spatials{&spatial}; + SPAS spatials{&spatial}; const auto& alpha(7.e3); auto params = Parameters(Parameter("melting_factor", alpha)); - TransientOperator oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, "TimeDerivative"); //--- Coefficients // Interfacial energy @@ -635,7 +629,7 @@ This is detailed in the [`Time` page of the user manual](../../../Documentation/ //----------------------- // Problem //----------------------- - Problem, VARS, PST> ac_problem(oper, vars, {coef_ac}, pst); + TransientPB ac_problem(oper, vars, {coef_ac}, pst); //----------------------- // Coupling @@ -653,9 +647,14 @@ This is detailed in the [`Time` page of the user manual](../../../Documentation/ time.solve(); + //--------------------------------------- + // Profiling stop + //--------------------------------------- + Profiling::getInstance().print(); //--------------------------------------- // Finalize MPI //--------------------------------------- mfem::Mpi::Finalize(); + return 0; } ``` \ No newline at end of file diff --git a/doc/mkdocs.yml.cmake b/doc/mkdocs.yml.cmake index 2844067a..b54aceaa 100644 --- a/doc/mkdocs.yml.cmake +++ b/doc/mkdocs.yml.cmake @@ -133,6 +133,7 @@ nav: - Code quality: Started/Quality/quality.md - User Manual: - Documentation/User/index.md + - Documentation/User/Aliases/index.md - Documentation/User/Glossary/index.md - Documentation/User/Parameters/index.md - Documentation/User/Variables/index.md