v0.15.0
Loading...
Searching...
No Matches
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
22
23 /// \biref operator to calculate the LHS for the RVE bounary conditions
24 struct OpRVEBCsLhs:public FaceElementForcesAndSourcesCore::UserDataOperator {
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
37 MatrixDouble Mat_face;
38 MatrixDouble Mat_face_Tran;
39
40 PetscErrorCode doWork(
41 int row_side,int col_side,
42 EntityType row_type,EntityType col_type,
43 DataForcesAndSurcesCore::EntData &row_data,
44 DataForcesAndSurcesCore::EntData &col_data
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
54 const FENumeredDofEntity *dof_ptr;
55 ierr = getNumeredEntFiniteElementPtr()->getColDofsByPetscGlobalDofIdx(col_data.getIndices()[0],&dof_ptr); CHKERRQ(ierr);
56 int rank = dof_ptr->getNbOfCoeffs();
57
58 Mat_face.resize(rank,3*rank);
59 Mat_face.clear();
60 Mat_face_Tran.resize(3*rank,rank);
61 Mat_face_Tran.clear();
62
63 switch(rank) {
64 case 3:
65 for(int nn=0; nn<3; nn++){
66 Mat_face(0,3*nn+0) = 1.0;
67 Mat_face(1,3*nn+1) = 1.0;
68 Mat_face(2,3*nn+2) = 1.0;
69 }
70 break;
71 case 1:
72 Mat_face(0,0) = 1.0;
73 Mat_face(0,1) = 1.0;
74 Mat_face(0,2) = 1.0;
75 break;
76 default:
77 SETERRQ(PETSC_COMM_SELF,1,"not implemented");
78 }
79
80 // Matrix C1
81 int nb_rows=row_data.getIndices().size();
82 int nb_cols=col_data.getIndices().size();
83 ierr = MatSetValues(
84 Aij,nb_rows,&row_data.getIndices()[0],nb_cols,&col_data.getIndices()[0],&Mat_face(0,0),ADD_VALUES
85 ); CHKERRQ(ierr);
86
87 // Matrix C1T
88 noalias(Mat_face_Tran) = trans(Mat_face);
89 ierr = MatSetValues(
90 Aij,nb_cols,&col_data.getIndices()[0],nb_rows,&row_data.getIndices()[0],&Mat_face_Tran(0,0),ADD_VALUES
91 ); CHKERRQ(ierr);
92
93 }
94 } catch (const std::exception& ex) {
95 ostringstream ss;
96 ss << "throw in method: " << ex.what() << endl;
97 SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
98 }
99 PetscFunctionReturn(0);
100 }
101 };
102
104 string field_name,string lagrang_field_name,Mat aij,map<int,RVEBC_Data> setOfRVEBC
105 ) {
106 PetscFunctionBegin;
107 map<int,RVEBC_Data>::iterator sit = setOfRVEBC.begin();
108 for(;sit!=setOfRVEBC.end();sit++) {
109 //LHS
110 feRVEBCLhs.getOpPtrVector().push_back(new OpRVEBCsLhs(field_name,lagrang_field_name,aij, sit->second));
111 }
112 PetscFunctionReturn(0);
113 }
114
115};
116
117#endif
static PetscErrorCode ierr
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
PetscErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSurcesCore::EntData &row_data, DataForcesAndSurcesCore::EntData &col_data)
OpRVEBCsLhs(const string field_name, const string lagrang_field_name, Mat aij, RVEBC_Data &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.