Skip to content

Commit bcd5a39

Browse files
authored
Merge pull request #31027 from loganharbour/ray_periodic
Implement PeriodicRayBC, add multisystem support to periodic BCs
2 parents 28f8bef + c8bc06a commit bcd5a39

70 files changed

Lines changed: 1900 additions & 682 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

framework/include/actions/AddPeriodicBCAction.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#pragma once
1111

1212
#include "Action.h"
13+
#include "PeriodicBCHelper.h"
1314

1415
class MooseMesh;
1516
namespace libMesh
@@ -22,7 +23,7 @@ class PeriodicBoundaryBase;
2223
* are not MooseObjects so you need not specify a type for these boundaries. If you
2324
* do, it will currently be ignored by this Action.
2425
*/
25-
class AddPeriodicBCAction : public Action
26+
class AddPeriodicBCAction : public Action, public Moose::PeriodicBCHelper
2627
{
2728
public:
2829
static InputParameters validParams();
@@ -32,15 +33,23 @@ class AddPeriodicBCAction : public Action
3233
virtual void act() override;
3334

3435
protected:
36+
using Action::paramError;
37+
38+
/**
39+
* Overriden method from PeriodicBCHelper that is called on every periodic
40+
* boundary, in which we will setup the algebraic ghosting via the DofMap
41+
* and the MooseMesh context if possible.
42+
*/
43+
virtual void onSetupPeriodicBoundary(libMesh::PeriodicBoundaryBase & p) override;
44+
3545
/**
36-
* This function will automatically add the correct translation vectors for
37-
* each requested dimension when using GeneratedMesh
38-
* @returns a boolean indicating whether or not these boundaries were automatically added
46+
* Helper for getting the variables to which periodic boundary
47+
* conditions will be applied
3948
*/
40-
bool autoTranslationBoundaries();
49+
std::vector<const MooseVariableFieldBase *> getVariables() const;
4150

42-
void setPeriodicVars(libMesh::PeriodicBoundaryBase & p,
43-
const std::vector<VariableName> & var_names);
51+
/// The variables to apply periodic boundary conditions to
52+
std::vector<const MooseVariableFieldBase *> _vars;
4453

4554
MooseMesh * _mesh;
4655
};

framework/include/bcs/FunctionPeriodicBoundary.h

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,37 @@
1111

1212
#include "Moose.h"
1313

14-
// libMesh
1514
#include "libmesh/point.h"
1615
#include "libmesh/periodic_boundary_base.h"
1716

17+
#include <array>
1818
#include <vector>
1919

2020
class FEProblemBase;
2121
class Function;
2222

2323
/**
24-
* Periodic boundary for calculation periodic BC on domains where the translation is given by
25-
* functions
24+
* Periodic boundary for calculation periodic BC on domains where the
25+
* translation is given by Function objects
2626
*/
2727
class FunctionPeriodicBoundary : public libMesh::PeriodicBoundaryBase
2828
{
2929
public:
3030
/**
31-
* Initialize the periodic boundary with three functions
31+
* Initialize the periodic with the functions and inverse functions, one
32+
* for each dimension needed
3233
*/
33-
FunctionPeriodicBoundary(FEProblemBase & subproblem, std::vector<std::string> fn_names);
34+
FunctionPeriodicBoundary(FEProblemBase & subproblem,
35+
const std::vector<std::string> & fn_names,
36+
const std::vector<std::string> & inv_fn_names);
3437

3538
/**
3639
* Copy constructor for creating the periodic boundary and inverse periodic boundary
3740
*
3841
* @param o - Periodic boundary being copied
42+
* @param t - Transformation direction
3943
*/
40-
FunctionPeriodicBoundary(const FunctionPeriodicBoundary & o);
44+
FunctionPeriodicBoundary(const FunctionPeriodicBoundary & o, TransformationType t = FORWARD);
4145

4246
/**
4347
* Get the translation based on point 'pt'
@@ -46,26 +50,17 @@ class FunctionPeriodicBoundary : public libMesh::PeriodicBoundaryBase
4650
*/
4751
virtual libMesh::Point get_corresponding_pos(const libMesh::Point & pt) const override;
4852

49-
/**
50-
* Required interface, this class must be able to clone itself
51-
*/
5253
virtual std::unique_ptr<libMesh::PeriodicBoundaryBase> clone(TransformationType t) const override;
5354

54-
protected:
55-
// /// The dimension of the problem (says which _tr_XYZ member variables are active)
56-
unsigned int _dim;
57-
58-
/// Pointer to Function for x-component of the boundary
59-
const Function * const _tr_x;
55+
private:
56+
static std::array<const Function *, 3> getFunctions(FEProblemBase & problem,
57+
const std::vector<std::string> & names);
6058

61-
/// Pointer to Function for y-component of the boundary
62-
const Function * const _tr_y;
59+
/// The dimension of the problem (says which of _tr and _inv_tr are active)
60+
const unsigned int _dim;
6361

64-
/// Pointer to Function for z-component of the boundary
65-
const Function * const _tr_z;
66-
67-
/**
68-
* An initialization method to make certain that initialSetup() of a function prior to value()
69-
*/
70-
void init();
62+
/// Pointers to translation functions in each dimension
63+
const std::array<const Function *, 3> _tr;
64+
/// Pointers to inverse translation functions in each dimension
65+
const std::array<const Function *, 3> _inv_tr;
7166
};

framework/include/interfaces/Coupleable.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,14 @@ class Coupleable
16341634
*/
16351635
MooseVariableFieldBase * getFieldVar(const std::string & var_name, unsigned int comp);
16361636

1637+
/*
1638+
* Extract pointers to all components of a base coupled field variable.
1639+
* Could be either a finite volume or finite element variable
1640+
* @param var_name Name of variable desired
1641+
* @return Pointers to the desired variables
1642+
*/
1643+
std::vector<const MooseVariableFieldBase *> getFieldVars(const std::string & var_name) const;
1644+
16371645
/**
16381646
* Helper that that be used to retrieve a variable of arbitrary type \p T
16391647
*/
@@ -1646,6 +1654,14 @@ class Coupleable
16461654
template <typename T>
16471655
T * getVarHelper(const std::string & var_name, unsigned int comp);
16481656

1657+
/**
1658+
* Helper that can be used to retrieve all the component variables of a variable
1659+
* of arbitrary type \p T
1660+
* @param var_name of the variable, can be a regular, vector or array variable
1661+
*/
1662+
template <typename T>
1663+
std::vector<const T *> getVarsHelper(const std::string & var_name) const;
1664+
16491665
/**
16501666
* Extract pointer to a coupled variable
16511667
* @param var_name Name of parameter desired
@@ -2003,3 +2019,14 @@ Coupleable::getVarHelper(const std::string & var_name, unsigned int comp) const
20032019
{
20042020
return const_cast<Coupleable *>(this)->getVarHelper<T>(var_name, comp);
20052021
}
2022+
2023+
template <typename T>
2024+
std::vector<const T *>
2025+
Coupleable::getVarsHelper(const std::string & var_name) const
2026+
{
2027+
const auto components = coupledComponents(var_name);
2028+
std::vector<const T *> vars(components);
2029+
for (const auto i : make_range(components))
2030+
vars[i] = getVarHelper<T>(var_name, i);
2031+
return vars;
2032+
}

0 commit comments

Comments
 (0)