-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8509a3f
commit 7627599
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "Phi.H" | ||
|
||
using namespace Foam; | ||
|
||
preciceAdapter::FF::Phi::Phi( | ||
const Foam::fvMesh& mesh, | ||
const std::string namePhi) | ||
: phi_( | ||
const_cast<surfaceScalarField*>( | ||
&mesh.lookupObject<surfaceScalarField>(namePhi))) | ||
{ | ||
dataType_ = scalar; | ||
} | ||
|
||
std::size_t preciceAdapter::FF::Phi::write(double* buffer, bool meshConnectivity, const unsigned int dim) | ||
{ | ||
int bufferIndex = 0; | ||
|
||
// For every boundary patch of the interface | ||
for (uint j = 0; j < patchIDs_.size(); j++) | ||
{ | ||
int patchID = patchIDs_.at(j); | ||
|
||
// For every cell of the patch | ||
forAll(phi_->boundaryFieldRef()[patchID], i) | ||
{ | ||
// Copy the Phi into the buffer | ||
buffer[bufferIndex++] = | ||
phi_->boundaryFieldRef()[patchID][i]; | ||
} | ||
} | ||
return bufferIndex; | ||
} | ||
|
||
void preciceAdapter::FF::Phi::read(double* buffer, const unsigned int dim) | ||
{ | ||
int bufferIndex = 0; | ||
|
||
// For every boundary patch of the interface | ||
for (uint j = 0; j < patchIDs_.size(); j++) | ||
{ | ||
int patchID = patchIDs_.at(j); | ||
|
||
forAll(phi_->boundaryFieldRef()[patchID], i) | ||
{ | ||
phi_->boundaryFieldRef()[patchID][i] = -buffer[bufferIndex++]; | ||
} | ||
} | ||
} | ||
|
||
bool preciceAdapter::FF::Phi::isLocationTypeSupported(const bool meshConnectivity) const | ||
{ | ||
return (this->locationType_ == LocationType::faceCenters); | ||
} | ||
|
||
std::string preciceAdapter::FF::Phi::getDataName() const | ||
{ | ||
return "Phi"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef FF_PHI_H | ||
#define FF_PHI_H | ||
|
||
#include "CouplingDataUser.H" | ||
|
||
#include "fvCFD.H" | ||
|
||
namespace preciceAdapter | ||
{ | ||
namespace FF | ||
{ | ||
|
||
//- Class that writes and reads the flux phi | ||
class Phi : public CouplingDataUser | ||
{ | ||
|
||
private: | ||
//- Phi field | ||
Foam::surfaceScalarField* phi_; | ||
|
||
public: | ||
//- Constructor | ||
Phi( | ||
const Foam::fvMesh& mesh, | ||
const std::string namePhi); | ||
|
||
//- Write the Phi values into the buffer | ||
std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); | ||
|
||
//- Read the Phi values from the buffer | ||
void read(double* buffer, const unsigned int dim); | ||
|
||
bool isLocationTypeSupported(const bool meshConnectivity) const override; | ||
|
||
//- Get the name of the current data field | ||
std::string getDataName() const override; | ||
}; | ||
|
||
} | ||
} | ||
|
||
#endif |