Page MenuHomec4science

trace_atom.hh
No OneTemporary

File Metadata

Created
Mon, Aug 5, 05:19

trace_atom.hh

/**
* @file trace_atom.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Mon Oct 28 19:23:14 2013
*
* @brief Set of macros to trace an atom through processor migrations
*
* @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_TRACE_ATOM_H__
#define __LIBMULTISCALE_TRACE_ATOM_H__
/* -------------------------------------------------------------------------- */
#ifdef TRACE_ATOM
/* -------------------------------------------------------------------------- */
#include "lm_common.hh"
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
extern Real trace_ref[3];
extern Real trace_tolerance;
extern UInt internal_index;
__END_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
#define ATOM_OUT(X) "(" << X[0] << "," << X[1] << "," << X[2] << ")"
/* -------------------------------------------------------------------------- */
#define CHECK_TRACED(X) if (trace_ref[0]-trace_tolerance <= X[0] \
&& X[0] <= trace_ref[0] + trace_tolerance \
&& trace_ref[1]-trace_tolerance <= X[1] \
&& X[1] <= trace_ref[1] + trace_tolerance \
&& trace_ref[2]-trace_tolerance <= X[2] \
&& X[2] <= trace_ref[2] + trace_tolerance )
/* -------------------------------------------------------------------------- */
#define CHECK_REF_TRACED(ref) \
Real tmp_pos[3]; ref.getPositions0(tmp_pos); \
CHECK_TRACED(tmp_pos)
/* -------------------------------------------------------------------------- */
#define IF_COORD_EQUALS(x1,x2) \
if (x1[0]-trace_tolerance <= x2[0] && x2[0] <= x1[0] + trace_tolerance && \
x1[1]-trace_tolerance <= x2[1] && x2[1] <= x1[1] + trace_tolerance && \
x1[2]-trace_tolerance <= x2[2] && x2[2] <= x1[2] + trace_tolerance )
/* -------------------------------------------------------------------------- */
#define IF_TRACED(X,message) CHECK_TRACED(X) { \
DUMP(ATOM_OUT(X) << message,DBG_MESSAGE); \
}
/* -------------------------------------------------------------------------- */
#define IF_REF_TRACED(ref,message) CHECK_REF_TRACED(ref) { \
DUMP(ref << " " << message,DBG_MESSAGE); \
}
/* -------------------------------------------------------------------------- */
#define VIEW_ATOM(T) { \
if (internal_index != UINT_MAX){ \
T ref(internal_index); \
DUMP("how is my atom now ? " << ref,DBG_MESSAGE); \
} \
else \
DUMP("my atom is not here ",DBG_MESSAGE); \
};
/* -------------------------------------------------------------------------- */
#define SET_INTERNAL_TRACE_INDEX(X,index) CHECK_TRACED(X) \
internal_index = index;
/* -------------------------------------------------------------------------- */
#define SET_REF_INTERNAL_TRACE_INDEX(ref,index) { \
CHECK_REF_TRACED(ref) \
internal_index = index; \
}
/* -------------------------------------------------------------------------- */
#else
#define IF_TRACED(X,message)
#define IF_REF_TRACED(ref,message)
#define VIEW_ATOM(T)
#define CHECK_TRACED(X) if (1 == 2)
#define CHECK_REF_TRACED(X) if (1 == 2)
#define IF_COORD_EQUALS(x1,x2)
#define SET_INTERNAL_TRACE_INDEX(X,index)
#define SET_REF_INTERNAL_TRACE_INDEX(ref,index)
#endif
/* -------------------------------------------------------------------------- */
#endif /* __LIBMULTISCALE_TRACE_ATOM_H__ */

Event Timeline