Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
13e85df
Create working side average postprocessor
mattfalcone1997 Oct 8, 2025
fc7b891
Updated FoamProcessor so it computes with FoamProblem
mattfalcone1997 Oct 9, 2025
66a1314
Add initial implementation of mass flow rate inlet BC
mattfalcone1997 Oct 14, 2025
da9c243
Simplify mass flow rate BC
mattfalcone1997 Oct 14, 2025
e7eff0e
Add initial makeshift test for mass flow rate BC
mattfalcone1997 Oct 14, 2025
7ce2927
Fix bugs in mass flow rate inlet implementation
mattfalcone1997 Oct 14, 2025
846b5ed
Remove unnecessary headers
mattfalcone1997 Oct 16, 2025
27cfcf9
Add initial implementation of mapped inlet mass flow rate boundary co…
mattfalcone1997 Nov 1, 2025
3f82930
Add initial implementation of the mapped inlet test solver
mattfalcone1997 Nov 1, 2025
951b295
Simplify mapped inlet test solver
mattfalcone1997 Nov 3, 2025
e44952e
Fix basic mapped inlet implementation
mattfalcone1997 Nov 3, 2025
da7c5f8
Change mapped inlet test solver to use a rank independent test function
mattfalcone1997 Nov 3, 2025
bc67083
Add test for mapped inlet mass flow rate BC
mattfalcone1997 Nov 3, 2025
68dff12
Fix error in mapped inlet test
mattfalcone1997 Nov 3, 2025
6ad0177
Use BBox to reduce communication for mapped inlet
mattfalcone1997 Nov 5, 2025
baf9f8f
Add mapped inlet base class
mattfalcone1997 Nov 5, 2025
de299d3
Add scalar bulk mapped inlet BC
mattfalcone1997 Nov 5, 2025
84af1a8
Rename mapped inlet test case
mattfalcone1997 Nov 5, 2025
b5a93ff
Correct gold file reference for mass flow rate BC
mattfalcone1997 Nov 5, 2025
25b8cb9
Implement new FoamVariableBCBase class and propagate changes
mattfalcone1997 Nov 6, 2025
e231440
Implement new FoamPostprocessorBCBase class and propagate
mattfalcone1997 Nov 6, 2025
a5c087e
Add default creation of Receiver for Postprocessor-based BCs
mattfalcone1997 Nov 6, 2025
b5574c0
Implement different scaling approaches for the scalar bulk mapped inlet
mattfalcone1997 Nov 6, 2025
6ff3a0e
Implement fixed value and fixed gradient postprocessor BCs
mattfalcone1997 Nov 7, 2025
2a353be
Clean up code and register postprocessor BC objects
mattfalcone1997 Nov 7, 2025
714dead
Add tests for postprocessor BCs
mattfalcone1997 Nov 7, 2025
7cf85f8
Improve mapped inlet tests, in particular the different bounding box …
mattfalcone1997 Nov 8, 2025
24d4a25
Add test for the mapped inlet subtract scaling method
mattfalcone1997 Nov 8, 2025
8d03496
Improve tests and code after review
mattfalcone1997 Nov 8, 2025
a921752
Implement initial fix to edge case where offset is on the cell face
mattfalcone1997 Nov 10, 2025
af2d41e
Fix bugs causing seg faults
mattfalcone1997 Nov 11, 2025
4e0f2b9
Add option of not scaling the bulk when using mapped inlet
mattfalcone1997 Nov 11, 2025
db54fed
Add scale factor to mass flow rate BCs
mattfalcone1997 Nov 16, 2025
ea9b3f7
Fix bugs after rebase
mattfalcone1997 Nov 16, 2025
2a02a08
Add integrated value foam postprocessor
mattfalcone1997 Dec 18, 2025
fa02fcd
Fix errors associated with rebase
mattfalcone1997 Feb 7, 2026
43ff8cb
Remove mapped inlet classes to separate branch
mattfalcone1997 Feb 8, 2026
99749a3
Remove thermal hydraulics from modules
mattfalcone1997 Feb 10, 2026
1e48ea0
Remove unnecessary verify test from mass flow rate BC
mattfalcone1997 Feb 10, 2026
5f39351
Remove unnecessary parameters from BCs
mattfalcone1997 Feb 10, 2026
ebe1303
Minor refactor after review
mattfalcone1997 Feb 10, 2026
6fe5f4c
Move listFromVector to internals namespace
mattfalcone1997 Feb 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ RDG := no
RICHARDS := no
STOCHASTIC_TOOLS := no
TENSOR_MECHANICS := no
THERMAL_HYDRAULICS := no
XFEM := no

