v0.14.0
NonlinearElasticElementInterface.hpp

Header file for NonlinearElasticElementInterface element implementation

/** \file NonlinearElasticElementInterface.hpp
* \example NonlinearElasticElementInterface.hpp
\brief Header file for NonlinearElasticElementInterface element implementation
*/
#ifndef __NONLINEARELEMENTINTERFACE_HPP__
#define __NONLINEARELEMENTINTERFACE_HPP__
/** \brief Set of functions declaring elements and setting operators
* for generic element interface
*/
SmartPetscObj<DM> dM;
PetscBool isQuasiStatic;
PetscInt oRder;
boost::shared_ptr<NonlinearElasticElement> elasticElementPtr;
boost::shared_ptr<ElasticMaterials> elasticMaterialsPtr;
boost::shared_ptr<PostProcVolumeOnRefinedMesh> postProcMeshPtr;
string positionField;
string meshNodeField;
string postion_field,
string mesh_posi_field_name = "MESH_NODE_POSITIONS",
bool is_displacement_field = true,
PetscBool is_quasi_static = PETSC_TRUE)
: mField(m_field), positionField(postion_field),
meshNodeField(mesh_posi_field_name),
isDisplacementField(is_displacement_field),
oRder = 1;
}
isQuasiStatic = PETSC_FALSE;
oRder = 2;
CHKERR PetscOptionsGetBool(PETSC_NULL, "-is_quasi_static", &isQuasiStatic,
PETSC_NULL);
CHKERR PetscOptionsGetInt(PETSC_NULL, "-order", &oRder, PETSC_NULL);
};
auto simple = mField.getInterface<Simple>();
3);
CHKERR simple->addBoundaryField(positionField, H1,
CHKERR simple->setFieldOrder(positionField, oRder);
}
3);
CHKERR simple->setFieldOrder(meshNodeField, 2);
}
};
elasticElementPtr = boost::make_shared<NonlinearElasticElement>(mField, 2);
elasticMaterialsPtr = boost::make_shared<ElasticMaterials>(mField, "HOOKE");
CHKERR elasticMaterialsPtr->setBlocks(elasticElementPtr->setOfBlocks);
false, false, false);
false, false, false);
true, false, false, false);
CHKERR elasticElementPtr->addElement("ELASTIC", positionField,
meshNodeField, false);
};
auto &pipeline_rhs = elasticElementPtr->feRhs.getOpPtrVector();
auto &pipeline_lhs = elasticElementPtr->feLhs.getOpPtrVector();
pipeline_rhs.push_back(new OpSetBc(positionField, true, mBoundaryMarker));
pipeline_lhs.push_back(new OpSetBc(positionField, true, mBoundaryMarker));
pipeline_rhs.push_back(new OpUnSetBc(positionField));
pipeline_lhs.push_back(new OpUnSetBc(positionField));
}
MoFEMErrorCode addElementsToDM(SmartPetscObj<DM> dm) {
this->dM = dm;
mField.getInterface<Simple>()->getOtherFiniteElements().push_back(
"ELASTIC");
};
dM, "ELASTIC", &elasticElementPtr->getLoopFeLhs(), NULL, NULL);
};
&elasticElementPtr->getLoopFeRhs(),
PETSC_NULL, PETSC_NULL);
};
auto &method = elasticElementPtr->getLoopFeLhs();
switch (type) {
case IM:
CHKERR DMMoFEMTSSetIJacobian(dM, "ELASTIC", &method, &method, &method);
break;
case IM2:
CHKERR DMMoFEMTSSetI2Jacobian(dM, "ELASTIC", &method, &method, &method);
break;
case EX:
CHKERR DMMoFEMTSSetRHSJacobian(dM, "ELASTIC", &method, &method, &method);
break;
default:
SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
"This TS is not yet implemented");
break;
}
};
auto &method = elasticElementPtr->getLoopFeRhs();
switch (type) {
case IM:
CHKERR DMMoFEMTSSetIFunction(dM, "ELASTIC", &method, &method, &method);
break;
case IM2:
CHKERR DMMoFEMTSSetI2Function(dM, "ELASTIC", &method, &method, &method);
break;
case EX:
CHKERR DMMoFEMTSSetRHSFunction(dM, "ELASTIC", &method, &method, &method);
break;
default:
SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not implemented");
break;
}
};
if (elasticElementPtr->setOfBlocks.empty())
postProcMeshPtr = boost::make_shared<PostProcVolumeOnRefinedMesh>(mField);
if (mField.check_field("MESH_NODE_POSITIONS"))
CHKERR addHOOpsVol("MESH_NODE_POSITIONS", *postProcMeshPtr, true, false,
false, false);
CHKERR postProcMeshPtr->generateReferenceElementMesh();
CHKERR postProcMeshPtr->addFieldValuesPostProc(positionField);
CHKERR postProcMeshPtr->addFieldValuesPostProc(meshNodeField);
CHKERR postProcMeshPtr->addFieldValuesGradientPostProc(positionField);
for (auto &sit : elasticElementPtr->setOfBlocks) {
postProcMeshPtr->getOpPtrVector().push_back(new PostProcStress(
postProcMeshPtr->postProcMesh, postProcMeshPtr->mapGaussPts,
positionField, sit.second, postProcMeshPtr->commonData,
}
}
elasticElementPtr->getLoopFeEnergy().snes_ctx = SnesMethod::CTX_SNESNONE;
elasticElementPtr->getLoopFeEnergy().eNergy = 0;
// MOFEM_LOG("WORLD", Sev::inform) << "Loop energy\n";
&elasticElementPtr->getLoopFeEnergy());
auto E = elasticElementPtr->getLoopFeEnergy().eNergy;
// Print elastic energy
MOFEM_LOG_C("WORLD", Sev::inform, "%d Time %3.2e Elastic energy %3.2e",
step, elasticElementPtr->getLoopFeRhs().ts_t, E);
auto out_name = "out_vol_" + to_string(step) + ".h5m";
CHKERR postProcMeshPtr->writeFile(out_name);
};
};
#endif //__NONLINEARELEMENTINTERFACE_HPP__
GenericElementInterface::EX
@ EX
Definition: GenericElementInterface.hpp:16
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Definition: UnknownInterface.hpp:93
H1
@ H1
continuous field
Definition: definitions.h:85
NonlinearElasticElementInterface::isDisplacementField
bool isDisplacementField
Definition: NonlinearElasticElementInterface.hpp:22
NonlinearElasticElementInterface::elasticMaterialsPtr
boost::shared_ptr< ElasticMaterials > elasticMaterialsPtr
Definition: NonlinearElasticElementInterface.hpp:25
MoFEM::addHOOpsVol
MoFEMErrorCode addHOOpsVol(const std::string field, E &e, bool h1, bool hcurl, bool hdiv, bool l2)
Definition: HODataOperators.hpp:764
NonlinearElasticElementInterface::bIt
BitRefLevel bIt
Definition: NonlinearElasticElementInterface.hpp:23
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
E
MoFEM::DMMoFEMTSSetRHSJacobian
PetscErrorCode DMMoFEMTSSetRHSJacobian(DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS the right hand side jacobian
Definition: DMMoFEM.cpp:926
NonlinearElasticElementInterface::setupSolverJacobianTS
MoFEMErrorCode setupSolverJacobianTS(const TSType type)
Definition: NonlinearElasticElementInterface.hpp:138
NonlinearElasticElementInterface::dM
SmartPetscObj< DM > dM
Definition: NonlinearElasticElementInterface.hpp:18
NonlinearElasticElementInterface::oRder
PetscInt oRder
Definition: NonlinearElasticElementInterface.hpp:21
MoFEM::DMMoFEMAddElement
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition: DMMoFEM.cpp:501
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
NonlinearElasticElementInterface::~NonlinearElasticElementInterface
~NonlinearElasticElementInterface()
Definition: NonlinearElasticElementInterface.hpp:43
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
NonlinearElasticElementInterface::mField
MoFEM::Interface & mField
Definition: NonlinearElasticElementInterface.hpp:17
PostProcStress
Definition: PostProcStresses.hpp:17
GenericElementInterface
Set of functions declaring elements and setting operators for generic element interface.
Definition: GenericElementInterface.hpp:13
MoFEM::DMMoFEMTSSetIJacobian
PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS Jacobian evaluation function
Definition: DMMoFEM.cpp:857
NonlinearElasticElementInterface::postProcessElement
MoFEMErrorCode postProcessElement(int step)
Definition: NonlinearElasticElementInterface.hpp:181
NonlinearElasticElementInterface::addElementsToDM
MoFEMErrorCode addElementsToDM(SmartPetscObj< DM > dm)
Definition: NonlinearElasticElementInterface.hpp:112
NonlinearElasticElementInterface::createElements
MoFEMErrorCode createElements()
Definition: NonlinearElasticElementInterface.hpp:75
NonlinearElasticElementInterface::meshNodeField
string meshNodeField
Definition: NonlinearElasticElementInterface.hpp:29
MoFEM::DMMoFEMTSSetI2Jacobian
PetscErrorCode DMMoFEMTSSetI2Jacobian(DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS Jacobian evaluation function
Definition: DMMoFEM.cpp:1021
MOFEM_LOG_C
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
MoFEM::DMMoFEMTSSetI2Function
PetscErrorCode DMMoFEMTSSetI2Function(DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS implicit function evaluation function
Definition: DMMoFEM.cpp:979
is_quasi_static
PetscBool is_quasi_static
Definition: plastic.cpp:190
simple
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
convert.type
type
Definition: convert.py:64
NonlinearElasticElementInterface::getCommandLineParameters
MoFEMErrorCode getCommandLineParameters()
Definition: NonlinearElasticElementInterface.hpp:45
NonlinearElasticElementInterface::elasticElementPtr
boost::shared_ptr< NonlinearElasticElement > elasticElementPtr
Definition: NonlinearElasticElementInterface.hpp:24
NonlinearElasticElementInterface::setupSolverJacobianSNES
MoFEMErrorCode setupSolverJacobianSNES()
Definition: NonlinearElasticElementInterface.hpp:122
MoFEM::DMMoFEMSNESSetJacobian
PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES Jacobian evaluation function
Definition: DMMoFEM.cpp:763
MoFEM::CoreInterface::check_field
virtual bool check_field(const std::string &name) const =0
check if field is in database
NonlinearElasticElementInterface::getBitRefLevel
BitRefLevel getBitRefLevel()
Definition: NonlinearElasticElementInterface.hpp:111
NonlinearElasticElementInterface::setupSolverFunctionSNES
MoFEMErrorCode setupSolverFunctionSNES()
Definition: NonlinearElasticElementInterface.hpp:130
GenericElementInterface::mBoundaryMarker
BcMarkerPtr mBoundaryMarker
Definition: GenericElementInterface.hpp:20
NonlinearElasticElementInterface::NonlinearElasticElementInterface
NonlinearElasticElementInterface(MoFEM::Interface &m_field, string postion_field, string mesh_posi_field_name="MESH_NODE_POSITIONS", bool is_displacement_field=true, PetscBool is_quasi_static=PETSC_TRUE)
Definition: NonlinearElasticElementInterface.hpp:31
NonlinearElasticElementInterface::setOperators
MoFEMErrorCode setOperators()
Definition: NonlinearElasticElementInterface.hpp:95
NonlinearElasticElementInterface::updateElementVariables
MoFEMErrorCode updateElementVariables()
Definition: NonlinearElasticElementInterface.hpp:180
MoFEM::DMMoFEMTSSetRHSFunction
PetscErrorCode DMMoFEMTSSetRHSFunction(DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS the right hand side function
Definition: DMMoFEM.cpp:886
NonlinearElasticElementInterface::positionField
string positionField
Definition: NonlinearElasticElementInterface.hpp:28
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
MoFEM::DMMoFEMTSSetIFunction
PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set TS implicit function evaluation function
Definition: DMMoFEM.cpp:804
GenericElementInterface::TSType
TSType
Definition: GenericElementInterface.hpp:16
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
MoFEM::DMoFEMLoopFiniteElements
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMoFEM.cpp:590
NonlinearElasticElementInterface
Set of functions declaring elements and setting operators for generic element interface.
Definition: NonlinearElasticElementInterface.hpp:15
MoFEM::PetscOptionsGetInt
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
Definition: DeprecatedPetsc.hpp:142
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
NonlinearElasticElementInterface::setupSolverFunctionTS
MoFEMErrorCode setupSolverFunctionTS(const TSType type)
Definition: NonlinearElasticElementInterface.hpp:159
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
NonlinearElasticElementInterface::addElementFields
MoFEMErrorCode addElementFields()
Definition: NonlinearElasticElementInterface.hpp:56
GenericElementInterface::IM2
@ IM2
Definition: GenericElementInterface.hpp:16
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
NonlinearElasticElementInterface::isQuasiStatic
PetscBool isQuasiStatic
Definition: NonlinearElasticElementInterface.hpp:19
NonlinearElasticElementInterface::postProcMeshPtr
boost::shared_ptr< PostProcVolumeOnRefinedMesh > postProcMeshPtr
Definition: NonlinearElasticElementInterface.hpp:26
MoFEM::DMMoFEMSNESSetFunction
PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES residual evaluation function
Definition: DMMoFEM.cpp:722
GenericElementInterface::IM
@ IM
Definition: GenericElementInterface.hpp:16
MoFEM::PetscOptionsGetBool
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
Definition: DeprecatedPetsc.hpp:182