Skip to content

Commit

Permalink
Merge pull request #266 from pecos/dev-gridClass
Browse files Browse the repository at this point in the history
Dev grid class
  • Loading branch information
shaering authored Mar 31, 2024
2 parents d3dfccd + 6e260bc commit 9543b56
Show file tree
Hide file tree
Showing 15 changed files with 621 additions and 256 deletions.
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cxx_sources = averaging.cpp faceGradientIntegration.cpp M2ulPhyS.cpp rh
pybindings.cpp gslib_interpolator.cpp loMach.cpp loMachIO.cpp loMach_options.cpp calorically_perfect.cpp \
thermo_chem_base.cpp split_flow_base.cpp tomboulides.cpp dirichlet_bc_helper.cpp \
sponge_base.cpp geometricSponge.cpp gaussianInterpExtData.cpp turb_model_base.cpp \
algebraicSubgridModels.cpp algebraic_rans.cpp
algebraicSubgridModels.cpp algebraic_rans.cpp mesh_base.cpp

mfem_extra_sources = ../utils/mfem_extras/pfem_extras.cpp

Expand All @@ -56,7 +56,7 @@ headers = averaging.hpp equation_of_state.hpp transport_properties.
loMach.hpp loMach_options.hpp calorically_perfect.hpp \
thermo_chem_base.hpp split_flow_base.hpp tomboulides.hpp dirichlet_bc_helper.hpp \
sponge_base.hpp geometricSponge.hpp externalData_base.hpp gaussianInterpExtData.hpp \
turb_model_base.hpp algebraicSubgridModels.hpp algebraic_rans.hpp
turb_model_base.hpp algebraicSubgridModels.hpp algebraic_rans.hpp mesh_base.hpp

mfem_extra_headers = ../utils/mfem_extras/pfem_extras.hpp

Expand Down
23 changes: 13 additions & 10 deletions src/algebraicSubgridModels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ using namespace mfem;
using namespace mfem::common;

