Skip to content

Commit

Permalink
Added an element data criterion for mesh adaptors.
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMaas1978 committed Oct 25, 2024
1 parent 29c30d8 commit 9153978
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
2 changes: 2 additions & 0 deletions FEAMR/FEAMR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SOFTWARE.*/
#include "FEScaleAdaptorCriterion.h"
#include "FEFilterAdaptorCriterion.h"
#include "FEDomainErrorCriterion.h"
#include "FEElementDataCriterion.h"

//-----------------------------------------------------------------------------
void FEAMR::InitModule()
Expand All @@ -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");
}
53 changes: 53 additions & 0 deletions FEAMR/FEElementDataCriterion.cpp
Original file line number Diff line number Diff line change
@@ -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 <FECore/FECoreKernel.h>

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<FELogElemData>(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;
}
44 changes: 44 additions & 0 deletions FEAMR/FEElementDataCriterion.h
Original file line number Diff line number Diff line change
@@ -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 <FECore/FEMeshAdaptorCriterion.h>
#include <FECore/ElementDataRecord.h>

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();
};

0 comments on commit 9153978

Please sign in to comment.