From 915397839479f6abfe56534e4819d746ed8d127d Mon Sep 17 00:00:00 2001 From: SteveMaas1978 Date: Fri, 25 Oct 2024 07:11:28 -0600 Subject: [PATCH] Added an element data criterion for mesh adaptors. --- FEAMR/FEAMR.cpp | 2 ++ FEAMR/FEElementDataCriterion.cpp | 53 ++++++++++++++++++++++++++++++++ FEAMR/FEElementDataCriterion.h | 44 ++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 FEAMR/FEElementDataCriterion.cpp create mode 100644 FEAMR/FEElementDataCriterion.h diff --git a/FEAMR/FEAMR.cpp b/FEAMR/FEAMR.cpp index 442b8ed50..ee8649b12 100644 --- a/FEAMR/FEAMR.cpp +++ b/FEAMR/FEAMR.cpp @@ -37,6 +37,7 @@ SOFTWARE.*/ #include "FEScaleAdaptorCriterion.h" #include "FEFilterAdaptorCriterion.h" #include "FEDomainErrorCriterion.h" +#include "FEElementDataCriterion.h" //----------------------------------------------------------------------------- void FEAMR::InitModule() @@ -55,4 +56,5 @@ REGISTER_FECORE_CLASS(FEElementSelectionCriterion, "element_selection"); REGISTER_FECORE_CLASS(FEScaleAdaptorCriterion , "math"); REGISTER_FECORE_CLASS(FEMinMaxFilterAdaptorCriterion, "min-max filter"); REGISTER_FECORE_CLASS(FEDomainErrorCriterion, "relative error"); +REGISTER_FECORE_CLASS(FEElementDataCriterion, "element data"); } diff --git a/FEAMR/FEElementDataCriterion.cpp b/FEAMR/FEElementDataCriterion.cpp new file mode 100644 index 000000000..55aabc99b --- /dev/null +++ b/FEAMR/FEElementDataCriterion.cpp @@ -0,0 +1,53 @@ +/*This file is part of the FEBio source code and is licensed under the MIT license +listed below. + +See Copyright-FEBio.txt for details. + +Copyright (c) 2021 University of Utah, The Trustees of Columbia University in +the City of New York, and others. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.*/ +#include "FEElementDataCriterion.h" +#include + +BEGIN_FECORE_CLASS(FEElementDataCriterion, FEMeshAdaptorCriterion) + ADD_PARAMETER(m_data, "element_data"); +END_FECORE_CLASS(); + +FEElementDataCriterion::FEElementDataCriterion(FEModel* fem) : FEMeshAdaptorCriterion(fem) +{ + m_pd = nullptr; +} + +bool FEElementDataCriterion::Init() +{ + m_pd = fecore_new(m_data.c_str(), GetFEModel()); + if (m_pd == nullptr) return false; + return FEMeshAdaptorCriterion::Init(); +} + +bool FEElementDataCriterion::GetElementValue(FEElement& el, double& val) +{ + if (m_pd) + { + val = m_pd->value(el); + return true; + } + else return false; +} diff --git a/FEAMR/FEElementDataCriterion.h b/FEAMR/FEElementDataCriterion.h new file mode 100644 index 000000000..34db502a7 --- /dev/null +++ b/FEAMR/FEElementDataCriterion.h @@ -0,0 +1,44 @@ +/*This file is part of the FEBio source code and is licensed under the MIT license +listed below. + +See Copyright-FEBio.txt for details. + +Copyright (c) 2021 University of Utah, The Trustees of Columbia University in +the City of New York, and others. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.*/ +#pragma once +#include +#include + +class FEElementDataCriterion : public FEMeshAdaptorCriterion +{ +public: + FEElementDataCriterion(FEModel* fem); + + bool Init() override; + + bool GetElementValue(FEElement& el, double& val) override; + +private: + std::string m_data; + FELogElemData* m_pd; + + DECLARE_FECORE_CLASS(); +};