v0.15.0
Loading...
Searching...
No Matches
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
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 */
41 struct OpVolumeCal: public VolumeElementForcesAndSourcesCore::UserDataOperator {
45
46 OpVolumeCal(MoFEM::Interface &m_field, string field_name, Vec _RVE_volume_Vec, NonlinearElasticElement::BlockData &data):
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,
53 DataForcesAndSurcesCore::EntData &row_data,
54 DataForcesAndSurcesCore::EntData &col_data) {
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__
static PetscErrorCode ierr
#define MYPCOMM_INDEX
default communicator number PCOMM
constexpr auto field_name
definition of volume element
MyVolumeFE(MoFEM::Interface &_mField)
NonlinearElasticElement::BlockData & dAta
MoFEM::Interface & mField
PetscErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSurcesCore::EntData &row_data, DataForcesAndSurcesCore::EntData &col_data)
OpVolumeCal(MoFEM::Interface &m_field, string field_name, Vec _RVE_volume_Vec, NonlinearElasticElement::BlockData &data)
BCs_RVEVolume(MoFEM::Interface &m_field)
MoFEM::Interface & mField
PetscErrorCode setRVEVolumeOperators(MoFEM::Interface &mField, string field_name, Vec _RVE_volume_Vec, map< int, NonlinearElasticElement::BlockData > &setOfBlocks)
MyVolumeFE feLhs
MyVolumeFE & getLoopFeLhs()
get lhs volume element
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
data for calculation heat conductivity and heat capacity elements
Range tEts
constrains elements in block set