diff --git a/models/IonModel.cpp b/models/IonModel.cpp index 7213cfce..9ab02d1e 100644 --- a/models/IonModel.cpp +++ b/models/IonModel.cpp @@ -583,6 +583,70 @@ void ScaLBL_IonModel::SetDomain() { nprocz = Dm->nprocz(); } +void ScaLBL_IonModel::SetMembrane() { + membrane_db = db->getDatabase("Membrane"); + + /* set distance based on labels inside the membrane (all other labels will be outside) */ + auto InsideMembraneLabels = membrane_db->getVector("InsideMembraneLabels"); + IonMembrane = std::shared_ptr(new Membrane(Dm, NeighborList, Np)); + + signed char LABEL = 0; + double *label_count; + double *label_count_global; + Array membrane_id(Nx,Ny,Nz); + label_count = new double[NLABELS]; + label_count_global = new double[NLABELS]; + // Assign the labels + for (size_t idx = 0; idx < NLABELS; idx++) + label_count[idx] = 0; + /* set the distance to the membrane */ + MembraneDistance.resize(Nx, Ny, Nz); + MembraneDistance.fill(0); + for (int k = 0; k < Nz; k++) { + for (int j = 0; j < Ny; j++) { + for (int i = 0; i < Nx; i++) { + membrane_id(i,j,k) = 1; // default value + LABEL = Dm->id[k*Nx*Ny + j*Nx + i]; + for (size_t m=0; mComm.sumReduce(label_count[m]); + } + if (rank == 0) { + printf("Membrane labels: %lu \n", MembraneLabels.size()); + for (size_t m=0; mrank()); diff --git a/models/IonModel.h b/models/IonModel.h index 8930b1df..5fcaa982 100644 --- a/models/IonModel.h +++ b/models/IonModel.h @@ -1,7 +1,6 @@ /* * Ion transporte LB Model */ - #ifndef ScaLBL_IonModel_INC #define ScaLBL_IonModel_INC @@ -16,6 +15,7 @@ #include "common/ScaLBL.h" #include "common/Communication.h" +#include "common/Membrane.h" #include "common/MPI.h" #include "analysis/Minkowski.h" #include "ProfilerApp.h" @@ -30,10 +30,12 @@ public: void ReadParams(string filename); void ReadParams(std::shared_ptr db0); void SetDomain(); + void SetMembrane(); void ReadInput(); void Create(); void Initialize(); void Run(double *Velocity, double *ElectricField); + void RunMembrane(double *Velocity, double *ElectricField, double *Psi); void getIonConcentration(DoubleArray &IonConcentration, const size_t ic); void getIonConcentration_debug(int timestep); void getIonFluxDiffusive(DoubleArray &IonFlux_x, DoubleArray &IonFlux_y, @@ -98,6 +100,13 @@ public: double *FluxAdvective; double *FluxElectrical; + + /* these support membrane capabilities */ + std::shared_ptr membrane_db; + std::shared_ptr IonMembrane; + DoubleArray MembraneDistance; + int MembraneCount; // number of links the cross the membrane + private: Utilities::MPI comm;