-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subtract out normal pressure gradient when mdot correction BC is acti…
…ve (#4)
- Loading branch information
1 parent
a529c52
commit 8f5162d
Showing
13 changed files
with
432 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*------------------------------------------------------------------------*/ | ||
/* Copyright 2014 Sandia Corporation. */ | ||
/* This software is released under the license detailed */ | ||
/* in the file, LICENSE, which is located in the top-level Nalu */ | ||
/* directory structure */ | ||
/*------------------------------------------------------------------------*/ | ||
|
||
|
||
#ifndef AssembleNodalGradPAlgorithmDriver_h | ||
#define AssembleNodalGradPAlgorithmDriver_h | ||
|
||
#include<AlgorithmDriver.h> | ||
#include <FieldTypeDef.h> | ||
|
||
namespace sierra{ | ||
namespace nalu{ | ||
|
||
class Realm; | ||
|
||
class AssembleNodalGradPAlgorithmDriver : public AlgorithmDriver | ||
{ | ||
public: | ||
|
||
AssembleNodalGradPAlgorithmDriver( | ||
Realm &realm); | ||
virtual ~AssembleNodalGradPAlgorithmDriver() {} | ||
|
||
virtual void pre_work() override; | ||
virtual void post_work() override; | ||
|
||
}; | ||
|
||
} // namespace nalu | ||
} // namespace Sierra | ||
|
||
#endif |
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
40 changes: 40 additions & 0 deletions
40
include/user_functions/CappingInversionTemperatureAuxFunction.h
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,40 @@ | ||
/*------------------------------------------------------------------------*/ | ||
/* Copyright 2014 Sandia Corporation. */ | ||
/* This software is released under the license detailed */ | ||
/* in the file, LICENSE, which is located in the top-level Nalu */ | ||
/* directory structure */ | ||
/*------------------------------------------------------------------------*/ | ||
|
||
#ifndef CappingInversionTemperatureAuxFunction_h | ||
#define CappingInversionTemperatureAuxFunction_h | ||
|
||
#include <AuxFunction.h> | ||
|
||
#include <vector> | ||
|
||
namespace sierra{ | ||
namespace nalu{ | ||
|
||
class CappingInversionTemperatureAuxFunction : public AuxFunction | ||
{ | ||
public: | ||
|
||
CappingInversionTemperatureAuxFunction(); | ||
|
||
virtual ~CappingInversionTemperatureAuxFunction() {} | ||
|
||
virtual void do_evaluate( | ||
const double * coords, | ||
const double time, | ||
const unsigned spatialDimension, | ||
const unsigned numPoints, | ||
double * fieldPtr, | ||
const unsigned fieldSize, | ||
const unsigned beginPos, | ||
const unsigned endPos) const; | ||
}; | ||
|
||
} // namespace nalu | ||
} // namespace Sierra | ||
|
||
#endif |
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
20 changes: 10 additions & 10 deletions
20
reg_tests/test_files/ablUnstableEdge/ablUnstableEdge_rst.norm.gold
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
13.79759875908612 1 1.25 | ||
0.8061222546965402 2 2.8125 | ||
0.562023679352072 3 4.76562 | ||
11.90085972620966 4 7.20703 | ||
6.266546368434017 5 9.68282 | ||
9.635424897738176 6 12.1237 | ||
17.95292177378264 7 14.5323 | ||
4.938092546499202 8 16.9087 | ||
10.69998797582451 9 19.2429 | ||
32.6178905646968 10 21.5424 | ||
13.79737695917944 1 1.25 | ||
0.8063289075114444 2 2.8125 | ||
0.5629518334281949 3 4.76562 | ||
11.90121212930885 4 7.20703 | ||
6.266459299114715 5 9.68282 | ||
9.635180348658634 6 12.1237 | ||
17.95413017303376 7 14.5323 | ||
4.939213131231322 8 16.9087 | ||
10.70056020635592 9 19.2429 | ||
32.63860650384363 10 21.5424 |
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,125 @@ | ||
/*------------------------------------------------------------------------*/ | ||
/* Copyright 2014 Sandia Corporation. */ | ||
/* This software is released under the license detailed */ | ||
/* in the file, LICENSE, which is located in the top-level Nalu */ | ||
/* directory structure */ | ||
/*------------------------------------------------------------------------*/ | ||
|
||
|
||
#include <AssembleNodalGradPAlgorithmDriver.h> | ||
#include <FieldTypeDef.h> | ||
#include <Realm.h> | ||
#include <SolutionOptions.h> | ||
|
||
|
||
// stk_mesh/base/fem | ||
#include <stk_mesh/base/BulkData.hpp> | ||
#include <stk_mesh/base/Field.hpp> | ||
#include <stk_mesh/base/FieldParallel.hpp> | ||
#include <stk_mesh/base/GetBuckets.hpp> | ||
#include <stk_mesh/base/GetEntities.hpp> | ||
#include <stk_mesh/base/MetaData.hpp> | ||
#include <stk_mesh/base/Part.hpp> | ||
#include <stk_mesh/base/FieldBLAS.hpp> | ||
|
||
namespace sierra{ | ||
namespace nalu{ | ||
|
||
class Realm; | ||
|
||
|
||
void subtract_normal_component(int dim, const double* normal, double* grad_p) | ||
{ | ||
double grad_p_dot_n = 0; | ||
for (int j = 0; j < dim; ++j) { | ||
grad_p_dot_n += normal[j] * grad_p[j]; | ||
} | ||
|
||
for (int j = 0; j < dim; ++j) { | ||
grad_p[j] -= grad_p_dot_n * normal[j]; | ||
} | ||
} | ||
|
||
void subtract_normal_pressure_gradient(const stk::mesh::BulkData& bulk, VectorFieldType& dqdxField) | ||
{ | ||
const auto& meta = bulk.mesh_meta_data(); | ||
ThrowRequireMsg(meta.get_field<VectorFieldType>(stk::topology::NODE_RANK, "average_open_normal") != nullptr, | ||
"average_open_normal field required"); | ||
VectorFieldType& meanNormalField = *meta.get_field<VectorFieldType>(stk::topology::NODE_RANK, "average_open_normal"); | ||
|
||
const int nDim = meta.spatial_dimension(); | ||
|
||
const stk::mesh::Selector& owned_or_shared_open = (meta.locally_owned_part() | meta.globally_shared_part()) | ||
& stk::mesh::selectField(meanNormalField); | ||
const stk::mesh::BucketVector& node_buckets = bulk.get_buckets(stk::topology::NODE_RANK, owned_or_shared_open); | ||
for (const auto* ib : node_buckets) { | ||
const auto& b = *ib; | ||
const size_t length = b.size(); | ||
for (size_t k = 0u; k < length; ++k) { | ||
const stk::mesh::Entity node = b[k]; | ||
const double* meanNormal = stk::mesh::field_data(meanNormalField, node); | ||
double* dqdx = stk::mesh::field_data(dqdxField, node); | ||
subtract_normal_component(nDim, meanNormal, dqdx); | ||
} | ||
} | ||
} | ||
|
||
//========================================================================== | ||
// Class Definition | ||
//========================================================================== | ||
// AssembleNodalGradPAlgorithmDriver - Drives nodal grad algorithms | ||
//========================================================================== | ||
//-------------------------------------------------------------------------- | ||
//-------- constructor ----------------------------------------------------- | ||
//-------------------------------------------------------------------------- | ||
AssembleNodalGradPAlgorithmDriver::AssembleNodalGradPAlgorithmDriver(Realm &realm) | ||
: AlgorithmDriver(realm) | ||
{ | ||
} | ||
|
||
//-------------------------------------------------------------------------- | ||
//-------- pre_work -------------------------------------------------------- | ||
//-------------------------------------------------------------------------- | ||
void | ||
AssembleNodalGradPAlgorithmDriver::pre_work() | ||
{ | ||
ThrowRequire(realm_.meta_data().get_field<VectorFieldType>(stk::topology::NODE_RANK, "dpdx") != nullptr); | ||
VectorFieldType& dpdxField = *realm_.meta_data().get_field<VectorFieldType>(stk::topology::NODE_RANK, "dpdx"); | ||
stk::mesh::field_fill(0.0, dpdxField); | ||
} | ||
|
||
//-------------------------------------------------------------------------- | ||
//-------- post_work ------------------------------------------------------- | ||
//-------------------------------------------------------------------------- | ||
void | ||
AssembleNodalGradPAlgorithmDriver::post_work() | ||
{ | ||
|
||
stk::mesh::BulkData & bulk_data = realm_.bulk_data(); | ||
stk::mesh::MetaData & meta_data = realm_.meta_data(); | ||
|
||
ThrowRequire(realm_.meta_data().get_field<VectorFieldType>(stk::topology::NODE_RANK, "dpdx") != nullptr); | ||
VectorFieldType& dpdxField = *realm_.meta_data().get_field<VectorFieldType>(stk::topology::NODE_RANK, "dpdx"); | ||
|
||
// extract fields | ||
stk::mesh::parallel_sum(bulk_data, {&dpdxField}); | ||
|
||
if ( realm_.hasPeriodic_) { | ||
const unsigned nDim = meta_data.spatial_dimension(); | ||
realm_.periodic_field_update(&dpdxField, nDim); | ||
} | ||
|
||
if ( realm_.hasOverset_ ) { | ||
// this is a tensor | ||
const unsigned nDim = meta_data.spatial_dimension(); | ||
realm_.overset_orphan_node_field_update(&dpdxField, 1, nDim); | ||
} | ||
|
||
if (realm_.solutionOptions_->explicitlyZeroOpenPressureGradient_) { | ||
subtract_normal_pressure_gradient(bulk_data, dpdxField); | ||
} | ||
|
||
} | ||
|
||
} // namespace nalu | ||
} // namespace Sierra |
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
Oops, something went wrong.