Skip to content

Commit 1a46125

Browse files
committed
spr: return error, add doc string
1 parent 0f14e36 commit 1a46125

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/MeshField_SPR_ErrorEstimator.hpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,37 @@ averageToVertex(Omega_h::Mesh &mesh,
227227
return sizeField;
228228
}
229229

230+
231+
/**
232+
* @brief Computes the SPR (Superconvergent Patch Recovery) size field for mesh adaptation
233+
*
234+
* This function performs error estimation using the SPR method and computes desired element
235+
* sizes based on the error between the original field and the recovered field. The resulting
236+
* size field can be used to guide adaptive mesh refinement.
237+
*
238+
* @tparam EstimationT The estimation type containing mesh, fields, tolerance, and other parameters
239+
* @tparam OmegahMeshField The Omega_h mesh field type for field evaluation
240+
* @tparam FieldElement The field element type for coordinate field operations
241+
*
242+
* @param e (In) The estimation object containing the mesh, input field (eps), recovered field (eps_star),
243+
* tolerance, and storage for intermediate results
244+
* @param omf (In) The Omega_h mesh field object used for evaluating fields at integration points
245+
* @param coordFe (In) The coordinate field element used for integration over mesh elements
246+
*
247+
* @return A tuple containing:
248+
* - Kokkos::View<MeshField::Real *>: The vertex-averaged size field indicating desired
249+
* element sizes at mesh vertices
250+
* - MeshField::Real: The sum of error norms raised to the power (2d/(2p+d)) over all elements,
251+
* where d is the mesh dimension and p is the recovered field polynomial order
252+
*/
230253
template <typename EstimationT, typename OmegahMeshField, typename FieldElement>
231-
Kokkos::View<MeshField::Real *>
254+
std::tuple< Kokkos::View<MeshField::Real *>, MeshField::Real >
232255
getSprSizeField(EstimationT &e, OmegahMeshField &omf, FieldElement &coordFe) {
233256
Error errorIntegrator(e, omf);
234257
errorIntegrator.process(coordFe);
235-
std::cout << "Error: " << errorIntegrator.r << "\n";
236258
computeSizeFactor(e, omf, coordFe, errorIntegrator);
237259
getElementSizeField(e, errorIntegrator);
238-
return averageToVertex(e.mesh, e.element_size);
260+
return {averageToVertex(e.mesh, e.element_size), errorIntegrator.r};
239261
}
240262

241263
} // end namespace SPR

test/testSprThwaitesAdapt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ int main(int argc, char **argv) {
195195
auto estimation = MeshField::SPR::Estimation(
196196
mesh, effectiveStrain, recoveredStrainField, adaptRatio);
197197

198-
const auto tgtLength =
198+
const auto [tgtLength, error] =
199199
MeshField::SPR::getSprSizeField(estimation, omf, coordFe);
200+
std::cout << "Error: " << error << '\n';
200201
Omega_h::Write<MeshField::Real> tgtLength_oh(tgtLength);
201202
mesh.add_tag<Real>(VERT, "tgtLength", 1, tgtLength_oh, false,
202203
Omega_h::ArrayType::VectorND);

0 commit comments

Comments
 (0)