Skip to content

Commit c96fafa

Browse files
Add mapped inlet changes to new branch
1 parent ffbe445 commit c96fafa

30 files changed

Lines changed: 2143 additions & 0 deletions
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#pragma once
2+
3+
#include "FoamPostprocessorBCBase.h"
4+
#include <UPstream.H>
5+
6+
class FoamMappedInletBCBase : public FoamPostprocessorBCBase
7+
{
8+
public:
9+
static InputParameters validParams();
10+
11+
FoamMappedInletBCBase(const InputParameters & params);
12+
13+
virtual ~FoamMappedInletBCBase() { destroyCommunicator(_foam_comm); }
14+
15+
protected:
16+
Foam::vector _offset;
17+
18+
std::map<int, std::vector<int>> _send_map;
19+
20+
std::map<int, std::vector<int>> _recv_map;
21+
22+
Foam::label _foam_comm;
23+
24+
MPI_Comm _mpi_comm;
25+
26+
// create send and receive information for mapping
27+
void createPatchProcMap();
28+
29+
// get array from mapped plane on the inlet processes
30+
template <typename T>
31+
Foam::Field<T> getMappedArray(const Foam::word & name);
32+
33+
// check if bounding box intersects with rank
34+
bool intersectMapPlane(const Foam::fvMesh & mesh, Real cart_bbox[6]);
35+
36+
// create/assign communicators for the transfers between map and inlet planes
37+
void createMapComm(const Foam::fvMesh & mesh,
38+
Foam::vectorField face_centres,
39+
std::vector<int> & send_process,
40+
std::vector<int> & recv_process);
41+
42+
// find index of cell containing point or raise error if not found
43+
int findIndex(const Foam::point & location, const MPI_Comm & comm);
44+
45+
// handle creation of new communicators in parallel or serial
46+
Foam::label
47+
createCommunicator(const Foam::label parent_comm, std::vector<int> procs, MPI_Comm & new_comm)
48+
{
49+
Foam::label foam_comm;
50+
if (Foam::UPstream::parRun())
51+
{
52+
Foam::labelList foam_procs(procs.begin(), procs.end());
53+
foam_comm = Foam::UPstream::allocateCommunicator(parent_comm, foam_procs, true);
54+
new_comm = Foam::PstreamGlobals::MPICommunicators_[foam_comm];
55+
}
56+
else
57+
{
58+
foam_comm = Foam::UPstream::worldComm;
59+
new_comm = MPI_COMM_WORLD;
60+
}
61+
return foam_comm;
62+
}
63+
64+
// free communicators if parallel run
65+
void destroyCommunicator(Foam::label comm)
66+
{
67+
if (Foam::UPstream::parRun())
68+
Foam::UPstream::freeCommunicator(comm);
69+
}
70+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
#include "FoamMappedInletBCBase.h"
3+
#include "MooseEnum.h"
4+
5+
class FoamMassFlowRateMappedInletBC : public FoamMappedInletBCBase
6+
{
7+
public:
8+
static InputParameters validParams();
9+
10+
FoamMassFlowRateMappedInletBC(const InputParameters & params);
11+
12+
virtual void imposeBoundaryCondition() override;
13+
14+
protected:
15+
MooseEnum _scale_method;
16+
17+
Real _scale_factor;
18+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
#include "FoamMappedInletBCBase.h"
3+
#include "MooseEnum.h"
4+
5+
class FoamScalarBulkMappedInletBC : public FoamMappedInletBCBase
6+
{
7+
public:
8+
static InputParameters validParams();
9+
10+
FoamScalarBulkMappedInletBC(const InputParameters & params);
11+
12+
virtual void imposeBoundaryCondition() override;
13+
14+
protected:
15+
MooseEnum _scale_method;
16+
17+
template <typename T>
18+
T applyScaleMethod(T & var, const Real bulk_ref, const Real bulk);
19+
};

0 commit comments

Comments
 (0)