-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainMHMFunctions.cpp
229 lines (189 loc) · 5.87 KB
/
mainMHMFunctions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include "pzlog.h"
#include "pzgmesh.h"
#include "pzmanvector.h"
#include "TPZVTKGeoMesh.h"
#include "TPZGmshReader.h"
#include "pzpoisson3d.h"
#include "pzbndcond.h"
#include "pzanalysis.h"
#include "TPZSSpStructMatrix.h"
#include "pzskylstrmatrix.h"
#include "pzstepsolver.h"
#include "meshgen.h"
#ifndef USING_MKL
#include "pzskylstrmatrix.h"
#endif
TPZCompMesh *BuildComputationalMesh(TPZGeoMesh *gmesh, int pOrder);
#ifdef LOG4CXX
static LoggerPtr logger(Logger::getLogger("pz.mainskeleton"));
#endif
int const darcy = 1;
int const frac = 2;
int const bc1=-1;
int const bcfracpoint=-2;
int const bcpoint = -6;
struct BoundaryForce
{
int sidecount = 4;
void operator()(const TPZVec<REAL> &x, TPZVec<STATE> &func)
{
switch(sidecount)
{
case 0:
if(fabs(x[1]) < 1.e-6 && x[0] < 0.5)
{
func[0] = -4.*(1.-2.*x[0]);
}
break;
case 1:
if(fabs(x[1]-1.) < 1.e-6)
{
func[0] = -1.;
}
break;
case 2:
if(fabs(x[1]) < 1.e-6 && x[0] < 0.5)
{
func[0] = -2.;
}
break;
case 3:
if(fabs(x[1]) < 1.e-6 && x[0] > 0.5)
{
func[0] = -2.;
}
break;
case 4:
func[0] = 0.;
break;
case 5:
if(fabs(x[0]-1.) < 1.e-6)
{
func[0] = -1.;
}
break;
default:
DebugStop();
}
}
};
BoundaryForce bound;
void StupidFunc(const TPZVec<REAL> &x, TPZVec<STATE> &force)
{
bound(x,force);
}
TPZAnalyticSolution *example;
int main(int argc, char *argv[])
{
#ifdef LOG4CXX
InitializePZLOG();
#endif
TExceptionManager except;
TPZGeoMesh *gmesh = 0;
{
TPZGmshReader gmsh;
// Assigns IDs of 1D and 2D elements defining boundary conditions.
gmsh.GetDimNamePhysical()[1]["BC"] = bc1;
gmsh.GetDimNamePhysical()[0]["BC_POINT"] = bcpoint;
gmsh.GetDimNamePhysical()[0]["BC_FRACPOINT"] = bcfracpoint;
// Assigns IDs of 2D and 3D elements defining the problem domain.
gmsh.GetDimNamePhysical()[2]["DARCY"] = 1;
gmsh.GetDimNamePhysical()[1]["FRAC"] = 2;
#ifdef MACOSX
gmesh = gmsh.GeometricGmshMesh("../MHMDFN_Functions.msh");
#else
gmesh = gmsh.GeometricGmshMesh("MHMDFN_Functions.msh");
#endif
}
#ifdef PZDEBUG
if(1)
{
std::ofstream file("GMeshDFN.vtk");
TPZVTKGeoMesh::PrintGMeshVTK(gmesh, file);
}
#endif
TPZCompMesh *cmesh = BuildComputationalMesh(gmesh, 2);
//calculo solution
bool shouldrenumber = true;
TPZAnalysis an(cmesh,shouldrenumber);
#ifdef USING_MKL
TPZSymetricSpStructMatrix strmat(cmesh);
strmat.SetNumThreads(0);
#else
TPZSkylineStructMatrix strmat(cmesh);
strmat.SetNumThreads(0);
#endif
an.SetStructuralMatrix(strmat);
TPZStepSolver<STATE> step;
step.SetDirect(ELDLt);
an.SetSolver(step);
std::cout << "Assembling\n";
for(int count = 0; count < 6; count++)
{
bound.sidecount = count;
if(bound.sidecount == 4)
{
TPZMaterial *mat = cmesh->FindMaterial(bcfracpoint);
TPZBndCond *bnd = dynamic_cast<TPZBndCond *>(mat);
if(!bnd) DebugStop();
bnd->Val2()(0,0) = -1.;
}
an.Assemble();
an.Solve();
an.SetStep(count);
std::string plotfile2("MHMFunc2D.vtk"),plotfile1("MHMFunc1D.vtk");
TPZStack<std::string> scalnames,vecnames;
scalnames.Push("Pressure");
vecnames.Push("Flux");
an.DefineGraphMesh(cmesh->Dimension()-1, scalnames, vecnames, plotfile1);
an.DefineGraphMesh(cmesh->Dimension(), scalnames, vecnames, plotfile2);
int resolution = 0;
// an.PostProcess(resolution,cmesh->Dimension()-1);
an.PostProcess(resolution,cmesh->Dimension());
}
return 0;
}
/// Insert material objects for the MHM Mesh solution
TPZCompMesh *BuildComputationalMesh(TPZGeoMesh *gmesh, int pOrder)
{
TPZCompMesh *cmeshptr = new TPZCompMesh(gmesh);
TPZCompMesh &cmesh = *cmeshptr;
int dim = gmesh->Dimension();
int dirichlet = 0;
int neumann = 1;
// Creates Poisson material
TPZMatPoisson3d *material = new TPZMatPoisson3d(darcy, dim);
material->SetInternalFlux(-1.);
cmesh.SetDimModel(dim);
cmesh.InsertMaterialObject(material);
{
TPZMatPoisson3d *material = new TPZMatPoisson3d(frac, dim-1);
TPZManVector<REAL,3> convdir(3,0.);
material->SetParameters(100., 0., convdir);
cmesh.InsertMaterialObject(material);
}
// TPZMaterial * mat(material);
// cmesh->InsertMaterialObject(mat);
// Inserts boundary conditions
TPZFMatrix<STATE> val1(2, 2, 0.), val2(2, 1, 0.);
{
TPZMaterial * BCond = material->CreateBC(material, bc1, neumann, val1, val2);
TPZDummyFunction<STATE> *dummy = new TPZDummyFunction<STATE>(StupidFunc,2);
TPZAutoPointer<TPZFunction<STATE> > autofunc(dummy);
BCond->SetForcingFunction(autofunc);
cmesh.InsertMaterialObject(BCond);
}
{
TPZMaterial * BCond = material->CreateBC(material, bcfracpoint, neumann, val1, val2);
cmesh.InsertMaterialObject(BCond);
}
{
TPZMaterial * BCond = material->CreateBC(material, bcpoint, dirichlet, val1, val2);
cmesh.InsertMaterialObject(BCond);
}
cmesh.SetDefaultOrder(pOrder);
cmesh.SetAllCreateFunctionsContinuous();
// Adjusts computational data structure
cmesh.AutoBuild();
return cmeshptr;
}