1#ifndef __MESH_SMOOTHING_OP_FACTORY_HPP__
2#define __MESH_SMOOTHING_OP_FACTORY_HPP__
5#error "MoFEM need to be compiled with ADOL-C"
47 boost::shared_ptr<SurfaceSlidingConstrains::DriverElementOrientation>
50 boost::shared_ptr<MoFEM::VolumeElementForcesAndSourcesCore>
minQualityFe;
59 double *min_quality_ptr)
64 MoFEMErrorCode
doWork(
int, EntityType type, EntitiesFieldData::EntData &data) {
76 const Range &fixed_vertices,
77 const Range &edge_entities,
85 handles.
feSmootherRhs = boost::make_shared<DomainEle>(m_field);
86 handles.
feSmootherLhs = boost::make_shared<DomainEle>(m_field);
101 template opRhsFactory<PETSC, GAUSS, DomainEleOp>(
107 template opLhsFactory<PETSC, GAUSS, DomainEleOp>(
111 boost::make_shared<MoFEM::VolumeElementForcesAndSourcesCore>(m_field);
113 boost::make_shared<double>(std::numeric_limits<double>::max());
118 if (!fixed_vertices.empty()) {
119 auto *prb_mng = m_field.
getInterface<ProblemsManager>();
122 CHKERR prb_mng->removeDofsOnEntities(
simple->getProblemName(),
127 CHKERR prb_mng->removeDofsOnEntities(
simple->getProblemName(),
134 CHKERR prb_mng->removeDofsOnEntities(
simple->getProblemName(),
156 CHKERR skin.find_skin(0, tets,
false, skin_faces);
157 if (skin_faces.empty()) {
159 "No skin faces found for edge constrains");
161 handles.
edgeConstraint = boost::make_shared<EdgeSlidingConstrains>(m_field);
173 boost::shared_ptr<ForcesAndSourcesCore> null;
181 CHKERR DMMoFEMSNESSetFunction(dm,
"SURFACE_SLIDING",
184 CHKERR DMMoFEMSNESSetJacobian(dm,
"SURFACE_SLIDING",
190 CHKERR DMMoFEMSNESSetFunction(dm,
"EDGE_SLIDING",
192 CHKERR DMMoFEMSNESSetJacobian(dm,
"EDGE_SLIDING",
200 const std::string &domain_fe_name,
202 double &min_quality) {
207 "Min quality operators are not initialised");
211 CHKERR DMoFEMLoopFiniteElements(dm, domain_fe_name.c_str(),
215 CHKERR DMoFEMGetInterfacePtr(dm, &m_field_ptr);
217 CHKERR MPI_Allreduce(&local_min, &min_quality, 1, MPI_DOUBLE, MPI_MIN,
225 char gamma_value[64];
226 CHKERR PetscSNPrintf(gamma_value,
sizeof(gamma_value),
"%.17g", gamma);
227 CHKERR PetscOptionsSetValue(NULL,
"-volume_length_gamma", gamma_value);
233inline MoFEMErrorCode
createSnes(DM dm, SmartPetscObj<SNES> &snes) {
236 CHKERR DMoFEMGetInterfacePtr(dm, &m_field_ptr);
237 snes = createSNES(m_field_ptr->
get_comm());
238 CHKERR SNESSetFromOptions(snes);
239 CHKERR SNESSetDM(snes, dm);
246 const std::vector<std::string> &zero_vertex_fields = {}) {
248 if (!zero_vertex_fields.empty()) {
250 CHKERR DMoFEMGetInterfacePtr(dm, &m_field_ptr);
251 auto field_blas = m_field_ptr->
getInterface<FieldBlas>();
252 for (
const auto &
field_name : zero_vertex_fields) {
260 CHKERR SNESSolve(snes, f, d);
ForcesAndSourcesCore::UserDataOperator UserDataOperator
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set ghosted vector values on all existing mesh entities
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
virtual bool check_field(const std::string &name) const =0
check if field is in database
boost::shared_ptr< ADolCData > createADolCDataPtr()
boost::shared_ptr< PhysicalEquations > createAdolCPhysicalEquationsPtr(boost::shared_ptr< ADolCData > adolc_data_ptr, int tag)
MoFEMErrorCode updateBarrierGamma(Handles &handles, double gamma)
MoFEMErrorCode evaluateMinQuality(DM dm, const std::string &domain_fe_name, const Handles &handles, double &min_quality)
MoFEMErrorCode createSnes(DM dm, SmartPetscObj< SNES > &snes)
MoFEMErrorCode solveSnes(DM dm, SNES snes, const std::vector< std::string > &zero_vertex_fields={})
MoFEMErrorCode createOperators(MoFEM::Interface &m_field, const Config &cfg, const Range &fixed_vertices, const Range &edge_entities, Handles &handles)
MoFEMErrorCode addToSnesDM(DM dm, const Config &cfg, const Handles &handles)
implementation of Data Operators for Forces and Sources
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
constexpr auto field_name
AdolCOps::VolumeLengthQualityType qualityType
std::string geometryField
std::string lambdaEdgeField
std::string meshReferenceField
std::string lambdaSurfaceField
bool enableSurfaceSliding
boost::shared_ptr< double > minQualityValue
boost::shared_ptr< ForcesAndSourcesCore > feSmootherLhs
boost::shared_ptr< AdolCOps::PhysicalEquations > volQualityPhysicalPtr
boost::shared_ptr< EdgeSlidingConstrains > edgeConstraint
boost::shared_ptr< MoFEM::VolumeElementForcesAndSourcesCore > minQualityFe
boost::shared_ptr< SurfaceSlidingConstrains > surfaceConstraint
MoFEM::Interface * m_field_ptr
boost::shared_ptr< ForcesAndSourcesCore > feSmootherRhs
boost::shared_ptr< SurfaceSlidingConstrains::DriverElementOrientation > surfaceOrientation
MinQualityOp(const std::string &field_name, double *min_quality_ptr)
MoFEMErrorCode doWork(int, EntityType type, EntitiesFieldData::EntData &data)
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Deprecated interface functions.
@ OPROW
operator doWork function is executed on FE rows
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Volume finite element base.
Class implemented by user to detect face orientation.
Shape preserving constrains, i.e. nodes sliding on body surface.
Implementing surface sliding constrains.