Skip to content

Commit 277dd06

Browse files
authored
Fiber direction spatial output seg fault 432 (SimVascular#435)
* Change file name. * Fix some indexing and scope bugs. * Add the 'Fiber_direction' Output command to the solver.xml file and update the result_001.vtu testing file.
1 parent aac9182 commit 277dd06

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

Code/Source/solver/post.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -681,27 +681,31 @@ void fib_dir_post(Simulation* simulation, const mshType& lM, const int nFn, Arra
681681
int Ac = lM.IEN(a,e);
682682
for (int i = 0; i < nsd; i++) {
683683
xl(i,a) = com_mod.x(i,Ac);
684+
}
685+
for (int i = 0; i < tDof; i++) {
684686
dl(i,a) = lD(i,Ac);
685687
}
686688
}
687689

688690
for (int iFn = 0; iFn < lM.nFn; iFn++) {
689691
for (int i = 0; i < nsd; i++) {
690-
fN(i,iFn) = lM.fN(iFn*nsd,e);
692+
fN(i,iFn) = lM.fN(i+iFn*nsd,e);
691693
}
692694
}
693695

694-
Array<double> F;
696+
Array<double> F(nsd,nsd);
697+
Array<double> Nx(nsd,eNoN);
698+
double Jac = 0.0;
695699

696700
for (int g = 0; g < lM.nG; g++) {
697-
double Jac = 0.0;
698701
if (g == 0 || !lM.lShpF) {
699-
auto Nx = lM.Nx.slice(g);
700-
nn::gnn(eNoN, nsd, nsd, Nx, xl, Nx, Jac, F);
702+
auto Nxi = lM.Nx.slice(g);
703+
nn::gnn(eNoN, nsd, nsd, Nxi, xl, Nx, Jac, F);
701704
}
702705

703706
double w = lM.w(g) * Jac;
704-
auto F = mat_fun::mat_id(nsd);
707+
N = lM.N.col(g);
708+
F = mat_fun::mat_id(nsd);
705709

706710
for (int a = 0; a < eNoN; a++) {
707711
if (nsd == 3) {
@@ -749,11 +753,12 @@ void fib_dir_post(Simulation* simulation, const mshType& lM, const int nFn, Arra
749753
for (int a = 0; a < lM.nNo; a++) {
750754
int Ac = lM.gN(a);
751755
if (!utils::is_zero(sA(Ac))) {
752-
for (int i = 0; i < nsd; i++) {
756+
for (int i = 0; i < nFn*nsd; i++) {
753757
res(i,a) = res(i,a) + sF(i,Ac) / sA(Ac);
754-
}
758+
}
755759
}
756760
}
761+
757762
}
758763

759764
/// @brief Compute fiber stretch based on 4th invariant: I_{4,f}

Code/Source/solver/vtk_xml.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ void do_test()
8686
}
8787
}
8888

89-
std::cout << "Num dupe: " << num_dupe << std::endl;
90-
9189
vtkSmartPointer<vtkUnstructuredGrid> mesh;
9290

9391
std::string fileName = "mesh-complete/mesh-complete.mesh.vtu";
@@ -98,8 +96,6 @@ void do_test()
9896

9997
vtkIdType m_NumPoints = mesh->GetNumberOfPoints();
10098
vtkIdType m_NumCells = mesh->GetNumberOfCells();
101-
std::cout << " Number of points: " << m_NumPoints << std::endl;
102-
std::cout << " Number of cells: " << m_NumCells << std::endl;
10399

104100
auto numPoints = mesh->GetNumberOfPoints();
105101
auto points = mesh->GetPoints();
@@ -138,10 +134,6 @@ void do_test()
138134
}
139135
}
140136

141-
std::cout << "num_found_1: " << num_found_1 << std::endl;
142-
std::cout << "num_found_2: " << num_found_2 << std::endl;
143-
144-
//exit(0);
145137
}
146138

147139
/// @brief This routine prepares data array of a regular mesh
@@ -1171,11 +1163,11 @@ void write_vtus(Simulation* simulation, const Array<double>& lA, const Array<dou
11711163
post::fib_dir_post(simulation, msh, nFn, tmpV, lD, iEq);
11721164
}
11731165
for (int iFn = 0; iFn < nFn; iFn++) {
1166+
cOut = cOut + 1;
11741167
is = outS[cOut];
11751168
ie = is + l - 1;
11761169
outS[cOut+1] = ie + 1;
1177-
outNames[cOut] = eq.output[iOut].name + std::to_string(iFn);
1178-
cOut = cOut + 1;
1170+
outNames[cOut] = eq.output[iOut].name + std::to_string(iFn+1);
11791171

11801172
for (int a = 0; a < msh.nNo; a++) {
11811173
for (int i = 0; i < l; i++) {
@@ -1414,8 +1406,6 @@ void write_vtus(Simulation* simulation, const Array<double>& lA, const Array<dou
14141406
nSh = nSh + d[iM].nNo;
14151407
}
14161408

1417-
// std::cout << "nOut: " << nOut << std::endl;
1418-
14191409
// Writing all solutions
14201410
//
14211411
for (int iOut = 1; iOut < nOut; iOut++) {
@@ -1436,9 +1426,6 @@ void write_vtus(Simulation* simulation, const Array<double>& lA, const Array<dou
14361426
nSh = nSh + d[iM].nNo;
14371427
}
14381428

1439-
// std::cout << "iOut: " << iOut << std::endl;
1440-
// std::cout << "outName: " << outNames[iOut] << std::endl;
1441-
14421429
vtk_writer->set_point_data(outNames[iOut], tmpV);
14431430
}
14441431

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:28755d0b759cc113191b1f54abee26fa67e98e15d1456ee55f79f34e4833b033
3-
size 1869197
2+
oid sha256:596c2cd4a299b1cbe1290a04f1175c50eae2a8f5514e40089f421fb88fd7bf23
3+
size 2148967

tests/cases/struct/LV_HolzapfelOgden_active/solver.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
<VonMises_stress> true </VonMises_stress>
9191
<Cauchy_stress> true </Cauchy_stress>
9292
<Def_grad> true </Def_grad>
93+
<Fiber_direction> true </Fiber_direction>
9394
</Output>
9495

9596
<LS type="GMRES" >

0 commit comments

Comments
 (0)