NeoPZ
pznlmat1d.cpp
Go to the documentation of this file.
1 
6 #include "pznlmat1d.h"
7 #include "TPZMaterial.h"
8 #include "pzconnect.h"
9 #include "pzbndcond.h"
10 #include "pzerror.h"
11 #include "pzvec.h"
12 
13 #include <math.h>
14 using namespace std;
15 
17 {}
18 
19 
21 {}
22 
23 void TPZNLMat1d::Contribute(TPZMaterialData &data, REAL weight,
25  TPZFMatrix<REAL> &dphi = data.dphix;
26  TPZFMatrix<REAL> &phi = data.phi;
27 // TPZManVector<REAL,3> &x = data.x;
28 
29  // this method adds the contribution of the material to the stiffness
30  // matrix and right hand side
31 
32  // check on the validity of the arguments
33 
34  if(phi.Cols() != 1 || dphi.Rows() != 1 || phi.Rows() != dphi.Cols()){
35  PZError << "TPZMat1dLin.contr, inconsistent input data : phi.Cols() = "
36  << phi.Cols() << " dphi.Cols + " << dphi.Cols() <<
37  " phi.Rows = " << phi.Rows() << " dphi.Rows = " <<
38  dphi.Rows() << "\n";
39  }
40 
41  // IT IS NOT IMPLEMENTED
42 
43 /* if(fForcingFunction) {
44  TPZManVector<REAL> xfloat(fXf.Rows());
45  fForcingFunction->Execute(x,xfloat);//fXf = xfloat
46  int i;
47  for(i=0; i<fXf.Rows(); i++) fXf(i,0) = xfloat[i];
48  }
49  int r = fXk.Rows();
50  int c = fXk.Cols();
51  TPZFMatrix<REAL> submat(r,c);
52  for(int in=0 ; in < phi.Rows() ; ++in){
53  ef.AddSub(in*r, 0, (fXf*(phi(in,0)*weight)));
54  for(int jn=0 ; jn<phi.Rows() ; ++jn){
55  submat = fXb*(phi(in,0)*phi(jn,0)*weight);
56  submat += fXk*(dphi(0,in)*dphi(0,jn)*weight);
57  submat += fXc*(phi(in,0)*dphi(0,jn)*weight);
58  ek.AddSub(in*r,jn*c,submat);
59  }
60  }
61  */
62 }
63 
64 void TPZNLMat1d::ContributeBC(TPZMaterialData &data, REAL weight,
66  TPZBndCond &bc) {
67 
68 // TPZFMatrix<REAL> &phi = data.phi;
69 
70  // this method applies the boundary condition itype to ek and ef
71 
72  if(bc.Material() != this){
73  PZError << "TPZMat1dLin.apply_bc warning : this material didn't create the boundary condition!\n";
74  }
75 
76  if(bc.Type() < 0 && bc.Type() > 2){
77  PZError << "TPZMat1dLin.aplybc, unknown boundary condition type :" <<
78  bc.Type() << " boundary condition ignored\n";
79  }
80 // int bcv1r,bcv1c,bcv2r,bcv2c;
81 
82  // IT IS NOT IMPLEMENTED YET
83 
84 /* int r = fXk.Rows();
85  int numnod = ek.Rows()/r;
86  bcv1r = bc.Val1().Rows();
87  bcv1c = bc.Val1().Cols();
88  bcv2r = bc.Val2().Rows();
89  bcv2c = bc.Val1().Cols();
90  if( bcv1r != r ||
91  bcv1c != r ||
92  bcv2r != r ||
93  bcv2c != 1 ) {
94  PZError << "TPZMat1dLin.aplybc, incompatible number of degrees of " <<
95  "freedom, \n"
96  " val1.Rows =" << bc.Val1().Rows() << " xk.Rows = " << fXk.Rows() << "\n"
97  " val2.Cols() = " << bc.Val2().Cols() << " val2.Rows() = " << bc.Val2().Rows() << "\n"
98  " val1.Cols() = " << bc.Val1().Cols() << "\n";
99  }
100 
101  int idf,jdf,in,jn;
102  switch(bc.Type()){
103 
104  case 0:
105  for(in=0 ; in<numnod ; ++in){
106  for(idf = 0;idf<r;idf++) {
107  (ef)(in*r+idf,0) += gBigNumber*phi(in,0)*bc.Val2()(idf,0)*weight;
108  }
109  for(jn=0 ; jn<numnod ; ++jn) {
110  for(idf = 0;idf<r;idf++) {
111  ek(in*r+idf,jn*r+idf) += gBigNumber*phi(in,0)*phi(jn,0)*weight;
112  }
113  }
114  }
115  break;
116 
117  case 1:
118  for(in=0 ; in<numnod ; ++in){
119  for(idf = 0;idf<r;idf++) {
120  (ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
121  }
122  }
123  break;
124 
125  case 2:
126  for(in=0 ; in<numnod ; ++in){
127  for(idf = 0;idf<r;idf++) {
128  (ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
129  }
130  for(jn=0 ; jn<numnod ; ++jn) {
131  for(idf = 0;idf<r;idf++) {
132  for(jdf = 0;jdf<r;jdf++) {
133  ek(in*r+idf,jn*r+jdf) += bc.Val1()(idf,jdf)*phi(in,0)*phi(jn,0)*weight;
134  }
135  }
136  }
137  }
138  break;
139 
140  }
141  */
142 }
143 
144 void TPZNLMat1d::Print(std::ostream & out){
145 
146  out << "Material type TPZNLMat1D -- number = " << Id() << "\n";
147 // out << "Matrix xk -> "; fXk.Print("fXk",out);
148 // out << "Matrix xc -> "; fXc.Print("fXc",out);
149 // out << "Matrix xb -> "; fXb.Print("fXb",out);
150 // out << "Matrix xf -> "; fXf.Print("fXf",out);
151 }
152 
virtual ~TPZNLMat1d()
Default destructor.
Definition: pznlmat1d.cpp:20
clarg::argBool bc("-bc", "binary checkpoints", false)
int Type()
Definition: pzbndcond.h:249
Templated vector implementation.
Defines PZError.
TPZFNMatrix< 220, REAL > phi
vector of shapefunctions (format is dependent on the value of shapetype)
TPZFNMatrix< 660, REAL > dphix
values of the derivative of the shape functions
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
Contains declaration of TPZConnect class which represents a set of shape functions associated with a ...
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
TPZNLMat1d(int id)
Simple constructor.
Definition: pznlmat1d.cpp:16
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
Computes contribution to the right hand side at an integration point.
Definition: pznlmat1d.cpp:64
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
Computes contribution to the stiffness matrix and right hand side at an integration point...
Definition: pznlmat1d.cpp:23
int Id() const
Definition: TPZMaterial.h:170
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
Contains the TPZNLMat1d class which implements the structure to evaluate non linear elements...
virtual void Print(std::ostream &out=std::cout) override
Prints out the data associated with the material.
Definition: pznlmat1d.cpp:144
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
TPZMaterial * Material() const
Definition: pzbndcond.h:263