├── .gitignore
├── ADERBox
├── ADERWENOGlobals1D.m
├── ADERWENOInit1D.m
├── ADERWENOLagrPoly1D.m
├── ADERWENOReconstruct1D.m
├── ADERWENOTest1D.m
├── ADERWENOTest2D.m
├── ADERWENOTestDG1D.m
├── GaussQuad1D.m
├── GaussQuadCoefs.m
├── GaussQuadCoefs1D.m
├── LagInterpCoef.m
├── LagInterpPoly.m
├── NewtonRaphsonSolve.m
├── OscillationIndicatorMatrix.m
├── RescaledLegendrePolyCoef.m
├── RescaledLegendrePolyVal.m
├── SpaceTimeDGGlobals1D.m
├── SpaceTimeDGInit1D.m
├── SumPoly.m
└── TestScalarModel1D.m
├── AutoDiffBox
├── ADChain.m
├── ADScalar.m
├── Test.m
└── Test2.m
├── BEMBox
├── BEMPotential2D
│ ├── BemElemInteg.m
│ ├── BemLoadMesh.m
│ ├── BemMain2D.m
│ ├── BemMeshGlobals.m
│ ├── BemPlotMesh.m
│ ├── FmmBemMain2D.m
│ ├── FmmBisect.m
│ ├── FmmCalcRhs.m
│ ├── FmmDownward.m
│ ├── FmmGenTree2D.m
│ ├── FmmMatVec.m
│ ├── FmmMoment.m
│ ├── FmmPlotTree2D.m
│ ├── FmmTreeGlobals.m
│ ├── FmmUpward.m
│ ├── input.dat
│ ├── input_ring_M360.dat
│ └── input_square_M20.dat
├── BEMYukawa2D
│ ├── BemCoef.m
│ ├── BemLoadMesh.m
│ ├── BemMain2D.m
│ ├── BemMeshGlobals.m
│ ├── BemPlotMesh.m
│ ├── BemPotentialCoef2D.m
│ ├── BemProbGlobals.m
│ ├── MeshGenCircle.m
│ ├── MeshGenSquare.m
│ └── input.dat
├── BEMYukawa3D
│ ├── BemBuildConstElem.m
│ ├── BemBuildLinearElem.m
│ ├── BemBuildNodePatch.m
│ ├── BemCoef.m
│ ├── BemCoef2.m
│ ├── BemCoefLinear.m
│ ├── BemCoefNodePatch.m
│ ├── BemLoadMesh.m
│ ├── BemMain3D.m
│ ├── BemMeshGlobals.m
│ ├── CalcFreeEnergy.m
│ ├── LineGaussRule.m
│ ├── TriangleGaussInteg.m
│ ├── TriangleGaussRule.m
│ └── TriangleRadSingularInteg.m
├── CloseIntegral
│ ├── LineGaussRule.m
│ ├── TestCloseInteg.m
│ ├── TriangleGaussInteg.m
│ ├── TriangleGaussRule.m
│ └── TriangleRadSingularInteg.m
└── doc
│ └── 1-s2.0-S0955799706000105-main.pdf
├── CIPBox
├── CIPCSL2Test1D.m
└── CIPCSL3Test1D.m
├── CavityBox
├── CavityBox.m
├── apply_mac_bc.m
├── apply_pres_bc.m
├── mac_laplacian.m
├── mac_predictor.m
└── mac_rhs.m
├── CavityBox2
├── Book1.xlsx
├── CavityBox.m
├── apply_mac_bc.m
├── apply_pres_bc.m
├── mac_advect.m
├── mac_laplacian.m
├── mac_predictor.m
├── mac_rhs.m
├── mac_viscop.m
├── zzz.m
└── zzz2.m
├── ClusterBox
├── DLACircRadial.m
├── DLASimple2D.m
├── intersect_circ.m
└── plot_circ.m
├── ConvDiffBox
├── CIPAdvect2D.m
├── CIPTanITrans.m
├── CIPTanTrans.m
├── CIPTest1D.m
├── LSTest.m
├── LSTest2.m
├── RiderKotheVortex.m
├── RiderKotheVortexTracing.m
├── TransportTest1D.m
├── VOFWLIC2D.m
├── VOFWLIC_flux1d.m
├── VOFWLIC_normal2d.m
└── VOFWLIC_scalarBC2d.m
├── CouetteBox
├── EBGlobals.m
├── EBMainKarmanVortex.m
├── EBNSDriver.m
├── EBPPEAdaptedRhs.m
├── EBPPEApplyOp.m
├── EBPPEGenerateCoef.m
├── EBPPELapOp.m
├── EBPPERhs.m
├── EBPPESolvability.m
├── EBPPESolver.m
├── EBPPESolver_cg.m
├── EBSampleCellFrac.m
├── EBSampleCellInfo.m
├── EBSampleFaceFrac.m
├── EBVelocityDiffusion.m
├── MainCouetteFlow.m
├── MainCouetteFlowPM.m
├── MainCouetteFlowPMIB.m
├── PMVelocityLapOp.m
├── PMViscosity.m
├── PPELapOp.m
├── PPERhs.m
├── PressureBC.m
├── ProbDistFunc.m
├── ProbVelFunc.m
├── VelocityBC.m
├── VelocityConvection.m
├── VelocityCorrector.m
├── VelocityDiffusion.m
├── VelocityInterpIB.m
├── VelocityLapOp.m
├── VelocityLapRhs.m
└── VelocityPredictor.m
├── CubeChoppingBox
├── CubeChopGetVolume.m
├── CubeChopGetVolume2D.m
├── CubeChoppingGlobals.m
├── CubeChoppingTest.m
├── StdChopGetIntercept.m
├── StdChopGetVolume.m
└── StdChopGetVolume2D.m
├── DEMBox
└── ContactPotential
│ ├── CornerApprox.m
│ ├── CornerDeriv.m
│ ├── CornerPotential.m
│ ├── ImplicitFuncReinit.m
│ ├── MakeCorner.m
│ ├── MakeEllipse.m
│ ├── MakeGridSDF.m
│ ├── MakeSDF.m
│ ├── MakeShapeGrid.m
│ ├── MakeSuperEllipse.m
│ ├── MakeWall.m
│ ├── PlotSDF.m
│ ├── PlotShape.m
│ ├── RotationMatrix.m
│ ├── SDFPotential.m
│ ├── SafeInvert.m
│ ├── ShapeConstraint.m
│ ├── ShapePotential.m
│ ├── SolveContactPotential.m
│ ├── SolveContactSDF.m
│ ├── SolveContactSDF2.m
│ ├── SolveContactWall.m
│ ├── SolveIntersectPotential.m
│ ├── TestContact1.m
│ ├── TestContact2.m
│ ├── TestCorner.m
│ ├── TestGenSph.m
│ ├── TestImplicitFunc.m
│ ├── TestSDF1.m
│ ├── TestSDF2.m
│ ├── TestSuperEllipse.m
│ └── WallPotential.m
├── EBBox
├── EBGlobals.m
├── EBMainChannelFlow.m
├── EBMainKarmanVortex.m
├── EBMainKarmanVortex2.m
├── EBNSDriver.m
├── EBPPEApplyOp.m
├── EBPPEGenerateCoef.m
├── EBPPELapOp.m
├── EBPPERhs.m
├── EBPPESolver.m
├── EBPPESolver_cg.m
├── PPELapOp.m
├── PPERhs.m
├── PressureBC.m
├── VelocityBC.m
├── VelocityCorrector.m
├── VelocityDiffusion.m
├── VelocityLapOp.m
├── VelocityLapRhs.m
└── VelocityPredictor.m
├── EFGBox
├── efg1d
│ ├── efg1d.m
│ └── fem1d.m
└── efg2d.m
├── ElectricalDoubleLayerBox
├── AdaptModSphBesselI.m
├── AdaptModSphBesselK.m
├── EnergyTwoBodyConstPotent.m
├── FuncA.m
├── FuncB.m
├── LegendrePoly.m
├── ModSphBesselI.m
├── ModSphBesselK.m
├── ReExpCalcR.m
├── ReExpCalcS.m
├── ReExpFuncRegular.m
├── ReExpFuncSingular.m
├── ReExpMat.m
├── ReExpSimpleRot.m
├── RecurModSphBesselI.m
├── RecurModSphBesselI2.m
├── RecurModSphBesselK.m
├── RecurModSphBesselK2.m
├── RecurModSphBesselK3.m
├── SignNonNeg.m
├── SolveTwoBodyConstPotent.m
├── SphHarmReexpandApply.m
├── SphHarmY.m
├── TestFuncInteg.m
├── TestMultiBody.m
├── TestReexpansion.m
├── TestReexpansion2.m
├── TestReexpansionRotate.m
├── TestReexpansionRotate2.m
├── TestReexpansionRotate3.m
├── TestTwoBody.m
├── TestTwoBody.xlsx
├── TestTwoBody2.m
├── double_factorial.m
├── sh_cart2sph.m
└── sh_sub2ind.m
├── ElectroKineticBox
├── BoltzmannDistrib.m
├── CalcGradPhi.m
├── CalcPartFrac.m
├── CalcPartSDF.m
├── CellInterpCoef2D.m
├── EKConst.m
├── EKInitConst.m
├── GhostIBTag.m
├── GridInterpCoef2D.m
├── HeatNoFlux2D.m
├── LaplacianOp2D.m
├── MakeLap2D.m
├── MakeLap2Da.m
├── ModifyLap2D.m
├── PB1D.m
├── PBTestCheckSum.m
├── PBTestForcing2D.m
├── PBTestPlotIon.m
├── PBTestPlotSol.m
├── PBTestSetup2D.m
├── PBTestSmooth2D.m
├── PNP1D.m
├── PNPSolveSpec.m
├── PNPTestForcing2D.m
├── PNPTestPlotSol.m
├── PNPTestSetup2D.m
├── SharpIBTag.m
├── SharpIntegTest2D.m
├── SurfaceAreaTest2D.m
├── TestFlux2D.m
├── TestFluxForcing2D.m
└── TestFluxForcingIter2D.m
├── FDPM2Box
├── +material
│ └── VonMises.m
├── 3d
│ ├── fdpm3dFormB.m
│ ├── fdpm3dFormDsig.m
│ └── fdpm3dFormG.m
├── Contents.m
├── README.md
├── SpMatAssem.m
├── fdpmCalcLmat.m
├── fdpmDriverBuildConn.m
├── fdpmDriverBuildConnMLS.m
├── fdpmDriverBuildTri.m
├── fdpmDriverCalcBndryForce.m
├── fdpmDriverCalcStab.m
├── fdpmDriverPlotNodes.m
├── fdpmDriverWriteCsv.m
├── fdpmFormAmat.m
├── fdpmFormBmat.m
├── fdpmFormFmat.m
├── fdpmFormGmat.m
├── fdpmLogm.m
├── fdpmNeighborhood.m
├── fdpmNodeDof.m
├── fdpmPlotNodes.m
├── fdpmResidError.m
├── fdpmShapeBasis.m
├── fdpmShapeDer.m
├── fdpmShapeDerFIGStab.m
├── fdpmShapeMLS.m
├── fdpmShapeMLS2.m
├── fdpmShapeMLS3.m
├── fdpmSolve.m
├── fdpmWeightFunc.m
├── materialLameConst.m
├── materialNeoHookeanPlaneStrain.m
├── materialVonMises.m
├── mathEigen.m
├── mathEigenProj.m
├── test
│ ├── arrayProduct.c
│ ├── mathDerFunm.m
│ ├── mathDerLogm.m
│ ├── mathExpm.m
│ ├── mathFunm.m
│ ├── mathLogm.m
│ ├── mathSqrtm.m
│ ├── mexcpp.cpp
│ ├── parDerGen.m
│ ├── parDerLogm.m
│ ├── voigt3dMat2Vec.m
│ └── voigt3dVec2Mat.m
├── test2
│ ├── testCompAalgo.m
│ ├── testShape.xlsx
│ ├── testShapeApprox.m
│ ├── testShapeDer.m
│ ├── testShapeFunc.m
│ └── testShapeMLS.m
├── test3
│ ├── dpc1.png
│ ├── dpc2.png
│ ├── dpc3.png
│ ├── dpc4.png
│ ├── dpc5.png
│ ├── material3dCamClay.m
│ ├── material3dDPCap.m
│ ├── material3dDruckerPrager.m
│ ├── material3dVonMisesLinHard.m
│ ├── materialDPC.m
│ ├── materialDPSetAngle.m
│ ├── materialLinElasticMod.m
│ ├── plotCap.m
│ ├── testCamClay.m
│ ├── testDPC.m
│ ├── testDPC3d.m
│ ├── testDPC3dIsoConsolidate.m
│ ├── testDPC3dReplotCurr.m
│ ├── testDPC3dTriaxialShear.m
│ ├── testDPC3dUniaxialStrain.m
│ ├── testDPCUniaxialStrain.m
│ ├── testVonMises.m
│ ├── testVonMisesDriverStrain.m
│ ├── testVonMisesDriverUniaxial.m
│ ├── voigt3dJ2.m
│ ├── voigt3dNorm.m
│ ├── voigt3dPressShear.m
│ ├── voigt3dSqrtJ2.m
│ ├── voigtJ2.m
│ ├── voigtPressShear.m
│ └── voigtSqrtJ2.m
├── test4
│ └── material3dCompNeoHookean.m
├── test5
│ ├── fdpmDriverBuildConnIntegBndry.m
│ ├── fdpmDriverBuildConnIntegBndry2.m
│ ├── fdpmDriverBuildConnIntegDomain.m
│ ├── fdpmDriverBuildConnRegular.m
│ ├── fdpmDriverBuildMoment.m
│ ├── fdpmDriverPoissonStabArt.m
│ ├── fdpmDriverPoissonStabHessian.m
│ ├── fdpmDriverShowIntegError.m
│ ├── fdpmDriverShowStiffEigen.m
│ ├── mlsInterpWeight.m
│ ├── mlsInterpWeight1D.m
│ ├── mlsParseInterpOptions.m
│ ├── mlsRegularShape1D.m
│ ├── mlsRegularShape2D.m
│ ├── mlsRegularWeight1D.m
│ ├── mlsRegularWeight2D.m
│ ├── mlsShapeInterp1D.m
│ ├── testInterpWeight.m
│ ├── testInterpWeight2.m
│ ├── testRegularPoisson1.m
│ ├── testRegularPoisson2.m
│ ├── testRegularPoisson2rz.m
│ ├── testRegularShape.m
│ ├── testRegularShape2D.m
│ ├── testRegularWeight.m
│ ├── testRegularWeight2D.m
│ ├── triCircumCenter.m
│ └── triRotateMaxAngle.m
├── testBarNecking
│ ├── testBarNecking.geo
│ ├── testBarNecking.m
│ ├── testBarNecking.msh
│ ├── testBarNeckingGenPart.m
│ └── testBarNeckingLoadMesh.m
├── testBeamTimo
│ ├── fdpmDriverShowLinElasticStiffEigen.m
│ ├── old_testCantilever2.m
│ ├── old_testTimoshenkoCantilever.m
│ ├── refsol_TimoshenkoCantilever.m
│ ├── testCantilever.m
│ ├── timobeam.geo
│ └── timobeam.msh
├── testCircularPlate.m
├── testDPCPress1.m
├── testPatch
│ ├── old_testPatch.m
│ ├── old_testPatch2.m
│ └── testPatchElasticDirichlet.m
├── testPlateHole
│ ├── plate.geo
│ ├── plate.msh
│ ├── refsol_PlateWithHole.m
│ ├── testLoadPlateMesh.m
│ └── testPlateHole.m
├── testPoisson
│ ├── old_testPoisson1.m
│ ├── old_testPoisson2.m
│ ├── old_testPoisson2a.m
│ ├── old_testPoisson3.m
│ ├── old_testPoisson4.m
│ └── old_testPoisson4a.m
├── testPresHalfPlane
│ ├── presLoadHalfPlane.geo
│ ├── presLoadHalfPlane.msh
│ ├── refsol_PresLoadHalfPlane.m
│ └── testPresHalfPlane.m
├── testTriangulation.m
├── testTubeHillEP
│ ├── testTube.m
│ ├── testTube2.m
│ ├── testTubeConstraint.m
│ ├── testTubeGenPart.m
│ ├── testTubeGenPart2.m
│ ├── testTubeHillElastoPlastic.m
│ ├── testTubePlotRadialDisp.m
│ ├── testTubeSolveInfinitesimal.m
│ ├── tube.geo
│ └── tube.msh
└── util
│ ├── +gmsh
│ ├── Group.m
│ ├── PhysicalGroups.m
│ └── loadMeshFile.m
│ ├── +vtk
│ ├── vtkCellType.m
│ └── writeTriMesh.m
│ ├── gauss1dGen.m
│ ├── gauss1dPoint.m
│ ├── gauss2dRectTensorPoint.m
│ ├── gauss2dTriPoint.m
│ ├── gmshGetGroupByName.m
│ ├── gmshLoad.m
│ ├── legendreP.m
│ ├── utilZipVec.m
│ ├── voigtDecode.m
│ └── voigtEncode.m
├── FDPMBox
├── Elements.txt
├── FDPM_DynamicDriver.m
├── FDPM_Neighborhood.m
├── FDPM_TimoshenkoCantilever.m
├── FDPM_cantilever.m
├── Nodes.txt
└── load_gmsh.m
├── FEM2DBox
├── BeamDriver.m
├── GaussPoint.m
├── GenerateMesh.m
├── JacobianMatrix.m
├── LagrangeBasis.m
├── PatchDriver.m
└── PoissonDriver.m
├── FastMultipoleBox
└── Simple1D
│ ├── LevelNodeNum1D.m
│ ├── LevelNodeRange1D.m
│ └── TestFMMSimple1D.m
├── FemNSBox
├── fem_ns.cpp
├── nsfem_report.pdf
└── tmp.txt
├── FemToolBox
├── BeamDriver.m
├── FEBilinearForm.m
├── FELinearForm.m
├── FESpace.m
├── FESpaceMake.m
├── GaussPoint.m
├── GenerateMesh.m
├── JacobianMatrix.m
├── LagrangeBasis.m
├── MeshMakeSquare.m
├── MeshPlotEasy.m
├── PatchDriver.m
└── PoissonDriver.m
├── FrontRegriddingBox
├── FTInit.m
├── FTRegrid.m
├── FTRegridAddElem.m
├── FTRegridDelElem.m
├── FTRegridGlobals.m
├── LinkListAdd.m
├── LinkListDel.m
├── ProblemGlobals.m
├── TestRKVort.m
├── VortVel.m
├── distmesh
│ ├── COPYRIGHT.TXT
│ ├── bndproj.m
│ ├── boundedges.m
│ ├── circumcenter.m
│ ├── dblock.m
│ ├── dcircle.m
│ ├── ddiff.m
│ ├── dellipse.cpp
│ ├── dellipse.mexa64
│ ├── dellipse.mexmaci64
│ ├── dellipse.mexw32
│ ├── dellipse.mexw64
│ ├── dellipsoid.cpp
│ ├── dellipsoid.mexa64
│ ├── dellipsoid.mexmaci64
│ ├── dellipsoid.mexw32
│ ├── dellipsoid.mexw64
│ ├── dexpr.m
│ ├── dintersect.m
│ ├── distmesh2d.m
│ ├── distmesh2doriginal.m
│ ├── distmeshnd.m
│ ├── distmeshsurface.m
│ ├── dmatrix.m
│ ├── dmatrix3d.m
│ ├── dpoly.m
│ ├── drectangle.m
│ ├── drectangle0.m
│ ├── dsegment.cpp
│ ├── dsegment.mexa64
│ ├── dsegment.mexmaci64
│ ├── dsegment.mexw32
│ ├── dsegment.mexw64
│ ├── dsphere.m
│ ├── dunion.m
│ ├── fixmesh.m
│ ├── hmatrix.m
│ ├── hmatrix3d.m
│ ├── huniform.m
│ ├── meshdemo2d.m
│ ├── meshdemond.m
│ ├── mkt2t.m
│ ├── protate.m
│ ├── pshift.m
│ ├── simpplot.m
│ ├── simpqual.m
│ ├── simpvol.m
│ ├── surftri.m
│ ├── trisurfupd.cpp
│ ├── trisurfupd.mexa64
│ ├── trisurfupd.mexmaci64
│ ├── trisurfupd.mexw32
│ ├── trisurfupd.mexw64
│ ├── uniformity.m
│ └── uniref.m
├── faddel.m
├── faspr.m
├── fdelel.m
├── felside.m
├── flocal.m
└── unit_sphere_gen.m
├── FrontTrackingBox
├── CavityBox.m
├── Channel.m
├── DNS-Solver.pdf
├── FTGlobals.m
├── apply_mac_bc.m
├── apply_pres_bc.m
├── code3_frt_st.m
├── code3_rt.m
├── mac_laplacian.m
├── mac_predictor.m
├── mac_rhs.m
├── tryggvason_code2.m
└── tryggvason_code3.m
├── ImmersedInterfaceBox
├── SolveChol.m
├── TestHelmholtz2D.m
└── TestHelmholtzSetup2D.m
├── LESBox
├── README.md
└── les_ch_s2.f
├── LatticeBoltzmannBox
├── IBLBM_CavityMain.m
├── LBMD2Q9Model.m
├── LBMEqDistrib2D.m
├── LBMMRT_CavityMain.m
├── LBMMain_ChannelFlow.m
├── LBMMain_NonNewtonChannel.m
├── LBMSRT_CavityMain.m
├── LBMStream2d.m
├── LBM_NaturalConvectionMain.m
├── LBM_PoiseuilleMain.m
├── LBM_PorousPlateMain.m
├── LBM_RayleighBenardInstability.m
├── LBM_ShanChenMain.m
└── cavity_Re0400.xlsx
├── LevelsetBox
├── LSBiasSign.m
├── LSFillGhost2D.m
├── LSGlobals2D.m
├── LSGlobalsInit2D.m
├── LSHeaviside.m
├── LSNormGrad2D.m
├── LSReinit2D.m
└── TestReinit2D.m
├── LiquidBridgeBox
├── AxisymEmbraceAngle.m
├── AxisymEvalForce.m
├── AxisymEvolver.m
├── AxisymEvolverConstraint.m
├── AxisymEvolverDerivForce.m
├── AxisymEvolverDirectForce.m
├── AxisymEvolverDriver.m
├── AxisymEvolverEnergy.m
├── AxisymEvolverEvalForce.m
├── AxisymEvolverGetPres.m
├── AxisymEvolverGuessInit.m
├── AxisymEvolverVolume.m
├── BridgeForceHR2.m
├── BridgeForceHuppmannRiegger.m
├── BridgeForceRabinovich.m
├── BridgeForceWillet.m
├── BridgeRuptureLian.m
├── BridgeRuptureMikami.m
├── BridgeRuptureWillet.m
├── ConeVolume.m
├── DerjaguinAngle.m
├── DerjaguinRadius.m
├── MakeBridge.m
├── PlotBridgeGeom.m
├── PlotCircle.m
├── Rupture
│ ├── FitParabolic.m
│ ├── FitQuartic.m
│ ├── SolveDroplet.m
│ ├── SolveDroplet2.m
│ ├── Test.m
│ └── TestParabolic.m
├── SolveFlatBridge.m
├── SolveFunc.m
├── SolveStraightBridge.m
├── SphereCapArea.m
├── SphereCapVolume.m
├── SphereVolume.m
├── TestAxisymEvolver.m
├── TestAxisymEvolverForce.m
├── TestAxisymEvolverRupture.m
├── TestHR2.m
├── TestHR2Asym.xlsx
├── TestHR2Asym1.m
├── TestHR2Asym2.m
├── TestHR2Asym2.xlsx
├── TestHR2Lambert.m
├── TestHR2Lambert.xlsx
├── TestHR2PreLarge.m
├── TestHR2PreLarge.xlsx
├── TestHR2PreSmall.m
├── TestHR2PreSmall.xlsx
├── TestHR2Rabinovich.m
├── TestHR2Rabinovich.xlsx
├── TestHR2Rup.m
├── TestHR2Table.m
├── TestHR2Toyota.m
├── TestHR2Toyota.xlsx
├── TestHR2Willet.m
├── TestHR2Willet.xlsx
├── TestHuppmannRiegger.m
├── TestHuppmannRiegger.xlsx
├── TestToyota.m
├── TestToyota2.m
├── YoungLaplace
│ ├── BridgeInteg.m
│ ├── BridgeIntegFindAlfa.m
│ ├── BridgeIntegFindPres.m
│ ├── ParamCurve.m
│ ├── ParamSolve2.m
│ ├── ParamSolvePres.m
│ ├── ParamVolume.m
│ ├── RunEvolver.m
│ ├── Test.m
│ ├── Test2.m
│ ├── Test3.m
│ ├── TestParamCurve.m
│ ├── TestParamCurve2.m
│ ├── TestParamRup.m
│ ├── TestSolSearch.m
│ ├── YLCalcVolume.m
│ ├── YLIntegrateBridge.m
│ ├── YLShootBVP.m
│ ├── YLSolve.m
│ ├── YLSolveBVP.m
│ ├── YLSolvePres.m
│ ├── YLSolvePres2.m
│ ├── YoungLaplace.m
│ ├── tmp_alfa.fig
│ ├── tmp_bridge.fig
│ ├── tmp_ca000_ca020_alfa.fig
│ └── tmp_vc.png
├── deg2rad.m
├── rad2deg.m
└── tmp
│ ├── shape_asym_v001_ca030_ca120_h005_ra1_rb2.png
│ ├── shape_asym_v004_ca015_ca060_h01_ra1_rb3.png
│ ├── shape_asym_v004_ca120_ca150_h02_ra2_rb1.png
│ ├── shape_asym_v01_ca060_ca100_h025_ra1_rb0.png
│ ├── shape_sym_v0005_ca015.png
│ └── shape_sym_v0005_ca090.png
├── MPSBox
└── SurfOpTest
│ ├── surf1.png
│ ├── surf2.png
│ ├── test.xlsx
│ ├── testSurfCircle.m
│ ├── testSurfRect.m
│ └── testSurfTriangle.m
├── MeshGenBox
├── distmesh
│ ├── COPYRIGHT.TXT
│ ├── bndproj.m
│ ├── boundedges.m
│ ├── circumcenter.m
│ ├── dblock.m
│ ├── dcircle.m
│ ├── ddiff.m
│ ├── dellipse.cpp
│ ├── dellipse.mexa64
│ ├── dellipse.mexmaci64
│ ├── dellipse.mexw32
│ ├── dellipse.mexw64
│ ├── dellipsoid.cpp
│ ├── dellipsoid.mexa64
│ ├── dellipsoid.mexmaci64
│ ├── dellipsoid.mexw32
│ ├── dellipsoid.mexw64
│ ├── dexpr.m
│ ├── dintersect.m
│ ├── distmesh2d.m
│ ├── distmesh2doriginal.m
│ ├── distmeshnd.m
│ ├── distmeshsurface.m
│ ├── dmatrix.m
│ ├── dmatrix3d.m
│ ├── dpoly.m
│ ├── drectangle.m
│ ├── drectangle0.m
│ ├── dsegment.cpp
│ ├── dsegment.mexa64
│ ├── dsegment.mexmaci64
│ ├── dsegment.mexw32
│ ├── dsegment.mexw64
│ ├── dsphere.m
│ ├── dunion.m
│ ├── fixmesh.m
│ ├── hmatrix.m
│ ├── hmatrix3d.m
│ ├── huniform.m
│ ├── meshdemo2d.m
│ ├── meshdemond.m
│ ├── mkt2t.m
│ ├── protate.m
│ ├── pshift.m
│ ├── simpplot.m
│ ├── simpqual.m
│ ├── simpvol.m
│ ├── surftri.m
│ ├── trisurfupd.cpp
│ ├── trisurfupd.mexa64
│ ├── trisurfupd.mexmaci64
│ ├── trisurfupd.mexw32
│ ├── trisurfupd.mexw64
│ ├── uniformity.m
│ └── uniref.m
└── persson04mesh.pdf
├── MeshfreeBox
├── MLPG_cantilever.m
├── MLS_basis.m
├── MLS_neigh.m
├── MLS_shape.m
├── MLS_test.m
├── MLS_weight.m
├── MonomialBasis1D.m
├── MonomialBasis2D.m
├── MonomialBasisSize.m
├── meshfree_MonoBasis.m
└── meshfree_neigh.m
├── RBFBox
├── RBF_FD_test.m
├── RBF_func.m
├── RBF_spfunc.m
├── RBF_test.m
├── RBFunc_CompactC2.m
├── RBFunc_CompactC4.m
├── RBFunc_GA.m
└── WendlandCSRBF.m
├── README.md
├── RiemannBox
├── BoundaryCondition1D.m
├── Burgers1DMain.m
└── BurgersExactRiemann1D.m
├── RigidBodyBox
├── DeriveShiftedMOI.m
├── TestInertia.m
├── TestRigidRotation.m
└── UpdatePartPosition.m
├── SemiMultiGridBox
├── SemiMGApply.m
├── SemiMGGenInterp.m
├── SemiMGGenMat.m
├── SemiMGGlobals.m
├── SemiMGInit.m
├── SemiMGProlong.m
├── SemiMGRelax.m
├── SemiMGResid.m
├── SemiMGRestrict.m
├── SemiMGSetup.m
├── SemiMGSmooth.m
├── TestInitProb.m
└── TestSemiMG.m
├── ShallowWaterBox
├── BathtubDriver.m
├── SWE1D_ConsToPrim.m
├── SWE1D_Driver.m
├── SWE1D_FillBC.m
├── SWE1D_Globals.m
├── SWE1D_LuOp.m
├── SWE1D_PrimToCons.m
├── SWE1D_SystemMatrix.m
├── TwoLayerSWE1D_Driver.m
├── TwoLayerSWE1D_LuOp.m
└── waterwave.m
├── SimpleCavityBox
├── SimpleBox.m
├── apply_pres_bc.m
├── apply_umac_bc.m
├── apply_vmac_bc.m
├── simple_globals.m
├── solve_pressure.m
├── solve_ustar.m
└── solve_vstar.m
├── SoilBox
├── DPC
│ ├── DPCGlobals.m
│ ├── DPCInitCap.m
│ ├── DPCLoadTriaxial.m
│ ├── DPCMatLaw.m
│ ├── DPCModel.m
│ ├── DPCPlotCap.m
│ └── DPCTestDriver.m
├── DruckerPragerTest
│ ├── Test.m
│ ├── dpfun_pq.m
│ ├── voigt_decode.m
│ ├── voigt_dev.m
│ ├── voigt_eig.m
│ ├── voigt_encode.m
│ ├── voigt_eye.m
│ └── voigt_norm.m
└── FiniteDeform
│ ├── README.txt
│ ├── assem.m
│ ├── der_shape_func.m
│ ├── formBG.m
│ ├── formDsig.m
│ ├── mainep.m
│ ├── parDerGen.m
│ ├── parDerLogm.m
│ ├── readme.docx
│ ├── setup_cube.m
│ ├── solveq.m
│ ├── test
│ └── TestFormDsig.m
│ ├── vmconst.m
│ └── xsplit.m
├── SpectralBox
├── TestCheb1.m
├── chebdiffmat.m
├── chebfit_nodal.m
├── chebnode.m
├── chebnode1.m
├── chebpoly1.m
└── chebrange.m
├── SphereGridBox
├── FibonacciPoints.m
├── IcosahedralGrid.m
├── IcosahedralPoints.m
├── IcosahedralPointsNum.m
├── IcosahedralRegular.m
├── MeshConnection.m
├── PlotSphereFibonacciGrid.m
├── PlotSphereGrid.m
├── RegularPlacePoints.m
├── SaveObjFile.m
├── SpherePointsToGrid.m
├── SpiralPoints.m
├── SpiralPointsEstimNum.m
├── TestIcosaGrid.m
├── TestIcosaGrid2.m
├── TestRegular.m
├── TestSpiralGrid.m
└── TestSurfInteg.m
├── StokesBox
├── FastSolve2d.m
├── FillPeriodic.m
├── IBSolve2d.m
├── StokesIB2d.m
├── StokesMain.m
├── hashimoto
│ ├── EwaldS1.m
│ ├── EwaldS2.m
│ ├── SumS1.m
│ ├── SumU.m
│ └── TestPointForce.m
├── particlemesh
│ ├── FuncGReg.m
│ ├── TestGReg.m
│ └── TestSphere.m
├── stokes2d.m
├── stokes2d.xlsx
└── swanchannel
│ ├── InterpOL.m
│ ├── InterpUF.m
│ ├── InterpUL.m
│ ├── InterpUS.m
│ ├── PartWallMobUF.m
│ ├── PartWallMobUL.m
│ ├── TestWallFunc.m
│ ├── WallMobGlobals.m
│ ├── WallMobLoadAll.m
│ ├── mes_f.m
│ ├── mes_g.m
│ ├── mes_h.m
│ ├── mol_fg.m
│ ├── mos_f.m
│ ├── muf_f.m
│ ├── muf_g.m
│ ├── mul_f.m
│ ├── mus_f.m
│ └── mus_g.m
├── StokesianDynBox
├── Channel
│ ├── ChannelMobGlobals.m
│ ├── ChannelMobLoadAll.m
│ ├── InterpOL.m
│ ├── InterpUF.m
│ ├── InterpUL.m
│ ├── InterpUS.m
│ ├── PartChanMobOL.m
│ ├── PartChanMobUF.m
│ ├── PartChanMobUL.m
│ ├── TestChannel1.m
│ ├── TestChannelFunc.m
│ ├── TestChannelSediment1.m
│ ├── TestChannelSediment2.m
│ ├── TestChannelSediment3.m
│ ├── mes_f.m
│ ├── mes_g.m
│ ├── mes_h.m
│ ├── mol_fg.m
│ ├── mos_f.m
│ ├── muf_f.m
│ ├── muf_g.m
│ ├── mul_f.m
│ ├── mus_f.m
│ └── mus_g.m
├── CollocationMultipole
│ ├── ADA147301.pdf
│ ├── cm_main.m
│ ├── cm_pns.m
│ ├── cm_pnsp.m
│ ├── cm_stokes.m
│ └── cm_stokesd.m
├── CommonGlobals.m
├── CommonInit.m
├── Ewald
│ ├── AddMobMatrix.m
│ ├── EwaldInit.m
│ ├── EwaldLubMatrix.m
│ ├── EwaldMobMatrix.m
│ ├── EwaldScalarReal.m
│ ├── TestDragBC.m
│ ├── TestDragFC.m
│ └── TestDragSC.m
├── TwoBody
│ ├── MinvScalarRes.m
│ └── TwoBodyScalarRes.m
├── WallBody
│ ├── TestWallOrthoGrid.m
│ ├── TestWallSediment.m
│ ├── WallAsymptotic.m
│ ├── WallParallel.m
│ ├── WallParallelRot.m
│ ├── WallParallelTrans.m
│ ├── WallPerpendicular.m
│ ├── WallPerpendicularRot.m
│ ├── WallPerpendicularTrans.m
│ ├── WallResistanceMatrix.m
│ ├── WallSphere.xlsx
│ └── WallSphereResTab.csv
└── capacitance
│ ├── C2b.m
│ ├── InductionMat.m
│ └── TestCapacitance.m
├── Tmp
├── besselzero.m
├── spindown.m
└── testDampInteg.m
├── Utils
├── K1.m
├── avg.m
├── deg2rad.m
├── easy_streamfunc.m
├── easy_vorticity.m
├── plot_mesh.m
├── poormans_streamfunc.m
├── rad2deg.m
└── zipcol.m
├── VorticityBox
├── SpectralMain.m
├── TimeIntegrators.m
└── Vorticity_incr.m
└── WENOBox
├── Euler1D_ConsToPrim.m
├── Euler1D_DerivePressure.m
├── Euler1D_LuOp.m
├── Euler1D_PrimToCons.m
├── Euler1D_RoeMatrix.m
├── Euler1D_csound.m
├── Euler1D_driver.m
├── Euler1D_flux.m
├── Euler1D_globals.m
├── WENO3_upwind.m
├── WENO_BurgersDriver.m
├── WENO_BurgersGlobals.m
├── WENO_LuOp.m
├── WENO_bc.m
├── WENO_flux.m
├── WENO_fluxsplit.m
├── cweno1D
└── CWENO1D_driver.m
├── sod-exact.out
└── sod.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 |
6 | # Compiled Dynamic libraries
7 | *.so
8 | *.dylib
9 |
10 | # Compiled Static libraries
11 | *.lai
12 | *.la
13 | *.a
14 |
15 | # matlab/octave
16 | octave-core
17 | *.mat
18 | *.fig
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ADERBox/ADERWENOLagrPoly1D.m:
--------------------------------------------------------------------------------
1 |
2 | function [ ps ] = ADERWENOLagrPoly1D(qs,der)
3 |
4 | ADERWENOGlobals1D;
5 |
6 | % if (isrow(qs)); qs = qs'; end
7 |
8 | d = 0;
9 | if (nargin > 1); d = der; end
10 |
11 | switch d
12 | case 0
13 | ps = SumPoly(LagrPsi, qs);
14 | case 1
15 | ps = SumPoly(LagrPsiDer1, qs);
16 | otherwise
17 | error('Invalid derivative');
18 | end
19 |
20 | return
21 | end
22 |
23 |
24 |
--------------------------------------------------------------------------------
/ADERBox/GaussQuad1D.m:
--------------------------------------------------------------------------------
1 | % ## Copyright (C) 2014 homu
2 | % ##
3 | % ## This program is free software; you can redistribute it and/or modify
4 | % ## it under the terms of the GNU General Public License as published by
5 | % ## the Free Software Foundation; either version 3 of the License, or
6 | % ## (at your option) any later version.
7 | % ##
8 | % ## This program is distributed in the hope that it will be useful,
9 | % ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % ## GNU General Public License for more details.
12 | % ##
13 | % ## You should have received a copy of the GNU General Public License
14 | % ## along with Octave; see the file COPYING. If not, see
15 | % ## .
16 |
17 | % ## GaussQuad1D
18 |
19 | % ## Author: homu
20 | % ## Created: 2014-01-20
21 |
22 | function [ q ] = GaussQuad1D (f, xi,wgt)
23 |
24 | q = sum(f(xi) .* wgt);
25 |
26 |
27 | return
28 | end
29 |
--------------------------------------------------------------------------------
/ADERBox/GaussQuadCoefs.m:
--------------------------------------------------------------------------------
1 | % ## Copyright (C) 2014 homu
2 | % ##
3 | % ## This program is free software; you can redistribute it and/or modify
4 | % ## it under the terms of the GNU General Public License as published by
5 | % ## the Free Software Foundation; either version 3 of the License, or
6 | % ## (at your option) any later version.
7 | % ##
8 | % ## This program is distributed in the hope that it will be useful,
9 | % ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % ## GNU General Public License for more details.
12 | % ##
13 | % ## You should have received a copy of the GNU General Public License
14 | % ## along with Octave; see the file COPYING. If not, see
15 | % ## .
16 |
17 | % ## GaussQuadCoefs
18 |
19 | % ## Author: homu
20 | % ## Created: 2014-01-19
21 |
22 | function [ ret ] = GaussQuadCoefs ()
23 |
24 |
25 | return
26 | end
27 |
--------------------------------------------------------------------------------
/ADERBox/LagInterpCoef.m:
--------------------------------------------------------------------------------
1 |
2 | function [ coef ] = LagInterpCoef(xint, xs)
3 |
4 | coef = zeros(size(xs));
5 |
6 | n = length(xs);
7 |
8 | for i = 1:n
9 | % js = [1:i-1, i+1:n];
10 | js = ((1:n) ~= i);
11 | coef(i) = prod(xint-xs(js)) / prod(xs(i)-xs(js));
12 | end
13 |
14 | return
15 | end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ADERBox/LagInterpPoly.m:
--------------------------------------------------------------------------------
1 |
2 | function [ ps ] = LagInterpPoly(xs, ys)
3 |
4 | n = length(xs);
5 | ps = zeros(n,n);
6 |
7 | for i = 1:n
8 | % the polynomial in the numerator
9 | pp = poly(xs((1:n)~=i));
10 | % denominator
11 | ps(:,i) = pp ./ polyval(pp, xs(i));
12 | end
13 |
14 | if (nargin == 2)
15 | % if (isrow(ys))
16 | % ys = ys';
17 | % end
18 | % pp = ps * ys;
19 | % ps = pp;
20 |
21 | ps = SumPoly(ps, ys);
22 | end
23 |
24 |
25 | return
26 | end
27 |
28 |
29 |
--------------------------------------------------------------------------------
/AutoDiffBox/Test2.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | % afun = @(x) tan(x) - 1 - x;
5 | % [sol,ok] = SolveFunc(afun, 0.8, 1.0e-12);
6 |
7 |
8 | R1 = 1.0;
9 | R2 = 1.0;
10 | H = 0.0;
11 | theta1 = 0;
12 | theta2 = 0;
13 | sigma = 1.0;
14 |
15 | V = 1.0e-2;
16 | % V = 1.0e-4;
17 | % V = 1.0e-6;
18 | % V = 1.0e-8;
19 | % V = 1.0e-10;
20 |
21 |
22 | F = BridgeForceHR2(R1,R2,H,theta1,theta2,V,sigma);
23 |
24 |
--------------------------------------------------------------------------------
/BEMBox/BEMPotential2D/BemElemInteg.m:
--------------------------------------------------------------------------------
1 |
2 | function [ aa,bb ] = BemElemInteg(i,j)
3 | % A(i,j) and b(i)
4 |
5 | BemMeshGlobals;
6 |
7 | al = dlen(j);
8 |
9 | j1 = node(1,j);
10 | j2 = node(2,j);
11 |
12 | x11 = y(1,j1) - x(1,i);
13 | x21 = y(2,j1) - x(2,i);
14 | x12 = y(1,j2) - x(1,i);
15 | x22 = y(2,j2) - x(2,i);
16 |
17 | r1 = sqrt(x11^2 + x21^2);
18 | r2 = sqrt(x12^2 + x22^2);
19 | d = x11*dnorm(1,j) + x21*dnorm(2,j);
20 | t1 = -x11*dnorm(2,j) + x21*dnorm(1,j);
21 | t2 = -x12*dnorm(2,j) + x22*dnorm(1,j);
22 |
23 | ds = abs(d);
24 | dtheta = atan2(ds*al, ds^2+t1*t2);
25 |
26 | aa = (-dtheta*ds + al + t1*log(r1) - t2*log(r2)) / (pi*2);
27 |
28 | if d < 0
29 | dtheta = -dtheta;
30 | end
31 | if i == j
32 | bb = 0.5;
33 | else
34 | bb = -dtheta / (pi*2);
35 | end
36 |
37 |
38 | return
39 | end
40 |
41 |
42 |
--------------------------------------------------------------------------------
/BEMBox/BEMPotential2D/BemMeshGlobals.m:
--------------------------------------------------------------------------------
1 |
2 | global bc_dir bc_neu;
3 |
4 | global prob_title;
5 |
6 | global n;
7 | global x y node bc dlen dnorm;
8 |
9 | global nfield;
10 | global xfield;
11 |
12 | global xmin xmax;
13 | global ymin ymax;
14 | % global xlen ylen;
15 | % global xcen ycen;
16 |
17 |
--------------------------------------------------------------------------------
/BEMBox/BEMPotential2D/BemPlotMesh.m:
--------------------------------------------------------------------------------
1 |
2 | figure;
3 | hold on;
4 | for i = 1:n
5 | j1 = node(1,i);
6 | j2 = node(2,i);
7 | plot([y(1,j1),y(1,j2)],[y(2,j1),y(2,j2)],'.-b');
8 | text(x(1,i),x(2,i),num2str(bc(:,i)));
9 | end
10 | plot(x(1,:),x(2,:),'.r');
11 | % quiver(x(1,:),x(2,:),dnorm(1,:),dnorm(2,:));
12 | plot(xfield(1,:),xfield(2,:),'.g');
13 | hold off;
14 | axis equal;
15 |
--------------------------------------------------------------------------------
/BEMBox/BEMPotential2D/FmmBisect.m:
--------------------------------------------------------------------------------
1 |
2 | function [ ielem,nsep ] = FmmBisect(x, ielem,ioff, n, xsep, icomp)
3 |
4 | nsep = 1;
5 | if n <= 0; return; end
6 |
7 | for ifr = 1:n
8 | % this is the true index in IELEM array
9 | idx = ifr + ioff - 1;
10 |
11 | if x(icomp,ielem(idx)) <= xsep
12 | if ifr ~= nsep
13 | isep = nsep + ioff - 1;
14 | itmp = ielem(isep);
15 | ielem(isep) = ielem(idx);
16 | ielem(idx) = itmp;
17 | end
18 | nsep = nsep + 1;
19 | end
20 | end
21 |
22 | return
23 | end
24 |
25 |
26 |
--------------------------------------------------------------------------------
/BEMBox/BEMPotential2D/FmmCalcRhs.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/BEMBox/BEMPotential2D/FmmCalcRhs.m
--------------------------------------------------------------------------------
/BEMBox/BEMPotential2D/FmmMatVec.m:
--------------------------------------------------------------------------------
1 |
2 | function [ ax ] = FmmMatVec(u,ax,a,b)
3 |
4 | BemMeshGlobals;
5 | FmmTreeGlobals;
6 |
7 | a = FmmUpward(u,a);
8 | [ax,b] = FmmDownward(u,ax,a,b);
9 |
10 | return
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/BEMBox/BEMPotential2D/FmmMoment.m:
--------------------------------------------------------------------------------
1 |
2 | function [ a ] = FmmMoment(y,node, ielem,ioff, num, nexp, cx,cy, u,uoff, bc,dnorm)
3 |
4 | a = zeros(nexp+1,1);
5 |
6 | for i = 1:num
7 | nelm = ielem(i+ioff-1);
8 | n1 = node(1,nelm);
9 | n2 = node(2,nelm);
10 | z1 = complex(y(1,n1)-cx, y(2,n1)-cy);
11 | z2 = complex(y(1,n2)-cx, y(2,n2)-cy);
12 | zwbar = conj(z2-z1);
13 | zwbar = zwbar / abs(zwbar);
14 | zp1 = z1 * zwbar;
15 | zp2 = z2 * zwbar;
16 | znorm = complex(dnorm(1,nelm),dnorm(2,nelm));
17 |
18 | if bc(1,nelm) == 1
19 | phi = 0.0;
20 | q = u(i+uoff-1);
21 | elseif bc(1,nelm) == 2
22 | phi = u(i+uoff-1);
23 | q = 0.0;
24 | end
25 |
26 | a(1) = a(1) - (zp2-zp1)*q;
27 | for k = 1:nexp
28 | a(k+1) = a(k+1) + (zp2-zp1)*znorm*phi;
29 | zp1 = zp1 * z1 / (k+1);
30 | zp2 = zp2 * z2 / (k+1);
31 | a(k+1) = a(k+1) - (zp2-zp1)*q;
32 | end
33 | end
34 |
35 | return
36 | end
37 |
38 |
39 |
--------------------------------------------------------------------------------
/BEMBox/BEMPotential2D/FmmPlotTree2D.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/BEMBox/BEMPotential2D/FmmPlotTree2D.m
--------------------------------------------------------------------------------
/BEMBox/BEMYukawa2D/BemMeshGlobals.m:
--------------------------------------------------------------------------------
1 |
2 | global bc_dir bc_neu;
3 |
4 | global prob_title;
5 |
6 | global npoint y;
7 | global nelem x node bc;
8 | global dlen dnorm dtang;
9 | global lenmin lenmax;
10 |
11 | global nfield;
12 | global xfield;
13 |
14 | global xmin xmax;
15 | global ymin ymax;
16 | % global xlen ylen;
17 | % global xcen ycen;
18 |
19 | global kappa;
20 |
--------------------------------------------------------------------------------
/BEMBox/BEMYukawa2D/BemPlotMesh.m:
--------------------------------------------------------------------------------
1 |
2 | figure;
3 | hold on;
4 | for i = 1:nelem
5 | j1 = node(1,i);
6 | j2 = node(2,i);
7 | plot([y(1,j1),y(1,j2)],[y(2,j1),y(2,j2)],'.-b');
8 | text(x(1,i),x(2,i),num2str(bc(:,i)));
9 | end
10 | plot(x(1,:),x(2,:),'.r');
11 | % quiver(x(1,:),x(2,:),dnorm(1,:),dnorm(2,:));
12 | plot(xfield(1,:),xfield(2,:),'.g');
13 | hold off;
14 | axis equal;
15 |
--------------------------------------------------------------------------------
/BEMBox/BEMYukawa2D/BemPotentialCoef2D.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | function [ aa,bb ] = BemPotentialCoef2D(xin,yin,jelem)
4 |
5 | BemMeshGlobals;
6 |
7 | % element
8 | al = dlen(jelem);
9 | j1 = node(1,jelem);
10 | j2 = node(2,jelem);
11 |
12 | % source point
13 | x11 = y(1,j1) - xin;
14 | x21 = y(2,j1) - yin;
15 | x12 = y(1,j2) - xin;
16 | x22 = y(2,j2) - yin;
17 |
18 | r1 = sqrt(x11^2 + x21^2);
19 | r2 = sqrt(x12^2 + x22^2);
20 | d = x11*dnorm(1,jelem) + x21*dnorm(2,jelem);
21 | t1 = x11*dtang(1,jelem) + x21*dtang(2,jelem);
22 | t2 = x12*dtang(1,jelem) + x22*dtang(2,jelem);
23 |
24 | ds = abs(d);
25 | theta1 = atan2(t1,ds);
26 | theta2 = atan2(t2,ds);
27 | dtheta = theta2 - theta1;
28 |
29 | aa = (-dtheta*ds + al + t1*log(r1) - t2*log(r2)) / (pi*2);
30 | if d < 0
31 | dtheta = -dtheta;
32 | end
33 | bb = -dtheta / (pi*2);
34 |
35 | return
36 | end
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/BEMBox/BEMYukawa2D/BemProbGlobals.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/BEMBox/BEMYukawa2D/BemProbGlobals.m
--------------------------------------------------------------------------------
/BEMBox/BEMYukawa3D/BemBuildConstElem.m:
--------------------------------------------------------------------------------
1 | % build by Constant Element
2 |
3 | amat = zeros(nface,nface);
4 | bvec = zeros(nface,1);
5 | for j = 1:nface
6 | for i = 1:nface
7 | % check distance for quadrature rule
8 | rij = norm(facecent(:,i)-facecent(:,j));
9 | dlen = facelmax(i) + facelmax(j);
10 | level = 0;
11 | if i==j || rij.
16 |
17 | % ## ../EBBox/EBNSDriver
18 |
19 | % ## Author: homu
20 | % ## Created: 2013-08-13
21 |
22 | function [ ret ] = EBNSDriver ()
23 |
24 | endfunction
25 |
--------------------------------------------------------------------------------
/CouetteBox/EBPPESolvability.m:
--------------------------------------------------------------------------------
1 |
2 | function [adiag,bx,by,rhs] = EBPPESolvability(nx,ny,dx,dy, adiag,bx,by, rhs)
3 |
4 | rhs = reshape(rhs, nx,ny);
5 |
6 | for i = 1:nx
7 | for j = 1:ny
8 | if (adiag(i,j) == 0)
9 | if (bx(i+1,j)==0 && bx(i,j)==0 && by(i,j+1)==0 && by(i,j)==0)
10 | adiag(i,j) = 1.0;
11 | rhs(i,j) = 0.0;
12 | end
13 | end
14 | end
15 | end
16 |
17 | rhs = reshape(rhs, nx*ny,1);
18 |
19 | return
20 | end
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CouetteBox/EBSampleCellFrac.m:
--------------------------------------------------------------------------------
1 |
2 | function [ frac ] = EBSampleCellFrac(xcen,ycen,dx,dy)
3 |
4 | % nsub = 5;
5 | nsub = 8;
6 |
7 | if (1)
8 | [xx,yy] = ndgrid( ...
9 | linspace(xcen-0.5*dx+0.5*dx/nsub, xcen+0.5*dx-0.5*dx/nsub, nsub), ...
10 | linspace(ycen-0.5*dy+0.5*dy/nsub, ycen+0.5*dy-0.5*dy/nsub, nsub));
11 |
12 | dist = ProbDistFunc(xx,yy);
13 | frac = double(sum(dist(:)<=0)) / nsub^2;
14 |
15 | else
16 | xlo = xcen - dx*0.5;
17 | ylo = ycen - dy*0.5;
18 |
19 |
20 | frac = 0.0;
21 |
22 | for isub = 1:nsub
23 | for jsub = 1:nsub
24 | xx = xlo + (isub-0.5)*(dx/nsub);
25 | yy = ylo + (jsub-0.5)*(dy/nsub);
26 | if ProbDistFunc(xx, yy) <= 0
27 | frac = frac + 1.0;
28 | end
29 | end
30 | end
31 |
32 | frac = frac / nsub^2;
33 |
34 | end
35 |
36 | return
37 | end
38 |
39 |
40 |
--------------------------------------------------------------------------------
/CouetteBox/EBSampleFaceFrac.m:
--------------------------------------------------------------------------------
1 |
2 | function [ frac ] = EBSampleFaceFrac(dir,xcen,ycen,dx,dy)
3 |
4 | nsub = 25;
5 |
6 | if dir == 0
7 | xx = zeros(nsub,1) + xcen;
8 | yy = linspace(ycen-0.5*dy+0.5*dy/nsub, ycen+0.5*dy-0.5*dy/nsub, nsub)';
9 | else
10 | xx = linspace(xcen-0.5*dx+0.5*dx/nsub, xcen+0.5*dx-0.5*dx/nsub, nsub)';
11 | yy = zeros(nsub,1) + ycen;
12 | end
13 |
14 | dist = ProbDistFunc(xx,yy);
15 | frac = double(sum(dist(:)<=0)) / nsub;
16 |
17 | return
18 | end
19 |
20 |
21 |
--------------------------------------------------------------------------------
/CouetteBox/PMViscosity.m:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | function [ nucell nunode ] = PMVelocityLapOp (eb_vof,nx,ny)
5 | %
6 | EBGlobals;
7 |
8 | % compute (penalty) viscosity from harmonic average
9 |
10 | % cell centered
11 | nucell = zeros(nx+2,ny+2);
12 | nucell = nu*nu_s ./ (eb_vof.*nu + (1.0-eb_vof).*nu_s);
13 |
14 | % node centered
15 | nunode = zeros(nx+1,ny+1);
16 | % compute node fraction first
17 | I = 1:nx+1;
18 | J = 1:ny+1;
19 | vofnode = 0.25 * (eb_vof(I,J) + eb_vof(I+1,J) + eb_vof(I,J+1) + eb_vof(I+1,J+1));
20 | %
21 | nunode = nu*nu_s ./ (vofnode.*nu + (1.0-vofnode).*nu_s);
22 |
23 |
24 | return
25 | end
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/CouetteBox/ProbDistFunc.m:
--------------------------------------------------------------------------------
1 |
2 | function [ dist ] = ProbDistFunc(x,y)
3 |
4 | EBGlobals;
5 |
6 | r = sqrt(x.^2 + y.^2);
7 | dist = min(r-R0, R1-r);
8 |
9 | return
10 | end
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/CouetteBox/ProbVelFunc.m:
--------------------------------------------------------------------------------
1 |
2 | function [ u,v ] = ProbVelFunc(x,y)
3 |
4 | EBGlobals;
5 |
6 | r = sqrt(x.^2 + y.^2);
7 |
8 | if r < 0.5*(R0+R1)
9 | u = -Omega0 * y;
10 | v = Omega0 * x;
11 | else
12 | u = 0;
13 | v = 0;
14 | end
15 |
16 |
17 | return
18 | end
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CubeChoppingBox/CubeChopGetVolume.m:
--------------------------------------------------------------------------------
1 |
2 | function [ vol ] = CubeChopGetVolume(nx,ny,nz,d, lx,ly,lz)
3 | % (x-xc).n = d
4 |
5 | xc = lx / 2;
6 | yc = ly / 2;
7 | zc = ly / 2;
8 |
9 |
10 | % flip the orientation
11 | if nx >= 0
12 | m1 = nx;
13 | else
14 | m1 = -nx;
15 | end
16 | if ny >= 0
17 | m2 = ny;
18 | else
19 | m2 = -ny;
20 | end
21 | if nz >= 0
22 | m3 = nz;
23 | else
24 | m3 = -nz;
25 | end
26 |
27 | alpha = d + xc*m1 + yc*m2 + zc*m3;
28 |
29 | m1 = m1 * lx;
30 | m2 = m2 * ly;
31 | m3 = m3 * lz;
32 |
33 | % put into standard form
34 | msum = m1 + m2 + m3;
35 | m1 = m1 / msum;
36 | m2 = m2 / msum;
37 | m3 = m3 / msum;
38 | alpha = alpha / msum;
39 |
40 | if m1 > m2
41 | tmp = m1;
42 | m1 = m2;
43 | m2 = tmp;
44 | end
45 | if m1 > m3
46 | tmp = m1;
47 | m1 = m3;
48 | m3 = tmp;
49 | end
50 | if m2 > m3
51 | tmp = m2;
52 | m2 = m3;
53 | m3 = tmp;
54 | end
55 |
56 | vol = StdChopGetVolume(m1,m2,m3,alpha);
57 |
58 |
59 |
60 | return
61 | end
62 |
63 |
--------------------------------------------------------------------------------
/CubeChoppingBox/CubeChopGetVolume2D.m:
--------------------------------------------------------------------------------
1 |
2 | function [ vol ] = CubeChopGetVolume2D(nx,ny,d, lx,ly)
3 | % (x-xc).n = d
4 |
5 | xc = lx / 2;
6 | yc = ly / 2;
7 |
8 | % flip the orientation
9 | if nx >= 0
10 | m1 = nx;
11 | else
12 | m1 = -nx;
13 | end
14 | if ny >= 0
15 | m2 = ny;
16 | else
17 | m2 = -ny;
18 | end
19 |
20 | alpha = d + xc*m1 + yc*m2;
21 |
22 | m1 = m1 * lx;
23 | m2 = m2 * ly;
24 |
25 | % put into standard form
26 | msum = m1 + m2;
27 | m1 = m1 / msum;
28 | m2 = m2 / msum;
29 | alpha = alpha / msum;
30 |
31 | if m1 > m2
32 | tmp = m1;
33 | m1 = m2;
34 | m2 = tmp;
35 | end
36 |
37 | vol = StdChopGetVolume2D(m1,m2,alpha);
38 |
39 |
40 |
41 | return
42 | end
43 |
44 |
--------------------------------------------------------------------------------
/CubeChoppingBox/CubeChoppingGlobals.m:
--------------------------------------------------------------------------------
1 |
2 | global ChopEps;
3 |
4 |
--------------------------------------------------------------------------------
/CubeChoppingBox/StdChopGetVolume2D.m:
--------------------------------------------------------------------------------
1 |
2 | function [ vol ] = StdChopGetVolume2D(m1,m2,alpha)
3 | % Core function in 2D. Require m1+m2=1; m1<=m2
4 |
5 | if alpha<0
6 | vol = 0.0;
7 | elseif 0<=alpha & alpha0.5
12 | % use complement
13 | vol = StdChopGetVolume2D(m1,m2,1-alpha);
14 | vol = 1.0 - vol;
15 | return
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/CornerApprox.m:
--------------------------------------------------------------------------------
1 | function [phi] = CornerApprox(xin,yin,dw,gw,hw,xbase)
2 |
3 | x = xin - xbase(1);
4 | y = yin - xbase(2);
5 |
6 | g1 = gw(1);
7 | g2 = gw(2);
8 | h11 = hw(1,1);
9 | h22 = hw(2,2);
10 | h12 = hw(1,2);
11 |
12 | phi = 0.5*h11*x.^2 + 0.5*h22*y.^2 + h12*x.*y + g1*x + g2*y + dw;
13 |
14 | return
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/CornerDeriv.m:
--------------------------------------------------------------------------------
1 | function [gw,hw] = CornerDeriv(corner,xc,yc,dh)
2 |
3 | dc = CornerPotential(corner,xc, yc );
4 | dw = CornerPotential(corner,xc-dh,yc );
5 | de = CornerPotential(corner,xc+dh,yc );
6 | ds = CornerPotential(corner,xc ,yc-dh);
7 | dn = CornerPotential(corner,xc ,yc+dh);
8 |
9 | wx = (de-dw) / (dh*2);
10 | wy = (dn-ds) / (dh*2);
11 | wxx = (de+dw-dc*2) / (dh*dh);
12 | wyy = (dn+ds-dc*2) / (dh*dh);
13 |
14 | d00 = CornerPotential(corner,xc-dh,yc-dh);
15 | d01 = CornerPotential(corner,xc+dh,yc-dh);
16 | d10 = CornerPotential(corner,xc-dh,yc+dh);
17 | d11 = CornerPotential(corner,xc+dh,yc+dh);
18 |
19 | wxy = ((d11-d10)/(dh*2) - (d01-d00)/(dh*2)) / (dh*2);
20 |
21 | gw = [ wx; wy ];
22 | hw = [ wxx, wxy; wxy, wyy ];
23 |
24 | return
25 | end
26 |
27 |
28 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/CornerPotential.m:
--------------------------------------------------------------------------------
1 | function [phi] = CornerPotential(corner,x,y)
2 |
3 | pos = [x;y];
4 |
5 | vw = pos - corner.xw;
6 |
7 | dot1 = dot(vw, corner.n1);
8 | dot2 = dot(vw, corner.n2);
9 |
10 | proj1 = pos - dot1*corner.n1;
11 | proj2 = pos - dot2*corner.n2;
12 |
13 | para1 = proj1 - corner.xw;
14 | para2 = proj2 - corner.xw;
15 |
16 | dist = 9999999;
17 | if dot(para1,corner.t1) < 0
18 | if abs(dist) > abs(dot1)
19 | dist = dot1;
20 | end
21 | end
22 | if dot(para2,corner.t2) > 0
23 | if abs(dist) > abs(dot2)
24 | dist = dot2;
25 | end
26 | end
27 | if 1
28 | distw = norm(vw);
29 | if abs(dist) > distw
30 | signw = sign(dot(vw,corner.nw));
31 | dist = distw * signw;
32 | end
33 | end
34 |
35 | phi = dist;
36 |
37 | return
38 | end
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/MakeCorner.m:
--------------------------------------------------------------------------------
1 | function [corner] = MakeCorner(xw,xa,xb)
2 |
3 | corner = struct();
4 |
5 | corner.type = -2;
6 |
7 | corner.xw = xw;
8 | corner.xa = xa;
9 | corner.xb = xb;
10 |
11 | t1 = normalize(xw - xa);
12 | n1 = [-t1(2), t1(1)]';
13 | corner.t1 = t1;
14 | corner.n1 = n1;
15 | corner.d1 = dot(n1,xw);
16 |
17 | t2 = normalize(xb - xw);
18 | n2 = [-t2(2), t2(1)]';
19 | corner.t2 = t2;
20 | corner.n2 = n2;
21 | corner.d2 = dot(n2,xw);
22 |
23 | nw = n1 + n2;
24 | nw = nw ./ norm(nw);
25 | corner.nw = nw;
26 |
27 | return
28 | end
29 |
30 | function [vn] = normalize(v)
31 | vn = v ./ norm(v);
32 | return
33 | end
34 |
35 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/MakeEllipse.m:
--------------------------------------------------------------------------------
1 | function [shape] = MakeEllipse(a,b, xc,yc,rotang)
2 |
3 | shape = struct();
4 |
5 | shape.type = 1;
6 |
7 | shape.a = a;
8 | shape.b = b;
9 |
10 | shape.xc = xc;
11 | shape.yc = yc;
12 | shape.rotang = rotang;
13 |
14 | return
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/MakeSDF.m:
--------------------------------------------------------------------------------
1 | function [sdf] = MakeSDF(shape)
2 |
3 |
4 | lx = shape.a * 6;
5 | ly = shape.b * 6;
6 | xmin = shape.xc - lx/2;
7 | xmax = shape.xc + lx/2;
8 | ymin = shape.yc - ly/2;
9 | ymax = shape.yc + ly/2;
10 |
11 | dh = min(shape.a,shape.b) / 20;
12 | [xg,yg] = ndgrid(xmin:dh:xmax,ymin:dh:ymax);
13 | nx = size(xg,1);
14 | ny = size(xg,2);
15 |
16 | phig = zeros(nx,ny);
17 | for i = 1:nx
18 | for j = 1:ny
19 | phig(i,j) = ShapePotential(shape,xg(i,j),yg(i,j));
20 | end
21 | end
22 |
23 | % reinitialize to get SDF
24 | band = lx * 0.2;
25 | phig = ImplicitFuncReinit(phig,nx,ny,dh,dh, band);
26 |
27 |
28 | sdf = struct();
29 | sdf.xmin = xmin;
30 | sdf.xmax = xmax;
31 | sdf.ymin = ymin;
32 | sdf.ymax = ymax;
33 | sdf.dh = dh;
34 | sdf.nx = nx;
35 | sdf.ny = ny;
36 | sdf.xg = xg;
37 | sdf.yg = yg;
38 | sdf.phig = phig;
39 |
40 |
41 |
42 | return
43 | end
44 |
45 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/MakeShapeGrid.m:
--------------------------------------------------------------------------------
1 | function [node,elem] = MakeShapeGrid(shape)
2 |
3 | if shape.type~=2
4 | error('type');
5 | end
6 |
7 | n = 36;
8 | theta = 2*pi/n * (0:n-1);
9 | xx = cos(theta);
10 | yy = sin(theta);
11 | sx = sign(xx);
12 | sy = sign(yy);
13 | px = shape.a * (xx.^2).^(1/shape.p) .* sx;
14 | py = shape.b * (yy.^2).^(1/shape.q) .* sy;
15 |
16 | node = [px; py];
17 |
18 | rmat = RotationMatrix(shape.rotang);
19 | node = rmat * node;
20 | node(1,:) = node(1,:) + shape.xc;
21 | node(2,:) = node(2,:) + shape.yc;
22 |
23 | elem = [1:n; 2:n+1]';
24 | elem(n,2) = 1;
25 |
26 |
27 | return
28 | end
29 |
30 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/MakeSuperEllipse.m:
--------------------------------------------------------------------------------
1 | function [shape] = MakeSuperEllipse(a,b,p,q, xc,yc,rotang)
2 |
3 | shape = struct();
4 |
5 | shape.type = 2;
6 |
7 | shape.a = a;
8 | shape.b = b;
9 | shape.p = p;
10 | shape.q = q;
11 |
12 | shape.xc = xc;
13 | shape.yc = yc;
14 | shape.rotang = rotang;
15 |
16 | return
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/MakeWall.m:
--------------------------------------------------------------------------------
1 | function [wall] = MakeWall(xw,yw,nx,ny)
2 |
3 | wall = struct();
4 |
5 | wall.type = -1;
6 |
7 | wall.xwall = [xw;yw];
8 |
9 | nvec = [nx;ny];
10 | wall.nwall = nvec ./ norm(nvec);
11 |
12 | wall.dwall = dot(wall.xwall,wall.nwall);
13 |
14 | return
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/PlotSDF.m:
--------------------------------------------------------------------------------
1 | function [] = PlotSDF(sdf, varargin)
2 |
3 | contour(sdf.xg,sdf.yg,sdf.phig, varargin{:});
4 |
5 | return
6 | end
7 |
8 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/PlotShape.m:
--------------------------------------------------------------------------------
1 |
2 | function [h] = PlotShape(shape,plotcell)
3 |
4 | % nseg = 360;
5 |
6 | % theta = (0:nseg) .* (2*pi/nseg);
7 |
8 | % ea = shape.a;
9 | % eb = shape.b;
10 | % xc = shape.xc;
11 | % yc = shape.yc;
12 | % rotang = shape.rotang;
13 |
14 | % xs = ea .* cos(theta);
15 | % ys = eb .* sin(theta);
16 | % pos = [xs;ys];
17 |
18 |
19 | % rotmat = RotationMatrix(rotang);
20 |
21 | % pos = rotmat * pos;
22 | % xs = pos(1,:) + xc;
23 | % ys = pos(2,:) + yc;
24 |
25 | % plot(xs,ys,plotcell{:});
26 |
27 | % range = [shape.xc-shape.a,shape.xc+shape.a, shape.yc-shape.b, shape.yc+shape.b];
28 |
29 | if shape.type >= 0
30 | h = ezplot(@(x,y) ShapePotential(shape,x,y));
31 | else
32 | h = ezplot(@(x,y) WallPotential(shape,x,y));
33 | end
34 | set(h, 'Color',plotcell{1});
35 |
36 |
37 |
38 | return
39 | end
40 |
41 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/RotationMatrix.m:
--------------------------------------------------------------------------------
1 | function [rotmat] = RotationMatrix(rotang)
2 | crot = cos(rotang);
3 | srot = sin(rotang);
4 | rotmat = [crot,-srot;srot,crot];
5 |
6 | return
7 | end
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/SafeInvert.m:
--------------------------------------------------------------------------------
1 | % may also use matlab's PINV
2 | function [minv] = SafeInvert(mat)
3 |
4 | % tol = epsilon * max(m,n) * max(Sigma)
5 |
6 | esmall = 1.0e-6;
7 |
8 | test = det(mat);
9 |
10 | if abs(test) >= esmall
11 | minv = inv(mat);
12 | else
13 | % near-sigular, use SVD to obtain pseudo-inverse
14 | [u,s,v] = svd(mat);
15 | sinv = s';
16 | n = size(mat,1);
17 | for i = 1:n
18 | if abs(s(i,i)) > esmall
19 | sinv(i,i) = 1.0 / s(i,i);
20 | else
21 | sinv(i,i) = 0.0;
22 | end
23 | end
24 |
25 | minv = v * sinv * u';
26 | end
27 |
28 | return
29 | end
30 |
31 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/ShapeConstraint.m:
--------------------------------------------------------------------------------
1 | function [c,ceq] = ShapeConstraint(shape,pos)
2 | c = [];
3 | ceq = EllipsePotential(shape,pos(1),pos(2));
4 | return
5 | end
6 |
7 |
8 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/ShapePotential.m:
--------------------------------------------------------------------------------
1 | function [phi] = ShapePotential(shape,x,y)
2 |
3 | % common operation
4 | % shift to center
5 | xp = x - shape.xc;
6 | yp = y - shape.yc;
7 | % back-transform to body coordinate
8 | rmat = RotationMatrix(-shape.rotang);
9 | pp = rmat * [xp';yp'];
10 | xp = pp(1,:)';
11 | yp = pp(2,:)';
12 |
13 | switch shape.type
14 | case 1
15 | phi = xp.^2/shape.a^2 + yp.^2/shape.b^2 - 1;
16 | case 2
17 | phi = (xp./shape.a).^shape.p + (yp./shape.b).^shape.q - 1;
18 | otherwise
19 | error(['Unknown shape.type=',int2str(shape.type)]);
20 | end
21 |
22 |
23 | return
24 | end
25 |
26 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/TestSuperEllipse.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | nx = 33;
5 | ny = 33;
6 | nz = 33;
7 | xs = linspace(-3,3,nx);
8 | ys = linspace(-3,3,ny);
9 | zs = linspace(-3,3,nz);
10 |
11 | [xs,ys,zs] = ndgrid(xs,ys,zs);
12 | % [xs,ys,zs] = meshgrid(xs,ys,zs);
13 |
14 | a = 1.0;
15 | b = 1.0;
16 | c = 2.0;
17 | alpha = 2.0;
18 | beta = 2.0;
19 | gamma = 16.0;
20 |
21 | phis = (xs/a).^alpha + (ys/b).^beta + (zs/c).^gamma - 1;
22 |
23 | % phis = zeros(nx,ny,nz);
24 | % for i = 1:nx
25 | % for j = 1:ny
26 | % for k = 1:nz
27 | % phis(i,j,k) = (xs(i)/a)^alpha + (ys(j)/b)^beta + (zs(k)/c)^gamma - 1;
28 | % end
29 | % end
30 | % end
31 |
32 | figure;
33 | % isosurface(xs,ys,zs,phis, 0);
34 | isosurface(phis, 0);
35 | axis equal;
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/DEMBox/ContactPotential/WallPotential.m:
--------------------------------------------------------------------------------
1 | function [phi] = WallPotential(wall,x,y)
2 | pos = [x';y'];
3 | phi = wall.nwall' * pos;
4 | phi = phi' - wall.dwall;
5 | return
6 | end
7 |
8 |
9 |
--------------------------------------------------------------------------------
/EBBox/EBNSDriver.m:
--------------------------------------------------------------------------------
1 | % ## Copyright (C) 2013 homu
2 | % ##
3 | % ## This program is free software; you can redistribute it and/or modify
4 | % ## it under the terms of the GNU General Public License as published by
5 | % ## the Free Software Foundation; either version 3 of the License, or
6 | % ## (at your option) any later version.
7 | % ##
8 | % ## This program is distributed in the hope that it will be useful,
9 | % ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % ## GNU General Public License for more details.
12 | % ##
13 | % ## You should have received a copy of the GNU General Public License
14 | % ## along with Octave; see the file COPYING. If not, see
15 | % ## .
16 |
17 | % ## ../EBBox/EBNSDriver
18 |
19 | % ## Author: homu
20 | % ## Created: 2013-08-13
21 |
22 | function [ ret ] = EBNSDriver ()
23 |
24 | endfunction
25 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/AdaptModSphBesselI.m:
--------------------------------------------------------------------------------
1 | function [ihat] = AdaptModSphBesselI(n,x)
2 |
3 | coef = double_factorial(2*n+1) ./ (x.^n);
4 |
5 | in = ModSphBesselI(n,x);
6 |
7 | ihat = coef .* in;
8 |
9 | return
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/AdaptModSphBesselK.m:
--------------------------------------------------------------------------------
1 | function [khat] = AdaptModSphBesselK(n,x)
2 |
3 | coef = exp(x) .* (x.^(n+1)) ./ double_factorial(2*n-1);
4 |
5 | kn = ModSphBesselK(n,x);
6 | khat = 2/pi .* coef .* kn;
7 |
8 | return
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/EnergyTwoBodyConstPotent.m:
--------------------------------------------------------------------------------
1 | function [u] = EnergyTwoBodyConstPotent(a1,a2,H,kappa,cutoff, acoef,bcoef, phi1,phi2)
2 |
3 | % currently only equal sphere
4 | if a1~=a2 || phi1~=phi2
5 | error('Equal sphere only!');
6 | end
7 |
8 | if 1
9 | ka = kappa * a1;
10 | kh = kappa * H;
11 | piso = phi1;
12 | a0 = acoef(1);
13 | aend = acoef(end);
14 |
15 | u = 4*pi * (-(pi/2)*(a0/piso)*csch(ka) + ka + ka*coth(ka));
16 | end
17 |
18 |
19 | return
20 | end
21 |
22 |
23 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/FuncA.m:
--------------------------------------------------------------------------------
1 | function [A] = FuncA(nu,n,m)
2 |
3 | a1 = gamma(n-nu+1/2) .* gamma(m-nu+1/2) .* gamma(nu+1/2) ./ gamma(m+n-nu+3/2);
4 |
5 | a2 = factorial(n+m-nu) ./ factorial(n-nu) ./ factorial(m-nu) ./ factorial(nu);
6 |
7 | A = (n+m-2*nu+1/2)/pi .* a1 .* a2;
8 |
9 | return
10 | end
11 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/FuncB.m:
--------------------------------------------------------------------------------
1 | function [Bnm] = FuncB(n,m,kR)
2 |
3 | numax = min(n,m);
4 |
5 | Bnm = 0;
6 | for nu = 0:numax
7 | Bnm = Bnm + FuncA(nu,n,m) * ModSphBesselK(n+m-2*nu,kR);
8 | end
9 |
10 | return
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/LegendrePoly.m:
--------------------------------------------------------------------------------
1 | function [p] = LegendrePoly(n,x)
2 |
3 | % associate Legendre function
4 | val = legendre(n,x);
5 |
6 | % the 0th-order assoc Legendre is Legendre Poly.
7 | p = val(1,:);
8 |
9 | p = p';
10 |
11 | return
12 | end
13 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/ModSphBesselI.m:
--------------------------------------------------------------------------------
1 | function [val] = ModSphBesselI(nu,x)
2 |
3 | val = sqrt((pi/2)./x) .* besseli(nu+0.5,x);
4 |
5 | return
6 | end
7 |
8 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/ModSphBesselK.m:
--------------------------------------------------------------------------------
1 | function [val] = ModSphBesselK(nu,x)
2 | % The modified spherical Bessel function of the 2nd kind
3 | % NOTE the form of the current function is slightly different from common definition,
4 | % the pre-factor is a different constant.
5 | %
6 |
7 | % val = sqrt((2/pi)./x) .* besselk(nu+0.5,x);
8 | val = sqrt((pi/2)./x) .* besselk(nu+0.5,x);
9 |
10 | return
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/ReExpMat.m:
--------------------------------------------------------------------------------
1 | function [Tmat,Rmat,Smat] = ReExpMat(psrc,pdst, kappa,nmax)
2 | % Wrapper function for re-expansion operation: src -> dst
3 |
4 | ImUnit = 1i;
5 |
6 | % reexpansion direction
7 | pab = pdst - psrc;
8 |
9 | % create original->coaxial rotation
10 | ReExpSimpleRot;
11 |
12 | % distance
13 | [r,theta,phi] = sh_cart2sph(pab);
14 | kr = kappa * r;
15 |
16 | if 1
17 | theta = thetaprime;
18 | phi = phiprime;
19 | end
20 |
21 | % cutoff
22 | nmax1 = nmax + 1;
23 | npole = nmax1^2;
24 | % disp(['nmax=',int2str(nmax), '; npole=',int2str(npole)]);
25 |
26 | % rotation matrix R
27 | ReExpCalcR;
28 |
29 | % scale matrix S
30 | ReExpCalcS;
31 |
32 | % combine total operations
33 | Tmat = Rmat * Smat * Rmat';
34 |
35 | return
36 | end
37 |
38 |
39 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/RecurModSphBesselI.m:
--------------------------------------------------------------------------------
1 | function [I] = RecurModBesselI(nmax,x)
2 |
3 | I = zeros(nmax+1,1);
4 |
5 | sinhx = sinh(x);
6 | coshx = cosh(x);
7 |
8 | for n = 0:nmax
9 | if n == 0
10 | in = sinhx / x;
11 | elseif n == 1
12 | in = (x*coshx-sinhx) / x^2;
13 | else
14 | in1 = I(n);
15 | in2 = I(n-1);
16 | in = in2 - (2*n-1)/x*in1;
17 | end
18 | I(n+1) = in;
19 | end
20 |
21 |
22 | return
23 | end
24 |
25 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/RecurModSphBesselI2.m:
--------------------------------------------------------------------------------
1 | function [I] = RecurModBesselI2(nmax,x)
2 |
3 | I = zeros(nmax+1,1);
4 |
5 | sinhx = sinh(x);
6 | coshx = cosh(x);
7 |
8 | for n = 0:nmax
9 | if n == 0
10 | % initial value for n=0,1
11 | im = 0;
12 | in = sinhx / x;
13 | ip = (x*coshx-sinhx) / x^2;
14 | % derivative i0' equal to i1
15 | din = ip;
16 | else
17 | ip = im - (2*n+1)/x*in;
18 | din = n/(2*n+1)*im + (n+1)/(2*n+1)*ip;
19 | end
20 |
21 | I(n+1,1) = in;
22 | I(n+1,2) = din;
23 |
24 | im = in;
25 | in = ip;
26 | end
27 |
28 |
29 | return
30 | end
31 |
32 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/RecurModSphBesselK2.m:
--------------------------------------------------------------------------------
1 |
2 | function [k] = RecurModSphBesselK2(nmax,x)
3 |
4 | k = recur2(nmax,x);
5 |
6 | return
7 | end
8 |
9 | function [k] = recur2(nmax,x)
10 | k = zeros(nmax+1,2);
11 |
12 | expnx = exp(-x);
13 |
14 | % kn = expnx / x;
15 | % kp = expnx / x^2 * (x+1);
16 |
17 | for n = 0:nmax
18 | if n == 0
19 | % initial value for n=0,1
20 | km = 0;
21 | kn = expnx / x;
22 | kp = expnx / x^2 * (x+1);
23 | % derivative n=0 is -k1
24 | dkn = -kp;
25 | else
26 | kp = km + (2*n+1)/x*kn;
27 | dkn = -n/(2*n+1)*km - (n+1)/(2*n+1)*kp;
28 | end
29 |
30 | k(n+1,1) = kn;
31 | k(n+1,2) = dkn;
32 |
33 | km = kn;
34 | kn = kp;
35 | end
36 |
37 | if 1
38 | % the sqrt(pi/2) factor
39 | k = k .* (pi/2);
40 | end
41 | return
42 | end
43 |
44 |
45 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/SignNonNeg.m:
--------------------------------------------------------------------------------
1 | function [s] = SignNonNeg(x)
2 |
3 | s = sign(x);
4 | s(x==0) = 1;
5 |
6 | return
7 | end
8 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/SphHarmReexpandApply.m:
--------------------------------------------------------------------------------
1 | function [acoef] = SphHarmReexpandApply(nmax,Rmat,Smat,bcoef)
2 |
3 |
4 | xtmp = zeros(size(bcoef));
5 | for n = 0:nmax
6 | for m = -n:n
7 | inm = sh_sub2ind(n,m);
8 | xnm = 0;
9 | for s = -n:n
10 | ins = sh_sub2ind(n,s);
11 | xnm = xnm + Rmat(inm,ins) * bcoef(ins);
12 | end
13 | xtmp(inm) = xnm;
14 | end
15 | end
16 |
17 | ytmp = zeros(size(bcoef));
18 | for n = 0:nmax
19 | for m = -n:n
20 | inm = sh_sub2ind(n,m);
21 | ynm = 0;
22 | for l = abs(m):nmax
23 | ilm = sh_sub2ind(l,m);
24 | ynm = ynm + Smat(inm,ilm) * xtmp(ilm);
25 | end
26 | ytmp(inm) = ynm;
27 | end
28 | end
29 |
30 | ztmp = zeros(size(bcoef));
31 | for n = 0:nmax
32 | for m = -n:n
33 | inm = sh_sub2ind(n,m);
34 | znm = 0;
35 | for s = -n:n
36 | ins = sh_sub2ind(n,s);
37 | znm = znm + conj(Rmat(ins,inm)) * ytmp(ins);
38 | end
39 | ztmp(inm) = znm;
40 | end
41 | end
42 |
43 | acoef = ztmp;
44 |
45 | return
46 | end
47 |
48 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/SphHarmY.m:
--------------------------------------------------------------------------------
1 | function [Ynm] = SphHarmY(n,m,theta,phi)
2 | % Spherical Harmonics Y_n^m(theta,phi)
3 | %
4 |
5 | szt = size(theta);
6 | szp = size(phi);
7 |
8 | theta = theta(:);
9 | phi = phi(:);
10 |
11 | absm = abs(m);
12 | mu = cos(theta);
13 |
14 | % associated Legendre function
15 | pnm = legendre(n,mu);
16 | pnm = pnm(absm+1,:)';
17 |
18 | N = sqrt(factorial(n-absm)/factorial(n+absm));
19 |
20 | em = exp(1i * m * phi);
21 |
22 | Ynm = N .* pnm .* em;
23 |
24 | if 1
25 | % the phase factor
26 | Ynm = Ynm * (-1)^m;
27 | end
28 |
29 | if 0
30 | % normalization factor
31 | Ynm = Ynm * sqrt((2*n+1)/(4*pi));
32 | end
33 |
34 | if numel(theta) > 1
35 | Ynm = reshape(Ynm,szt);
36 | elseif numel(phi) > 1
37 | Ynm = reshape(Ynm,szp);
38 | end
39 |
40 | return
41 | end
42 |
43 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/TestTwoBody.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/ElectricalDoubleLayerBox/TestTwoBody.xlsx
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/double_factorial.m:
--------------------------------------------------------------------------------
1 | function [val] = double_factorial(n)
2 | % The n!! double factorial
3 | % n!! = prod(1, 3, 5, ..., n)
4 | %
5 |
6 | if n == 0
7 | val = 1;
8 | else
9 | ns = double(1:2:n);
10 | val = prod(ns);
11 | end
12 |
13 | return
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/sh_cart2sph.m:
--------------------------------------------------------------------------------
1 | function [r,theta,phi] = sh_cart2sph(x,y,z)
2 |
3 | if nargin == 1
4 | y = x(2);
5 | z = x(3);
6 | x = x(1);
7 | end
8 |
9 | r = sqrt(x.^2 + y.^2 + z.^2);
10 |
11 | theta = acos(z./r);
12 |
13 | phi = atan2(y,x);
14 | if phi < 0
15 | phi = phi + pi*2;
16 | end
17 |
18 | return
19 | end
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ElectricalDoubleLayerBox/sh_sub2ind.m:
--------------------------------------------------------------------------------
1 | function [ind] = sh_sub2ind(n,m, islocal)
2 | %
3 |
4 | ind = m + n + 1;
5 |
6 | if nargin == 2
7 | ind = ind + n^2;
8 | end
9 |
10 | return
11 | end
12 |
--------------------------------------------------------------------------------
/ElectroKineticBox/BoltzmannDistrib.m:
--------------------------------------------------------------------------------
1 |
2 | function [ n ] = BoltzmannDistrib(ninf,z,T, psi)
3 |
4 | EKConst;
5 |
6 | n = ninf .* exp(-e0*z/(kB*T) .* psi);
7 |
8 |
9 | return
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/ElectroKineticBox/CalcPartFrac.m:
--------------------------------------------------------------------------------
1 |
2 | function [ frac ] = CalcPartFrac(x0,y0,r0, xs,ys,dx,dy)
3 |
4 | [sdf,rr,rx,ry] = CalcPartSDF(x0,y0,r0, xs,ys);
5 |
6 | frac = zeros(size(xs));
7 | cutoff = max(dx,dy) * 2;
8 | frac(sdf>=cutoff) = 0;
9 | frac(sdf<=-cutoff) = 1;
10 |
11 | range = find(sdf>-cutoff & sdf0) = 1;
6 | tag(sdf<=0) = -1;
7 | for j = 2:ny-1
8 | for i = 2:nx-1
9 | if sdf(i,j) <= 0
10 | if sdf(i-1,j)>0 | sdf(i+1,j)>0 | sdf(i,j-1)>0 | sdf(i,j+1)>0
11 | tag(i,j) = 0;
12 | end
13 | end
14 | end
15 | end
16 |
17 | return
18 | end
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ElectroKineticBox/GridInterpCoef2D.m:
--------------------------------------------------------------------------------
1 |
2 | function [ ws,is,js ] = GridInterpCoef2D(xint,yint, xlo,ylo,dx,dy)
3 |
4 | xbase = xlo + dx/2;
5 | ybase = ylo + dy/2;
6 |
7 | i0 = floor((xint-xbase) / dx) + 1;
8 | j0 = floor((yint-ybase) / dy) + 1;
9 |
10 | x0 = (i0-1)*dx + xbase;
11 | y0 = (j0-1)*dy + ybase;
12 |
13 | rx = (xint-x0) / dx;
14 | ry = (yint-y0) / dy;
15 |
16 | is(1) = i0;
17 | js(1) = j0;
18 | ws(1) = (1-rx) * (1-ry);
19 | is(2) = i0 + 1;
20 | js(2) = j0;
21 | ws(2) = rx * (1-ry);
22 | is(3) = i0;
23 | js(3) = j0 + 1;
24 | ws(3) = (1-rx) * ry;
25 | is(4) = i0 + 1;
26 | js(4) = j0 + 1;
27 | ws(4) = rx * ry;
28 |
29 |
30 |
31 | return
32 | end
33 |
--------------------------------------------------------------------------------
/ElectroKineticBox/PBTestPlotIon.m:
--------------------------------------------------------------------------------
1 |
2 | %
3 | % call FIGURE by yourself...
4 | %
5 |
6 | zz = 1.0;
7 | sol_cation = exp(-zz .* sol);
8 | sol_anion = exp(-(-zz) .* sol);
9 | sol_cation(tag_solid) = nan;
10 | sol_anion(tag_solid) = nan;
11 |
12 |
13 | figure;
14 | contourf(xcell,ycell,sol_cation);
15 | colorbar;
16 | title('cation');
17 | axis equal;
18 | hold on;
19 | contour(xcell,ycell,sdf,[0,0]);
20 | hold off;
21 |
22 | figure;
23 | contourf(xcell,ycell,sol_anion);
24 | colorbar;
25 | title('anion');
26 | axis equal;
27 | hold on;
28 | contour(xcell,ycell,sdf,[0,0]);
29 | hold off;
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ElectroKineticBox/PBTestPlotSol.m:
--------------------------------------------------------------------------------
1 |
2 | %
3 | % call FIGURE by yourself...
4 | %
5 |
6 | solsave = sol;
7 | sol(tag_solid) = nan;
8 |
9 | % imagesc(xcell,ycell,sol);
10 | contourf(xcell,ycell,sol,-1.4:0.1:-0.2);
11 | colorbar;
12 | % contourf(xcell,ycell,phi);
13 | % contourf(xcell,ycell,dphi);
14 | % imagesc([xlo+dx/2,xhi-dx/2],[ylo+dy/2,yhi-dy/2],owner');
15 | % imagesc([xlo+dx/2,xhi-dx/2],[ylo+dy/2,yhi-dy/2],tag');
16 | axis equal;
17 | hold on;
18 | contour(xcell,ycell,sdf,[0,0]);
19 | hold off;
20 |
21 | sol = solsave;
22 | clear solsave;
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ElectroKineticBox/PNPTestPlotSol.m:
--------------------------------------------------------------------------------
1 |
2 | %
3 | % call FIGURE by yourself...
4 | %
5 |
6 | solsave = sol;
7 |
8 | sol = reshape(sol,nx,ny);
9 | sol(tag_solid) = nan;
10 |
11 | if isempty(solrange)
12 | contourf(xcell,ycell,sol,'ShowText','on');
13 | else
14 | contourf(xcell,ycell,sol,solrange, 'ShowText','on');
15 | end
16 | % imagesc([xlo+dx/2,xhi-dx/2],[ylo+dy/2,yhi-dy/2],owner');
17 | % imagesc([xlo+dx/2,xhi-dx/2],[ylo+dy/2,yhi-dy/2],tag');
18 | colorbar;
19 | axis equal;
20 | axis([xlo,xhi,ylo,3.5*D]);
21 | % axis([7.5,12.5,7.5,12.5]);
22 |
23 | hold on;
24 | contour(xcell,ycell,sdf,[0,0],'LineColor','r');
25 | hold off;
26 |
27 | sol = solsave;
28 | clear solsave;
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/ElectroKineticBox/SharpIBTag.m:
--------------------------------------------------------------------------------
1 |
2 | function [ tag ] = SharpIBTag(nx,ny,sdf)
3 |
4 | tag = zeros(nx,ny);
5 |
6 | tag_s = -1;
7 | tag_sf = 0;
8 | tag_fs = 1;
9 | tag_f = 2;
10 |
11 | for j = 1:ny
12 | for i = 1:nx
13 | if sdf(i,j) > 0
14 | flag = tag_f;
15 | if (i>1 & sdf(i-1,j)<=0) | (i1 & sdf(i,j-1)<=0) | (j1 & sdf(i-1,j)>0) | (i0) | (j>1 & sdf(i,j-1)>0) | (j0)
21 | flag = tag_sf;
22 | end
23 | end
24 | tag(i,j) = flag;
25 | end
26 | end
27 |
28 |
29 | return
30 | end
31 |
32 |
33 |
--------------------------------------------------------------------------------
/FDPM2Box/+material/VonMises.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FDPM2Box/+material/VonMises.m
--------------------------------------------------------------------------------
/FDPM2Box/3d/fdpm3dFormB.m:
--------------------------------------------------------------------------------
1 | function [B] = fdpm3dFormB(np,dNx,dNy,dNz)
2 | %fdpm3dFormB
3 | % B is the 6-component standard strain-displacement
4 | %
5 |
6 | B = zeros(6,np*3);
7 |
8 | % xx
9 | B(1,1:3:end) = dNx;
10 | % yy
11 | B(2,2:3:end) = dNy;
12 | % zz
13 | B(3,3:3:end) = dNz;
14 | % xy
15 | B(4,1:3:end) = dNy;
16 | B(4,2:3:end) = dNx;
17 | % yz
18 | B(5,2:3:end) = dNz;
19 | B(5,3:3:end) = dNy;
20 | % zx
21 | B(6,1:3:end) = dNz;
22 | B(6,3:3:end) = dNx;
23 |
24 |
25 |
26 | return
27 | end
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/FDPM2Box/3d/fdpm3dFormG.m:
--------------------------------------------------------------------------------
1 | function [G] = fdpm3dFormG(np,dNx,dNy,dNz)
2 | %fdpm3dFormG
3 | % G is the 9-component full strain-displacement
4 | %
5 |
6 | G = zeros(9,np*3);
7 |
8 | % xx
9 | G(1,1:3:end) = dNx;
10 |
11 | % yy
12 | G(2,2:3:end) = dNy;
13 |
14 | % zz
15 | G(3,3:3:end) = dNz;
16 |
17 | % xy,yx
18 | G(4,1:3:end) = dNy;
19 | G(5,2:3:end) = dNx;
20 |
21 | % yz,zy
22 | G(6,2:3:end) = dNz;
23 | G(7,3:3:end) = dNy;
24 |
25 | % zx,xz
26 | G(8,3:3:end) = dNx;
27 | G(9,1:3:end) = dNz;
28 |
29 |
30 |
31 | return
32 | end
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/FDPM2Box/README.md:
--------------------------------------------------------------------------------
1 |
2 | # FDPM
3 |
4 |
5 | the FDPM code
6 |
7 | 1. asdf
8 | 1. 1234
9 | 1. asdf
10 | 1. adsf
11 |
12 |
13 | * item
14 | * item
15 | * asdf
16 | * 1234
17 |
18 |
19 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmDriverBuildConnMLS.m:
--------------------------------------------------------------------------------
1 | % Build particle connectivity
2 | %
3 | %
4 |
5 | clear conn;
6 |
7 | for i = 1:numNodes
8 |
9 | [neigh,rs,rx,ry,cutoff] = fdpmNeighborhood(i,nodePos,re);
10 | neigh2 = [neigh; i]; % particle included in the neighbourhood
11 |
12 | [N,Nx,Ny] = fdpmShapeMLS2(rx(neigh2),ry(neigh2),cutoff);
13 |
14 | % save connection
15 | conn(i).numNeigh = numel(neigh2);
16 | conn(i).neigh2 = neigh2'; % neighbor list is a row vector
17 | % conn(i).W = [w(:)', 0]; % weights, the last self weight is zero
18 | conn(i).N = N;
19 | conn(i).NX = Nx;
20 | conn(i).NY = Ny;
21 | end
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmDriverWriteCsv.m:
--------------------------------------------------------------------------------
1 |
2 | % write header
3 | filename = 'hoge00.csv';
4 | fid = fopen(filename,'w');
5 | % fprintf(fid, 'x,y,z,s11,s22,s12,s33\n');
6 | fprintf(fid, 'x,y,z,u,v,s11,s22,s12,s33\n');
7 | fclose(fid);
8 |
9 | clear fid;
10 |
11 |
12 | dlmwrite(filename, [nodeCoord',zeros(numNodes,1), nodeDisp', nodeSigma'], ...
13 | '-append', 'precision','%0.5e', 'delimiter',',');
14 |
15 |
16 | disp(['Saved to ', filename]);
17 |
18 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmFormBmat.m:
--------------------------------------------------------------------------------
1 | function [B] = fdpmFormBmat(np,dNx,dNy, prob_type,x,y)
2 | %fdpmFormBmat
3 | % B is the 3-component standard strain-displacement
4 | % [Nx,0; 0,Ny; Ny,Nx]
5 |
6 | ndim = 2;
7 |
8 | if ~exist('prob_type', 'var')
9 | prob_type = 1;
10 | end
11 |
12 | if prob_type == 1
13 | % plane-strain
14 | B = zeros(3,np*ndim);
15 | elseif prob_type == 2
16 | % axisymmetric
17 | B = zeros(4,np*ndim);
18 | end
19 |
20 | % 11: [Nx, 0]
21 | B(1,1:ndim:end) = dNx;
22 |
23 | % 22: [0, Ny]
24 | B(2,2:ndim:end) = dNy;
25 |
26 | % 12: [Ny,Nx]
27 | B(3,1:ndim:end) = dNy;
28 | B(3,2:ndim:end) = dNx;
29 |
30 | % RZ coord
31 | if prob_type == 2
32 | % in this case, the hoop deformation is u/r
33 | % NOTE the center particle is always put in the last point
34 | rr = x(end);
35 | if rr == 0
36 | % B(4,end-1) = 0;
37 | B(4,1:ndim:end) = dNx;
38 | else
39 | B(4,end-1) = 1.0 / rr;
40 | end
41 | end
42 |
43 |
44 | return
45 | end
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmFormFmat.m:
--------------------------------------------------------------------------------
1 | function [F3] = fdpmFormFmat(F2, prob_type, xref, xpos)
2 | %fdpmFormFmat: Fill the (3,3) out-of-plane component of deform grad F.
3 |
4 | error('bad');
5 |
6 | F3 = F2;
7 |
8 | if prob_type == 1
9 | % plane strain
10 | % no deformation in Z-dir
11 | F3(3,3) = 1;
12 | elseif prob_type == 2
13 | % axisymmetric
14 | % the hoop deform = x/X
15 | if xref == 0
16 | % for point just on axis
17 | F3(3,3) = 1;
18 | else
19 | F3(3,3) = xpos / xref;
20 | end
21 | end
22 |
23 |
24 | return
25 | end
26 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmFormGmat.m:
--------------------------------------------------------------------------------
1 | function [G] = fdpmFormGmat(np, dNx,dNy, prob_type,x,y)
2 | %fdpmFormGmat
3 | % G is 4-component full strain-displacement matrix
4 | % [11,21,12,22]
5 | % [Nx,0; 0,Nx; Ny,0; 0,Ny]
6 |
7 | ndim = 2;
8 |
9 | if prob_type == 1
10 | % plane-strain
11 | G = zeros(4,np*ndim);
12 | elseif prob_type == 2
13 | % axisymmetric
14 | G = zeros(5,np*ndim);
15 | end
16 |
17 | % 11: [Nx,0]
18 | G(1,1:ndim:end) = dNx;
19 |
20 | % 21: [0,Nx]
21 | G(2,2:ndim:end) = dNx;
22 |
23 | % 12: [Ny,0]
24 | G(3,1:ndim:end) = dNy;
25 |
26 | % 22: [0,Ny]
27 | G(4,2:ndim:end) = dNy;
28 |
29 | % RZ coord
30 | if prob_type == 2
31 | rr = x(end);
32 | if rr == 0
33 | % G(5,end-1) = 0.0;
34 | G(5,1:ndim:end) = dNx;
35 | else
36 | G(5,end-1) = 1.0 / rr;
37 | end
38 | end
39 |
40 | return
41 | end
42 |
43 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmLogm.m:
--------------------------------------------------------------------------------
1 | function [y] = fdpmLogm(x)
2 | %fdpmLogm
3 | % special y = logm(x)
4 | % for x is a plane-strain or axisymmetric 3x3 matrix
5 | % [ x11, x12, 0 ]
6 | % [ x12, x22, 0 ]
7 | % [ 0, 0, x33 ]
8 | %
9 |
10 | y = zeros(3);
11 |
12 | if 0
13 | % matlab logm is not very fast...
14 | y(1:2,1:2) = logm(x(1:2,1:2));
15 | end
16 |
17 | if 1
18 | % eig is faster for small 2x2 submatrix
19 | [v,d] = eig(x(1:2,1:2));
20 | y(1:2,1:2) = v * diag(log(diag(d))) * v.';
21 | end
22 |
23 |
24 |
25 | % the 33 component
26 | y(3,3) = log(x(3,3));
27 |
28 |
29 | return
30 | end
31 |
32 |
33 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmNeighborhood.m:
--------------------------------------------------------------------------------
1 |
2 | function [ neigh,dist,rx,ry,re ] = fdpmNeighborhood (target,nodes,re)
3 | %fdpmNeighborhood
4 | % Get
5 | % If $TARGET is an integer, then used as an index in $NODES
6 | % otherwise used as coordinate
7 |
8 | % check input target point
9 | % if a scalar integer, then it's an index in the nodes array
10 | % otherwise it's coordinate
11 | if isscalar(target)
12 | isnode = true;
13 | else
14 | isnode = false;
15 | end
16 |
17 | if isnode
18 | xc = nodes(target,1);
19 | yc = nodes(target,2);
20 | else
21 | xc = target(1);
22 | yc = target(2);
23 | end
24 |
25 | rx = nodes(:,1)-xc;
26 | ry = nodes(:,2)-yc;
27 | dist = sqrt(rx.^2 + ry.^2);
28 |
29 | if (~isscalar(re))
30 | % re is a vector, to be symmetrized
31 | rc = re(target);
32 | re = 1/2 * (re + rc);
33 | end
34 |
35 | flag = (dist < re);
36 | if isnode
37 | % exclude target particle itself
38 | flag(target) = 0;
39 | end
40 |
41 | neigh = find(flag);
42 |
43 | return
44 | end
45 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmNodeDof.m:
--------------------------------------------------------------------------------
1 | function [idof] = fdpmNodeDof(inode,op)
2 | %fdpmNodeDof
3 | % Node index -> DOF index
4 | % Input
5 | % OP: 0->xy; 1->x; 2->y;
6 | % Output
7 | % column vector idof
8 |
9 | % ensure a row vector
10 | inode = inode(:).';
11 |
12 | switch op
13 | case 'xy'
14 | idof = reshape([inode*2-1; inode*2], [],1);
15 | case 'x'
16 | idof = reshape(inode*2-1, [],1);
17 | case 'y'
18 | idof = reshape(inode*2, [],1);
19 | otherwise
20 | disp('Unknown op = ');
21 | disp(op);
22 | error('Unknown op');
23 | end
24 |
25 |
26 |
27 | return
28 | end
29 |
30 |
31 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmPlotNodes.m:
--------------------------------------------------------------------------------
1 | %
2 |
3 | plot(nodeX,nodeY,'o', ...
4 | nodeX(fixed_nodes),nodeY(fixed_nodes),'x', ...
5 | nodeX(loaded_nodes),nodeY(loaded_nodes),'s');
6 | legend('node','disp','trac');
7 | axis('equal');
8 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmResidError.m:
--------------------------------------------------------------------------------
1 | function [err] = fdpmResidError(resid, measure)
2 | %fdpmResidError
3 | % Calculates the residual error
4 | % Default is L2-error
5 | %
6 |
7 | % default error measure
8 | if nargin == 1
9 | measure = 'L2';
10 | end
11 |
12 | % ensure vector
13 | resid = resid(:);
14 |
15 |
16 | switch measure
17 | case 'L2'
18 | err = sqrt(mean(resid.^2));
19 | case 'L1'
20 | err = mean(abs(resid));
21 | case 'Linf'
22 | err = max(abs(resid));
23 | otherwise
24 | error(['Unknown error measure = ', measure]);
25 | end
26 |
27 |
28 |
29 | return
30 | end
31 |
32 |
33 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmShapeBasis.m:
--------------------------------------------------------------------------------
1 | function [P] = fdpmShapeBasis(rx,ry)
2 | %fdpmShapeBasis
3 | % Return the polynomial basis
4 | % Currently upto 2nd-order [x, y, x2, xy, y2]
5 | %
6 |
7 | rx = rx(:);
8 | ry = ry(:);
9 |
10 |
11 | % the order of polynomial
12 | completeness = 2;
13 |
14 | %
15 | switch completeness
16 | case {1}
17 | % x,y
18 | P = [ rx, ry ];
19 | case {2}
20 | % x,y, x^2
21 | P = [ rx, ry, 1/2*rx.^2, rx.*ry, 1/2*ry.^2 ];
22 | otherwise
23 | error('Unsupported completeness=%d',completeness);
24 | end
25 |
26 | return
27 | end
28 |
29 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmShapeDerFIGStab.m:
--------------------------------------------------------------------------------
1 | function [NxStab,NyStab] = fdpmShapeDerFIGStab(Nx,Ny,Nxx,Nxy,Nyy, hx,hy)
2 | %fdpmShapeDerFIGStab
3 | % Apply Finite-Increment-Gradient Stabilization to derivative shape functions
4 | % Inputs
5 | % hx,hy: controls the increment size
6 | %
7 |
8 | NxStab = Nx + hx*Nxx + hy*Nxy;
9 | NyStab = Ny + hy*Nyy + hx*Nxy;
10 | % NxStab = Nx - hx*Nxx - hy*Nxy;
11 | % NyStab = Ny - hy*Nyy - hx*Nxy;
12 |
13 |
14 |
15 |
16 |
17 | return
18 | end
19 |
20 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmSolve.m:
--------------------------------------------------------------------------------
1 | function [d,react] = fdpmSolve(K,f, bcdof,bcval)
2 | %fdpmSolve
3 | % stiffness matrix K
4 | % external - internal force f
5 | %
6 | % We remove Dirichlet BC
7 | %
8 |
9 | % free dof
10 | nall = size(f,1);
11 | freedof = (1:nall)';
12 | % remove Dirichlet BC dof, this reduces the vector size
13 | freedof(bcdof) = [];
14 |
15 | % rhs
16 | if isempty(bcval)
17 | % homogeneous BC
18 | rhs = f(freedof);
19 | else
20 | rhs = f(freedof) - K(freedof,bcdof)*bcval;
21 | end
22 |
23 | %
24 | sol = K(freedof,freedof) \ rhs;
25 |
26 | % displacement as solution
27 | d = zeros(size(f));
28 | % fill solved part
29 | d(freedof) = sol;
30 | if ~isempty(bcval)
31 | % fill Dirichlet BC value
32 | d(bcdof) = bcval;
33 | end
34 |
35 | if nargout > 1
36 | % react force
37 | % this should only be nonzero for Dirichlet points
38 | react = K * d - f;
39 | end
40 |
41 | return
42 | end
43 |
44 |
--------------------------------------------------------------------------------
/FDPM2Box/fdpmWeightFunc.m:
--------------------------------------------------------------------------------
1 | function [w] = fdpmWeightFunc(q, cutoff)
2 | %fdpmWeightFunc
3 | % Calculate weight function
4 | %
5 |
6 | if exist('cutoff','var')
7 | q = q ./ cutoff;
8 | end
9 |
10 | w = (q<1) .* (1 - 6*q.^2 + 8*q.^3 - 3*q.^4);
11 |
12 | return
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/FDPM2Box/materialLameConst.m:
--------------------------------------------------------------------------------
1 | function [lambda0,mu0] = materialLameConst(E0,nu0)
2 | %material_LameConst
3 | % Calculate Lame's constants (lambda,mu) from Young E and Poisson nu
4 |
5 |
6 |
7 | lambda0 = E0*nu0 / (1+nu0) / (1-2*nu0);
8 | mu0 = E0 / 2 / (1+nu0);
9 |
10 | return
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/FDPM2Box/mathEigen.m:
--------------------------------------------------------------------------------
1 | function [v,d,repeat] = mathEigen(a)
2 | %mathEigen: similar to [v,d] = eig(a)
3 | % Only operates on 2x2
4 | % Checks repeated eigenvalues
5 |
6 | [v,d] = eig(a(1:2,1:2));
7 |
8 | if nargout >= 3
9 | % check repeated eigenvalues
10 | % tol_abs = 1.0e-9;
11 | % tol_rel = 1.0e-6;
12 | tol = 1.0e-6;
13 |
14 | repeat = 0;
15 | d1 = d(1,1);
16 | d2 = d(2,2);
17 | diff = abs(d1-d2);
18 | dmax = max(abs(d1), abs(d2));
19 | if dmax > 0
20 | diff = diff / dmax;
21 | end
22 | if diff < tol
23 | repeat = 1;
24 | end
25 | end
26 |
27 |
28 |
29 | return
30 | end
31 |
32 |
33 |
--------------------------------------------------------------------------------
/FDPM2Box/mathEigenProj.m:
--------------------------------------------------------------------------------
1 | function [vproj] = mathEigenProj(v,d,repeat)
2 | %mathEigenProj: eigenprojection from [V,D]
3 | %
4 |
5 | if repeat
6 | warning('Repeated eigenvalues, eigenprojection incorrect!');
7 | end
8 |
9 | vproj = zeros(4,2);
10 | for dir = 1:2
11 | vv = v(:,dir) * v(:,dir)';
12 | vproj(1:3,dir) = [vv(1,1),vv(2,2),vv(1,2)];
13 | end
14 |
15 |
16 | return
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/FDPM2Box/test/mathExpm.m:
--------------------------------------------------------------------------------
1 | function [b] = mathExpm(a)
2 | %mathExpm
3 | % b = expm(a)
4 |
5 | b = mathFunm(a, @exp);
6 |
7 | return
8 | end
9 |
10 |
--------------------------------------------------------------------------------
/FDPM2Box/test/mathFunm.m:
--------------------------------------------------------------------------------
1 | function [b] = mathFunm(a,fun)
2 | %mathFunm: Tensor function of eigenvalues
3 | % Decompose A by
4 | % a*v = v*d
5 | % Compute B by
6 | % b = fun(a) = v * fun(d) * inv(v)
7 | %
8 |
9 | % TODO check A symmetric
10 |
11 | % A*V = V*D
12 | [v,d] = eig(a);
13 |
14 | % extract eigenvalues and compute
15 | s = fun(diag(d));
16 |
17 | % not work for equal eigenvalues
18 | % b = v * diag(s) * v';
19 |
20 | % work around
21 | b = v * diag(s) * inv(v);
22 |
23 |
24 |
25 |
26 | return
27 | end
--------------------------------------------------------------------------------
/FDPM2Box/test/mathLogm.m:
--------------------------------------------------------------------------------
1 | function [b] = mathLogm(a)
2 | %mathLogm
3 | % b = logm(a)
4 |
5 | b = mathFunm(a, @log);
6 |
7 | return
8 | end
--------------------------------------------------------------------------------
/FDPM2Box/test/mathSqrtm.m:
--------------------------------------------------------------------------------
1 | function [b] = mathSqrtm(a)
2 | %mathSqrt
3 | % b = sqrtm(a)
4 |
5 | b = mathFunm(a, @sqrt);
6 |
7 | return
8 | end
9 |
10 |
--------------------------------------------------------------------------------
/FDPM2Box/test/voigt3dMat2Vec.m:
--------------------------------------------------------------------------------
1 | function [vec] = voigtMat2Vec(mat,op)
2 | %voigtMat2Vec
3 | % Voigt notation, encode
4 |
5 | if numel(mat) ~= 9
6 | error('Invalid input matrix');
7 | end
8 |
9 | switch op
10 | case 'stress'
11 | vec = [mat(1); mat(5); mat(9); mat(2); mat(6); mat(7)];
12 | case 'strain'
13 | vec = [mat(1); mat(5); mat(9); 2*mat(2); 2*mat(6); 2*mat(7)];
14 | otherwise
15 | error(['Unknown voigt type=',op]);
16 | end
17 |
18 |
19 | return
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/FDPM2Box/test/voigt3dVec2Mat.m:
--------------------------------------------------------------------------------
1 | function [mat] = voigtVec2Mat(vec,op)
2 | %voigtVec2Mat
3 | % Voigt notation, decode
4 |
5 | if numel(vec) ~= 6
6 | error('Invalid input vector');
7 | end
8 |
9 | switch op
10 | case 'stress'
11 | mat = [vec(1),vec(4),vec(6); vec(4),vec(2),vec(5); vec(6),vec(5),vec(3)];
12 | case 'strain'
13 | mat = [vec(1),vec(4)/2,vec(6)/2; vec(4)/2,vec(2),vec(5)/2; vec(6)/2,vec(5)/2,vec(3)];
14 | otherwise
15 | error(['Unknown voigt type=',op]);
16 | end
17 |
18 |
19 | return
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/FDPM2Box/test2/testShape.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FDPM2Box/test2/testShape.xlsx
--------------------------------------------------------------------------------
/FDPM2Box/test3/dpc1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FDPM2Box/test3/dpc1.png
--------------------------------------------------------------------------------
/FDPM2Box/test3/dpc2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FDPM2Box/test3/dpc2.png
--------------------------------------------------------------------------------
/FDPM2Box/test3/dpc3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FDPM2Box/test3/dpc3.png
--------------------------------------------------------------------------------
/FDPM2Box/test3/dpc4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FDPM2Box/test3/dpc4.png
--------------------------------------------------------------------------------
/FDPM2Box/test3/dpc5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FDPM2Box/test3/dpc5.png
--------------------------------------------------------------------------------
/FDPM2Box/test3/material3dDruckerPrager.m:
--------------------------------------------------------------------------------
1 | function [] = material3dDruckerPrager()
2 | %material3dDruckerPrager
3 |
4 |
5 |
6 | friction_angle = 20;
7 | dilatency_angle = 20;
8 |
9 | error('Not implemented');
10 |
11 | return
12 | end
13 |
14 |
15 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/materialLinElasticMod.m:
--------------------------------------------------------------------------------
1 | function [K,G,De] = materialLinElastiMod(E,nu)
2 |
3 | K = E / 3 / (1-2*nu);
4 | G = E / 2 / (1+nu);
5 |
6 | De = E/(1+nu)/(1-2*nu) * [...
7 | 1-nu, nu, 0, nu;
8 | nu, 1-nu, 0, nu;
9 | 0, 0, 0.5-nu, 0;
10 | nu, nu, 0, 1-nu];
11 |
12 | return
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/plotCap.m:
--------------------------------------------------------------------------------
1 | function [] = plotCap(par, a, varargin)
2 | %plotCap
3 |
4 | beta = par.beta;
5 | M = par.M;
6 | pt = par.ptens;
7 |
8 | b = beta;
9 |
10 | tt = linspace(0,pi/2,91);
11 | tt = tt + pi/2;
12 |
13 | xx = (pt-a) + b*a*cos(tt);
14 | yy = M/sqrt(3)*a*sin(tt);
15 |
16 | plot(xx,yy,varargin{:});
17 |
18 |
19 | return
20 | end
21 |
22 |
23 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/testDPC3dReplotCurr.m:
--------------------------------------------------------------------------------
1 |
2 | if 1
3 |
4 | % figure(hfig);
5 | % hold on;
6 |
7 | % plot cap
8 | a = par.a0 + alpha*par.Hcap;
9 | plotCap(par, a, 'r-');
10 |
11 | % plot current state
12 | [p,s] = voigt3dPressShear(sigma);
13 | sj2 = sqrt(voigt3dJ2(s));
14 | plot(p,sj2,'x');
15 |
16 | titlestr = ['step=',int2str(istep),'/',int2str(nstep)];
17 | switch mtype
18 | case 0
19 | titlestr = [titlestr,';mtype=',int2str(mtype),'(elastic)'];
20 | case 1
21 | titlestr = [titlestr,';mtype=',int2str(mtype),'(cone)'];
22 | case 2
23 | titlestr = [titlestr,';mtype=',int2str(mtype),'(apex)'];
24 | case 3
25 | titlestr = [titlestr,';mtype=',int2str(mtype),'(cap)'];
26 | case 4
27 | titlestr = [titlestr,';mtype=',int2str(mtype),'(corner)'];
28 | end
29 | title(titlestr);
30 |
31 | % hold off;
32 |
33 | end
34 |
35 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/testVonMises.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 |
5 | E = 210;
6 | nu = 0.3;
7 | sigmay0 = 0.24;
8 | % sigmay0 = 10000;
9 | % H = 0;
10 | H = 10;
11 |
12 | % elastic strain
13 | epsE = zeros(6,1);
14 | % yield stress
15 | sigmay = sigmay0;
16 | % accumulative plastic
17 | epbar = 0;
18 |
19 |
20 | % strain controled
21 | testVonMisesDriverStrain;
22 |
23 | % uniaxial
24 | % testVonMisesDriverUniaxial;
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/voigt3dJ2.m:
--------------------------------------------------------------------------------
1 | function [j2,dj2,ddj2] = voigt3dJ2(s)
2 | %voigt3dJ2
3 | % Input: s is the deviatoric part of stress sigma
4 | % Output: J2, dJ2/dsigma, dd(J2)/dd(sigma)
5 |
6 | % J2
7 | % notice the factor 2
8 | j2 = 0.5 * (sum(s(1:3).^2) + 2*sum(s(4:6).^2));
9 |
10 | if nargout > 1
11 | % dJ2/dsig
12 | dj2 = zeros(6,1);
13 | dj2(1:3) = s(1:3);
14 | dj2(4:6) = 2*s(4:6); % notice the factor 2
15 | end
16 |
17 | if nargout > 2
18 | % ddJ2/ddsig
19 | ddj2 = zeros(6);
20 | ddj2(1:3,1:3) = eye(3) - 1/3*ones(3);
21 | ddj2(4:6,4:6) = 2*eye(3); % notice the factor 2
22 | end
23 |
24 |
25 | return
26 | end
27 |
28 |
29 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/voigt3dNorm.m:
--------------------------------------------------------------------------------
1 | function [n] = voigt3dNorm(v)
2 | %voigt3dNorm
3 |
4 | % assert(numel(v) == 6);
5 |
6 | n = sum(v(1:3).^2) + 2*sum(v(4:6).^2);
7 | n = sqrt(n);
8 |
9 |
10 | return
11 | end
12 |
13 |
14 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/voigt3dPressShear.m:
--------------------------------------------------------------------------------
1 | function [p,s] = voigt3dPressShear(vsig)
2 | %voigt3dPressShear
3 |
4 | bm1 = [1;1;1;0;0;0];
5 |
6 | % volumetric pressure
7 | p = mean(vsig(1:3));
8 |
9 | % deviatoric shear
10 | s = vsig - p.*bm1;
11 |
12 |
13 | return
14 | end
15 |
16 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/voigt3dSqrtJ2.m:
--------------------------------------------------------------------------------
1 | function [sqrtj2,dsqrtj2,ddsqrtj2] = voigt3dSqrtJ2(s)
2 | %voigt3dSqrtJ2
3 | % sqrt(J2(s))
4 | %
5 |
6 | [j2,dj2,ddj2] = voigt3dJ2(s);
7 |
8 | % sqrt(J2)
9 | sqrtj2 = sqrt(j2);
10 |
11 | if nargout > 1
12 | dsqrtj2 = 0.5 / sqrtj2 * dj2;
13 | end
14 |
15 | if nargout > 2
16 | ddsqrtj2 = 0.5 / sqrtj2 * (-(dj2*dj2')/(2*j2) + ddj2);
17 | end
18 |
19 |
20 |
21 |
22 | return
23 | end
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/voigtJ2.m:
--------------------------------------------------------------------------------
1 | function [j2,dj2,ddj2] = voigt3dJ2(s)
2 | %voigtJ2
3 | % Input: s is the deviatoric part of stress sigma
4 | % Output: J2, dJ2/dsigma, dd(J2)/dd(sigma)
5 |
6 | assert(numel(s) == 4);
7 |
8 | % J2
9 | % notice the factor 2
10 | j2 = 0.5 * (s(1)^2 + s(2)^2 + s(4)^2 + 2*s(3)^2);
11 |
12 | if nargout > 1
13 | % dJ2/dsig
14 | dj2 = s;
15 | dj2(3) = s(3)*2; % notice the factor 2
16 | end
17 |
18 | if nargout > 2
19 | % ddJ2/ddsig
20 | ddj2 = zeros(4);
21 | ddj2([1,2,4],[1,2,4]) = eye(3) - 1/3*ones(3);
22 | ddj2(3,3) = 2; % notice the factor 2
23 | end
24 |
25 |
26 | return
27 | end
28 |
29 |
30 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/voigtPressShear.m:
--------------------------------------------------------------------------------
1 | function [p,s] = voigtPressShear(sigma)
2 |
3 | bm1 = [ 1; 1; 0; 1 ];
4 |
5 | p = mean(sigma([1 2 4]));
6 | s = sigma - p.*bm1;
7 |
8 |
9 | return
10 | end
11 |
12 |
13 |
--------------------------------------------------------------------------------
/FDPM2Box/test3/voigtSqrtJ2.m:
--------------------------------------------------------------------------------
1 | function [sqrtj2,dsqrtj2,ddsqrtj2] = voigtSqrtJ2(s)
2 | %voigtSqrtJ2
3 | % sqrt(J2(s))
4 | %
5 |
6 | [j2,dj2,ddj2] = voigtJ2(s);
7 |
8 | % sqrt(J2)
9 | sqrtj2 = sqrt(j2);
10 |
11 | if nargout > 1
12 | dsqrtj2 = 0.5 / sqrtj2 * dj2;
13 | end
14 |
15 | if nargout > 2
16 | ddsqrtj2 = 0.5 / sqrtj2 * (-(dj2*dj2')/(2*j2) + ddj2);
17 | end
18 |
19 | return
20 | end
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/fdpmDriverPoissonStabArt.m:
--------------------------------------------------------------------------------
1 |
2 | cart = -0.05;
3 |
4 | for i = 1:numNodes
5 | % nneigh = conn(i).numNeigh;
6 | ineigh = conn(i).neigh2;
7 | ivol = nodeVol(i);
8 |
9 |
10 | %
11 | for j = ineigh
12 | jneigh = conn(j).neigh2;
13 | jvol = nodeVol(j);
14 |
15 | rij = nodePos(j,:) - nodePos(i,:);
16 | wij = 4 - norm(rij)^2 / re^2;
17 |
18 | cij = cart;
19 |
20 | %
21 | Kassem.SpMatAssemBlockWithDof([1,-1].*wij.*cij, i,[j,i]);
22 |
23 | %
24 | Kassem.SpMatAssemBlockWithDof(-rij * [conn(i).dNX; conn(i).dNY] .* wij.*cij, i,ineigh);
25 |
26 | %
27 | Kassem.SpMatAssemBlockWithDof(-rij * [conn(j).dNX; conn(j).dNY] .* wij.*cij, i,jneigh);
28 | end
29 | end
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/fdpmDriverPoissonStabHessian.m:
--------------------------------------------------------------------------------
1 |
2 | for i = 1:numNodes
3 | nneigh = conn(i).numNeigh;
4 | ineigh = conn(i).neigh2;
5 | ivol = nodeVol(i);
6 |
7 | % finite increment
8 | eta = 1.0;
9 | hfic = eta * h0;
10 |
11 | % cfic = 0.25;
12 | cfic = 1.0 / 12;
13 |
14 | if 0
15 | dH = [conn(i).dNXX; conn(i).dNXY; conn(i).dNXY; conn(i).dNYY];
16 | Kfic = dH' * dH * ivol * cfic*hfic^2;
17 | else
18 | Bx = [conn(i).dNXX; conn(i).dNXY];
19 | By = [conn(i).dNXY; conn(i).dNYY];
20 | Kfic = nodeMomXX(i)*Bx'*Bx + nodeMomYY(i)*By'*By + nodeMomXY(i)*Bx'*By + nodeMomXY(i)*By'*Bx;
21 | end
22 |
23 | SpMatAssemBlockWithDof(Kassem, Kfic, ineigh,ineigh);
24 | end
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/fdpmDriverShowStiffEigen.m:
--------------------------------------------------------------------------------
1 | %Show eigen vectors of stiffness matrix: INPUT Ktan
2 |
3 | if 1
4 | % check stiffness K matrix eigen structure
5 |
6 | figure;
7 |
8 | % we copy the K matrix and set Dirichlet BC for boundaries
9 | % Ktan = Ktan0;
10 |
11 | if 1
12 | % Dirichlet BC
13 | Ktan(sub2ind([numDofs,numDofs],dirBCDofs,dirBCDofs)) = 1.0e10;
14 | end
15 |
16 | neig = 20;
17 | % [v,d] = eigs(Ktan, neig);
18 | [v,d] = eigs(Ktan, neig, 'sm'); % from min eigenvalue
19 |
20 | for ieig = 1:neig
21 | vv = v(:,ieig);
22 | % surf(xx,yy, reshape(vv,nlen,nlen), 'FaceColor','interp');
23 | trisurf(tri,nodeX,nodeY, vv, 'FaceColor','interp');
24 | title(['eig(',int2str(ieig),')=',num2str(d(ieig,ieig))]);
25 | pause;
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/mlsInterpWeight.m:
--------------------------------------------------------------------------------
1 | function [] = mlsInterpWeight(rs, re)
2 |
3 | nd = size(rs, 2);
4 |
5 | if nd == 1
6 |
7 | else
8 | error('Invalid dimension');
9 | end
10 |
11 |
12 |
13 | return
14 | end
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/mlsParseInterpOptions.m:
--------------------------------------------------------------------------------
1 |
2 | kvpairs = varargin;
3 | for i = 1:2:length(kvpairs)
4 | key = kvpairs{i};
5 | val = kvpairs{i+1};
6 |
7 | switch key
8 | case 'mls_order'
9 | mls_order = val;
10 | case 'mls_volume'
11 | mls_volume = val;
12 | otherwise
13 | error('Unknown %s',kvpairs{i});
14 | end
15 | end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/testInterpWeight.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | xs = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
5 | % xs = [0.0, 1.5, 3.0, 3.5, 4.0, 5.0, 6.0];
6 |
7 | % re = 2.0;
8 | re = 2.5;
9 | % re = 3.0;
10 |
11 | xx = 1.0:0.01:5.0;
12 | ww = [];
13 | for xint = xx
14 | w = mlsInterpWeight1D(xint, xs, re);
15 | ww(end+1) = w(4);
16 | % ww(end+1,:) = w;
17 | % plot(xx,ww,'x-');
18 | % pause;
19 | end
20 |
21 |
22 | % plot(ww,'-');
23 | plot(xx,ww,'-'); %axis([1 5 0 1])
24 |
25 |
26 | if 1
27 | % use finite difference to check weight derivatives
28 |
29 | dx = 1.0e-5;
30 |
31 | xtest = 4.1;
32 | [w,wx] = mlsInterpWeight1D(xtest, xs, re);
33 |
34 | wp = mlsInterpWeight1D(xtest+dx, xs, re);
35 | wm = mlsInterpWeight1D(xtest-dx, xs, re);
36 | dw = (wp-wm) ./ (dx*2);
37 |
38 | wx
39 | dw
40 | norm(wx-dw)
41 | end
42 |
43 |
44 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/testRegularShape2D.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | re = 2.0;
5 |
6 | xs = linspace(0.0, 6.0, 7);
7 | ys = linspace(0.0, 6.0, 7);
8 | [xs,ys] = ndgrid(xs,ys);
9 | xs = xs(:);
10 | ys = ys(:);
11 |
12 | figure;
13 | plot(xs,ys,'o');
14 | axis equal;
15 |
16 |
17 | if 1
18 | xtest = [ 0.0, 0.0 ];
19 | % xtest = [ 1.0, 1.0 ];
20 | % xtest = [ 2.0, 2.0 ];
21 | % xtest = [ 3.1, 3.1 ];
22 |
23 | neigh = find(sqrt((xtest(1)-xs).^2 + (xtest(2)-ys).^2) < re);
24 |
25 | hold on;
26 | rectangle('Position',[xtest-re [re*2,re*2]], 'Curvature',[1,1]);
27 | plot(xtest(1),xtest(2),'xr', xs(neigh),ys(neigh),'+');
28 | hold off;
29 |
30 | [N,Nx,Ny] = mlsRegularShape2D(xtest, xs(neigh),ys(neigh), re);
31 |
32 | [sum(N), sum(xs(neigh).*N(:)), sum(ys(neigh).*N(:))]
33 |
34 | [Nx; Ny] * [xs(neigh), ys(neigh)]
35 |
36 | end
37 |
38 |
39 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/testRegularWeight.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | xs = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
5 | % xs = [0.0, 1.5, 3.0, 3.5, 4.0, 5.0, 6.0];
6 |
7 | re = 2.0;
8 | % re = 2.5;
9 | % re = 3.0;
10 |
11 | xx = 1.0:0.01:5.0;
12 | ww = [];
13 | for xint = xx
14 | w = mlsRegularWeight1D(xint, xs, re);
15 | ww(end+1) = w(4);
16 | % ww(end+1,:) = w;
17 | % plot(xx,ww,'x-');
18 | % pause;
19 | end
20 |
21 |
22 | figure;
23 | plot(xx,ww,'-'); %axis([1 5 0 1])
24 |
25 |
26 | if 1
27 | % use finite difference to check weight derivatives
28 |
29 | dx = 1.0e-5;
30 |
31 | xtest = 2.0;
32 | [w,wx] = mlsRegularWeight1D(xtest, xs, re);
33 |
34 | wp = mlsRegularWeight1D(xtest+dx, xs, re);
35 | wm = mlsRegularWeight1D(xtest-dx, xs, re);
36 | dw = (wp-wm) ./ (dx*2);
37 |
38 | wx
39 | dw
40 | norm(wx-dw)
41 | end
42 |
43 |
44 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/testRegularWeight2D.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | re = 2.0;
5 | % re = 2.5;
6 | % re = 3.0;
7 |
8 |
9 | xs = linspace(0.0, 6.0, 7);
10 | ys = linspace(0.0, 6.0, 7);
11 |
12 |
13 | % xs = [0.0, 1.5, 3.0, 3.5, 4.0, 5.0, 6.0];
14 |
15 |
16 | if 1
17 | % use finite difference to check weight derivatives
18 |
19 | dx = 1.0e-5;
20 |
21 | xtest = [2.4, 2.0];
22 | [w,wx,wy] = mlsRegularWeight2D(xtest, xs,ys, re);
23 |
24 | wp = mlsRegularWeight2D(xtest+[dx,0], xs,ys, re);
25 | wm = mlsRegularWeight2D(xtest-[dx,0], xs,ys, re);
26 | dwx = (wp-wm) ./ (dx*2);
27 | [wx;dwx]
28 |
29 | wp = mlsRegularWeight2D(xtest+[0,dx], xs,ys, re);
30 | wm = mlsRegularWeight2D(xtest-[0,dx], xs,ys, re);
31 | dwy = (wp-wm) ./ (dx*2);
32 | [wy;dwy]
33 | end
34 |
35 |
36 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/triCircumCenter.m:
--------------------------------------------------------------------------------
1 | function [cc] = triCircumCenter(ax,ay, bx,by, cx,cy)
2 | %triCircumCenter: Compute circumcenter of triangle
3 | % CC is a row vector
4 |
5 | bcy = by - cy;
6 | cay = cy - ay;
7 | aby = ay - by;
8 |
9 | cbx = cx - bx;
10 | acx = ax - cx;
11 | bax = bx - ax;
12 |
13 | a2 = ax.^2 + ay.^2;
14 | b2 = bx.^2 + by.^2;
15 | c2 = cx.^2 + cy.^2;
16 |
17 | dd = 2 .* (ax.*bcy + bx.*cay + cx.*aby);
18 |
19 | uu = (a2.*bcy + b2.*cay + c2.*aby) ./ dd;
20 | vv = (a2.*cbx + b2.*acx + c2.*bax) ./ dd;
21 |
22 | cc = [uu,vv];
23 |
24 |
25 | return
26 | end
27 |
28 |
--------------------------------------------------------------------------------
/FDPM2Box/test5/triRotateMaxAngle.m:
--------------------------------------------------------------------------------
1 | function [ia,ib,ic, la,lb,lc, ta,tb,tc] = triRotateMaxAngle(tri, pos, i)
2 | %triRotateMaxAngle: Rotate index
3 |
4 | i1 = tri(i,1);
5 | i2 = tri(i,2);
6 | i3 = tri(i,3);
7 |
8 | l1 = norm(pos(i2,:)-pos(i3,:));
9 | l2 = norm(pos(i3,:)-pos(i1,:));
10 | l3 = norm(pos(i1,:)-pos(i2,:));
11 |
12 | ll = [l1,l2,l3];
13 |
14 | ii = 1;
15 | if l2 > ll(ii)
16 | ii = 2;
17 | end
18 | if l3 > ll(ii)
19 | ii = 3;
20 | end
21 |
22 | if ii == 1
23 | ia = i1; ib = i2; ic = i3;
24 | la = l1; lb = l2; lc = l3;
25 | elseif ii == 2
26 | ia = i2; ib = i3; ic = i1;
27 | la = l2; lb = l3; lc = l1;
28 | else
29 | ia = i3; ib = i1; ic = i2;
30 | la = l3; lb = l1; lc = l2;
31 | end
32 | assert(la>=lb && la>=lc);
33 |
34 | if nargout > 6
35 | ta = acos((lb^2+lc^2-la^2)/(2*lb*lc));
36 | tb = acos((lc^2+la^2-lb^2)/(2*lc*la));
37 | tc = pi - ta - tb;
38 | end
39 |
40 |
41 |
42 |
43 | return
44 | end
45 |
46 |
--------------------------------------------------------------------------------
/FDPM2Box/testBarNecking/testBarNecking.geo:
--------------------------------------------------------------------------------
1 |
2 | //
3 | R0 = 6.413e-3;
4 | Rmid = R0 * 0.982;
5 | L0 = 53.334e-3;
6 | Lmid = L0 * 0.5;
7 |
8 | //
9 | dh1 = 0.4e-3;
10 | dh2 = 2e-3;
11 |
12 |
13 | Point(1) = {0,0,0, dh1};
14 | Point(2) = {Rmid,0,0, dh1};
15 | Point(3) = {R0,Lmid,0, dh2};
16 | Point(4) = {0,Lmid,0, dh2};
17 |
18 |
19 |
20 |
21 | //+
22 | Line(1) = {1, 2};
23 | //+
24 | Line(2) = {2, 3};
25 | //+
26 | Line(3) = {3, 4};
27 | //+
28 | Line(4) = {4, 1};
29 | //+
30 | Line Loop(5) = {4, 1, 2, 3};
31 | //+
32 | Plane Surface(6) = {5};
33 | //+
34 | Physical Line("left") = {4};
35 | //+
36 | Physical Line("right") = {2};
37 | //+
38 | Physical Line("bottom") = {1};
39 | //+
40 | Physical Line("top") = {3};
41 | //+
42 | Physical Surface("bar") = {6};
43 |
--------------------------------------------------------------------------------
/FDPM2Box/testBeamTimo/fdpmDriverShowLinElasticStiffEigen.m:
--------------------------------------------------------------------------------
1 |
2 | if 1
3 | if ~exist('plot_disp_scale','var')
4 | plot_disp_scale = 50.0;
5 | end
6 |
7 | figure;
8 | neig = 10;
9 | [v,d] = eigs(Ktan, neig, 'sm');
10 | for ieig = 1:neig
11 | vv = v(:,ieig);
12 | vv = reshape(vv, 2, []).';
13 | triplot(tri, nodeX+plot_disp_scale.*vv(:,1), nodeY+plot_disp_scale.*vv(:,2));
14 | title(['eig(',int2str(ieig),')=',num2str(d(ieig,ieig))]);
15 | axis equal;
16 | pause;
17 | end
18 | end
19 |
20 |
21 |
--------------------------------------------------------------------------------
/FDPM2Box/testPlateHole/plate.geo:
--------------------------------------------------------------------------------
1 |
2 | R = 1;
3 | L = 5;
4 |
5 |
6 | size1 = 0.05;
7 | size2 = 0.5;
8 |
9 |
10 | Point(1) = {0, 0, 0, size1};
11 | Point(2) = {R, 0, 0, size1};
12 | Point(3) = {0, R, 0, size1};
13 | Point(4) = {L, 0, 0, size2};
14 | Point(5) = {L, L, 0, size2};
15 | Point(6) = {0, L, 0, size2};
16 |
17 | Line(1) = {2, 4};
18 | Line(2) = {4, 5};
19 | Line(3) = {5, 6};
20 | Line(4) = {6, 3};
21 | Circle(5) = {3, 1, 2};
22 | Line Loop(7) = {4, 5, 1, 2, 3};
23 |
24 | Plane Surface(7) = {7};
25 |
26 | //+
27 | Physical Line("bottom") = {1};
28 | //+
29 | Physical Line("left") = {4};
30 | //+
31 | Physical Line("right") = {2};
32 | //+
33 | Physical Line("top") = {3};
34 | //+
35 | Physical Line("hole") = {5};
36 | //+
37 | Physical Surface("plate") = {7};
38 |
--------------------------------------------------------------------------------
/FDPM2Box/testPlateHole/testLoadPlateMesh.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | [groups,nodes] = gmshLoad('plate.msh');
5 |
6 |
7 | figure;
8 | plot(nodes(:,1),nodes(:,2),'.k');
9 | hold on;
10 | group = gmshGetGroupByName(groups,'hole');
11 | conn = group.conn;
12 | if size(conn,2) == 2
13 | for i = 1:size(conn, 1)
14 | plot(nodes(conn(i,:),1), nodes(conn(i,:),2));
15 | end
16 | else
17 | triplot(conn, nodes(:,1), nodes(:,2));
18 | end
19 | hold off;
20 | axis equal;
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/FDPM2Box/testPresHalfPlane/presLoadHalfPlane.geo:
--------------------------------------------------------------------------------
1 |
2 | a = 1.0;
3 | L = 3.0;
4 |
5 | yprobe = 2.0;
6 |
7 | dh1 = 0.2;
8 | dh2 = 0.2;
9 |
10 | Point(1) = {0, 0, 0, dh1};
11 | Point(2) = {L, 0, 0, dh1};
12 | Point(3) = {L, L, 0, dh2};
13 | Point(4) = {0, L, 0, dh1};
14 | Point(5) = {L-a, L, 0, dh2}; //
15 | Point(6) = {0, yprobe, 0, dh1}; //
16 | Point(7) = {L, yprobe, 0, dh1}; //
17 |
18 |
19 |
20 |
21 | Line(1) = {1, 2};
22 | Line(2) = {2, 7};
23 | Line(3) = {7, 3};
24 | Line(4) = {3, 5};
25 | Line(5) = {5, 4};
26 | Line(6) = {4, 6};
27 | Line(7) = {6, 1};
28 | Line(8) = {6, 7};
29 |
30 | Line Loop(9) = {7, 1, 2, -8};
31 | Plane Surface(10) = {9};
32 | Line Loop(11) = {6, 8, 3, 4, 5};
33 | Plane Surface(12) = {11};
34 |
35 |
36 | Physical Line("left") = {6, 7};
37 | Physical Line("right") = {2, 3};
38 | Physical Line("bottom") = {1};
39 | Physical Line("topfree") = {5};
40 | Physical Line("topload") = {4};
41 | Physical Line("yline") = {8};
42 | Physical Surface("plane") = {10, 12};
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/FDPM2Box/testTubeHillEP/tube.geo:
--------------------------------------------------------------------------------
1 |
2 | R1 = 1.0;
3 | R2 = 2.0;
4 |
5 | dh1 = 0.02;
6 | dh2 = 0.2;
7 |
8 |
9 | Point(1) = {0, 0, 0, dh1};
10 | Point(2) = {R1, 0, 0, dh1};
11 | Point(3) = {R2, 0, 0, dh2};
12 | Point(4) = {0, R2, 0, dh2};
13 | Point(5) = {0, R1, 0, dh1};
14 |
15 | Line(1) = {2, 3};
16 | Circle(2) = {3, 1, 4};
17 | Line(3) = {4, 5};
18 | Circle(4) = {5, 1, 2};
19 |
20 | Line Loop(5) = {2, 3, 4, 1};
21 | Plane Surface(6) = {5};
22 |
23 | Physical Line("bottom") = {1};
24 | Physical Line("left") = {3};
25 | Physical Line("inner") = {4};
26 | Physical Line("outer") = {2};
27 | Physical Surface("tube") = {6};
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/FDPM2Box/util/+gmsh/Group.m:
--------------------------------------------------------------------------------
1 | %gmsh.Group create a physical group
2 | %
3 |
4 | classdef Group < handle
5 |
6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 | properties
8 | ndim;
9 | name;
10 | conn;
11 |
12 | nodeIds;
13 | end
14 |
15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 | methods
17 |
18 | function [obj] = Group()
19 | obj.ndim = 0;
20 | obj.name = '';
21 | obj.conn = [];
22 |
23 | obj.nodeIds = [];
24 | end
25 |
26 | function [ids] = nodes(obj)
27 | nmax = max(obj.conn(:));
28 | ids = zeros(nmax, 1);
29 | for i = 1:size(obj.conn,2)
30 | ids(obj.conn(:,i)) = 1;
31 | end
32 | ids = find(ids == 1);
33 | end
34 |
35 |
36 | end
37 |
38 |
39 |
40 |
41 | end
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/FDPM2Box/util/gauss1dGen.m:
--------------------------------------------------------------------------------
1 | function [] = gauss1dGen()
2 |
3 | return
4 | end
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/FDPM2Box/util/gauss2dRectTensorPoint.m:
--------------------------------------------------------------------------------
1 | function [gn,gp,gw] = gauss2dRectTensorPoint(gnx, gny)
2 | %gauss2dRectTensorPoint: 2D tensor product of 1D gauss
3 |
4 |
5 | if nargin == 1
6 | gny = gnx;
7 | end
8 |
9 | % create 1d points
10 | [gpx,gwx] = gauss1dPoint(gnx);
11 | [gpy,gwy] = gauss1dPoint(gny);
12 |
13 | % tensor product
14 | gx = zeros(gnx,gny);
15 | gy = zeros(gnx,gny);
16 | gw = zeros(gnx,gny);
17 |
18 | for j = 1:gny
19 | for i = 1:gnx
20 | gx(i,j) = gpx(i);
21 | gy(i,j) = gpy(j);
22 | gw(i,j) = gwx(i) * gwy(j);
23 | end
24 | end
25 |
26 | gn = gnx * gny;
27 | gp = [gx(:),gy(:)];
28 | gw = gw(:);
29 |
30 |
31 | return
32 | end
33 |
--------------------------------------------------------------------------------
/FDPM2Box/util/gmshGetGroupByName.m:
--------------------------------------------------------------------------------
1 | function [g] = gmshGetGroupByName(groups, name)
2 |
3 | g = [];
4 | for i = 1:length(groups)
5 | if strcmp(groups(i).name, name)
6 | g = groups(i);
7 | break;
8 | end
9 | end
10 |
11 | return
12 | end
13 |
14 |
--------------------------------------------------------------------------------
/FDPM2Box/util/legendreP.m:
--------------------------------------------------------------------------------
1 | function [p] = legendreP(n, x)
2 |
3 | ps = legendre(n, x);
4 |
5 | p = ps(1,:);
6 |
7 | p = reshape(p, size(x));
8 |
9 | return
10 | end
11 |
12 |
13 |
--------------------------------------------------------------------------------
/FDPM2Box/util/voigtDecode.m:
--------------------------------------------------------------------------------
1 | function [m] = voigtDecode(v, off_scale)
2 |
3 | if off_scale
4 | s = 0.5;
5 | else
6 | s = 1.0;
7 | end
8 |
9 | m = [ v(1), s*v(3), 0; s*v(3), v(2), 0; 0, 0, v(4) ];
10 |
11 |
12 | return
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/FDPM2Box/util/voigtEncode.m:
--------------------------------------------------------------------------------
1 | function [v] = voigtEncode(m, off_scale)
2 |
3 | if off_scale
4 | s = 2.0;
5 | else
6 | s = 1.0;
7 | end
8 |
9 | v = [ m(1,1); m(2,2); s*m(1,2); m(3,3) ];
10 |
11 |
12 | return
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/FEM2DBox/GenerateMesh.m:
--------------------------------------------------------------------------------
1 | % ## Copyright (C) 2013 homu
2 | % ##
3 | % ## This program is free software; you can redistribute it and/or modify
4 | % ## it under the terms of the GNU General Public License as published by
5 | % ## the Free Software Foundation; either version 3 of the License, or
6 | % ## (at your option) any later version.
7 | % ##
8 | % ## This program is distributed in the hope that it will be useful,
9 | % ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % ## GNU General Public License for more details.
12 | % ##
13 | % ## You should have received a copy of the GNU General Public License
14 | % ## along with Octave; see the file COPYING. If not, see
15 | % ## .
16 |
17 | % ## GenerateMesh
18 |
19 | % ## Author: homu
20 | % ## Created: 2013-07-30
21 |
22 | function [ ret ] = GenerateMesh ()
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/FastMultipoleBox/Simple1D/LevelNodeNum1D.m:
--------------------------------------------------------------------------------
1 |
2 | function [ num ] = LevelNodeNum1D(ilevel)
3 | % Node number on given level.
4 |
5 | num = 2^(ilevel-1);
6 |
7 | return
8 | end
9 |
10 |
--------------------------------------------------------------------------------
/FastMultipoleBox/Simple1D/LevelNodeRange1D.m:
--------------------------------------------------------------------------------
1 |
2 | function [ range ] = LevelNodeRange1D(ilevel)
3 | % Node ID range on given level.
4 |
5 | range = 2^(ilevel-1):(2^ilevel-1);
6 |
7 | return
8 | end
9 |
10 |
--------------------------------------------------------------------------------
/FemNSBox/nsfem_report.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FemNSBox/nsfem_report.pdf
--------------------------------------------------------------------------------
/FemNSBox/tmp.txt:
--------------------------------------------------------------------------------
1 | clear;
2 |
3 | fstats=@(p,t) fprintf('%d nodes, %d elements, min quality %.2f\n', ...
4 | size(p,1),size(t,1),min(simpqual(p,t)));
5 |
6 | fprintf('Rectangle with circular hole, refined at circle boundary\n');
7 |
8 | xlo = -0.2;
9 | xhi = 2.0;
10 | ylo = -0.2;
11 | yhi = 0.2;
12 | R = 0.05;
13 |
14 | h = R * 0.1;
15 |
16 | fd=@(p) ddiff(drectangle(p,xlo,xhi,ylo,yhi),dcircle(p,0,0,R));
17 | fh=@(p) h+0.1*dcircle(p,0,0,R);
18 | % fh=@(p) huniform(p);
19 |
20 | figure;
21 | [p,t]=distmesh2d(fd,fh,h, ...
22 | [xlo,ylo;xhi,yhi], ...
23 | [xlo,ylo;xlo,yhi;xhi,ylo;xhi,yhi]);
24 |
25 | fstats(p,t);
26 |
27 |
28 |
--------------------------------------------------------------------------------
/FemToolBox/FESpaceMake.m:
--------------------------------------------------------------------------------
1 | function [fespace] = FESpaceMake(mesh, elem_type, var_dim)
2 |
3 | fespace = FESpace();
4 |
5 | % fespace.mesh = mesh;
6 |
7 | %
8 | fespace.mesh = mesh;
9 |
10 | %
11 | fespace.type = elem_type;
12 | fespace.vdim = var_dim;
13 |
14 | %
15 | switch elem_type
16 | case 'Q1'
17 | if mesh.type == 'quad'
18 | % fespace.nVert = mesh.nVert;
19 | fespace.nNode = mesh.nVert;
20 | fespace.nElem = mesh.nElem;
21 | fespace.nodes = mesh.verts;
22 | fespace.elems = mesh.conn;
23 | else
24 | error('Wrong mesh.type=%s',mesh.type);
25 | end
26 | otherwise
27 | error('Unsupport ELEM_TYPE=%s',elem_type);
28 | end
29 |
30 | %
31 | fespace.nDofs = fespace.nNode;
32 | fespace.nSize = fespace.nNode * fespace.vdim;
33 |
34 |
35 |
36 | return
37 | end
38 |
39 |
--------------------------------------------------------------------------------
/FemToolBox/GenerateMesh.m:
--------------------------------------------------------------------------------
1 | % ## Copyright (C) 2013 homu
2 | % ##
3 | % ## This program is free software; you can redistribute it and/or modify
4 | % ## it under the terms of the GNU General Public License as published by
5 | % ## the Free Software Foundation; either version 3 of the License, or
6 | % ## (at your option) any later version.
7 | % ##
8 | % ## This program is distributed in the hope that it will be useful,
9 | % ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % ## GNU General Public License for more details.
12 | % ##
13 | % ## You should have received a copy of the GNU General Public License
14 | % ## along with Octave; see the file COPYING. If not, see
15 | % ## .
16 |
17 | % ## GenerateMesh
18 |
19 | % ## Author: homu
20 | % ## Created: 2013-07-30
21 |
22 | function [ ret ] = GenerateMesh ()
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/FTInit.m:
--------------------------------------------------------------------------------
1 |
2 | function [] = FTInit(pt0,tri0,nbr0)
3 |
4 | FTRegridGlobals;
5 |
6 | np = size(pt0,1);
7 | nelem = size(tri0,1);
8 |
9 | % copy to storage
10 | pt(1:np,:) = pt0;
11 | icp(1:nelem,:) = tri0;
12 | ine(1:nelem,:) = nbr0;
13 |
14 | % initialize link list
15 | ffp = 1;
16 | lfp = np;
17 | fep = np+1;
18 | %
19 | ptcon(ffp:lfp-1) = ffp+1:lfp;
20 | ptcon(lfp) = ffp;
21 | bptcon(ffp+1:lfp) = ffp:lfp-1;
22 | bptcon(ffp) = lfp;
23 | %
24 | ptcon(fep:maxpt-1) = fep+1:maxpt;
25 | ptcon(maxpt) = fep;
26 | bptcon(fep+1:maxpt) = fep:maxpt-1;
27 | bptcon(fep) = maxpt;
28 |
29 | %
30 | ffe = 1;
31 | lfe = nelem;
32 | fee = nelem+1;
33 | %
34 | elcon(ffe:lfe-1) = ffe+1:lfe;
35 | elcon(lfe) = ffe;
36 | belcon(ffe+1:lfe) = ffe:lfe-1;
37 | belcon(ffe) = lfe;
38 | %
39 | elcon(fee:maxel-1) = fee+1:maxel;
40 | elcon(maxel) = fee;
41 | belcon(fee+1:maxel) = fee:maxel-1;
42 | belcon(fee) = maxel;
43 |
44 | return
45 | end
46 |
47 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/FTRegrid.m:
--------------------------------------------------------------------------------
1 |
2 | function [] = FTRegrid()
3 |
4 | FTRegridGlobals;
5 |
6 | ipassmax = 6;
7 |
8 | for ipass = 1:ipassmax
9 |
10 | neladd = FTRegridAddElem();
11 |
12 | neldel = FTRegridDelElem();
13 |
14 | fprintf('IPASS=%d,NADD=%d,NDEL=%d\n', ipass, neladd,neldel);
15 |
16 | if (neladd==0 && neldel==0); break; end
17 | end
18 |
19 | return
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/FTRegridAddElem.m:
--------------------------------------------------------------------------------
1 |
2 | function [ neladd ] = FTRegridAddElem()
3 |
4 | FTRegridGlobals;
5 |
6 | neladd = 0;
7 |
8 | ke = ffe;
9 | % this loop takes MAXEL, because elements are being dynamically added
10 | for kk = 1:maxel
11 | %
12 | [s,n] = felside(ke,icp,pt);
13 |
14 | flag = 0;
15 | if (s(3)>amax)
16 | flag = 1;
17 | end
18 | if (s(1)>amin)
19 | aspr = faspr(ke,icp,pt);
20 | if (aspr > aspmax)
21 | flag = 1;
22 | end
23 | end
24 |
25 | if (flag == 1)
26 | % add 2 elements, one for current, one for its neighbor
27 | if (np+1>=maxpt); error('point overflow'); end
28 | if (nelem+2>=maxel); error('element overflow'); end
29 |
30 | %
31 | faddel(ke,n(3));
32 |
33 | neladd = neladd + 2;
34 | end
35 |
36 | if (ke==lfe); break; end
37 | ke = elcon(ke);
38 | end
39 |
40 |
41 | return
42 | end
43 |
44 |
45 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/FTRegridDelElem.m:
--------------------------------------------------------------------------------
1 |
2 | function [ neldel ] = FTRegridDelElem()
3 |
4 | FTRegridGlobals;
5 |
6 | neldel = 0;
7 |
8 | ke = ffe;
9 | % this loop takes MAXEL, because elements are being dynamically deleted
10 | for kk = 1:maxel
11 | %
12 | [s,n] = felside(ke,icp,pt);
13 |
14 | flag = 0;
15 | if s(1) < amin
16 | flag = 1;
17 | end
18 |
19 | kenew = ke;
20 | if (flag == 1)
21 | kenew = fdelel(ke,n(1));
22 |
23 | neldel = neldel + 2;
24 | end
25 |
26 | if (ke==lfe); break; end
27 |
28 | if kenew==ke
29 | ke = elcon(ke);
30 | else
31 | ke = kenew;
32 | end
33 | end
34 |
35 |
36 | return
37 | end
38 |
39 |
40 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/FTRegridGlobals.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | global maxpt
4 | global maxel
5 |
6 | %
7 | global np
8 | global ffp lfp fep ptcon bptcon
9 | global pt % node position
10 | %
11 | global nelem
12 | global ffe lfe fee elcon belcon
13 | global icp % element's 3 nodes
14 | global ine % element's 3 neighbor elements
15 |
16 | global dh am amax amin aspmax
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/LinkListAdd.m:
--------------------------------------------------------------------------------
1 |
2 | function [ newid num head tail free next prev ] = LinkListAdd(...
3 | num,head,tail,free,next,prev, maxnum)
4 |
5 | if num+1 > maxnum
6 | fprintf('Link List: MAXNUM=%d\n',maxnum);
7 | error('Link List overflow');
8 | end
9 |
10 | % sieze new ID
11 | newid = free;
12 | free = next(free);
13 |
14 | next(newid) = next(tail);
15 | next(tail) = newid;
16 | prev(newid) = tail;
17 | prev(head) = newid;
18 |
19 | tail = newid;
20 |
21 | num = num + 1;
22 |
23 | return
24 | end
25 |
26 |
27 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/LinkListDel.m:
--------------------------------------------------------------------------------
1 |
2 | function [ num head tail free next prev ] = LinkListDel(oldid, ...
3 | num,head,tail,free,next,prev, maxnum)
4 |
5 | % adjust the used list
6 | if oldid == head
7 | head = next(head);
8 | end
9 | if oldid == tail
10 | tail = prev(oldid);
11 | end
12 | if prev(oldid)==0 || next(oldid)==0
13 | fprintf('ID=%d,PREV=%d,NEXT=%d\n',oldid,prev(oldid),next(oldid));
14 | end
15 | next(prev(oldid)) = next(oldid);
16 | prev(next(oldid)) = prev(oldid);
17 |
18 | % adjust the free list
19 | next(oldid) = free;
20 | prev(oldid) = prev(free);
21 | prev(free) = oldid;
22 | free = oldid;
23 |
24 | num = num - 1;
25 |
26 | return
27 | end
28 |
29 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/ProblemGlobals.m:
--------------------------------------------------------------------------------
1 |
2 | % RK vortex parameter
3 | global U T
4 |
5 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/VortVel.m:
--------------------------------------------------------------------------------
1 |
2 | function [u,v,w] = VortVel(x,y,z,t)
3 |
4 | ProblemGlobals;
5 | % U = 1.0;
6 | % T = 8.0;
7 |
8 | sx = sin(pi.*x);
9 | sy = sin(pi.*y);
10 | cx = cos(pi.*x);
11 | cy = cos(pi.*y);
12 |
13 | u = -U*cos(pi*t/T) .* (sx.^2) .* (2*sy.*cy);
14 | v = U*cos(pi*t/T) .* (sy.^2) .* (2*sx.*cx);
15 | w = zeros(size(u));
16 |
17 | return
18 | end
19 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/boundedges.m:
--------------------------------------------------------------------------------
1 | function e=boundedges(p,t)
2 | %BOUNDEDGES Find boundary edges from triangular mesh
3 | % E=BOUNDEDGES(P,T)
4 |
5 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
6 |
7 | % Form all edges, non-duplicates are boundary edges
8 | edges=[t(:,[1,2]);
9 | t(:,[1,3]);
10 | t(:,[2,3])];
11 | node3=[t(:,3);t(:,2);t(:,1)];
12 | edges=sort(edges,2);
13 | [foo,ix,jx]=unique(edges,'rows');
14 | vec=histc(jx,1:max(jx));
15 | qx=find(vec==1);
16 | e=edges(ix(qx),:);
17 | node3=node3(ix(qx));
18 |
19 | % Orientation
20 | v1=p(e(:,2),:)-p(e(:,1),:);
21 | v2=p(node3,:)-p(e(:,1),:);
22 | ix=find(v1(:,1).*v2(:,2)-v1(:,2).*v2(:,1)>0);
23 | e(ix,[1,2])=e(ix,[2,1]);
24 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/circumcenter.m:
--------------------------------------------------------------------------------
1 | function [pc,r]=circumcenter(p,t)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | nt=size(t,1);
6 | pc=zeros(nt,2);
7 | r=zeros(nt,1);
8 |
9 | for it=1:nt
10 | ct=t(it,:);
11 | dp1=p(ct(2),:)-p(ct(1),:);
12 | dp2=p(ct(3),:)-p(ct(1),:);
13 |
14 | mid1=(p(ct(2),:)+p(ct(1),:))/2;
15 | mid2=(p(ct(3),:)+p(ct(1),:))/2;
16 |
17 | s=[-dp1(2),dp2(2);dp1(1),-dp2(1)]\[-mid1+mid2]';
18 |
19 | cpc=mid1+s(1)*[-dp1(2),dp1(1)];
20 | cr=norm(p(ct(1),:)-cpc);
21 |
22 | pc(it,:)=cpc;
23 | r(it,1)=cr;
24 | end
25 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dblock.m:
--------------------------------------------------------------------------------
1 | function d=dblock(p,x1,x2,y1,y2,z1,z2)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=-min(min(min(min(min(-z1+p(:,3),z2-p(:,3)),-y1+p(:,2)),y2-p(:,2)),-x1+p(:,1)),x2-p(:,1));
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dcircle.m:
--------------------------------------------------------------------------------
1 | function d=dcircle(p,xc,yc,r)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=sqrt((p(:,1)-xc).^2+(p(:,2)-yc).^2)-r;
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/ddiff.m:
--------------------------------------------------------------------------------
1 | function d=ddiff(d1,d2), d=max(d1,-d2);
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dellipse.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dellipse.mexa64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dellipse.mexmaci64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dellipse.mexmaci64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dellipse.mexw32:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dellipse.mexw32
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dellipse.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dellipse.mexw64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dellipsoid.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dellipsoid.mexa64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dellipsoid.mexmaci64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dellipsoid.mexmaci64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dellipsoid.mexw32:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dellipsoid.mexw32
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dellipsoid.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dellipsoid.mexw64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dintersect.m:
--------------------------------------------------------------------------------
1 | function d=dintersect(d1,d2), d=max(d1,d2);
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dmatrix.m:
--------------------------------------------------------------------------------
1 | function d=dmatrix(p,xx,yy,dd,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=interp2(xx,yy,dd,p(:,1),p(:,2),'*linear');
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dmatrix3d.m:
--------------------------------------------------------------------------------
1 | function d=dmatrix3d(p,xx,yy,zz,dd,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=interpn(xx,yy,zz,dd,p(:,1),p(:,2),p(:,3),'*linear');
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dpoly.m:
--------------------------------------------------------------------------------
1 | function d=dpoly(p,pv)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | np=size(p,1);
6 | nvs=size(pv,1)-1;
7 |
8 | ds=dsegment(p,pv);
9 | %ds=zeros(np,nvs);
10 | %for iv=1:nvs
11 | % ds(:,iv)=donesegment(p,pv(iv:iv+1,:));
12 | %end
13 | d=min(ds,[],2);
14 |
15 | d=(-1).^(inpolygon(p(:,1),p(:,2),pv(:,1),pv(:,2))).*d;
16 |
17 | % MEXED
18 |
19 | %function ds=donesegment(p,pv)
20 | %
21 | %e=ones(size(p,1),1);
22 | %
23 | %v=diff(pv,1);
24 | %w=p-e*pv(1,:);
25 | %
26 | %c1=sum(w.*v(e,:),2);
27 | %c2=sum(v(e,:).^2,2);
28 | %
29 | %ds=0*e;
30 | %
31 | %ix=c1<=0;
32 | %ds(ix)=sqrt(sum((p(ix,:)-pv(1*ones(sum(ix),1),:)).^2,2));
33 | %
34 | %ix=c1>=c2;
35 | %ds(ix)=sqrt(sum((p(ix,:)-pv(2*ones(sum(ix),1),:)).^2,2));
36 | %
37 | %ix=c1>0 & c2>c1;
38 | %nix=sum(ix);
39 | %if nix>0
40 | % Pb=ones(nix,1)*pv(1,:)+c1(ix)./c2(ix)*v;
41 | % ds(ix)=sqrt(sum((p(ix,:)-Pb).^2,2));
42 | %end
43 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/drectangle.m:
--------------------------------------------------------------------------------
1 | function d=drectangle(p,x1,x2,y1,y2)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=-min(min(min(-y1+p(:,2),y2-p(:,2)),-x1+p(:,1)),x2-p(:,1));
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/drectangle0.m:
--------------------------------------------------------------------------------
1 | function d=drectangle0(p,x1,x2,y1,y2)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d1=y1-p(:,2);
6 | d2=-y2+p(:,2);
7 | d3=x1-p(:,1);
8 | d4=-x2+p(:,1);
9 |
10 | d5=sqrt(d1.^2+d3.^2);
11 | d6=sqrt(d1.^2+d4.^2);
12 | d7=sqrt(d2.^2+d3.^2);
13 | d8=sqrt(d2.^2+d4.^2);
14 |
15 | d=-min(min(min(-d1,-d2),-d3),-d4);
16 |
17 | ix=d1>0 & d3>0;
18 | d(ix)=d5(ix);
19 | ix=d1>0 & d4>0;
20 | d(ix)=d6(ix);
21 | ix=d2>0 & d3>0;
22 | d(ix)=d7(ix);
23 | ix=d2>0 & d4>0;
24 | d(ix)=d8(ix);
25 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dsegment.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dsegment.mexa64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dsegment.mexmaci64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dsegment.mexmaci64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dsegment.mexw32:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dsegment.mexw32
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dsegment.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/dsegment.mexw64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dsphere.m:
--------------------------------------------------------------------------------
1 | function d=dsphere(p,xc,yc,zc,r)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=sqrt((p(:,1)-xc).^2+(p(:,2)-yc).^2+(p(:,3)-zc).^2)-r;
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/dunion.m:
--------------------------------------------------------------------------------
1 | function d=dunion(d1,d2), d=min(d1,d2);
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/fixmesh.m:
--------------------------------------------------------------------------------
1 | function [p,t,pix]=fixmesh(p,t,ptol)
2 | %FIXMESH Remove duplicated/unused nodes and fix element orientation.
3 | % [P,T]=FIXMESH(P,T)
4 |
5 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
6 |
7 | if nargin<3, ptol=1024*eps; end
8 | if nargin>=2 & (isempty(p) | isempty(t)), pix=1:size(p,1); return; end
9 |
10 | snap=max(max(p,[],1)-min(p,[],1),[],2)*ptol;
11 | [foo,ix,jx]=unique(round(p/snap)*snap,'rows');
12 | p=p(ix,:);
13 |
14 | if nargin>=2
15 | t=reshape(jx(t),size(t));
16 |
17 | [pix,ix1,jx1]=unique(t);
18 | t=reshape(jx1,size(t));
19 | p=p(pix,:);
20 | pix=ix(pix);
21 |
22 | if size(t,2)==size(p,2)+1
23 | flip=simpvol(p,t)<0;
24 | t(flip,[1,2])=t(flip,[2,1]);
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/hmatrix.m:
--------------------------------------------------------------------------------
1 | function h=hmatrix(p,xx,yy,dd,hh,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | h=interp2(xx,yy,hh,p(:,1),p(:,2),'*linear');
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/hmatrix3d.m:
--------------------------------------------------------------------------------
1 | function h=hmatrix3d(p,xx,yy,zz,dd,hh,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | h=interpn(xx,yy,zz,hh,p(:,1),p(:,2),p(:,3),'*linear');
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/huniform.m:
--------------------------------------------------------------------------------
1 | function h=huniform(p,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | h=ones(size(p,1),1);
6 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/protate.m:
--------------------------------------------------------------------------------
1 | function p=protate(p,phi)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | A=[cos(phi),-sin(phi);sin(phi),cos(phi)];
6 | p=p*A;
7 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/pshift.m:
--------------------------------------------------------------------------------
1 | function p=pshift(p,x0,y0)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | p(:,1)=p(:,1)+x0;
6 | p(:,2)=p(:,2)+y0;
7 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/simpvol.m:
--------------------------------------------------------------------------------
1 | function v=simpvol(p,t)
2 | %SIMPVOL Simplex volume.
3 | % V=SIMPVOL(P,T)
4 |
5 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
6 |
7 | switch size(p,2)
8 | case 1
9 | d12=p(t(:,2),:)-p(t(:,1),:);
10 | v=d12;
11 | case 2
12 | d12=p(t(:,2),:)-p(t(:,1),:);
13 | d13=p(t(:,3),:)-p(t(:,1),:);
14 | v=(d12(:,1).*d13(:,2)-d12(:,2).*d13(:,1))/2;
15 | case 3
16 | d12=p(t(:,2),:)-p(t(:,1),:);
17 | d13=p(t(:,3),:)-p(t(:,1),:);
18 | d14=p(t(:,4),:)-p(t(:,1),:);
19 | v=dot(cross(d12,d13,2),d14,2)/6;
20 | otherwise
21 | v=zeros(size(t,1),1);
22 | for ii=1:size(t,1)
23 | A=zeros(size(p,2)+1);
24 | A(:,1)=1;
25 | for jj=1:size(p,2)+1
26 | A(jj,2:end)=p(t(ii,jj),:);
27 | end
28 | v(ii)=det(A);
29 | end
30 | v=v/factorial(size(p,2));
31 | end
32 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/surftri.m:
--------------------------------------------------------------------------------
1 | function tri=surftri(p,t)
2 | %SURFTRI Find surface triangles from tetrahedra mesh
3 | % TRI=SURFTRI(P,T)
4 |
5 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
6 |
7 | % Form all faces, non-duplicates are surface triangles
8 | faces=[t(:,[1,2,3]);
9 | t(:,[1,2,4]);
10 | t(:,[1,3,4]);
11 | t(:,[2,3,4])];
12 | node4=[t(:,4);t(:,3);t(:,2);t(:,1)];
13 | faces=sort(faces,2);
14 | [foo,ix,jx]=unique(faces,'rows');
15 | vec=histc(jx,1:max(jx));
16 | qx=find(vec==1);
17 | tri=faces(ix(qx),:);
18 | node4=node4(ix(qx));
19 |
20 | % Orientation
21 | v1=p(tri(:,2),:)-p(tri(:,1),:);
22 | v2=p(tri(:,3),:)-p(tri(:,1),:);
23 | v3=p(node4,:)-p(tri(:,1),:);
24 | ix=find(dot(cross(v1,v2,2),v3,2)>0);
25 | tri(ix,[2,3])=tri(ix,[3,2]);
26 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/trisurfupd.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/trisurfupd.mexa64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/trisurfupd.mexmaci64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/trisurfupd.mexmaci64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/trisurfupd.mexw32:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/trisurfupd.mexw32
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/trisurfupd.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontRegriddingBox/distmesh/trisurfupd.mexw64
--------------------------------------------------------------------------------
/FrontRegriddingBox/distmesh/uniformity.m:
--------------------------------------------------------------------------------
1 | function u=uniformity(p,t,fh,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | [pc,r]=circumcenter(p,t);
6 | hc=feval(fh,pc,varargin{:});
7 |
8 | sz=r./hc;
9 | u=std(sz)/mean(sz);
10 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/faspr.m:
--------------------------------------------------------------------------------
1 |
2 | function [ aspr ] = faspr(ke,icp,pt)
3 |
4 | kp1 = icp(ke,1);
5 | kp2 = icp(ke,2);
6 | kp3 = icp(ke,3);
7 |
8 | p1 = pt(kp1,:);
9 | p2 = pt(kp2,:);
10 | p3 = pt(kp3,:);
11 |
12 | s1 = norm(p2-p1);
13 | s2 = norm(p3-p2);
14 | s3 = norm(p1-p3);
15 | s = (s1+s2+s3)/3.0;
16 |
17 | at = norm(cross(p2-p1,p3-p1));
18 |
19 | aspr = 0.5*s*s*sqrt(3)/at;
20 |
21 | return
22 | end
23 |
24 |
25 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/felside.m:
--------------------------------------------------------------------------------
1 |
2 | function [len,ind] = felside(ke,icp,pt)
3 |
4 | % FTRegridGlobals;
5 |
6 | kp1 = icp(ke,1);
7 | kp2 = icp(ke,2);
8 | kp3 = icp(ke,3);
9 |
10 | % s1 = norm(pt(kp2,:)-pt(kp1,:));
11 | % s2 = norm(pt(kp3,:)-pt(kp2,:));
12 | % s3 = norm(pt(kp1,:)-pt(kp3,:));
13 |
14 | len = [ norm(pt(kp2,:)-pt(kp1,:)),norm(pt(kp3,:)-pt(kp2,:)),norm(pt(kp1,:)-pt(kp3,:))];
15 |
16 | [len,ind] = sort(len);
17 |
18 |
19 | return
20 | end
21 |
22 |
23 |
--------------------------------------------------------------------------------
/FrontRegriddingBox/flocal.m:
--------------------------------------------------------------------------------
1 |
2 | function [n1,n2,n3,nc1,nc2,nc3,kp] = flocal(ke,n1,icp,ine)
3 |
4 | % NOTE the relationship between n1 and ine(n1)
5 |
6 | kec = ine(ke,n1);
7 |
8 | % [i,i+1,i+2]
9 | n2 = mod(n1,3)+1;
10 | n3 = mod(n2,3)+1;
11 |
12 | kp = zeros(1,4);
13 | %
14 | kp(1) = icp(ke,n1);
15 | kp(2) = icp(ke,n2);
16 | kp(3) = icp(ke,n3);
17 | %
18 | nc1 = 0;
19 | for i = 1:3
20 | if icp(kec,i) == kp(1)
21 | nc1 = i;
22 | end
23 | end
24 | if ~nc1
25 | fprintf('KE=%d,N1=%d,KP1=%d,KEC=%d\n', ke,n1,kp(1),kec);
26 | error('Node not match');
27 | end
28 | nc2 = mod(nc1,3)+1;
29 | nc3 = mod(nc2,3)+1;
30 | %
31 | kp(4) = icp(kec,nc2);
32 |
33 | if ine(kec,nc3)~=ke
34 | fprintf('KE=%d,N1=%d,KP1=%d,KEC=%d\n', ke,n1,kp(1),kec);
35 | error('Element not match');
36 | end
37 |
38 |
39 | return
40 | end
41 |
42 |
--------------------------------------------------------------------------------
/FrontTrackingBox/DNS-Solver.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/FrontTrackingBox/DNS-Solver.pdf
--------------------------------------------------------------------------------
/FrontTrackingBox/FTGlobals.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | % 0 = Cart, 1 = RZ
4 | global CoordSys
5 | CoordSys_Cart = 0;
6 | CoordSys_RZ = 1;
7 |
8 | global ProbLo ProbHi ProbLen
9 |
10 | global CellXs CellYs
11 | global EdgeXs EdgeYs
12 | global EdgeRs CellRs
13 |
14 |
--------------------------------------------------------------------------------
/ImmersedInterfaceBox/SolveChol.m:
--------------------------------------------------------------------------------
1 |
2 | function [x] = SolveChol(b,R,Rt,perm)
3 |
4 | if isempty(Rt)
5 | Rt = R';
6 | end
7 |
8 | if isempty(perm)
9 | x = R \ (Rt \ b);
10 | else
11 | x = zeros(size(b));
12 | x(perm) = R \ (Rt \ b(perm));
13 | end
14 |
15 | return
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/LESBox/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | [Kaji homepage](http://www-fluid.mech.eng.osaka-u.ac.jp/~kajisima/)
4 |
5 | [Smagorinsky in OpenFOAM](http://caefn.com/openfoam/smagorinsky-sgs-model)
6 |
7 | Default model coef.
8 | Ce = 1.048
9 | Ck = 0.094
10 |
11 | [LES in OpenFOAM](http://caefn.com/openfoam/les)
12 |
13 | [Smagorinsky in OpenFOAM](http://caefn.com/openfoam/smagorinsky-sgs-model)
14 |
15 | [WALE in OpenFOAM](http://caefn.com/openfoam/wale-sgs-model)
16 |
17 |
18 |
--------------------------------------------------------------------------------
/LatticeBoltzmannBox/LBM_PoiseuilleMain.m:
--------------------------------------------------------------------------------
1 |
2 | function LBM_PoiseuilleMain
3 |
4 | refine = 1;
5 | Lx = 64*refine;
6 | Ly = 32*refine;
7 | nx = Lx;
8 | ny = Ly;
9 | Nx = nx + 2;
10 | Ny = ny + 2;
11 |
12 | hx = Lx / nx;
13 | hy = Ly / ny;
14 | hh = min([hx hy]);
15 | qc = 1;
16 | dt = hh / qc;
17 | cs = 1/sqrt(3) * qc;
18 | cs2 = 1/3 * qc^2;
19 |
20 | u = zeros(Nx,Ny);
21 | v = zeros(Nx,Ny);
22 | feq = zeros(Nx,Ny,9);
23 | f = zeros(Nx,Ny,9);
24 |
25 |
26 |
27 |
28 | return
29 | end % end of main function
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LatticeBoltzmannBox/cavity_Re0400.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LatticeBoltzmannBox/cavity_Re0400.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/AxisymEmbraceAngle.m:
--------------------------------------------------------------------------------
1 | function [alpha] = AxisymEmbraceAngle(R,r)
2 | % Calculate embracing angle
3 |
4 | if R > 0
5 | alpha = asin(r/R);
6 | else
7 | alpha = 0;
8 | end
9 |
10 | return
11 | end
12 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/AxisymEvalForce.m:
--------------------------------------------------------------------------------
1 | %% Eval liquid bridge action by pressure and tension.
2 | %% Attractive +, Repulsive -
3 | %% alpha: embracing angle, wall=0
4 | %% theta: contact angle
5 | %% r: contact ring, not sphere!!
6 | %% pres: pressure, convex>0, concave<0
7 | %% sigma: surface tension
8 | function [f,fp,ft] = AxisymEvalForce(alpha,theta,r,pres,sigma)
9 |
10 | % laplace pressure
11 | fp = -pi*r^2*pres;
12 |
13 | % tension on contact ring
14 | ft = 2*pi*r*sin(alpha+theta) * sigma;
15 |
16 | % total force
17 | f = fp + ft;
18 |
19 |
20 | return
21 | end
22 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/AxisymEvolver.m:
--------------------------------------------------------------------------------
1 | function [rp,xp,pres,sene] = AxisymEvolver(bridge,np,rp,xp)
2 | % Function performing the interface optimization.
3 |
4 | % bridge parameters
5 | R1 = bridge.R1;
6 | R2 = bridge.R2;
7 | H = bridge.H;
8 | theta1 = bridge.theta1;
9 | theta2 = bridge.theta2;
10 | sigma = bridge.sigma;
11 | X1 = bridge.X1;
12 | X2 = bridge.X2;
13 |
14 | % check input initial node positions
15 | % if not provided, then generate initial guess
16 | if isempty(rp) || isempty(xp)
17 | [rp,xp] = AxisymEvolverGuessInit(bridge,np);
18 | end
19 |
20 | % call optimizer
21 | AxisymEvolverDriver;
22 |
23 |
24 |
25 |
26 | return
27 | end
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/AxisymEvolverDirectForce.m:
--------------------------------------------------------------------------------
1 | function [F1,F1p,F1t,F2,F2p,F2t] = AxisymEvolverDirectForce(bridge, np,rp,xp)
2 | % Obtain force by direct integration
3 |
4 | % exec evolver
5 | [rp,xp,pres] = AxisymEvolver(bridge, np,rp,xp);
6 |
7 | % eval force
8 | [F1,F1p,F1t,F2,F2p,F2t] = AxisymEvolverEvalForce(bridge, np,rp,xp,pres);
9 |
10 | return
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/AxisymEvolverEvalForce.m:
--------------------------------------------------------------------------------
1 | %% Directly calculate the force from the Laplace part and the tension part.
2 | %%
3 | function [F1,Fp1,Ft1,F2,Fp2,Ft2] = AxisymEvolverEvalForce(bridge, np,rp,xp,pres)
4 |
5 | R1 = bridge.R1;
6 | R2 = bridge.R2;
7 | theta1 = bridge.theta1;
8 | theta2 = bridge.theta2;
9 | sigma = bridge.sigma;
10 |
11 | % force at left sphere
12 | r1 = rp(1);
13 | alpha1 = AxisymEmbraceAngle(R1,r1);
14 | [F1,Fp1,Ft1] = AxisymEvalForce(alpha1,theta1,r1,pres,sigma);
15 |
16 | % force at right sphere
17 | r2 = rp(np);
18 | alpha2 = AxisymEmbraceAngle(R2,r2);
19 | [F2,Fp2,Ft2] = AxisymEvalForce(alpha2,theta2,r2,pres,sigma);
20 |
21 | % NOTE F1 and F2 should be almost the same
22 |
23 |
24 | return
25 | end
26 |
27 |
28 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/AxisymEvolverVolume.m:
--------------------------------------------------------------------------------
1 | function [vol] = AxisymEvolverVolume(bridge, np,rp,xp)
2 | % Evaluate the volume by revolving the interface.
3 |
4 | R1 = bridge.R1;
5 | R2 = bridge.R2;
6 | % H = bridge.H;
7 | % theta1 = bridge.theta1;
8 | % theta2 = bridge.theta2;
9 |
10 | % contact ring
11 | r1 = rp(1);
12 | r2 = rp(np);
13 |
14 | % embracing angle
15 | alpha1 = AxisymEmbraceAngle(R1,r1);
16 | % cap height
17 | h1 = R1*(1-cos(alpha1));
18 | % sphere cap volume
19 | vcap1 = SphereCapVolume(r1,h1);
20 |
21 | % check wall
22 | if R2 > 0
23 | alpha2 = asin(r2/R2);
24 | h2 = R2*(1-cos(alpha2));
25 | vcap2 = SphereCapVolume(r2,h2);
26 | else
27 | alpha2 = 0;
28 | h2 = 0;
29 | vcap2 = 0;
30 | end
31 |
32 | % rotational body
33 | dx = xp(2:np) - xp(1:np-1);
34 | % radius at element center
35 | rc = 0.5 * (rp(2:np)+rp(1:np-1));
36 | %
37 | vrot = sum(pi.* rc.^2 .* dx);
38 |
39 |
40 | % liquid volume
41 | vol = vrot - vcap1 - vcap2;
42 |
43 |
44 | return
45 | end
46 |
47 |
48 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/BridgeForceRabinovich.m:
--------------------------------------------------------------------------------
1 | function [F] = BridgeForceRabinovich(R,H,theta,V,sigma)
2 |
3 | if H > 0
4 | h2d = 1 / (-1 + sqrt(1+2*V/(pi*R*H^2)));
5 | else
6 | h2d = 0;
7 | end
8 |
9 | F = 2*pi*R*sigma*cos(theta) / (1+h2d);
10 |
11 | return
12 | end
13 |
14 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/BridgeRuptureLian.m:
--------------------------------------------------------------------------------
1 | function [hrup] = BridgeRuptureLian(theta,V)
2 | hrup = (1+0.5*theta) * V^(1.0/3.0);
3 | return
4 | end
5 |
6 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/BridgeRuptureMikami.m:
--------------------------------------------------------------------------------
1 | function [hrup] = BridgeRuptureMikami(R1,R2,theta,V)
2 |
3 | if R2 > 0
4 | % sphere-sphere
5 | hrup = (0.99+0.62*theta) * V^(0.34);
6 | else
7 | % sphere-wall
8 | hrup = (0.95+0.22*theta) * V^(0.32);
9 | end
10 |
11 | return
12 | end
13 |
14 |
15 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/BridgeRuptureWillet.m:
--------------------------------------------------------------------------------
1 | function [Hrup] = BridgeRuptureWillet(R1,R2,theta,V)
2 |
3 | Rm = DerjaguinRadius(R1,R2);
4 |
5 | if R2 > 0
6 | % size ratio must < 1
7 | if R2 > R1
8 | rr = R1 / R2;
9 | else
10 | rr = R2 / R1;
11 | end
12 | else
13 | % sphere-flat
14 | rr = 0;
15 | end
16 |
17 | % nondimensional
18 | Vstar = V / Rm^3;
19 |
20 | Vhat = Vstar^(1/3);
21 |
22 | Hstar = (1 + 0.25*theta*(rr+1)) * (Vhat + (0.5*rr-0.4)*Vhat^2);
23 |
24 | % restore dimension
25 | Hrup = Hstar * Rm;
26 |
27 |
28 | return
29 | end
30 |
31 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/ConeVolume.m:
--------------------------------------------------------------------------------
1 | function [V] = ConeVolume(r1,r2,h)
2 | % Volume of Frustum Cone with (r1,r2,h)
3 |
4 | V = pi/3 .* h .* (r1.^2 + r2.^2 + r1.*r2);
5 | return
6 | end
7 |
8 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/DerjaguinAngle.m:
--------------------------------------------------------------------------------
1 | function [theta] = DerjaguinAngle(theta1,theta2)
2 | % Average different contact angles
3 |
4 | theta = acos(0.5*(cos(theta1)+cos(theta2)));
5 |
6 | return
7 | end
8 |
9 |
10 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/DerjaguinRadius.m:
--------------------------------------------------------------------------------
1 | function [R] = DerjaguinRadius(R1,R2)
2 | % Average different radii
3 | % For wall, R2->infty
4 |
5 | if R2 > 0
6 | R = 2*R1*R2/(R1+R2);
7 | else
8 | R = 2*R1;
9 | end
10 |
11 | return
12 | end
13 |
14 |
15 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/MakeBridge.m:
--------------------------------------------------------------------------------
1 | function [bridge] = MakeBridge(R1,R2,H,theta1,theta2,V,sigma)
2 | % Create a bridge struct holding given parameters.
3 |
4 | if ~exist('sigma','var')
5 | sigma = 1.0;
6 | end
7 |
8 | %
9 | bridge = struct();
10 |
11 | bridge.R1 = R1;
12 | bridge.R2 = R2;
13 | bridge.H = H;
14 | bridge.theta1 = theta1;
15 | bridge.theta2 = theta2;
16 | bridge.V = V;
17 | bridge.sigma = sigma;
18 |
19 | % two sphere centers
20 | bridge.X1 = 0;
21 | if R2 > 0
22 | bridge.X2 = R1 + H + R2;
23 | else
24 | bridge.X2 = R1 + H;
25 | end
26 |
27 |
28 | return
29 | end
30 |
31 |
32 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/PlotBridgeGeom.m:
--------------------------------------------------------------------------------
1 | function [] = PlotBridgeGeom(bridge)
2 | % Plot the fixed spheres (walls).
3 | % Remember to activate the figure and hold on.
4 |
5 | % parameters
6 | R1 = bridge.R1;
7 | R2 = bridge.R2;
8 | H = bridge.H;
9 | X1 = bridge.X1;
10 | X2 = bridge.X2;
11 |
12 | % draw sphere 1
13 | % PlotCircle([X1,0],R1, 'EdgeColor','k');
14 | % ts = linspace(0,pi/2,361);
15 | ts = linspace(0,pi/4,361);
16 | plot(R1*cos(ts),R1*sin(ts),'k-');
17 |
18 | if R2 > 0
19 | % draw sphere 2
20 | % PlotCircle([X2,0],R2, 'EdgeColor','k');
21 | % ts = linspace(pi/2,pi,361);
22 | ts = linspace(pi/4*3,pi,361);
23 | plot(X2+R2*cos(ts),R2*sin(ts),'k-');
24 | else
25 | % draw straight wall
26 | line([X2,X2], [0,R1*1.5], 'Color','k');
27 | end
28 |
29 | axis equal;
30 | axis([X1 X2 0 R1*1.25]);
31 |
32 |
33 | return
34 | end
35 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/PlotCircle.m:
--------------------------------------------------------------------------------
1 | function [] = PlotCircle(cen,rad,varargin)
2 |
3 | pos = [cen(1)-rad,cen(2)-rad,rad*2,rad*2];
4 | curv = [1,1];
5 | rectangle('Position',pos,'Curvature',curv, varargin{:});
6 |
7 |
8 | return
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/Rupture/SolveDroplet.m:
--------------------------------------------------------------------------------
1 | function [alpha,ssph,sdrop] = SolveDroplet(R,theta,V)
2 |
3 | alpha0 = pi/6;
4 |
5 | alpha = fsolve(@(aa) (vol_func(R,theta,V,aa)./V-1), alpha0);
6 |
7 | b = R * sin(alpha);
8 | r = b / sin(alpha+theta);
9 |
10 | hdrop = r * (1-cos(alpha+theta));
11 | hsph = R * (1-cos(alpha));
12 |
13 | sdrop = 2*pi*r*hdrop;
14 | ssph = 2*pi*R*hsph;
15 |
16 | return
17 | end
18 |
19 | function [vol] = vol_func(R,theta,V, alpha)
20 | b = R * sin(alpha);
21 | r = b / sin(alpha+theta);
22 |
23 | hdrop = r * (1-cos(alpha+theta));
24 | hsph = R * (1-cos(alpha));
25 |
26 | vdrop = SphereCapVolume(b, hdrop);
27 | vsph = SphereCapVolume(b, hsph);
28 | vol = vdrop - vsph;
29 | return
30 | end
31 |
32 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/Rupture/SolveDroplet2.m:
--------------------------------------------------------------------------------
1 | function [phi,ssph,sdrop] = SolveDroplet2(R,V, alpha)
2 |
3 | phi0 = pi/6;
4 |
5 | phi = fsolve(@(aa) (vol_func(R,V,alpha,aa)./V-1), phi0);
6 |
7 | b = R * sin(alpha);
8 | r = b / sin(phi);
9 |
10 | hdrop = r * (1-cos(phi));
11 | hsph = R * (1-cos(alpha));
12 |
13 | sdrop = 2*pi*r*hdrop;
14 | ssph = 2*pi*R*hsph;
15 |
16 | return
17 | end
18 |
19 | function [vol] = vol_func(R,V, alpha, phi)
20 | b = R * sin(alpha);
21 | r = b / sin(phi);
22 |
23 | hdrop = r * (1-cos(phi));
24 | hsph = R * (1-cos(alpha));
25 |
26 | vdrop = SphereCapVolume(b, hdrop);
27 | vsph = SphereCapVolume(b, hsph);
28 | vol = vdrop - vsph;
29 | return
30 | end
31 |
32 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/SphereCapArea.m:
--------------------------------------------------------------------------------
1 | function [area] = SphereCapArea(a,h)
2 | % Area of spherical cap.
3 | % a: radius of cap (not sphere radius)
4 | % h: height of cap
5 |
6 | r = (a^2+h^2)/(h*2);
7 | area = 2*pi * r*h;
8 |
9 | return
10 | end
11 |
12 |
13 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/SphereCapVolume.m:
--------------------------------------------------------------------------------
1 | function [vol] = SphereCapVolume(a,h)
2 | % Volume of spherical cap.
3 | % a: radius of cap (not sphere radius)
4 | % h: height of cap
5 |
6 | vol = pi/6 * h * (3*a^2+h^2);
7 |
8 | return
9 | end
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/SphereVolume.m:
--------------------------------------------------------------------------------
1 | function [vol] = SphereVolume(R)
2 | vol = 4/3*pi*R^3;
3 | return
4 | end
5 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestAxisymEvolver.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | sigma = 1.0;
5 | R1 = 1.0;
6 | R2 = 1.0;
7 | H = 0.0;
8 | theta1 = deg2rad(0);
9 | theta2 = deg2rad(0);
10 | % V = SphereVolume(R1)*0.2;
11 | V = 1.0e-7;
12 |
13 | bridge = MakeBridge(R1,R2,H,theta1,theta2,V,sigma);
14 |
15 | %
16 | X1 = bridge.X1;
17 | X2 = bridge.X2;
18 |
19 | % draw spheres
20 | hfig = figure;
21 | hold on;
22 | PlotBridgeGeom(bridge);
23 | hold off;
24 |
25 | %
26 | np = 51;
27 | [rp,xp] = AxisymEvolverGuessInit(bridge,np);
28 |
29 | if 1
30 | % draw initial shape
31 | figure(hfig);
32 | hold on;
33 | plot(xp,rp,'-b');
34 | hold off;
35 | drawnow;
36 | end
37 | % return
38 |
39 | % optimize
40 | [rp,xp,pres] = AxisymEvolver(bridge,np,rp,xp);
41 |
42 | if 1
43 | % draw optimized shape
44 | figure(hfig);
45 | hold on;
46 | plot(xp,rp,'.-r');
47 | hold off;
48 | drawnow;
49 | end
50 |
51 | % force
52 | [F1,~,~,F2,~,~] = AxisymEvolverEvalForce(bridge, np,rp,xp,pres)
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestAxisymEvolverForce.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | sigma = 1.0;
5 | theta = deg2rad(15);
6 | theta1 = theta;
7 | theta2 = theta;
8 | R1 = 1.0;
9 | R2 = 1.0;
10 | % H = 0.2;
11 | V = SphereVolume(R1)*0.005;
12 |
13 | dist = linspace(0,0.2,21);
14 |
15 | if 1
16 | for H = dist
17 |
18 | end
19 | end
20 |
21 | bridge = MakeBridge(R1,R2,H,theta1,theta2,V,sigma);
22 |
23 | %
24 | X1 = bridge.X1;
25 | X2 = bridge.X2;
26 |
27 | np = 51;
28 |
29 | Fdirect = AxisymEvolverDirectForce(bridge,np,[],[]);
30 | % Fderiv = AxisymEvolverDerivForce(bridge,np,[],[]);
31 |
32 | Fdirect
33 | % Fderiv
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2Asym.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHR2Asym.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2Asym2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHR2Asym2.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2Lambert.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHR2Lambert.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2PreLarge.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | sigma = 1.0;
5 | R = 1.0;
6 |
7 | % V = SphereVolume(R)*0.1;
8 | % dist = linspace(0,0.5,11);
9 | V = SphereVolume(R)*0.2;
10 | dist = linspace(0,1.0,11);
11 |
12 | % theta = deg2rad(15);
13 | % theta = deg2rad(45);
14 | % theta = deg2rad(90);
15 | theta = deg2rad(120);
16 |
17 |
18 | data0 = [];
19 | data0a = [];
20 | data1 = [];
21 | data2 = [];
22 |
23 | if 1
24 | for H = dist
25 | % data1(end+1) = BridgeForceRabinovich(R,H,theta,V,sigma);
26 | % data1(end+1) = BridgeForceHuppmannRiegger(R,H,theta,V,sigma);
27 | data2(end+1) = BridgeForceHR2(R,R,H,theta,theta,V,sigma);
28 | end
29 | end
30 |
31 | if 0
32 | for H = dist
33 | np = 51;
34 | bridge = MakeBridge(R,R,H,theta,theta,V,sigma);
35 | [data0(end+1),~,~, data0a(end+1),~,~] = AxisymEvolverDirectForce(bridge,np,[],[]);
36 | end
37 | end
38 |
39 | data = [data0',data1',data2'];
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2PreLarge.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHR2PreLarge.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2PreSmall.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | sigma = 1.0;
5 | R = 1.0;
6 |
7 | % theta = deg2rad(15);
8 | % theta = deg2rad(30);
9 | % theta = deg2rad(60);
10 | theta = deg2rad(90);
11 |
12 | V = SphereVolume(R)*0.005;
13 |
14 | dist = linspace(0,0.2,21);
15 | data0 = [];
16 | data1 = [];
17 | data2 = [];
18 | data3 = [];
19 |
20 | if 1
21 | for H = dist
22 | % data1(end+1) = BridgeForceRabinovich(R,H,theta,V,sigma);
23 | % data2(end+1) = BridgeForceHuppmannRiegger(R,H,theta,V,sigma);
24 | data3(end+1) = BridgeForceHR2(R,R,H,theta,theta,V,sigma);
25 | end
26 | end
27 |
28 | if 0
29 | for H = dist
30 | np = 51;
31 | bridge = MakeBridge(R,R,H,theta,theta,V,sigma);
32 | data0(end+1) = AxisymEvolverDirectForce(bridge,np,[],[]);
33 | end
34 | end
35 |
36 | data = [data0',data1',data2',data3'];
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2PreSmall.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHR2PreSmall.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2Rabinovich.m:
--------------------------------------------------------------------------------
1 | %%
2 | %% (Rabinovich et al., 2005)
3 | %%
4 |
5 | clear;
6 |
7 | % CA
8 | theta = deg2rad(10);
9 |
10 | % case 1
11 | sigma = 27; % mN/m
12 | R1 = 19; % um
13 | R2 = 35;
14 | V = 0.2; % um^3
15 | dist = 0:0.01:0.77;
16 |
17 | % % case 2
18 | % sigma = 24; % mN/m
19 | % R1 = 19; % um
20 | % R2 = 32.5;
21 | % V = 1.2; % um^3
22 | % dist = 0:0.01:1.25;
23 |
24 | % % case 3
25 | % sigma = 28; % mN/m
26 | % R1 = 19; % um
27 | % R2 = 27.5;
28 | % V = 3.6; % um^3
29 | % dist = 0:0.01:2.0;
30 |
31 |
32 | data0 = [];
33 | data1 = [];
34 |
35 | if 1
36 | % Model
37 | for H = dist
38 | data1(end+1) = BridgeForceHR2(R1*1e-6,R2*1e-6,H*1e-6,theta,theta*1e-18,V*1e-18,sigma);
39 | end
40 | end
41 |
42 | if 1
43 | % Optimal solution
44 | for H = 0:0.05:dist(end)
45 | np = 51;
46 | bridge = MakeBridge(R1,R2,H,theta,theta,V,sigma*1e-3);
47 | data0(end+1) = AxisymEvolverDirectForce(bridge,np,[],[]);
48 | end
49 | end
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2Rabinovich.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHR2Rabinovich.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2Toyota.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHR2Toyota.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHR2Willet.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHR2Willet.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHuppmannRiegger.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | R = 1.0;
5 | Vsph = SphereVolume(R);
6 | sigma = 1.0;
7 |
8 | %
9 | % V = 0.1*Vsph;
10 | % theta = deg2rad(36);
11 | % V = 0.2*Vsph;
12 | % theta = deg2rad(36);
13 | % V = 0.1*Vsph;
14 | % theta = deg2rad(90);
15 | V = 0.2*Vsph;
16 | theta = deg2rad(90);
17 |
18 | %
19 | dist = 0:0.1:1.2;
20 | force = [];
21 | for H = dist
22 | force(end+1) = HuppmannRiegger(R,H,theta,V,sigma);
23 | end
24 |
25 | if 1
26 | figure;
27 | plot(dist,force);
28 | axis([0,1,-3,3]);
29 | end
30 |
31 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestHuppmannRiegger.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/TestHuppmannRiegger.xlsx
--------------------------------------------------------------------------------
/LiquidBridgeBox/TestToyota2.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | %% TOYOTA, particle-wall bridge force
5 |
6 |
7 | sigma = 1.0;
8 |
9 | R1 = 1.0;
10 | R2 = -1.0; % wall
11 |
12 | theta1 = deg2rad(60);
13 | theta2 = deg2rad(100);
14 |
15 | % the average CA
16 | thetam = acos(0.5*(cos(theta1)+cos(theta2)));
17 |
18 | % 40% liquid volume
19 | Vliq = 4/3*pi * R1^3 * 0.4;
20 |
21 |
22 | % ncoord = 1;
23 | % ncoord = 2;
24 | % ncoord = 4;
25 | % ncoord = 6;
26 | % ncoord = 8;
27 | ncoord = 10;
28 |
29 | V = Vliq / ncoord;
30 |
31 |
32 | data = [];
33 | for H = 0:0.01:0.5
34 | f1 = BridgeForceHR2(R1,R2,H,theta1,theta2,V,sigma);
35 | f2 = BridgeForceHR2(R1,R2,H,thetam,thetam,V,sigma);
36 | data(end+1,:) = [H, f1,f2];
37 | end
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/YoungLaplace/ParamVolume.m:
--------------------------------------------------------------------------------
1 | function [vol] = ParamVolume(phi1,phi2, C,M)
2 |
3 | fun = @(phi) volfunc(phi, phi1, C,M);
4 |
5 | if 1
6 | vol = integral(fun, phi1,phi2, 'AbsTol',1.0e-10,'RelTol',0.0);
7 | else
8 | % ndiv = 21;
9 | % ndiv = 51;
10 | % ndiv = 101;
11 | ndiv = 201;
12 | % ndiv = 501;
13 | phis = linspace(phi1,phi2,ndiv);
14 | % dvol = volfunc(phis, phi1, C,M);
15 | % vol = trapz(phis,dvol);
16 | [x,y] = ParamCurve(phis, phi1, C,M);
17 | vol = trapz(x,pi*y.^2);
18 | end
19 |
20 | return
21 | end
22 |
23 |
24 | function [dvol] = volfunc(phi, phi0, C,M)
25 |
26 | [x,y,dxdphi,~] = ParamCurve(phi, phi0, C,M);
27 |
28 | dvol = pi * y.^2 .* dxdphi;
29 | % dvol = pi * y.^2;
30 |
31 | return
32 | end
33 |
34 |
35 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/YoungLaplace/RunEvolver.m:
--------------------------------------------------------------------------------
1 | %
2 | % must define bridge
3 | %
4 |
5 | %
6 | % np = 41;
7 | np = 61;
8 | % np = 81;
9 | [rp,xp] = AxisymEvolverGuessInit(bridge,np);
10 |
11 | if 0
12 | % draw initial shape
13 | figure(hfig);
14 | hold on;
15 | plot(xp,rp,'-b');
16 | hold off;
17 | drawnow;
18 | end
19 | % return
20 |
21 | % optimize
22 | [rp,xp,pres] = AxisymEvolver(bridge,np,rp,xp);
23 | %
24 | pres
25 |
26 | if 1
27 | % draw optimized shape
28 | figure(hfig);
29 | hold on;
30 | plot(xp,rp,'.-r');
31 | hold off;
32 | drawnow;
33 | end
34 |
35 | % force
36 | [F1,~,~,F2,~,~] = AxisymEvolverEvalForce(bridge, np,rp,xp,pres);
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/YoungLaplace/YLCalcVolume.m:
--------------------------------------------------------------------------------
1 | function [vol] = YLCalcVolume(xs,rs)
2 |
3 |
4 |
5 |
6 | rm = 0.5 * (rs(1:end-1) + rs(2:end));
7 | xl = xs(2:end) - xs(1:end-1);
8 | vol = sum(pi .* rm.^2 .* xl);
9 |
10 |
11 |
12 | return
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/YoungLaplace/YoungLaplace.m:
--------------------------------------------------------------------------------
1 | function dz = younglaplace(t,z)
2 |
3 | dz = zeros(2,1);
4 |
5 | dz(1) = ;
6 |
7 | return
8 | end
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/YoungLaplace/tmp_alfa.fig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/YoungLaplace/tmp_alfa.fig
--------------------------------------------------------------------------------
/LiquidBridgeBox/YoungLaplace/tmp_bridge.fig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/YoungLaplace/tmp_bridge.fig
--------------------------------------------------------------------------------
/LiquidBridgeBox/YoungLaplace/tmp_ca000_ca020_alfa.fig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/YoungLaplace/tmp_ca000_ca020_alfa.fig
--------------------------------------------------------------------------------
/LiquidBridgeBox/YoungLaplace/tmp_vc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/YoungLaplace/tmp_vc.png
--------------------------------------------------------------------------------
/LiquidBridgeBox/deg2rad.m:
--------------------------------------------------------------------------------
1 | function [rad] = deg2rad(deg)
2 | rad = deg .* (pi/180);
3 | return
4 | end
5 |
6 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/rad2deg.m:
--------------------------------------------------------------------------------
1 | function [deg] = rad2deg(rad)
2 | deg = rad .* (180/pi);
3 | return
4 | end
5 |
6 |
--------------------------------------------------------------------------------
/LiquidBridgeBox/tmp/shape_asym_v001_ca030_ca120_h005_ra1_rb2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/tmp/shape_asym_v001_ca030_ca120_h005_ra1_rb2.png
--------------------------------------------------------------------------------
/LiquidBridgeBox/tmp/shape_asym_v004_ca015_ca060_h01_ra1_rb3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/tmp/shape_asym_v004_ca015_ca060_h01_ra1_rb3.png
--------------------------------------------------------------------------------
/LiquidBridgeBox/tmp/shape_asym_v004_ca120_ca150_h02_ra2_rb1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/tmp/shape_asym_v004_ca120_ca150_h02_ra2_rb1.png
--------------------------------------------------------------------------------
/LiquidBridgeBox/tmp/shape_asym_v01_ca060_ca100_h025_ra1_rb0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/tmp/shape_asym_v01_ca060_ca100_h025_ra1_rb0.png
--------------------------------------------------------------------------------
/LiquidBridgeBox/tmp/shape_sym_v0005_ca015.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/tmp/shape_sym_v0005_ca015.png
--------------------------------------------------------------------------------
/LiquidBridgeBox/tmp/shape_sym_v0005_ca090.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/LiquidBridgeBox/tmp/shape_sym_v0005_ca090.png
--------------------------------------------------------------------------------
/MPSBox/SurfOpTest/surf1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MPSBox/SurfOpTest/surf1.png
--------------------------------------------------------------------------------
/MPSBox/SurfOpTest/surf2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MPSBox/SurfOpTest/surf2.png
--------------------------------------------------------------------------------
/MPSBox/SurfOpTest/test.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MPSBox/SurfOpTest/test.xlsx
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/boundedges.m:
--------------------------------------------------------------------------------
1 | function e=boundedges(p,t)
2 | %BOUNDEDGES Find boundary edges from triangular mesh
3 | % E=BOUNDEDGES(P,T)
4 |
5 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
6 |
7 | % Form all edges, non-duplicates are boundary edges
8 | edges=[t(:,[1,2]);
9 | t(:,[1,3]);
10 | t(:,[2,3])];
11 | node3=[t(:,3);t(:,2);t(:,1)];
12 | edges=sort(edges,2);
13 | [foo,ix,jx]=unique(edges,'rows');
14 | vec=histc(jx,1:max(jx));
15 | qx=find(vec==1);
16 | e=edges(ix(qx),:);
17 | node3=node3(ix(qx));
18 |
19 | % Orientation
20 | v1=p(e(:,2),:)-p(e(:,1),:);
21 | v2=p(node3,:)-p(e(:,1),:);
22 | ix=find(v1(:,1).*v2(:,2)-v1(:,2).*v2(:,1)>0);
23 | e(ix,[1,2])=e(ix,[2,1]);
24 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/circumcenter.m:
--------------------------------------------------------------------------------
1 | function [pc,r]=circumcenter(p,t)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | nt=size(t,1);
6 | pc=zeros(nt,2);
7 | r=zeros(nt,1);
8 |
9 | for it=1:nt
10 | ct=t(it,:);
11 | dp1=p(ct(2),:)-p(ct(1),:);
12 | dp2=p(ct(3),:)-p(ct(1),:);
13 |
14 | mid1=(p(ct(2),:)+p(ct(1),:))/2;
15 | mid2=(p(ct(3),:)+p(ct(1),:))/2;
16 |
17 | s=[-dp1(2),dp2(2);dp1(1),-dp2(1)]\[-mid1+mid2]';
18 |
19 | cpc=mid1+s(1)*[-dp1(2),dp1(1)];
20 | cr=norm(p(ct(1),:)-cpc);
21 |
22 | pc(it,:)=cpc;
23 | r(it,1)=cr;
24 | end
25 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dblock.m:
--------------------------------------------------------------------------------
1 | function d=dblock(p,x1,x2,y1,y2,z1,z2)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=-min(min(min(min(min(-z1+p(:,3),z2-p(:,3)),-y1+p(:,2)),y2-p(:,2)),-x1+p(:,1)),x2-p(:,1));
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dcircle.m:
--------------------------------------------------------------------------------
1 | function d=dcircle(p,xc,yc,r)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=sqrt((p(:,1)-xc).^2+(p(:,2)-yc).^2)-r;
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/ddiff.m:
--------------------------------------------------------------------------------
1 | function d=ddiff(d1,d2), d=max(d1,-d2);
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dellipse.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dellipse.mexa64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dellipse.mexmaci64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dellipse.mexmaci64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dellipse.mexw32:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dellipse.mexw32
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dellipse.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dellipse.mexw64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dellipsoid.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dellipsoid.mexa64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dellipsoid.mexmaci64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dellipsoid.mexmaci64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dellipsoid.mexw32:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dellipsoid.mexw32
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dellipsoid.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dellipsoid.mexw64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dintersect.m:
--------------------------------------------------------------------------------
1 | function d=dintersect(d1,d2), d=max(d1,d2);
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dmatrix.m:
--------------------------------------------------------------------------------
1 | function d=dmatrix(p,xx,yy,dd,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=interp2(xx,yy,dd,p(:,1),p(:,2),'*linear');
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dmatrix3d.m:
--------------------------------------------------------------------------------
1 | function d=dmatrix3d(p,xx,yy,zz,dd,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=interpn(xx,yy,zz,dd,p(:,1),p(:,2),p(:,3),'*linear');
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dpoly.m:
--------------------------------------------------------------------------------
1 | function d=dpoly(p,pv)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | np=size(p,1);
6 | nvs=size(pv,1)-1;
7 |
8 | ds=dsegment(p,pv);
9 | %ds=zeros(np,nvs);
10 | %for iv=1:nvs
11 | % ds(:,iv)=donesegment(p,pv(iv:iv+1,:));
12 | %end
13 | d=min(ds,[],2);
14 |
15 | d=(-1).^(inpolygon(p(:,1),p(:,2),pv(:,1),pv(:,2))).*d;
16 |
17 | % MEXED
18 |
19 | %function ds=donesegment(p,pv)
20 | %
21 | %e=ones(size(p,1),1);
22 | %
23 | %v=diff(pv,1);
24 | %w=p-e*pv(1,:);
25 | %
26 | %c1=sum(w.*v(e,:),2);
27 | %c2=sum(v(e,:).^2,2);
28 | %
29 | %ds=0*e;
30 | %
31 | %ix=c1<=0;
32 | %ds(ix)=sqrt(sum((p(ix,:)-pv(1*ones(sum(ix),1),:)).^2,2));
33 | %
34 | %ix=c1>=c2;
35 | %ds(ix)=sqrt(sum((p(ix,:)-pv(2*ones(sum(ix),1),:)).^2,2));
36 | %
37 | %ix=c1>0 & c2>c1;
38 | %nix=sum(ix);
39 | %if nix>0
40 | % Pb=ones(nix,1)*pv(1,:)+c1(ix)./c2(ix)*v;
41 | % ds(ix)=sqrt(sum((p(ix,:)-Pb).^2,2));
42 | %end
43 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/drectangle.m:
--------------------------------------------------------------------------------
1 | function d=drectangle(p,x1,x2,y1,y2)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=-min(min(min(-y1+p(:,2),y2-p(:,2)),-x1+p(:,1)),x2-p(:,1));
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/drectangle0.m:
--------------------------------------------------------------------------------
1 | function d=drectangle0(p,x1,x2,y1,y2)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d1=y1-p(:,2);
6 | d2=-y2+p(:,2);
7 | d3=x1-p(:,1);
8 | d4=-x2+p(:,1);
9 |
10 | d5=sqrt(d1.^2+d3.^2);
11 | d6=sqrt(d1.^2+d4.^2);
12 | d7=sqrt(d2.^2+d3.^2);
13 | d8=sqrt(d2.^2+d4.^2);
14 |
15 | d=-min(min(min(-d1,-d2),-d3),-d4);
16 |
17 | ix=d1>0 & d3>0;
18 | d(ix)=d5(ix);
19 | ix=d1>0 & d4>0;
20 | d(ix)=d6(ix);
21 | ix=d2>0 & d3>0;
22 | d(ix)=d7(ix);
23 | ix=d2>0 & d4>0;
24 | d(ix)=d8(ix);
25 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dsegment.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dsegment.mexa64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dsegment.mexmaci64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dsegment.mexmaci64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dsegment.mexw32:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dsegment.mexw32
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dsegment.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/dsegment.mexw64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dsphere.m:
--------------------------------------------------------------------------------
1 | function d=dsphere(p,xc,yc,zc,r)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | d=sqrt((p(:,1)-xc).^2+(p(:,2)-yc).^2+(p(:,3)-zc).^2)-r;
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/dunion.m:
--------------------------------------------------------------------------------
1 | function d=dunion(d1,d2), d=min(d1,d2);
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/fixmesh.m:
--------------------------------------------------------------------------------
1 | function [p,t,pix]=fixmesh(p,t,ptol)
2 | %FIXMESH Remove duplicated/unused nodes and fix element orientation.
3 | % [P,T]=FIXMESH(P,T)
4 |
5 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
6 |
7 | if nargin<3, ptol=1024*eps; end
8 | if nargin>=2 & (isempty(p) | isempty(t)), pix=1:size(p,1); return; end
9 |
10 | snap=max(max(p,[],1)-min(p,[],1),[],2)*ptol;
11 | [foo,ix,jx]=unique(round(p/snap)*snap,'rows');
12 | p=p(ix,:);
13 |
14 | if nargin>=2
15 | t=reshape(jx(t),size(t));
16 |
17 | [pix,ix1,jx1]=unique(t);
18 | t=reshape(jx1,size(t));
19 | p=p(pix,:);
20 | pix=ix(pix);
21 |
22 | if size(t,2)==size(p,2)+1
23 | flip=simpvol(p,t)<0;
24 | t(flip,[1,2])=t(flip,[2,1]);
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/hmatrix.m:
--------------------------------------------------------------------------------
1 | function h=hmatrix(p,xx,yy,dd,hh,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | h=interp2(xx,yy,hh,p(:,1),p(:,2),'*linear');
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/hmatrix3d.m:
--------------------------------------------------------------------------------
1 | function h=hmatrix3d(p,xx,yy,zz,dd,hh,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | h=interpn(xx,yy,zz,hh,p(:,1),p(:,2),p(:,3),'*linear');
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/huniform.m:
--------------------------------------------------------------------------------
1 | function h=huniform(p,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | h=ones(size(p,1),1);
6 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/protate.m:
--------------------------------------------------------------------------------
1 | function p=protate(p,phi)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | A=[cos(phi),-sin(phi);sin(phi),cos(phi)];
6 | p=p*A;
7 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/pshift.m:
--------------------------------------------------------------------------------
1 | function p=pshift(p,x0,y0)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | p(:,1)=p(:,1)+x0;
6 | p(:,2)=p(:,2)+y0;
7 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/simpvol.m:
--------------------------------------------------------------------------------
1 | function v=simpvol(p,t)
2 | %SIMPVOL Simplex volume.
3 | % V=SIMPVOL(P,T)
4 |
5 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
6 |
7 | switch size(p,2)
8 | case 1
9 | d12=p(t(:,2),:)-p(t(:,1),:);
10 | v=d12;
11 | case 2
12 | d12=p(t(:,2),:)-p(t(:,1),:);
13 | d13=p(t(:,3),:)-p(t(:,1),:);
14 | v=(d12(:,1).*d13(:,2)-d12(:,2).*d13(:,1))/2;
15 | case 3
16 | d12=p(t(:,2),:)-p(t(:,1),:);
17 | d13=p(t(:,3),:)-p(t(:,1),:);
18 | d14=p(t(:,4),:)-p(t(:,1),:);
19 | v=dot(cross(d12,d13,2),d14,2)/6;
20 | otherwise
21 | v=zeros(size(t,1),1);
22 | for ii=1:size(t,1)
23 | A=zeros(size(p,2)+1);
24 | A(:,1)=1;
25 | for jj=1:size(p,2)+1
26 | A(jj,2:end)=p(t(ii,jj),:);
27 | end
28 | v(ii)=det(A);
29 | end
30 | v=v/factorial(size(p,2));
31 | end
32 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/surftri.m:
--------------------------------------------------------------------------------
1 | function tri=surftri(p,t)
2 | %SURFTRI Find surface triangles from tetrahedra mesh
3 | % TRI=SURFTRI(P,T)
4 |
5 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
6 |
7 | % Form all faces, non-duplicates are surface triangles
8 | faces=[t(:,[1,2,3]);
9 | t(:,[1,2,4]);
10 | t(:,[1,3,4]);
11 | t(:,[2,3,4])];
12 | node4=[t(:,4);t(:,3);t(:,2);t(:,1)];
13 | faces=sort(faces,2);
14 | [foo,ix,jx]=unique(faces,'rows');
15 | vec=histc(jx,1:max(jx));
16 | qx=find(vec==1);
17 | tri=faces(ix(qx),:);
18 | node4=node4(ix(qx));
19 |
20 | % Orientation
21 | v1=p(tri(:,2),:)-p(tri(:,1),:);
22 | v2=p(tri(:,3),:)-p(tri(:,1),:);
23 | v3=p(node4,:)-p(tri(:,1),:);
24 | ix=find(dot(cross(v1,v2,2),v3,2)>0);
25 | tri(ix,[2,3])=tri(ix,[3,2]);
26 |
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/trisurfupd.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/trisurfupd.mexa64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/trisurfupd.mexmaci64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/trisurfupd.mexmaci64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/trisurfupd.mexw32:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/trisurfupd.mexw32
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/trisurfupd.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/distmesh/trisurfupd.mexw64
--------------------------------------------------------------------------------
/MeshGenBox/distmesh/uniformity.m:
--------------------------------------------------------------------------------
1 | function u=uniformity(p,t,fh,varargin)
2 |
3 | % Copyright (C) 2004-2012 Per-Olof Persson. See COPYRIGHT.TXT for details.
4 |
5 | [pc,r]=circumcenter(p,t);
6 | hc=feval(fh,pc,varargin{:});
7 |
8 | sz=r./hc;
9 | u=std(sz)/mean(sz);
10 |
--------------------------------------------------------------------------------
/MeshGenBox/persson04mesh.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/MeshGenBox/persson04mesh.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | StupidCFD
2 | =========
3 |
4 | Some simple CFD codes.
5 |
6 | # Cavity Box
7 | They are finite difference (FD) or finite volume (FV) solutions to the lid-driven cavity flow problems in 2D.
8 |
9 | # Simple Box
10 | SIMPLE solver for steady lid-driven cavity.
11 |
12 | # WENO Box
13 | WENO + flux-split
14 |
15 | # Rigid Box
16 | Rigid rotation
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/RigidBodyBox/DeriveShiftedMOI.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | function [ Jall ] = DeriveShiftedMOI(xcen,ycen,zcen,npart,xpart,ypart,zpart,mpart,Jpart)
4 |
5 | xref = xpart - xcen;
6 | yref = ypart - ycen;
7 | zref = zpart - zcen;
8 |
9 | J11 = (yref.^2 + zref.^2) .* mpart;
10 | J12 = -xref .* yref .* mpart;
11 | J13 = -xref .* zref .* mpart;
12 | J21 = -yref .* xref .* mpart;
13 | J22 = (zref.^2 + xref.^2) .* mpart;
14 | J23 = -yref .* zref .* mpart;
15 | J31 = -zref .* xref .* mpart;
16 | J32 = -zref .* yref .* mpart;
17 | J33 = (xref.^2 + yref.^2) .* mpart;
18 |
19 | Jsft = [sum(J11),sum(J12),sum(J13); sum(J21),sum(J22),sum(J23); sum(J31),sum(J32),sum(J33)];
20 | Jall = sum(Jpart,3) + Jsft;
21 |
22 |
23 |
24 | return
25 | end
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/RigidBodyBox/UpdatePartPosition.m:
--------------------------------------------------------------------------------
1 |
2 | function [xpos,ypos,zpos] = UpdatePartPosition(xcen,ycen,zcen,omega,dt,npart,xpart,ypart,zpart)
3 |
4 | xpos = xpart;
5 | ypos = ypart;
6 | zpos = zpart;
7 |
8 | xref = xpart - xcen;
9 | yref = ypart - ycen;
10 | zref = zpart - zcen;
11 |
12 | theta = norm(omega*dt);
13 | ctheta = cos(theta);
14 | stheta = sin(theta);
15 |
16 | axis = omega / norm(omega);
17 |
18 |
19 | for i = 1:npart
20 | rold = [xref(i); yref(i); zref(i)];
21 | proj = dot(rold, axis);
22 | orth = cross(axis, rold);
23 |
24 | rnew = ctheta*rold + proj*(1-ctheta)*axis + stheta*orth;
25 | xpos(i) = rnew(1) + xcen;
26 | ypos(i) = rnew(2) + ycen;
27 | zpos(i) = rnew(3) + zcen;
28 | end
29 |
30 | return
31 | end
32 |
33 |
--------------------------------------------------------------------------------
/SoilBox/DPC/DPCGlobals.m:
--------------------------------------------------------------------------------
1 |
2 | % inout
3 | global sigx sigy sigz sigxz sigyz sigxy
4 |
5 | % not used
6 | global epsx epsy epsz epsxz epsyz epsxy
7 |
8 | % input
9 | global depsx depsy depsz depsxz depsyz depsxy
10 |
11 | % 0=tension cutoff, 1=elastic, 2=failure/transition, 3=cap
12 | global mtype
13 |
14 | % 1=compacting material, 2=dilative material
15 | global ltype
16 |
17 | global tcut fcut
18 | global geop
19 | global nocon
20 | global istat
21 |
22 | global el
23 |
24 | global aki ak1 ak2
25 | global agi ag1 ag2
26 | global aa ab ac
27 | global cr0 cr1 cr2
28 | global aw ad astart
29 | global ep
30 | global layer
31 |
32 |
--------------------------------------------------------------------------------
/SoilBox/DPC/DPCInitCap.m:
--------------------------------------------------------------------------------
1 | function DPCInitCap()
2 | %DPCInitCap
3 | % Solve cap center L0 = ASTART for inital pressure state
4 | % Xinit = 3 * p_background
5 | % so L0 must be the intersection of envelop and cap
6 | %
7 |
8 | DPCGlobals;
9 |
10 | cr = cr0;
11 | xi = 3 * geop;
12 |
13 | ok = 0;
14 |
15 | if 0
16 | xo = 0;
17 | fo = cr * (aa-ac);
18 | x = xi + ab;
19 | for iter = 1:30
20 | f = x + cr*(aa-ac*exp(-ab*x)) - xi;
21 | if abs(f) < 1e-5
22 | ok = 1; break;
23 | end
24 | xn = x - f*(x-xo)/(f-fo);
25 | xo = x;
26 | fo = f;
27 | x = xn;
28 | end
29 | else
30 | fun = @(ll) (ll-xi) + cr*(aa-ac*exp(-ab*ll));
31 | [x,~,ok] = fsolve(fun,0.0);
32 | end
33 |
34 | if ok == 1
35 | astart = x;
36 | else
37 | error('astart failed to converge');
38 | end
39 |
40 | return
41 | end
42 |
43 |
--------------------------------------------------------------------------------
/SoilBox/DPC/DPCModel.m:
--------------------------------------------------------------------------------
1 | function [p,s] = DPCModel(p,s)
2 |
3 | DPCGlobals;
4 |
5 | ltype = 1;
6 | if layer >= istat
7 | ltype = 2;
8 | end
9 |
10 | % intersection
11 | fcut = log(aa/ac) / ab;
12 | % tension cutoff
13 | tcut = 0.0;
14 |
15 | sigx = s(1) + p;
16 | sigy = s(2) + p;
17 | sigz = 3*p - sigx - sigy;
18 | sigxz = s(3);
19 | sigyz = s(4);
20 | sigxy = s(5);
21 | %
22 | ep = el;
23 |
24 | DPCMatLaw;
25 |
26 | %
27 | p = (sigx+sigy+sigz) / 3;
28 | s(1) = sigx - p;
29 | s(2) = sigy - p;
30 | s(3) = sigxz;
31 | s(4) = sigyz;
32 | s(5) = sigxy;
33 | el = ep;
34 |
35 |
36 |
37 | return
38 | end
39 |
40 |
41 |
--------------------------------------------------------------------------------
/SoilBox/DPC/DPCPlotCap.m:
--------------------------------------------------------------------------------
1 | function DPCPlotCap(varargin)
2 |
3 | DPCGlobals;
4 |
5 | % figure(hfig);
6 |
7 | % L
8 | ll = el;
9 | % R
10 | rr = cr0;
11 |
12 | % calculate X
13 | xx = rr * (aa - ac.*exp(-ab.*ll)) + ll;
14 |
15 | tt = linspace(0,pi/2,31);
16 |
17 | xplot = ll + (xx-ll) * cos(tt);
18 | yplot = (xx-ll)/rr * sin(tt);
19 |
20 | plot(xplot,yplot,varargin{:});
21 |
22 |
23 |
24 | return
25 | end
26 |
27 |
28 |
--------------------------------------------------------------------------------
/SoilBox/DruckerPragerTest/Test.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | I = voigt_eye();
5 |
6 | % set material
7 | matl = struct();
8 | matl.nu = 0.3;
9 | matl.E = 25000;
10 | matl.alpha0 = 0.7;
11 | matl.beta0 = 0.7;
12 | matl.a = 0.25;
13 | matl.k = 0.1;
14 |
15 | % derive others
16 | % bulk modulus
17 | matl.K = matl.E / (3*(1-2*matl.nu));
18 | % Lame const
19 | matl.mu = matl.E / (2*(1+matl.nu));
20 | matl.lambda = matl.E*matl.nu/((1+matl.nu)*(1-2*matl.nu));
21 | % elastic tensor 6x6
22 | matl.Ce = 2*matl.mu*eye(6) + matl.lambda*(I*I');
23 | % elastic matrix in principal axis
24 | matl.ae = (matl.K + 4*matl.mu/3)*eye(3) + (mal.K-2*matl.mu/3)*(~eye(3));
25 |
26 |
27 |
28 |
29 |
30 |
31 | % initial stress, hydrostatic compression
32 | sigma = -50.0 * I;
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/SoilBox/DruckerPragerTest/dpfun_pq.m:
--------------------------------------------------------------------------------
1 | function [p,q] = dpfun_pq(sigma)
2 | % SIGMA must be principle stress
3 | % p is hydrostatic mean stress
4 | % q is sqrt(3/2) * |s|
5 |
6 | s1 = sigma(1);
7 | s2 = sigma(2);
8 | s3 = sigma(3);
9 |
10 | p = (s1+s2+s3) / 3;
11 | q = sqrt(s1^2 + s2^2 + s3^2 - s1*s2 - s2*s3 - s3*s1);
12 |
13 |
14 | return
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/SoilBox/DruckerPragerTest/voigt_decode.m:
--------------------------------------------------------------------------------
1 | function [afull] = voigt_decode(avoigt)
2 |
3 | a1 = avoigt([1,6,5])';
4 | a2 = avoigt([6,2,4])';
5 | a3 = avoigt([5,4,3])';
6 |
7 | afull = [ a1; a2; a3 ];
8 |
9 | return
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/SoilBox/DruckerPragerTest/voigt_dev.m:
--------------------------------------------------------------------------------
1 | function [sdev] = voigt_dev(sigma)
2 | % Deviatoric part
3 | % Both input and output must be in Voigt form
4 |
5 | I = [1,1,1,0,0,0]';
6 |
7 | sm = sum(sigma(1:3)) / 3.0;
8 | sdev = sigma - sm * I;
9 |
10 | return
11 | end
12 |
13 |
14 |
--------------------------------------------------------------------------------
/SoilBox/DruckerPragerTest/voigt_eig.m:
--------------------------------------------------------------------------------
1 | function [eigvec,eigdir,eigval] = voigt_eig(vm)
2 |
3 | % convert to full matrix
4 | m = voigt_decode(vm);
5 |
6 | % eigen vectors and values
7 | [v,d] = eig(m);
8 |
9 |
10 | eigvec = v;
11 | eigval = d([1,5,9])';
12 |
13 | eigdir = zeros(6,3);
14 | for i = 1:3
15 | vi = v(:,i);
16 | eigdir(:,i) = voigt_encode(vi * vi');
17 | end
18 |
19 |
20 | return
21 | end
22 |
23 |
24 |
--------------------------------------------------------------------------------
/SoilBox/DruckerPragerTest/voigt_encode.m:
--------------------------------------------------------------------------------
1 | function [avoigt] = voigt_encode(afull)
2 | avoigt = afull([1,5,9,6,3,2])';
3 | return
4 | end
5 |
6 |
--------------------------------------------------------------------------------
/SoilBox/DruckerPragerTest/voigt_eye.m:
--------------------------------------------------------------------------------
1 | function [I] = voigt_eye()
2 | I = [ 1; 1; 1; 0; 0; 0 ];
3 | return
4 | end
5 |
--------------------------------------------------------------------------------
/SoilBox/DruckerPragerTest/voigt_norm.m:
--------------------------------------------------------------------------------
1 | function [n] = voigt_norm(v)
2 |
3 | if numel(v) ~= 6
4 | error('input vector size is not 6')
5 | end
6 |
7 | va = v(1:3);
8 | vb = v(4:6);
9 | n = sqrt(sum(va.^2 + 2*(vb.^2)));
10 |
11 |
12 | return
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/SoilBox/FiniteDeform/README.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/SoilBox/FiniteDeform/README.txt
--------------------------------------------------------------------------------
/SoilBox/FiniteDeform/assem.m:
--------------------------------------------------------------------------------
1 | function [K] = assem(edof,K,Ke)
2 | % assemble element stiffness to global stiffness
3 |
4 | [nie,n] = size(edof);
5 |
6 | t = edof(:,2:n);
7 |
8 | for i = 1:nie
9 | ind = t(i,:);
10 | K(ind,ind) = K(ind,ind) + Ke;
11 | end
12 |
13 |
14 |
15 | return
16 | end
17 |
18 |
19 |
--------------------------------------------------------------------------------
/SoilBox/FiniteDeform/formBG.m:
--------------------------------------------------------------------------------
1 | function [B,G] = formBG(dNx,nen)
2 | % B is the 6-component standard strain-displacement
3 | % G is the 9-component full strain-displacement
4 |
5 |
6 | ix = 1:3:nen*3;
7 | iy = 2:3:nen*3;
8 | iz = 3:3:nen*3;
9 |
10 | B = zeros(6,nen*3);
11 | % xx
12 | B(1,1:3:end) = dNx(1,:);
13 | % yy
14 | B(2,2:3:end) = dNx(2,:);
15 | % zz
16 | B(3,3:3:end) = dNx(3,:);
17 | % xy
18 | B(4,1:3:end) = dNx(2,:);
19 | B(4,2:3:end) = dNx(1,:);
20 | % yz
21 | B(5,2:3:end) = dNx(3,:);
22 | B(5,3:3:end) = dNx(2,:);
23 | % zx
24 | B(6,1:3:end) = dNx(3,:);
25 | B(6,3:3:end) = dNx(1,:);
26 |
27 | G = zeros(9,nen*3);
28 | % xx,yy,zz
29 | G(1:3,:) = B(1:3,:);
30 | % xy,yx
31 | G(4,1:3:end) = dNx(2,:);
32 | G(5,2:3:end) = dNx(1,:);
33 | % yz,zy
34 | G(6,2:3:end) = dNx(3,:);
35 | G(7,3:3:end) = dNx(2,:);
36 | % zx,xz
37 | G(8,3:3:end) = dNx(1,:);
38 | G(9,1:3:end) = dNx(3,:);
39 |
40 |
41 |
42 |
43 | return
44 | end
45 |
46 |
--------------------------------------------------------------------------------
/SoilBox/FiniteDeform/readme.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/SoilBox/FiniteDeform/readme.docx
--------------------------------------------------------------------------------
/SoilBox/FiniteDeform/setup_cube.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/SoilBox/FiniteDeform/setup_cube.m
--------------------------------------------------------------------------------
/SoilBox/FiniteDeform/solveq.m:
--------------------------------------------------------------------------------
1 | function [d,R] = solveq(K,f,bc)
2 |
3 | fdof = [1:size(K)]';
4 |
5 | d = zeros(size(fdof));
6 |
7 | % dof with known BC
8 | fbc = bc(:,1);
9 |
10 | % remove known BC, this reduces the vector size
11 | fdof(bc(:,1)) = [];
12 |
13 | rhs = f(fdof) - K(fdof,fbc)*bc(:,2);
14 |
15 | sol = K(fdof,fdof) \ rhs;
16 |
17 | d(fbc) = bc(:,2);
18 | d(fdof) = sol;
19 |
20 | % residual
21 | R = K * d - f;
22 |
23 | return
24 | end
25 |
26 |
27 |
--------------------------------------------------------------------------------
/SoilBox/FiniteDeform/xsplit.m:
--------------------------------------------------------------------------------
1 | function [ex,ey,ez] = xsplit(edof,coord,dof,nen,nel)
2 | %
3 |
4 |
5 | nn = zeros(1,nen);
6 |
7 | ex = zeros(nel,nen);
8 | ey = ex;
9 | ez = ex;
10 |
11 | for i = 1:nel
12 | for j = 1:nen
13 | nn(j) = find(dof(:,1)-edof(i,j*3-1)==0);
14 | end
15 | ex(i,:) = coord(nn,1)';
16 | ey(i,:) = coord(nn,2)';
17 | ez(i,:) = coord(nn,3)';
18 | end
19 |
20 |
21 | return
22 | end
--------------------------------------------------------------------------------
/SpectralBox/chebdiffmat.m:
--------------------------------------------------------------------------------
1 | %%
2 | %%
3 |
4 |
5 | function [D,x] = chebdiffmat(n)
6 |
7 | if n == 0
8 | D = 0;
9 | x = 1;
10 | else
11 | x = chebnode(n);
12 |
13 | c = [2; ones(n-1,1); 2] .* (-1).^(0:n)';
14 | m = repmat(x,1,n+1);
15 | dm = m - m';
16 |
17 | % off-diagonal
18 | D = (c*(1 ./ c)') ./ (dm+eye(n+1));
19 | % diagonal
20 | D = D - diag(sum(D'));
21 | end
22 |
23 | return
24 | end
25 |
26 |
27 |
--------------------------------------------------------------------------------
/SpectralBox/chebfit_nodal.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | function [ ws ] = chebfit_nodal(n,xin,yin)
4 |
5 | if isrow(xin)
6 | xin = xin';
7 | end
8 | if isrow(yin)
9 | yin = yin';
10 | end
11 |
12 | % change to range [-1,1]
13 | xmin = min(xin);
14 | xmax = max(xin);
15 | scale = 2.0 / (xmax-xmin);
16 | xs = (xin-xmin).*scale - 1;
17 |
18 | cp = chebpoly1(n, xs);
19 |
20 | ws = cp \ yin;
21 |
22 |
23 | return
24 | end
25 |
26 |
--------------------------------------------------------------------------------
/SpectralBox/chebnode.m:
--------------------------------------------------------------------------------
1 |
2 | function [ xs ] = chebnode(n,xa,xb)
3 | % Chebyshev points of the 2nd kind
4 | % (or Chebyshev extreme point)
5 | % (or Gauss-Chebyshev point)
6 | %
7 | % xk = cos(pi*k/n), 0<=k<=n
8 | % It contains two boundary nodes at endpoints +1 and -1.
9 | %
10 | % NOTE this is different from Chebyshev points of the 1st kind
11 | %
12 | if ~exist('xa','var')
13 | xa = -1.0;
14 | end
15 | if ~exist('xb','var')
16 | xb = 1.0;
17 | end
18 |
19 | if n == 0
20 | xs = 1.0;
21 | else
22 | xs = cos(pi/n .* (0:n))';
23 | xs = (xb-xa)/2 .* (xs+1) + xa;
24 | end
25 |
26 |
27 |
28 | return
29 | end
30 |
31 |
--------------------------------------------------------------------------------
/SpectralBox/chebnode1.m:
--------------------------------------------------------------------------------
1 |
2 | function [ xs ] = chebnode1(n,xa,xb)
3 | % Chebyshev points of the 1st kind
4 | % xk = cos(pi*k/n), 0<=k<=n
5 | % It contains two boundary nodes at endpoints +1 and -1.
6 | %
7 | % NOTE this is different from Chebyshev points of the 2nd kind
8 | %
9 | if ~exist('xa','var')
10 | xa = -1.0;
11 | end
12 | if ~exist('xb','var')
13 | xb = 1.0;
14 | end
15 |
16 | if n == 0
17 | xs = 0;
18 | else
19 | ks = 0:n-1;
20 | % definition by cosine
21 | % xs = cos(pi/(n-1) .* ks);
22 | % sine version, numerically more symmetric!
23 | xs = sin(pi/(2*n) * (n-1-ks*2));
24 | % xs = (xb-xa)/2 .* (xs+1) + xa;
25 | xs = xs';
26 | end
27 |
28 |
29 |
30 | return
31 | end
32 |
33 |
--------------------------------------------------------------------------------
/SpectralBox/chebpoly1.m:
--------------------------------------------------------------------------------
1 |
2 | function [cp] = chebpoly1(np,xs)
3 |
4 | if isrow(xs)
5 | xs = xs';
6 | end
7 |
8 | nx = numel(xs);
9 |
10 | % [0,...,np]
11 | cp = zeros(nx,np+1);
12 |
13 | % T0
14 | cp(:,1) = 1;
15 |
16 | if np >= 1
17 | % T1
18 | cp(:,2) = xs;
19 |
20 | if np >= 2
21 | % n>1, use recurrence relation
22 | for i = 3:np+1
23 | cp(:,i) = 2*xs.*cp(:,i-1) - cp(:,i-2);
24 | end
25 | end
26 | end
27 |
28 |
29 | return
30 | end
31 |
32 |
--------------------------------------------------------------------------------
/SpectralBox/chebrange.m:
--------------------------------------------------------------------------------
1 |
2 | function [xs,scale,xmin,xmax] = chebrange(xin)
3 |
4 | xmin = min(xin);
5 | xmax = max(xin);
6 | scale = 2.0 / (xmax-xmin);
7 | xs = (xin-xmin).*scale - 1;
8 |
9 | return
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/SphereGridBox/IcosahedralPointsNum.m:
--------------------------------------------------------------------------------
1 | function [np] = IcosahedralPointsNum(factor)
2 | %
3 | % 12 vertex, 30 edge, 20 face
4 | %
5 |
6 | np = 12 + 10*3*(factor-1) + 10*(factor-2)*(factor-1);
7 |
8 | return
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/SphereGridBox/RegularPlacePoints.m:
--------------------------------------------------------------------------------
1 |
2 | function [xg] = RegularPlacePoints(ng)
3 |
4 |
5 | r = 1.0;
6 | a = 4*pi*r^2 / ng;
7 | d = sqrt(a);
8 |
9 | mt = round(pi/d);
10 | dt = pi / mt;
11 | dp = a / dt;
12 |
13 | % xg = zeros(ng, 3);
14 | xg = [];
15 | cnt = 0;
16 | for m = 0:(mt-1)
17 | t = pi * (m+0.5) / mt;
18 | mp = round(2*pi*sin(t)/dp);
19 |
20 | for n = 0:(mp-1)
21 | p = 2*pi*n/mp;
22 | x = r * sin(t) * cos(p);
23 | y = r * sin(t) * sin(p);
24 | z = r * cos(t);
25 | xg(end+1,:) = [x,y,z];
26 | cnt = cnt + 1;
27 | end
28 | end
29 |
30 |
31 |
32 | return
33 | end
34 |
35 |
36 |
--------------------------------------------------------------------------------
/SphereGridBox/SaveObjFile.m:
--------------------------------------------------------------------------------
1 | function [] = SaveObjFile(filename, node,elem)
2 |
3 | fileid = fopen(filename,'w');
4 |
5 | nnode = size(node,2);
6 | nelem = size(elem,1);
7 |
8 | fprintf(fileid,'# sphere grid\n');
9 |
10 | for i = 1:nnode
11 | fprintf(fileid, 'v %f %f %f\n', node(1,i),node(2,i),node(3,i));
12 | end
13 |
14 | for i = 1:nelem
15 | fprintf(fileid, 'f %d %d %d\n', elem(i,1),elem(i,2),elem(i,3));
16 | end
17 |
18 | fclose(fileid);
19 |
20 | return
21 | end
22 |
23 |
24 |
--------------------------------------------------------------------------------
/SphereGridBox/SpherePointsToGrid.m:
--------------------------------------------------------------------------------
1 | function [tri] = SpherePointsToGrid(x,y,z)
2 |
3 | % this is an easy hack
4 | % if input points are all on sphere surface,
5 | % then their convex hull is equivalent to a sphere Delaunay
6 | tri = convhull(x,y,z);
7 |
8 |
9 | return
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/SphereGridBox/SpiralPointsEstimNum.m:
--------------------------------------------------------------------------------
1 |
2 | function [n] = SpiralPointsEstimNum(dist)
3 | % Estimate for unit sphere (a=1)
4 | % The typical distance is given relative to a.
5 |
6 | coef = 2.0 / sqrt(3.0);
7 | n = ceil(coef * 4*pi / dist^2);
8 |
9 |
10 | return
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/SphereGridBox/TestRegular.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 |
5 | a = 1.0;
6 |
7 | % np = 64
8 | np = 160
9 |
10 | pos = RegularPlacePoints(np);
11 | pos = pos.';
12 | np = size(pos,2);
13 |
14 | dist = [];
15 |
16 | for i = 1:np
17 | hi = 99999;
18 | for j = 1:np
19 | if i == j
20 | continue;
21 | end
22 |
23 | rij = pos(:,i)-pos(:,j);
24 | rij = sqrt(rij' * rij);
25 |
26 | hi = min(hi,rij);
27 | end
28 | dist(i,:) = [i,hi];
29 | end
30 |
31 | havg = mean(dist(:,2))
32 |
33 | scale = [ 1, 1, 1 ];
34 | % scale = [ 2, 1, 1 ];
35 | pos(1,:) = scale(1) * pos(1,:);
36 | pos(2,:) = scale(2) * pos(2,:);
37 | pos(3,:) = scale(3) * pos(3,:);
38 |
39 | figure;
40 | PlotSphereGrid(np,pos',scale);
41 |
42 |
--------------------------------------------------------------------------------
/SphereGridBox/TestSpiralGrid.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 |
5 | a = 1.0;
6 |
7 | % h = a / 4.0
8 | h = a * 0.32
9 |
10 | np = SpiralPointsEstimNum(h/a)
11 |
12 | np = 64
13 | np = 128
14 |
15 | pos = SpiralPoints(a,[0,0,0]',np);
16 |
17 | dist = [];
18 |
19 | for i = 1:np
20 | hi = 99999;
21 | for j = 1:np
22 | if i == j
23 | continue;
24 | end
25 |
26 | rij = pos(:,i)-pos(:,j);
27 | rij = sqrt(rij' * rij);
28 |
29 | hi = min(hi,rij);
30 | end
31 | dist(i,:) = [i,hi];
32 | end
33 |
34 | havg = mean(dist(:,2))
35 |
36 | scale = [ 1, 1, 1 ];
37 | % scale = [ 2, 1, 1 ];
38 | pos(1,:) = scale(1) * pos(1,:);
39 | pos(2,:) = scale(2) * pos(2,:);
40 | pos(3,:) = scale(3) * pos(3,:);
41 |
42 | figure;
43 | PlotSphereGrid(np,pos',scale);
44 |
45 |
--------------------------------------------------------------------------------
/StokesBox/FillPeriodic.m:
--------------------------------------------------------------------------------
1 |
2 | function [uper] = FillPeriodic(u,nx,ny)
3 |
4 | uper = zeros(nx+1,ny+1);
5 | uper(1:nx,1:ny) = u;
6 | uper(:,ny+1) = uper(:,1);
7 | uper(nx+1,:) = uper(1,:);
8 |
9 | return
10 | end
11 |
--------------------------------------------------------------------------------
/StokesBox/IBSolve2d.m:
--------------------------------------------------------------------------------
1 |
2 | function [ax] = IBSolve2d(kx,ky, np,fp,gp,up,vp, nx,ny,dx,dy,nu)
3 |
4 | global Emat Hmat;
5 |
6 | % distribute to grid
7 | fs = Emat * fp;
8 | gs = Emat * gp;
9 | fs = reshape(fs, nx,ny);
10 | gs = reshape(gs, nx,ny);
11 |
12 | %
13 | [us,vs,ps] = FastSolve2d(kx,ky, fs,gs, nx,ny,dx,dy,nu);
14 |
15 | us = reshape(us, nx*ny,1);
16 | vs = reshape(vs, nx*ny,1);
17 | uint = Hmat * us;
18 | vint = Hmat * vs;
19 |
20 | ax = [uint; vint];
21 |
22 | return
23 | end
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/StokesBox/hashimoto/SumS1.m:
--------------------------------------------------------------------------------
1 |
2 | function [S1] = SumS1(x,y,z,lx,ly,lz,kmax)
3 |
4 | twopiI = pi * 2.0i;
5 |
6 | S1 = 0;
7 |
8 | kxs = (-kmax:kmax) ./ lx;
9 | kys = (-kmax:kmax) ./ ly;
10 | kzs = (-kmax:kmax) ./ lz;
11 |
12 | [kx,ky] = ndgrid(kxs,kys);
13 | kx2 = kx.^2;
14 | ky2 = ky.^2;
15 | kx_x = kx .* x;
16 | ky_y = ky .* y;
17 |
18 | for kz = kzs
19 | k2 = kx2 + ky2 + kz^2;
20 | kr = kx_x + ky_y + kz*z;
21 | ss = exp(twopiI .* kr) ./ k2;
22 | if kz == 0
23 | % k2(kmax+1,kmax+1) = 1.0;
24 | ss(kmax+1,kmax+1) = 0.0;
25 | end
26 | S1 = S1 + sum(ss(:));
27 | end
28 |
29 |
30 | % for kz = kzs
31 | % for ky = kys
32 | % for kx = kxs
33 | % k2 = kx^2 + ky^2 + kz^2;
34 | % if k2 > 0
35 | % kr = kx*x + ky*y + kz*z;
36 | % ss = exp(twopiI * kr) / k2;
37 | % S1 = S1 + ss;
38 | % end
39 | % end
40 | % end
41 | % end
42 |
43 | S1 = real(S1);
44 |
45 | return
46 | end
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/StokesBox/hashimoto/SumU.m:
--------------------------------------------------------------------------------
1 |
2 | function [u] = SumU(x,y,z,lx,ly,lz,kmax)
3 |
4 | twopiI = -pi * 2.0i;
5 |
6 | u = 0;
7 |
8 | % kxs = (-kmax:kmax) ./ lx;
9 | kxs = (0:kmax) ./ lx;
10 | kys = (-kmax:kmax) ./ ly;
11 | kzs = (-kmax:kmax) ./ lz;
12 |
13 | [ky,kz] = ndgrid(kys,kzs);
14 | % ky = reshape(ky,[],1);
15 | % kz = reshape(kz,[],1);
16 |
17 | ky2 = ky.^2;
18 | kz2 = kz.^2;
19 | ky2kz2 = ky2 + kz2;
20 |
21 | kz_z = kz .* z;
22 | ky_y = ky .* y;
23 |
24 | eyz = exp(twopiI .* (ky_y+kz_z));
25 | eyz = real(eyz);
26 |
27 | cyz = -ky2kz2 .* eyz;
28 |
29 | for kx = kxs
30 | k2 = kx.^2 + ky2kz2;
31 | k4 = k2.^2;
32 |
33 | % uu = cyz ./ k4 .* exp(twopiI*kx*x);
34 |
35 | cx = 2;
36 | if kx == 0
37 | cx = 1;
38 | end
39 | uu = cyz ./ k4 .* (cx*cos(2*pi*kx*x));
40 |
41 | if kx == 0
42 | uu(kmax+1,kmax+1) = 0;
43 | end
44 |
45 | u = u + sum(uu(:));
46 | end
47 |
48 | % u = real(u);
49 |
50 | fx = 1.0;
51 | mu = 1.0/(6*pi);
52 | u = u * (-fx) / (4*pi^2*mu*lx*ly*lz);
53 |
54 | return
55 | end
56 |
57 |
--------------------------------------------------------------------------------
/StokesBox/particlemesh/FuncGReg.m:
--------------------------------------------------------------------------------
1 |
2 | function [gl] = FuncGReg(rr,xx,alpha,xi)
3 |
4 | if rr > 0
5 | er = xi * rr;
6 | ar = alpha * rr;
7 |
8 | c1 = (erf(er) - erf(ar)) / rr;
9 | c2 = 2.0/sqrt(pi) * (xi*exp(-er*er) - alpha*exp(-ar*ar));
10 |
11 | ee = xx ./ rr;
12 | ee = ee * ee';
13 |
14 | ee1 = ee + eye(3);
15 | ee2 = -ee + eye(3);
16 |
17 | gl = ee1*c1 + ee2*c2;
18 | else
19 | gl = eye(3) .* (4*(xi-alpha)/sqrt(pi));
20 | end
21 |
22 |
23 | return
24 | end
25 |
26 |
--------------------------------------------------------------------------------
/StokesBox/particlemesh/TestGReg.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | a = 1.0;
5 |
6 | alpha = 0 / a;
7 | xi = 2.0 / a;
8 |
9 |
10 | rs = linspace(0, 8*a, 101);
11 |
12 | gx = [];
13 | gy = [];
14 | gz = [];
15 | for r = rs
16 | gl = FuncGReg(r,[r,0,0]', alpha,xi);
17 | gx(end+1) = gl(1,1);
18 | gy(end+1) = gl(2,2);
19 | gz(end+1) = gl(3,3);
20 | end
21 |
22 | figure;
23 | plot(rs,gx,'x-', rs,gy,'o-');
24 | axis([0,4*a,0,10]);
25 | title(['xi=',num2str(xi),';alpha=',num2str(alpha)]);
26 |
27 |
28 |
--------------------------------------------------------------------------------
/StokesBox/stokes2d.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/StokesBox/stokes2d.xlsx
--------------------------------------------------------------------------------
/StokesBox/swanchannel/InterpOL.m:
--------------------------------------------------------------------------------
1 | function [f3,g3] = InterpOL(theta)
2 |
3 | WallMobGlobals;
4 |
5 | tmp = interp1(MOL_fg(:,1), MOL_fg(:,2:end), theta);
6 | f3 = tmp(1);
7 | g3 = tmp(2);
8 |
9 | return
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/StokesBox/swanchannel/InterpUF.m:
--------------------------------------------------------------------------------
1 | function [f1,f3,f5,g1,g3,g5] = InterpUF(theta)
2 |
3 | WallMobGlobals;
4 |
5 | tmp = interp1(MUF_f(:,1),MUF_f(:,2:end), theta);
6 | f1 = tmp(1);
7 | f3 = tmp(2);
8 | f5 = tmp(3);
9 |
10 | tmp = interp1(MUF_g(:,1),MUF_g(:,2:end), theta);
11 | g1 = tmp(1);
12 | g3 = tmp(2);
13 | g5 = tmp(3);
14 |
15 |
16 | return
17 | end
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/StokesBox/swanchannel/InterpUL.m:
--------------------------------------------------------------------------------
1 | function [f2,f4] = InterpUL(theta)
2 |
3 | WallMobGlobals;
4 |
5 | tmp = interp1(MUL_f(:,1),MUL_f(:,2:end), theta);
6 | f2 = tmp(1);
7 | f4 = tmp(2);
8 |
9 |
10 | return
11 | end
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/StokesBox/swanchannel/InterpUS.m:
--------------------------------------------------------------------------------
1 | function [f2,f4,f6,g2,g4,g6] = InterpUS(theta)
2 |
3 | WallMobGlobals;
4 |
5 | tmp = interp1(MUS_f(:,1), MUS_f(:,2:end), theta);
6 | f2 = tmp(1);
7 | f4 = tmp(2);
8 | f6 = tmp(3);
9 |
10 | tmp = interp1(MUS_g(:,1), MUS_g(:,2:end), theta);
11 | g2 = tmp(1);
12 | g4 = tmp(2);
13 | g6 = tmp(3);
14 |
15 | return
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/StokesBox/swanchannel/PartWallMobUF.m:
--------------------------------------------------------------------------------
1 | function [muf] = PartWallMobUF(theta,ah,ewall)
2 |
3 | [f1,f3,f5,g1,g3,g5] = InterpUF(theta);
4 |
5 | ah3 = ah^3;
6 | ah5 = ah^5;
7 |
8 | cf = 1 - f1*ah + f3*ah3 - f5*ah5;
9 | cg = 1 - g1*ah + g3*ah3 - g5*ah5;
10 |
11 | ww = ewall * ewall';
12 | muf = (eye(3)-ww).*cf + ww.*cg;
13 |
14 | return
15 | end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/StokesBox/swanchannel/PartWallMobUL.m:
--------------------------------------------------------------------------------
1 | function [mul] = PartWallMobUL(theta,ah,ewall)
2 |
3 | [f2,f4] = InterpUL(theta);
4 |
5 | ah2 = ah^2;
6 | ah4 = ah^4;
7 |
8 | cf = f2*ah2 + f4*ah4;
9 |
10 | cf = 1 - f1*ah + f3*ah3 - f5*ah5;
11 | cg = 1 - g1*ah + g3*ah3 - g5*ah5;
12 |
13 | ww = ewall * ewall';
14 | muf = (eye(3)-ww).*cf + ww.*cg;
15 |
16 | return
17 | end
18 |
19 |
20 |
--------------------------------------------------------------------------------
/StokesBox/swanchannel/WallMobGlobals.m:
--------------------------------------------------------------------------------
1 |
2 | %
3 | % [ MUF MUL MUS ]
4 | % [ MOF MOL MOS ]
5 | % [ MEF MEL MES ]
6 | %
7 |
8 |
9 | % f1,f3,f5, g1,g3,g5
10 | global MUF_f MUF_g
11 |
12 | global MUL_f
13 |
14 | global MUS_f MUS_g
15 |
16 | global MOL_fg
17 |
18 | global MOS_f
19 |
20 | global MES_f MES_g MES_h
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/StokesBox/swanchannel/WallMobLoadAll.m:
--------------------------------------------------------------------------------
1 |
2 | WallMobGlobals;
3 |
4 | % UF
5 | muf_f();
6 | muf_g();
7 |
8 | % UL
9 | mul_f();
10 |
11 | % US
12 | mus_f();
13 | mus_g();
14 |
15 | % OL
16 | mol_fg();
17 |
18 | % OS
19 | mos_f();
20 |
21 | % ES
22 | mes_f();
23 | mes_g();
24 | mes_h();
25 |
26 |
27 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/ChannelMobGlobals.m:
--------------------------------------------------------------------------------
1 |
2 | %
3 | % [ MUF MUL MUS ]
4 | % [ MOF MOL MOS ]
5 | % [ MEF MEL MES ]
6 | %
7 |
8 |
9 | % f1,f3,f5, g1,g3,g5
10 | global MUF_f MUF_g
11 |
12 | global MUL_f
13 |
14 | global MUS_f MUS_g
15 |
16 | global MOL_fg
17 |
18 | global MOS_f
19 |
20 | global MES_f MES_g MES_h
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/ChannelMobLoadAll.m:
--------------------------------------------------------------------------------
1 |
2 | ChannelMobGlobals;
3 |
4 | % UF
5 | muf_f();
6 | muf_g();
7 |
8 | % UL
9 | mul_f();
10 |
11 | % US
12 | mus_f();
13 | mus_g();
14 |
15 | % OL
16 | mol_fg();
17 |
18 | % OS
19 | mos_f();
20 |
21 | % ES
22 | mes_f();
23 | mes_g();
24 | mes_h();
25 |
26 |
27 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/InterpOL.m:
--------------------------------------------------------------------------------
1 | function [f3,g3] = InterpOL(theta)
2 |
3 | ChannelMobGlobals;
4 |
5 | tmp = interp1(MOL_fg(:,1), MOL_fg(:,2:end), theta);
6 | f3 = tmp(1);
7 | g3 = tmp(2);
8 |
9 | return
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/InterpUF.m:
--------------------------------------------------------------------------------
1 | function [f1,f3,f5,g1,g3,g5] = InterpUF(theta)
2 |
3 | ChannelMobGlobals;
4 |
5 | tmp = interp1(MUF_f(:,1),MUF_f(:,2:end), theta);
6 | f1 = tmp(1);
7 | f3 = tmp(2);
8 | f5 = tmp(3);
9 |
10 | tmp = interp1(MUF_g(:,1),MUF_g(:,2:end), theta);
11 | g1 = tmp(1);
12 | g3 = tmp(2);
13 | g5 = tmp(3);
14 |
15 |
16 | return
17 | end
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/InterpUL.m:
--------------------------------------------------------------------------------
1 | function [f2,f4] = InterpUL(theta)
2 |
3 | ChannelMobGlobals;
4 |
5 | tmp = interp1(MUL_f(:,1),MUL_f(:,2:end), theta);
6 | f2 = tmp(1);
7 | f4 = tmp(2);
8 |
9 |
10 | return
11 | end
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/InterpUS.m:
--------------------------------------------------------------------------------
1 | function [f2,f4,f6,g2,g4,g6] = InterpUS(theta)
2 |
3 | ChannelMobGlobals;
4 |
5 | tmp = interp1(MUS_f(:,1), MUS_f(:,2:end), theta);
6 | f2 = tmp(1);
7 | f4 = tmp(2);
8 | f6 = tmp(3);
9 |
10 | tmp = interp1(MUS_g(:,1), MUS_g(:,2:end), theta);
11 | g2 = tmp(1);
12 | g4 = tmp(2);
13 | g6 = tmp(3);
14 |
15 | return
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/PartChanMobOL.m:
--------------------------------------------------------------------------------
1 | function [mol] = PartChanMobOL(theta,ah,ewall)
2 |
3 | [f3,g3] = InterpOL(theta);
4 |
5 | ah3 = ah^3;
6 |
7 | cf = 0.75 - f3*ah3;
8 | cg = 0.75 - g3*ah3;
9 |
10 | ww = ewall * ewall';
11 | mol = (eye(3)-ww).*cf + ww.*cg;
12 |
13 | return
14 | end
15 |
16 |
17 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/PartChanMobUF.m:
--------------------------------------------------------------------------------
1 | function [muf] = PartChanMobUF(theta,ah,ewall)
2 |
3 | [f1,f3,f5,g1,g3,g5] = InterpUF(theta);
4 |
5 | ah3 = ah^3;
6 | ah5 = ah^5;
7 |
8 | cf = 1 - f1*ah + f3*ah3 - f5*ah5;
9 | cg = 1 - g1*ah + g3*ah3 - g5*ah5;
10 |
11 | ww = ewall * ewall';
12 | muf = (eye(3)-ww).*cf + ww.*cg;
13 |
14 | return
15 | end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/StokesianDynBox/Channel/PartChanMobUL.m:
--------------------------------------------------------------------------------
1 | function [mul] = PartChanMobUL(theta,ah,ewall)
2 |
3 | CommonGlobals;
4 |
5 | [f2,f4] = InterpUL(theta);
6 |
7 | ah2 = ah^2;
8 | ah4 = ah^4;
9 |
10 | cf = f2*ah2 + f4*ah4;
11 |
12 | mul = zeros(3,3);
13 | for i = 1:3
14 | for j = 1:3
15 | for k = 1:3
16 | mul(i,j) = mul(i,j) + Epsil(i,j,k)*ewall(k);
17 | end
18 | end
19 | end
20 |
21 | mul = mul.*cf;
22 |
23 | return
24 | end
25 |
26 |
27 |
--------------------------------------------------------------------------------
/StokesianDynBox/CollocationMultipole/ADA147301.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/StokesianDynBox/CollocationMultipole/ADA147301.pdf
--------------------------------------------------------------------------------
/StokesianDynBox/CollocationMultipole/cm_stokesd.m:
--------------------------------------------------------------------------------
1 |
2 | function [ cmn ] = cm_stokesd(R,sgn,np,rhs)
3 |
4 |
5 | A = zeros(np,np);
6 |
7 | for k = 1:np
8 | n = k;
9 | fn1 = (n+1) / (4*n-2);
10 | fn2 = (n-2) / (n*(4*n-2));
11 |
12 | for i = 1:np
13 | theta = (i-1) * pi/(np-1);
14 | co1 = cos(theta);
15 | si1 = sqrt(1.0-co1^2);
16 | r2 = sqrt(si1^2 + (R+co1)^2);
17 | co2 = -(R+co1)/r2;
18 |
19 | ppns1 = cm_pns(n,1,co1);
20 | ppns2 = cm_pns(n,1,co2);
21 |
22 | rr = 1.0/r2;
23 | A(i,k) = -ppns1 - rr*sgn*ppns2/r2^(n+1);
24 | end
25 | end
26 |
27 | sol = A \ rhs;
28 | cmn = sol;
29 |
30 | return
31 | end
32 |
33 |
--------------------------------------------------------------------------------
/StokesianDynBox/CommonGlobals.m:
--------------------------------------------------------------------------------
1 |
2 | global TwoPi ThreePi FourPi SixPi EightPi
3 |
4 | global Delta Epsil
5 |
6 |
7 |
--------------------------------------------------------------------------------
/StokesianDynBox/CommonInit.m:
--------------------------------------------------------------------------------
1 |
2 | TwoPi = pi * 2;
3 | ThreePi = pi * 3;
4 | FourPi = pi * 4;
5 | SixPi = pi * 6;
6 | EightPi = pi * 8;
7 |
8 |
9 | Delta = eye(3);
10 |
11 | Epsil = zeros(3,3,3);
12 | Epsil(1,2,3) = 1;
13 | Epsil(2,3,1) = 1;
14 | Epsil(3,1,2) = 1;
15 | Epsil(3,2,1) = -1;
16 | Epsil(2,1,3) = -1;
17 | Epsil(1,3,2) = -1;
18 |
--------------------------------------------------------------------------------
/StokesianDynBox/Ewald/EwaldScalarReal.m:
--------------------------------------------------------------------------------
1 | function [xa,ya,yb,xc,yc] = EwaldScalarReal(xi,r)
2 |
3 | xa = 0;
4 | ya = 0;
5 | yb = 0;
6 | xc = 0;
7 | yc = 0;
8 |
9 | xir = xi * r;
10 | xir2 = xir^2;
11 | s = r;
12 | s2 = s^2;
13 |
14 | erfcxir = erfc(xir);
15 | expxir2 = xi/sqrt(pi) * exp(-xir2);
16 |
17 | ya = (0.75 + 0.5 / s2) / s * erfcxir + ((1.0 + xir2 * (14.0 + 4.0 * xir2 * (- 5.0 + xir2))) / s2 - 4.5 + 3.0 * xir2) * expxir2;
18 | a2 = (0.75 - 1.5 / s2) / s * erfcxir + ((- 3.0 + xir2 * (- 2.0 + 4.0 * xir2 * (4.0 - xir2))) / s2 + 1.5 - 3.0 * xir2) * expxir2;
19 | xa = a2 + ya;
20 |
21 | yb = - 0.75 / s2 * erfcxir - 1.5 * (+ 1.0 + xir2 * (- 6.0 + xir2 * (+ 2.0))) / s * expxir2;
22 |
23 | yc = - 3.0 / 8.0 / s2 / s * erfcxir - 0.75 * (+ 1.0 + xir2 * (+ 14.0 + xir2 * (-20.0 + xir2 * ( + 4.0)))) / s2 * expxir2;
24 | c2 = 9.0 / 8.0 / s2 / s * erfcxir - 0.75 * (- 3.0 + xir2 * (- 2.0 + xir2 * (+ 16.0 + xir2 * (- 4.0)))) / s2 * expxir2;
25 | xc = c2 + yc;
26 |
27 |
28 |
29 |
30 | return
31 | end
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/StokesianDynBox/Ewald/TestDragBC.m:
--------------------------------------------------------------------------------
1 | % body-centered
2 |
3 | clear all;
4 |
5 | a = 1.0;
6 |
7 | np = 2;
8 |
9 | % frac = 0.000125
10 | % frac = 0.008
11 | % frac = 0.027
12 | % frac = 0.064
13 | frac = 0.125
14 |
15 | len = (4/3*pi*a^3 * np / frac)^(1/3)
16 |
17 | tol = 1.0e-8;
18 | xi = 2 / len;
19 |
20 | ewald = EwaldInit(tol, xi, len,len,len)
21 |
22 | xp = zeros(3,np);
23 | xp(:,1) = [0,0,0]';
24 | xp(:,2) = [-len/2,-len/2,-len/2]';
25 |
26 | up = zeros(6,np);
27 | % particle move U=1
28 | up(1,:) = 1.0;
29 |
30 | mob = EwaldMobMatrix(ewald,np,xp);
31 | lub = EwaldLubMatrix(ewald,np,xp);
32 |
33 | res = inv(mob);
34 | res = res + lub;
35 |
36 | uvec = reshape(up,[],1);
37 |
38 | % F = RU
39 | fvec = res * uvec;
40 |
41 | fvec(1)
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/StokesianDynBox/Ewald/TestDragFC.m:
--------------------------------------------------------------------------------
1 | % face-centered
2 |
3 | clear all;
4 |
5 | a = 1.0;
6 |
7 | np = 4;
8 |
9 | % frac = 0.000125
10 | % frac = 0.008
11 | % frac = 0.027
12 | % frac = 0.064
13 | frac = 0.125
14 |
15 | len = (4/3*pi*a^3 * np / frac)^(1/3)
16 |
17 | tol = 1.0e-8;
18 | xi = 2 / len;
19 |
20 | ewald = EwaldInit(tol, xi, len,len,len)
21 |
22 | xp = zeros(3,np);
23 | xp(:,1) = [-len/2,-len/2,-len/2]';
24 | xp(:,2) = [-len/2,0,0]';
25 | xp(:,3) = [0,-len/2,0]';
26 | xp(:,4) = [0,0,-len/2]';
27 |
28 | up = zeros(6,np);
29 | % particle move U=1
30 | up(1,:) = 1.0;
31 |
32 | mob = EwaldMobMatrix(ewald,np,xp);
33 | lub = EwaldLubMatrix(ewald,np,xp);
34 |
35 | res = inv(mob);
36 | res = res + lub;
37 |
38 | uvec = reshape(up,[],1);
39 |
40 | % F = RU
41 | fvec = res * uvec;
42 |
43 | fvec(1)
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/StokesianDynBox/Ewald/TestDragSC.m:
--------------------------------------------------------------------------------
1 | % simple cubic
2 |
3 | clear all;
4 |
5 | addpath('../TwoBody');
6 |
7 | a = 1.0;
8 |
9 | % frac = 0.000125
10 | % frac = 0.008
11 | % frac = 0.027
12 | % frac = 0.064
13 | frac = 0.125
14 | % frac = 0.52
15 |
16 | len = (4/3*pi*a^3 / frac)^(1/3)
17 |
18 | tol = 1.0e-8;
19 | xi = 2 / len;
20 |
21 | ewald = EwaldInit(tol, xi, len,len,len)
22 |
23 | np = 1;
24 | xp = zeros(3,np);
25 | up = zeros(6,np);
26 |
27 | % particle move U=1
28 | up(:,1) = [1,0,0, 0,0,0]';
29 |
30 | mob = EwaldMobMatrix(ewald,np,xp);
31 |
32 | lub = EwaldLubMatrix(ewald,np,xp);
33 |
34 | resfar = inv(mob);
35 | res = resfar;
36 | res = res + lub;
37 |
38 | uvec = reshape(up,[],1);
39 |
40 | % F = RU
41 | fvec = res * uvec;
42 |
43 | fvec(1)
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/StokesianDynBox/WallBody/TestWallOrthoGrid.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | a = 1;
5 | d = 3;
6 |
7 | alpha = acosh(d/a);
8 | c = d / coth(alpha);
9 |
10 |
11 | xis = linspace(0,alpha, 65);
12 | etas = linspace(0,pi,33);
13 |
14 | [xis,etas] = ndgrid(xis,etas);
15 |
16 | rs = c .* sin(etas) ./ (cosh(xis)-cos(etas));
17 | zs = c .* sinh(xis) ./ (cosh(xis)-cos(etas));
18 |
19 |
20 | figure;
21 | plot(rs(:),zs(:),'.');
22 | axis equal;
23 |
24 |
--------------------------------------------------------------------------------
/StokesianDynBox/WallBody/WallPerpendicular.m:
--------------------------------------------------------------------------------
1 | %% Resistance for sphere-wall in perpendicular direction
2 | %%
3 | %%
4 |
5 | clear all;
6 |
7 | nmax = 100;
8 |
9 | a = 1;
10 |
11 | if (0)
12 | % test [Brenner,1961]
13 |
14 | hs = [1.1276260,1.5430806,2.3524096,3.7621957,6.1822895,10.067662];
15 | data = [];
16 | for h = hs
17 | f = WallPerpendicularTrans(h/a,nmax);
18 | data(end+1,:) = [h,f];
19 | end
20 | end
21 |
22 | if (1)
23 | % generate table
24 |
25 | resdat = [];
26 | for h = 1.001:0.001:4.000
27 | f = WallPerpendicularTrans(h/a,nmax);
28 | g = WallPerpendicularRot(h/a,nmax);
29 |
30 | resdat(end+1,:) = [h,f,g];
31 |
32 | if mod(h,0.1) == 0
33 | disp(['h=',num2str(h)]);
34 | end
35 | end
36 |
37 | dlmwrite('tmp.csv',resdat,'precision',8);
38 | end
39 |
40 |
41 |
--------------------------------------------------------------------------------
/StokesianDynBox/WallBody/WallPerpendicularRot.m:
--------------------------------------------------------------------------------
1 | %% Resistance for sphere-wall rotation in perpendicular direction
2 | %% See (Jeffery, 1916) and (Cox & Brenner, 1967)
3 | %%
4 |
5 | function [g] = WallPerpendicularRot(ha,nmax)
6 |
7 | % truncation of series
8 | if ~exist('nmax','var')
9 | nmax = 500;
10 | end
11 |
12 | alpha = acosh(ha);
13 | sinha = sinh(alpha);
14 | cotha = coth(alpha);
15 | cosecha = 1 / sinha;
16 |
17 | ns = 1:nmax;
18 |
19 | s1 = sinh(ns.*alpha);
20 | g = sum(s1.^(-3)) * sinha^3;
21 |
22 | % we normalize by 6*pi*mu*a^3
23 | g = g * 4/3;
24 |
25 | return
26 | end
27 |
28 |
29 |
--------------------------------------------------------------------------------
/StokesianDynBox/WallBody/WallPerpendicularTrans.m:
--------------------------------------------------------------------------------
1 | %% Resistance for sphere-wall translation in perpendicular direction
2 | %% (Brenner, 1961)
3 | %%
4 |
5 | function [f] = WallPerpendicularTrans(ha,nmax)
6 |
7 | % truncation of series
8 | if ~exist('nmax','var')
9 | nmax = 500;
10 | end
11 |
12 | alpha = acosh(ha);
13 | sinha = sinh(alpha);
14 | cotha = coth(alpha);
15 | cosecha = 1 / sinha;
16 |
17 | ns = 1:nmax;
18 |
19 | nc = ns .* (ns+1) ./ (2*ns-1) ./ (2*ns+3);
20 | s1 = sinh((2*ns+1).*alpha);
21 | s2 = (2*ns+1) .* sinh(2*alpha);
22 | s3 = sinh((ns+0.5).*alpha);
23 | s4 = (2*ns+1).^2 .*sinha^2;
24 |
25 | fs = (2*s1 + s2) ./ (4*s3.^2 - s4) - 1;
26 | fs = nc .* fs;
27 |
28 | f = sum(fs) * sinha * 4/3;
29 |
30 |
31 | return
32 | end
33 |
34 |
35 |
--------------------------------------------------------------------------------
/StokesianDynBox/WallBody/WallResistanceMatrix.m:
--------------------------------------------------------------------------------
1 |
2 | function [mat] = WallResistanceMatrix(z)
3 |
4 | global wallresdat;
5 |
6 | if isempty(wallresdat)
7 | % h/a,Fxt,Fxr,Tyt,Tyr,Fzt,Tzr
8 | wallresdat = dlmread('WallSphereResTab.csv');
9 | disp(['Load tabular data: ', int2str(size(wallresdat))]);
10 | end
11 |
12 | zvalid = 4.0;
13 | zsmall = 1.001;
14 |
15 | if z <= zsmall
16 | % asymptotic lubrication theory
17 | [fxt,fxr,tyr,fzt,tzr] = WallAsymptotic(z);
18 | tyt = fxr;
19 | elseif z <= zvalid
20 | resint = interp1(wallresdat(:,1),wallresdat(:,2:end),z);
21 | fxt = resint(1);
22 | fxr = resint(2);
23 | tyt = resint(3);
24 | tyr = resint(4);
25 | fzt = resint(5);
26 | tzr = resint(6);
27 | else
28 | error(['Invalid sphere-wall distance z=',num2str(z)]);
29 | end
30 |
31 | mat = [...
32 | fxt, 0, 0, 0, -fxr, 0;
33 | 0, fxt, 0, fxr, 0, 0;
34 | 0, 0, fzt, 0, 0, 0;
35 | 0, tyt, 0, tyr, 0, 0;
36 | -tyt, 0, 0, 0, tyr, 0;
37 | 0, 0, 0, 0, 0, tzr];
38 |
39 |
40 | return
41 | end
42 |
--------------------------------------------------------------------------------
/StokesianDynBox/WallBody/WallSphere.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/StokesianDynBox/WallBody/WallSphere.xlsx
--------------------------------------------------------------------------------
/StokesianDynBox/capacitance/InductionMat.m:
--------------------------------------------------------------------------------
1 |
2 | function [ Pmat ] = InductionMat(a,h,H)
3 |
4 | theta = h / H;
5 |
6 | % Pmat = zeros(2,2);
7 |
8 | euler_const = 0.5772156649;
9 | zeta3 = 1.202056903159594;
10 |
11 | p11 = 1 + 0.5*(psi(0,theta) + psi(0,1-theta) + 2*euler_const) * (a/H);
12 | p12 = 0.25 * (psi(1,theta) - psi(1,1-theta)) * (a/H)^2;
13 | p22 = 1 + 0.125 * (psi(2,theta) + psi(2,1-theta) - 4*zeta3) * (a/H)^3;
14 |
15 |
16 | Pmat = [ p11,p12; p12,p22 ];
17 |
18 |
19 | return
20 | end
21 |
22 |
23 |
--------------------------------------------------------------------------------
/StokesianDynBox/capacitance/TestCapacitance.m:
--------------------------------------------------------------------------------
1 |
2 | clear all;
3 |
4 | a = 1;
5 | H = a * 4;
6 |
7 | is = 0:50;
8 | dd = 5.5;
9 | ss = 0.5 + 0.5*tanh(dd.*(is./max(is)-0.5)) ./ tanh(dd/2);
10 |
11 | hsmall = a * 1.0e-3;
12 | % remember to exclude the sphere radius
13 | hmin = a + hsmall;
14 | hmax = H - a - hsmall;
15 | hs = hmin + (hmax-hmin).*ss;
16 |
17 | c11 = [];
18 | c12 = [];
19 | c22 = [];
20 | cs = [];
21 |
22 | % hs = [1.01];
23 | for h = hs
24 |
25 | P = InductionMat(a,h,H);
26 |
27 | Cinf = inv(P);
28 |
29 | C2 = C2b(a,h,H);
30 |
31 | C = Cinf + C2;
32 |
33 | cs(end+1,:) = reshape(C,1,[]);
34 | end
35 |
36 | figure;
37 | plot(hs,cs(:,1),'x-', hs,cs(:,2),'x-', hs,cs(:,4),'x-');
38 | legend('c11','c12','c22');
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Tmp/testDampInteg.m:
--------------------------------------------------------------------------------
1 |
2 | clear;
3 |
4 | k = 1;
5 | % eta = 0.1;
6 | eta = 0.0;
7 | delta = 1.0e-2;
8 |
9 | % smoothsign = @(y) y ./ sqrt(y.^2+delta^2));
10 | smoothsign = @(y) tanh(y./delta);
11 |
12 | afun = @(t,y) -k*smoothsign(y) - eta*y;
13 |
14 | y0 = 1.0;
15 | tmax = 2.0;
16 | % y0 = -1.0e-3;
17 | % tmax = 0.1;
18 | [t,y] = ode45(afun, [0,tmax], [y0]);
19 |
20 |
21 | %
22 | wfun = @(w) w + delta.*log(tanh(w./delta) ./ (tanh(w./delta)+1));
23 | ts = linspace(0,tmax,11);
24 | yana = [];
25 | w0 = wfun(y0);
26 | for tt = ts
27 | yana(end+1) = fsolve(@(w) (wfun(w) + k*tt - w0), y0);
28 | end
29 | yana = real(yana);
30 |
31 | figure;
32 | plot(t,y,'-x', ts,yana,'+');
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Utils/deg2rad.m:
--------------------------------------------------------------------------------
1 | function [rad] = deg2rad(deg)
2 | rad = deg .* (pi/180);
3 | return
4 | end
5 |
6 |
--------------------------------------------------------------------------------
/Utils/rad2deg.m:
--------------------------------------------------------------------------------
1 | function [deg] = rad2deg(rad)
2 | deg = rad .* (180/pi);
3 | return
4 | end
5 |
6 |
--------------------------------------------------------------------------------
/Utils/zipcol.m:
--------------------------------------------------------------------------------
1 | % ## Copyright (C) 2013 homu
2 | % ##
3 | % ## This program is free software; you can redistribute it and/or modify
4 | % ## it under the terms of the GNU General Public License as published by
5 | % ## the Free Software Foundation; either version 3 of the License, or
6 | % ## (at your option) any later version.
7 | % ##
8 | % ## This program is distributed in the hope that it will be useful,
9 | % ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | % ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | % ## GNU General Public License for more details.
12 | % ##
13 | % ## You should have received a copy of the GNU General Public License
14 | % ## along with Octave; see the file COPYING. If not, see
15 | % ## .
16 |
17 | % ## ../Utils/zipcol
18 |
19 | % ## Author: homu
20 | % ## Created: 2013-07-30
21 |
22 | function [ ret ] = zipcol (us)
23 | % Description
24 |
25 | ret = reshape(us', [], 1);
26 |
27 | return
28 | end
29 |
--------------------------------------------------------------------------------
/WENOBox/sod.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haloless/StupidCFD/e84e97851c015108bc4f74b26063e49ff0324731/WENOBox/sod.png
--------------------------------------------------------------------------------