v0.13.1
BCs_RVELagrange_Trac_Rigid_Trans.hpp
Go to the documentation of this file.
1/* This file is part of MoFEM.
2 * MoFEM is free software: you can redistribute it and/or modify it under
3 * the terms of the GNU Lesser General Public License as published by the
4 * Free Software Foundation, either version 3 of the License, or (at your
5 * option) any later version.
6 *
7 * MoFEM is distributed in the hope that it will be useful, but WITHOUT
8 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10 * License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
14
15#ifndef __BCS_RVELAGRANGE_TRAC_RIGID_TRANS_HPP
16#define __BCS_RVELAGRANGE_TRAC_RIGID_TRANS_HPP
17
19
21 BCs_RVELagrange_Disp(m_field) {}
22
23 /// \biref operator to calculate the LHS for the RVE bounary conditions
25
27 Mat Aij;
28 OpRVEBCsLhs(const string field_name, const string lagrang_field_name,Mat aij,RVEBC_Data &data):
30 lagrang_field_name,field_name,UserDataOperator::OPROWCOL
31 ),
32 dAta(data),Aij(aij) {
33 //This will make sure to loop over all intities (e.g. for order=2 it will make doWork to loop 16 time)
34 sYmm = false;
35 }
36
39
40 PetscErrorCode doWork(
41 int row_side,int col_side,
42 EntityType row_type,EntityType col_type,
45 ) {
46 PetscFunctionBegin;
47
48 try {
49 if(row_data.getIndices().size()==0) PetscFunctionReturn(0);
50 if(col_data.getIndices().size()==0) PetscFunctionReturn(0);
51 if(col_type==MBVERTEX) {
52
53 auto weak_ptr_dof =
54 getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(
55 col_data.getIndices()[0]);
56 const FENumeredDofEntity *dof_ptr;
57 if (auto ptr = weak_ptr_dof.lock())
58 dof_ptr = ptr.get();
59 else
60 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Dof not found");
61
62 int rank = dof_ptr->getNbOfCoeffs();
63
64 Mat_face.resize(rank,3*rank);
65 Mat_face.clear();
66 Mat_face_Tran.resize(3*rank,rank);
67 Mat_face_Tran.clear();
68
69 switch(rank) {
70 case 3:
71 for(int nn=0; nn<3; nn++){
72 Mat_face(0,3*nn+0) = 1.0;
73 Mat_face(1,3*nn+1) = 1.0;
74 Mat_face(2,3*nn+2) = 1.0;
75 }
76 break;
77 case 1:
78 Mat_face(0,0) = 1.0;
79 Mat_face(0,1) = 1.0;
80 Mat_face(0,2) = 1.0;
81 break;
82 default:
83 SETERRQ(PETSC_COMM_SELF,1,"not implemented");
84 }
85
86 // Matrix C1
87 int nb_rows=row_data.getIndices().size();
88 int nb_cols=col_data.getIndices().size();
90 Aij,nb_rows,&row_data.getIndices()[0],nb_cols,&col_data.getIndices()[0],&Mat_face(0,0),ADD_VALUES
91 ); CHKERRQ(ierr);
92
93 // Matrix C1T
94 noalias(Mat_face_Tran) = trans(Mat_face);
96 Aij,nb_cols,&col_data.getIndices()[0],nb_rows,&row_data.getIndices()[0],&Mat_face_Tran(0,0),ADD_VALUES
97 ); CHKERRQ(ierr);
98
99 }
100 } catch (const std::exception& ex) {
101 ostringstream ss;
102 ss << "throw in method: " << ex.what() << endl;
103 SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
104 }
105 PetscFunctionReturn(0);
106 }
107 };
108
110 string field_name,string lagrang_field_name,Mat aij,map<int,RVEBC_Data> setOfRVEBC
111 ) {
112 PetscFunctionBegin;
113 map<int,RVEBC_Data>::iterator sit = setOfRVEBC.begin();
114 for(;sit!=setOfRVEBC.end();sit++) {
115 //LHS
116 feRVEBCLhs.getOpPtrVector().push_back(new OpRVEBCsLhs(field_name,lagrang_field_name,aij, sit->second));
117 }
118 PetscFunctionReturn(0);
119 }
120
121};
122
123#endif
ForcesAndSourcesCore::UserDataOperator UserDataOperator
EntitiesFieldData::EntData EntData
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
constexpr auto field_name
map< int, RVEBC_Data > setOfRVEBC
maps side set id with appropriate FluxData
\biref operator to calculate the LHS for the RVE bounary conditions
OpRVEBCsLhs(const string field_name, const string lagrang_field_name, Mat aij, RVEBC_Data &data)
PetscErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
PetscErrorCode setRVEBCsRigidBodyTranOperators(string field_name, string lagrang_field_name, Mat aij, map< int, RVEBC_Data > setOfRVEBC)
BCs_RVELagrange_Trac_Rigid_Trans(MoFEM::Interface &m_field)
Deprecated interface functions.