AlgebraicSubgridModels::AlgebraicSubgridModels(mfem::ParMesh *pmesh, LoMachOptions *loMach_opts, TPS::Tps *tps,
int sModel)
ParGridFunction *gridScale, int sModel)
: tpsP_(tps), loMach_opts_(loMach_opts), pmesh_(pmesh) {
rank_ = pmesh_->GetMyRank();
rank0_ = (pmesh_->GetMyRank() == 0);
dim_ = pmesh_->Dimension();
nvel_ = dim_;
order_ = loMach_opts_->order;
gridScale_ = gridScale;
sModel_ = sModel;

// read-ins
Expand All @@ -69,7 +70,7 @@ AlgebraicSubgridModels::AlgebraicSubgridModels(mfem::ParMesh *pmesh, LoMachOptio
}

AlgebraicSubgridModels::~AlgebraicSubgridModels() {
delete bufferGridScale_;
// delete bufferGridScale_;
delete sfec_;
delete sfes_;
delete vfec_;
Expand Down Expand Up @@ -107,11 +108,11 @@ void AlgebraicSubgridModels::initializeSelf() {
gradW_.SetSize(vfes_truevsize);
rn_.SetSize(sfes_truevsize);

gridScale_.SetSize(sfes_truevsize);
// gridScale_.SetSize(sfes_truevsize);
// gridScaleX_.SetSize(sfes_truevsize);
// gridScaleY_.SetSize(sfes_truevsize);
// gridScaleZ_.SetSize(sfes_truevsize);
resolution_gf_.SetSpace(sfes_);
// resolution_gf_.SetSpace(sfes_);

if (verbose) grvy_printf(ginfo, "AlgebraicSubgridModels vectors and gf initialized...\n");

Expand All @@ -125,11 +126,12 @@ void AlgebraicSubgridModels::initializeOperators() {
}

void AlgebraicSubgridModels::initializeViz(ParaViewDataCollection &pvdc) {
pvdc.RegisterField("resolution", &resolution_gf_);
// pvdc.RegisterField("resolution", &resolution_gf_);
pvdc.RegisterField("muT", &subgridVisc_gf_);
}

void AlgebraicSubgridModels::setup() {
/*
/// Grid-related ///
// Build grid size vector and grid function
Expand Down Expand Up @@ -213,6 +215,7 @@ void AlgebraicSubgridModels::setup() {
}
resolution_gf_ = *bufferGridScale_;
*/
}

void AlgebraicSubgridModels::step() {
Expand All @@ -229,11 +232,11 @@ void AlgebraicSubgridModels::step() {
(thermoChem_interface_->density)->GetTrueDofs(rn_);

subgridVisc_ = 0.0;
double *dGradU = gradU_.HostReadWrite();
double *dGradV = gradV_.HostReadWrite();
double *dGradW = gradW_.HostReadWrite();
double *del = gridScale_.HostReadWrite();
double *rho = rn_.HostReadWrite();
const double *dGradU = gradU_.HostRead();
const double *dGradV = gradV_.HostRead();
const double *dGradW = gradW_.HostRead();
const double *rho = rn_.HostRead();
const double *del = gridScale_->HostRead();
double *data = subgridVisc_.HostReadWrite();

if (sModel_ == 1) {
Expand Down
12 changes: 7 additions & 5 deletions src/algebraicSubgridModels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,21 @@ class AlgebraicSubgridModels : public TurbModelBase {
Vector subgridVisc_;

// for plotting
ParGridFunction resolution_gf_;
Vector gridScale_;
// ParGridFunction resolution_gf_;
// Vector gridScale_;

// grid information
ParGridFunction *bufferGridScale_ = nullptr;
ParGridFunction *gridScale_ = nullptr;
// ParGridFunction *bufferGridScale_ = nullptr;
// ParGridFunction *bufferGridScaleX = nullptr;
// ParGridFunction *bufferGridScaleY = nullptr;
// ParGridFunction *bufferGridScaleZ = nullptr;

double sgs_model_const_;

public:
AlgebraicSubgridModels(mfem::ParMesh *pmesh, LoMachOptions *loMach_opts, TPS::Tps *tps, int sModel);
AlgebraicSubgridModels(mfem::ParMesh *pmesh, LoMachOptions *loMach_opts, TPS::Tps *tps, ParGridFunction *gridScale,
int sModel);
virtual ~AlgebraicSubgridModels();

// Functions overriden from base class
Expand All @@ -154,7 +156,7 @@ class AlgebraicSubgridModels : public TurbModelBase {
ParGridFunction *getCurrentEddyViscosity() { return &subgridVisc_gf_; }

/// Return a pointer to the scalar grid size measure ParGridFunction.
ParGridFunction *getGridScale() { return &resolution_gf_; }
// ParGridFunction *getGridScale() { return &resolution_gf_; }

// subgrid scale models => move to turb model class
void sgsSmag(const DenseMatrix &gradUp, double delta, double &nu_sgs);
Expand Down
10 changes: 7 additions & 3 deletions src/algebraic_rans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@

using namespace mfem;

AlgebraicRans::AlgebraicRans(Mesh *smesh, ParMesh *pmesh, const Array<int> &partitioning, int order, TPS::Tps *tps)
: pmesh_(pmesh), order_(order) {
// AlgebraicRans::AlgebraicRans(Mesh *smesh, ParMesh *pmesh, const Array<int> &partitioning, int order, TPS::Tps *tps)
AlgebraicRans::AlgebraicRans(ParMesh *pmesh, const Array<int> &partitioning, int order, TPS::Tps *tps,
ParGridFunction *distance)
: pmesh_(pmesh), order_(order), distance_(distance) {
dim_ = pmesh_->Dimension();

// Check for axisymmetric flag
Expand All @@ -54,6 +56,7 @@ AlgebraicRans::AlgebraicRans(Mesh *smesh, ParMesh *pmesh, const Array<int> &part
sfec_ = new H1_FECollection(order_);
sfes_ = new ParFiniteElementSpace(pmesh_, sfec_);

/*
// Evaluate distance function
FiniteElementSpace serial_fes(smesh, sfec_);
GridFunction serial_distance(&serial_fes);
Expand Down Expand Up @@ -96,6 +99,7 @@ AlgebraicRans::AlgebraicRans(Mesh *smesh, ParMesh *pmesh, const Array<int> &part
if (partitioning.HostRead() == nullptr) {
*distance_ = serial_distance;
}
*/

// Necessary?
// distance_->ParFESpace()->ExchangeFaceNbrData();
Expand All @@ -112,7 +116,7 @@ AlgebraicRans::~AlgebraicRans() {
delete mut_;

// Alloced in ctor
delete distance_;
// delete distance_;
delete sfes_;
delete sfec_;
}
Expand Down
6 changes: 4 additions & 2 deletions src/algebraic_rans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ class AlgebraicRans : public TurbModelBase {

public:
/// Constructor
AlgebraicRans(mfem::Mesh *smesh, mfem::ParMesh *pmesh, const mfem::Array<int> &partitioning, int order,
TPS::Tps *tps);
// AlgebraicRans(mfem::Mesh *smesh, mfem::ParMesh *pmesh, const mfem::Array<int> &partitioning, int order, TPS::Tps
// *tps);
AlgebraicRans(mfem::ParMesh *pmesh, const mfem::Array<int> &partitioning, int order, TPS::Tps *tps,
mfem::ParGridFunction *distance);

/// Destructor
virtual ~AlgebraicRans();
Expand Down
7 changes: 6 additions & 1 deletion src/calorically_perfect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class CaloricallyPerfectThermoChem : public ThermoChemModelBase {
double static_rho_;

/// pressure-related, closed-system thermo pressure changes
double ambient_pressure_, thermo_pressure_, system_mass_;
double ambient_pressure_, system_mass_;
// double thermo_pressure_;
double dtP_;

// Initial temperature value (if constant IC)
Expand Down Expand Up @@ -244,6 +245,10 @@ class CaloricallyPerfectThermoChem : public ThermoChemModelBase {
/// Return a pointer to the current total thermal diffusivity ParGridFunction.
ParGridFunction *GetCurrentThermalDiv() { return &Qt_gf_; }

/// Return thermodynamic pressure for restarts
// double GetCurrentThermoPressure() { return thermo_pressure_; }
// double SetCurrentThermoPressure(double Po) { thermo_pressure_ = Po;}

/// Rotate entries in the time step and solution history arrays.
void UpdateTimestepHistory(double dt);

Expand Down
Loading

0 comments on commit 9543b56

Please sign in to comment.