NeoPZ
TPZMeshSolution.cpp
Go to the documentation of this file.
1 //
2 // TPZMeshSolution.cpp
3 // PZ
4 //
5 // Created by Philippe Devloo on 30/10/16.
6 //
7 //
8 
9 #include "TPZMeshSolution.h"
10 #include "TPZMaterial.h"
11 #include "pzcmesh.h"
12 
13 //TPZCompMesh *fMesh;
14 //
15 //int64_t fGeoElIndex;
16 //
17 //TPZManVector<REAL,3> fLastLoc;
18 //
19 //int dimension;
20 //
21 //int fSolutionVarindex;
22 //
23 //int fGradVarindex;
24 //
25 //int fPolynomialOrder;
26 //
27 //public:
28 
32 fMesh(cmesh), fMaterialIndex(materialid)
33 {
34  fDimension = cmesh->Dimension();
36  TPZMaterial *material = cmesh->FindMaterial(materialid);
37  if (!material) {
38  DebugStop();
39  }
40  fSolutionVarindex = material->VariableIndex("Pressure");
41  fGradVarindex = material->VariableIndex("Derivative");
43  int64_t nel = cmesh->Reference()->NElements();
44  int64_t el;
45  for (el=0; el<nel; el++) {
46  TPZGeoEl *gel = fMesh->Reference()->Element(el);
47  if (gel && gel->Dimension() == fDimension) {
48  break;
49  }
50  }
51  if (el==nel) {
52  DebugStop();
53  }
54  fGeoElIndex = el;
55 }
56 
59 {
60 
61 }
62 
70 {
71  TPZManVector<REAL,3> xcopy(x);
74  TPZCompEl *cel = gel->Reference();
75  TPZManVector<STATE> sol(1), dsol(3);
77  cel->Solution(fLastLoc,fGradVarindex,dsol);
78  int maxd = 3;
79  if (df.Rows() < 3) {
80  maxd = df.Rows();
81  }
82  for (int is=0; is<fNumSolutions; is++) {
83  f[is] = sol[is];
84  for (int d=0; d<maxd; d++) {
85  df(d,is) = dsol[is*3+d];
86  }
87  }
88 }
89 
91 void TPZMeshSolution::Print(std::ostream &out)
92 {
93  out << __PRETTY_FUNCTION__ << std::endl;
94  out << "NFunctions = " << NFunctions() << std::endl;
95  out << "Polynomial Order = " << PolynomialOrder() << std::endl;
96 }
97 
98 
100  return Hash("TPZMeshSolution") ^ TPZFunction<STATE>::ClassId() << 1;
101 }
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Definition: pzcmesh.h:209
int fSolutionVarindex
variable index of the solution variable
int64_t fGeoElIndex
Geometric element index where the last point was found.
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
int64_t NElements() const
Number of elements of the mesh.
Definition: pzgmesh.h:129
TPZCompMesh * fMesh
Mesh for which the solution applies.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
int ClassId() const override
Define the class id associated with the class.
f
Definition: test.py:287
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
class which represents the solution and its derivative as a function
TPZGeoEl * Element(int64_t iel)
Definition: pzgmesh.h:139
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
int Dimension() const
Returns the dimension of the simulation.
Definition: pzcmesh.h:148
virtual int NFunctions() const override
Returns number of functions.
TPZMaterial * FindMaterial(int id)
Find the material with identity id.
Definition: pzcmesh.cpp:297
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
Definition: pzgeoel.h:750
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
virtual void Print(std::ostream &out) override
Print a brief statement.
TPZGeoEl * FindElement(TPZVec< REAL > &x, TPZVec< REAL > &qsi, int64_t &InitialElIndex, int targetDim) const
Returns the element that contains the given point x and it respective point in parametric domain qsi...
Definition: pzgmesh.cpp:579
Contains declaration of TPZCompMesh class which is a repository for computational elements...
~TPZMeshSolution()
Class destructor.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
virtual void Execute(const TPZVec< REAL > &x, TPZVec< STATE > &f, TPZFMatrix< STATE > &df) override
Performs function computation.
virtual int Dimension() const =0
Returns the dimension of the element.
int fNumSolutions
number of state variables of the differential equation
virtual int NSolutionVariables(int var)
Returns the number of variables associated with the variable indexed by var.
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
int fDimension
dimension of the problem
virtual void Solution(TPZVec< REAL > &qsi, int var, TPZVec< STATE > &sol)
Calculates the solution - sol - for the variable var at point qsi, where qsi is expressed in terms of...
Definition: pzcompel.cpp:421
int ClassId() const override
Define the class id associated with the class.
Definition: pzfunction.h:95
virtual int PolynomialOrder() const override
Polynomial order of this function.
int fGradVarindex
variable index of the gradient of the solution
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
TPZMeshSolution(TPZCompMesh *cmesh, int materialid)
Class constructor.
TPZManVector< REAL, 3 > fLastLoc
Parametric coordinate where the last point was found.