From eb753bcc7a43cb33a028a2f24fff90216a053680 Mon Sep 17 00:00:00 2001 From: cfdem Date: Tue, 27 Nov 2012 14:31:53 +0100 Subject: [PATCH] release on 2012-11-27_14-31-53 --- README | 82 +++++++ doc/CFDEMcoupling_Manual.pdf | Bin 515182 -> 515182 bytes doc/githubAccess_public.pdf | Bin 361862 -> 361862 bytes doc/locateModel_turboEngineSearchM2M.html | 2 +- doc/locateModel_turboEngineSearchM2M.txt | 2 +- src/lagrangian/cfdemParticle/Make/files | 22 +- src/lagrangian/cfdemParticle/Make/options | 5 +- .../twoWayM2M/library/libcouple.a | Bin 4209202 -> 4209202 bytes .../dataExchangeModel/twoWayM2M/twoWayM2M.C | 216 ++++++++++++++---- .../dataExchangeModel/twoWayM2M/twoWayM2M.H | 6 +- 10 files changed, 284 insertions(+), 51 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 00000000..a677e0a8 --- /dev/null +++ b/README @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------*\ + CFDEMcoupling - Open Source CFD-DEM coupling + + CFDEMcoupling is part of the CFDEMproject + www.cfdem.com + Christoph Goniva, christoph.goniva@cfdem.com + Copyright 2009-2012 JKU Linz + Copyright 2012- DCS Computing GmbH, Linz +------------------------------------------------------------------------------- +License + This file is part of CFDEMcoupling. + + CFDEMcoupling is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or (at your + option) any later version. + + CFDEMcoupling is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with CFDEMcoupling; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + This code is designed to realize coupled CFD-DEM simulations using LIGGGHTS + and OpenFOAM. Note: this code is not part of OpenFOAM (see DISCLAIMER). +\*---------------------------------------------------------------------------*/ + + +CFDEM coupling provides an open source parallel coupled CFD-DEM framework +combining the strengths of LIGGGHTS DEM code and the Open Source +CFD package OpenFOAM(R)(*). The CFDEMcoupling toolbox allows to expand +standard CFD solvers of OpenFOAM(R)(*) to include a coupling to the DEM +code LIGGGHTS. In this toolbox the particle representation within the +CFD solver is organized by "cloud" classes. Key functionalities are organised +in sub-models (e.g. force models, data exchange models, etc.) which can easily +be selected and combined by dictionary settings. + +The coupled solvers run fully parallel on distributed-memory clusters. + +Features are: + +- its modular approach allows users to easily implement new models +- its MPI parallelization enables to use it for large scale problems +- the "forum"_lws on CFD-DEM gives the possibility to exchange with other + users / developers +- the use of GIT allows to easily update to the latest version +- basic documentation is provided + +The file structure: + +- "src" directory including the source files of the coupling toolbox and models +- "applications" directory including the solver files for coupled CFD-DEM simulations +- "doc" directory including the documentation of CFDEMcoupling +- "tutorials" directory including basic tutorial cases showing the functionality + + + +Details on installation are given on the "www.cfdem.com" + +The functionality of this CFD-DEM framwork is described via "tutorial cases" showing +how to use different solvers and models. + +CFDEMcoupling stands for Computational Fluid Dynamics (CFD) - +Discrete Element Method (DEM) coupling. + +CFDEMcoupling is an open-source code, distributed freely under the terms of the +GNU Public License (GPL). + +Core development of CFDEMcoupling is done by +Christoph Goniva and Christoph Kloss, both at DCS Computing GmbH, 2012 + + +\*---------------------------------------------------------------------------*/ +(*) "OpenFOAM(R)"_of is a registered trade mark of Silicon Graphics +International Corp. This offering is not affiliated, approved or endorsed by +Silicon Graphics International Corp., the producer of the OpenFOAM(R) software +and owner of the OpenFOAM(R) trademark. +\*---------------------------------------------------------------------------*/ diff --git a/doc/CFDEMcoupling_Manual.pdf b/doc/CFDEMcoupling_Manual.pdf index 912655567c9f01124865757df993e386849427c1..2ef1ad4193565140c03fe344b370eed2b510cff2 100644 GIT binary patch delta 989 zcmV<310wwHxF7DgACQR$H!(CbF*G@WkcE%|g^&V;kOPH~1ci_Vg^&idkOu)ieu3$@JdcX8waAXUTgu`jDo57w8rF-mr#$_e-nyizD2phid{N>(#h+%{xRNMI zU1BZG=f{Q1{>Rm2!EkiF%qdA|f3+cBdX^!nl2(;(OH3;{{jj{fyWeZ|iKV5drzd)> zEnlrZjhqcxO=(8w7T;Hd30~-fYFp7&=6us|{CasqN$zr)4av;11bD2fX``gDe6K2Q zezOPtQQdXhy5sxw{*i^2JCeb*^L)LW_cg^dOIH}F5Pn9d-a6v8ymibU)y#d9%yVt!F1bv}?fP;N^ovLGdRg?XgksPwS3vJ1bYke` zlzyOKAgkzLm@LAQ3E+rkf2(wDcWpS7EPAK2GFmuQ!s|LM%0A?P-Yi{2$;}C*yBE>! z8#X#EPqvW?4z1lI2L__aJ41#Lj^+rP$8=-NM+%yDn z`j?-vR$8;!tFD3=9H@e}^=IyAuT1S?M}!yyYch-?q;>?FYD0C4f3fiys)9E6LgNKq z*z0y620k!5^-LexTGoVJqG`AxC~u=QW`$%gxsg;|Vdu5<&7DPPYf%y^4@5m#j@bu_1R=Ma((j#m?k>9NAORBVsdkZD?kcXZtY zXppAY*m2VRZ6ThT=ojj65*D~qHexq LI0_{tMNdWw6Dr$r delta 989 zcmV<310wwHxF7DgACQR$GchzWIWstckcE%|g^&V;kOPH~1ci_Vg^&idkOu)ie>yND zYB-;7-q3$c5{mJcP?=IzkZdP$6yuFs61P13G)b~F%BffsQA{nRaU9+ByM`Vo<2|HV z9xcYw(H_!y9u;G0ksVLBl*LI@j-=x~q!+rUIQ^5}x}d2jizuahQQ|qpS2Jx~N|dB7 zu$JcY`LqerQm?UfxiWyI5vJFtaQH9;<5FC@C!8tBRZ7 z>_LB2cipz`_&&XVWTEAbWH9Y4UoYoo`yd@McG4o4f4}7otW{KZ zFm%{Ab+`RRt37L5v!SY%wpN|cuTiiN(~S$$8OXnikIv(J?~_GJF+f2m=The-l;d>b z&kGI0XQcI(iaYX_npf4#eUZ#_ZRIYx49T7Pa^dugNAh}E^rZx2P%W20ZzNP=sO6M? zpdcWt=wO&E+>#04h-RyFe{FYdP)ZiP(ODTS94ldUofc*9azJmEE~4b-1k&A$X!i}9 z9>)JG2piED{x=W|_3-`bYIVy->U!^b^4l%F+A)n-L+?f{1lqjog@!B+g5)H*X$b7} z4?knCv}UtcT?IBcR0VD8&)m^oncDe|2tJ0k$uNr$+7W504b?5?f5vCf3gp}ijR#m^ zPu!t1@WSlWGks)hSrbl)rs0M_y^Ycs7Lq;ZMqG7?o#)bbcgU9fkRT~K7EmA_}p;J$iWAvfNLeB?+Z-nGqc8O2`&^LJRxqtIqqk{ax@?g>Ws%6?T zR;z1C>nVl`*s#7De^NgfUsnf{FqVGr)N^-HO$P~(SWmU{+;UfOwZ3|jL`e_8h(`lA zJ;{!v?r#&Z`oQl|FXZ7kEO4pFgEoM@=Q9pS6dzkf7@0s6@w+hl$@m|s{lLam$#vC0 z?;-jrx(vP4y3y}ZRbBIX4lUZ`)dl4LSHcQ_Aa|nMa!~s&NmT5NM*-CbZg8#m2K5({ zr<1>r{4!i$r(1H=ha+-%*p5FYPWRa`=b)9O^DzHMYX5kXCWI zGB!6cIA%9xH#cKrWjHo6F)?L0Ib=0AH)CRAWiVqjK3zUO3UhQ}a&&ldWo8OAIXE>q LI0_{tMNdWw?EBqo diff --git a/doc/githubAccess_public.pdf b/doc/githubAccess_public.pdf index a03509e9b8fe564d47e790fef8e819c75dd3ce8c..58a90235dcd7be5091506df0146cbd70352b1386 100644 GIT binary patch delta 107 zcmZqc7HjJko6yN_ZfIg`Xkytop>+ad>jb9O3Cyh%Shh}JozdcyYMg9nVq%$`XknRZ hnwn~0W|@+dn3S5DVv?3(oM>cbXG2KE^sH7^832AOB7gt@ delta 107 zcmZqc7HjJko6yN_Y-nO+X>8Frp>+ad>jb9O3Cyh%Shh}Jozdb16izcwOir{gF*P!^ gOioELN;OJ0O0-NePffHmHb}CwA*5n@Rx7Iv09D^1V*mgE diff --git a/doc/locateModel_turboEngineSearchM2M.html b/doc/locateModel_turboEngineSearchM2M.html index e6f89b6a..5082aaa7 100644 --- a/doc/locateModel_turboEngineSearchM2M.html +++ b/doc/locateModel_turboEngineSearchM2M.html @@ -33,7 +33,7 @@ turboEngineM2MProps { turboEngineProps { - treeSearch false; + treeSearch true; } } diff --git a/doc/locateModel_turboEngineSearchM2M.txt b/doc/locateModel_turboEngineSearchM2M.txt index 9e074348..c126f9f3 100644 --- a/doc/locateModel_turboEngineSearchM2M.txt +++ b/doc/locateModel_turboEngineSearchM2M.txt @@ -30,7 +30,7 @@ turboEngineM2MProps \{ turboEngineProps \{ - treeSearch false; + treeSearch true; \} \} :pre diff --git a/src/lagrangian/cfdemParticle/Make/files b/src/lagrangian/cfdemParticle/Make/files index b26fe6cd..e2411291 100644 --- a/src/lagrangian/cfdemParticle/Make/files +++ b/src/lagrangian/cfdemParticle/Make/files @@ -20,18 +20,33 @@ $(forceModels)/forceModel/forceModel.C $(forceModels)/forceModel/newForceModel.C $(forceModels)/noDrag/noDrag.C $(forceModels)/DiFeliceDrag/DiFeliceDrag.C +$(forceModels)/DiFeliceDragNLift/DiFeliceDragNLift.C $(forceModels)/GidaspowDrag/GidaspowDrag.C $(forceModels)/SchillerNaumannDrag/SchillerNaumannDrag.C $(forceModels)/Archimedes/Archimedes.C $(forceModels)/ArchimedesIB/ArchimedesIB.C $(forceModels)/interface/interface.C $(forceModels)/ShirgaonkarIB/ShirgaonkarIB.C +$(forceModels)/fieldTimeAverage/fieldTimeAverage.C +$(forceModels)/fieldBound/fieldBound.C +$(forceModels)/volWeightedAverage/volWeightedAverage.C +$(forceModels)/totalMomentumExchange/totalMomentumExchange.C $(forceModels)/KochHillDrag/KochHillDrag.C +$(forceModels)/BeetstraDrag/multiphaseFlowBasic/multiphaseFlowBasic.C +$(forceModels)/BeetstraDrag/BeetstraDrag.C +$(forceModels)/LaEuScalarLiquid/LaEuScalarLiquid.C $(forceModels)/LaEuScalarTemp/LaEuScalarTemp.C +$(forceModels)/LaEuScalarDust/LaEuScalarDust.C $(forceModels)/virtualMassForce/virtualMassForce.C $(forceModels)/gradPForce/gradPForce.C +$(forceModels)/gradULiftForce/gradULiftForce.C $(forceModels)/viscForce/viscForce.C $(forceModels)/MeiLift/MeiLift.C +$(forceModels)/KochHillDragNLift/KochHillDragNLift.C +$(forceModels)/solidsPressureForce/solidsPressureForce.C +$(forceModels)/periodicPressure/periodicPressure.C +$(forceModels)/periodicPressureControl/periodicPressureControl.C +$(forceModels)/averageSlipVel/averageSlipVel.C $(forceModelsMS)/forceModelMS/forceModelMS.C $(forceModelsMS)/forceModelMS/newForceModelMS.C @@ -42,6 +57,7 @@ $(IOModels)/IOModel/newIOModel.C $(IOModels)/noIO/noIO.C $(IOModels)/basicIO/basicIO.C $(IOModels)/trackIO/trackIO.C +$(IOModels)/sophIO/sophIO.C $(voidFractionModels)/voidFractionModel/voidFractionModel.C $(voidFractionModels)/voidFractionModel/newVoidFractionModel.C @@ -57,22 +73,25 @@ $(locateModels)/locateModel/newLocateModel.C $(locateModels)/standardSearch/standardSearch.C $(locateModels)/engineSearch/engineSearch.C $(locateModels)/turboEngineSearch/turboEngineSearch.C +$(locateModels)/turboEngineSearchM2M/turboEngineSearchM2M.C $(locateModels)/engineSearchIB/engineSearchIB.C - $(meshMotionModels)/meshMotionModel/meshMotionModel.C $(meshMotionModels)/meshMotionModel/newMeshMotionModel.C $(meshMotionModels)/noMeshMotion/noMeshMotion.C +$(meshMotionModels)/DEMdrivenMeshMotion/DEMdrivenMeshMotion.C $(momCoupleModels)/momCoupleModel/momCoupleModel.C $(momCoupleModels)/momCoupleModel/newMomCoupleModel.C $(momCoupleModels)/explicitCouple/explicitCouple.C +$(momCoupleModels)/explicitCoupleSource/explicitCoupleSource.C $(momCoupleModels)/implicitCouple/implicitCouple.C $(momCoupleModels)/noCouple/noCouple.C $(regionModels)/regionModel/regionModel.C $(regionModels)/regionModel/newRegionModel.C $(regionModels)/allRegion/allRegion.C +$(regionModels)/differentialRegion/differentialRegion.C $(dataExchangeModels)/dataExchangeModel/dataExchangeModel.C $(dataExchangeModels)/dataExchangeModel/newDataExchangeModel.C @@ -80,6 +99,7 @@ $(dataExchangeModels)/oneWayVTK/oneWayVTK.C $(dataExchangeModels)/twoWayFiles/twoWayFiles.C $(dataExchangeModels)/noDataExchange/noDataExchange.C $(dataExchangeModels)/twoWayMPI/twoWayMPI.C +$(dataExchangeModels)/twoWayM2M/twoWayM2M.C $(averagingModels)/averagingModel/averagingModel.C $(averagingModels)/averagingModel/newAveragingModel.C diff --git a/src/lagrangian/cfdemParticle/Make/options b/src/lagrangian/cfdemParticle/Make/options index e24e4695..eb5d1463 100644 --- a/src/lagrangian/cfdemParticle/Make/options +++ b/src/lagrangian/cfdemParticle/Make/options @@ -13,6 +13,7 @@ EXE_INC = \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/OpenFOAM/containers/HashTables/labelHashSet \ -I$(CFDEM_LIGGGHTS_SRC_DIR) \ + -I$(CFDEM_M2MLIB_PATH) \ LIB_LIBS = \ $(PLIBS) \ @@ -24,4 +25,6 @@ LIB_LIBS = \ -llagrangian \ -lmpi_cxx \ -L$(CFDEM_LIGGGHTS_SRC_DIR) \ - -l$(CFDEM_LIGGGHTS_LIB_NAME) + -l$(CFDEM_LIGGGHTS_LIB_NAME) \ + -L$(CFDEM_M2MLIB_PATH) \ + -lcouple diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/libcouple.a b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/libcouple.a index b68d5eb3ff6d553fa721e24f2687b5e9e99f5171..b9aa4517d4f20b248b9c25298dd5bf1e73e4ae2a 100644 GIT binary patch delta 402 zcmXxfJ5Rz;7=Yn`g7vPb6f0`Q8{TNao>~+y2|vP#&G<8lE}q0NILYYBOlnR-2l+P) z#Do}ke4%l8hLgPCm+!QHpWEnHWMreZgB*6ThkYF2P&I1#!fRB!k{U-i z#tBYwhJxz$tjG5#^rDNazAdYM5ha|%fq;t(RrS3uF`jVk=nymTq#2ZPi7QlajT>bK Hx2cyuY)YXt delta 402 zcmXxfJ5Rz;7=Yn`g7vPb6f0`Q8{TMbDOANv!jEubGyaUCizhJ*PBOYOlbVyzLH-Q` zF(JksUp+WH!%5!n%Xiw}5Ail$vPst|+a>QY_nwR080uv=yS=P8H4jA0xJBrzfD zhIV`RU)zzEmS2J9R}z2QgcWI+#1y76gIUZ;E1G{Bs!6BGq%QiM1uPZ8*ugILurC|6eBoKuML~@N9O4Ma zI6*;nd)EEyC{!0$16x#sQ#f!@gohH!vKsgwo|^E~A!g_cGd#mNE>OWGuA~`Wr=ETQ D^&g0){ double **tata_ = (double **) lammps_extract_atom(lmp,charName); @@ -181,8 +182,9 @@ void twoWayM2M::getData lmp2foam_vec_->exchange(tata_, &(field[0][0])); }*/ //for (int i = 0; i < nlocal_foam_; i++) + // Pout << "hihi getData: " << name <<"=" << field[i][0]<<","<exchange(tmp_, &(field[0][0])); //for (int i = 0; i < nlocal_foam_; i++) @@ -320,6 +322,7 @@ bool Foam::twoWayM2M::couple() const // m2m stuff particleCloud_.clockM().start(4,"CoupleSyncIDs()"); syncIDs(); + firstRun_=false; particleCloud_.clockM().stop("CoupleSyncIDs()"); // give nr of particles to cloud @@ -349,54 +352,180 @@ int Foam::twoWayM2M::getNumberOfClumps() const void Foam::twoWayM2M::syncIDs() const { + //MPI_Barrier(MPI_COMM_WORLD); + //Pout << "== syncIDs " << endl; + particleCloud_.clockM().start(5,"recv_DEM_ids"); // get data from lammps + int nlocal_lammps_old=nlocal_lammps_; nlocal_lammps_ = *((int *) lammps_extract_global(lmp,"nlocal")); - id_lammps_ = (int *) lammps_extract_atom(lmp,"id"); + + // weak form to detect lmp proc change - this will cause problems!!! + //bool comRun=false; + //if(nlocal_lammps_old != nlocal_lammps_) comRun=true; + //MPI_Allreduce(&comRun, &firstRun_, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); + + int* id_lammps_sync; + double** pos_lammps_sync; + if(firstRun_) // do not forget iterator ! + { + // IDs for vectors + id_lammps_ = (int *) lammps_extract_atom(lmp,"id"); + + delete [] id_lammps_vec_; + Foam::dataExchangeModel::allocateArray(id_lammps_vec_,0,nlocal_lammps_*3); + for (int i = 0; i < nlocal_lammps_; i++) + for (int j=0;j<3;j++) + id_lammps_vec_[i*3+j] = id_lammps_[i]*3+j; + + Foam::dataExchangeModel::allocateArray(pos_lammps_,-1.,3,nlocal_lammps_); // do I need this??? + pos_lammps_ = (double **) lammps_extract_atom(lmp,"x"); + + //for (int i = 0; i < nlocal_lammps_; i++){ + // vector pp; + // for (int j = 0; j < 3; j++) pp[j]=pos_lammps_[i][j]; + // Pout << "pp=" << pp << endl; + //} + + }else + { + // re-arrange data using map + Foam::dataExchangeModel::allocateArray(id_lammps_sync,-1.,nlocal_lammps_); + id_lammps_sync = (int *) lammps_extract_atom(lmp,"id"); + + delete [] id_lammps_vec_; + Foam::dataExchangeModel::allocateArray(id_lammps_vec_,0,nlocal_lammps_*3); + for (int i = 0; i < nlocal_lammps_; i++) + for (int j=0;j<3;j++) + id_lammps_vec_[i*3+j] = id_lammps_sync[i]*3+j; + + // make setup of m2m + lmp2foam_->setup(nlocal_lammps_,id_lammps_sync,nlocal_foam_,id_foam_); + lmp2foam_vec_->setup(nlocal_lammps_*3,id_lammps_vec_,nlocal_foam_*3,id_foam_vec_); + foam2lmp_vec_->setup(nlocal_foam_*3,id_foam_vec_,nlocal_lammps_*3,id_lammps_vec_); + + Foam::dataExchangeModel::allocateArray(id_lammps_,-1,nlocal_foam_); // probably not necessary + lmp2foam_->exchange(id_lammps_sync, id_lammps_); + + + Foam::dataExchangeModel::allocateArray(pos_lammps_sync,-1.,3,nlocal_lammps_); // probably not necessary + pos_lammps_sync = (double **) lammps_extract_atom(lmp,"x"); + + // find better solution here!!! + double** gugu; + Foam::dataExchangeModel::allocateArray(gugu,-1.,3*nlocal_foam_,1); + Foam::dataExchangeModel::allocateArray(pos_lammps_,-1.,3,nlocal_foam_); + lmp2foam_vec_->exchange(&(pos_lammps_sync[0][0]), &(gugu[0][0])); + + // try the same with getData + //double** gugu; + //Foam::dataExchangeModel::allocateArray(gugu,-1.,3,nlocal_foam_); + //Foam::dataExchangeModel::allocateArray(pos_lammps_,-1.,3,nlocal_foam_); + //getData("x","vector-atom",gugu,1); + + // conversion of array (should not be necessary if above problem is solved) + for (int i = 0; i < nlocal_foam_; i++) + for (int j = 0; j < 3; j++) + pos_lammps_[i][j]=gugu[0][i*3+j]; + + /*// test communication - works!!! + int* llv; + int* ovv; + Many2Many* l2f = new Many2Many(MPI_COMM_WORLD); + double** gaga; + if(Pstream::myProcNo()==0) + { + Foam::dataExchangeModel::allocateArray(llv,0,6); + Foam::dataExchangeModel::allocateArray(ovv,0,1); + for(int i=0;i<6;i++) + llv[i]=i+1; + ovv[0]=-1; + l2f->setup(6,llv,0,ovv); + l2f->exchange(&(pos_lammps_sync[0][0]), &(gaga[0][0])); + }else{ + Foam::dataExchangeModel::allocateArray(llv,0,1); + Foam::dataExchangeModel::allocateArray(ovv,0,6); + for(int i=0;i<6;i++) + ovv[i]=i+1; + llv[0]=-1; + l2f->setup(0,llv,6,ovv); + + double** gugu; + Foam::dataExchangeModel::allocateArray(gaga,-1.,3,2); + Foam::dataExchangeModel::allocateArray(gugu,-1.,3,2); + l2f->exchange(&(pos_lammps_sync[0][0]), &(gugu[0][0])); + + // this does not work! -conversion needed! + //for (int i = 0; i < 2; i++) + // Pout << "getDataXX: " << "v" <<"=" << gugu[i][0]<<","<< gugu[i][1]<<","<< gugu[i][2]<setup(nlocal_lammps_,id_lammpsComm_,nlocal_foam_,id_foam_); - lmp2foam_vec_->setup(nlocal_lammps_*3,id_lammps_vec_,nlocal_foam_*3,id_foam_vec_); - foam2lmp_vec_->setup(nlocal_foam_*3,id_foam_vec_,nlocal_lammps_*3,id_lammps_vec_); + if(firstRun_) + { + //lmp2foam_->setup(nlocal_lammps_,id_lammpsComm_,nlocal_foam_,id_foam_); + lmp2foam_->setup(nlocal_lammps_,id_lammps_,nlocal_foam_,id_foam_); + lmp2foam_vec_->setup(nlocal_lammps_*3,id_lammps_vec_,nlocal_foam_*3,id_foam_vec_); + foam2lmp_vec_->setup(nlocal_foam_*3,id_foam_vec_,nlocal_lammps_*3,id_lammps_vec_); + }else + { + //lmp2foam_->setup(nlocal_lammps_,id_lammpsComm_,nlocal_foam_,id_foam_); + lmp2foam_->setup(nlocal_lammps_,id_lammps_sync,nlocal_foam_,id_foam_); + lmp2foam_vec_->setup(nlocal_lammps_*3,id_lammps_vec_,nlocal_foam_*3,id_foam_vec_); + foam2lmp_vec_->setup(nlocal_foam_*3,id_foam_vec_,nlocal_lammps_*3,id_lammps_vec_); + } particleCloud_.clockM().stop("setup_Comm"); } @@ -428,9 +557,6 @@ void Foam::twoWayM2M::locateParticle() const delete [] id_foam_vec_; Foam::dataExchangeModel::allocateArray(id_foam_vec_,0,nop*3); - delete [] id_lammps_vec_; - Foam::dataExchangeModel::allocateArray(id_lammps_vec_,0,nop*3); - delete [] cellID_foam_; Foam::dataExchangeModel::allocateArray(cellID_foam_,0,nop); delete [] pos_foam_; @@ -446,10 +572,11 @@ void Foam::twoWayM2M::locateParticle() const } } - // if global nr of particles changed: - // realloc idHashTable_ - // loop all lmp particles + int iterate; + if(firstRun_) iterate=nlocal_lammps_; + else iterate=nlocal_foam_; + nlocal_foam_ = 0; nlocal_foam_lost_ = 0; vector pos; @@ -457,16 +584,15 @@ void Foam::twoWayM2M::locateParticle() const label searchCellID; particleCloud_.clockM().start(7,"locate_Stage1"); - for (int i = 0; i < nlocal_lammps_; i++) + + for (int i = 0; i < iterate; i++) { pos = vector(pos_lammps_[i][0],pos_lammps_[i][1],pos_lammps_[i][2]); - searchCellID = -1;//idHashTable_[id_lammps_[i]]; + searchCellID = -1; + //Pout << "stage1 looking for particle pos="<< pos << endl; + cellID = particleCloud_.locateM().findSingleCell(pos,searchCellID); - // IDs for vectors - for (int j=0;j<3;j++) - id_lammps_vec_[i*3+j] = id_lammps_[i]*3+j; - // found particle on cfd proc if (cellID >= 0) { @@ -481,11 +607,8 @@ void Foam::twoWayM2M::locateParticle() const } cellID_foam_[nlocal_foam_] = cellID; - // cell id hash table - //idHashTable_[id_lammps_[i]]=cellID; - nlocal_foam_ += 1; - //Pout << "found particle at pos=" << pos << endl; + //Pout << "stage1 found particle at pos=" << pos << endl; } else { @@ -502,14 +625,23 @@ void Foam::twoWayM2M::locateParticle() const // using allgather to allreduce lost particles particleCloud_.clockM().start(8,"locate_Stage2"); + + // we could add this here - but some arrays must be init + //int lost_all; + //MPI_Allreduce(&nlocal_foam_lost_, &lost_all, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); + //if(lost_all>0) + + int nlocal_foam_lost_all = LAMMPS_NS::MPI_Allgather_Vector(lost_pos_, nlocal_foam_lost_*3, lost_pos_all, MPI_COMM_WORLD)/3; LAMMPS_NS::MPI_Allgather_Vector(id_foam_lost_, nlocal_foam_lost_, id_foam_lost_all, MPI_COMM_WORLD); + Info << couplingStep_ << "st nlocal_foam_lost_all=" << nlocal_foam_lost_all << endl; // locate lost particles for (int i = 0; i < nlocal_foam_lost_all; i++) { pos = vector(lost_pos_all[i*3+0],lost_pos_all[i*3+1],lost_pos_all[i*3+2]); - searchCellID = -1;//idHashTable_[id_foam_lost_all[i]]; + //Pout << "stage2 looking for particle pos="<< pos << endl; + searchCellID = -1; particleCloud_.clockM().start(9,"findSingleCell"); cellID = particleCloud_.locateM().findSingleCell(pos,searchCellID); particleCloud_.clockM().stop("findSingleCell"); @@ -531,10 +663,8 @@ void Foam::twoWayM2M::locateParticle() const // mark that ID was finally found id_foam_lost_all[i]=-1; - // cell id hash table - //idHashTable_[id_foam_lost_all[i]]=cellID; - nlocal_foam_ += 1; + //Pout << "stage2 found particle at pos=" << pos << endl; } } particleCloud_.clockM().stop("locate_Stage2"); @@ -560,7 +690,7 @@ void Foam::twoWayM2M::locateParticle() const // re-arrange IDs for vectors for (int k=0;k<3;k++) { - id_lammps_vec_[j*3+k] = id_lammps_vec_[(nlocal_lammps_-1)*3+k]; + id_lammps_vec_[j*3+k] = id_lammps_vec_[nlocal_lammps_*3+k]; } nlocal_lammps_ -= 1; @@ -570,7 +700,7 @@ void Foam::twoWayM2M::locateParticle() const } i++; } - particleCloud_.clockM().stop("locate_Stage3");*/ + particleCloud_.clockM().stop("locate_Stage3");*/ /*int gaga; MPI_Allreduce(&nlocal_foam_, &gaga, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.H b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.H index 68441ac7..8c9be08b 100644 --- a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.H +++ b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.H @@ -89,12 +89,13 @@ private: dictionary propsDict_; // new vars + mutable bool firstRun_; mutable Many2Many *lmp2foam_; mutable Many2Many *lmp2foam_vec_; mutable Many2Many *foam2lmp_vec_; mutable int nlocal_lammps_; mutable int *id_lammps_; - mutable int *id_lammpsComm_; + //mutable int *id_lammpsComm_; mutable int *id_lammps_vec_; mutable int nlocal_foam_; mutable int *id_foam_; @@ -110,9 +111,6 @@ private: mutable int *cellID_foam_; mutable double *pos_foam_; - // optimization - //mutable int *idHashTable_; - // variables int me;