Page MenuHomec4science

compute_lgfm.cc
No OneTemporary

File Metadata

Created
Sat, Sep 7, 06:51

compute_lgfm.cc

/**
* @file compute_dd_displacement.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Max Hodapp <max.hodapp@epfl.ch>
*
* @brief This compute allows to compute stresses due to force
* and displacements at a generic interface.
*
* @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/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "compute_lgfm.hh"
#include "communicator.hh"
#include "domain_dd_interface.hh"
#include "domain_multiscale.hh"
#include "lib_continuum.hh"
#include "lib_dd.hh"
#include "lib_md.hh"
#include "lm_common.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
ComputeLGFM::ComputeLGFM(const LMID &id) : LMObject(id) {
this->removeInput("input1");
this->createInput("sources");
this->createInput("stress_points");
}
/* -------------------------------------------------------------------------- */
ComputeLGFM::~ComputeLGFM() {}
/* -------------------------------------------------------------------------- */
template <typename ContainerSources, typename ContainerField>
void ComputeLGFM::build(ContainerSources &cont_sources, ContainerField &cont_stress_points) {
// iteration over sources and copy in a contiguous array
// example for flat array
std::vector<Real> flat_positions;
for (auto && p: cont_sources){
auto pos = p.position0();
for(UInt i = 0; i<spatial_dimension; ++i)
flat_positions.push_back(pos[i]);
}
// example for vector array
std::vector<Vector<3>> vector_positions;
for (auto && p: cont_sources){
auto pos = p.position0();
vector_positions.push_back(pos);
}
// the contiguous array pointer is
// Real * ptr = (Real*)&vector_positions[0];
// iteration over stress points or fetch of pointer
// call to LGFM library
// LGFM::compute(ptr);
// get the result: a pointer to a contiguous space
// wrap a Libmultiscale container around that pointer => make it the output of the compute
}
/* -------------------------------------------------------------------------- */
/* LMDESC LGFM
Calculate DD displacements at fieldpoints defined by INPUT.
*/
/* LMEXAMPLE
COMPUTE stress LGFM INPUT sources=points stress_points=where
*/
inline void ComputeLGFM::declareParams() {
ComputeInterface::declareParams();
};
/* -------------------------------------------------------------------------- */
void ComputeLGFM::compute_make_call() {
DUMP(this->getID() << ": Compute", DBG_INFO);
call_compute(*this, [&](auto &... args) { this->build(args...); },
this->getInput("sources"), this->getInput("stress_points"));
}
__END_LIBMULTISCALE__

Event Timeline