Skip to content

Commit

Permalink
vtkpy folder added
Browse files Browse the repository at this point in the history
  • Loading branch information
mojumder17 committed Aug 16, 2022
1 parent 0dd1bc0 commit 60709ed
Show file tree
Hide file tree
Showing 199 changed files with 11,926 additions and 0 deletions.
54 changes: 54 additions & 0 deletions vtk_py/BiV.geo
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Geometry.HideCompounds = 1;

Mesh.CharacteristicLengthFactor = <<Meshsize>> ;// Fine

Mesh.Algorithm = 6; // (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=bamg, 8=delquad) (Default=2)
Mesh.RecombineAll = 0;

Mesh.RemeshAlgorithm = 1; // (0=no split, 1=automatic, 2=automatic only with metis) (Default=0)

Mesh.RemeshParametrization = 7; // (0=harmonic_circle, 1=conformal_spectral, 2=rbf, 3=harmonic_plane, 4=convex_circle, 5=convex_plane, 6=harmonic square, 7=conformal_fe) (Default=4)

Mesh.Algorithm3D = 4; // (1=Delaunay, 4=Frontal, 5=Frontal Delaunay, 6=Frontal Hex, 7=MMG3D, 9=R-tree) (Default=1)
Mesh.Recombine3DAll = 0;

Mesh.Optimize = 1;
Mesh.OptimizeNetgen = 1;

Mesh.Smoothing = 0;

Merge <<LVfilename>>;
Merge <<RVfilename>>;
Merge <<Epifilename>>;

CreateTopology;

ll[] = Line "*";
L_LV_base = newl; Compound Line(L_LV_base) = ll[2];
L_RV_base = newl; Compound Line(L_RV_base) = ll[0];
L_epi_base = newl; Compound Line(L_epi_base) = ll[1];
// Physical Line("EPI_BASE") = {L_epi_base};
//Physical Line(0) = {L_epi_base};

ss[] = Surface "*";
S_LV = news; Compound Surface(S_LV) = ss[0];
S_RV = news; Compound Surface(S_RV) = ss[1];
S_epi = news; Compound Surface(S_epi) = ss[2];
// Physical Surface("LV") = {S_LV};
// Physical Surface("RV") = {S_RV};
// Physical Surface("epi") = {S_epi};
//Physical Surface(3) = {S_epi};
//Physical Surface(1) = {S_RV};
//Physical Surface(2) = {S_LV};


LL_base = newll; Line Loop(LL_base) = {L_LV_base, L_RV_base, L_epi_base};
S_base = news; Plane Surface(S_base) = {LL_base};
// Physical Surface("BASE") = {S_base};
//Physical Surface(4) = {S_base};

SL_wall = newsl; Surface Loop(SL_wall) = {S_LV, S_RV, S_epi, S_base};
V_wall = newv; Volume(V_wall) = {SL_wall};
//Physical Volume("WALL") = {V_wall};
Physical Volume(0) = {V_wall};

19 changes: 19 additions & 0 deletions vtk_py/CreateVertexFromPoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
########################################################################

import sys
import vtk

########################################################################

def CreateVertexFromPoint(ugrid):

vertices = vtk.vtkCellArray()
for p in range(ugrid.GetNumberOfPoints()):
vert = vtk.vtkVertex()
vert.GetPointIds().SetId(0, p)
vertices.InsertNextCell(vert)

ugrid.SetCells(1, vertices)



Binary file added vtk_py/CreateVertexFromPoint.pyc
Binary file not shown.
74 changes: 74 additions & 0 deletions vtk_py/LV.geo
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Geometry.HideCompounds = 1;

Mesh.CharacteristicLengthFactor = <<mesh_d>>; // Coarse

Mesh.Algorithm = 6; // (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=bamg, 8=delquad) (Default=2)
Mesh.RecombineAll = 0;

Mesh.RemeshAlgorithm = 1; // (0=no split, 1=automatic, 2=automatic only with metis) (Default=0)

Mesh.RemeshParametrization = 7; // (0=harmonic_circle, 1=conformal_spectral, 2=rbf, 3=harmonic_plane, 4=convex_circle, 5=convex_plane, 6=harmonic square, 7=conformal_fe) (Default=4)

Mesh.Algorithm3D = 4; // (1=Delaunay, 4=Frontal, 5=Frontal Delaunay, 6=Frontal Hex, 7=MMG3D, 9=R-tree) (Default=1)
Mesh.Recombine3DAll = 0;

Mesh.Optimize = 1;
Mesh.OptimizeNetgen = 1;

Mesh.Smoothing = 0;

Merge "<<Endofilename>>";
Merge "<<Epifilename>>";

CreateTopology;

ll[] = Line "*";
L_LV_base = newl; Compound Line(L_LV_base) = ll[1];
L_epi_base = newl; Compound Line(L_epi_base) = ll[0];
//Physical Line("EPI_BASE") = {L_epi_base};

ss[] = Surface "*";
S_LV = news; Compound Surface(S_LV) = ss[0];
S_epi = news; Compound Surface(S_epi) = ss[1];
Physical Surface("LV") = {S_LV};
Physical Surface("epi") = {S_epi};

LL_base = newll; Line Loop(LL_base) = {L_LV_base, L_epi_base};
S_base = news; Plane Surface(S_base) = {LL_base};
Physical Surface("BASE") = {S_base};

SL_wall = newsl; Surface Loop(SL_wall) = {S_LV, S_epi, S_base};
V_wall = newv; Volume(V_wall) = {SL_wall};
Physical Volume("WALL") = {V_wall};


