Skip to content

Commit 9ea7c93

Browse files
authored
Merge pull request #1190 from LLNL/feature/kweiss/shaping-with-device-mfem
quest's SamplingShaper can now be used when mfem is configured for devices
2 parents 9a25422 + 235a35b commit 9ea7c93

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

RELEASE-NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
3434

3535
### Fixed
3636
- quest's `SamplingShaper` now properly handles material names containing underscores
37+
- quest's `SamplingShaper` can now be used with an mfem that is configured for (GPU) devices
3738

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

src/axom/quest/detail/shaping/shaping_helpers.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ void replaceMaterial(mfem::QuadratureFunction* shapeQFunc,
3030
SLIC_ASSERT(materialQFunc->Size() == shapeQFunc->Size());
3131

3232
const int SZ = materialQFunc->Size();
33-
double* mData = materialQFunc->GetData();
34-
double* sData = shapeQFunc->GetData();
33+
double* mData = materialQFunc->HostReadWrite();
34+
double* sData = shapeQFunc->HostReadWrite();
3535

3636
if(shapeReplacesMaterial)
3737
{
@@ -61,8 +61,8 @@ void copyShapeIntoMaterial(const mfem::QuadratureFunction* shapeQFunc,
6161
SLIC_ASSERT(materialQFunc->Size() == shapeQFunc->Size());
6262

6363
const int SZ = materialQFunc->Size();
64-
double* mData = materialQFunc->GetData();
65-
const double* sData = shapeQFunc->GetData();
64+
double* mData = materialQFunc->HostReadWrite();
65+
const double* sData = shapeQFunc->HostRead();
6666

6767
// When reuseExisting, don't reset material values; otherwise, just copy values over
6868
if(reuseExisting)
@@ -114,9 +114,11 @@ void generatePositionsQFunction(mfem::Mesh* mesh,
114114
const int nq = ir.GetNPoints();
115115
const auto* geomFactors =
116116
mesh->GetGeometricFactors(ir, mfem::GeometricFactors::COORDINATES);
117+
geomFactors->X.HostRead();
117118

118119
mfem::QuadratureFunction* pos_coef = new mfem::QuadratureFunction(sp, dim);
119120
pos_coef->SetOwnsSpace(true);
121+
pos_coef->HostReadWrite();
120122

121123
// Rearrange positions into quadrature function
122124
{
@@ -186,6 +188,7 @@ void computeVolumeFractions(const std::string& matField,
186188
fes = new mfem::FiniteElementSpace(mesh, fec);
187189
volFrac = new mfem::GridFunction(fes);
188190
volFrac->MakeOwner(fec);
191+
volFrac->HostReadWrite();
189192

190193
dc->RegisterField(volFracName, volFrac);
191194
}
@@ -400,6 +403,7 @@ void computeVolumeFractionsIdentity(mfem::DataCollection* dc,
400403
mfem::FiniteElementSpace* fes = new mfem::FiniteElementSpace(mesh, fec);
401404
mfem::GridFunction* volFrac = new mfem::GridFunction(fes);
402405
volFrac->MakeOwner(fec);
406+
volFrac->HostReadWrite();
403407
dc->RegisterField(name, volFrac);
404408

405409
(*volFrac) = (*inout);

0 commit comments

Comments
 (0)