Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8fcf898
Create working side average postprocessor
mattfalcone1997 Oct 8, 2025
714721e
Updated FoamProcessor so it computes with FoamProblem
mattfalcone1997 Oct 9, 2025
3427449
Add initial implementation of mass flow rate inlet BC
mattfalcone1997 Oct 14, 2025
56b9673
Simplify mass flow rate BC
mattfalcone1997 Oct 14, 2025
32f9897
Add initial makeshift test for mass flow rate BC
mattfalcone1997 Oct 14, 2025
da5911c
Fix bugs in mass flow rate inlet implementation
mattfalcone1997 Oct 14, 2025
3e3593b
Remove unnecessary headers
mattfalcone1997 Oct 16, 2025
a4dc8d5
Add initial implementation of mapped inlet mass flow rate boundary co…
mattfalcone1997 Nov 1, 2025
03a6ede
Add initial implementation of the mapped inlet test solver
mattfalcone1997 Nov 1, 2025
5f7fce8
Simplify mapped inlet test solver
mattfalcone1997 Nov 3, 2025
5f4090c
Fix basic mapped inlet implementation
mattfalcone1997 Nov 3, 2025
e6db2a2
Change mapped inlet test solver to use a rank independent test function
mattfalcone1997 Nov 3, 2025
4a931e7
Add test for mapped inlet mass flow rate BC
mattfalcone1997 Nov 3, 2025
814b529
Fix error in mapped inlet test
mattfalcone1997 Nov 3, 2025
ada9b4a
Use BBox to reduce communication for mapped inlet
mattfalcone1997 Nov 5, 2025
f741424
Add mapped inlet base class
mattfalcone1997 Nov 5, 2025
673b664
Add scalar bulk mapped inlet BC
mattfalcone1997 Nov 5, 2025
500020d
Rename mapped inlet test case
mattfalcone1997 Nov 5, 2025
eb2eb3b
Correct gold file reference for mass flow rate BC
mattfalcone1997 Nov 5, 2025
b8e079c
Implement new FoamVariableBCBase class and propagate changes
mattfalcone1997 Nov 6, 2025
dbdb50d
Implement new FoamPostprocessorBCBase class and propagate
mattfalcone1997 Nov 6, 2025
a2134ff
Add default creation of Receiver for Postprocessor-based BCs
mattfalcone1997 Nov 6, 2025
c3f2c35
Implement different scaling approaches for the scalar bulk mapped inlet
mattfalcone1997 Nov 6, 2025
d416fd7
Implement fixed value and fixed gradient postprocessor BCs
mattfalcone1997 Nov 7, 2025
2ff4f29
Clean up code and register postprocessor BC objects
mattfalcone1997 Nov 7, 2025
e81a0c1
Add tests for postprocessor BCs
mattfalcone1997 Nov 7, 2025
17ac488
Improve mapped inlet tests, in particular the different bounding box …
mattfalcone1997 Nov 8, 2025
fb0cf89
Add test for the mapped inlet subtract scaling method
mattfalcone1997 Nov 8, 2025
ed023c3
Improve tests and code after review
mattfalcone1997 Nov 8, 2025
08fa707
Implement initial fix to edge case where offset is on the cell face
mattfalcone1997 Nov 10, 2025
84f1301
Fix bugs causing seg faults
mattfalcone1997 Nov 11, 2025
2004fe1
Add option of not scaling the bulk when using mapped inlet
mattfalcone1997 Nov 11, 2025
56e48ce
Add scale factor to mass flow rate BCs
mattfalcone1997 Nov 16, 2025
2462563
Fix bugs after rebase
mattfalcone1997 Nov 16, 2025
f7d6fdb
Add integrated value foam postprocessor
mattfalcone1997 Dec 18, 2025
68865b0
Fix errors associated with rebase
mattfalcone1997 Feb 7, 2026
18fd234
Remove mapped inlet classes to separate branch
mattfalcone1997 Feb 8, 2026
a96b6e5
Remove thermal hydraulics from modules
mattfalcone1997 Feb 10, 2026
e12943c
Remove unnecessary verify test from mass flow rate BC
mattfalcone1997 Feb 10, 2026
3387e9c
Remove unnecessary parameters from BCs
mattfalcone1997 Feb 10, 2026
00592bf
Minor refactor after review
mattfalcone1997 Feb 10, 2026
049db78
Move listFromVector to internals namespace
mattfalcone1997 Feb 10, 2026
7d6eb08
Remove FoamControlledTimeStepper after rebase
mattfalcone1997 Apr 20, 2026
060aea8
Add mapped inlet changes to new branch
mattfalcone1997 Feb 8, 2026
053a357
Remove FoamControlledTimeStepper after mapped inlet rebase
mattfalcone1997 Apr 20, 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;
};
70 changes: 70 additions & 0 deletions include/bcs/FoamMappedInletBCBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#pragma once

#include "FoamPostprocessorBCBase.h"
#include <UPstream.H>

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

FoamMappedInletBCBase(const InputParameters & params);

virtual ~FoamMappedInletBCBase() { destroyCommunicator(_foam_comm); }

protected:
Foam::vector _offset;

std::map<int, std::vector<int>> _send_map;

std::map<int, std::vector<int>> _recv_map;

Foam::label _foam_comm;

MPI_Comm _mpi_comm;

// create send and receive information for mapping
void createPatchProcMap();

// get array from mapped plane on the inlet processes
template <typename T>
Foam::Field<T> getMappedArray(const Foam::word & name);

// check if bounding box intersects with rank
bool intersectMapPlane(const Foam::fvMesh & mesh, Real cart_bbox[6]);

// create/assign communicators for the transfers between map and inlet planes
void createMapComm(const Foam::fvMesh & mesh,
Foam::vectorField face_centres,
std::vector<int> & send_process,
std::vector<int> & recv_process);

// find index of cell containing point or raise error if not found
int findIndex(const Foam::point & location, const MPI_Comm & comm);

// handle creation of new communicators in parallel or serial
Foam::label
createCommunicator(const Foam::label parent_comm, std::vector<int> procs, MPI_Comm & new_comm)
{
Foam::label foam_comm;
if (Foam::UPstream::parRun())
{
Foam::labelList foam_procs(procs.begin(), procs.end());
foam_comm = Foam::UPstream::allocateCommunicator(parent_comm, foam_procs, true);
new_comm = Foam::PstreamGlobals::MPICommunicators_[foam_comm];
}
else
{
foam_comm = Foam::UPstream::worldComm;
new_comm = MPI_COMM_WORLD;
}
return foam_comm;
}

// free communicators if parallel run
void destroyCommunicator(Foam::label comm)
{
if (Foam::UPstream::parRun())
Foam::UPstream::freeCommunicator(comm);
}
};
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;
};
18 changes: 18 additions & 0 deletions include/bcs/FoamMassFlowRateMappedInletBC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include "FoamMappedInletBCBase.h"
#include "MooseEnum.h"

class FoamMassFlowRateMappedInletBC : public FoamMappedInletBCBase
{
public:
static InputParameters validParams();

FoamMassFlowRateMappedInletBC(const InputParameters & params);

virtual void imposeBoundaryCondition() override;

protected:
MooseEnum _scale_method;

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;
};
19 changes: 19 additions & 0 deletions include/bcs/FoamScalarBulkMappedInletBC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#include "FoamMappedInletBCBase.h"
#include "MooseEnum.h"

class FoamScalarBulkMappedInletBC : public FoamMappedInletBCBase
{
public:
static InputParameters validParams();

FoamScalarBulkMappedInletBC(const InputParameters & params);

virtual void imposeBoundaryCondition() override;

protected:
MooseEnum _scale_method;

template <typename T>
T applyScaleMethod(T & var, const Real bulk_ref, const Real bulk);
};
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 @@ -62,12 +62,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);
}
Loading
Loading