v0.9.0
Public Member Functions | Private Attributes | List of all members
PoissonExample::CreateFiniteElements Struct Reference

Create finite elements instances. More...

#include <users_modules/basic_finite_elements/poisson/src/PoissonOperators.hpp>

Collaboration diagram for PoissonExample::CreateFiniteElements:
[legend]

Public Member Functions

 CreateFiniteElements (MoFEM::Interface &m_field)
 
MoFEMErrorCode createFEToAssembleMatrixAndVector (boost::function< double(const double, const double, const double)> f_u, boost::function< double(const double, const double, const double)> f_source, boost::shared_ptr< ForcesAndSourcesCore > &domain_lhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &boundary_lhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &domain_rhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &boundary_rhs_fe, bool trans=true) const
 Create finite element to calculate matrix and vectors. More...
 
MoFEMErrorCode createFEToEvaluateError (boost::function< double(const double, const double, const double)> f_u, boost::function< FTensor::Tensor1< double, 3 >(const double, const double, const double)> g_u, Vec global_error, boost::shared_ptr< ForcesAndSourcesCore > &domain_error) const
 Create finite element to calculate error. More...
 
MoFEMErrorCode creatFEToPostProcessResults (boost::shared_ptr< ForcesAndSourcesCore > &post_proc_volume) const
 Create finite element to post-process results. More...
 
MoFEMErrorCode createFEToAssembleMatrixAndVectorForNonlinearProblem (boost::function< double(const double, const double, const double)> f_u, boost::function< double(const double, const double, const double)> f_source, boost::function< double(const double)> a, boost::function< double(const double)> diff_a, boost::shared_ptr< ForcesAndSourcesCore > &domain_lhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &boundary_lhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &domain_rhs_fe, boost::shared_ptr< ForcesAndSourcesCore > &boundary_rhs_fe, ForcesAndSourcesCore::RuleHookFun vol_rule, ForcesAndSourcesCore::RuleHookFun face_rule=FaceRule(), bool trans=true) const
 Create finite element to calculate matrix and vectors. More...
 

Private Attributes

MoFEM::InterfacemField
 

Detailed Description

Create finite elements instances.

Create finite element instances and add operators to finite elements.

Examples
analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, and analytical_poisson_field_split.cpp.

Definition at line 871 of file PoissonOperators.hpp.

Constructor & Destructor Documentation

◆ CreateFiniteElements()

PoissonExample::CreateFiniteElements::CreateFiniteElements ( MoFEM::Interface m_field)
Examples
PoissonOperators.hpp.

Definition at line 873 of file PoissonOperators.hpp.

873 : mField(m_field) {}

Member Function Documentation

◆ createFEToAssembleMatrixAndVector()

MoFEMErrorCode PoissonExample::CreateFiniteElements::createFEToAssembleMatrixAndVector ( boost::function< double(const double, const double, const double)>  f_u,
boost::function< double(const double, const double, const double)>  f_source,
boost::shared_ptr< ForcesAndSourcesCore > &  domain_lhs_fe,
boost::shared_ptr< ForcesAndSourcesCore > &  boundary_lhs_fe,
boost::shared_ptr< ForcesAndSourcesCore > &  domain_rhs_fe,
boost::shared_ptr< ForcesAndSourcesCore > &  boundary_rhs_fe,
bool  trans = true 
) const

Create finite element to calculate matrix and vectors.

Examples
analytical_poisson.cpp, analytical_poisson_field_split.cpp, and PoissonOperators.hpp.

Definition at line 878 of file PoissonOperators.hpp.

886  {
888 
889  // Create elements element instances
890  domain_lhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
892  boundary_lhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
894  domain_rhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
896  boundary_rhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
898 
899  // Set integration rule to elements instances
900  domain_lhs_fe->getRuleHook = VolRule();
901  domain_rhs_fe->getRuleHook = VolRule();
902  boundary_lhs_fe->getRuleHook = FaceRule();
903  boundary_rhs_fe->getRuleHook = FaceRule();
904 
905  // Add operators to element instances
906  // Add operator grad-grad for calculate matrix
907  domain_lhs_fe->getOpPtrVector().push_back(new OpK());
908  // Add operator to calculate source terms
909  domain_rhs_fe->getOpPtrVector().push_back(new OpF(f_source));
910  // Add operator calculating constrains matrix
911  boundary_lhs_fe->getOpPtrVector().push_back(new OpC(trans));
912  // Add operator calculating constrains vector
913  boundary_rhs_fe->getOpPtrVector().push_back(new Op_g(f_u));
914 
916  }
Set integration rule.
VolumeElementForcesAndSourcesCoreSwitch< 0 > VolumeElementForcesAndSourcesCore
Volume finite element default.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
Set integration rule to boundary elements.
assemble the stiffness matrix
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
FaceElementForcesAndSourcesCoreSwitch< 0 > FaceElementForcesAndSourcesCore
Face finite element default.

