Ice Sheet System Model  4.18
Code documentation
Public Member Functions | Data Fields
Cfsurfacesquare Class Reference

#include <Cfsurfacesquare.h>

Inheritance diagram for Cfsurfacesquare:
Object Definition

Public Member Functions

 Cfsurfacesquare ()
 
 Cfsurfacesquare (char *in_name, int in_definitionenum, int in_model_enum, int in_observation_enum, int in_weights_enum, IssmDouble in_datatime, bool timepassedflag)
 
 ~Cfsurfacesquare ()
 
Objectcopy ()
 
void DeepEcho (void)
 
void Echo (void)
 
int Id (void)
 
void Marshall (char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
 
int ObjectEnum (void)
 
int DefinitionEnum ()
 
char * Name ()
 
IssmDouble Response (FemModel *femmodel)
 
IssmDouble Cfsurfacesquare_Calculation (Element *element, int model_enum, int observation_enum, int weights_enum)
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
- Public Member Functions inherited from Definition
virtual ~Definition ()
 

Data Fields

int definitionenum
 
int local
 
int model_enum
 
char * name
 
int observation_enum
 
char * timeinterpolation
 
int weights_enum
 
IssmDouble datatime
 
bool timepassedflag
 
IssmDouble last_time
 
int lock
 
IssmDouble misfit
 

Detailed Description

Definition at line 15 of file Cfsurfacesquare.h.

Constructor & Destructor Documentation

◆ Cfsurfacesquare() [1/2]

Cfsurfacesquare::Cfsurfacesquare ( )

Definition at line 27 of file Cfsurfacesquare.cpp.

27  {/*{{{*/
28 
29  this->definitionenum = -1;
30  this->name = NULL;
31  this->model_enum = UNDEF;
32  this->observation_enum = UNDEF;
33  this->weights_enum = UNDEF;
34  this->misfit=0;
35  this->lock=0;
36  this->datatime=0.;
37  this->timepassedflag = false;
38  this->last_time = 0.;
39 
40 }

◆ Cfsurfacesquare() [2/2]

Cfsurfacesquare::Cfsurfacesquare ( char *  in_name,
int  in_definitionenum,
int  in_model_enum,
int  in_observation_enum,
int  in_weights_enum,
IssmDouble  in_datatime,
bool  timepassedflag 
)

Definition at line 42 of file Cfsurfacesquare.cpp.

42  {/*{{{*/
43 
44  this->definitionenum=in_definitionenum;
45 
46  this->name = xNew<char>(strlen(in_name)+1);
47  xMemCpy<char>(this->name,in_name,strlen(in_name)+1);
48 
49  this->model_enum=in_model_enum;
50  this->observation_enum=in_observation_enum;
51  this->weights_enum=in_weights_enum;
52  this->datatime=in_datatime;
53  this->timepassedflag=in_timepassedflag;
54 
55  this->misfit=0;
56  this->lock=0;
57 }

◆ ~Cfsurfacesquare()

Cfsurfacesquare::~Cfsurfacesquare ( )

Definition at line 59 of file Cfsurfacesquare.cpp.

59  {/*{{{*/
60  if(this->name)xDelete(this->name);
61  this->misfit=0;
62  this->lock=0;
63 }

Member Function Documentation

◆ copy()

Object * Cfsurfacesquare::copy ( void  )
virtual

Implements Object.

Definition at line 66 of file Cfsurfacesquare.cpp.

66  {/*{{{*/
68  mf->misfit=this->misfit;
69  mf->lock=this->lock;
70  return (Object*) mf;
71 }

◆ DeepEcho()

void Cfsurfacesquare::DeepEcho ( void  )
virtual

Implements Object.

Definition at line 73 of file Cfsurfacesquare.cpp.

73  {/*{{{*/
74  this->Echo();
75 }

◆ Echo()

void Cfsurfacesquare::Echo ( void  )
virtual

Implements Object.

Definition at line 77 of file Cfsurfacesquare.cpp.

77  {/*{{{*/
78  _printf_(" Cfsurfacesquare: " << name << " " << this->definitionenum << "\n");
79  _printf_(" model_enum: " << model_enum << " " << EnumToStringx(model_enum) << "\n");
80  _printf_(" observation_enum: " << observation_enum << " " << EnumToStringx(observation_enum) << "\n");
81  _printf_(" weights_enum: " << weights_enum << " " << EnumToStringx(weights_enum) << "\n");
82  _printf_(" datatime: " << datatime << "\n");
83  _printf_(" timepassedflag: "<<timepassedflag<<"\n");
84 }

◆ Id()

int Cfsurfacesquare::Id ( void  )
virtual

Implements Object.

Definition at line 86 of file Cfsurfacesquare.cpp.

86  {/*{{{*/
87  return -1;
88 }

◆ Marshall()

void Cfsurfacesquare::Marshall ( char **  pmarshalled_data,
int *  pmarshalled_data_size,
int  marshall_direction 
)
virtual

Implements Object.

Definition at line 90 of file Cfsurfacesquare.cpp.

90  {/*{{{*/
91  _error_("not implemented yet!");
92 }

◆ ObjectEnum()

int Cfsurfacesquare::ObjectEnum ( void  )
virtual

Implements Object.

Definition at line 94 of file Cfsurfacesquare.cpp.

94  {/*{{{*/
95  return CfsurfacesquareEnum;
96 }

◆ DefinitionEnum()

int Cfsurfacesquare::DefinitionEnum ( )
virtual

Implements Definition.

Definition at line 99 of file Cfsurfacesquare.cpp.

99  {/*{{{*/
100  return this->definitionenum;
101 }

◆ Name()

char * Cfsurfacesquare::Name ( )
virtual

Implements Definition.

Definition at line 103 of file Cfsurfacesquare.cpp.

103  {/*{{{*/
104  char* name2=xNew<char>(strlen(this->name)+1);
105  xMemCpy(name2,this->name,strlen(this->name)+1);
106 
107  return name2;
108 }

◆ Response()

IssmDouble Cfsurfacesquare::Response ( FemModel femmodel)
virtual

Implements Definition.

Definition at line 110 of file Cfsurfacesquare.cpp.

110  {/*{{{*/
111  /*diverse: */
112  IssmDouble time;
113 
114  /*recover time parameters: */
116  if(time < last_time) timepassedflag = false;
117  last_time = time;
118 
119  int i;
120  IssmDouble J=0.;
121  IssmDouble J_sum=0.;
122 
123  if(datatime<=time && !timepassedflag){
124  for(i=0;i<femmodel->elements->Size();i++){
127  }
128 
129  ISSM_MPI_Allreduce ( (void*)&J,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
131  J=J_sum;
132 
133  timepassedflag = true;
134  return J;
135  }
136  else return J;
137  }

◆ Cfsurfacesquare_Calculation()

IssmDouble Cfsurfacesquare::Cfsurfacesquare_Calculation ( Element element,
int  model_enum,
int  observation_enum,
int  weights_enum 
)

Definition at line 139 of file Cfsurfacesquare.cpp.

139  {/*{{{*/
140 
141  int domaintype,numcomponents;
142  IssmDouble Jelem=0.;
143  IssmDouble misfit,Jdet;
144  IssmDouble model,obs,weight;
145  IssmDouble* xyz_list = NULL;
146 
147  /*Get basal element*/
148  if(!element->IsOnSurface()) return 0.;
149 
150  /*If on water, return 0: */
151  if(!element->IsIceInElement()) return 0.;
152 
153  /*Get problem dimension*/
154  element->FindParam(&domaintype,DomainTypeEnum);
155  switch(domaintype){
156  case Domain2DverticalEnum: numcomponents = 1; break;
157  case Domain3DEnum: numcomponents = 2; break;
158  case Domain2DhorizontalEnum: numcomponents = 2; break;
159  default: _error_("not supported yet");
160  }
161 
162  /*Spawn surface element*/
163  Element* topelement = element->SpawnTopElement();
164 
165  /* Get node coordinates*/
166  topelement->GetVerticesCoordinates(&xyz_list);
167 
168  /*Retrieve all inputs we will be needing: */
169  DatasetInput2 *datasetinput = topelement->GetDatasetInput2(definitionenum); _assert_(datasetinput);
170  Input2 *model_input = topelement->GetInput2(model_enum); _assert_(model_input);
171 
172  /* Start looping on the number of gaussian points: */
173  Gauss* gauss=topelement->NewGauss(2);
174  for(int ig=gauss->begin();ig<gauss->end();ig++){
175 
176  gauss->GaussPoint(ig);
177 
178  /* Get Jacobian determinant: */
179  topelement->JacobianDeterminant(&Jdet,xyz_list,gauss);
180 
181  /*Get all parameters at gaussian point*/
182  datasetinput->GetInputValue(&weight,gauss,WeightsSurfaceObservationEnum);
183  model_input->GetInputValue(&model,gauss);
184  datasetinput->GetInputValue(&obs,gauss,SurfaceObservationEnum);
185 
186  /*Compute SurfaceAbsVelMisfitEnum:
187  * *
188  * * 1 [ 2 2 ]
189  * * J = --- | (u - u ) + (v - v ) |
190  * * 2 [ obs obs ]
191  * *
192  * */
193  misfit=0.5*(model-obs)*(model-obs);
194 
195  /*Add to cost function*/
196  Jelem+=misfit*weight*Jdet*gauss->weight;
197  }
198 
199  /*clean up and Return: */
200  if(domaintype!=Domain2DhorizontalEnum){topelement->DeleteMaterials(); delete topelement;};
201  xDelete<IssmDouble>(xyz_list);
202  delete gauss;
203  return Jelem;
204 }/*}}}*/

Field Documentation

◆ definitionenum

int Cfsurfacesquare::definitionenum

Definition at line 19 of file Cfsurfacesquare.h.

◆ local

int Cfsurfacesquare::local

Definition at line 20 of file Cfsurfacesquare.h.

◆ model_enum

int Cfsurfacesquare::model_enum

Definition at line 21 of file Cfsurfacesquare.h.

◆ name

char* Cfsurfacesquare::name

Definition at line 22 of file Cfsurfacesquare.h.

◆ observation_enum

int Cfsurfacesquare::observation_enum

Definition at line 23 of file Cfsurfacesquare.h.

◆ timeinterpolation

char* Cfsurfacesquare::timeinterpolation

Definition at line 24 of file Cfsurfacesquare.h.

◆ weights_enum

int Cfsurfacesquare::weights_enum

Definition at line 25 of file Cfsurfacesquare.h.

◆ datatime

IssmDouble Cfsurfacesquare::datatime

Definition at line 26 of file Cfsurfacesquare.h.

◆ timepassedflag

bool Cfsurfacesquare::timepassedflag

Definition at line 27 of file Cfsurfacesquare.h.

◆ last_time

IssmDouble Cfsurfacesquare::last_time

Definition at line 28 of file Cfsurfacesquare.h.

◆ lock

int Cfsurfacesquare::lock

Definition at line 30 of file Cfsurfacesquare.h.

◆ misfit

IssmDouble Cfsurfacesquare::misfit

Definition at line 31 of file Cfsurfacesquare.h.


The documentation for this class was generated from the following files:
DataSet::Size
int Size()
Definition: DataSet.cpp:399
SurfaceObservationEnum
@ SurfaceObservationEnum
Definition: EnumDefinitions.h:827
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
IssmDouble
double IssmDouble
Definition: types.h:37
DatasetInput2
Definition: DatasetInput2.h:14
ISSM_MPI_Allreduce
int ISSM_MPI_Allreduce(void *sendbuf, void *recvbuf, int count, ISSM_MPI_Datatype datatype, ISSM_MPI_Op op, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:116
Element::FindParam
void FindParam(bool *pvalue, int paramenum)
Definition: Element.cpp:933
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
Cfsurfacesquare::observation_enum
int observation_enum
Definition: Cfsurfacesquare.h:23
ISSM_MPI_SUM
#define ISSM_MPI_SUM
Definition: issmmpi.h:134
FemModel::parameters
Parameters * parameters
Definition: FemModel.h:46
TimeEnum
@ TimeEnum
Definition: EnumDefinitions.h:427
Cfsurfacesquare::Cfsurfacesquare_Calculation
IssmDouble Cfsurfacesquare_Calculation(Element *element, int model_enum, int observation_enum, int weights_enum)
Definition: Cfsurfacesquare.cpp:139
IssmComm::GetComm
static ISSM_MPI_Comm GetComm(void)
Definition: IssmComm.cpp:30
Cfsurfacesquare::datatime
IssmDouble datatime
Definition: Cfsurfacesquare.h:26
Cfsurfacesquare::model_enum
int model_enum
Definition: Cfsurfacesquare.h:21
DatasetInput2::GetInputValue
void GetInputValue(IssmDouble *pvalue, Gauss *gauss, int index)
Definition: DatasetInput2.cpp:199
Element::GetInput2
virtual Input2 * GetInput2(int inputenum)=0
Element::DeleteMaterials
void DeleteMaterials(void)
Definition: Element.cpp:429
Element
Definition: Element.h:41
Element::GetDatasetInput2
virtual DatasetInput2 * GetDatasetInput2(int inputenum)
Definition: Element.h:250
Domain2DhorizontalEnum
@ Domain2DhorizontalEnum
Definition: EnumDefinitions.h:534
ISSM_MPI_DOUBLE
#define ISSM_MPI_DOUBLE
Definition: issmmpi.h:125
Cfsurfacesquare::last_time
IssmDouble last_time
Definition: Cfsurfacesquare.h:28
Object
Definition: Object.h:13
DomainTypeEnum
@ DomainTypeEnum
Definition: EnumDefinitions.h:124
xDelete
void xDelete(T **&aT_pp)
Definition: MemOps.h:97
Element::NewGauss
virtual Gauss * NewGauss(void)=0
Cfsurfacesquare::timepassedflag
bool timepassedflag
Definition: Cfsurfacesquare.h:27
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
Cfsurfacesquare
Definition: Cfsurfacesquare.h:15
UNDEF
#define UNDEF
Definition: constants.h:8
Element::GetVerticesCoordinates
void GetVerticesCoordinates(IssmDouble **xyz_list)
Definition: Element.cpp:1446
Domain3DEnum
@ Domain3DEnum
Definition: EnumDefinitions.h:536
FemModel::elements
Elements * elements
Definition: FemModel.h:44
ISSM_MPI_Bcast
int ISSM_MPI_Bcast(void *buffer, int count, ISSM_MPI_Datatype datatype, int root, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:162
Cfsurfacesquare::Cfsurfacesquare
Cfsurfacesquare()
Definition: Cfsurfacesquare.cpp:27
Input2
Definition: Input2.h:18
Cfsurfacesquare::name
char * name
Definition: Cfsurfacesquare.h:22
Element::IsIceInElement
bool IsIceInElement()
Definition: Element.cpp:2021
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
CfsurfacesquareEnum
@ CfsurfacesquareEnum
Definition: EnumDefinitions.h:1007
Element::SpawnTopElement
virtual Element * SpawnTopElement(void)=0
Cfsurfacesquare::lock
int lock
Definition: Cfsurfacesquare.h:30
Cfsurfacesquare::weights_enum
int weights_enum
Definition: Cfsurfacesquare.h:25
Gauss::begin
virtual int begin(void)=0
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334
WeightsSurfaceObservationEnum
@ WeightsSurfaceObservationEnum
Definition: EnumDefinitions.h:864
Cfsurfacesquare::Echo
void Echo(void)
Definition: Cfsurfacesquare.cpp:77
Element::JacobianDeterminant
virtual void JacobianDeterminant(IssmDouble *Jdet, IssmDouble *xyz_list, Gauss *gauss)=0
Gauss::GaussPoint
virtual void GaussPoint(int ig)=0
Parameters::FindParam
void FindParam(bool *pinteger, int enum_type)
Definition: Parameters.cpp:262
Input2::GetInputValue
virtual void GetInputValue(IssmDouble *pvalue, Gauss *gauss)
Definition: Input2.h:38
Gauss::weight
IssmDouble weight
Definition: Gauss.h:11
Element::IsOnSurface
bool IsOnSurface()
Definition: Element.cpp:1981
xMemCpy
T * xMemCpy(T *dest, const T *src, unsigned int size)
Definition: MemOps.h:152
Cfsurfacesquare::misfit
IssmDouble misfit
Definition: Cfsurfacesquare.h:31
Cfsurfacesquare::definitionenum
int definitionenum
Definition: Cfsurfacesquare.h:19
Domain2DverticalEnum
@ Domain2DverticalEnum
Definition: EnumDefinitions.h:535
Gauss
Definition: Gauss.h:8
femmodel
FemModel * femmodel
Definition: esmfbinders.cpp:16