v0.14.0
nonlinear_poisson_2d.cpp
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <MoFEM.hpp>
4 
5 using namespace MoFEM;
6 using namespace NonlinearPoissonOps;
7 
8 constexpr int SPACE_DIM = 2;
9 static char help[] = "...\n\n";
10 
11 inline double sqr(const double x) { return x * x; }
12 
13 inline double cube(const double x) { return x * x * x; }
14 
16 public:
18 
19  // Declaration of the main function to run analysis
20  MoFEMErrorCode runProgram();
21 
22 private:
23  // Declaration of other main functions called in runProgram()
24  MoFEMErrorCode readMesh();
25  MoFEMErrorCode setupProblem();
26  MoFEMErrorCode setIntegrationRules();
27  MoFEMErrorCode boundaryCondition();
28  MoFEMErrorCode assembleSystem();
29  MoFEMErrorCode solveSystem();
30  MoFEMErrorCode outputResults();
31  MoFEMErrorCode checkResults();
32 
33  // Function to calculate the Source term
34  static double sourceTermFunction(const double x, const double y,
35  const double z) {
36 
37  return 2 * M_PI * M_PI *
38  (cos(M_PI * x) * cos(M_PI * y) +
39  cube(cos(M_PI * x)) * cube(cos(M_PI * y)) -
40  cos(M_PI * x) * cos(M_PI * y) *
41  (sqr(sin(M_PI * x)) * sqr(cos(M_PI * y)) +
42  sqr(sin(M_PI * y)) * sqr(cos(M_PI * x))));
43  }
44 
45  // Function to calculate the Boundary term
46  static double boundaryFunction(const double x, const double y,
47  const double z) {
48  return -cos(M_PI * x) *
49  cos(M_PI * y); // here should put the negative of the proper formula
50  }
51 
52  // Main interfaces
55 
56  // Field name and approximation order
57  std::string domainField = "POTENTIAL";
58  int order;
59 
60  // PETSc vector for storing norms
62  int atomTest = 0;
63  enum NORMS { NORM = 0, LAST_NORM };
64  enum EX_NORMS { EX_NORM = 0, LAST_EX_NORM };
65 
66  // Object to mark boundary entities for the assembling of domain elements
67  boost::shared_ptr<std::vector<unsigned char>> boundaryMarker;
68 
70 
71  // Object needed for postprocessing
72  boost::shared_ptr<PostProcEle> postProc;
73 
74  // Boundary entities marked for fieldsplit (block) solver - optional
76 };
77 
79  : mField(m_field) {}
80 
83 
84  CHKERR readMesh();
92 
94 }
95 
98 
102 
104 }
105 
108 
109  Range domain_ents;
110  CHKERR mField.get_moab().get_entities_by_dimension(0, SPACE_DIM, domain_ents,
111  true);
112  auto get_ents_by_dim = [&](const auto dim) {
113  if (dim == SPACE_DIM) {
114  return domain_ents;
115  } else {
116  Range ents;
117  if (dim == 0)
118  CHKERR mField.get_moab().get_connectivity(domain_ents, ents, true);
119  else
120  CHKERR mField.get_moab().get_entities_by_dimension(0, dim, ents, true);
121  return ents;
122  }
123  };
124  // Select base
125  auto get_base = [&]() {
126  auto domain_ents = get_ents_by_dim(SPACE_DIM);
127  if (domain_ents.empty())
128  CHK_THROW_MESSAGE(MOFEM_NOT_FOUND, "Empty mesh");
129  const auto type = type_from_handle(domain_ents[0]);
130  switch (type) {
131  case MBQUAD:
132  return DEMKOWICZ_JACOBI_BASE;
133  case MBHEX:
134  return DEMKOWICZ_JACOBI_BASE;
135  case MBTRI:
137  case MBTET:
139  default:
140  CHK_THROW_MESSAGE(MOFEM_NOT_FOUND, "Element type not handled");
141  }
142  return NOBASE;
143  };
144  auto base = get_base();
147 
148  order = 2;
149 
150  CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-order", &order, PETSC_NULL);
151  CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-atom_test", &atomTest,
152  PETSC_NULL);
154 
156 
158 }
159 
162 
163  auto domain_rule_lhs = [](int, int, int p) -> int { return 2 * p - 1; };
164  auto domain_rule_rhs = [](int, int, int p) -> int { return 2 * p - 1; };
165 
166  auto boundary_rule_lhs = [](int, int, int p) -> int { return 2 * p; };
167  auto boundary_rule_rhs = [](int, int, int p) -> int { return 2 * p; };
168 
169  auto pipeline_mng = mField.getInterface<PipelineManager>();
170  CHKERR pipeline_mng->setDomainRhsIntegrationRule(domain_rule_lhs);
171  CHKERR pipeline_mng->setDomainLhsIntegrationRule(domain_rule_rhs);
172  CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(boundary_rule_lhs);
173  CHKERR pipeline_mng->setBoundaryRhsIntegrationRule(boundary_rule_rhs);
174 
176 }
177 
180 
181  // Get boundary edges marked in block named "BOUNDARY_CONDITION"
182  auto get_ents_on_mesh_skin = [&]() {
183  Range boundary_entities;
185  std::string entity_name = it->getName();
186  if (entity_name.compare(0, 18, "BOUNDARY_CONDITION") == 0) {
187  CHKERR it->getMeshsetIdEntitiesByDimension(mField.get_moab(), 1,
188  boundary_entities, true);
189  }
190  }
191  // Add vertices to boundary entities
192  Range boundary_vertices;
193  CHKERR mField.get_moab().get_connectivity(boundary_entities,
194  boundary_vertices, true);
195  boundary_entities.merge(boundary_vertices);
196 
197  // Store entities for fieldsplit (block) solver
198  boundaryEntitiesForFieldsplit = boundary_entities;
199 
200  return boundary_entities;
201  };
202 
203  auto mark_boundary_dofs = [&](Range &&skin_edges) {
204  auto problem_manager = mField.getInterface<ProblemsManager>();
205  auto marker_ptr = boost::make_shared<std::vector<unsigned char>>();
206  problem_manager->markDofs(simpleInterface->getProblemName(), ROW,
207  ProblemsManager::OR, skin_edges, *marker_ptr);
208  return marker_ptr;
209  };
210 
211  // Get global local vector of marked DOFs. Is global, since is set for all
212  // DOFs on processor. Is local since only DOFs on processor are in the
213  // vector. To access DOFs use local indices.
214  boundaryMarker = mark_boundary_dofs(get_ents_on_mesh_skin());
215 
217 }
218 
221 
222  auto pipeline_mng = mField.getInterface<PipelineManager>();
223  CHKERR AddHOOps<2, 2, 2>::add(pipeline_mng->getOpDomainLhsPipeline(), {H1});
224  CHKERR AddHOOps<2, 2, 2>::add(pipeline_mng->getOpDomainRhsPipeline(), {H1});
225 
226  auto add_domain_lhs_ops = [&](auto &pipeline) {
227  pipeline.push_back(new OpSetBc(domainField, true, boundaryMarker));
228  auto data_u_at_gauss_pts = boost::make_shared<VectorDouble>();
229  auto grad_u_at_gauss_pts = boost::make_shared<MatrixDouble>();
230  pipeline.push_back(
231  new OpCalculateScalarFieldValues(domainField, data_u_at_gauss_pts));
232  pipeline.push_back(new OpCalculateScalarFieldGradient<2>(
233  domainField, grad_u_at_gauss_pts));
234  pipeline.push_back(new OpDomainLhs(
235  domainField, domainField, data_u_at_gauss_pts, grad_u_at_gauss_pts));
236  pipeline.push_back(new OpUnSetBc(domainField));
237  };
238 
239  auto add_domain_rhs_ops = [&](auto &pipeline) {
240  pipeline.push_back(new OpSetBc(domainField, true, boundaryMarker));
241  auto data_u_at_gauss_pts = boost::make_shared<VectorDouble>();
242  auto grad_u_at_gauss_pts = boost::make_shared<MatrixDouble>();
243  pipeline.push_back(
244  new OpCalculateScalarFieldValues(domainField, data_u_at_gauss_pts));
245  pipeline.push_back(new OpCalculateScalarFieldGradient<2>(
246  domainField, grad_u_at_gauss_pts));
247  pipeline.push_back(new OpDomainRhs(domainField, sourceTermFunction,
248  data_u_at_gauss_pts,
249  grad_u_at_gauss_pts));
250  pipeline.push_back(new OpUnSetBc(domainField));
251  };
252 
253  auto add_boundary_lhs_ops = [&](auto &pipeline) {
254  pipeline.push_back(new OpSetBc(domainField, false, boundaryMarker));
255  pipeline.push_back(new OpBoundaryLhs(
257  [](const double, const double, const double) { return 1; }));
258  pipeline.push_back(new OpUnSetBc(domainField));
259  };
260 
261  auto add_boundary_rhs_ops = [&](auto &pipeline) {
262  pipeline.push_back(new OpSetBc(domainField, false, boundaryMarker));
263  auto u_at_gauss_pts = boost::make_shared<VectorDouble>();
264  pipeline.push_back(
265  new OpCalculateScalarFieldValues(domainField, u_at_gauss_pts));
266  pipeline.push_back(new OpBoundaryRhs(
267  domainField, u_at_gauss_pts,
268  [](const double, const double, const double) { return 1; }));
269  pipeline.push_back(new OpBoundaryRhsSource(domainField, boundaryFunction));
270  pipeline.push_back(new OpUnSetBc(domainField));
271  };
272 
273  add_domain_lhs_ops(pipeline_mng->getOpDomainLhsPipeline());
274  add_domain_rhs_ops(pipeline_mng->getOpDomainRhsPipeline());
275 
276  add_boundary_lhs_ops(pipeline_mng->getOpBoundaryLhsPipeline());
277  add_boundary_rhs_ops(pipeline_mng->getOpBoundaryRhsPipeline());
278 
280 }
281 
284 
285  auto *simple = mField.getInterface<Simple>();
286 
287  auto set_fieldsplit_preconditioner = [&](auto snes) {
289  KSP ksp;
290  CHKERR SNESGetKSP(snes, &ksp);
291  PC pc;
292  CHKERR KSPGetPC(ksp, &pc);
293  PetscBool is_pcfs = PETSC_FALSE;
294  PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
295 
296  // Set up FIELDSPLIT, only when option used -pc_type fieldsplit
297  if (is_pcfs == PETSC_TRUE) {
298  auto name_prb = simple->getProblemName();
299  SmartPetscObj<IS> is_all_bc;
300  CHKERR mField.getInterface<ISManager>()->isCreateProblemFieldAndRank(
301  name_prb, ROW, domainField, 0, 1, is_all_bc,
303  int is_all_bc_size;
304  CHKERR ISGetSize(is_all_bc, &is_all_bc_size);
305  MOFEM_LOG("EXAMPLE", Sev::inform)
306  << "Field split block size " << is_all_bc_size;
307  CHKERR PCFieldSplitSetIS(pc, PETSC_NULL,
308  is_all_bc); // boundary block
309  }
311  };
312 
313  // Create global RHS and solution vectors
314  auto dm = simple->getDM();
315  SmartPetscObj<Vec> global_rhs, global_solution;
316  CHKERR DMCreateGlobalVector_MoFEM(dm, global_rhs);
317  global_solution = vectorDuplicate(global_rhs);
318 
319  // Create nonlinear solver (SNES)
320  auto pipeline_mng = mField.getInterface<PipelineManager>();
321  auto solver = pipeline_mng->createSNES();
322  CHKERR SNESSetFromOptions(solver);
323  CHKERR set_fieldsplit_preconditioner(solver);
324  CHKERR SNESSetUp(solver);
325 
326  // Solve the system
327  CHKERR SNESSolve(solver, global_rhs, global_solution);
328 
329  // Scatter result data on the mesh
330  CHKERR DMoFEMMeshToGlobalVector(dm, global_solution, INSERT_VALUES,
331  SCATTER_REVERSE);
332 
334 }
335 
338 
339  auto post_proc = boost::make_shared<PostProcEle>(mField);
340 
341  auto u_ptr = boost::make_shared<VectorDouble>();
342  post_proc->getOpPtrVector().push_back(
344 
346 
347  post_proc->getOpPtrVector().push_back(
348 
349  new OpPPMap(post_proc->getPostProcMesh(), post_proc->getMapGaussPts(),
350 
351  {{domainField, u_ptr}},
352 
353  {}, {}, {}
354 
355  )
356 
357  );
358 
359  auto *simple = mField.getInterface<Simple>();
360  auto dm = simple->getDM();
361  CHKERR DMoFEMLoopFiniteElements(dm, simple->getDomainFEName(), post_proc);
362 
363  CHKERR post_proc->writeFile("out_result.h5m");
364 
366 }
367 
368 //! [Check]
371  auto check_result_fe_ptr = boost::make_shared<DomainEle>(mField);
372  auto errorVec =
374  (mField.get_comm_rank() == 0) ? LAST_NORM : 0, LAST_NORM);
375  auto exactVec = createVectorMPI(
376  mField.get_comm(), (mField.get_comm_rank() == 0) ? LAST_EX_NORM : 0,
377  LAST_EX_NORM);
379  check_result_fe_ptr->getOpPtrVector(), {H1})),
380  "Apply transform");
381  check_result_fe_ptr->getRuleHook = [](int, int, int p) { return p; };
382  auto analyticalFunction = [&](double x, double y, double z) {
383  return cos(M_PI * x) * cos(M_PI * y);
384  };
385  auto u_ptr = boost::make_shared<VectorDouble>();
386  check_result_fe_ptr->getOpPtrVector().push_back(
388  auto mValFuncPtr = boost::make_shared<VectorDouble>();
389  check_result_fe_ptr->getOpPtrVector().push_back(
390  new OpGetTensor0fromFunc(mValFuncPtr, analyticalFunction));
391  check_result_fe_ptr->getOpPtrVector().push_back(
392  new OpCalcNormL2Tensor0(u_ptr, errorVec, NORM, mValFuncPtr));
393  check_result_fe_ptr->getOpPtrVector().push_back(
394  new OpCalcNormL2Tensor0(u_ptr, exactVec, EX_NORM));
395  CHKERR VecZeroEntries(errorVec);
396  CHKERR VecZeroEntries(exactVec);
399  check_result_fe_ptr);
400  CHKERR VecAssemblyBegin(errorVec);
401  CHKERR VecAssemblyEnd(errorVec);
402  CHKERR VecAssemblyBegin(exactVec);
403  CHKERR VecAssemblyEnd(exactVec);
404  MOFEM_LOG_CHANNEL("SELF"); // Clear channel from old tags
405  // print norm in general log
406  if (mField.get_comm_rank() == 0) {
407  const double *L2_norms;
408  const double *Ex_norms;
409  CHKERR VecGetArrayRead(errorVec, &L2_norms);
410  CHKERR VecGetArrayRead(exactVec, &Ex_norms);
411  MOFEM_TAG_AND_LOG("SELF", Sev::inform, "Errors")
412  << "L2_NORM: " << std::sqrt(L2_norms[NORM]);
413  MOFEM_TAG_AND_LOG("SELF", Sev::inform, "Errors")
414  << "NORMALISED_ERROR: "
415  << (std::sqrt(L2_norms[NORM]) / std::sqrt(Ex_norms[EX_NORM]));
416  CHKERR VecRestoreArrayRead(errorVec, &L2_norms);
417  CHKERR VecRestoreArrayRead(exactVec, &Ex_norms);
418  }
419  // compare norm for ctest
420  if (atomTest && !mField.get_comm_rank()) {
421  const double *L2_norms;
422  const double *Ex_norms;
423  CHKERR VecGetArrayRead(errorVec, &L2_norms);
424  CHKERR VecGetArrayRead(exactVec, &Ex_norms);
425  double ref_percentage = 4.4e-04;
426  double normalised_error;
427  switch (atomTest) {
428  case 1: // 2D
429  normalised_error = std::sqrt(L2_norms[0]) / std::sqrt(Ex_norms[0]);
430  break;
431  default:
432  SETERRQ1(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
433  "atom test %d does not exist", atomTest);
434  }
435  if (normalised_error > ref_percentage) {
436  SETERRQ3(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
437  "atom test %d failed! Calculated Norm %3.16e is greater than "
438  "reference Norm %3.16e",
439  atomTest, normalised_error, ref_percentage);
440  }
441  CHKERR VecRestoreArrayRead(errorVec, &L2_norms);
442  CHKERR VecRestoreArrayRead(exactVec, &Ex_norms);
443  }
445 }
446 //! [Check]
447 
448 int main(int argc, char *argv[]) {
449 
450  // Initialisation of MoFEM/PETSc and MOAB data structures
451  const char param_file[] = "param_file.petsc";
452  MoFEM::Core::Initialize(&argc, &argv, param_file, help);
453 
454  auto core_log = logging::core::get();
455  core_log->add_sink(
456  LogManager::createSink(LogManager::getStrmWorld(), "EXAMPLE"));
457  LogManager::setLog("EXAMPLE");
458  MOFEM_LOG_TAG("EXAMPLE", "example")
459 
460  // Error handling
461  try {
462  // Register MoFEM discrete manager in PETSc
463  DMType dm_name = "DMMOFEM";
464  CHKERR DMRegister_MoFEM(dm_name);
465 
466  // Create MOAB instance
467  moab::Core mb_instance; // mesh database
468  moab::Interface &moab = mb_instance; // mesh database interface
469 
470  // Create MoFEM instance
471  MoFEM::Core core(moab); // finite element database
472  MoFEM::Interface &m_field = core; // finite element interface
473 
474  // Run the main analysis
475  NonlinearPoisson poisson_problem(m_field);
476  CHKERR poisson_problem.runProgram();
477  }
478  CATCH_ERRORS;
479 
480  // Finish work: cleaning memory, getting statistics, etc.
482 
483  return 0;
484 }
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
NonlinearPoisson::outputResults
MoFEMErrorCode outputResults()
Definition: nonlinear_poisson_2d.cpp:336
H1
@ H1
continuous field
Definition: definitions.h:85
NonlinearPoisson::EX_NORM
@ EX_NORM
Definition: nonlinear_poisson_2d.cpp:64
NonlinearPoisson::NonlinearPoisson
NonlinearPoisson(MoFEM::Interface &m_field)
Definition: nonlinear_poisson_2d.cpp:78
MoFEM::PipelineManager::createSNES
SmartPetscObj< SNES > createSNES(SmartPetscObj< DM > dm=nullptr)
Create SNES (nonlinear) solver.
Definition: PipelineManager.cpp:109
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
MoFEM::ProblemsManager
Problem manager is used to build and partition problems.
Definition: ProblemsManager.hpp:21
NonlinearPoisson::boundaryFunction
static double boundaryFunction(const double x, const double y, const double z)
Definition: nonlinear_poisson_2d.cpp:46
OpBoundaryRhs
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesScalar< 1 > OpBoundaryRhs
Definition: nonlinear_poisson_2d.hpp:18
MoFEM::CoreInterface::get_comm
virtual MPI_Comm & get_comm() const =0
NOBASE
@ NOBASE
Definition: definitions.h:59
CHK_THROW_MESSAGE
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:609
NonlinearPoisson::LAST_NORM
@ LAST_NORM
Definition: nonlinear_poisson_2d.cpp:63
NonlinearPoisson::boundaryCondition
MoFEMErrorCode boundaryCondition()
Definition: nonlinear_poisson_2d.cpp:178
NonlinearPoisson::sourceTermFunction
static double sourceTermFunction(const double x, const double y, const double z)
Definition: nonlinear_poisson_2d.cpp:34
NonlinearPoisson::order
int order
Definition: nonlinear_poisson_2d.cpp:58
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
NonlinearPoisson::EX_NORMS
EX_NORMS
Definition: nonlinear_poisson_2d.cpp:64
MoFEM::CoreInterface::get_comm_rank
virtual int get_comm_rank() const =0
domainField
constexpr auto domainField
Definition: electrostatics.hpp:7
MoFEM::Simple::loadFile
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
Definition: Simple.cpp:194
SPACE_DIM
constexpr int SPACE_DIM
Definition: nonlinear_poisson_2d.cpp:8
MoFEM::PipelineManager
PipelineManager interface.
Definition: PipelineManager.hpp:24
MoFEM.hpp
NonlinearPoissonOps
Definition: nonlinear_poisson_2d.hpp:31
NonlinearPoisson
Definition: nonlinear_poisson_2d.cpp:15
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
nonlinear_poisson_2d.hpp
MoFEM::Simple
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
NonlinearPoisson::NORM
@ NORM
Definition: nonlinear_poisson_2d.cpp:63
NonlinearPoisson::domainField
std::string domainField
Definition: nonlinear_poisson_2d.cpp:57
MoFEM::OpCalculateScalarFieldGradient
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Definition: UserDataOperators.hpp:1293
ROW
@ ROW
Definition: definitions.h:136
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
MoFEM::DMCreateGlobalVector_MoFEM
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition: DMMoFEM.cpp:1167
MoFEM::Simple::getOptions
MoFEMErrorCode getOptions()
get options
Definition: Simple.cpp:180
MoFEM::PostProcBrokenMeshInMoab
Definition: PostProcBrokenMeshInMoabBase.hpp:667
NonlinearPoisson::setIntegrationRules
MoFEMErrorCode setIntegrationRules()
Definition: nonlinear_poisson_2d.cpp:160
MoFEM::Simple::getDM
MoFEMErrorCode getDM(DM *dm)
Get DM.
Definition: Simple.cpp:747
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
NonlinearPoisson::boundaryMarker
boost::shared_ptr< std::vector< unsigned char > > boundaryMarker
Definition: nonlinear_poisson_2d.cpp:67
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
NonlinearPoisson::assembleSystem
MoFEMErrorCode assembleSystem()
Definition: nonlinear_poisson_2d.cpp:219
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
NonlinearPoisson::simpleInterface
Simple * simpleInterface
Definition: nonlinear_poisson_2d.cpp:54
MoFEM::ISManager
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
OpBoundaryRhsSource
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, 1 > OpBoundaryRhsSource
Definition: nonlinear_poisson_2d.hpp:20
NonlinearPoisson::solveSystem
MoFEMErrorCode solveSystem()
Definition: nonlinear_poisson_2d.cpp:282
simple
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
NonlinearPoisson::atomTest
int atomTest
Definition: nonlinear_poisson_2d.cpp:62
convert.type
type
Definition: convert.py:64
OpPPMap
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
Definition: photon_diffusion.cpp:29
NonlinearPoisson::checkResults
MoFEMErrorCode checkResults()
[Check]
Definition: nonlinear_poisson_2d.cpp:369
MoFEM::DMoFEMMeshToGlobalVector
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
Definition: DMMoFEM.cpp:535
MoFEM::OpCalculateScalarFieldValues
Get value at integration points for scalar field.
Definition: UserDataOperators.hpp:82
MoFEM::Simple::addDomainField
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.
Definition: Simple.cpp:264
NonlinearPoisson::LAST_EX_NORM
@ LAST_EX_NORM
Definition: nonlinear_poisson_2d.cpp:64
MoFEM::DMRegister_MoFEM
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMoFEM.cpp:43
MoFEM::Simple::getDomainFEName
const std::string getDomainFEName() const
Get the Domain FE Name.
Definition: Simple.hpp:368
OpBoundaryLhs
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, 1 > OpBoundaryLhs
Definition: nonlinear_poisson_2d.hpp:16
MoFEM::ProblemsManager::markDofs
MoFEMErrorCode markDofs(const std::string problem_name, RowColData rc, const enum MarkOP op, const Range ents, std::vector< unsigned char > &marker) const
Create vector with marked indices.
Definition: ProblemsManager.cpp:3548
MoFEM::type_from_handle
auto type_from_handle(const EntityHandle h)
get type from entity handle
Definition: Templates.hpp:1898
NonlinearPoissonOps::OpDomainRhs
Definition: nonlinear_poisson_2d.hpp:119
NonlinearPoissonOps::OpDomainLhs
Definition: nonlinear_poisson_2d.hpp:39
MOFEM_LOG_TAG
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
MoFEM::OpGetTensor0fromFunc
Get values from scalar function at integration points and save them to VectorDouble for Tensor0.
Definition: NormsOperators.hpp:105
MOFEM_NOT_FOUND
@ MOFEM_NOT_FOUND
Definition: definitions.h:33
NonlinearPoisson::runProgram
MoFEMErrorCode runProgram()
Definition: nonlinear_poisson_2d.cpp:81
NonlinearPoisson::mField
MoFEM::Interface & mField
Definition: nonlinear_poisson_2d.cpp:53
sqr
double sqr(const double x)
Definition: nonlinear_poisson_2d.cpp:11
MoFEM::Simple::setFieldOrder
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition: Simple.cpp:545
MoFEM::AddHOOps
Add operators pushing bases from local to physical configuration.
Definition: HODataOperators.hpp:413
help
static char help[]
Definition: nonlinear_poisson_2d.cpp:9
NonlinearPoisson::exactVec
SmartPetscObj< Vec > exactVec
Definition: nonlinear_poisson_2d.cpp:61
MoFEM::OpUnSetBc
Definition: FormsIntegrators.hpp:49
Range
MoFEM::CoreTmp< 0 >::Initialize
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
MOFEM_TAG_AND_LOG
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:362
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::vectorDuplicate
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
Definition: PetscSmartObj.hpp:221
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
DEMKOWICZ_JACOBI_BASE
@ DEMKOWICZ_JACOBI_BASE
Definition: definitions.h:66
NonlinearPoisson::errorVec
SmartPetscObj< Vec > errorVec
Definition: nonlinear_poisson_2d.cpp:61
_IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
Definition: MeshsetsManager.hpp:71
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
BLOCKSET
@ BLOCKSET
Definition: definitions.h:161
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
MoFEM::OpSetBc
Set indices on entities on finite element.
Definition: FormsIntegrators.hpp:38
MoFEM::OpCalcNormL2Tensor0
Get norm of input VectorDouble for Tensor0.
Definition: NormsOperators.hpp:15
MoFEM::createVectorMPI
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
Definition: PetscSmartObj.hpp:202
NonlinearPoisson::NORMS
NORMS
Definition: nonlinear_poisson_2d.cpp:63
MoFEM::Simple::addBoundaryField
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.
Definition: Simple.cpp:354
NonlinearPoisson::setupProblem
MoFEMErrorCode setupProblem()
Definition: nonlinear_poisson_2d.cpp:106
MOFEM_ATOM_TEST_INVALID
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
main
int main(int argc, char *argv[])
[Check]
Definition: nonlinear_poisson_2d.cpp:448
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
MoFEM::SmartPetscObj< Vec >
MoFEM::Simple::setUp
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition: Simple.cpp:683
MoFEM::Simple::getProblemName
const std::string getProblemName() const
Get the Problem Name.
Definition: Simple.hpp:389
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:586
convert.int
int
Definition: convert.py:64
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:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
MOFEM_INVALID_DATA
@ MOFEM_INVALID_DATA
Definition: definitions.h:36
cube
double cube(const double x)
Definition: nonlinear_poisson_2d.cpp:13
NonlinearPoisson::postProc
boost::shared_ptr< PostProcEle > postProc
Definition: nonlinear_poisson_2d.cpp:72
NonlinearPoisson::readMesh
MoFEMErrorCode readMesh()
Definition: nonlinear_poisson_2d.cpp:96
NonlinearPoisson::boundaryEntitiesForFieldsplit
Range boundaryEntitiesForFieldsplit
Definition: nonlinear_poisson_2d.cpp:75
MoFEM::OpPostProcMapInMoab
Post post-proc data at points from hash maps.
Definition: PostProcBrokenMeshInMoabBase.hpp:698