28 {
29
31
32 try {
33
34 PetscOptionsBegin(PETSC_COMM_WORLD, "", "Mesh cut options", "none");
35 CHKERR PetscOptionsInt(
"-edges_block_set",
"edges side set",
"",
37 CHKERR PetscOptionsInt(
"-vertex_block_set",
"vertex side set",
"",
39 CHKERR PetscOptionsBool(
"-output_vtk",
"if true outout vtk file",
"",
41 CHKERR PetscOptionsScalar(
"-quality_reduction_tol",
"",
42 "Tolerance of quality reduction",
tol, &
tol,
43 PETSC_NULLPTR);
44 CHKERR PetscOptionsScalar(
"-gamma_factor",
"",
46 PETSC_NULLPTR);
47 PetscOptionsEnd();
48
49
50 moab::Core moab_core;
51 moab::Interface &moab = moab_core;
52
55
57
58
59
61 Range edges, vertices, fixed_vertex;
62
63
64 {
65
67
69
70
71
74
77
78
80 1);
82 1);
83
86
87
92 true);
93
94 } else {
96 }
101 fixed_vertex, true);
102 }
103
104 CHKERR m_field.
get_moab().get_connectivity(edges, vertices,
true);
105
106
108
112 "LAMBDA_EDGE");
114 ->synchroniseFieldEntities("LAMBDA_EDGE");
116
119 "EDGE_SLIDING", "MESH_NODE_POSITIONS");
121 "EDGE_SLIDING", "MESH_NODE_POSITIONS");
123 "EDGE_SLIDING", "MESH_NODE_POSITIONS");
125 "LAMBDA_EDGE");
127 "LAMBDA_EDGE");
129 "LAMBDA_EDGE");
131 "EDGE_SLIDING");
133 }
134
140
141
142 if (!edges.empty()) {
151 "LAMBDA_SURFACE", verts, 0, 1);
153 CHKERR prb_mng->removeDofsOnEntities(
155 0, 3);
156 }
157 }
158 }
159
169 smoothing_cfg.
alpha = 1.0;
170 smoothing_cfg.
gamma = 0.0;
171
174 edges, smoothing_handles);
175
176 DM dm;
179
180 struct Solve {
181
186
187 auto hook = [&](SNES snes,
Vec x,
Vec F,
188 boost::shared_ptr<CacheTuple> cache_ptr,
191
194
196 auto post_proc_fe =
197 boost::make_shared<PostProcEleDomain>(*m_field_ptr);
198 auto &pip = post_proc_fe->getOpPtrVector();
199 auto X_ptr = boost::make_shared<MatrixDouble>();
201 "MESH_NODE_POSITIONS", X_ptr));
202 auto res_X_ptr = boost::make_shared<MatrixDouble>();
205 auto lambda_ptr = boost::make_shared<VectorDouble>();
206 pip.push_back(
208 auto res_lambda_ptr = boost::make_shared<VectorDouble>();
211
213 pip.push_back(
214
216
217 post_proc_fe->getPostProcMesh(),
218 post_proc_fe->getMapGaussPts(),
219
220 {{"LAMBDA_SURFACE", lambda_ptr},
221 {"RES_LAMBDA_SURFACE", res_lambda_ptr}},
222
223 {{"MESH_NODE_POSITIONS", X_ptr},
224
225 {"RES_MESH_NODE_POSITIONS", res_X_ptr}},
226
227 {},
228
229 {}
230
231 )
232
233 );
234
236 CHKERR post_proc_fe->writeFile(
"debug_smoothing.h5m");
238 };
239
241 snes_ctx_ptr->getRhsHook() = hook;
242
244
246 }
247
253 "MESH_NODE_POSITIONS", it)) {
254 if (it->get()->getEntType() != MBVERTEX)
255 continue;
257 for(
int dd = 0;
dd!=3;++
dd)
258 coords[dd] = it->get()->getEntFieldData()[
dd];
260 CHKERR m_field_ptr->
get_moab().set_coords(&ent, 1, &*coords.begin());
261 }
263 }
264
270 "MESH_NODE_POSITIONS", it)) {
271 if (it->get()->getEntType() != MBVERTEX)
272 continue;
275 CHKERR m_field_ptr->
get_moab().get_coords(&ent, 1, &*coords.begin());
276 for(
int dd = 0;
dd!=3;++
dd)
277 it->get()->getEntFieldData()[
dd] = coords[
dd];
278 }
280 }
281
282 };
283
286
287 double min_quality = 0;
289 dm, simple_interface->
getDomainFEName(), smoothing_handles, min_quality);
290 PetscPrintf(PETSC_COMM_WORLD, "Min quality = %4.3f\n", min_quality);
291
292 double gamma = min_quality > 0 ?
gamma_factor * min_quality
295
296 double min_quality_p,
eps;
297 do {
298
299 min_quality_p = min_quality;
300
302
306 min_quality);
307
308 eps = (min_quality - min_quality_p) / min_quality;
309 PetscPrintf(PETSC_COMM_WORLD, "Min quality = %4.3f eps = %4.3f\n",
311
312 double gamma = min_quality > 0 ?
gamma_factor * min_quality
315
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
339 "");
340 }
342
344}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PostProcEleByDim< SPACE_DIM >::PostProcEleDomain PostProcEleDomain
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
#define _IT_GET_ENT_FIELD_BY_NAME_FOR_LOOP_(MFIELD, NAME, IT)
loop over all dofs from a moFEM field and particular field
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_field)=0
set finite element field data
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
bool checkMeshset(const int ms_id, const CubitBCType cubit_bc_type) const
Check for CUBIT meshset by ID and type.
MoFEM::PipelineManager::ElementsAndOpsByDim< SPACE_DIM >::DomainEle Ele
const FTensor::Tensor2< T, Dim, Dim > Vec
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
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)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
VectorBoundedArray< double, 3 > VectorDouble3
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
static PetscErrorCode solve(Mat mat, Vec x, Vec y)
auto getInterfacePtr(DM dm)
Get the Interface Ptr object.
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
VolumeLengthQualityType qualityType
std::string geometryField
std::string lambdaEdgeField
std::string meshReferenceField
std::string lambdaSurfaceField
bool enableSurfaceSliding
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode add_field(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Interface for managing meshsets containing materials and boundary conditions.
Specialization for double precision scalar field values calculation.
Specialization for double precision vector field values calculation.
Post post-proc data at points from hash maps.
Template struct for dimension-specific finite element types.
Problem manager is used to build and partition problems.
Simple interface for fast problem set-up.
MoFEMErrorCode buildProblem()
Build problem.
MoFEMErrorCode addDomainField(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
const std::string getBoundaryFEName() const
Get the Boundary FE Name.
MoFEMErrorCode defineFiniteElements()
Define finite elements.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
MoFEMErrorCode buildFiniteElements()
Build finite elements.
MoFEMErrorCode addBoundaryField(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on boundary.
std::vector< std::string > & getOtherFiniteElements()
Get the Other Finite Elements.
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode getDM(DM *dm)
Get DM.
MoFEMErrorCode buildFields()
Build fields.
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode defineProblem(const PetscBool is_partitioned=PETSC_TRUE)
define problem
const std::string getProblemName() const
Get the Problem Name.
const std::string getDomainFEName() const
Get the Domain FE Name.
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
static MoFEMErrorCode extractMeshEdges(MoFEM::Interface &m_field, Range &output_edges, Range &output_vertices)