Skip to content

Implement inherited MOOSE variable classes to shadow OpenFOAM fields and function objects#66

Merged
mattfalcone1997 merged 19 commits intoaurora-multiphysics:generalise_bcs_transferfrom
mattfalcone1997:foam_variable_shadowing
Sep 29, 2025
Merged

Implement inherited MOOSE variable classes to shadow OpenFOAM fields and function objects#66
mattfalcone1997 merged 19 commits intoaurora-multiphysics:generalise_bcs_transferfrom
mattfalcone1997:foam_variable_shadowing

Conversation

@mattfalcone1997
Copy link
Collaborator

@mattfalcone1997 mattfalcone1997 commented Sep 16, 2025

Summary

Currently, Hippo transfers fields explicitly to be imposed as temperatures or heat fluxes in MOOSE. This PR generalises part of this by allowing OpenFOAM fields (such as temperature T) and function objects (such as heat flux wallHeatFlux) to be shadowed by MOOSE variables. The second part of this will be to generalise the imposition of BCs in OpenFOAM using MOOSE input file syntax.

Related Issue

Resolves #43

Checklist

  • Scalar field shadowing implemented
  • Function object shadowing implemented for scalars
  • Code well commented
  • Tests have been implemented to test shadowing of volScalarFields and function objects that return volScalarFields.
  • Decide whether to implement vector shadowing in this PR
    • We will do this when looking at multi-scale case

@mattfalcone1997
Copy link
Collaborator Author

I think we should consider whether to use a specialised FoamVariables input syntax to make it clear the distinction between regular AuxVariables and the ones that shadow OpenFOAM. Their operation can be the same other wise.

Copy link
Collaborator

@hsaunders1904 hsaunders1904 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! A much nicer interface, I think. When are we planning on removing the old way of performing the transfers? I guess when the BCs are done?

Do you have a clear idea of how we would extend the existing FoamVariableField code for volumetric transfers?

# Additional special case targets should be added here

# Add foam modules
# TODO: Reorganise build: consider single mk for all OpenFOAM modules
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we open an issue for this, rather than leaving it as a TODO?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add an issue but would rather leave to todo's in, so I get a reminder when I am doing it

#include "MooseTypes.h"
#include "FoamMesh.h"

class FoamVariableField : public MooseObject
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would FoamFieldVariable be a better name here? It's a MOOSE variable representing an OpenFOAM field, so it feels like "foam" and "field" belong next to one-another.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that when I add handling of vectors at some point I will change it to FoamScalarField/FoamVectorField to mirror volScalarField etc. Also there is a MOOSE class called MooseVariableField so the analogy may be useful.

FoamVariableField::createMooseVariable(std::string name, const InputParameters & params)
{
// TODO: Add other parameters from variable instantiations such as Boundary restrictions
auto & problem = getMooseApp().feProblem();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be checking this a FoamProblem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, but by this point it would be checked already by the action syntax, so probably fine. Depends on how defensive we need to be.

[]
[Problem]
type = FoamProblem
# Take the boundary temperature from OpenFOAM and set it on the MOOSE mesh.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment useful anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this in the tests PR.

#include "SystemBase.h"
#include "dictionary.H"
#include "functionObject.H"
// #include "wallHeatFlux.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this in the tests PR.

@mattfalcone1997
Copy link
Collaborator Author

I am deprecating the old syntax in a separate PR I hope to create by the end of the day. For volumetric transfers, that is a question of rewriting FoamMesh, which is a future me problem. I reckon the volumetric transfers should be reasonably straightforward after that.

@mattfalcone1997
Copy link
Collaborator Author

I will merge this now to the interim branch and make fixes to the most recent branch.

@mattfalcone1997 mattfalcone1997 merged commit bce2c98 into aurora-multiphysics:generalise_bcs_transfer Sep 29, 2025
2 checks passed
@mattfalcone1997 mattfalcone1997 deleted the foam_variable_shadowing branch September 29, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants