Skip to content

Commit

Permalink
Merge pull request #1175 from LLNL/feature/kweiss/shaping-c2c-and-stl
Browse files Browse the repository at this point in the history
Checks that we can use both `c2c` and `stl` in the same sample-based shaping deck
  • Loading branch information
kennyweiss committed Sep 14, 2023
2 parents e8ee083 + 0feb8c9 commit 80889b6
Show file tree
Hide file tree
Showing 4 changed files with 326 additions and 65 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
- `MarchingCubes::MarchingCubes`
- `MarchingCubesSingleDomain::MarchingCubesSingleDomain`

### Fixed
- quest's `SamplingShaper` now properly handles material names containing underscores

## [Version 0.8.1] - Release date 2023-08-16

### Changed
Expand Down
81 changes: 22 additions & 59 deletions src/axom/quest/SamplingShaper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,6 @@ class SamplingShaper : public Shaper

void applyReplacementRules(const klee::Shape& shape) override
{
using axom::utilities::string::rsplitN;

internal::ScopedLogLevelChanger logLevelChanger(
this->isVerbose() ? slic::message::Debug : slic::message::Warning);

Expand Down Expand Up @@ -513,7 +511,7 @@ class SamplingShaper : public Shaper
}

const bool shouldReplace = shape.replaces(otherMatName);
SLIC_DEBUG(axom::fmt::format(
SLIC_INFO(axom::fmt::format(
"Should we replace material '{}' with shape '{}' of material '{}'? {}",
otherMatName,
shapeName,
Expand Down Expand Up @@ -659,71 +657,36 @@ class SamplingShaper : public Shaper
/// This function is intended to help with debugging
void printRegisteredFieldNames(const std::string& initialMessage)
{
std::stringstream sstr;
sstr << "List of registered fields in the SamplingShaper " << initialMessage
<< std::endl;
{
std::vector<std::string> names;
for(auto kv : m_dc->GetFieldMap())
// helper lambda to extract the keys of a map<string,*> as a vector of strings
auto extractKeys = [](const auto& map) {
std::vector<std::string> keys;
for(const auto& kv : map)
{
names.push_back(kv.first);
keys.push_back(kv.first);
}
sstr << fmt::format("\t* Data collection grid funcs: {}",
fmt::join(names, ", "))
<< std::endl;
}
{
std::vector<std::string> names;
for(auto kv : m_dc->GetQFieldMap())
{
names.push_back(kv.first);
}
sstr << fmt::format("\t* Data collection qfuncs: {}",
fmt::join(names, ", "))
<< std::endl;
}
return keys;
};

{
std::vector<std::string> names;
for(auto name : m_knownMaterials)
{
names.push_back(name);
}
sstr << fmt::format("\t* Known materials: {}", fmt::join(names, ", "))
<< std::endl;
}
std::stringstream sstr;
sstr << "List of registered fields in the SamplingShaper " << initialMessage
<< fmt::format("\n\t* Data collection grid funcs: {}",
fmt::join(extractKeys(m_dc->GetFieldMap()), ", "))
<< fmt::format("\n\t* Data collection qfuncs: {}",
fmt::join(extractKeys(m_dc->GetQFieldMap()), ", "))
<< fmt::format("\n\t* Known materials: {}",
fmt::join(m_knownMaterials, ", "));

if(m_vfSampling == shaping::VolFracSampling::SAMPLE_AT_QPTS)
{
{
std::vector<std::string> names;
for(auto kv : m_inoutShapeQFuncs)
{
names.push_back(kv.first);
}
sstr << fmt::format("\t* Shape qfuncs: {}", fmt::join(names, ", "))
<< std::endl;
}
{
std::vector<std::string> names;
for(auto kv : m_inoutMaterialQFuncs)
{
names.push_back(kv.first);
}
sstr << fmt::format("\t* Mat qfuncs: {}", fmt::join(names, ", "))
<< std::endl;
}
sstr << fmt::format("\n\t* Shape qfuncs: {}",
fmt::join(extractKeys(m_inoutShapeQFuncs), ", "))
<< fmt::format("\n\t* Mat qfuncs: {}",
fmt::join(extractKeys(m_inoutMaterialQFuncs), ", "));
}
else if(m_vfSampling == shaping::VolFracSampling::SAMPLE_AT_DOFS)
{
std::vector<std::string> names;
for(auto kv : m_inoutDofs)
{
names.push_back(kv.first);
}
sstr << fmt::format("\t* Shape samples at DOFs: {}",
fmt::join(names, ", "))
<< std::endl;
sstr << fmt::format("\n\t* Shape samples at DOFs: {}",
fmt::join(extractKeys(m_inoutDofs), ", "));
}
SLIC_INFO(sstr.str());
}
Expand Down
5 changes: 2 additions & 3 deletions src/axom/quest/detail/shaping/shaping_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ void computeVolumeFractions(const std::string& matField,
QFunctionCollection& inoutQFuncs,
int outputOrder)
{
using axom::utilities::string::rsplitN;
SLIC_ASSERT(axom::utilities::string::startsWith(matField, "mat_inout_"));

auto matName = rsplitN(matField, 2, '_')[1];
auto volFracName = axom::fmt::format("vol_frac_{}", matName);
const auto volFracName = axom::fmt::format("vol_frac_{}", matField.substr(10));

// Grab a pointer to the inout samples QFunc
mfem::QuadratureFunction* inout = inoutQFuncs.Get(matField);
Expand Down

0 comments on commit 80889b6

Please sign in to comment.