vtf-logo

BeamELCCoupledSolver.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2003-2007 California Institute of Technology
00004 // Ralf Deiterding, ralf@amroc.net
00005 
00006 #ifndef BEAM_ELC_COUPLED_SOLVER_H
00007 #define BEAM_ELC_COUPLED_SOLVER_H
00008 
00016 template <int dim> class BeamCoupledSolver;
00017 
00018 #include "BeamCoupledSolver2.h"
00019 #include "elc/LagrangianComm.h"
00020 
00027 template <int dim>
00028 class BeamELCCoupledSolver : public BeamCoupledSolver<dim> {
00029   typedef BeamCoupledSolver<dim> base;
00030 public:
00031   typedef elc::LagrangianComm<dim,double> elc_lagcomm_type;
00032 
00033   BeamELCCoupledSolver() : base(), _olog(0), _elcLag(0) {}
00034 
00035   virtual ~BeamELCCoupledSolver() {     
00036     if (_elcLag) delete _elcLag;
00037     if (_olog) delete _olog;
00038   }
00039 
00040   void SetupInterComm(MPI_Comm solidComm, int numFluidNodes, int firstFluidNode) {
00041     MPI_Comm_rank(solidComm, &myRank);
00042 #ifdef DEBUG_PRINT
00043     std::ostringstream obuf;
00044     obuf << "S" << myRank << ".log" << static_cast<char>(0);
00045     oflog.open(obuf.str().c_str());     
00046     _olog = new std::ostream(oflog.rdbuf());
00047 #endif
00048 
00049 #ifdef DEBUG_PRINT_ELC
00050     ( log() << "*** LagrangianComm: " << numFluidNodes << "  " << firstFluidNode ).flush();
00051 #endif  
00052     // instantiate an elc object for data exchange
00053     _elcLag = new elc_lagcomm_type(MPI_COMM_WORLD, solidComm, numFluidNodes,
00054                                    firstFluidNode, elc::GlobalIdentifiers);
00055 #ifdef DEBUG_PRINT_ELC
00056     ( log() << " created.\n").flush();
00057 #endif  
00058   }
00059 
00060   virtual void sendBoundaryReceivePressure() {
00061 
00062     int elNumNodes = base::NumNodes();
00063     int elNumElements = base::NumElements();
00064     double *elPressures = base::Pressures();
00065     const int* elGlobalNodeIDs = base::NodeIDs();
00066     const int* elConnectivity = base::Connections();
00067     const double* elCoordinates = base::Coordinates();
00068     const double* elVelocities = base::Velocities();
00069     base::UpdateBoundary();
00070 #ifdef DEBUG_PRINT_ELC_VALUES
00071     for (register int n=0; n<elNumNodes; n++) 
00072       ( log() << "(" << elCoordinates[2*n] << "," 
00073         << elCoordinates[2*n+1] << ")  " ).flush();
00074     ( log() << std::endl ).flush();
00075 #endif
00076 
00077 #ifdef DEBUG_PRINT_ELC
00078     ( log() << "*** BeamCoupledSolver::sendBoundaryReceivePressure" ).flush();
00079 #endif
00080         
00081     _elcLag->sendMesh(elNumNodes, reinterpret_cast<const void*>(elGlobalNodeIDs), 
00082                       reinterpret_cast<const void*>(elCoordinates), 
00083                       reinterpret_cast<const void*>(elVelocities), 
00084                       elNumElements, reinterpret_cast<const void*>(elConnectivity));
00085     _elcLag->waitForMesh();
00086     _elcLag->receivePressure(elNumNodes, reinterpret_cast<void*>(elPressures));
00087     _elcLag->waitForPressure();
00088     // Necessary if solid domain larger than fluid domain
00089     for (register int n=0; n<elNumNodes; n++) 
00090       if (elPressures[n] == std::numeric_limits<double>::max()) 
00091         elPressures[n] = 0.0;
00092 #ifdef DEBUG_PRINT_ELC_VALUES
00093     for (register int n=0; n<elNumNodes; n++) 
00094       ( log() << elPressures[n] << "  " ).flush();
00095     ( log() << std::endl ).flush();
00096 #endif
00097     
00098 #ifdef DEBUG_PRINT_ELC
00099     ( log() << " done.\n" ).flush();
00100 #endif
00101   }
00102 
00103   inline std::ostream& log() { return *_olog; }
00104 
00105 protected:
00106   std::ostream* _olog;
00107   std::ofstream oflog; 
00108   int myRank;
00109   elc_lagcomm_type* _elcLag;
00110 };
00111 
00112 #endif

Generated on Fri Aug 24 13:01:04 2007 for AMROC's Beam solver - by  doxygen 1.4.7