◆ createFEToAssembleMatrixAndVectorForNonlinearProblem()

MoFEMErrorCode PoissonExample::CreateFiniteElements::createFEToAssembleMatrixAndVectorForNonlinearProblem ( boost::function< double(const double, const double, const double)>  f_u,
boost::function< double(const double, const double, const double)>  f_source,
boost::function< double(const double)>  a,
boost::function< double(const double)>  diff_a,
boost::shared_ptr< ForcesAndSourcesCore > &  domain_lhs_fe,
boost::shared_ptr< ForcesAndSourcesCore > &  boundary_lhs_fe,
boost::shared_ptr< ForcesAndSourcesCore > &  domain_rhs_fe,
boost::shared_ptr< ForcesAndSourcesCore > &  boundary_rhs_fe,
ForcesAndSourcesCore::RuleHookFun  vol_rule,
ForcesAndSourcesCore::RuleHookFun  face_rule = FaceRule(),
bool  trans = true 
) const

Create finite element to calculate matrix and vectors.

Examples
analytical_nonlinear_poisson.cpp, and PoissonOperators.hpp.

Definition at line 993 of file PoissonOperators.hpp.

1005  {
1007 
1008  // Create elements element instances
1009  domain_lhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
1011  boundary_lhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
1013  domain_rhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
1015  boundary_rhs_fe = boost::shared_ptr<ForcesAndSourcesCore>(
1017 
1018  // Set integration rule to elements instances
1019  domain_lhs_fe->getRuleHook = vol_rule;
1020  domain_rhs_fe->getRuleHook = vol_rule;
1021  boundary_lhs_fe->getRuleHook = face_rule;
1022  boundary_rhs_fe->getRuleHook = face_rule;
1023 
1024  // Set integration rule
1025  // Crate shared vector storing values of field "u" on integration points on
1026  // element. element is local and is used to exchange data between operators.
1027  boost::shared_ptr<VectorDouble> values_at_integration_ptr =
1028  boost::make_shared<VectorDouble>();
1029  // Storing gradients of field
1030  boost::shared_ptr<MatrixDouble> grad_at_integration_ptr =
1031  boost::make_shared<MatrixDouble>();
1032  // multipliers values
1033  boost::shared_ptr<VectorDouble> multiplier_at_integration_ptr =
1034  boost::make_shared<VectorDouble>();
1035 
1036  // Add operators to element instances
1037  // Add default operator to calculate field values at integration points
1038  domain_lhs_fe->getOpPtrVector().push_back(
1039  new OpCalculateScalarFieldValues("U", values_at_integration_ptr));
1040  // Add default operator to calculate field gradient at integration points
1041  domain_lhs_fe->getOpPtrVector().push_back(
1042  new OpCalculateScalarFieldGradient<3>("U", grad_at_integration_ptr));
1043  // Add operator grad-(1+u^2)grad for calculate matrix
1044  domain_lhs_fe->getOpPtrVector().push_back(new OpKt(
1045  a, diff_a, values_at_integration_ptr, grad_at_integration_ptr));
1046 
1047  // Add default operator to calculate field values at integration points
1048  domain_rhs_fe->getOpPtrVector().push_back(
1049  new OpCalculateScalarFieldValues("U", values_at_integration_ptr));
1050  // Add default operator to calculate field gradient at integration points
1051  domain_rhs_fe->getOpPtrVector().push_back(
1052  new OpCalculateScalarFieldGradient<3>("U", grad_at_integration_ptr));
1053  // Add operator to calculate source terms
1054  domain_rhs_fe->getOpPtrVector().push_back(new OpResF_Domain(
1055  f_source, a, values_at_integration_ptr, grad_at_integration_ptr));
1056 
1057  // Add operator calculating constrains matrix
1058  boundary_lhs_fe->getOpPtrVector().push_back(new OpC(trans));
1059 
1060  // Add default operator to calculate field values at integration points
1061  boundary_rhs_fe->getOpPtrVector().push_back(
1062  new OpCalculateScalarFieldValues("U", values_at_integration_ptr));
1063  // Add default operator to calculate values of Lagrange multipliers
1064  boundary_rhs_fe->getOpPtrVector().push_back(
1065  new OpCalculateScalarFieldValues("L", multiplier_at_integration_ptr));
1066  // Add operator calculating constrains vector
1067  boundary_rhs_fe->getOpPtrVector().push_back(
1068  new OpRes_g(f_u, values_at_integration_ptr));
1069  boundary_rhs_fe->getOpPtrVector().push_back(
1070  new OpResF_Boundary(multiplier_at_integration_ptr));
1071 
1073  }
VolumeElementForcesAndSourcesCoreSwitch< 0 > VolumeElementForcesAndSourcesCore
Volume finite element default.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
FaceElementForcesAndSourcesCoreSwitch< 0 > FaceElementForcesAndSourcesCore
Face finite element default.

◆ createFEToEvaluateError()

MoFEMErrorCode PoissonExample::CreateFiniteElements::createFEToEvaluateError ( boost::function< double(const double, const double, const double)>  f_u,
boost::function< FTensor::Tensor1< double, 3 >(const double, const double, const double)>  g_u,
Vec  global_error,
boost::shared_ptr< ForcesAndSourcesCore > &  domain_error 
) const

Create finite element to calculate error.

Examples
analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, analytical_poisson_field_split.cpp, and PoissonOperators.hpp.

Definition at line 921 of file PoissonOperators.hpp.

927  {
929  // Create finite element instance to calculate error
930  domain_error = boost::shared_ptr<ForcesAndSourcesCore>(
932  domain_error->getRuleHook = VolRule();
933  // Set integration rule
934  // Crate shared vector storing values of field "u" on integration points on
935  // element. element is local and is used to exchange data between operators.
936  boost::shared_ptr<VectorDouble> values_at_integration_ptr =
937  boost::make_shared<VectorDouble>();
938  // Storing gradients of field
939  boost::shared_ptr<MatrixDouble> grad_at_integration_ptr =
940  boost::make_shared<MatrixDouble>();
941  // Add default operator to calculate field values at integration points
942  domain_error->getOpPtrVector().push_back(
943  new OpCalculateScalarFieldValues("U", values_at_integration_ptr));
944  // Add default operator to calculate field gradient at integration points
945  domain_error->getOpPtrVector().push_back(
946  new OpCalculateScalarFieldGradient<3>("U", grad_at_integration_ptr));
947  // Add operator to integrate error element by element.
948  domain_error->getOpPtrVector().push_back(
949  new OpError(f_u, g_u, values_at_integration_ptr,
950  grad_at_integration_ptr, global_error));
952  }
Set integration rule.
VolumeElementForcesAndSourcesCoreSwitch< 0 > VolumeElementForcesAndSourcesCore
Volume finite element default.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ creatFEToPostProcessResults()

MoFEMErrorCode PoissonExample::CreateFiniteElements::creatFEToPostProcessResults ( boost::shared_ptr< ForcesAndSourcesCore > &  post_proc_volume) const

Create finite element to post-process results.

Examples
analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, analytical_poisson_field_split.cpp, and PoissonOperators.hpp.

Definition at line 957 of file PoissonOperators.hpp.

958  {
959 
961 
962  // Note that user can stack together arbitrary number of operators to
963  // compose complex PDEs.
964 
965  // Post-process results. This is standard element, with functionality
966  // enabling refining mesh for post-processing. In addition in
967  // PostProcOnRefMesh.hpp are implanted set of users operators to
968  // post-processing fields. Here using simplified mechanism for
969  // post-processing finite element, we add operators to save data from field
970  // on mesh tags for ParaView visualization.
971  post_proc_volume = boost::shared_ptr<ForcesAndSourcesCore>(
973  // Add operators to the elements, starting with some generic
974  CHKERR boost::static_pointer_cast<PostProcVolumeOnRefinedMesh>(
975  post_proc_volume)
976  ->generateReferenceElementMesh();
977  CHKERR boost::static_pointer_cast<PostProcVolumeOnRefinedMesh>(
978  post_proc_volume)
979  ->addFieldValuesPostProc("U");
980  CHKERR boost::static_pointer_cast<PostProcVolumeOnRefinedMesh>(
981  post_proc_volume)
982  ->addFieldValuesPostProc("ERROR");
983  CHKERR boost::static_pointer_cast<PostProcVolumeOnRefinedMesh>(
984  post_proc_volume)
985  ->addFieldValuesGradientPostProc("U");
986 
988  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
Post processing.
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

Member Data Documentation

◆ mField

MoFEM::Interface& PoissonExample::CreateFiniteElements::mField
private
Examples
PoissonOperators.hpp.

Definition at line 1076 of file PoissonOperators.hpp.


The documentation for this struct was generated from the following file: