22 #ifndef OPM_REDISTRIBUTEDATAHANDLES_HEADER
23 #define OPM_REDISTRIBUTEDATAHANDLES_HEADER
25 #include <opm/core/simulator/BlackoilState.hpp>
30 #include<boost/any.hpp>
37 EclipseStateConstPtr ,
46 #if HAVE_DUNE_CORNERPOINT
47 class GeologyDataHandle
52 typedef double DataType;
58 GeologyDataHandle(
const Dune::CpGrid& sendGrid,
59 const Dune::CpGrid& recvGrid,
60 const DerivedGeology& sendGeology,
61 DerivedGeology& recvGeology)
62 : sendGrid_(sendGrid), recvGrid_(recvGrid), sendGeology_(sendGeology),
63 recvGeology_(recvGeology)
66 bool fixedsize(
int ,
int )
71 std::size_t size(
const T& e)
73 if ( T::codimension == 0)
75 return 1 + sendGrid_.numCellFaces(e.index());
79 OPM_THROW(std::logic_error,
"Data handle can only be used for elements");
82 template<
class B,
class T>
83 void gather(B& buffer,
const T& e)
85 assert( T::codimension == 0);
86 buffer.write(sendGeology_.poreVolume()[e.index()]);
87 for (
int i=0; i< sendGrid_.numCellFaces(e.index()); ++i )
89 buffer.write(sendGeology_.transmissibility()[sendGrid_.cellFace(e.index(), i)]);
92 template<
class B,
class T>
93 void scatter(B& buffer,
const T& e, std::size_t )
95 assert( T::codimension == 0);
98 recvGeology_.poreVolume()[e.index()]=val;
99 for (
int i=0; i< recvGrid_.numCellFaces(e.index()); ++i )
102 recvGeology_.transmissibility()[recvGrid_.cellFace(e.index(), i)]=val;
105 bool contains(
int dim,
int codim)
107 return dim==3 && codim==0;
111 const Dune::CpGrid& sendGrid_;
113 const Dune::CpGrid& recvGrid_;
115 const DerivedGeology& sendGeology_;
117 DerivedGeology& recvGeology_;
121 class BlackoilStateDataHandle
125 typedef double DataType;
131 BlackoilStateDataHandle(
const Dune::CpGrid& sendGrid,
132 const Dune::CpGrid& recvGrid,
133 const BlackoilState& sendState,
134 BlackoilState& recvState)
135 : sendGrid_(sendGrid), recvGrid_(recvGrid), sendState_(sendState), recvState_(recvState)
138 bool fixedsize(
int ,
int )
144 std::size_t size(
const T& e)
146 if ( T::codimension == 0)
148 return 2 * sendState_.numPhases() +4+2*sendGrid_.numCellFaces(e.index());
152 OPM_THROW(std::logic_error,
"Data handle can only be used for elements");
156 template<
class B,
class T>
157 void gather(B& buffer,
const T& e)
159 assert( T::codimension == 0);
161 for (
int i=0; i<sendState_.numPhases(); ++i )
163 buffer.write(sendState_.surfacevol()[e.index()*sendState_.numPhases()+i]);
165 buffer.write(sendState_.gasoilratio()[e.index()]);
166 buffer.write(sendState_.rv()[e.index()]);
167 buffer.write(sendState_.pressure()[e.index()]);
168 buffer.write(sendState_.temperature()[e.index()]);
169 for (
int i=0; i<sendState_.numPhases(); ++i )
171 buffer.write(sendState_.saturation()[e.index()*sendState_.numPhases()+i]);
173 for (
int i=0; i<sendGrid_.numCellFaces(e.index()); ++i )
175 buffer.write(sendState_.facepressure()[sendGrid_.cellFace(e.index(), i)]);
177 for (
int i=0; i<sendGrid_.numCellFaces(e.index()); ++i )
179 buffer.write(sendState_.faceflux()[sendGrid_.cellFace(e.index(), i)]);
182 template<
class B,
class T>
183 void scatter(B& buffer,
const T& e, std::size_t size_arg)
185 assert( T::codimension == 0);
186 assert(
int(size_arg) == 2 * recvState_.numPhases() +4+2*recvGrid_.numCellFaces(e.index()));
187 static_cast<void>(size_arg);
190 for (
int i=0; i<recvState_.numPhases(); ++i )
193 recvState_.surfacevol()[e.index()*sendState_.numPhases()+i]=val;
196 recvState_.gasoilratio()[e.index()]=val;
198 recvState_.rv()[e.index()]=val;
200 recvState_.pressure()[e.index()]=val;
202 recvState_.temperature()[e.index()]=val;
203 for (
int i=0; i<recvState_.numPhases(); ++i )
206 recvState_.saturation()[e.index()*sendState_.numPhases()+i]=val;
208 for (
int i=0; i<recvGrid_.numCellFaces(e.index()); ++i )
211 recvState_.facepressure()[recvGrid_.cellFace(e.index(), i)]=val;
213 for (
int i=0; i<recvGrid_.numCellFaces(e.index()); ++i )
216 recvState_.faceflux()[recvGrid_.cellFace(e.index(), i)]=val;
219 bool contains(
int dim,
int codim)
221 return dim==3 && codim==0;
225 const Dune::CpGrid& sendGrid_;
227 const Dune::CpGrid& recvGrid_;
229 const BlackoilState& sendState_;
231 BlackoilState& recvState_;
234 class BlackoilPropsDataHandle
238 typedef double DataType;
242 BlackoilPropsDataHandle(
const BlackoilPropsAdFromDeck& sendProps,
243 BlackoilPropsAdFromDeck& recvProps)
244 : sendProps_(sendProps), recvProps_(recvProps),
249 if ( sendProps.satOilMax_.size()>0 )
251 recvProps_.satOilMax_.resize(recvProps_.cellPvtRegionIdx_.size(),
252 -std::numeric_limits<double>::max());
257 bool fixedsize(
int ,
int )
263 std::size_t size(
const T&)
265 if ( T::codimension == 0)
272 OPM_THROW(std::logic_error,
"Data handle can only be used for elements");
275 template<
class B,
class T>
276 void gather(B& buffer,
const T& e)
278 assert( T::codimension == 0);
280 buffer.write(sendProps_.cellPvtRegionIndex()[e.index()]);
282 buffer.write(sendProps_.satOilMax_[e.index()]);
285 template<
class B,
class T>
286 void scatter(B& buffer,
const T& e, std::size_t size_arg)
288 assert( T::codimension == 0);
289 assert( size_arg==size_ ); (void) size_arg;
292 recvProps_.cellPvtRegionIdx_[e.index()]=val;
295 recvProps_.satOilMax_[e.index()]=val;
298 bool contains(
int dim,
int codim)
300 return dim==3 && codim==0;
304 const BlackoilPropsAdFromDeck& sendProps_;
306 BlackoilPropsAdFromDeck& recvProps_;
312 EclipseStateConstPtr eclipseState,
313 BlackoilState& state,
314 BlackoilPropsAdFromDeck& properties,
315 DerivedGeology& geology,
316 boost::any& parallelInformation,
317 const bool useLocalPerm)
319 BlackoilState distributed_state;
321 Dune::CpGrid global_grid ( grid );
322 global_grid.switchToGlobalView();
325 grid.loadBalance(eclipseState);
326 grid.switchToDistributedView();
328 BlackoilPropsAdFromDeck distributed_props(properties, grid.numCells());
329 distributed_state.init(grid.numCells(), grid.numFaces(), state.numPhases());
331 distributed_state.surfacevol().resize(grid.numCells()*state.numPhases(),
332 std::numeric_limits<double>::max());
333 BlackoilStateDataHandle state_handle(global_grid, grid,
334 state, distributed_state);
335 BlackoilPropsDataHandle props_handle(properties,
337 grid.scatterData(state_handle);
338 grid.scatterData(props_handle);
341 DerivedGeology distributed_geology(grid,
342 distributed_props, eclipseState,
343 useLocalPerm, geology.gravity());
344 GeologyDataHandle geo_handle(global_grid, grid,
345 geology, distributed_geology);
346 grid.scatterData(geo_handle);
349 properties = distributed_props;
350 geology = distributed_geology;
351 state = distributed_state;
353 extractParallelGridInformationToISTL(grid, parallelInformation);
Definition: GeoProps.hpp:53
Definition: AdditionalObjectDeleter.hpp:22
Definition: BlackoilPropsAdFromDeck.hpp:58
void distributeGridAndData(Grid &, EclipseStateConstPtr, BlackoilState &, BlackoilPropsAdFromDeck &, DerivedGeology &, boost::any &, const bool)
Definition: RedistributeDataHandles.hpp:36