diff --git a/README b/README deleted file mode 100644 index a677e0a8..00000000 --- a/README +++ /dev/null @@ -1,82 +0,0 @@ -/*---------------------------------------------------------------------------*\ - 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 81a55d31..90a60e64 100644 Binary files a/doc/CFDEMcoupling_Manual.pdf and b/doc/CFDEMcoupling_Manual.pdf differ diff --git a/doc/githubAccess_public.pdf b/doc/githubAccess_public.pdf index 74778a77..863e3f7c 100644 Binary files a/doc/githubAccess_public.pdf and b/doc/githubAccess_public.pdf differ diff --git a/src/lagrangian/cfdemParticle/Make/files b/src/lagrangian/cfdemParticle/Make/files index d1578924..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 @@ -60,20 +76,22 @@ $(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 diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/irregular.o b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/irregular.o index 7f77b22c..590607a5 100644 Binary files a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/irregular.o and b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/irregular.o differ diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/libcouple.a b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/libcouple.a index d87f0f65..58d2cea5 100644 Binary files a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/libcouple.a and b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/library/libcouple.a differ diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.C b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.C index a1602e1c..0120f068 100644 --- a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.C +++ b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.C @@ -61,7 +61,10 @@ twoWayM2M::twoWayM2M ) : dataExchangeModel(dict,sm), - propsDict_(dict.subDict(typeName + "Props")) + propsDict_(dict.subDict(typeName + "Props"))/*, + lmp2foam_(*new Many2Many(MPI_COMM_WORLD)), // init of many2many & + lmp2foam_vec_(*new Many2Many(MPI_COMM_WORLD)), + foam2lmp_vec_(*new Many2Many(MPI_COMM_WORLD))*/ { Info<<"Starting up LIGGGHTS for first time execution"<0){ - double **tata_ = (double **) lammps_extract_atom(lmp,charName); - lmp2foam_vec_->exchange(&(tata_[0][0]), &(field[0][0])); - /*}else{ - // is this else necessary? - double *tata_ = (double *) lammps_extract_atom(lmp,charName); - lmp2foam_vec_->exchange(tata_, &(field[0][0])); - }*/ + double **tata_ = (double **) lammps_extract_atom(lmp,charName); + lmp2foam_vec_->exchange(&(tata_[0][0]), &(field[0][0])); //for (int i = 0; i < nlocal_foam_; i++) // Pout << "hihi getData: " << name <<"=" << field[i][0]<<","<0){ + tmp_ = (double *) lammps_extract_atom(lmp,charName); + /*}else{ + // might use the fct from dataExchangeModel mother class + tmp_=new double[1]; + tmp_[0]=0; + }*/ + lmp2foam_->exchange(tmp_, &(field[0][0])); //for (int i = 0; i < nlocal_foam_; i++) // Pout << name <<"[0][i]=" << field[0][i] <0){ + id_lammps_ = (int *) lammps_extract_atom(lmp,"id"); + }else{ + // might use the fct from dataExchangeModel mother class + id_lammps_=new int[1]; + id_lammps_[0]=0; + } - delete [] id_lammps_vec_; + Pout << couplingStep_ << "st id_lammps_[0]=" << id_lammps_[0]<< endl; + + + //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"); + if(nlocal_lammps_>0){ + pos_lammps_ = (double **) lammps_extract_atom(lmp,"x"); + }else{ + // might use the fct from dataExchangeModel mother class + pos_lammps_ = new double*[1]; + pos_lammps_[0] = new double [1]; + pos_lammps_[0][0] = 0; + } } else { // re-arrange data using map - Foam::dataExchangeModel::allocateArray(id_lammps_sync,-1.,nlocal_lammps_); // probably not necessary - id_lammps_sync = (int *) lammps_extract_atom(lmp,"id"); - - delete [] id_lammps_vec_; + //Foam::dataExchangeModel::allocateArray(id_lammps_sync,-1.,nlocal_lammps_); // probably not necessary + if(nlocal_lammps_>0){ + id_lammps_sync = (int *) lammps_extract_atom(lmp,"id"); + }else{ + // might use the fct from dataExchangeModel mother class + id_lammps_sync=new int[1]; + id_lammps_sync[0]=10; + } + //extract_save(id_lammps_sync,"id"); // in future it should look like this!!! 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++) @@ -404,13 +435,22 @@ void Foam::twoWayM2M::syncIDs() const foam2lmp_vec_->setup(nlocal_foam_*3,id_foam_vec_,nlocal_lammps_*3,id_lammps_vec_); // map data according to last TS - Foam::dataExchangeModel::allocateArray(id_lammps_,-1,nlocal_foam_); // probably not necessary + Foam::dataExchangeModel::allocateArray(id_lammps_,0,nlocal_foam_); 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"); - + if(nlocal_lammps_>0){ + pos_lammps_sync = (double **) lammps_extract_atom(lmp,"x"); + }else{ + // might use the fct from dataExchangeModel mother class + pos_lammps_sync = new double*[1]; + pos_lammps_sync[0] = new double [3]; + pos_lammps_sync[0][0] = 0; + pos_lammps_sync[0][1] = 0; + pos_lammps_sync[0][2] = 0; + } // find better solution here!!! + //Foam::dataExchangeModel::allocateArray(pos_lammps_,-1.,3,nlocal_foam_); + //lmp2foam_vec_->exchange(&(pos_lammps_sync[0][0]), &(pos_lammps_[0][0])); double** gugu; Foam::dataExchangeModel::allocateArray(gugu,-1.,3*nlocal_foam_,1); Foam::dataExchangeModel::allocateArray(pos_lammps_,-1.,3,nlocal_foam_); @@ -420,7 +460,6 @@ void Foam::twoWayM2M::syncIDs() const for (int i = 0; i < nlocal_foam_; i++) for (int j = 0; j < 3; j++) pos_lammps_[i][j]=gugu[0][i*3+j]; - } particleCloud_.clockM().stop("recv_DEM_ids"); @@ -458,6 +497,13 @@ void Foam::twoWayM2M::syncIDs() const Pout << couplingStep_ << "st nlocal_lammps_=" << nlocal_lammps_ << endl; Pout << couplingStep_ << "st nlocal_foam_=" << nlocal_foam_ << endl; + delete lmp2foam_; + delete lmp2foam_vec_; + delete foam2lmp_vec_; + lmp2foam_ = new Many2Many(MPI_COMM_WORLD); + lmp2foam_vec_ = new Many2Many(MPI_COMM_WORLD); + foam2lmp_vec_ = new Many2Many(MPI_COMM_WORLD); + // correct mapping particleCloud_.clockM().start(11,"setup_Comm"); if(firstRun_) @@ -484,21 +530,21 @@ void Foam::twoWayM2M::locateParticle() const if (particleCloud_.numberOfParticlesChanged()) { // these arrays will be to long, but we do not know their length a priori - delete[] id_foam_lost_; + //delete[] id_foam_lost_; Foam::dataExchangeModel::allocateArray(id_foam_lost_,0,nop); - delete [] lost_pos_; + //delete [] lost_pos_; Foam::dataExchangeModel::allocateArray(lost_pos_,0.,nop*3); - delete [] id_foam_; + //delete [] id_foam_; Foam::dataExchangeModel::allocateArray(id_foam_,0,nop); - delete [] id_foam_vec_; + //delete [] id_foam_vec_; Foam::dataExchangeModel::allocateArray(id_foam_vec_,0,nop*3); - delete [] cellID_foam_; + //delete [] cellID_foam_; Foam::dataExchangeModel::allocateArray(cellID_foam_,0,nop); - delete [] pos_foam_; + //delete [] pos_foam_; Foam::dataExchangeModel::allocateArray(pos_foam_,0,nop*3); } else @@ -524,13 +570,36 @@ void Foam::twoWayM2M::locateParticle() const particleCloud_.clockM().start(7,"locate_Stage1"); +/*//=============== + // move this to top level + const polyBoundaryMesh& pbm = particleCloud_.mesh().boundaryMesh(); + const globalMeshData& pData = particleCloud_.mesh().globalData(); // polyMesh??? + + // Which patches are processor patches + const labelList& procPatches = pData.processorPatches(); + + // Indexing of patches into the procPatches list + const labelList& procPatchIndices = pData.processorPatchIndices(); + + // Which processors this processor is connected to + const labelList& neighbourProcs = pData[Pstream::myProcNo()]; + + // Indexing from the processor number into the neighbourProcs list + labelList neighbourProcIndices(Pstream::nProcs(), -1); + + forAll(neighbourProcs, i) + { + neighbourProcIndices[neighbourProcs[i]] = i; + } + + List< DynamicList > particleTransferLists(neighbourProcs.size()); +//===============*/ + for (int i = 0; i < iterate; i++) { pos = vector(pos_lammps_[i][0],pos_lammps_[i][1],pos_lammps_[i][2]); searchCellID = -1; - //Pout << "stage1 looking for particle pos="<< pos << endl; cellID = particleCloud_.locateM().findSingleCell(pos,searchCellID); - point oldPos(pos_foam_[nlocal_foam_*3+0],pos_foam_[nlocal_foam_*3+1],pos_foam_[nlocal_foam_*3+2]); // found particle on cfd proc @@ -552,6 +621,7 @@ void Foam::twoWayM2M::locateParticle() const } else { + //----------------- id_foam_lost_[nlocal_foam_lost_] = id_lammps_[i]; for (int j=0; j<3; j++) @@ -559,89 +629,53 @@ void Foam::twoWayM2M::locateParticle() const nlocal_foam_lost_ += 1; //Pout << couplingStep_ << "st cellID="<< cellID << " lost particle id="<< id_lammps_[i] <<" at pos=" << pos << endl; - - // find out where particle has migrated (must have passed a CFD proc border) - /*point newPos=pos; + //----------------- + /*// find out where particle has migrated (must have passed a CFD proc border) + point newPos=pos; label nearestFace = particleCloud_.locateM().intersection(oldPos,newPos); Pout << "nearest face=" << nearestFace << endl; + // If we hit a boundary face if (nearestFace >= particleCloud_.mesh().nInternalFaces()) { Pout << " face=" << nearestFace << " , is a boundary face!" << endl; - }*/ + label patchI = pbm.whichPatch(nearestFace); -/* // probably useful proc stuff from Cloud.C - - const polyBoundaryMesh& pbm = pMesh().boundaryMesh(); - const globalMeshData& pData = polyMesh_.globalData(); - - // Which patches are processor patches - const labelList& procPatches = pData.processorPatches(); - - // Indexing of patches into the procPatches list - const labelList& procPatchIndices = pData.processorPatchIndices(); - - // Indexing of equivalent patch on neighbour processor into the - // procPatches list on the neighbour - const labelList& procPatchNeighbours = pData.processorPatchNeighbours(); - - // Which processors this processor is connected to - const labelList& neighbourProcs = pData[Pstream::myProcNo()]; - - // Indexing from the processor number into the neighbourProcs list - labelList neighbourProcIndices(Pstream::nProcs(), -1); - - forAll(neighbourProcs, i) - { - neighbourProcIndices[neighbourProcs[i]] = i; - } - - - - // If we are running in parallel and the particle is on a - // boundary face - if (Pstream::parRun() && p.face() >= pMesh().nInternalFaces()) + // ... and the face is on a processor patch + // prepare it for transfer + if (procPatchIndices[patchI] != -1) { - label patchI = pbm.whichPatch(p.face()); - - // ... and the face is on a processor patch - // prepare it for transfer - if (procPatchIndices[patchI] != -1) - { - label n = neighbourProcIndices - [ - refCast - ( - pbm[patchI] - ).neighbProcNo() - ]; - - p.prepareForParallelTransfer(patchI, td); - - particleTransferLists[n].append(this->remove(&p)); - - patchIndexTransferLists[n].append + Pout << " face=" << nearestFace << " , is a proc face!" << endl; + label n = neighbourProcIndices + [ + refCast ( - procPatchNeighbours[patchI] - ); - } + pbm[patchI] + ).neighbProcNo() + ]; + Pout << " communicate to n=" << n << endl; + particleTransferLists[n].append(id_lammps_[i]); } -*/ + }*/ + //----------------- } } + + /*forAll(particleTransferLists, i) + { + forAll(particleTransferLists[i],j) + { + Pout << "communicate particle i="<< particleTransferLists[i][j]<<" to proc "<< i << endl; + } + }*/ + particleCloud_.clockM().stop("locate_Stage1"); // 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; @@ -720,15 +754,24 @@ int gugu; MPI_Allreduce(&nlocal_lammps_, &gugu, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); Info << "nlocal_lammps_ALL=" << gugu << endl;*/ - delete[] id_foam_nowhere_all; - delete[] id_foam_lost_all; - delete[] lost_pos_all; + //delete[] id_foam_nowhere_all; + //delete[] id_foam_lost_all; + //delete[] lost_pos_all; } -void Foam::twoWayM2M::exchange(double* demDat, double* cfdDat) const +/*void Foam::twoWayM2M::exchange(double* demDat, double* cfdDat) const { lmp2foam_->exchange(demDat,cfdDat);//(pos_lammps,pos_foam); -} +}*/ + +/*template +T*& Foam::twoWayM2M::extract_save(T *& a,char name) +{ + a = (T *) lammps_extract_atom(lmp,name); + if(!a) + a=new T[1]; + return a;//static_const(a); +}*/ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.H b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.H index 8c9be08b..e27f32a7 100644 --- a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.H +++ b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayM2M/twoWayM2M.H @@ -90,9 +90,9 @@ private: // new vars mutable bool firstRun_; - mutable Many2Many *lmp2foam_; - mutable Many2Many *lmp2foam_vec_; - mutable Many2Many *foam2lmp_vec_; + mutable Many2Many * lmp2foam_; + mutable Many2Many * lmp2foam_vec_; + mutable Many2Many * foam2lmp_vec_; mutable int nlocal_lammps_; mutable int *id_lammps_; //mutable int *id_lammpsComm_; @@ -191,7 +191,9 @@ public: void syncIDs() const; void locateParticle() const; - void exchange(double*,double*) const; + //void exchange(double*,double*) const; + //template + //T*& extract_save(T *& a,char name); };