Page MenuHomec4science

compute_interface.hh
No OneTemporary

File Metadata

Created
Sun, Jun 2, 23:27

compute_interface.hh

/**
* @file compute_interface.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Mon Oct 28 19:23:14 2013
*
* @brief This is the interface of all computes
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale is free software: you can redistribute it and/or modify it
* under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* LibMultiScale 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LIBMULTISCALE_COMPUTE_INTERFACE_HH__
#define __LIBMULTISCALE_COMPUTE_INTERFACE_HH__
/* -------------------------------------------------------------------------- */
#include "container_array.hh"
#include "filter_interface.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
class ComputeInterface : public virtual FilterInterface,
public virtual ContainerArray<Real> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
ComputeInterface(const std::string &name);
virtual ~ComputeInterface();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
//! gather result routine
std::vector<Real> &gatherData(UInt source_rank, UInt root_rank = 0);
//! gather all other processor result routine
std::vector<Real> &gatherAllData(UInt root_rank = 0);
//! all gather result routine
std::vector<Real> &allGatherAllData();
//! return the total number of elements (parallel safe)
UInt getTotalNbData(UInt root_rank = 0);
//! get an item from its computed name
virtual Real &operator()(const std::string &name, UInt index = 0) {
std::vector<std::string>::iterator it;
it = find(name_computed.begin(), name_computed.end(), name);
if (it == name_computed.end()) {
LM_FATAL("Name computed '" << name << "' not found");
} else {
UInt position = it - name_computed.begin();
LM_FATAL("temp " << position);
}
}
void setDim(UInt dim) { LM_TOIMPLEMENT; };
UInt getDim() { LM_TOIMPLEMENT; };
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
std::vector<std::string> name_computed;
//! vector for gather routine usage
std::vector<Real> data_gather;
//! vector for receive counts on allGatherAllData.
std::vector<int> rcnts;
//! flag specifying that input data was gathered(for python)
bool gather_flag;
//! processor number compute_python use to gather data
UInt gather_root_proc;
};
__END_LIBMULTISCALE__
#define DECLARE_COMPUTE(class_name) \
class_name(const std::string &name); \
virtual ~class_name(); \
\
void declareParams() override; \
void compute_make_call() override
#endif /* __LIBMULTISCALE_COMPUTE_INTERFACE_HH__ */

Event Timeline