v0.14.0
EssentialHeatFluxCubitBcData.hpp
Go to the documentation of this file.
1 /**
2  * @file EssentialHeatFluxCubitBcData.hpp
3  * @brief Specialization for essential b.c. with HeatFluxCubitBcData
4  * @version 0.13.2
5  * @date 2022-09-18
6  *
7  * @copyright Copyright (c) 2022
8  *
9  */
10 
11 #ifndef _ESSENTIAL_HEATFLUXCUBITBCDATA_HPP_
12 #define _ESSENTIAL_HEATFLUXCUBITBCDATA_HPP_
13 
14 namespace MoFEM {
15 
16 template <AssemblyType A, typename OpBase>
18  : FormsIntegrators<OpBase>::template Assembly<A>::OpBase {
19 
21 
22  OpEssentialRhsImpl(const std::string field_name,
23  boost::shared_ptr<HeatFluxCubitBcData> bc_data,
24  boost::shared_ptr<Range> ents_ptr,
25  std::vector<boost::shared_ptr<ScalingMethod>> smv);
26 
27 protected:
28  MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data);
29 
30 private:
31  double heatFlux;
33 };
34 
35 template <AssemblyType A, typename OpBase>
37  : OpEssentialRhsImpl<HeatFluxCubitBcData, 3, 3, A, GAUSS, OpBase> {
40 };
41 
42 template <AssemblyType A, typename OpBase>
44  OpEssentialRhsImpl(const std::string field_name,
45  boost::shared_ptr<HeatFluxCubitBcData> bc_data,
46  boost::shared_ptr<Range> ents_ptr,
47  std::vector<boost::shared_ptr<ScalingMethod>> smv)
48  : OP(field_name, field_name, OpBase::OPROW, ents_ptr),
49  vecOfTimeScalingMethods(smv) {
50  heatFlux = -bc_data->data.value1;
51  this->timeScalingFun = [this](const double t) {
52  double s = 1;
53  for (auto &o : vecOfTimeScalingMethods) {
54  s *= o->getScale(t);
55  }
56  return s;
57  };
58 }
59 
60 template <AssemblyType A, typename OpBase>
63  EntitiesFieldData::EntData &row_data) {
65 
66  FTENSOR_INDEX(3, i);
67 
68  // get element volume
69  const double vol = OP::getMeasure();
70  // get integration weights
71  auto t_w = OP::getFTensor0IntegrationWeight();
72  // get base function gradient on rows
73  auto t_row_base = row_data.getFTensor1N<3>();
74  // get normal
75  auto t_normal = OP::getFTensor1NormalsAtGaussPts();
76 
77  // loop over integration points
78  for (int gg = 0; gg != OP::nbIntegrationPts; gg++) {
79  // take into account Jacobian
80  const double alpha = t_w;
81 
82  FTensor::Tensor1<double, 3> t_unit_normal;
83  t_unit_normal(i) = t_normal(i) / t_normal.l2();
84 
85  // loop over rows base functions
86  int rr = 0;
87  for (; rr != OP::nbRows; ++rr) {
88  OP::locF[rr] += alpha * (t_row_base(i) * t_unit_normal(i));
89  ++t_row_base;
90  }
91  for (; rr < OP::nbRowBaseFunctions; ++rr)
92  ++t_row_base;
93  ++t_w; // move to another integration weight
94  ++t_normal;
95  }
96 
97  OP::locF *= vol * heatFlux;
98 
100 }
101 
102 template <int BASE_DIM, int FIELD_DIM, AssemblyType A, IntegrationType I,
103  typename OpBase>
105  OpBase>
106  : OpEssentialLhsImpl<DisplacementCubitBcData, BASE_DIM, FIELD_DIM, A, I,
107  OpBase> {
110 };
111 
112 template <int BASE_DIM, int FIELD_DIM, AssemblyType A, IntegrationType I,
113  typename OpBase>
115 
117  A, I, OpBase
118 
119  > {
120 
122 
124 
125  MoFEM::Interface &m_field,
126  boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
127  const std::string problem_name, std::string field_name,
128  boost::shared_ptr<MatrixDouble> field_mat_ptr,
129  std::vector<boost::shared_ptr<ScalingMethod>> smv
130 
131  ) {
133 
134  using OP =
135  typename EssentialBC<OpBase>::template Assembly<A>::template LinearForm<
136  I>::template OpEssentialRhs<HeatFluxCubitBcData, BASE_DIM,
137  FIELD_DIM>;
138  using OpInternal = typename FormsIntegrators<OpBase>::template Assembly<
139  A>::template LinearForm<I>::template OpBaseTimesVector<BASE_DIM,
140  FIELD_DIM, 1>;
141 
142  auto add_op = [&](auto &bcs) {
144  for (auto &m : bcs) {
145  if (auto bc = m.second->heatFluxBcPtr) {
146  auto &bc_id = m.first;
147  auto regex_str =
148  (boost::format("%s_%s_(.*)") % problem_name % field_name).str();
149  if (std::regex_match(bc_id, std::regex(regex_str))) {
150  MOFEM_TAG_AND_LOG("SELF", Sev::noisy, "OpEssentialRhs") << *bc;
151  pipeline.push_back(
152  new OpSetBc(field_name, false, m.second->getBcMarkersPtr()));
153  pipeline.push_back(
154  new OP(field_name, bc, m.second->getBcEntsPtr(), smv));
155  pipeline.push_back(new OpInternal(
156  field_name, field_mat_ptr,
157  [](double, double, double) constexpr { return 1.; },
158  m.second->getBcEntsPtr()));
159  pipeline.push_back(new OpUnSetBc(field_name));
160  }
161  }
162  }
163  MOFEM_LOG_CHANNEL("SELF");
165  };
166 
167  CHKERR add_op(m_field.getInterface<BcManager>()->getBcMapByBlockName());
168 
170  }
171 };
172 
173 template <int BASE_DIM, int FIELD_DIM, AssemblyType A, IntegrationType I,
174  typename OpBase>
176 
178  A, I, OpBase
179 
180  > {
181 
183 
185 
186  MoFEM::Interface &m_field,
187  boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
188  const std::string problem_name, std::string field_name) {
190 
191  using OP = typename EssentialBC<OpBase>::template Assembly<A>::
192  template BiLinearForm<I>::template OpEssentialLhs<HeatFluxCubitBcData,
194 
195  auto add_op = [&](auto &bcs) {
197  for (auto &m : bcs) {
198  if (auto bc = m.second->heatFluxBcPtr) {
199  auto &bc_id = m.first;
200  auto regex_str =
201  (boost::format("%s_%s_(.*)") % problem_name % field_name).str();
202  if (std::regex_match(bc_id, std::regex(regex_str))) {
203  MOFEM_TAG_AND_LOG("SELF", Sev::noisy, "OpEssentialLhs") << *bc;
204  pipeline.push_back(
205  new OpSetBc(field_name, false, m.second->getBcMarkersPtr()));
206  pipeline.push_back(new OP(field_name, m.second->getBcEntsPtr()));
207  pipeline.push_back(new OpUnSetBc(field_name));
208  }
209  }
210  }
211  MOFEM_LOG_CHANNEL("SELF");
213  };
214 
215  CHKERR add_op(m_field.getInterface<BcManager>()->getBcMapByBlockName());
216 
218  }
219 };
220 
221 } // namespace MoFEM
222 
223 #endif //_ESSENTIAL_HEATFLUXCUBITBCDATA_HPP_
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::EntitiesFieldData::EntData
Data on single entity (This is passed as argument to DataOperator::doWork)
Definition: EntitiesFieldData.hpp:128
FTensor::Tensor1< double, 3 >
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
MoFEM::EssentialBC
Essential boundary conditions.
Definition: Essential.hpp:111
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
FTensor::Tensor1::l2
T l2() const
Definition: Tensor1_value.hpp:84
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
MoFEM::DisplacementCubitBcData
Definition of the displacement bc data structure.
Definition: BCData.hpp:76
OpBase
OpBaseImpl< PETSC, EdgeEleOp > OpBase
Definition: radiation.cpp:29
FTENSOR_INDEX
#define FTENSOR_INDEX(DIM, I)
Definition: Templates.hpp:2011
BASE_DIM
constexpr int BASE_DIM
Definition: dg_projection.cpp:15
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
FIELD_DIM
constexpr int FIELD_DIM
Definition: child_and_parent.cpp:15
I
constexpr IntegrationType I
Definition: operators_tests.cpp:31
MoFEM::OpBaseImpl
Definition: FormsIntegrators.hpp:178
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::BcManager
Simple interface for fast problem set-up.
Definition: BcManager.hpp:25
MoFEM::AddEssentialToLhsPipelineImpl< OpEssentialLhsImpl< HeatFluxCubitBcData, BASE_DIM, FIELD_DIM, A, I, OpBase >, A, I, OpBase >::add
static MoFEMErrorCode add(MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, const std::string problem_name, std::string field_name)
Definition: EssentialHeatFluxCubitBcData.hpp:184
MoFEM::OpEssentialLhsImpl
Enforce essential constrains on lhs.
Definition: Essential.hpp:81
MoFEM::BcManager::getBcMapByBlockName
BcMapByBlockName & getBcMapByBlockName()
Get the bc map.
Definition: BcManager.hpp:243
MoFEM::AddEssentialToRhsPipelineImpl
Function (factory) for setting operators for rhs pipeline.
Definition: Essential.hpp:92
MoFEM::AddEssentialToLhsPipelineImpl
Function (factory) for setting operators for lhs pipeline.
Definition: Essential.hpp:103
MoFEM::GAUSS
@ GAUSS
Definition: FormsIntegrators.hpp:136
t
constexpr double t
plate stiffness
Definition: plate.cpp:58
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
BiLinearForm
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
MoFEM::IntegrationType
IntegrationType
Form integrator integration types.
Definition: FormsIntegrators.hpp:136
MoFEM::AddEssentialToRhsPipelineImpl< OpEssentialRhsImpl< HeatFluxCubitBcData, BASE_DIM, FIELD_DIM, A, I, OpBase >, A, I, OpBase >::add
static MoFEMErrorCode add(MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, const std::string problem_name, std::string field_name, boost::shared_ptr< MatrixDouble > field_mat_ptr, std::vector< boost::shared_ptr< ScalingMethod >> smv)
Definition: EssentialHeatFluxCubitBcData.hpp:123
MoFEM::OpUnSetBc
Definition: FormsIntegrators.hpp:49
MOFEM_TAG_AND_LOG
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:362
MoFEM::OpEssentialRhsImpl
Enforce essential constrains on rhs.
Definition: Essential.hpp:65
MoFEM::AssemblyType
AssemblyType
[Storage and set boundary conditions]
Definition: FormsIntegrators.hpp:104
MoFEM::EntitiesFieldData::EntData::getFTensor1N
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1N(FieldApproximationBase base)
Get base functions for Hdiv/Hcurl spaces.
Definition: EntitiesFieldData.cpp:640
MoFEM::VecOfTimeScalingMethods
std::vector< boost::shared_ptr< ScalingMethod > > VecOfTimeScalingMethods
Vector of time scaling methods.
Definition: Natural.hpp:20
MoFEM::OpSetBc
Set indices on entities on finite element.
Definition: FormsIntegrators.hpp:38
MoFEM::OpEssentialRhsImpl< HeatFluxCubitBcData, 3, 3, A, GAUSS, OpBase >::heatFlux
double heatFlux
Definition: EssentialHeatFluxCubitBcData.hpp:31
MoFEM::FormsIntegrators
Integrator forms.
Definition: FormsIntegrators.hpp:306
MoFEM::HeatFluxCubitBcData
Definition of the heat flux bc data structure.
Definition: BCData.hpp:427
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
OP
MoFEM::OpEssentialRhsImpl< HeatFluxCubitBcData, 3, 3, A, GAUSS, OpBase >::vecOfTimeScalingMethods
VecOfTimeScalingMethods vecOfTimeScalingMethods
Definition: EssentialHeatFluxCubitBcData.hpp:32
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