Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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);
}
};
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;
};
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);
};
Loading
Loading