Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 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
7620ca9
Add mapped inlet changes to new branch
mattfalcone1997 Feb 8, 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);
};
23 changes: 22 additions & 1 deletion include/bcs/FoamBCBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@
#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;

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;
}

class FoamBCBase : public MooseObject, public Coupleable
{
Expand All @@ -26,7 +44,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;
};
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