From 7c9b05de6428f508d1028fc47c1a1e8dade0b5f9 Mon Sep 17 00:00:00 2001 From: Patrick Sanan Date: Tue, 12 Apr 2022 15:53:54 +0200 Subject: [PATCH 1/2] Multiple sinker model: add option to load inclusion origins from file For model 7 (pTatin sinkers, 3D only), add a command line option to specify a text file with coordinates for the inclusion centers, as three floating point numbers per line. Note that no checks are done to ensure that these inclusions are in the domain, don't overlap with specified radius, etc. --- exSaddle.c | 2 +- models.c | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/exSaddle.c b/exSaddle.c index b86f1f1..5721833 100644 --- a/exSaddle.c +++ b/exSaddle.c @@ -26,7 +26,7 @@ static char help[] = "Solves " #endif "-model 6 : single sinker \n" #if NSD == 3 -"-model 7 : lots of sinkers, controlled by -sinker_n \n" +"-model 7 : lots of sinkers, controlled by -sinker_n and -sinker_use_file\n" #endif #if defined(LAME) "-model 8 : one inclusion, fixed base, free elsewhere \n" diff --git a/models.c b/models.c index 1852ef8..4730c9b 100644 --- a/models.c +++ b/models.c @@ -1160,6 +1160,34 @@ PetscErrorCode StokesOneSinker_EvaluateCoefficients(PetscReal coor[],PetscReal * /*****************************************************************************/ #if NSD == 3 +/* + (3d only) + Loads inclusion origins from a simple text file, with three floating point numbers per line. + */ +PetscErrorCode LoadInclusionOrigins(const char* filename,PetscInt ninclusions,PetscReal **_pos) +{ + PetscReal *pos; + FILE *fp; + + PetscPrintf(PETSC_COMM_WORLD,"# LoadInclusionOrigins\n"); + PetscPrintf(PETSC_COMM_WORLD,"Loading %D inclusion origin(s) from file: %s\n",ninclusions,filename); + + PetscMalloc1(NSD*ninclusions,&pos); + if ((fp = fopen(filename,"r")) == NULL) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Could not open inclusions file %s",filename); + for (PetscInt i=0; i Date: Thu, 21 Apr 2022 16:37:32 +0200 Subject: [PATCH 2/2] Models: add options to control matrix and inclusion densities --- models.c | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/models.c b/models.c index 4730c9b..b91a19f 100644 --- a/models.c +++ b/models.c @@ -655,7 +655,7 @@ Lame' (Elasticity) PetscErrorCode LameOneSinker_EvaluateCoefficients(PetscReal coor[],PetscReal *mu,PetscReal *lambda, PetscReal Fu[],PetscReal Fp[]) { PetscErrorCode ierr; - static PetscReal opts_mu0,opts_mu1,opts_lambda0,opts_lambda1,opts_rad; + static PetscReal opts_mu0,opts_mu1,opts_lambda0,opts_lambda1,opts_rad,opts_rho0,opts_rho1; static PetscBool been_here = PETSC_FALSE; PetscReal mu_qp,lambda_qp,rho_qp; PetscBool inside = PETSC_FALSE; @@ -668,6 +668,8 @@ PetscErrorCode LameOneSinker_EvaluateCoefficients(PetscReal coor[],PetscReal *mu opts_lambda0 = 1.0; opts_lambda1 = 2.0; opts_rad = 0.25; + opts_rho0 = 1.0; + opts_rho1 = 2.0; ierr = PetscOptionsGetReal(NULL,NULL,"-mu0",&opts_mu0,0);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-mu1",&opts_mu1,0);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-lambda0",&opts_lambda0,0);CHKERRQ(ierr); @@ -683,7 +685,7 @@ PetscErrorCode LameOneSinker_EvaluateCoefficients(PetscReal coor[],PetscReal *mu mu_qp = opts_mu0; lambda_qp = opts_lambda0; - rho_qp = 1.0; + rho_qp = opts_rho0; { #if NSD == 2 @@ -695,7 +697,7 @@ PetscErrorCode LameOneSinker_EvaluateCoefficients(PetscReal coor[],PetscReal *mu } if (inside) { - rho_qp = 2.0; /* 2x density inside the inclusion */ + rho_qp = opts_rho1; mu_qp = opts_mu1; lambda_qp = opts_lambda1; } @@ -722,7 +724,7 @@ PetscErrorCode LameOneSinker_EvaluateCoefficients(PetscReal coor[],PetscReal *mu /******************************************************************************/ PetscErrorCode LameXSinker_EvaluateCoefficients(PetscReal coor[],PetscReal *mu,PetscReal *lambda,PetscReal Fu[],PetscReal Fp[]) { - static PetscReal opts_mu0,opts_mu1,opts_lambda0,opts_lambda1,opts_rad; + static PetscReal opts_mu0,opts_mu1,opts_lambda0,opts_lambda1,opts_rad,opts_rho0,opts_rho1; static PetscBool been_here = PETSC_FALSE; static PetscInt opts_numinc; const PetscReal posx[8] = { 0.27 , 0.6 , 0.7 , 0.2 , 0.85 , 0.4 , 0.16 , 0.55 }; @@ -744,6 +746,8 @@ PetscErrorCode LameXSinker_EvaluateCoefficients(PetscReal coor[],PetscReal *mu,P opts_lambda1 = 1.0; opts_rad = 0.05; opts_numinc = 3; + opts_rho0 = 1.0; + opts_rho1 = 2.0; ierr = PetscOptionsGetReal(NULL,NULL,"-mu0",&opts_mu0,0);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-mu1",&opts_mu1,0);CHKERRQ(ierr); @@ -769,7 +773,7 @@ PetscErrorCode LameXSinker_EvaluateCoefficients(PetscReal coor[],PetscReal *mu,P mu_qp = opts_mu0; lambda_qp = opts_lambda0; - rho_qp = 1.0; + rho_qp = opts_rho0; for(i=0; i