v0.14.0
BCs_RVEVolume.hpp
Go to the documentation of this file.
1 /* Copyright (C) 2014, Zahur Ullah (Zahur.Ullah AT glasgow.ac.uk)
2  * --------------------------------------------------------------
3  * FIXME: DESCRIPTION
4  */
5 
6 /* This file is part of MoFEM.
7  * MoFEM is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #ifndef __BCSRVEVOLUME_HPP
21 #define __BCSRVEVOLUME_HPP
22 
23 struct BCs_RVEVolume {
24 
25  /// \brief definition of volume element
26  struct MyVolumeFE: public VolumeElementForcesAndSourcesCore {
27  MyVolumeFE(MoFEM::Interface &_mField): VolumeElementForcesAndSourcesCore(_mField) {}
28  };
29 
30  MyVolumeFE feLhs; //< calculate left hand side for tetrahedral elements
31  MyVolumeFE& getLoopFeLhs() { return feLhs; } ///< get lhs volume element
32 
35  feLhs(m_field),
36  mField(m_field) {}
37 
38  /** \biref operator to calculate left hand side of heat conductivity terms
39  * \infroup mofem_thermal_elem
40  */
45 
47  VolumeElementForcesAndSourcesCore::UserDataOperator(field_name, UserDataOperator::OPROWCOL),
48  mField(m_field), RVE_volume_Vec(_RVE_volume_Vec), dAta(data) { }
49 
50  PetscErrorCode doWork(
51  int row_side,int col_side,
52  EntityType row_type,EntityType col_type,
55  PetscFunctionBegin;
56  if(dAta.tEts.find(getNumeredEntFiniteElementPtr()->getEnt()) == dAta.tEts.end()) {
57  PetscFunctionReturn(0);
58  }
59 
60  // cout<<"Hi from OpVolumeCal "<<endl;
61  if(row_type == MBVERTEX && col_type==MBVERTEX) {
62  // cout<<"Hi from MBVERTEX "<<endl;
63  ParallelComm* pcomm = ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
64  int Indices[1]; Indices[0]=pcomm->rank();
65  double Vol_elm[1]; Vol_elm[0]=0;
66  for(unsigned int gg = 0;gg<row_data.getN().size1();gg++) {
67  if(getHoGaussPtsDetJac().size()>0) {
68  // cout<<"getHoGaussPtsDetJac()[gg] "<<getHoGaussPtsDetJac()[gg]<<endl;
69  // cout<<"High order geometry "<<endl;
70  Vol_elm[0]+=getVolume()*getGaussPts()(3,gg)*getHoGaussPtsDetJac()[gg];
71  }else{
72  // cout<<"Low order geometry "<<endl;
73  Vol_elm[0]+=getVolume()*getGaussPts()(3,gg);
74  }
75  }
76 
77  ierr = VecSetValues(RVE_volume_Vec,1,Indices,Vol_elm,ADD_VALUES); CHKERRQ(ierr);
78  // cout<<"Indices[0] "<<Indices[0] << endl;
79  // cout<<"Vol_elm[0] "<<Vol_elm[0] << endl;
80  }
81  PetscFunctionReturn(0);
82  }
83  };
84 
85 
86  PetscErrorCode setRVEVolumeOperators(MoFEM::Interface &mField, string field_name, Vec _RVE_volume_Vec, map<int,NonlinearElasticElement::BlockData> &setOfBlocks) {
87  PetscFunctionBegin;
88 
89  //// cout<<"Hi from setRVEVolumeOperators "<<endl;
90  map<int,NonlinearElasticElement::BlockData>::iterator sit = setOfBlocks.begin();
91  for(;sit!=setOfBlocks.end();sit++) {
92  // cout<<"Hi from loop "<<endl;
93  // cout<<"sit->second.tEts === "<<sit->second.tEts<<endl;
94  feLhs.getOpPtrVector().push_back(new OpVolumeCal(mField, field_name, _RVE_volume_Vec, sit->second));
95  }
96  }
97 
98 
99  }
100 
101 #endif //__RVEVolume_HPP__
MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
BCs_RVEVolume::OpVolumeCal::OpVolumeCal
OpVolumeCal(MoFEM::Interface &m_field, string field_name, Vec _RVE_volume_Vec, NonlinearElasticElement::BlockData &data)
Definition: BCs_RVEVolume.hpp:46
MoFEM::VecSetValues
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
Definition: EntitiesFieldData.hpp:1576
BCs_RVEVolume::mField
MoFEM::Interface & mField
Definition: BCs_RVEVolume.hpp:33
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM::ForcesAndSourcesCore::UserDataOperator
Definition: ForcesAndSourcesCore.hpp:549
BCs_RVEVolume::OpVolumeCal::dAta
NonlinearElasticElement::BlockData & dAta
Definition: BCs_RVEVolume.hpp:43
BCs_RVEVolume::OpVolumeCal
Definition: BCs_RVEVolume.hpp:41
BCs_RVEVolume::OpVolumeCal::mField
MoFEM::Interface & mField
Definition: BCs_RVEVolume.hpp:44
NonlinearElasticElement::BlockData
data for calculation heat conductivity and heat capacity elements
Definition: HookeElement.hpp:32
BCs_RVEVolume::setRVEVolumeOperators
PetscErrorCode setRVEVolumeOperators(MoFEM::Interface &mField, string field_name, Vec _RVE_volume_Vec, map< int, NonlinearElasticElement::BlockData > &setOfBlocks)
Definition: BCs_RVEVolume.hpp:86
BCs_RVEVolume::feLhs
MyVolumeFE feLhs
Definition: BCs_RVEVolume.hpp:30
EntData
EntitiesFieldData::EntData EntData
Definition: child_and_parent.cpp:37
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
BCs_RVEVolume::MyVolumeFE
definition of volume element
Definition: BCs_RVEVolume.hpp:26
BCs_RVEVolume
Definition: BCs_RVEVolume.hpp:23
BCs_RVEVolume::OpVolumeCal::doWork
PetscErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSurcesCore::EntData &row_data, DataForcesAndSurcesCore::EntData &col_data)
Definition: BCs_RVEVolume.hpp:50
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
NonlinearElasticElement::BlockData::tEts
Range tEts
constrains elements in block set
Definition: HookeElement.hpp:36
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
BCs_RVEVolume::MyVolumeFE::MyVolumeFE
MyVolumeFE(MoFEM::Interface &_mField)
Definition: BCs_RVEVolume.hpp:27
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
BCs_RVEVolume::OpVolumeCal::RVE_volume_Vec
Vec RVE_volume_Vec
Definition: BCs_RVEVolume.hpp:42
BCs_RVEVolume::BCs_RVEVolume
BCs_RVEVolume(MoFEM::Interface &m_field)
Definition: BCs_RVEVolume.hpp:34