include $(MOOSE_DIR)/modules/modules.mk
Expand Down
7 changes: 6 additions & 1 deletion include/actions/AddFoamBCAction.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include "InputParameters.h"
#include "MooseObjectAction.h"
#include "FoamProblem.h"

#include <MooseObjectAction.h>

class AddFoamBCAction : public MooseObjectAction
{
Expand All @@ -15,4 +17,7 @@ class AddFoamBCAction : public MooseObjectAction
protected:
// Create AuxVariable associated with new-style BCs
void createAuxVariable();

// Create Receiver for Postprocessor-based BCs
void createReceiver(FoamProblem & problem);
};
8 changes: 7 additions & 1 deletion include/bcs/FoamBCBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <MooseObject.h>
#include <MooseTypes.h>
#include <MooseVariableFieldBase.h>
#include "VariadicTable.h"

typedef VariadicTable<std::string, std::string, std::string, std::string, std::string> BCInfoTable;

class FoamBCBase : public MooseObject, public Coupleable
{
Expand All @@ -26,7 +29,10 @@ class FoamBCBase : public MooseObject, public Coupleable
// returns the name of the foam boundaries the BC applies to
std::vector<SubdomainName> boundary() const { return _boundary; };

virtual void initialSetup();
virtual void initialSetup() = 0;

// Add information about BC to table
virtual void addInfoRow(BCInfoTable & table) = 0;

protected:
// OpenFOAM variable which this BC is to be imposed on
Expand Down
4 changes: 2 additions & 2 deletions include/bcs/FoamFixedGradientBC.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "FoamBCBase.h"
#include "FoamVariableBCBase.h"
#include "InputParameters.h"

class FoamFixedGradientBC : public FoamBCBase
class FoamFixedGradientBC : public FoamVariableBCBase
{
public:
// Validate input file parameters
Expand Down
19 changes: 19 additions & 0 deletions include/bcs/FoamFixedGradientPostprocessorBC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "FoamPostprocessorBCBase.h"
#include "InputParameters.h"

class FoamFixedGradientPostprocessorBC : public FoamPostprocessorBCBase
{
public:
static InputParameters validParams();

FoamFixedGradientPostprocessorBC(const InputParameters & params);

// impose boundary condition
virtual void imposeBoundaryCondition() override;

protected:
// name of diffusivity coefficient used to divide flux
std::string _diffusivity_coefficient;
};
4 changes: 2 additions & 2 deletions include/bcs/FoamFixedValueBC.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "FoamBCBase.h"
#include "FoamVariableBCBase.h"
#include "InputParameters.h"

class FoamFixedValueBC : public FoamBCBase
class FoamFixedValueBC : public FoamVariableBCBase
{
public:
// Validate input file parameters
Expand Down
14 changes: 14 additions & 0 deletions include/bcs/FoamFixedValuePostprocessorBC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "FoamPostprocessorBCBase.h"

class FoamFixedValuePostprocessorBC : public FoamPostprocessorBCBase
{
public:
static InputParameters validParams();

FoamFixedValuePostprocessorBC(const InputParameters & params);

// Impose boundary conditions (to be called from FoamProblem class)
virtual void imposeBoundaryCondition() override;
};
17 changes: 17 additions & 0 deletions include/bcs/FoamMassFlowRateInletBC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "FoamPostprocessorBCBase.h"
#include "InputParameters.h"
#include "MooseTypes.h"
#include "PostprocessorInterface.h"

class FoamMassFlowRateInletBC : public FoamPostprocessorBCBase
{
public:
static InputParameters validParams();

FoamMassFlowRateInletBC(const InputParameters & params);

virtual void imposeBoundaryCondition() override;

protected:
const Real _scale_factor;
};
27 changes: 27 additions & 0 deletions include/bcs/FoamPostprocessorBCBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "FoamBCBase.h"
#include "InputParameters.h"
#include "MooseTypes.h"
#include "PostprocessorInterface.h"

class FoamPostprocessorBCBase : public FoamBCBase, public PostprocessorInterface
{
public:
static InputParameters validParams();

explicit FoamPostprocessorBCBase(const InputParameters & params);

// returns the moose AuxVariable imposed on OpenFOAM
VariableName moosePostprocessor() const { return _pp_name; }

virtual void initialSetup() {};

virtual void addInfoRow(BCInfoTable & table);

protected:
const PostprocessorName _pp_name;

// Pointer to Moose variable used to impose BC
const PostprocessorValue & _pp_value;
};
29 changes: 29 additions & 0 deletions include/bcs/FoamVariableBCBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "FoamBCBase.h"
#include "InputParameters.h"

class FoamVariableBCBase : public FoamBCBase
{
public:
static InputParameters validParams();

explicit FoamVariableBCBase(const InputParameters & params);

// returns the moose AuxVariable imposed on OpenFOAM
VariableName mooseVariable() const { return _moose_var->name(); }

virtual void initialSetup();

virtual void addInfoRow(BCInfoTable & table);

protected:
// Get the value of the MOOSE variable at an element
Real variableValueAtElement(const libMesh::Elem & elem);

// Get the data vector of the MOOSE field on a subdomain
std::vector<Real> getMooseVariableArray(int subdomainId);

// Pointer to Moose variable used to impose BC
MooseVariableFieldBase * _moose_var;
};
11 changes: 9 additions & 2 deletions include/mesh/FoamMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,19 @@ class FoamMesh : public MooseMesh
return _foam_mesh.foundObject<T>(name);
}

// Returns the patch array for field and subdomain
template <typename GeoField, typename Type>
Foam::fvPatchField<Type> & getBCField(SubdomainID subdomain, Foam::word const & field)
{
return const_cast<Foam::fvPatchField<Type> &>(
_foam_mesh.boundary()[subdomain].lookupPatchField<GeoField, Type>(field));
}

// Returns the gradient BC array for field and subdomain
template <typename GeoField, typename Type>
Foam::Field<Type> & getGradientBCField(SubdomainID subdomain, Foam::word const & field)
{
auto & var = const_cast<Foam::fvPatchField<Type> &>(
_foam_mesh.boundary()[subdomain].lookupPatchField<GeoField, Type>(field));
auto & var = getBCField<GeoField, Type>(subdomain, field);
return Foam::refCast<Foam::fixedGradientFvPatchField<Type>>(var).gradient();
}

Expand Down
15 changes: 15 additions & 0 deletions include/util/hippoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,20 @@ copyParamFromParam(InputParameters & dst, const InputParameters & src, const std
if (src.isParamValid(name_in))
dst.set<T>(name_in) = src.get<T>(name_in);
}

template <typename StrType>
inline std::string
listFromVector(std::vector<StrType> vec, StrType sep = ", ")
{
if (vec.size() == 0)
return std::string();
else if (vec.size() == 1)
return vec.at(0);

std::string str;
auto binary_op = [&](const std::string & acc, const std::string & it) { return acc + sep + it; };
std::accumulate(vec.begin(), vec.end(), str, binary_op);
return str;
}
}
}
26 changes: 25 additions & 1 deletion src/actions/AddFoamBCAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@

registerMooseAction("hippoApp", AddFoamBCAction, "add_foam_bc");

namespace
{
inline bool
findParamKey(const InputParameters & params, const std::string & key)
{
return std::find_if(params.begin(),
params.end(),
[&](const auto & param) { return param.first == key; }) != params.end();
}
}

InputParameters
AddFoamBCAction::validParams()
{
Expand All @@ -27,9 +38,13 @@ AddFoamBCAction::act()
mooseError("FoamBCs system can only be used with FoamProblem.");

// Do not create aux variable if variable provided.
if (!_moose_object_pars.isParamSetByUser("v"))
if (findParamKey(_moose_object_pars, "v") && !_moose_object_pars.isParamSetByUser("v"))
createAuxVariable();

// Create receiver if pp not provided and pp is an allowed parameter
if (findParamKey(_moose_object_pars, "pp") && !_moose_object_pars.isParamSetByUser("pp"))
createReceiver(*foam_problem);

foam_problem->addObject<FoamBCBase>(_type, _name, _moose_object_pars, false);
}
}
Expand All @@ -56,3 +71,12 @@ AddFoamBCAction::createAuxVariable()
std::static_pointer_cast<Action>(_action_factory.create(class_name, name(), action_params));
_awh.addActionBlock(action);
}

void
AddFoamBCAction::createReceiver(FoamProblem & problem)
{
auto params = _factory.getValidParams("Receiver");

Hippo::internal::copyParamFromParam<Real>(params, _moose_object_pars, "default");
problem.addPostprocessor("Receiver", name(), params);
}
65 changes: 4 additions & 61 deletions src/bcs/FoamBCBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
#include <algorithm>
#include <vector>