//
//// P1 = newp; Point(P1) = {36., 74., 70.};
//// Field[1] = Attractor;
//// Field[1].NodesList = {P1};
//// Field[2] = Threshold;
//// Field[2].IField = 1;
//// Field[2].LcMin = 100.;
//// Field[2].LcMax = 100.;
//// Field[2].DistMin = 0.;
//// Field[2].DistMax = 10.;
//// Background Field = 2;
//
//// Field[1] = Box;
//// Field[1].VIn = 5.;
//// Field[1].VOut = 5.;
//// Field[1].XMin = 30.;
//// Field[1].XMax = 40.;
//// Field[1].YMin = 70.;
//// Field[1].YMax = 80.;
//// Field[1].ZMin = 69.;
//// Field[1].ZMax = 71.;
//// Background Field = 1;








74 changes: 74 additions & 0 deletions vtk_py/LV_original.geo
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Geometry.HideCompounds = 1;

Mesh.CharacteristicLengthFactor = <<mesh_d>>; // Coarse

Mesh.Algorithm = 6; // (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=bamg, 8=delquad) (Default=2)
Mesh.RecombineAll = 0;

Mesh.RemeshAlgorithm = 1; // (0=no split, 1=automatic, 2=automatic only with metis) (Default=0)

Mesh.RemeshParametrization = 7; // (0=harmonic_circle, 1=conformal_spectral, 2=rbf, 3=harmonic_plane, 4=convex_circle, 5=convex_plane, 6=harmonic square, 7=conformal_fe) (Default=4)

Mesh.Algorithm3D = 4; // (1=Delaunay, 4=Frontal, 5=Frontal Delaunay, 6=Frontal Hex, 7=MMG3D, 9=R-tree) (Default=1)
Mesh.Recombine3DAll = 0;

Mesh.Optimize = 1;
Mesh.OptimizeNetgen = 1;

Mesh.Smoothing = 0;

Merge "<<Endofilename>>";
Merge "<<Epifilename>>";

CreateTopology;

ll[] = Line "*";
L_LV_base = newl; Compound Line(L_LV_base) = ll[1];
L_epi_base = newl; Compound Line(L_epi_base) = ll[0];
//Physical Line("EPI_BASE") = {L_epi_base};

ss[] = Surface "*";
S_LV = news; Compound Surface(S_LV) = ss[0];
S_epi = news; Compound Surface(S_epi) = ss[1];
Physical Surface("LV") = {S_LV};
Physical Surface("epi") = {S_epi};

LL_base = newll; Line Loop(LL_base) = {L_LV_base, L_epi_base};
S_base = news; Plane Surface(S_base) = {LL_base};
Physical Surface("BASE") = {S_base};

SL_wall = newsl; Surface Loop(SL_wall) = {S_LV, S_epi, S_base};
V_wall = newv; Volume(V_wall) = {SL_wall};
Physical Volume("WALL") = {V_wall};


//
//// P1 = newp; Point(P1) = {36., 74., 70.};
//// Field[1] = Attractor;
//// Field[1].NodesList = {P1};
//// Field[2] = Threshold;
//// Field[2].IField = 1;
//// Field[2].LcMin = 100.;
//// Field[2].LcMax = 100.;
//// Field[2].DistMin = 0.;
//// Field[2].DistMax = 10.;
//// Background Field = 2;
//
//// Field[1] = Box;
//// Field[1].VIn = 5.;
//// Field[1].VOut = 5.;
//// Field[1].XMin = 30.;
//// Field[1].XMax = 40.;
//// Field[1].YMin = 70.;
//// Field[1].YMax = 80.;
//// Field[1].ZMin = 69.;
//// Field[1].ZMax = 71.;
//// Background Field = 1;








62 changes: 62 additions & 0 deletions vtk_py/Set4ChamberDirection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
########################################################################
import argparse
import numpy as np
from dolfin import *
import math
########################################################################


def Set4ChamberDirection(mesh, outfilename, apexC, apexR, basalC, basalN, outdirectory="./"):


def BCbase(x, on_boundary):
basalNorm = np.linalg.norm(basalN)
basalNN = 1.0/basalNorm*np.array(basalN)

return (x[0] - basalC[0])*basalNN[0] + (x[1] - basalC[1])*basalNN[1] < DOLFIN_EPS and on_boundary

def BCapex(x, on_boundary):
return (x[0] - apexC[0])**2 + (x[1] - apexC[1])**2 < apexR[0]**2 and on_boundary


V = FunctionSpace(mesh, 'Lagrange', 1)
u0 = Constant(1.0)
u1 = Constant(0.0)

bc =[DirichletBC(V, u1, BCapex), DirichletBC(V, u0, BCbase)]

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0)
a = inner(nabla_grad(u), nabla_grad(v))*dx
L = f*v*dx

# Compute solution
u = Function(V)
solve(a == L, u, bc)
u_a = u.vector().array()

# Compute gradient
V_g = VectorFunctionSpace(mesh, 'Lagrange', 1)
v = TestFunction(V_g)
w = TrialFunction(V_g)

a = inner(w, v)*dx
L = inner(grad(u), v)*dx
grad_u = Function(V_g)
solve(a == L, grad_u)
#normalize_grad_u = project(grad_u/sqrt(dot(grad_u, grad_u)), V_g)
grad_u.rename('matdir', 'matdir')

#plot(normalize_grad_u, interactive=True)
pvdoutfile = outdirectory+outfilename+"_matdir.pvd"
file15 = File(pvdoutfile)
file15 << grad_u

#plot(normalize_grad_u, interactive=True)
pvdoutfile2 = outdirectory+outfilename+"_dirsoln.pvd"
file16 = File(pvdoutfile2)
file16 << u


Binary file added vtk_py/Set4ChamberDirection.pyc
Binary file not shown.
Loading

0 comments on commit 60709ed

Please sign in to comment.