namespace
{
// Private function to check if variables are constant monomials
inline bool
is_constant_monomial(const MooseVariableFieldBase & var)
{
return var.order() == libMesh::Order::CONSTANT && var.feType().family == FEFamily::MONOMIAL;
}
}

InputParameters
FoamBCBase::validParams()
{
Expand All @@ -32,13 +22,8 @@ FoamBCBase::validParams()
"Name of a Foam field. e.g. T (temperature) U (velocity).");
params.addParam<std::vector<SubdomainName>>("boundary",
"Boundaries that the boundary condition applies to.");

params.addParam<VariableName>(
"v",
"Optional variable to use in BC. This allows existing AuxVariables to be"
" used rather than creating a new one under the hood.");
// Get desired parameters from Variable objects
params.transferParam<std::vector<Real>>(MooseVariable::validParams(), "initial_condition");
params.addRequiredParam<std::string>("foam_variable",
"Name of a Foam field. e.g. T (temperature) U (velocity).");

params.registerSystemAttributeName("FoamBC");
params.registerBase("FoamBC");
Expand All @@ -50,7 +35,6 @@ FoamBCBase::FoamBCBase(const InputParameters & params)
: MooseObject(params),
Coupleable(this, false),
_foam_variable(params.get<std::string>("foam_variable")),
_moose_var(nullptr),
_boundary(params.get<std::vector<SubdomainName>>("boundary"))
{
auto * problem = dynamic_cast<FoamProblem *>(&_c_fe_problem);
Expand All @@ -60,7 +44,8 @@ FoamBCBase::FoamBCBase(const InputParameters & params)
_mesh = &problem->mesh();

// check that the foam variable exists
if (!_mesh->foamHasObject<Foam::volScalarField>(_foam_variable))
if (!params.isPrivate("foam_variable") &&
!_mesh->foamHasObject<Foam::volScalarField>(_foam_variable))
mooseError("There is no OpenFOAM field named '", _foam_variable, "'");

// check that the boundary is in the FoamMesh
Expand All @@ -75,45 +60,3 @@ FoamBCBase::FoamBCBase(const InputParameters & params)
if (_boundary.empty())
_boundary = all_subdomain_names;
}

void
FoamBCBase::initialSetup()
{
// Check variable exists
auto var_name = parameters().isParamValid("v") ? parameters().get<VariableName>("v") : _name;
if (!_c_fe_problem.hasVariable(var_name))
mooseError("Variable '", var_name, "' doesn't exist");

THREAD_ID tid = parameters().get<THREAD_ID>("_tid");
_moose_var = &_c_fe_problem.getVariable(tid, var_name);

// Check variable is constant monomial in case it is provided.
if (!is_constant_monomial(*_moose_var))
mooseError("Variable '", var_name, "' must be a constant monomial.");
}

Real
FoamBCBase::variableValueAtElement(const libMesh::Elem * elem)
{
auto & sys = _moose_var->sys();
auto dof = elem->dof_number(sys.number(), _moose_var->number(), 0);
return sys.solution()(dof);
}

std::vector<Real>
FoamBCBase::getMooseVariableArray(int subdomain_id)
{
size_t patch_count = _mesh->getPatchCount(subdomain_id);
size_t patch_offset = _mesh->getPatchOffset(subdomain_id);

std::vector<Real> var_array(patch_count);
for (size_t j = 0; j < patch_count; ++j)
{
auto elem = patch_offset + j;
auto elem_ptr = _mesh->getElemPtr(elem + _mesh->rank_element_offset);
assert(elem_ptr);
var_array[j] = variableValueAtElement(elem_ptr);
}

return var_array;
}
4 changes: 2 additions & 2 deletions src/bcs/FoamFixedGradientBC.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ registerMooseObject("hippoApp", FoamFixedGradientBC);
InputParameters
FoamFixedGradientBC::validParams()
{
auto params = FoamBCBase::validParams();
auto params = FoamVariableBCBase::validParams();
params.addClassDescription("A FoamBC that imposes a fixed gradient dirichlet boundary condition "
"on the OpenFOAM simulation");
params.addParam<std::string>("diffusivity_coefficient",
Expand All @@ -20,7 +20,7 @@ FoamFixedGradientBC::validParams()
}

FoamFixedGradientBC::FoamFixedGradientBC(const InputParameters & parameters)
: FoamBCBase(parameters),
: FoamVariableBCBase(parameters),
_diffusivity_coefficient(parameters.get<std::string>("diffusivity_coefficient"))
{
// check that the diffusivity coefficient is a OpenFOAM scalar field
Expand Down
Loading